fraddyrad

Enigma Protector 4.xx and 5.XX unpacker

Aug 4th, 2022
861
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 48.39 KB | None | 0 0
  1. // Enigma Protector 4.xx and 5.XX unpacker by GIV (some parts are from LCF-AT Alternativ 1.1 script and the API fix is from SHADOW_UA script)
  2. // January 22 2016
  3. // PRIVATE
  4. // 3D00F000007E13B800000100 - API COMPARE AND JUMP
  5. // 3B????????0075??B2018BC2C3 - IAT EMULATION ROUTINE
  6. // 8B08C601FF - OEP MARKER
  7. // 85C00F95C08B??????????8B??8? - HWID
  8. // 6A4068001010006800093D006A00E8??????FF - High memory allocation marker
  9. //
  10. // Script-Editing by LCF-AT
  11. // ---------------------------------
  12. // Enter ARImpRec.dll path below
  13. // Added Screw Prevent patch
  14. // Added Dumper
  15. // Added Section Adder
  16. // Added IAT Fixer (using SearchAndRebuildImports@28 of ARImpRec.dll) enter IATSTART & SIZE (last API-Entry+04 bytes / see counter)
  17.  
  18.  
  19. var intermediar
  20. var dumpvm
  21. var disablehighvmalloc
  22. var counter
  23. var sectiuneenigma
  24. var patchedvm
  25. var SIZE
  26. var SIZE2
  27. var primacautarevariabile
  28. var bazacod
  29. var rulat_r
  30.  
  31. call VARS
  32.  
  33. //lc
  34. log "Enigma 4.XX and 5.XX simple HWID bypass, IAT scrambling repair, OEP find by GIV - 0.2a - private"
  35. log "Emulated API'S fixer by PC-RET"
  36. bc
  37. bphwc
  38. bpmc
  39.  
  40. mov rulat_r, 0
  41. var IS_DLL
  42. mov IS_DLL, 0
  43.  
  44. //Change the Arimprec.dll path below or put in unpackme directory
  45.  
  46. gpi CURRENTDIR
  47. mov dir_curent, $RESULT
  48.  
  49. /////////////////////////////////////////////////////
  50. //Declare options
  51. // In case of Demo protected files you can set disablehighvmalloc to 0
  52. //mov arimprecpath, "C:\ARImpRec.dll"
  53.  
  54. // LCF-AT
  55. mov ARIMPREC_PATH, "C:\ARImpRec.dll"
  56.  
  57. mov primacautarevariabile, 0
  58. mov patchedvm, 1 //0=Not patch the high alloc 1=patch the high alloc of the VM
  59. mov dumpvm, 1 //Change to 0 if the OEP is not virtualized
  60. mov disablehighvmalloc, 1 //Change to 0 if the OEP is not virtualized or in case of files protected with DEMO version
  61. mov counter, 0 //Do not change
  62. mov TYPE, 00101000 // MEM_COMMIT|MEM_TOP_DOWN
  63. mov SIZE1, 00100000 //Do not cahnge
  64. //HWID data
  65. mov changeid, 1 //change to 0 if you do not want a HWID change
  66. mov old, "FCD92259AB2EBE7BCB7D46C4AACACD626752" //Your HWID
  67. mov new, "72662259EEF6548F4C6172CDD50B2BB8AED9" //The HWID that need to be
  68. len old
  69. mov marime, $RESULT
  70.  
  71. // If you want to change the HWID use changeid=1 and patchedvm=1
  72. /////////////////////////////////////////////////////
  73.  
  74. alloc 01000000
  75. mov MYSEC, $RESULT
  76. mov MYSEC2, MYSEC
  77.  
  78. gmi eip, PATH
  79. mov exepath, $RESULT
  80. len exepath // length of path+name+".exe" (full path)
  81. sub $RESULT, 4 // length of path+name
  82. mov basepath, exepath, $RESULT
  83.  
  84. gmi eip, MODULEBASE
  85. MOV IMAGEBASE, $RESULT
  86.  
  87. GPA "VirtualAlloc", "kernel32.dll"
  88. mov VirtualAlloc, $RESULT
  89.  
  90. GPA "GetProcAddress", "kernel32.dll"
  91. mov GetProcAddress, $RESULT
  92.  
  93. cmp changeid, 1
  94. ifeq
  95. mov schimbarehwid, 1
  96. else
  97. mov schimbarehwid, 0
  98. endif
  99. //jmp Continuare_VALLOC
  100.  
  101. ////////////////////////////////////////////////////////////
  102. GPA_AGAIN:
  103. bp GetProcAddress
  104. run
  105. bc eip
  106. rtr
  107. bc
  108. bphwc
  109. cmp [esi], #4D5A# ,02
  110. ifeq
  111. cmp esi, 70000000
  112. ja GPA_AGAIN
  113. mov sectiuneenigma, esi
  114. endif
  115. cmp [edi], #4D5A# ,02
  116. ifeq
  117. cmp edi, 70000000
  118. ja GPA_AGAIN
  119. mov sectiuneenigma, edi
  120. endif
  121.  
  122. // LCF-AT Patch
  123. ///////////////////////
  124. find sectiuneenigma, #F646038075??#
  125. cmp $RESULT, 00
  126. je IMPORTS_SCREW_NOT_FOUND
  127. mov IMPORTS_SCREW, $RESULT
  128. mov [IMPORTS_SCREW+04], 0EB, 01
  129. eval "Prevent IMPORTS SCREW at: {IMPORTS_SCREW}"
  130. log $RESULT, ""
  131. ///////////////////////
  132. IMPORTS_SCREW_NOT_FOUND:
  133. log "No IMPORTS SCREW found!"
  134. log "Fixing of IAT could get wrong later!"
  135. ///////////////////////
  136.  
  137.  
  138. NO_INT_VERSION:
  139. findmem #85C00F95C08B??????????8B??8?#, IMAGEBASE
  140. cmp $RESULT, 00
  141. je NP_HWID_BASIC_FOUND
  142. mov REG1, $RESULT+02
  143. find REG1, #85C00F95C08B??????????8B??8?#
  144. mov REG2, $RESULT+02
  145. gci REG1, COMMAND
  146. mov REG1_COM, $RESULT
  147. gci REG2, COMMAND
  148. mov REG2_COM, $RESULT
  149. log ""
  150. log "Possible used RegSheme found!"
  151. log ""
  152. eval "Address: {REG1} - {REG1_COM}"
  153. log $RESULT, ""
  154. eval "Address: {REG2} - {REG2_COM}"
  155. log $RESULT, ""
  156. log ""
  157. ///////////////////////
  158. NP_HWID_BASIC_FOUND:
  159. findmem #89431?83C31C4E75??5F5E5BC3#, IMAGEBASE
  160. cmp $RESULT, 00
  161. jne FOUND_API_TABLE
  162. je NO_MJ_FOUND
  163. pause
  164. pause
  165. ret
  166. ///////////////////////
  167. FOUND_API_TABLE:
  168. mov IAT_TABLE_1, $RESULT
  169. mov [IAT_TABLE_1+02], 14, 01
  170. findmem #33D2????????????74??????????????74??????????????74#, IMAGEBASE
  171. cmp $RESULT, 00
  172. je NO_MJ_FOUND
  173. mov MJ, $RESULT
  174. mov [MJ], #33D2B801000000C3#
  175. log ""
  176. eval "MJ found and patched at: {MJ}"
  177. log $RESULT, ""
  178. ///////////////////////
  179. NO_MJ_FOUND:
  180. findmem #8D047F8B55FC8B4DF0894C820447FF4DD0#, IMAGEBASE
  181. cmp $RESULT, 00
  182. je NO_QUCIK_RD_FOUND
  183. mov QUICK, $RESULT
  184. ///////////////////////
  185. NO_QUCIK_RD_FOUND:
  186. mov [REG1-02], FE, 01
  187. mov [REG2-02], FE, 01
  188. log "HWID EASY BYPASS was patched!"
  189. /////////////////////////////////////////////////////////////
  190. Continuare_VALLOC:
  191.  
  192. bphws VirtualAlloc
  193. //bp VirtualAlloc
  194.  
  195. cmp disablehighvmalloc, 0
  196. ifeq
  197. jmp continuarefaradezactivaremv
  198. endif
  199.  
  200. alloc 01000000
  201. mov zonaalocata, $RESULT
  202.  
  203. bpgoto VirtualAlloc, Verificare
  204. Urmatorul:
  205. inc counter
  206. cmp counter, 500
  207. ifeq
  208. jmp continuarefaradezactivaremv
  209. endif
  210. RUN:
  211. erun
  212. pause
  213.  
  214. ////////////////////////////
  215. Verificare:
  216.  
  217. findmem #5356575583C4F4890C248BF885FF0F95C085D20F95C132C1740A#, bazacod
  218. mov integritate, $RESULT
  219. cmp integritate, 0
  220. ifa
  221. log "Integrity check patched"
  222. log integritate, ""
  223. asm integritate, "xor eax,eax"
  224. asm integritate+2, "ret"
  225. endif
  226.  
  227. findmem #68584D56#, bazacod
  228. var vm_gasit
  229. cmp $RESULT, 0
  230. ifa
  231. mov vm_gasit, $RESULT
  232. log "VMWare run restriction patched"
  233. log $RESULT, ""
  234. //fill vm_gasit, 4, 90
  235. repl vm_gasit, #68584D56#, #5F564947#, 4
  236. endif
  237. findmem #68584D56#, vm_gasit+5
  238. cmp $RESULT, 0
  239. ifa
  240. mov vm_gasit, $RESULT
  241. log $RESULT, ""
  242. //fill vm_gasit, 4, 90
  243. repl vm_gasit, #68584D56#, #5F564947#, 4
  244. endif
  245.  
  246. cmp primacautarevariabile, 0
  247. ifeq
  248. inc primacautarevariabile
  249. findmem #8B08C601FF#, IMAGEBASE
  250. mov oep_in_ecx, $RESULT
  251. cmp oep_in_ecx, 0
  252. ifeq
  253. log "Search pattern for MOV ECX,DWORD PTR DS:[EAX] not found"
  254. pause
  255. ret
  256. endif
  257. bphws oep_in_ecx, "x"
  258. bpgoto oep_in_ecx, procesare_OEP //18.02.2016
  259. log "OEP JUMP:"
  260. log oep_in_ecx,""
  261. findmem #3D00F000007E13B800000100#, IMAGEBASE
  262. cmp $RESULT, 0
  263. ifeq
  264. log "Search pattern for CMP EAX,F000 not found"
  265. pause
  266. ret
  267. endif
  268. mov iatscrambling, $RESULT-15
  269. log ""
  270. log "IAT SCRAMBLING:"
  271. log iatscrambling, ""
  272. //bphws oep_in_ecx, "x"
  273. //bpgoto oep_in_ecx, procesare_OEP
  274. bphws iatscrambling, "x"
  275. bpgoto iatscrambling, IAT_REDIRECTION
  276.  
  277. endif
  278.  
  279. mov bpesp, [esp]
  280. cmp [esp+4], 0
  281. jne RUN
  282. cmp [esp+8], SIZE1
  283. je A1
  284. cmp [esp+C], TYPE
  285. jne RUN
  286. mov [esp+C], 1000 // MEM_COMMIT
  287. mov SIZE2, [esp+08]
  288. ///////////////////////
  289. A1:
  290. bphwc eip
  291. rtr
  292. esti
  293. //bphws eip
  294. cmp [eip], #5D# ,01
  295. ifeq
  296. bp eip
  297. endif
  298. mov eax, MYSEC
  299. mov eax, MYSEC
  300. log ""
  301. log "Allocated memory zone:"
  302. log eax, ""
  303. cmp SIZE2, 0
  304. je A2
  305. add MYSEC, SIZE2
  306. mov SIZE2, 0
  307. bphwc bpesp-6
  308. erun
  309. pause
  310. ///////////////////////
  311. A2:
  312. add MYSEC, SIZE1
  313. //bphwc eip
  314. bc eip
  315. bphws bpesp-6, "x"
  316. erun
  317. jmp VASTOP
  318.  
  319. //HWID 15.01.2016
  320. rularehwid:
  321. gstr eax
  322. cmp $RESULT, 0
  323. ifeq
  324. esto
  325. endif
  326. cmp $RESULT, old
  327. ifeq
  328. log $RESULT, ""
  329. mov [eax], new
  330. log "HWID found and patched"
  331. endif
  332. jmp RUN1
  333.  
  334. ///////////////////////////14.01.2016
  335. RUN1:
  336. ERUN
  337. ///////////////////////
  338. VASTOP:
  339. cmp [esp], 0
  340. jne RUN1
  341. cmp [esp+4], SIZE1
  342. je A11
  343. cmp [esp+08], TYPE
  344. jne RUN1
  345. mov [esp+08], 1000 // MEM_COMMIT
  346. mov SIZE2, [esp+04]
  347. mov patchedvm, 1
  348. ///////////////////////
  349. bphws iatscrambling, "x"
  350. bpgoto iatscrambling, IAT_REDIRECTION
  351. ///////////////////////
  352. A11:
  353. bphwc eip
  354. //bphws eip+06
  355. bp eip+06
  356. erun
  357. log eax,""
  358. cmp patchedvm, 1
  359. ifeq
  360. cmp schimbarehwid, 1
  361. ifeq
  362. inc patchedvm
  363. mov primulbytemv, MYSEC
  364. bphws primulbytemv, "x"
  365. bpgoto primulbytemv, rularehwid
  366. endif
  367. endif
  368. //bphwc eip
  369. bc eip
  370. //bphws bpesp-6, "x"
  371. bp bpesp-6
  372. mov eax, MYSEC
  373. cmp SIZE2, 0
  374. je A22
  375. add MYSEC, SIZE2
  376. mov SIZE2, 0
  377. //bphws bpesp-6, "x"
  378. bp bpesp-6
  379. erun
  380. ///////////////////////
  381. A22:
  382. add MYSEC, SIZE1
  383. erun
  384. jmp VASTOP
  385. ///////////////////////
  386. ////////////////////////////
  387. continuarefaradezactivaremv:
  388. cmp disablehighvmalloc, 0
  389. ifeq
  390. erun
  391. rtr
  392. esti
  393. endif
  394. bc
  395. bphwc
  396.  
  397. ASK_DIALOG0:
  398. MSGYN "Cancel CRC check (first time press NO)?=YES / NO = Go to HWID dialog"
  399. cmp $RESULT, 0
  400. je ASK_DIALOG2
  401.  
  402. CRC:
  403. mov marker, IMAGEBASE
  404. //CRC fix
  405. CRC_FIX:
  406. findmem #83??FF8B????85??7C??4?#, IMAGEBASE
  407. cmp $RESULT, 0
  408. ifeq
  409. je ASK_DIALOG1
  410. endif
  411. mov CRC_PLACE, $RESULT
  412. find CRC_PLACE, #7C#
  413. mov CRC_JUMP, $RESULT
  414.  
  415. mov patchpoint1va, CRC_JUMP
  416. GCI patchpoint1va, COMMAND
  417. mov opcode1, $RESULT
  418. repl CRC_JUMP, #7C#, #EB#, 1
  419. log "CRC PLACE PATCHED:"
  420. log CRC_JUMP, ""
  421. mov marker, CRC_PLACE
  422.  
  423. GCI CRC_JUMP, DESTINATION
  424. find $RESULT, #C3#
  425. mov bp_ret_crc, $RESULT
  426. bphws bp_ret_crc
  427. run
  428. bphwc bp_ret_crc
  429. //eval "{opcode1}"
  430. //asm CRC_JUMP, $RESULT
  431. fill patchpoint1va, 1, 7C
  432. inc marker
  433. //jmp CRC_FIX
  434.  
  435. ASK_DIALOG1:
  436. MSGYN "Cancel API redirection?=YES / NO = Go to OEP"
  437. cmp $RESULT, 0
  438. je oep
  439.  
  440. OEP_FIND:
  441. findmem #8B08C601FF#, IMAGEBASE
  442. cmp $RESULT, 0
  443. ifeq
  444. log "Search pattern for MOV ECX,DWORD PTR DS:[EAX] not found"
  445. pause
  446. ret
  447. endif
  448. mov oep_marker, $RESULT
  449. log ""
  450. log "OEP marker in ECX"
  451. log ""
  452. log oep_marker,""
  453. bphws oep_marker
  454. bpgoto oep_marker, procesare_OEP
  455.  
  456. ASK_DIALOG2:
  457. MSGYN "Is HWID used?=YES / NO = Go to IAT redirection"
  458. cmp $RESULT, 0
  459. je IAT_REDIRECTION
  460. jne HWID_PATCH
  461.  
  462.  
  463. HWID_PATCH:
  464. mov imagebase_HWID, IMAGEBASE
  465. mov hwid_count, 1
  466. //mov marker, imagebase_HWID
  467. mov marker, IMAGEBASE
  468.  
  469. HWID_FIX:
  470. findmem #85C00F95C08B??????????8B??8?#, marker
  471. cmp $RESULT, 0
  472. ifeq
  473. je IAT_REDIRECTION
  474. endif
  475. mov HWID_PLACE, $RESULT
  476. bphws HWID_PLACE
  477. bpgoto HWID_PLACE, HWID_FIX_EXEC
  478. eval "The HWID {hwid_count} is at: {HWID_PLACE}"
  479. log $RESULT, ""
  480. mov marker, HWID_PLACE+1
  481. inc hwid_count
  482. cmp hwid_count, 2
  483. ja IAT_REDIRECTION
  484. jmp HWID_FIX
  485.  
  486.  
  487. IAT_REDIRECTION:
  488. bphwc bpesp-6
  489. bphwc VirtualAlloc
  490. bc
  491. bphwc iatscrambling
  492. mov patchpoint1va, iatscrambling
  493. GCI patchpoint1va, COMMAND
  494. mov opcode1, $RESULT
  495. //bphws iatscrambling
  496. //run
  497.  
  498. IAT_REDIRECTION_SPLIT:
  499. bphwc iatscrambling
  500. asm eip, "inc al"
  501. esti
  502. GCI eip, DESTINATION
  503. find $RESULT, #C3#
  504. mov bp_ret_iat, $RESULT
  505. bphws bp_ret_iat, "x"
  506. erun
  507. bphwc bp_ret_iat
  508. eval "{opcode1}"
  509. asm patchpoint1va, $RESULT
  510.  
  511. bphwc
  512. cmp changeid, 0
  513. ifeq
  514. jmp C_01
  515. endif
  516. bphws primulbytemv, "x"
  517. bpgoto primulbytemv, rularehwid
  518.  
  519. C_01:
  520. bphws oep_in_ecx, "x"
  521. bpgoto oep_in_ecx, procesare_OEP
  522.  
  523. jmp oep
  524.  
  525. oep:
  526. //findmem #8B08C601FF#, IMAGEBASE
  527. //cmp $RESULT, 0
  528. //ifeq
  529. //log "Search pattern for MOV ECX,DWORD PTR DS:[EAX] not found"
  530. //pause
  531. //ret
  532. //endif
  533. //bphwc VirtualAlloc
  534. //mov primulbp, $RESULT
  535. bphws oep_in_ecx, "x"
  536. run
  537. bphwc oep_in_ecx
  538. jmp procesare_OEP
  539.  
  540. procesare_OEP:
  541. bphwc oep_in_ecx //18.02.2016
  542. //bc
  543. //bphwc
  544. //dbh
  545. esti
  546. mov saltoep, ecx
  547. bphws saltoep, "x"
  548. erun
  549. bphwc saltoep
  550. esti
  551. jmp sfarsit
  552.  
  553.  
  554. sfarsit:
  555. bphwc
  556. bc
  557. bpmc
  558.  
  559. cmp disablehighvmalloc, 1
  560. ifeq
  561. //dm VM_address, vm_size, fisier
  562. mov eax, MYSEC2
  563. mov edi, eax
  564. sub edi, IMAGEBASE
  565. MOV SPLICESRVA, edi
  566. mov ecx, MYSEC
  567. sub ecx, eax
  568. eval "{eax} VA - {edi} RVA.mem"
  569. mov filelc, $RESULT
  570. mov fisier, filelc
  571. dm eax,ecx, filelc
  572. //msg "Now dump file / Add section use right RVA / Validate file & Fix file with Lord-PE! \r\n\r\nSmall part from one script of LCF-AT"
  573. endif
  574.  
  575. cmt eip, "<----------This is the entry point - GIV"
  576. //lc
  577. log "****************************************************************************************"
  578. log "Made in 2016"
  579. log ""
  580. log "Current directory:"
  581. log dir_curent, ""
  582. log ""
  583. log "Imagebase of the module:"
  584. log ""
  585. log IMAGEBASE, ""
  586. log ""
  587. log "This is the OEP VA:"
  588. log ""
  589. log eip, ""
  590. log ""
  591. log "This is the OEP RVA:"
  592. mov OEP, eip
  593. sub OEP, IMAGEBASE
  594. log ""
  595. log OEP, ""
  596. log ""
  597. eval "The VM have been dumped in file: {filelc}"
  598. mov mesaj, $RESULT
  599. log mesaj, ""
  600. cmp [eip], #83EC04#, 03
  601. log ""
  602. ifeq
  603. msgyn "The file semms to be multiple packed. The second layer seems to be Themida. Dump the file?"
  604. cmp $RESULT, 1
  605. ifeq
  606. dpe "c:\unpacked.exe", eip
  607. msg "The dumped file is c:\unpacked.exe"
  608. endif
  609. endif
  610. //MSGYN "Search and fix VM API's?=YES/NO=End script"
  611. log "This part was done by by PC-RET"
  612. //cmp $RESULT, 1
  613. //je VM_API_FIX
  614. jmp VM_API_FIX
  615. ////////////////////
  616. finalizare:
  617.  
  618. // LCF-AT
  619. ////////////////////
  620. ASK_FOR_IAT_DATAS:
  621. ask "Enter the IAT Start VA address!"
  622. cmp $RESULT, -1
  623. je ASK_FOR_IAT_DATAS
  624. cmp $RESULT, 00
  625. je ASK_FOR_IAT_DATAS
  626. mov IATSTART, $RESULT
  627. mov IATRVA, $RESULT
  628. eval "IATSTART VA: {IATRVA}"
  629. log $RESULT, ""
  630. gmi IATRVA, MODULEBASE
  631. sub IATRVA, $RESULT
  632. eval "IATSTART RVA: {IATRVA}"
  633. log $RESULT, ""
  634. ////////////////////
  635. ASK_FOR_IAT_LENGHT:
  636. ask "Enter the IAT size from start till end!"
  637. cmp $RESULT, -1
  638. je ASK_FOR_IAT_LENGHT
  639. cmp $RESULT, 00
  640. je ASK_FOR_IAT_LENGHT
  641. mov IATSIZE, $RESULT
  642. eval "IATSIZE : {IATSIZE}"
  643. log $RESULT, ""
  644. mov IATEND, IATSTART
  645. add IATEND, IATSIZE
  646. call DUMPER
  647. call FIXER
  648. cmp disablehighvmalloc, 01
  649. jne NO_SECTION_ADDING
  650. call ADDER
  651. ////////////////////
  652. NO_SECTION_ADDING:
  653.  
  654. jmp Recuperare_cod
  655. ret
  656.  
  657. HWID_FIX_EXEC:
  658. bc
  659. exec
  660. mov al,1
  661. ende
  662. bphwc iatscrambling
  663. call IAT_REDIRECTION
  664. ret
  665.  
  666.  
  667. VM_API_FIX:
  668. ////////////////////////////////////////////////////////////////////////////////
  669. ////////////////////////////////////////////////////////////////////////////////
  670. ///////////////////////Enigma Protector 4.xx VM API Fixer///////////////////////
  671. //////////////////////////////////by PC-RET/////////////////////////////////////
  672. ////////////////////////////////////////////////////////////v0.5.1 public///////
  673. ////////////////////////////////////////////////////////////////////////////////
  674.  
  675.  
  676. log ""
  677. log "Enigma Protector 4.xx VM API Fixer - Public Version"
  678. log "------------------------------------------------------------"
  679. bc
  680. bphwc
  681. bpmc
  682. mov notfixed, 0
  683. mov fixed, 0
  684. pusha
  685. gmi eip, MODULEBASE
  686. mov MODULEBASE, $RESULT
  687. mov eax, $RESULT
  688. mov edi, eax
  689. add eax, 3C
  690. mov eax, edi+[eax]
  691. mov SECTIONS, [eax+06], 02
  692. mov esi, eax+0F8
  693. mov edi, 28
  694. mov ebp, SECTIONS
  695. mov ecx, edi
  696. mul edi, SECTIONS
  697. add edi, esi
  698. sub edi, 28
  699. mov LASTSECTION, [edi+0C]
  700. add LASTSECTION, MODULEBASE
  701. sub edi, 28
  702. mov ENIGMASECTION, [edi+0C]
  703. add ENIGMASECTION, MODULEBASE
  704. cmp [ENIGMASECTION], #4D5A# ,02
  705. je ENIGMASECTION_FOUND
  706. cmp [LASTSECTION], #4D5A# ,02
  707. je ENIGMASECTION_FOUND_LAST
  708. ENIGMAENTER:
  709. ask "Please enter ENIGMA section address:"
  710. cmp $RESULT, 0
  711. je canceled
  712. mov ENIGMASECTION, $RESULT
  713. cmp [ENIGMASECTION], #4D5A# ,02
  714. jne ENIGMASUSPICIOUS
  715. jmp start
  716. ENIGMASUSPICIOUS:
  717. eval "The entered VA doesn't seems like ENIGMA section address.\r\n\r\nTry again?"
  718. msgyn $RESULT
  719. cmp $RESULT, 01
  720. je ENIGMAENTER
  721. ENIGMASECTION_FOUND_LAST:
  722. mov ENIGMASECTION, LASTSECTION
  723. ENIGMASECTION_FOUND:
  724. popa
  725. start:
  726. eval "Do you want the script to automatically search for VM'ed imports and fix them?"
  727. msgyn $RESULT
  728. cmp $RESULT, 01
  729. je auto
  730. manual:
  731. ask "Please enter IAT start:"
  732. cmp $RESULT, 0
  733. je canceled
  734. mov IATStart, $RESULT
  735. ask "Please enter IAT end:"
  736. cmp $RESULT, 0
  737. je canceled
  738. mov IATEnd, $RESULT
  739. mov IATSize,IATEnd
  740. sub IATSize,IATStart
  741.  
  742. log "------------------IAT data------------------"
  743. log "IAT start address:"
  744. log IATStart,""
  745. log "IAT end address:"
  746. log IATEnd,""
  747. log "IAT size:"
  748. log IATSize,""
  749. log " "
  750. log "--------------------------------------------"
  751.  
  752.  
  753. gmemi ENIGMASECTION, MEMORYSIZE
  754. mov ENIGMASIZE, $RESULT
  755. gpi MAINBASE
  756. mov filebase, $RESULT
  757. gmi filebase, CODEBASE
  758. mov CODESECTION, $RESULT
  759. gmi filebase, CODESIZE
  760. mov CODESIZE, $RESULT
  761. alloc 2000
  762. mov VMAPILOGGER, $RESULT
  763. alloc 1000
  764. mov vmapialloc, $RESULT
  765. mov [vmapialloc], #60BBAAAAAAAABEBBBBBBBBBFCCCCCCCC03F33BDE0F8711000000833B000F850E00000083C304E9E7FFFFFFE91D000000908B1381FA0070530072E881FA00907C0077E0891F89570483C708EBD66190#
  766. mov [vmapialloc+2], IATStart
  767. mov [vmapialloc+7], IATSize
  768. mov [vmapialloc+C], VMAPILOGGER
  769. mov [vmapialloc+35], ENIGMASECTION
  770. mov [vmapialloc+3D], ENIGMASECTION
  771. add [vmapialloc+3D], ENIGMASIZE
  772. mov OEP, eip
  773. mov eip, vmapialloc
  774. bp vmapialloc+4E
  775. run
  776. jmp vmpapialloc_set
  777. auto:
  778. gmemi ENIGMASECTION, MEMORYSIZE
  779. mov ENIGMASIZE, $RESULT
  780. gpi MAINBASE
  781. mov filebase, $RESULT
  782. gmi filebase, CODEBASE
  783. mov CODESECTION, $RESULT
  784. gmi filebase, CODESIZE
  785. mov CODESIZE, $RESULT
  786. alloc 2000
  787. mov VMAPILOGGER, $RESULT
  788. alloc 1000
  789. mov vmapialloc, $RESULT
  790. mov [vmapialloc], #60BB00104000BE00400E00BF0000320503F383EE013BDE0F841100000066813BFF250F840C00000043E9E7FFFFFFE930000000908B5302FF7302E820BD4F7783F80174E48B1281FA0070E70372DA81FA0050420477D28B4B02890F89570483C708EBC5BB00104000BE00400E0003F383EE013BDE0F841100000066813BFF150F840C00000043E9E7FFFFFFE930000000908B5302FF7302E8C3BC4F7783F80174E48B1281FA0070E70372DA81FA0050420477D28B4B02890F89570483C708EBC56190#
  791. mov [vmapialloc+2], CODESECTION
  792. mov [vmapialloc+7], CODESIZE
  793. mov [vmapialloc+C], VMAPILOGGER
  794. mov [vmapialloc+64], CODESECTION
  795. mov [vmapialloc+69], CODESIZE
  796. mov [vmapialloc+48], ENIGMASECTION
  797. mov [vmapialloc+50], ENIGMASECTION
  798. add [vmapialloc+50], ENIGMASIZE
  799. mov [vmapialloc+A5], ENIGMASECTION
  800. mov [vmapialloc+AD], ENIGMASECTION
  801. add [vmapialloc+AD], ENIGMASIZE
  802. GPA "IsBadCodePtr", "kernel32.dll"
  803. mov IsBadCodePtr, $RESULT
  804. eval "call {IsBadCodePtr}"
  805. asm vmapialloc+3A, $RESULT
  806. eval "call {IsBadCodePtr}"
  807. asm vmapialloc+97, $RESULT
  808. mov OEP, eip
  809. mov eip, vmapialloc
  810. bp vmapialloc+C1
  811. run
  812. vmpapialloc_set:
  813. mov eip, OEP
  814. mov esp_addr, esp
  815. pusha
  816. alloc 1000
  817. mov searchalloc, $RESULT
  818. mov [searchalloc], #60B800000000B900000000BE0000000003C883E9013BC10F840F0000008038E90F840800000040E9E9FFFFFF90908B500103D083C20581FA0000000072E83BD177E49090803A6875DD39720175D86190#
  819. mov [searchalloc+2], ENIGMASECTION
  820. mov [searchalloc+38], ENIGMASECTION
  821. mov [searchalloc+7], ENIGMASIZE
  822. looplogger:
  823. mov origapiaddr, [VMAPILOGGER]
  824. mov vmedlocation, [VMAPILOGGER+4]
  825. cmp origapiaddr, 0
  826. je end
  827. gmemi [origapiaddr], MEMORYBASE
  828. cmp $RESULT, ENIGMASECTION
  829. jne next4bytes
  830. mov eip, vmedlocation
  831. loopsti:
  832. find eip, #68????????#
  833. cmp $RESULT, 0
  834. jne foundpointer_push
  835. findmovpointer:
  836. find eip, #C70424#
  837. cmp $RESULT, 0
  838. jne foundpointer_mov
  839. do_sti:
  840. sti
  841. jmp loopsti
  842. foundpointer_push:
  843. cmp $RESULT, eip
  844. jne findmovpointer
  845. jmp endsearch
  846. foundpointer_mov:
  847. cmp $RESULT, eip
  848. jne do_sti
  849. jmp endsearch
  850. endsearch:
  851. cmp [eip], #68#, 1
  852. je push_type
  853. cmp [eip], #C70424#, 3
  854. je mov_type
  855. push_type:
  856. mov searchpointer, [eip+1], 4
  857. jmp startsearch
  858. mov_type:
  859. mov searchpointer, [eip+3], 4
  860. startsearch:
  861. mov [searchalloc+C], searchpointer
  862. mov bakeip, eip
  863. mov eip, searchalloc
  864. bp searchalloc+2C
  865. bp searchalloc+4E
  866. run
  867. bc
  868. cmp eip,searchalloc+2C
  869. je next4bytes1
  870. cmp eip,searchalloc+4E
  871. je foundpointer
  872. jmp end
  873. foundpointer:
  874. mov addr_result, eax
  875. and addr_result, f0
  876. cmp addr_result, 0
  877. jne normal
  878. mov addr_result, eax
  879. alloc 100
  880. mov alloc1, $RESULT
  881. mov [alloc1], addr_result
  882. rev [alloc1]
  883. mov addr_result, $RESULT
  884. eval #0{addr_result}#
  885. mov addr_result, $RESULT
  886. mov addr_result_bak, $RESULT
  887. free alloc1
  888. jmp after_notnormal
  889. normal:
  890. mov addr_result, eax
  891. mov addr_result_bak, eax
  892. after_notnormal:
  893. sti
  894. mov searchaddr_start, ENIGMASECTION
  895. searchres:
  896. find searchaddr_start, addr_result
  897. cmp $RESULT, 0
  898. je next4bytes1
  899. mov addr_result, $RESULT
  900.  
  901. gmi [addr_result-4], MODULEBASE
  902. mov mdbase, $RESULT
  903. cmp mdbase, 0
  904. je cont_s
  905. cmp mdbase, [addr_result-8]
  906. jne cont_s
  907. jmp stop_search
  908.  
  909. cont_s:
  910. mov searchaddr_start, addr_result
  911. add searchaddr_start, 4
  912. mov addr_result, addr_result_bak
  913. jmp searchres
  914.  
  915. stop_search:
  916. mov [origapiaddr], [addr_result-4]
  917. gn [addr_result-4]
  918. mov apiname, $RESULT_2
  919. add fixed, 1
  920. eval "[INFO]: Fixed at {origapiaddr} - {apiname}"
  921. log $RESULT, ""
  922. mov eip, bakeip
  923. jmp next4bytes
  924. next4bytes:
  925. mov searchpointer, 0
  926. mov addr_result, 0
  927. add VMAPILOGGER, 8
  928. jmp looplogger
  929. next4bytes1:
  930. mov eip, bakeip
  931. add notfixed, 1
  932. eval "[ERROR]: NOT fixed at {origapiaddr}"
  933. log $RESULT, ""
  934. add VMAPILOGGER, 8
  935. mov searchpointer, 0
  936. mov addr_result, 0
  937. jmp looplogger
  938. end:
  939. mov eip, bakeip
  940. free searchalloc
  941. free VMAPILOGGER
  942. free vmapialloc
  943. mov esp, esp_addr
  944. popa
  945. mov eip, OEP
  946. cmp fixed, 0
  947. je nofixed
  948. log " "
  949. log "------------------UIF data------------------"
  950. GPI PROCESSID
  951. MOV PID, $RESULT
  952. log "Process ID:"
  953. log PID,""
  954. log "Code section address:"
  955. log CODESECTION,""
  956. mov codesecend, CODESECTION
  957. add codesecend, CODESIZE
  958. log "Code section end:"
  959. log codesecend,""
  960. log " "
  961. log PID,""
  962. log CODESECTION,""
  963. log codesecend,""
  964. log " "
  965. log "--------------------------------------------"
  966. eval "Job completed.\r\n--------------------------\r\nFixed: {fixed}\r\nNOT fixed: {notfixed}\r\n--------------------------\r\nCheck log for more details."
  967. jmp DONE1
  968. nofixed:
  969. eval "Job completed.\r\nNothing has been fixed."
  970. DONE1:
  971. msg $RESULT
  972.  
  973. Recuperare_cod:
  974. cmp rulat_r, 0
  975. ja Sfarsit
  976. MSGYN "Do you want to recover virtualized OEP?"
  977. cmp $RESULT, 0
  978. ifeq
  979. mov rulat_r, 1
  980. jmp finalizare
  981. //jmp Sfarsit
  982. endif
  983.  
  984. GMI eip, CODEBASE
  985. mov bazacod, $RESULT
  986. GMI eip, CODESIZE
  987. mov marimecod, $RESULT
  988.  
  989. VAR INTRARE
  990. //ask "Enter the EIP of the stolen OEP"
  991. mov INTRARE, eip
  992. //mov INTRARE, 0041F372
  993.  
  994.  
  995. BPHWS INTRARE
  996. erun
  997. bphwc INTRARE
  998.  
  999. ask "Enter compiler type: 1 for Delphi 2 for Visual Basic 3 for C++"
  1000. var sFile
  1001. mov tipcompilator, $RESULT
  1002. cmp $RESULT,1
  1003. ifeq
  1004. jmp Delphi
  1005. endif
  1006. cmp $RESULT,2
  1007. ifeq
  1008. jmp vb6
  1009. endif
  1010. cmp $RESULT,3
  1011. ifeq
  1012. jmp C_plus
  1013. endif
  1014.  
  1015. //Target compiler select
  1016. mov delphi, 1
  1017. mov vb6, 0
  1018. mov cpp, 0
  1019. /////////////////
  1020.  
  1021.  
  1022. cmp delphi, 1
  1023. ifeq
  1024. jmp Delphi
  1025. endif
  1026.  
  1027. cmp vb6, 1
  1028. ifeq
  1029. jmp vb6
  1030. endif
  1031.  
  1032. cmp cpp, 1
  1033. ifeq
  1034. jmp C_plus
  1035. endif
  1036.  
  1037.  
  1038. Delphi:
  1039. eval "Recovered_OEP_Delphi.txt"
  1040. mov sFile, $RESULT
  1041. wrt sFile, " "
  1042. wrta sFile, "PUSH EBP"
  1043. wrta sFile, "MOV EBP, ESP"
  1044. wrta sFile, "ADD ESP, -10"
  1045.  
  1046. log "PUSH EBP"
  1047. log "MOV EBP, ESP"
  1048. log "ADD ESP, -10"
  1049.  
  1050. BREAK:
  1051.  
  1052. bc
  1053. bphwc
  1054. bpmc
  1055.  
  1056. BPRM bazacod, marimecod
  1057. erun
  1058. cmp eip, INTRARE
  1059. ifeq
  1060. jmp BREAK
  1061. endif
  1062. cmp eip, bazacod+marimecod
  1063. ifa
  1064. jmp BREAK
  1065. endif
  1066. cmp eax, 01000000
  1067. ifa
  1068. jmp DWORD
  1069. endif
  1070. cmp [eip], #FF25#, 2
  1071. ifeq
  1072. jmp BREAK
  1073. endif
  1074. mov valoareeax, eax
  1075. eval "MOV EAX, 00{valoareeax}"
  1076. LOG $RESULT, ""
  1077. wrta sFile, $RESULT
  1078. eval "MOV ECX, 00{ecx}"
  1079. log $RESULT, ""
  1080. wrta sFile, $RESULT
  1081. eval "MOV EDX, 00{edx}"
  1082. log $RESULT, ""
  1083. wrta sFile, $RESULT
  1084. mov pozitie, eip
  1085. eval "CALL 0{pozitie}"
  1086. log $RESULT, ""
  1087. wrta sFile, $RESULT
  1088.  
  1089. GASIRE_RET:
  1090. bpmc
  1091. cmp [eip], #FF25#, 2
  1092. ifeq
  1093. jmp BREAK
  1094. endif
  1095. find eip, #C3#, 5
  1096. mov adresagasitaret, $RESULT
  1097. cmp adresagasitaret, 0
  1098. ifa
  1099. bp adresagasitaret
  1100. erun
  1101. bc adresagasitaret
  1102. esti
  1103. gci eip, COMMAND
  1104. mov stringoep, $RESULT
  1105. scmpi stringoep, "PUSH 0x0", 4
  1106. cmp $RESULT, 0
  1107. ifa
  1108. jmp Comanda_gci
  1109. endif
  1110. esti
  1111. jmp Comanda_gci
  1112. endif
  1113.  
  1114.  
  1115. find eip, #5?C?#, 1500
  1116. mov adresagasitaret, $RESULT
  1117. cmp adresagasitaret, 0
  1118. ifa
  1119. mov diferenta, adresagasitaret-eip
  1120. cmp diferenta, 35
  1121. ifb
  1122. cmp [adresagasitaret], #5BC3#, 2
  1123. ifeq
  1124. bpmc
  1125. bp adresagasitaret
  1126. erun
  1127. esti
  1128. esti
  1129. jmp Comanda_gci
  1130. endif
  1131. cmp [adresagasitaret], #5DC2#, 2
  1132. ifeq
  1133. bpmc
  1134. bp adresagasitaret
  1135. erun
  1136. esti
  1137. esti
  1138. jmp Comanda_gci
  1139. endif
  1140. msg "Diferenta prea mica"
  1141. endif
  1142. mov adresacomparare, adresagasitaret
  1143. add adresacomparare, 1
  1144. cmp [adresacomparare], #C3#,1
  1145. ifneq
  1146. mov start, eip
  1147. add start, 35
  1148. find start,#E8????????C3#
  1149. bp $RESULT
  1150. erun
  1151. bc
  1152. find eip, #5?C?#
  1153. bp $RESULT
  1154. erun
  1155. bc
  1156. esti
  1157. esti
  1158. jmp Comanda_gci
  1159. //msg "Pauza C3"
  1160. endif
  1161. bp adresagasitaret
  1162. erun
  1163. bc adresagasitaret
  1164. esti
  1165. esti
  1166. jmp Comanda_gci
  1167. endif
  1168.  
  1169. find eip, #5?5?5?5?C3#,500
  1170. bpmc
  1171. mov adresagasitaret, $RESULT
  1172. cmp adresagasitaret, 0
  1173. ifa
  1174. bp adresagasitaret
  1175. erun
  1176. bc adresagasitaret
  1177. esti
  1178. esti
  1179. jmp Comanda_gci
  1180. endif
  1181.  
  1182. cmp adresagasitaret, 0
  1183.  
  1184. Continuare_ret:
  1185. bpmc
  1186. ifa
  1187. bp adresagasitaret
  1188. bpmc
  1189. erun
  1190. endif
  1191. bc adresagasitaret
  1192. esti
  1193. esti
  1194. Comanda_gci:
  1195. GCI eip, COMMAND
  1196. mov comanda, $RESULT
  1197. scmpi comanda, "PUSH 0x0", 4
  1198. ifneq
  1199. jmp GASIRE_RET
  1200. endif
  1201. jmp BREAK
  1202.  
  1203. DWORD:
  1204. /////////
  1205. bc
  1206. bphwc
  1207. /////////
  1208. mov gasire, eax
  1209. rev gasire
  1210. mov gasire, $RESULT
  1211. ///////////////////
  1212. eval "{gasire}"
  1213. mov gasire, $RESULT
  1214. //////////////////
  1215. len gasire
  1216. cmp $RESULT, 7
  1217. ifeq
  1218. eval "0{gasire}"
  1219. mov gasire, $RESULT
  1220. jmp ansamblare_gasire
  1221. endif
  1222. len gasire
  1223. cmp $RESULT, 6
  1224. ifeq
  1225. eval "00{gasire}"
  1226. mov gasire, $RESULT
  1227. endif
  1228. //log gasire, ""
  1229. ansamblare_gasire:
  1230. eval "#{gasire}#"
  1231. mov gasire, $RESULT
  1232. findmem gasire, bazacod
  1233. mov adresa_p, $RESULT
  1234. cmp adresa_p, 0
  1235. ifeq
  1236. GCI eip, COMMAND
  1237. mov comanda, $RESULT
  1238. scmpi comanda, "MOV EDX", 7
  1239. ifeq
  1240. find eip, #58C3#
  1241. bp $RESULT+1
  1242. bpmc
  1243. bphwc
  1244. erun
  1245. bc
  1246. esti
  1247. esti
  1248. jmp Comanda_gci
  1249. endif
  1250. msg "Pointer negasit"
  1251. pause
  1252. endif
  1253. ifa
  1254. eval "MOV EAX, DWORD PTR[{adresa_p}]"
  1255. log $RESULT, ""
  1256. wrta sFile, $RESULT
  1257. cmp ecx, 401000
  1258. ifa
  1259. eval "MOV ECX, 00{ecx}"
  1260. log $RESULT, ""
  1261. wrta sFile, $RESULT
  1262. endif
  1263. cmp edx, 401000
  1264. ifa
  1265. eval "MOV EDX, 00{edx}"
  1266. log $RESULT, ""
  1267. wrta sFile, $RESULT
  1268. endif
  1269. mov pozitie, eip
  1270. eval "CALL 0{pozitie}"
  1271. log $RESULT, ""
  1272. wrta sFile, $RESULT
  1273. jmp GASIRE_RET
  1274.  
  1275. vb6:
  1276. eval "Recovered_OEP_VB6.txt"
  1277. mov sFile, $RESULT
  1278. wrt sFile, " "
  1279. findmem #5642??21#, bazacod
  1280. mov variabilapush, $RESULT
  1281. cmp variabilapush,0
  1282. ifeq
  1283. msg "Pattern not found for push value - VB6"
  1284. jmp Sfarsit
  1285. endif
  1286. eval "PUSH 00{variabilapush}"
  1287. LOG $RESULT, ""
  1288. wrta sFile, $RESULT
  1289. asm eip, $RESULT
  1290. mov variabilacall, eip-6
  1291. eval "CALL 00{variabilacall}"
  1292. LOG $RESULT, ""
  1293. wrta sFile, $RESULT
  1294. asm eip+5, $RESULT
  1295. jmp Sfarsit
  1296.  
  1297. C_plus:
  1298. bc
  1299. bphwc
  1300. bpmc
  1301. BPRM bazacod, marimecod
  1302. erun
  1303. MOV intrarecallc, eip
  1304. eval "Recovered_OEP_CPP.txt"
  1305. mov sFile, $RESULT
  1306. wrt sFile, " "
  1307. EVAL "CALL {intrarecallc}"
  1308. log $RESULT, ""
  1309. wrta sFile, $RESULT
  1310. ASM INTRARE, $RESULT
  1311. bc
  1312. bphwc
  1313. bpmc
  1314. rtr
  1315. esti
  1316. BPRM bazacod, marimecod
  1317. erun
  1318. MOV jmpc, eip
  1319. EVAL "JMP {jmpc}"
  1320. log $RESULT, ""
  1321. wrta sFile, $RESULT
  1322. ASM INTRARE+5, $RESULT
  1323. jmp Sfarsit
  1324.  
  1325. Sfarsit:
  1326. msg "Script is finished"
  1327. //endif
  1328. pause
  1329. pause
  1330. ret
  1331. canceled:
  1332. msg "Canceled by user"
  1333. pause
  1334. pause
  1335. ret
  1336. ////////////////////
  1337. ////////////////////
  1338. ////////////////////
  1339. VARS:
  1340. var EXEFILENAME
  1341. var CURRENTDIR
  1342. var EXEFILENAME_LEN
  1343. var CURRENTDIR_LEN
  1344. var LoadLibraryA
  1345. var VirtualAlloc
  1346. var GetModuleHandleA
  1347. var GetModuleFileNameA
  1348. var GetCurrentProcessId
  1349. var OpenProcess
  1350. var malloc
  1351. var free
  1352. var ReadProcessMemory
  1353. var CloseHandle
  1354. var VirtualFree
  1355. var CreateFileA
  1356. var WriteFile
  1357. var GetFileSize
  1358. var ReadFile
  1359. var SetFilePointer
  1360. var GetCommandLineA
  1361. var CreateFileMappingA
  1362. var MapViewOfFile
  1363. var lstrcpynA
  1364. var VirtualLock
  1365. var SetEndOfFile
  1366. var VirtualUnlock
  1367. var UnmapViewOfFile
  1368. var lstrlenA
  1369. var ldiv
  1370. var PATCH_CODESEC
  1371. var BAK_EIP
  1372. var ARIMPREC_PATH
  1373. var TRY_NAMES
  1374. var SearchAndRebuildImports
  1375. var PID
  1376. var IATRVA
  1377. var IATSIZE
  1378. var REBUILD_PATCH
  1379. var MessageBoxA
  1380. var GetProcAddress
  1381. var DOT_END
  1382. var DeleteFileA
  1383. var MoveFileA
  1384. var SECHANDLE
  1385. var EXEFILENAME_SHORT // xy.exe oder xy.dll
  1386. var OEP_RVA // new rva ohne IB
  1387. var NEW_SEC_RVA // rva of new section
  1388. var NEW_SECTION_NAME // name of dumped section to add
  1389. var NEW_SECTION_PATH // section full path
  1390. gpa "MessageBoxA", "user32.dll"
  1391. mov MessageBoxA, $RESULT
  1392. gpa "MoveFileA", "kernel32.dll"
  1393. mov MoveFileA, $RESULT
  1394. gpa "DeleteFileA", "kernel32.dll"
  1395. mov DeleteFileA, $RESULT
  1396. gpa "GetProcAddress", "kernel32.dll"
  1397. mov GetProcAddress, $RESULT
  1398. gpa "LoadLibraryA", "kernel32.dll"
  1399. mov LoadLibraryA, $RESULT
  1400. gpa "VirtualAlloc", "kernel32.dll"
  1401. mov VirtualAlloc, $RESULT
  1402. gpa "GetModuleHandleA", "kernel32.dll"
  1403. mov GetModuleHandleA, $RESULT
  1404. gpa "GetModuleFileNameA", "kernel32.dll"
  1405. mov GetModuleFileNameA, $RESULT
  1406. gpa "GetCurrentProcessId", "kernel32.dll"
  1407. mov GetCurrentProcessId, $RESULT
  1408. gpa "OpenProcess", "kernel32.dll"
  1409. mov OpenProcess, $RESULT
  1410. gpa "ReadProcessMemory", "kernel32.dll"
  1411. mov ReadProcessMemory, $RESULT
  1412. gpa "CloseHandle", "kernel32.dll"
  1413. mov CloseHandle, $RESULT
  1414. gpa "VirtualFree", "kernel32.dll"
  1415. mov VirtualFree, $RESULT
  1416. gpa "CreateFileA", "kernel32.dll"
  1417. mov CreateFileA, $RESULT
  1418. gpa "WriteFile", "kernel32.dll"
  1419. mov WriteFile, $RESULT
  1420. gpa "GetFileSize", "kernel32.dll"
  1421. mov GetFileSize, $RESULT
  1422. gpa "ReadFile", "kernel32.dll"
  1423. mov ReadFile, $RESULT
  1424. gpa "SetFilePointer", "kernel32.dll"
  1425. mov SetFilePointer, $RESULT
  1426. gpa "GetCommandLineA", "kernel32.dll"
  1427. mov GetCommandLineA, $RESULT
  1428. gpa "CreateFileMappingA", "kernel32.dll"
  1429. mov CreateFileMappingA, $RESULT
  1430. gpa "MapViewOfFile", "kernel32.dll"
  1431. mov MapViewOfFile, $RESULT
  1432. gpa "lstrcpynA", "kernel32.dll"
  1433. mov lstrcpynA, $RESULT
  1434. gpa "VirtualLock", "kernel32.dll"
  1435. mov VirtualLock, $RESULT
  1436. gpa "SetEndOfFile", "kernel32.dll"
  1437. mov SetEndOfFile, $RESULT
  1438. gpa "VirtualUnlock", "kernel32.dll"
  1439. mov VirtualUnlock, $RESULT
  1440. gpa "UnmapViewOfFile", "kernel32.dll"
  1441. mov UnmapViewOfFile, $RESULT
  1442. gpa "lstrlenA", "kernel32.dll"
  1443. mov lstrlenA, $RESULT
  1444. ret
  1445. ////////////////////
  1446. DUMPER:
  1447. gpi EXEFILENAME
  1448. mov EXEFILENAME, $RESULT
  1449. len EXEFILENAME
  1450. mov EXEFILENAME_LEN, $RESULT
  1451. gpi CURRENTDIR
  1452. mov CURRENTDIR, $RESULT
  1453. len CURRENTDIR
  1454. mov CURRENTDIR_LEN, $RESULT
  1455. pusha
  1456. alloc 1000
  1457. mov eax, $RESULT
  1458. mov esi, eax
  1459. mov [eax], EXEFILENAME
  1460. add eax, CURRENTDIR_LEN
  1461. mov ecx, EXEFILENAME_LEN
  1462. sub ecx, CURRENTDIR_LEN
  1463. readstr [eax], ecx
  1464. mov EXEFILENAME_SHORT, $RESULT
  1465. str EXEFILENAME_SHORT
  1466. add eax, 10
  1467. add eax, ecx
  1468. mov [eax], "msvcrt.dll"
  1469. mov edi, LoadLibraryA
  1470. exec
  1471. push eax
  1472. call edi
  1473. ende
  1474. cmp eax, 00
  1475. jne MSVCRT_LOADED
  1476. msg "Can't load msvcrt.dll!"
  1477. pause
  1478. pause
  1479. cret
  1480. ret
  1481. ////////////////////
  1482. MSVCRT_LOADED:
  1483. free esi
  1484. popa
  1485. gpa "malloc", "msvcrt.dll"
  1486. mov malloc, $RESULT
  1487. gpa "free", "msvcrt.dll"
  1488. mov free, $RESULT
  1489. gpa "ldiv", "msvcrt.dll"
  1490. mov ldiv, $RESULT
  1491. ////////////////////
  1492. ASK_OEP_RVA:
  1493. // ask "Enter new OEP RVA"
  1494. // cmp $RESULT, 00
  1495. // je ASK_OEP_RVA
  1496. // cmp $RESULT, -1
  1497. // je ASK_OEP_RVA
  1498. mov OEP_RVA, eip
  1499. gmi OEP_RVA, MODULEBASE
  1500. sub OEP_RVA, $RESULT
  1501. ////////////////////
  1502. START_OF_PATCH:
  1503. mov BAK_EIP, eip
  1504. alloc 2000
  1505. mov PATCH_CODESEC, $RESULT
  1506. mov eip, PATCH_CODESEC+09F
  1507. alloc 1000
  1508. //new
  1509. mov NAME_FILE, $RESULT
  1510. mov [NAME_FILE], EXEFILENAME_SHORT
  1511. mov [PATCH_CODESEC], OEP_RVA
  1512. // mov [PATCH_CODESEC+04], EXEFILENAME_SHORT
  1513. mov [PATCH_CODESEC+86], "msvcrt.dll"
  1514. mov [PATCH_CODESEC+09F], #C705AAAAAAAA000000008925AAAAAAAAA3AAAAAAAA890DAAAAAAAA8915AAAAAAAA891DAAAAAAAA892DAAAAAAAA8935AAAAAAAA893DAAAAAAAA#
  1515. mov [PATCH_CODESEC+0D8], #68AAAAAAAAE8D9BA21BB83F8000F84920400006A40680010000068004000006A00E8BDBA21BB83F8000F8476040000A3AAAAAAAA05002000008BE08BE881ED000200006A40680010000068001000006A00E88DBA21BB#
  1516. mov [PATCH_CODESEC+12E], #83F8000F8446040000A3AAAAAAAA6A40680010000068001000006A00E86CBA21BB83F8000F8425040000A3AAAAAAAA68AAAAAAAAE854BA21BB83F8000F840D0400006800100000FF35AAAAAAAA50E83ABA21BB83F8000F84F303000068AAAAAAAAE827BA21BB#
  1517. mov [PATCH_CODESEC+194], #83F8000F84E0030000A3AAAAAAAA8B483C03C88B51508915AAAAAAAA6800100000FF35AAAAAAAAFF35AAAAAAAAE8F5B921BB83F8000F84AE030000A3AAAAAAAA0305AAAAAAAA#
  1518. mov [PATCH_CODESEC+1DA], #83E8046681382E64741A6681382E4474136681382E65741B6681382E457414E97F030000C7005F44502EC74004646C6C00EB0FC7005F44502EC7400465786500EB00E89AB921BBA3AAAAAAAAFF35AAAAAAAA6A006A10E886B921BB#
  1519. mov [PATCH_CODESEC+235], #83F8000F843F030000A3AAAAAAAA33C0FF35AAAAAAAAE86BB921BB83F8000F8424030000A3AAAAAAAA8D55D852FF35AAAAAAAAFF35AAAAAAAAA1AAAAAAAA50FF35AAAAAAAAE83CB921BB83F8000F84F5020000FF35AAAAAAAAE828B921BB#
  1520. mov [PATCH_CODESEC+293], #83F8000F84E10200006A40680010000068002000006A00E80CB921BB83F8000F84C5020000A3AAAAAAAAA1AAAAAAAA8B0DAAAAAAAA518B35AAAAAAAA568BD052E883010000A1AAAAAAAA03403C8BF08B1DAAAAAAAA#
  1521. mov [PATCH_CODESEC+2E8], #895E28E805010000A1AAAAAAAA03403C8B40508B15AAAAAAAA8B35AAAAAAAA894424108954246C525056E87A0000008B25AAAAAAAA68008000006A00FF35AAAAAAAA#
  1522. mov [PATCH_CODESEC+32A], #E88CB821BB68008000006A00FF35AAAAAAAAE87AB821BB68008000006A00FF35AAAAAAAAE868B821BB68008000006A00FF35AAAAAAAAE856B821BBA1AAAAAAAA8B0DAAAAAAAA8B15AAAAAAAA8B1DAAAAAAAA8B2DAAAAAAAA8B35AAAAAAAA8B3DAAAAAAAA#
  1523. mov [PATCH_CODESEC+38E], #9090908974240CA1AAAAAAAA566A0068800000006A026A006A0368000000C050E808B821BB8BF083FEFF0F84BF0100008B54240CA1AAAAAAAA8D4C24106A0051525056E8E5B721BB83F8000F849E01000056E8D6B721BB#
  1524. mov [PATCH_CODESEC+3E5], #83F8000F848F010000B8010000005EC333D23BC20F847E01000033C9668B48148D4C08188955FC8955E433F6668B70063BD6731C8B710C8971148B710889711083C128894DE042EBDEC745FCFFFFFFFFB90010000089483C894854C3#
  1525. mov [PATCH_CODESEC+441], #9090B8010000008B4DF064890D000000005F5E5B8BE55DC3909081EC3C01000053555633ED575568800000006A03556A01680000008050E83EB721BB8BF083FEFF7512E9F40000005F5E5D33C05B81C43C010000C3#
  1526. mov [PATCH_CODESEC+496], #6A0056E81DB721BB83F8FF0F84D6000000BFBBBBBBBB8D4C24106A00518D54241C6A405256FFD785C00F84B800000066817C24144D5A7412E9AA0000005F5E5D33C05B81C43C010000C38B442450BBBBBBBBBB#
  1527. mov [PATCH_CODESEC+4E9], #6A006A005056FFD38D4C24106A00518D54245C68F80000005256FFD785C00F8470000000817C2454504500000F85620000008B8424A80000008B8C24580100003BC10F874C0000006A006A006A0056FFD38B9424A80000008B8424540100008D4C24106A0051525056FFD7#
  1528. mov [PATCH_CODESEC+554], #85C00F8421000000BD0100000056E854B621BB83F8000F840D0000005F8BC55E5D5B81C43C010000C39090#
  1529. pusha
  1530. mov eax, PATCH_CODESEC
  1531. add eax, 09F
  1532. mov ecx, PATCH_CODESEC
  1533. mov [eax+002], ecx
  1534. mov [eax+006], OEP_RVA
  1535. mov [eax+00C], ecx+04E
  1536. mov [eax+011], ecx+05A
  1537. mov [eax+017], ecx+05E
  1538. mov [eax+01D], ecx+062
  1539. mov [eax+023], ecx+066
  1540. mov [eax+029], ecx+06A
  1541. mov [eax+02F], ecx+06E
  1542. mov [eax+035], ecx+072
  1543. mov [eax+03A], ecx+086
  1544. eval "call {LoadLibraryA}"
  1545. asm eax+03E, $RESULT
  1546. eval "call {VirtualAlloc}"
  1547. asm eax+05A, $RESULT
  1548. mov [eax+069], ecx+052
  1549. eval "call {VirtualAlloc}"
  1550. asm eax+08A, $RESULT
  1551. mov [eax+099], ecx+076
  1552. eval "call {VirtualAlloc}"
  1553. asm eax+0AB, $RESULT
  1554. mov [eax+0BA], ecx+07A
  1555. // mov [eax+0BF], ecx+004
  1556. mov [eax+0BF], NAME_FILE
  1557. eval "call {GetModuleHandleA}"
  1558. asm eax+0C3, $RESULT
  1559. mov [eax+0D8], ecx+07A
  1560. eval "call {GetModuleFileNameA}"
  1561. asm eax+0DD, $RESULT
  1562. // mov [eax+0EC], ecx+004
  1563. mov [eax+0EC], NAME_FILE
  1564. eval "call {GetModuleHandleA}"
  1565. asm eax+0F0, $RESULT
  1566. mov [eax+0FF], ecx+032
  1567. mov [eax+10D], ecx+036
  1568. mov [eax+118], ecx+076
  1569. mov [eax+11E], ecx+032
  1570. eval "call {GetModuleFileNameA}"
  1571. asm eax+122, $RESULT
  1572. mov [eax+131], ecx+056
  1573. mov [eax+137], ecx+076
  1574. eval "call {GetCurrentProcessId}"
  1575. asm eax+17D, $RESULT
  1576. mov [eax+183], ecx+03A
  1577. mov [eax+189], ecx+03A
  1578. eval "call {OpenProcess}"
  1579. asm eax+191, $RESULT
  1580. mov [eax+1A0], ecx+03E
  1581. mov [eax+1A8], ecx+036
  1582. eval "call {malloc}"
  1583. asm eax+1AC, $RESULT
  1584. mov [eax+1BB], ecx+046
  1585. mov [eax+1C5], ecx+036
  1586. mov [eax+1CB], ecx+046
  1587. mov [eax+1D0], ecx+032
  1588. mov [eax+1D7], ecx+03E
  1589. eval "call {ReadProcessMemory}"
  1590. asm eax+1DB, $RESULT
  1591. mov [eax+1EB], ecx+03E
  1592. eval "call {CloseHandle}"
  1593. asm eax+1EF, $RESULT
  1594. eval "call {VirtualAlloc}"
  1595. asm eax+20B, $RESULT
  1596. mov [eax+21A], ecx+02E
  1597. mov [eax+21F], ecx+07A
  1598. mov [eax+225], ecx+036
  1599. mov [eax+22C], ecx+02E
  1600. mov [eax+23A], ecx+046
  1601. mov [eax+245], ecx
  1602. mov [eax+252], ecx+046
  1603. mov [eax+25E], ecx+046
  1604. mov [eax+264], ecx+076
  1605. mov [eax+27A], ecx+04E
  1606. mov [eax+287], ecx+052
  1607. eval "call {VirtualFree}"
  1608. asm eax+28B, $RESULT
  1609. mov [eax+299], ecx+076
  1610. eval "call {VirtualFree}"
  1611. asm eax+29D, $RESULT
  1612. mov [eax+2AB], ecx+07A
  1613. eval "call {VirtualFree}"
  1614. asm eax+2AF, $RESULT
  1615. mov [eax+2BD], ecx+02E
  1616. eval "call {VirtualFree}"
  1617. asm eax+2C1, $RESULT
  1618. mov [eax+2C7], ecx+05A
  1619. mov [eax+2CD], ecx+05E
  1620. mov [eax+2D3], ecx+062
  1621. mov [eax+2D9], ecx+066
  1622. mov [eax+2DF], ecx+06A
  1623. mov [eax+2E5], ecx+06E
  1624. mov [eax+2EB], ecx+072
  1625. mov [eax+2F7], ecx+076
  1626. eval "call {CreateFileA}"
  1627. asm eax+30F, $RESULT
  1628. mov [eax+324], ecx+046
  1629. eval "call {WriteFile}"
  1630. asm eax+332, $RESULT
  1631. eval "call {CloseHandle}"
  1632. asm eax+341, $RESULT
  1633. eval "call {CreateFileA}"
  1634. asm eax+3D9, $RESULT
  1635. eval "call {GetFileSize}"
  1636. asm eax+3FA, $RESULT
  1637. mov [eax+409], ReadFile
  1638. mov [eax+446], SetFilePointer
  1639. eval "call {CloseHandle}"
  1640. asm eax+4C3, $RESULT
  1641. popa
  1642. bp PATCH_CODESEC+38F // success dumping
  1643. bp PATCH_CODESEC+57D // PROBLEM
  1644. esto
  1645. bc
  1646. cmp eip, PATCH_CODESEC+38F
  1647. je DUMPING_SUCCESSFULLY
  1648. msg "Dumping failed by the script! \r\n\r\nDump the file manually! \r\n\r\nLCF-AT"
  1649. pause
  1650. pause
  1651. cret
  1652. ret
  1653. ////////////////////
  1654. DUMPING_SUCCESSFULLY:
  1655. msg "Dumping was successfully by the script! \r\n\r\nLCF-AT"
  1656. mov eip, BAK_EIP
  1657. free PATCH_CODESEC
  1658. ret
  1659. ////////////////////
  1660. ADDER:
  1661. alloc 2000
  1662. mov PATCH_CODESEC, $RESULT
  1663. ////////////////////
  1664. ASK_SECTION_NAME:
  1665. // ask "Enter section name of dumped section with quotes"
  1666. // cmp $RESULT, 00
  1667. // je ASK_SECTION_NAME
  1668. // cmp $RESULT, -1
  1669. // je ASK_SECTION_NAME
  1670. mov $RESULT, filelc
  1671. mov NEW_SECTION_NAME, $RESULT
  1672. log NEW_SECTION_NAME, ""
  1673. ////////////////////
  1674. ASK_NEW_SEC_RVA:
  1675. // ask "Enter new section RVA or nothing"
  1676. // cmp $RESULT, -1
  1677. // je ASK_NEW_SEC_RVA
  1678. mov $RESULT, SPLICESRVA
  1679. mov NEW_SEC_RVA, $RESULT
  1680. eval "{CURRENTDIR}{NEW_SECTION_NAME}"
  1681. mov NEW_SECTION_PATH, $RESULT
  1682. log NEW_SECTION_PATH, ""
  1683. mov [PATCH_CODESEC], NEW_SEC_RVA
  1684. mov [PATCH_CODESEC+08], NEW_SECTION_NAME
  1685. mov [PATCH_CODESEC+37], EXEFILENAME_SHORT
  1686. mov [PATCH_CODESEC+59], NEW_SECTION_PATH
  1687. mov [PATCH_CODESEC+216], #2E4E657753656300#
  1688. pusha
  1689. mov eax, PATCH_CODESEC
  1690. mov ecx, PATCH_CODESEC
  1691. add eax, 222
  1692. mov eip, eax
  1693. mov [eax], #60B8AAAAAAAAA3AAAAAAAAB8AAAAAA0AA3AAAAAAAA618925AAAAAAAAA3AAAAAAAA890DAAAAAAAA8915AAAAAAAA891DAAAAAAAA892DAAAAAAAA8935AAAAAAAA893DAAAAAAAA8925AAAAAAAA6A40680010000068004000006A00E83BB921BB83F8000F84FD060000A3AAAAAAAA05002000008BE08BE881ED000200006A40680010000068001000006A00E80BB921BB83F800#
  1694. mov [eax+091], #0F84CD060000A3AAAAAAAA8BF868AAAAAAAAE8F1B821BB83F8000F84B30600006800100000FF35AAAAAAAA50E8D7B821BB83F8000F84990600000305AAAAAAAA83E8046681382E64741A6681382E4474136681382E65741B6681382E457414E96F060000C7005F44502EC74004646C6C00EB0FC7005F44502EC7400465786500EB00A1AAAAAAAA8BF8EB37E878B821BB#
  1695. mov [eax+121], #4033C980382274044140EBF72BC1890DAAAAAAAA96F3A4A1AAAAAAAA8BD8031DAAAAAAAA83EB048B3BC7035F44502E897B03FF35AAAAAAAAE80700000090E806010000905355568B742410576A0068800000006A036A006A0368000000C056E814B821BB#
  1696. mov [eax+185], #8BF8A3AAAAAAAA83FFFF7505E9CE0500006A0057E8FBB721BB83F8FF0F84BD0500006A006A006A006A046A0057A3AAAAAAAA898608010000E8D7B721BB83F8008BE885ED7505E9940500006A006A006A006A0655E8BBB721BB83F8000F847D05000055BDBBBBBBBB#
  1697. mov [eax+1ED], #8BD8FFD583F8000F846A050000891DAAAAAAAA8BC38B403C03C3A3AAAAAAAAC780D000000000000000C780D4000000000000008BC885C08D511889861001000089961C010000740583C270EB0383C26033C0899620010000668B4114C78628010000000000005F8D4C081833C0898E24010000890DAAAAAAAA83C40CC36A0068800000006A036A006A01B9AAAAAAAA#
  1698. mov [eax+27C], #680000008051E812B721BB8BD883FBFF7505E9D1040000BDBBBBBBBB6A0053FFD583F8FF0F84BE0400008BF056E8EBB621BBA3AAAAAAAA8BF88D5424146A0052565753E8D5B621BB83F8000F8497040000E8550400008B48148B501003CA8B15AAAAAAAA518B423C50E8560400008B0DAAAAAAAA#
  1699. mov [eax+2F0], #6A006A005051E89EB621BBA1AAAAAAAA8D5424146A0052565750BDBBBBBBBB83F8000F844C04000057E8FD030000E82B030000E8FF0300008BF8566800100000897710E8080400008B0DAAAAAAAA89470851E8E302000083C4108D5424186A095052E842B621BB#
  1700. mov [eax+357], #83F8000F84040400008B4424186A0089078B4C2420894F048B15AAAAAAAA52FFD568AAAAAAAAA3AAAAAAAAE8630200008B1DAAAAAAAA6A0068800000006A036A006A0368000000C053E8F4B521BB83F8FF894424147505E9B10300008B5424146A0052E8DAB521BB83F8FF0F849C0300008BD8895C241C895C24186A046800100000536A00E8B8B521BB#
  1701. mov [eax+3E1], #85C0894424107505E9760300008B4424105350E8A0B521BB8B5424108B4424148D4C24246A0051535250E889B521BB83F8000F844B0300008B4C24108B413C03C1A3AAAAAAAA8BD08B4C24188B5424105152A1AAAAAAAA6033D2668B500633C9668B48148D4C0818BF2800000003CF4A83FA0075F883E928833DAAAAAAAA00#
  1702. mov [eax+460], #74098B35AAAAAAAA89710C61E8940000008BD88B4C24105183C40C8B542414BBBBBBBBBB6A006A006A0052FFD38B4C24188B5424108D4424246A00508B44241C515250E8F1B421BB83F8000F84B30200008B4C24188B5424146A006A005152FFD38B44241450E8CEB421BB#
  1703. mov [eax+4CB], #8B5C241CC7442420010000008B4C24105351E8B7B421BB8B54241068008000006A0052E8A6B421BB8B44241450E89CB421BB909090E9890000005333C9668B481433D2668B5006565783CFFF85D28D4C08187619558D59148BEA8B3385F67406#
  1704. mov [eax+52B], #3BF773028BFE83C3284D75EE5D33F64A85D2897854761A8B51348B790C2BD789510833D2668B500683C128464A3BF272E68B5424148B59148B71082BD38951108B490C85F6740E03CE5F8948505EB8010000005BC3#
  1705. mov [eax+580], #03CA5F8948505EB8010000005BC38B25AAAAAAAA68008000006A00FF35AAAAAAAAE8F3B321BB68008000006A00FF35AAAAAAAAE8E1B321BB8B25AAAAAAAAA1AAAAAAAA8B0DAAAAAAAA8B15AAAAAAAA8B1DAAAAAAAA8B2DAAAAAAAA8B35AAAAAAAA8B3DAAAAAAAA909090#
  1706. mov [eax+5EA], #568B742408A1AAAAAAAA50E89FB321BB8B0DAAAAAAAA8B15AAAAAAAA6A006A005152E888B321BBA1AAAAAAAA50E87DB321BB8B0DAAAAAAAA51E871B321BB5EC3568B74240856E864B321BB8A4C30FF8D4430FF80F9005E7409#
  1707. mov [eax+643], #8A48FF4880F90075F740C3E89A00000085C00F8505000000E9040100005657E8C00000008BF033FFC7464CE00000E0897E30A1AAAAAAAA8B08894E288B500466897E4A89562C66897E48897E448B46148B56108B0DAAAAAAAA03C28B513C5052E898000000#
  1708. mov [eax+6A8], #89463C897E40897E388B460883C4083BC774088B4E0C03C851EB098B560C8B461003D0526800100000E86A000000894634A1AAAAAAAA83C40866FF4006B8010000005F5EC3#
  1709. mov [eax+6ED], #8B0DAAAAAAAA33C033D2668B4106668B51148D04808D04C28B15AAAAAAAA8B523C8D4410408B51543BD01BC040C38B44240450E874B221BB59C38B0DAAAAAAAA33C0668B41068D1480A1AAAAAAAA8D44D0D8C3#
  1710. mov [eax+740], #568B742408578B7C24105657E848B221BB83C40885D27407405F0FAFC65EC38BC75F5EC39090#
  1711. mov [eax+02], ecx+216
  1712. mov [eax+07], ecx+20E
  1713. mov [eax+0C], ecx+008
  1714. mov [eax+11], ecx+1E6
  1715. mov [eax+18], ecx+1DE
  1716. mov [eax+1D], ecx+1BE
  1717. mov [eax+23], ecx+1C2
  1718. mov [eax+29], ecx+1C6
  1719. mov [eax+2F], ecx+1CA
  1720. mov [eax+35], ecx+1CE
  1721. mov [eax+3B], ecx+1D2
  1722. mov [eax+41], ecx+1D6
  1723. mov [eax+47], ecx+1DE
  1724. eval "call {VirtualAlloc}"
  1725. asm eax+59, $RESULT
  1726. mov [eax+68], ecx+1DA
  1727. eval "call {VirtualAlloc}"
  1728. asm eax+89, $RESULT
  1729. mov [eax+98], ecx+20A
  1730. // mov [eax+9F], ecx+037
  1731. mov [eax+9F], NAME_FILE
  1732. eval "call {GetModuleHandleA}"
  1733. asm eax+0A3, $RESULT
  1734. mov [eax+0B8], ecx+20A
  1735. eval "call {GetModuleFileNameA}"
  1736. asm eax+0BD, $RESULT
  1737. mov [eax+0CD], ecx+20A
  1738. mov [eax+114], ecx+20A
  1739. eval "call {GetCommandLineA}"
  1740. asm eax+11C, $RESULT
  1741. mov [eax+131], ecx+21E
  1742. mov [eax+139], ecx+20A
  1743. mov [eax+141], ecx+21E
  1744. mov [eax+155], ecx+20A
  1745. eval "call {CreateFileA}"
  1746. asm eax+180, $RESULT
  1747. mov [eax+188], ecx+206
  1748. eval "call {GetFileSize}"
  1749. asm eax+199, $RESULT
  1750. mov [eax+1B3], ecx+1F2
  1751. eval "call {CreateFileMappingA}"
  1752. asm eax+1BD, $RESULT
  1753. eval "call {MapViewOfFile}"
  1754. asm eax+1D9, $RESULT
  1755. mov [eax+1E9], CloseHandle
  1756. mov [eax+1FC], ecx+1FA
  1757. mov [eax+208], ecx+1FE
  1758. mov [eax+262], ecx+202
  1759. mov [eax+278], ecx+059
  1760. eval "call {CreateFileA}"
  1761. asm eax+282, $RESULT
  1762. mov [eax+294], GetFileSize
  1763. eval "call {malloc}"
  1764. asm eax+2A9, $RESULT
  1765. mov [eax+2AF], ecx+1EA
  1766. eval "call {ReadFile}"
  1767. asm eax+2BF, $RESULT
  1768. mov [eax+2DC], ecx+1FE
  1769. mov [eax+2EC], ecx+206
  1770. eval "call {SetFilePointer}"
  1771. asm eax+2F6, $RESULT
  1772. mov [eax+2FC], ecx+206
  1773. eval "call {WriteFile}"
  1774. asm eax+30A, $RESULT
  1775. mov [eax+33A], ecx+1E6
  1776. eval "call {lstrcpynA}"
  1777. asm eax+352, $RESULT
  1778. mov [eax+371], ecx+206
  1779. mov [eax+379], ecx+20A
  1780. mov [eax+37E], ecx+1F6
  1781. mov [eax+389], ecx+20A
  1782. eval "call {CreateFileA}"
  1783. asm eax+3A0, $RESULT
  1784. eval "call {GetFileSize}"
  1785. asm eax+3BA, $RESULT
  1786. eval "call {VirtualAlloc}"
  1787. asm eax+3DC, $RESULT
  1788. eval "call {VirtualLock}"
  1789. asm eax+3F4, $RESULT
  1790. eval "call {ReadFile}"
  1791. asm eax+40B, $RESULT
  1792. mov [eax+423], ecx+1FE
  1793. mov [eax+434], ecx+1FE
  1794. mov [eax+45B], ecx
  1795. mov [eax+464], ecx
  1796. mov [eax+480], SetFilePointer
  1797. eval "call {WriteFile}"
  1798. asm eax+4A3, $RESULT
  1799. eval "call {SetEndOfFile}"
  1800. asm eax+4C6, $RESULT
  1801. eval "call {VirtualUnlock}"
  1802. asm eax+4DD, $RESULT
  1803. eval "call {VirtualFree}"
  1804. asm eax+4EE, $RESULT
  1805. eval "call {CloseHandle}"
  1806. asm eax+4F8, $RESULT
  1807. mov [eax+590], ecx+1DE
  1808. mov [eax+59D], ecx+1DA
  1809. eval "call {VirtualFree}"
  1810. asm eax+5A1, $RESULT
  1811. mov [eax+5AF], ecx+20A
  1812. eval "call {VirtualFree}"
  1813. asm eax+5B3, $RESULT
  1814. mov [eax+5BA], ecx+1DE
  1815. mov [eax+5BF], ecx+1BE
  1816. mov [eax+5C5], ecx+1C2
  1817. mov [eax+5CB], ecx+1C6
  1818. mov [eax+5D1], ecx+1CA
  1819. mov [eax+5D7], ecx+1CE
  1820. mov [eax+5DD], ecx+1D2
  1821. mov [eax+5E3], ecx+1D6
  1822. mov [eax+5F0], ecx+1FA
  1823. eval "call {UnmapViewOfFile}"
  1824. asm eax+5F5, $RESULT
  1825. mov [eax+5FC], ecx+1F6
  1826. mov [eax+602], ecx+206
  1827. eval "call {SetFilePointer}"
  1828. asm eax+60C, $RESULT
  1829. mov [eax+612], ecx+206
  1830. eval "call {SetEndOfFile}"
  1831. asm eax+617, $RESULT
  1832. mov [eax+61E], ecx+206
  1833. eval "call {CloseHandle}"
  1834. asm eax+623, $RESULT
  1835. eval "call {lstrlenA}"
  1836. asm eax+630, $RESULT
  1837. mov [eax+676], ecx+20E
  1838. mov [eax+698], ecx+1FE
  1839. mov [eax+6DA], ecx+1FE
  1840. mov [eax+6EF], ecx+1FE
  1841. mov [eax+707], ecx+1FA
  1842. eval "call {free}"
  1843. asm eax+720, $RESULT
  1844. mov [eax+729], ecx+1FE
  1845. mov [eax+737], ecx+202
  1846. eval "call {ldiv}"
  1847. asm eax+74C, $RESULT
  1848. bp eax+5E7
  1849. bp eax+764
  1850. bp PATCH_CODESEC+4A9 // SecHandle
  1851. popa
  1852. esto
  1853. cmp eip, PATCH_CODESEC+4A9
  1854. jne NO_HANDLES
  1855. bc eip
  1856. mov SECHANDLE, eax
  1857. esto
  1858. ////////////////////
  1859. NO_HANDLES:
  1860. bc
  1861. cmp eip, PATCH_CODESEC+809
  1862. je SECTION_ADDED_OK
  1863. cmp eip, PATCH_CODESEC+886
  1864. je NO_SECTION_ADDED
  1865. pause
  1866. pause
  1867. cret
  1868. ret
  1869. ////////////////////
  1870. NO_SECTION_ADDED:
  1871. msg "Can't add the dumped section to file! \r\n\r\nDo it manually later! \r\n\r\nLCF-AT"
  1872. pause
  1873. pause
  1874. cret
  1875. ret
  1876. ////////////////////
  1877. SECTION_ADDED_OK:
  1878. fill PATCH_CODESEC, 100, 00
  1879. mov [PATCH_CODESEC], filelc
  1880. pusha
  1881. mov edi, PATCH_CODESEC
  1882. mov esi, SECHANDLE
  1883. exec
  1884. push esi
  1885. call {CloseHandle}
  1886. push edi
  1887. call {DeleteFileA}
  1888. ende
  1889. popa
  1890. msg "Section was successfully added to dumped file! \r\n\r\nPE Rebuild was successfully! \r\n\r\nLCF-AT"
  1891. log "Section was successfully added to dumped file!"
  1892. log "PE Rebuild was successfully!"
  1893. mov eip, BAK_EIP
  1894. free PATCH_CODESEC
  1895. ret
  1896. ////////////////////
  1897. FIXER:
  1898. call LOAD_ARI_DLL
  1899. jmp DO_REBUILD
  1900. ////////////////////
  1901. LOAD_ARI_DLL:
  1902. pusha
  1903. alloc 1000
  1904. mov TRY_NAMES, $RESULT
  1905. mov eax, TRY_NAMES
  1906. mov [TRY_NAMES], ARIMPREC_PATH
  1907. mov ecx, LoadLibraryA
  1908. log ""
  1909. log eax
  1910. log ecx
  1911. exec
  1912. push eax
  1913. call ecx
  1914. ende
  1915. log eax
  1916. cmp eax, 00
  1917. jne DLL_LOAD_SUCCESS
  1918. log ""
  1919. log "Can't load the ARImpRec.dll!"
  1920. msg "Can't load the ARImpRec.dll!"
  1921. pause
  1922. pause
  1923. cret
  1924. ret
  1925. ////////////////////
  1926. DLL_LOAD_SUCCESS:
  1927. refresh eax
  1928. mov [eax+1EA7D], #496174466978#
  1929. fill TRY_NAMES, 1000, 00
  1930. mov [TRY_NAMES], "SearchAndRebuildImports@28"
  1931. mov ecx, TRY_NAMES
  1932. mov edi, GetProcAddress
  1933. log ""
  1934. log ecx
  1935. log eax
  1936. log edi
  1937. exec
  1938. push ecx
  1939. push eax
  1940. call edi
  1941. ende
  1942. log eax
  1943. cmp eax, 00
  1944. jne TRY_API_SUCCESS
  1945. log ""
  1946. log "Can't get the SearchAndRebuildImports API!"
  1947. msg "Can't get the SearchAndRebuildImports API!"
  1948. pause
  1949. pause
  1950. cret
  1951. ret
  1952. ////////////////////
  1953. TRY_API_SUCCESS:
  1954. mov SearchAndRebuildImports, eax
  1955. fill TRY_NAMES, 1000, 00
  1956. free TRY_NAMES
  1957. popa
  1958. ret
  1959. ////////////////////
  1960. DO_REBUILD:
  1961. alloc 2000
  1962. mov PATCH_CODESEC, $RESULT
  1963. mov BAK_EIP, eip
  1964. mov [PATCH_CODESEC], PATCH_CODESEC+1800
  1965. mov [PATCH_CODESEC+04], IATSIZE
  1966. mov [PATCH_CODESEC+08], IATRVA
  1967. mov [PATCH_CODESEC+0C], PATCH_CODESEC+1500 // Dumpname
  1968. mov [PATCH_CODESEC+1500], EXEFILENAME
  1969. pusha
  1970. mov eax, PATCH_CODESEC+1500
  1971. add eax, EXEFILENAME_LEN
  1972. mov ecx, EXEFILENAME_LEN
  1973. xor ebx, ebx
  1974. ////////////////////
  1975. DOT_LOOP:
  1976. cmp ecx, 00
  1977. jne DOT_LOOP_GO
  1978. msg "Can't find the dot in filename! \r\n\r\nLCF-AT"
  1979. log "Can't find the dot in filename!"
  1980. pause
  1981. pause
  1982. cret
  1983. ret
  1984. ////////////////////
  1985. DOT_LOOP_GO:
  1986. cmp [eax], 2E, 01
  1987. je DOT
  1988. dec ecx
  1989. dec eax
  1990. inc ebx
  1991. jmp DOT_LOOP
  1992. ////////////////////
  1993. DOT:
  1994. len [eax]
  1995. mov edx, $RESULT
  1996. gstr eax
  1997. mov DOT_END, $RESULT
  1998. mov [eax], "_DP"
  1999. add eax, 03
  2000. mov [eax], DOT_END
  2001. popa
  2002. pusha
  2003. exec
  2004. call {GetCurrentProcessId}
  2005. ende
  2006. mov PID, eax
  2007. popa
  2008. mov [PATCH_CODESEC+10], PID
  2009. mov [PATCH_CODESEC+14], SearchAndRebuildImports
  2010. mov [PATCH_CODESEC+100], #606800000000680000000068000000006A0068000000006800000000FF3500000000FF1500000000906190#
  2011. mov [PATCH_CODESEC+102], PATCH_CODESEC+1800 // PATCH_CODESEC
  2012. mov [PATCH_CODESEC+107], PATCH_CODESEC+04
  2013. mov [PATCH_CODESEC+10C], PATCH_CODESEC+08
  2014. mov [PATCH_CODESEC+113], BAK_EIP
  2015. mov [PATCH_CODESEC+118], [PATCH_CODESEC+0C]
  2016. mov [PATCH_CODESEC+11E], PATCH_CODESEC+10
  2017. mov [PATCH_CODESEC+124], PATCH_CODESEC+14
  2018. mov eip, PATCH_CODESEC+100
  2019. bp PATCH_CODESEC+128
  2020. bp PATCH_CODESEC+12A
  2021. esto
  2022. bc eip
  2023. cmp eax, 0
  2024. je REBUILD_GOOD
  2025. pusha
  2026. alloc 1000
  2027. mov edi, $RESULT
  2028. mov [edi], "Warning!"
  2029. mov esi, PATCH_CODESEC+1800
  2030. exec
  2031. push 30
  2032. push edi
  2033. push esi
  2034. push 0
  2035. call {MessageBoxA}
  2036. ende
  2037. free edi
  2038. popa
  2039. pause
  2040. pause
  2041. cret
  2042. ret
  2043. ////////////////////
  2044. REBUILD_GOOD:
  2045. run
  2046. bc eip
  2047. mov eip, BAK_EIP
  2048. pusha
  2049. mov edi, PATCH_CODESEC+1500
  2050. exec
  2051. push edi
  2052. call {DeleteFileA}
  2053. ende
  2054. cmp eax, 01
  2055. jne DELETE_FAILED
  2056. len [edi]
  2057. mov esi, $RESULT
  2058. add esi, edi
  2059. inc esi
  2060. mov [esi], EXEFILENAME
  2061. mov eax, esi
  2062. len [eax]
  2063. add eax, $RESULT
  2064. ////////////////////
  2065. DOT_LOOP_GO_2:
  2066. cmp [eax], 2E, 01
  2067. je DOT_2
  2068. dec eax
  2069. jmp DOT_LOOP_GO_2
  2070. ////////////////////
  2071. DOT_2:
  2072. mov [eax], "_DP_"
  2073. add eax, 04
  2074. mov [eax], DOT_END
  2075. exec
  2076. push edi
  2077. push esi
  2078. call {MoveFileA}
  2079. ende
  2080. ////////////////////
  2081. DELETE_FAILED:
  2082. popa
  2083. free PATCH_CODESEC
  2084. msg "IAT was rebuild into dumped file! \r\n\r\nLCF-AT"
  2085. log "IAT was rebuild into dumped file!"
  2086. ret
Advertisement
Add Comment
Please, Sign In to add comment