23.03.2013 Views

Quick introduction to reverse engineering for beginners

Quick introduction to reverse engineering for beginners

Quick introduction to reverse engineering for beginners

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

7.1 “QR9”: Rubik’s cube inspired amateur cryp<strong>to</strong>-algorithm<br />

Sometimes amateur cryp<strong>to</strong>systems appear <strong>to</strong> be pretty bizarre.<br />

I was asked <strong>to</strong> revese engineer an amateur cryp<strong>to</strong>algorithm of some data crypting utility, source code of<br />

which was lost 1 .<br />

Here is also IDA 5 exported listing from original crypting utility:<br />

.text:00541000 set_bit proc near ; CODE XREF: rotate1+42<br />

.text:00541000 ; rotate2+42 ...<br />

.text:00541000<br />

.text:00541000 arg_0 = dword ptr 4<br />

.text:00541000 arg_4 = dword ptr 8<br />

.text:00541000 arg_8 = dword ptr 0Ch<br />

.text:00541000 arg_C = byte ptr 10h<br />

.text:00541000<br />

.text:00541000 mov al, [esp+arg_C]<br />

.text:00541004 mov ecx, [esp+arg_8]<br />

.text:00541008 push esi<br />

.text:00541009 mov esi, [esp+4+arg_0]<br />

.text:0054100D test al, al<br />

.text:0054100F mov eax, [esp+4+arg_4]<br />

.text:00541013 mov dl, 1<br />

.text:00541015 jz short loc_54102B<br />

.text:00541017 shl dl, cl<br />

.text:00541019 mov cl, cube64[eax+esi*8]<br />

.text:00541020 or cl, dl<br />

.text:00541022 mov cube64[eax+esi*8], cl<br />

.text:00541029 pop esi<br />

.text:0054102A retn<br />

.text:0054102B ;<br />

---------------------------------------------------------------------------<br />

.text:0054102B<br />

.text:0054102B loc_54102B: ; CODE XREF: set_bit+15<br />

.text:0054102B shl dl, cl<br />

.text:0054102D mov cl, cube64[eax+esi*8]<br />

.text:00541034 not dl<br />

.text:00541036 and cl, dl<br />

.text:00541038 mov cube64[eax+esi*8], cl<br />

.text:0054103F pop esi<br />

.text:00541040 retn<br />

.text:00541040 set_bit endp<br />

.text:00541040<br />

.text:00541040 ;<br />

---------------------------------------------------------------------------<br />

.text:00541041 align 10h<br />

.text:00541050<br />

.text:00541050 ; =============== S U B R O U T I N E<br />

=======================================<br />

.text:00541050<br />

.text:00541050<br />

.text:00541050 get_bit proc near ; CODE XREF: rotate1+16<br />

.text:00541050 ; rotate2+16 ...<br />

.text:00541050<br />

1 I also got permit from cus<strong>to</strong>mer <strong>to</strong> publish the algorithm details<br />

148

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!