home *** CD-ROM | disk | FTP | other *** search
/ KeyGen Studio 2002 / KeyGen_Studio_2002.iso / Tutorials / ReverseMes / santmat.txt < prev    next >
Encoding:
Text File  |  2001-09-21  |  9.8 KB  |  197 lines

  1.     ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
  2.     ▓▓         ____                     __       __                ▓▓▀█
  3.     ▓▓        /  _/_ _  __ _  ___  ____/ /____ _/ /                ▓▓ █▀█
  4.     ▓▓       _/ //  ' \/  ' \/ _ \/ __/ __/ _ `/ /                 ▓▓ █ █
  5.     ▓▓      /___/_/_/_/_/_/_/\___/_/  \__/\_,_/_/                  ▓▓ █ █
  6.     ▓▓        ____                          __          __         ▓▓ █ █
  7.     ▓▓       / __ \___ ___ _______ ___  ___/ /__ ____  / /____     ▓▓ █ █
  8.     ▓▓      / /_/ / -_|_-</ __/ -_) _ \/ _  / _ `/ _ \/ __(_-<     ▓▓ █ █
  9.     ▓▓     /_____/\__/___/\__/\__/_//_/\_,_/\_,_/_//_/\__/___/     ▓▓ █ █
  10.     ▓▓                                                             ▓▓ █ █
  11.     ▓▓ Author: SantMat                                             ▓▓ █ █
  12.     ▓▓ Topic: Adding functionality to Muad'Dib's ReverseMe1        ▓▓ █ █
  13.     ▓▓ Date: 2/24/2000                                             ▓▓ █ █
  14.     ▓▓ Level:                                                      ▓▓ █ █
  15.     ▓▓ ( ) Beginner (X) Intermediate ( ) Advanced ( ) Expert       ▓▓ █ █
  16.     ▓▓                                                             ▓▓ █ █
  17.     ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ █ █
  18.       █▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄█ █
  19.         █▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄█
  20.  
  21.  
  22. ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
  23.  
  24. Source code and additional links:
  25. The file we will be adding functionality to is Muad'Dib's ReverseMe1, which
  26. is located at http://www.immortaldescendants.com/database/muad/rm1.zip.
  27.  
  28. The modified program is located at:
  29. http://www.immortaldescendants.com/database/essays/santmat/source/rm1.zip
  30.  
  31. ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
  32.  
  33. I.  Introduction
  34. II  Tools you need for my tutorial
  35. III.The Crack
  36. IV. BTW aka Greetz
  37.  
  38.  
  39. I.  As this is my 1st tutorial, I shall do the best I can. I thank you for your patience. 
  40.  
  41. II. WDASM
  42.     Hiew
  43.     Some knowledge of reversing
  44.     OpGen, if you want
  45.  
  46. III.Ok, lets start!
  47.  
  48.     First run the program rm1.exe add see what it is we are trying to do here. Our Goal
  49.     here is make the "Exit" button in the main part of the program actually exit the
  50.     program, but before it exits, we must also add a custom message box of our own!
  51.  
  52.     So, load rm1.exe in wdasm and disassemble it. Now take a look at the code. Notice the
  53.     section where MessageBoxA is called when the "Exit" button it hit:
  54.     
  55.     :0040103E 6A00            push 00000000    
  56.     
  57.     * Possible StringData Ref from Data Obj ->"GOAL:"
  58.                                   |
  59.     :00401040 682F304000                push 0040302F    ;address where text for
  60.                                                         ;caption is located
  61.  
  62.     * Possible StringData Ref from Data Obj ->"Your job is to make me work as "
  63.                                             ->"an exit button!"
  64.                                   |
  65.     :00401045 6800304000                push 00403000    ;address where text for the
  66.                                                         ;message's text is located 
  67.     :0040104A FF7508                    push [ebp+08]
  68.  
  69.     * Reference To: USER32.MessageBoxA, Ord:01BBh
  70.                                   |
  71.     :0040104D E832000000                Call 00401084    ;pops message box on screen
  72.  
  73.     Now that we know where the code for the message box starts, :0040103E, and ends,
  74.     :0040104D, we know where the code that needs changing is. 
  75.  
  76.     The next thing we need to do is make our custom message box. So run hiew and open the
  77.     file rm1.exe. Now, we could put the text for the caption and message text over
  78.     Muad'Dib's existing message box, or just put it somewhere else.  I think that instead
  79.     of just hex editing the existing text, we should put it somewhere else in the code of
  80.     the program so we can learn how to add code at the end of sections for future
  81.     reversing projects.
  82.  
  83.     So get out ProcDump and goto the "PE Editor" and open the file. Now click the 
  84.     "sections" button. You will notice that there are a bunch of sections, only 2 that
  85.     concern us:
  86.     
  87.     1. The ".text" section, that is our code section. You will see that it is only 8A
  88.        bytes long out of a possible 200 bytes and the offset is at 400.  Which means we
  89.        have 176 bytes(200-8A=176) to enter our code into. And we can start entering
  90.        that code at offset 48A(400+8A=48A).
  91.     
  92.     2. The ".data" section, that is our section where we will place the text for our
  93.        custom message box. You will see that it is only 3C bytes long out of a possible
  94.        200 bytes and the offset is at 800.  Which means we have 1C4 bytes(200-3C=1C4) to
  95.        enter our text into. And we can start entering that code at offset 83C(800+3C=83C).
  96.  
  97.     Well, as you can see, we have ample room to enter our code and text into. So lets do
  98.     it then. First we will enter the text for the caption and message's text in our
  99.     custom message box.
  100.  
  101.     So open up hiew and goto the offset 83C. This is where we will enter the code at.
  102.     Enter your text for the message's text at 83C. Then make sure there is a "00" after
  103.     the text you entered, then enter the caption at whatever offset you are at. Make sure
  104.     you record at what addresses you entered the text and caption. Take note that the
  105.     offset 83C is also address 0040303C. You need this address and the one for the caption
  106.     when you are enter the code to make your customer message box.
  107.  
  108.     Here is an example of my text and caption entering:
  109.  
  110.     Offset        Hex Code                Ascii Code
  111.     00000800        596F7572206A6F6220697320746F206D    Your job is to m
  112.     00000810        616B65206D6520776F726B2061732061    ake me work as a
  113.     00000820        6E206578697420627574746F6E210047    n exit button!.G
  114.     00000830        4F414C3A00000000000000002D3D3D57    OAL:........-==W
  115.     00000840        656C636F6D6520746F206D7920637573    elcome to my cus
  116.     00000850        746F6D206D65737361676520626F7821    tom message box!
  117.     00000860        3D3D2D20456E6A6F7920796F75722073    ==- Enjoy your s
  118.     00000870        746179210053616E744D617427732043    tay!.SantMat's C
  119.     00000880        7573746F6D2047726565746572000000    ustom Greeter...
  120.     
  121.     Now, my added text for the message's text starts at offset 83C and ends at offset 873.
  122.     And the text for my caption starts at offset 875 and ends at offset 87D. Now when I
  123.     view my file in hiew, I see that at the offset 83C, it is the address 0040303C and at
  124.     the offset 875, it is the address 00403075. Now that we have added our code and have
  125.     the addresses for the location of our caption(00403075) and text(0040303C), we can
  126.     proceed in adding our code to the ".text" section, thereby making our custom message
  127.     box function correctly.
  128.  
  129.     We have now done part of the process in making the custom message box, but we still
  130.     have to do the second half. Don't forget about exiting the program also, we have to
  131.     add that code too. 
  132.  
  133.     So open up hiew again and goto the offset where we can add new code, 48A. Now add
  134.     this code:
  135.  
  136.     ;type in exactly as I have below
  137.  
  138.     push 0
  139.     push 00403075    ;This pushes the text for the caption you just entered
  140.     push 0040303C    ;This pushes the text for the message's text you just entered
  141.     push 0
  142.     call 00000484    ;This calls the MessageBoxA function, which in turn displays it!
  143.  
  144.     This is all the code we need to enter to display the message box, but we are still a
  145.     distance from being done. After that code has been entered, you should be at the
  146.     offset, 49D. 
  147.  
  148.     So open up hiew again and goto the offset where we can add new code, 49D. Now add
  149.     this code:
  150.  
  151.     ;type in exactly as I have below
  152.  
  153.     jmp d,[00402004]    ;This calls ExitProcess directly
  154.  
  155.     Ok, not don't go crazy. I will explain the line above. The number 00402004 is the
  156.     OpCode for ExitProcess for this program. There are two ways to get this number, you
  157.     could use a program like OpGen to get all OpCodes for the program or you could look
  158.     around the file in hiew and find them yourself. Since this file isn't big at all, I
  159.     suggest the latter method. Guess what, if you look just above offset 48A, you will
  160.     see the opcode for Exit Process at offset 46C. Not that wasn't to hard now was it.
  161.  
  162.     Well, just one more thing needs to be done to make this whole thing function
  163.     correctly. If you were to run the program right now, after all the changes we have
  164.     made so far, you wouldn't notice a difference at all.
  165.  
  166.     Lets switch it up now. Remember long ago, when we were at the top of this tut and we
  167.     found the code that send us to Muad'Dib's message box. When it is time to remember, I
  168.     will repeat if you are too lazy to scroll up the tut. 
  169.     
  170.     "Now that we know where the code for the message box starts, :0040103E, and ends,
  171.     :0040104D, we know where the code that needs changing is."
  172.  
  173.     So we need to write some code that will redirect us to the code for our custom
  174.     message box. Hmmm, maybe a jmp perhaps!
  175.  
  176.     So open up hiew again and goto the offset where we can add new code, 43E. Now add
  177.     this code:
  178.  
  179.     ;type in exactly as I have below
  180.  
  181.     jmp 48A
  182.  
  183.     Well folks, thats about it. It is all done. Lets have a celebration!! Yes!!!
  184.  
  185.     You will notice that there is all that leftover code that continues till 0040104D,
  186.     you don't have to worry about it, because the jmp just bypasses it altogether. But
  187.     if you want, you can nop(90h) it all out!!
  188.  
  189.  
  190. IV. BTW, I hope ya'll learned something from this little tut of mine. As my knowledge
  191.     grows, so shall the depth of my tuts. I bid you farewell, C U around!
  192.      
  193.     Greets to: Everyone who cracks for the fun and knowledge of it!!!
  194.                
  195.     If anyone has any questions or comments:
  196.     
  197.     Please send them to --> SantMat@immortaldescendants.org