News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

XorData, RorData, and RolData

Started by paneselchino, June 07, 2013, 02:47:24 PM

Previous topic - Next topic

paneselchino

Can someone give examples of this functions I google them for a while, but I can't find something useful. Thanks in advanced

Adamanteus

 That's need exacting what's it doing, so first function bit filed operation, two last could supply copy bits algo.

paneselchino

Quote from: Adamanteus on June 07, 2013, 03:30:43 PM
That's need exacting what's it doing, so first function bit filed operation, two last could supply copy bits algo.
I need code man
like this:
.386
.model flat, stdcall
option casemap :none ; case sensitive
.nolist
include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
include \masm32\include\masm32.inc
.list
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\masm32.lib
.data
message DW 27
key DW 30
.code
inicio:
invoke XorData,addr message,sizeof message,addr key,sizeof key
end inicio

By the way this code isn't working

hutch--

It does not appear that you have read the help file on those algos. They all need another file to combine the data with, usually  a high quality random pad. XOR the second time to unencrypt the data using the identical pad, with the rotate algos, the first one used is decrypted with the second against the identical pad.

paneselchino

I just only need a example, a basic example, teach me with code :) , I read the help...

hutch--

We don't do requests here, show us what you have written.

dedndave

\masm32\help\masmlib.chm, under Encryption Components

your code might work, you just aren't looking at the results properly

but - try something a bit larger than words

hutch--

This should get you going.



IF 0  ; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
                      Build this template with "CONSOLE ASSEMBLE AND LINK"
ENDIF ; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

    include \masm32\include\masm32rt.inc

    .data
      srctxt db "I wanna encrypt this data",0   ; the data to encrypt
      thekey db "this is the key I will use",0  ; the KEY to encrypt it against
      lsrc dd sizeof srctxt                     ; the length of the source to encrypt
      lkey dd sizeof thekey                     ; the length of the key to encrypt against

    .code

start:
   
; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

    call main
    inkey
    exit

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

main proc

    print ADDR srctxt,13,10                     ; display the original string

    invoke XorData,OFFSET srctxt,lsrc,OFFSET thekey,lkey

    print ADDR srctxt,13,10                     ; display what you can of the encrypted string

    invoke XorData,OFFSET srctxt,lsrc,OFFSET thekey,lkey

    print ADDR srctxt,13,10                     ; display the string again after decrypting it

    ret

main endp

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

end start

hutch--

Something you should note when using these very simple algorithms, it is not the algorithm that gives you the encryption strength, it is the quality of the key or properly the PAD that you use to encrypt against. If it is a highly randomised pad it will be much harder to break and also note that in critical tasks the reusing the same pad makes it weaker each time. An amateur will not breqak it as the pad weakens but a pro will work it out if they need to.

dedndave

yah - a longer key is better
and, XorData on the data, then RolData on the key   :P

paneselchino


Thank you, you wasn't helpful, here is my code it read a string from keyboard and a key and that message get encrypt and decrypted.I'll leave it here since it was difficult to find information

Here is the code --hutch...
with XorData:

.386
.model flat, stdcall
option casemap :none ; case sensitive
.nolist
include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
include \masm32\include\masm32.inc


.list
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\masm32.lib

.data
mensaje1 DB "Digite un mensaje a encriptar ",0
mensaje2 DB "Digite llave de encriptacion ",0
mensaje3 DB "Mensaje Encriptado ",0
mensaje4 DB "Mensaje despues de desencriptar ",0
msj DB 127 DUP (0),0
key DB 127 DUP (0),0

.code
inicio:
invoke ClearScreen
invoke StdOut,ADDR mensaje1
invoke StdIn,ADDR msj,LENGTHOF msj
invoke StdOut,ADDR mensaje2
invoke StdIn,ADDR key,LENGTHOF key
invoke XorData,ADDR msj,LENGTHOF msj,ADDR key,LENGTHOF key
invoke StdOut,ADDR mensaje3
invoke StdOut,ADDR msj
invoke XorData,ADDR msj,LENGTHOF msj,addr key,LENGTHOF key
invoke StdOut,ADDR mensaje4
invoke StdOut,ADDR msj
invoke ExitProcess,0
end inicio

RorData and RolData

.386
.model flat, stdcall
option casemap :none ; case sensitive
.nolist
include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
include \masm32\include\masm32.inc


.list
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\masm32.lib

.data
mensaje1 DB "Digite un mensaje a encriptar ",0
mensaje2 DB "Digite llave de encriptacion ",0
mensaje3 DB "Mensaje Encriptado ",0
mensaje4 DB "Mensaje despues de desencriptar ",0
msj DB 127 DUP (0),0
key DB 127 DUP (0),0

.code
inicio:
invoke ClearScreen
invoke StdOut,ADDR mensaje1
invoke StdIn,ADDR msj,LENGTHOF msj
invoke StdOut,ADDR mensaje2
invoke StdIn,ADDR key,LENGTHOF key
invoke RolData,ADDR msj,LENGTHOF msj,ADDR key,LENGTHOF key
invoke StdOut,ADDR mensaje3
invoke StdOut,ADDR msj
invoke RorData,ADDR msj,LENGTHOF msj,addr key,LENGTHOF key
invoke StdOut,ADDR mensaje4
invoke StdOut,ADDR msj
invoke ExitProcess,0
end inicio

Greetings from El Salvador.