home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Corleone / NotePad.txt < prev    next >
Text File  |  2000-05-25  |  12KB  |  254 lines

  1. ----------------------[ Nag Screen Removal: NotePad - Date: 15/12/98 ]----------
  2.  
  3. -= Written By =-                                              Number of pages: 5
  4.   ______
  5.  /  ___ \  ______   ______   ______   ______   ______   _    _   ______
  6.  | /   \| /  ___ \ /  __  \ /  __  \ /  ___ \ /  __  \ / \  / \ /  ___ \
  7.  | |    | | /   \| | /  \ | | /  \ | | /   \| | /  \ | | |  | | | /   \|
  8.  | |      | |_   | | \__/ | | \__/ | | |_   | | \__/ | | |  | | | \____
  9.  | |      |   \    |  __  / |  __  / |   \    |  __  / | |  | | \____  \
  10.  | |    | |  _/  | | /  \ \ | /  \ \ |  _/  | | /  \ \ | |  | |      \ |
  11.  | \___/| | \___/| | |  | | | \__/ | | \___/| | |  | | | \__/ | |\___/ |
  12.  \______/ \______/ \_/  \_/ \______/ \______/ \_/  \_/ \______/  \_____/
  13.  
  14.  
  15. +----------                                                          ---------+
  16.   How to get rid of the nasty Nag you get in Notepad when opening large files
  17. +----------                                                          ---------+
  18.  
  19.  
  20. My first tutorial. I want to crack Notepad. Yeah, I know, many before me did it. But they all did it with help of SoftIce, but I somehow knew that this wasn't necessary. So I started cracking.
  21.  
  22. Required:
  23. * W32Dasm, I used version 8.9  <- Find it on the I-Net (f.e. Astalavista.box.sk)
  24. * HView, I used version 5.84   <- Find it on the I-Net (f.e. Astalavista.box.sk)
  25. * FC (File Compare, standard in DOS)
  26. * Some programming experience
  27. * A BackUp of NotePad
  28.  
  29. First of all you'll have to run Notepad and open a big file (> 32Kb). If it is OK, you'll see a message like this (Translated from Dutch, so the English version could be a little different!!):
  30.  
  31. +--------------------------------------------------+
  32. | File is too big and cannot be opened by Notepad. |
  33. | Do you want to run WordPad to read this file?    |
  34. +--------------------------------------------------+
  35.  
  36. If you choose [NO], it doesn't run WordPad, but if you choose [YES], it'll run WordPad! Remember the message. It is always necessary that you write down or remember the shown message. You'll have to keep in mind that a messagebox was shown.
  37.  
  38. We have everything we need to crack, so exit NotePad. Disassemble NotePad with W32Dasm. Click on "List and Search for String Data Referenced in Disassembly". The button is between [DLG Ref] and the Print Button, or you could select "String Data References" under the "Refs" menu. Find the Message in the list and double-click on it. Close the box. 
  39. Click on "List and Search for Imported Modules and Functions". Between [Ret] and [Exp Fn] on the Toolbar or choose "Imports" in the "Functions" menu. Find in the list "USER32.MessageBoxA", the "32" and the "A" says it is 32-bit. Double-click on the item and close the dialog box. Why first the string search? Well, a messagebox is called often by the same program, so it is very unlikely that you get the right one immediately. We want the MessageBox which is shown after the text is initialised, therefore it has to be done this way!
  40. You see this:
  41.  
  42. * Reference To: USER32.MessageBoxA, Ord:01ACh
  43.                                   |
  44. :004033B1 FF15A8644000            Call dword ptr [004064A8] <-- The call to
  45.                                                         show the dialog box
  46. :004033B7 83F806                  cmp eax, 00000006 <-- When [YES] is
  47.                                                         pressed, the
  48.                                                         dialog box sets eax
  49.                                                         to 6, but if [NO]
  50.                                                         is pressed, eax
  51.                                                         would be set to 7
  52. :004033BA 0F85A7000000            jne 0040467       <-- Jump Not Equal (eax
  53.                                                         equal to 6. No?
  54.                                                         Then jump else
  55.                                                         don't jump)
  56. :004033C0 6804010000              push 00000104
  57. :004033C5 8D858CFDFFFF            lea eax, dword ptr [ebp+FFFFFD8C]
  58. :004033CB 837D1001                cmp dword ptr [ebp+10], 00000001
  59. :004033CF 1BFF                    sbb edi, edi
  60. :004033D1 50                      push eax
  61. :004033D2 83C737                  add edi, 00000037
  62.  
  63. * Possible Reference to String Resource ID=00056: "wordpad.exe"
  64.                                   |
  65. :004033D5 6A38                    push 00000038
  66. :004033D7 FF3540554000            push dword ptr [00405540]
  67.  
  68. As you see, poorly protected. But why should it?
  69.  
  70. Select the line: Call dword ptr [004064A8]
  71. On the statusbar you see "@Offset 000033B1h"
  72. Then select the line: jne 0040467
  73. On the statusbar you see "@Offset 000033BAh"
  74. These are the offsets in the file NotePad.EXE, which we are going to use when patching it.
  75.  
  76. Let's delete the call to the dialog box. You can do this with the NOP instruction, but programs which are checking itself, 'know' that it is a crack when it encounters about three NOP's in the program. NotePad doesn't check itself, but I show you how to avoid such checks anyway. We can increase a register and decrease it, so we don't have to use NOP and we don't change the progress. We're going to do the same thing with the conditional jump (jne).
  77.  
  78. :004033B1 FF15A8644000            Call dword ptr [004064A8]
  79.           \-> Bytes: FFh 15h A8h 64h 40h 00h
  80.  
  81.       Action        Instruction  Byte Offset
  82.       =----=        =---------=  =--= =----=
  83.       Increase ecx: inc   ecx -> 41h  33B1h
  84.       Increase edx: inc   edx -> 42h  33B2h +1, because the instruction is
  85.                                                 1 byte long
  86.       Decrease ecx: dec   ecx -> 49h  33B3h
  87.       Decrease edx: dec   edx -> 4Ah  33B4h
  88.       Increase eax: inc   eax -> 40h  33B5h
  89.       Decrease eax: dec   eax -> 48h  33B6h
  90.  
  91. :004033BA 0F85A7000000            jne 0040467
  92.           \-> Bytes: OFh 85h A7h 00h 00h 00h
  93.  
  94.       Decrease eax: dec   eax -> 48h  33BAh
  95.       Increase eax: inc   eax -> 40h  33BBh
  96.       Increase ecx: inc   ecx -> 41h  33BCh
  97.       Decrease ecx: dec   ecx -> 49h  33BDh
  98.       Decrease edx: dec   edx -> 4Ah  33BEh
  99.       Increase edx: inc   edx -> 42h  33BFh
  100.       
  101. (You can also do other registers, as long as you make sure the registers doesn't have other values after the action!)
  102.  
  103. Load HView 5.84 with the only parameter $windowspath$\NOTEPAD.EXE
  104. - Press [F4] (Mode) and choose "Decode". 
  105. Now you see the listing with at the left side the offset, then the bytes then the instruction. 
  106. - Press [F5] (Goto) and input our first offset: 33B1h (you can omit the 'h'). 
  107. - Press [F3] (Edit) and input the bytes which belong to that offset: 41 (Hexadecimal!)
  108. The instruction immediately changes to: inc   ecx
  109. Repeat this routine until you did all the offsets. Beware of the offset 33B7h, this is a CoMPare, and we won't delete it. If you want to do this anyway you can use one NOP and an INCrease and an DECrease instruction.
  110. - Press [F9] (Update)
  111. - Press [F10] (Quit)
  112.  
  113. Load NotePad and open a big file (> 32Kb). Yes, it's cracked!! Now create a patch and distribute it.
  114.  
  115. Compare the BackUp and the cracked NotePad with:
  116.  
  117. FC /B $backup$ NotePad.EXE > Crack.TXT
  118.  
  119. When opening "Crack.TXT" you get:
  120.  
  121. Offset    Original Cracked 
  122. ------    -------- ------- 
  123. 000033B1: FF       41
  124. 000033B2: 15       42
  125. 000033B3: A8       49 
  126. 000033B4: 64       4A
  127. 000033B5: 40       40
  128. 000033B6: 00       48
  129. 000033BA: 0F       48
  130. 000033BB: 85       40
  131. 000033BC: A7       41
  132. 000033BD: 00       49
  133. 000033BE: 00       4A
  134. 000033BF: 00       42
  135.  
  136. Source:
  137.  
  138. BASIC
  139. -----
  140.  
  141. DEFINT A-Z
  142. CONST NumOffset = 12                                   ' Number of offsets
  143. CONST FileName = "NOTEPAD.EXE"                         ' Filename
  144. CONST True = -1
  145. CONST False = 0
  146. TYPE CrackType
  147.   Offset AS INTEGER                                    ' The offset
  148.   Original AS INTEGER                                  ' Original code
  149.   ChangeTo AS INTEGER                                  ' Change it to
  150. END TYPE
  151. DIM Crack(1 TO NumOffset) AS CrackType, Byte AS INTEGER
  152. RANDOMIZE TIMER
  153.  
  154. SCREEN 0, 0, 0, 0                                      ' Draw logo
  155. COLOR 7, 0
  156. CLS
  157. COLOR 14, 1
  158.  
  159. PRINT "                                                                          "
  160. PRINT " -= Created By =-                                                         "
  161. PRINT "                                                                          "
  162. PRINT "   ______                                                                 "
  163. PRINT "  /  ___ \  ______   ______   ______   ______   ______   _    _   ______  "
  164. PRINT "  | /   \| /  ___ \ /  __  \ /  __  \ /  ___ \ /  __  \ / \  / \ /  ___ \ "
  165. PRINT "  | |    | | /   \| | /  \ | | /  \ | | /   \| | /  \ | | |  | | | /   \| "
  166. PRINT "  | |      | |_   | | \__/ | | \__/ | | |_   | | \__/ | | |  | | | \____  "
  167. PRINT "  | |      |   \    |  __  / |  __  / |   \    |  __  / | |  | | \____  \ "
  168. PRINT "  | |    | |  _/  | | /  \ \ | /  \ \ |  _/  | | /  \ \ | |  | |      \ | "
  169. PRINT "  | \___/| | \___/| | |  | | | \__/ | | \___/| | |  | | | \__/ | |\___/ | "
  170. PRINT "  \______/ \______/ \_/  \_/ \______/ \______/ \_/  \_/ \______/  \_____/ "
  171. PRINT "                                                                          "
  172. PRINT "                                    cerberus_x@hotmail.com                "
  173. PRINT "                                                                          "
  174. COLOR 7, 0
  175. FOR Count = 1 TO NumOffset                             ' Read DATA into Crack()
  176.   READ Ofs, Ori, Cha
  177.   Crack(Count).Offset = Ofs + 1                        ' Offset
  178.   Crack(Count).Original = Ori                          ' Original code
  179.   Crack(Count).ChangeTo = Cha                          ' Change it to
  180. NEXT Count
  181. ON ERROR GOTO NotValid
  182. OPEN FileName FOR INPUT AS #1: CLOSE
  183. ON ERROR GOTO 0
  184.  
  185. OPEN FileName FOR BINARY AS #1                         ' Open file
  186.   FOR Count = 1 TO NumOffset                           ' Check if file
  187.     Ofs = Crack(Count).Offset                          ' is a valid Notepad
  188.     Ori = Crack(Count).Original
  189.     Bytes$ = " "
  190.     GET #1, Ofs, Bytes$
  191.     Byte = ASC(Bytes$)
  192.     IF Byte <> Ori THEN GOTO NotValid                  ' If not, goto NotValid
  193.   NEXT
  194.  
  195.   PRINT
  196.   PRINT "Creating BackUp [NOTEPAD.CBS]..."
  197.   SHELL "COPY NOTEPAD.EXE NOTEPAD.CBS > Null"          ' Create BackUp
  198.   GOSUB Pause
  199.  
  200.   PRINT
  201.   PRINT "Patching...";
  202.   LOCATE CSRLIN - 1, 1
  203.   FOR Count = 1 TO NumOffset                           ' Apply patch
  204.     Ofs = Crack(Count).Offset
  205.     Cha = Crack(Count).ChangeTo
  206.     Bytes$ = CHR$(Cha)
  207.     PUT #1, Ofs, Bytes$
  208.     GOSUB Pause
  209.   NEXT
  210.   
  211.   PRINT
  212.   PRINT "NotePad successfully patched!"                ' Message if OK
  213.   GOTO Quit
  214.  
  215. NotValid:
  216.   PRINT
  217.   PRINT "NotePad.EXE isn't valid!"                     ' Message if not OK
  218.   BEEP
  219.  
  220. Quit:
  221. CLOSE
  222. END
  223.  
  224. Pause:                                                 ' This routine sets a
  225.   t! = TIMER + RND / 6                                 ' delay, so it seems
  226.   DO WHILE TIMER <= t!: LOOP                           ' as if it is a difficult
  227. RETURN                                                 ' task
  228.  
  229. 'DATA acquired from the compare made with File Compare
  230. 'Offset, Original, Change the byte to
  231.  
  232. DATA &H33B1, &HFF, &H41
  233. DATA &H33B2, &H15, &H42
  234. DATA &H33B3, &HA8, &H49
  235. DATA &H33B4, &H64, &H4A
  236. DATA &H33B5, &H40, &H40
  237. DATA &H33B6, &H00, &H48
  238.  
  239. DATA &H33BA, &H0F, &H48
  240. DATA &H33BB, &H85, &H40
  241. DATA &H33BC, &HA7, &H41
  242. DATA &H33BD, &H00, &H49
  243. DATA &H33BE, &H00, &H4A
  244. DATA &H33BF, &H00, &H42
  245.  
  246.  
  247. If you want to E-Mail me, and you want to, mail to this address:
  248.  
  249. cerberus_x@hotmail.com
  250.  
  251. Cerberus
  252.  
  253. --------------------------------------[ Einde ] --------------------------------------
  254.