flat assembler
Message board for the users of flat assembler.

Index > Main > simple 32byte hashing

Author
Thread Post new topic Reply to topic
zxcv
Guest




zxcv
i need to make simple 32 bytes string of 0-1a-zA-Z. I used rand, and jumps, but its many code. Isd there a function under windows wich generate me a random string?
Post 15 Jan 2008, 03:06
Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17271
Location: In your JS exploiting you and your system
revolution
With the crypto API you can get pseudo-random bytes:
Code:
      push    eax
 mov     esi,esp
     invoke  CryptAcquireContext,esi,NULL,NULL,PROV_RSA_FULL,CRYPT_VERIFYCONTEXT
 test    eax,eax
     jz      .failed
     invoke  CryptGenRandom,dword[esi],byte_count,address
        test    eax,eax
     setz    bl
  invoke  CryptReleaseContext,dword[esi],0
    test    eax,eax
     setz    al
  or      al,bl
       jnz     .failed
     pop     eax
 clc
 ret
    .failed:
     pop     eax
 stc
 ret    
Post 15 Jan 2008, 03:35
View user's profile Send private message Visit poster's website Reply with quote
zxcv
Guest




zxcv
my code is not much longer, without calls Wink

so thers no smth like md5(DWORD seed) ?
Post 15 Jan 2008, 04:17
Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17271
Location: In your JS exploiting you and your system
revolution
Windows will give you MD5 see CryptCreateHash. Just do your own if you only need a simple dword seed as your entropy.

But if you want good entropy pseudo-randomness then the API method is very good. To do your own with similar entropy is not easy and requires good planning and lots of effort.
Post 15 Jan 2008, 04:34
View user's profile Send private message Visit poster's website Reply with quote
zxcv
Guest




zxcv
i already have this:
but i feel its not random. i use rand to switch between number, lower, and bigger. So only /3 goes to number, /2 smaller etc..
Code:
format pe console
section '.code' code readable executable

push 768
call [malloc]
mov [buffer],eax
add eax,335
mov [hash],eax
add eax,33






push eax
push 0x0202
call [WSAStartup]
push 0
call [time]
push eax
call [srand]
add esp,12




mov ebp,[hash]
mov edi,3
mov esi,ebp
add esi,32
hashproc:
call [rand]
xor edx,edx
div edi
cmp edx,1
jg hash_big
jl hash_small

mov ebx,10
mov ecx,48




jmp hash_end
hash_big:


mov ebx,26
mov ecx,65




jmp hash_end
hash_small:



mov ebx,26
mov ecx,97



hash_end:

xor edx,edx
div ebx
add edx,ecx



mov [ebp],dl
inc ebp
cmp esi,ebp
jne hashproc
mov [ebp],byte 0

push [hash]
push f
call [printf]
add esp, 8


retn
section '.data' data readable writeable

f db '%s',13,10,0


buffer dd ?
hash dd ?


section '.idata' import data readable
dd 0,0,0,RVA msvcrt_name,RVA msvcrt_table
dd 0,0,0,RVA ws2_32_name,RVA ws2_32_table
dd 0,0,0,RVA kernel32_name,RVA kernel32_table
dd 5 dup ?

msvcrt_table:
printf dd RVA _printf
time dd RVA _time
srand dd RVA _srand
rand dd RVA _rand
malloc dd RVA _malloc
memset dd RVA _memset
dd 0

ws2_32_table:
WSAStartup dd RVA _WSAStartup
socket dd RVA _socket
closesocket dd RVA _closesocket
connect dd RVA _connect
recv dd RVA _recv
send dd RVA _send
sendto dd RVA _sendto
dd 0


kernel32_table:
dd 0



msvcrt_name db 'msvcrt.dll',0
ws2_32_name db 'ws2_32.dll',0
kernel32_name db 'kernel32.dll',0


_printf db 0,0,'printf',0
_time db 0,0,'time',0
_srand db 0,0,'srand',0
_rand db 0,0,'rand',0
_malloc db 0,0,'malloc',0
_memset db 0,0,'memset',0

_WSAStartup db 0,0,'WSAStartup',0
_socket db 0,0,'socket',0
_closesocket db 0,0,'closesocket',0
_connect db 0,0,'connect',0
_recv db 0,0,'recv',0
_send db 0,0,'send',0
_sendto db 0,0,'sendto',0    
Post 15 Jan 2008, 06:50
Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.