Rev 6465 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 6465 | Rev 9216 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | use32 |
1 | use32 |
2 | org 0x0 |
2 | org 0x0 |
3 | db 'MENUET01' |
3 | db 'MENUET01' |
4 | dd 0x01,start,i_end,e_end,e_end,0,this_file_name |
4 | dd 0x01,start,i_end,e_end,e_end,0,this_file_name |
Line 5... | Line 5... | ||
5 | 5 | ||
6 | include '../../../../proc32.inc' |
6 | include 'proc32.inc' |
7 | include '../../../../macros.inc' |
7 | include 'macros.inc' |
8 | include '../../../../dll.inc' |
8 | include 'dll.inc' |
9 | ;include '../../../../debug.inc' |
9 | ;include 'debug-fdo.inc' |
Line 10... | Line 10... | ||
10 | include 'libcrash.inc' |
10 | include 'libcrash.inc' |
Line 11... | Line 11... | ||
11 | 11 | ||
12 | BUFFER_SIZE = 4096 |
12 | BUFFER_SIZE = 0x1000 |
13 | 13 | ||
14 | 14 | ||
15 | start: |
15 | start: |
16 | pushfd |
16 | pushfd |
Line 17... | Line 17... | ||
17 | pop eax |
17 | pop eax |
Line 41... | Line 41... | ||
41 | 41 | ||
42 | redraw: |
42 | redraw: |
43 | mcall 12, 1 |
43 | mcall 12, 1 |
Line 44... | Line -... | ||
44 | mcall 0, <0,900>, <0,160>, 0x34000000, 0x80000000, window_title |
- | |
45 | - | ||
46 | - | ||
47 | mcall 4, < 0, 0>, 0xc0ffffff, message, , 0 |
44 | mcall 0, <0,900>, <0,160>, 0x34000000, 0x80000000, window_title |
48 | 45 | ||
49 | mov [hid], 0 |
46 | mov [f70_buf.src], 0 |
50 | mov [text_pos_y], 10 |
- | |
51 | mov [hash_name], hash_strings |
47 | invoke crash.hash, LIBCRASH_SHA2_256, read_data, 0, bin |
- | 48 | stdcall bin2hex, bin, SHA2_256_LEN, hex |
|
52 | .next_hash: |
49 | mcall 4, <0,0>, 0xc0ffffff, hex, 0, 0 |
53 | mov dword[f70_buf + 4], 0 |
50 | |
54 | mov dword[msglen], 0 |
- | |
55 | mov edi, hex |
51 | invoke crash.hash_oneshot, LIBCRASH_SHA2_256, ctx, 0, i_end |
56 | xor eax, eax |
- | |
57 | mov ecx, 1024/4 |
- | |
- | 52 | stdcall bin2hex, ctx, SHA2_256_LEN, hex |
|
58 | rep stosd |
53 | mcall 4, <0,10>, 0xc0ffffff, hex, 0, 0 |
59 | invoke crash.hash, [hid], data_buffer, update_data_buffer, ctx |
54 | |
60 | invoke crash.bin2hex, ctx, hex, [hid] |
55 | invoke sha2_256.oneshot, ctx, 0, i_end |
- | 56 | stdcall bin2hex, ctx, SHA2_256_LEN, hex |
|
61 | mov ebx, [text_pos_y] |
57 | mcall 4, <0,20>, 0xc0ffffff, hex, 0, 0 |
62 | mcall 4, , 0xc0ffffff, [hash_name], , 0 |
58 | |
63 | mov ebx, [text_pos_y] |
59 | invoke sha2_256.init, ctx |
64 | add ebx, 66 SHL 16 |
60 | invoke sha2_256.update, ctx, 0, 42 |
65 | mcall 4, , 0x40ffffff, hex, 128, 0 |
61 | invoke sha2_256.update, ctx, 42, i_end-42 |
66 | add [text_pos_y], 10 |
- | |
67 | add [hash_name], 12 ; lenght of hash_strings item |
62 | invoke sha2_256.finish, ctx |
68 | inc [hid] |
- | |
Line 69... | Line 63... | ||
69 | cmp [hid], LIBCRASH_SHA3_512 |
63 | stdcall bin2hex, ctx, SHA2_256_LEN, hex |
70 | jng .next_hash |
64 | mcall 4, <0,30>, 0xc0ffffff, hex, 0, 0 |
Line 71... | Line 65... | ||
71 | 65 | ||
Line 79... | Line 73... | ||
79 | 73 | ||
80 | quit: |
74 | quit: |
Line 81... | Line 75... | ||
81 | mcall -1 |
75 | mcall -1 |
82 | 76 | ||
- | 77 | ||
83 | 78 | proc bin2hex uses esi edi, _bin, _len, _hex |
|
- | 79 | mov esi, [_bin] |
|
- | 80 | mov edi, [_hex] |
|
- | 81 | mov ecx, [_len] |
|
- | 82 | .next_byte: |
|
- | 83 | movzx eax, byte[esi] |
|
- | 84 | shr al, 4 |
|
- | 85 | cmp al, 10 |
|
- | 86 | sbb al, 0x69 |
|
- | 87 | das |
|
- | 88 | stosb |
|
- | 89 | lodsb |
|
- | 90 | and al, 0x0f |
|
- | 91 | cmp al, 10 |
|
- | 92 | sbb al, 0x69 |
|
84 | proc update_data_buffer _left |
93 | das |
- | 94 | stosb |
|
- | 95 | loop .next_byte |
|
- | 96 | mov byte[edi], 0 |
|
- | 97 | ret |
|
- | 98 | endp |
|
85 | mov eax, data_buffer |
99 | |
- | 100 | ||
86 | add eax, [_left] |
101 | proc read_data uses ebx, _user, _buf, _len |
87 | mov dword[f70_buf + 16], eax |
102 | mov eax, [_buf] |
88 | mov eax, BUFFER_SIZE |
103 | mov [f70_buf.dst], eax |
89 | sub eax, [_left] |
104 | mov eax, [_len] |
90 | mov dword[f70_buf + 12], eax |
105 | mov [f70_buf.count], eax |
91 | mcall 70, f70_buf |
106 | mcall 70, f70_buf |
92 | mov eax, ebx |
107 | mov eax, ebx |
93 | cmp eax, -1 |
108 | cmp eax, -1 |
94 | jne @f |
109 | jnz @f |
95 | inc eax |
110 | inc eax |
96 | @@: |
111 | @@: |
Line 97... | Line 112... | ||
97 | add dword[f70_buf + 4], eax |
112 | add [f70_buf.src], eax |
98 | ret |
- | |
99 | endp |
- | |
100 | - | ||
101 | - | ||
102 | szZ window_title , 'libcrash example' |
- | |
103 | szZ message , 'hash sums of this file' |
- | |
104 | - | ||
105 | hash_strings: |
- | |
106 | db 'crc32 : ',0 |
- | |
107 | db 'md4 : ',0 |
- | |
108 | db 'md5 : ',0 |
- | |
109 | db 'sha1 : ',0 |
- | |
110 | db 'sha224 : ',0 |
- | |
111 | db 'sha256 : ',0 |
- | |
112 | db 'sha384 : ',0 |
- | |
Line 113... | Line 113... | ||
113 | db 'sha512 : ',0 |
113 | ret |
114 | db 'sha3-224 : ',0 |
114 | endp |
115 | db 'sha3-256 : ',0 |
115 | |
116 | db 'sha3-384 : ',0 |
116 | |
117 | db 'sha3-512 : ',0 |
117 | sz window_title, 'libcrash example',0 |
118 | 118 | ||
119 | f70_buf: |
119 | f70_buf: |
120 | funcnum dd 0 |
120 | .funcnum dd 0 |
Line 121... | Line 121... | ||
121 | src dd 0 |
121 | .src dd 0 |
122 | res1 dd 0 |
122 | dd 0 |
Line 133... | Line 133... | ||
133 | libcrash, 'libcrash.obj' |
133 | libcrash, 'libcrash.obj' |
Line 134... | Line 134... | ||
134 | 134 | ||
135 | import libcrash , \ |
135 | import libcrash, \ |
136 | libcrash.init , 'lib_init' , \ |
136 | libcrash.init, 'lib_init', \ |
- | 137 | crash.hash, 'crash_hash', \ |
|
137 | crash.hash , 'crash_hash' , \ |
138 | crash.hash_oneshot, 'crash_hash_oneshot', \ |
- | 139 | crash.mac, 'crash_mac', \ |
|
- | 140 | crash.mac_oneshot, 'crash_mac_oneshot', \ |
|
- | 141 | crash.crypt, 'crash_crypt', \ |
|
- | 142 | crash.crypt_oneshot, 'crash_crypt_oneshot', \ |
|
- | 143 | sha2_256.init, 'sha2_256_init', \ |
|
- | 144 | sha2_256.update, 'sha2_256_update', \ |
|
- | 145 | sha2_256.finish, 'sha2_256_finish', \ |
|
- | 146 | sha2_256.oneshot, 'sha2_256_oneshot', \ |
|
- | 147 | hmac_sha2_256.init, 'hmac_sha2_256_init', \ |
|
- | 148 | hmac_sha2_256.update, 'hmac_sha2_256_update', \ |
|
- | 149 | hmac_sha2_256.finish, 'hmac_sha2_256_finish', \ |
|
- | 150 | hmac_sha2_256.oneshot, 'hmac_sha2_256_oneshot', \ |
|
- | 151 | aes256ctr.init, 'aes256ctr_init', \ |
|
- | 152 | aes256ctr.update, 'aes256ctr_update', \ |
|
- | 153 | aes256ctr.finish, 'aes256ctr_finish', \ |
|
Line 138... | Line 154... | ||
138 | crash.bin2hex , 'crash_bin2hex' |
154 | aes256ctr.oneshot, 'aes256ctr_oneshot' |
139 | - | ||
140 | i_end: |
- | |
141 | hash_name rd 1 |
- | |
142 | text_pos_y rd 1 |
155 | |
143 | hash rd 50 |
- | |
144 | hid rd 1 ; hash id |
156 | i_end: |
145 | msglen rd 1 |
157 | bin rb MAX_HASH_LEN |
146 | hex rb 1024 |
158 | hex rb MAX_HASH_LEN*2+1 |
147 | data_buffer rb BUFFER_SIZE |
159 | data_buffer rb BUFFER_SIZE |
148 | this_file_name rb 4096 |
160 | this_file_name rb 0x1000 |
149 | rb 0x800 ;stack |
161 | align LIBCRASH_ALIGN |
150 | align 16 ; should be enough |
162 | ctx rb LIBCRASH_CTX_LEN |
151 | ctx rb 0x1000 |
- |