OllyDbg using notes (13)

Source: Internet
Author: User

OllyDbg using notes (13)


Reference

Book: "Encryption and decryption"

Video: Small Turtle decryption Series video


Example program: Http://pan.baidu.com/s/1hqBrJWo


method One: inline patches


load program, press F9 Run, click Enter Reg.code input Name,key, etc., do not press OK, into the OD press CTRL + N to open the input and output table, search KillTimer, set breakpoints. Then click on the Registration window OK, we can see:

(you can also find the following code in the pop-up window when the search registration fails" The registration code seems to is not valid ")

004dc19d > \83f8 cmp eax, 3004dc1a0.  1E jnz short 004dc1c0004dc1a2.  8b57 1C mov edx, DWORD ptr [edi+1c];  Case 3 of the switch 004dbda4004dc1a5. -Push eax;  /timerid004dc1a6.  |HWND004DC1A7-Push edx; FF15 b4575e00 call DWORD ptr [<&user32. Killtimer>];  \killtimer004dc1ad.  6A. Push 0004dc1af.  6A. Push 0004dc1b1.  5c666400 push 0064665C; ASCII "The registration code seems to is not valid.", LF, "Please check if you didn ' t made any mistake."  004dc1b6.  E8 919d0d00 call 005B5F4C004DC1BB.  E9 B7000000 jmp 004dc277004dc1c0 > 83f8 cmp eax, 4004dc1c3.  1E jnz short 004dc1e3004dc1c5. -Push eax; /timerid;  Case 4 of the switch 004dbda4004dc1c6.    8b47 1C   mov eax, DWORD ptr [edi+1c]; |004dc1c9.  EAX; |hwnd004dc1ca. FF15 b4575e00 call DWORD ptr [<&user32. Killtimer>];  \killtimer004dc1d0.  6A. Push 0004dc1d2.  6A. Push 0004dc1d4.  FC656400 push 006465FC; ASCII "Thank your support!", LF, "Please Exit the software and start it again to validate the code."  004dc1d9.  E8 6e9d0d00 call 005b5f4c004dc1de.  E9 94000000 jmp 004dc277004dc1e3 > 83f8 cmp eax, 5004dc1e6.  JNZ short 004dc1fd004dc1e8.  8b4f 1C mov ecx, DWORD ptr [edi+1c];  Case 5 of the switch 004dbda4004dc1eb. -Push eax;  /timerid004dc1ec.  ECX push; |hwnd004dc1ed. FF15 b4575e00 call DWORD ptr [<&user32. Killtimer>]; \killtimer004dc1f3   . 6A FF push-1;  /exitcode = Ffffffff004dc1f5. FF15 d0545e00 call DWORD ptr [&LT;&AMP;KERNEL32. exitproces>;  \EXITPROCESS004DC1FB.  EB 7A jmp short 004dc277004dc1fd > 83f8 cmp eax, 6004dc200.  0D jnz short 004dc20f004dc202.  8b57 1C mov edx, DWORD ptr [edi+1c];  Case 6 of the switch 004dbda4004dc205. -Push eax;  /timerid004dc206.  |hwnd004dc207-Push edx; FF15 b4575e00 call DWORD ptr [<&user32. Killtimer>];  \killtimer004dc20d.  EB, jmp short 004dc277004dc20f > 83f8 0A cmp eax, 0a004dc212.  2D jnz short 004dc241004dc214. -Push eax; /timerid;  Case A of Switch 004dbda4004dc215. 8b47 1C mov eax, DWORD ptr [edi+1c]; |004dc218.  EAX; |hwnd004dc219. FF15 b4575e00 call DWORD ptr [<&user32. Killtimer>];  \killtimer004dc21f.  8B17 mov edx, DWORD ptr [edi]004dc221.  8BCF mov ecx, edi004dc223.  FF92 C0000000 call DWORD ptr [edx+c0]004dc229.  85C0 test eax, eax004dc22b.  4 A JE short 004dc277004dc22d.  8BC8 mov ecx, eax004dc22f.  E8 772d0e00 call 005befab004dc234.  85C0 test eax, eax004dc236.  3F JE Short 004dc277004dc238.  8BC8 mov ecx, eax004dc23a.  E8 F13efeff call 004c0130004dc23f.  EB, jmp short 004dc277004dc241 > 83f8 0B cmp eax, 0b004dc244.  JNZ short 004dc277004dc246. -Push eax; /timerid;  Case B of Switch 004dbda4004dc247. 8b47 1C mov eax, DWORD ptr [edi+1c]; |004dc24a.  EAX; |hwnd004dc24b. FF15 b4575e00 call DWORD ptr [<&user32. Killtimer>];  \killtimer004dc251.  E8 f3570e00 call 005c1a49004dc256.  8B40 mov eax, DWORD ptr [eax+4]004dc259.  6A. Push 0004dc25b.  b03c6400 push 00643cb0;  ASCII "Resettoolbars" 004dc260.  1cf16300 push 0063f11c;  ASCII "Settings" 004dc265.  8BC8 mov ecx, eax004dc267.  E8 255c0e00 call 005c1e91004dc26c.  85C0 test eax, eax004dc26e.  Je short 004dc277004dc270.  8BCF mov ecx, edi004dc272.  E8 99190000 Call 004ddc10004dc277 > 8BCF mov ecx, EDI;  Default Case of Switch 004dbda4004dc279.  E8 51040d00 call 005ac6cf004dc27e.  8B4D F4 mov ecx, DWORD ptr [ebp-c]004dc281. 5F Pop Edi004dc282.  5E pop esi004dc283.  5 b pop ebx004dc284.  64:890d 00000>mov dword ptr fs:[0], ecx004dc28b.  8BE5 mov esp, ebp004dc28d.  5D pop ebp004dc28e. C2 0400 RETN 4



The code is actually Swith, and now the code EAX is 3, and the code at Case 3 is running. Observe each case and you can find the "Thank for your support!" in case 4, and we can know that case 4 is the successful registration. We'll find a way to change Swith 3 to Swith 4.


Let's take a look at the code that Swith started


004dbd80.  Push Ebp004dbd81.  8BEC mov ebp, esp004dbd83.  6A FF push-1004dbd85.  17b85d00 push 005db817;  The SE handler installs the 004dbd8a.  64:A1 0000000>mov eax, DWORD ptr fs:[0]004dbd90.  Push eax004dbd91.  64:8925 00000>mov dword ptr fs:[0], esp004dbd98.  81EC 68010000 Sub ESP, 168004dbd9e.  8B45 mov eax, DWORD ptr [EBP+8]004DBDA1.  Ebx004dbda2 push.  Esi004dbda3 push.  EDI004DBDA4 push.  83F8 cmp eax, 1;  Switch (Cases 1..B) 004dbda7.  8BF9 mov edi, ecx004dbda9.  JNZ short 004dbdfe004dbdab. -Push eax; /timerid;  Case 1 of the switch 004DBDA4004DBDAC.  8b47 1C mov eax, DWORD ptr [edi+1c]; |004dbdaf.                  Push EAX            ; |hwnd004dbdb0. FF15 b4575e00 call DWORD ptr [<&user32. Killtimer>];  \killtimer004dbdb6. E8 8e5c0e00 Call 005c1a49


Under 004dbd80, remove the breakpoint from the previous KillTimer setting and rerun the program. More than a few times F9 (the place at the bottom of the breakpoint, the program interface before the call, so more than a few times F9), you can see the program interface, open the Registration window, enter information, click OK, found that the program is broken in front of the place where the breakpoint.

Press F8 single-step operation, you can find mov eax, DWORD ptr [Ebp+8], is to set the value of EAX in Swith. Can try to change it to mov eax, 4, but we can find that the original code occupies 3 bytes, the revised code occupies 5 bytes, the following code push EBX, push ESI is overwritten.


At this point we can use the embedded patch, first mov eax, DWORD ptr [ebp+8] into jmp xxx to the blank code, and then in the blank code to write the code to execute, and then jump back.


Here we can change mov eax, DWORD ptr [ebp+8] to JMP 005e47cc

and write the following code in 005e47cc.

005E47CB            db      00005e47cc      B8 04000000   mov     eax, 4005e47d1   .            ebx005e47d2 push   .    esi005e47d3   . ^ E9 cb75efff   jmp     004dbda3005e47d8            db      00


Copy to executable program, normal running program, you can find that the program is open always pops up "Thank you for your support!" 's window. After debugging the modified program, we can find that the original program has been in the loop of execution Swith, because we changed to switch 4, so always pops up "Thank you for your support!" 's window. In fact, this program is only because after the expiration of the previous one let us enter the key of the Nag window can not be used, we just let this nag window does not appear on it. We can make him switc 0b,0b neither pops up "the registration code seems to is not valid" window, nor pops up "Thank you for your support!" 's window. The Mov eax, 4 changed to mov eax, 0b copy to the executable program, and then normal running program, you can find that the program can run normally.



method Two: View the call stack


This program, because it produces a non-skipped nag window and cannot be used, can be cracked by changing the jump so that the program does not execute the code of the Nag window.


Find the code that generated the Nag window


Reload the program, delete the breakpoint set earlier, press F9 to run the program, see the Nag window appear, pause the program, press Alt+k to view the stack call,


Picture 1


Click "Call from" at the bottom. View the code (click the Function procedure is to see the function of the specific code, click on the call from is to see calls)


In this call up and down breakpoints, rerun the program,

Picture 2



It can be found that this call produced a NAG window.


Find the beginning of this code (that is, find the push EBP)

Picture 3


At the push EBP Breakpoint, run the program again, press F9, and go to the breakpoint.

Press F8 Single step to run, change the side attention to jump, changing registers, so that the program skip call 005abe4d.


Can be found as long as the jnz short 004dbde6 do not jump that can be implemented to skip call 005abe4d.









OllyDbg using notes (13)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.