Guest User

Assembly code

a guest
Jul 30th, 2022
361
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.83 KB | None | 0 0
  1. .text:00401510 ; Attributes: bp-based frame fuzzy-sp
  2. .text:00401510
  3. .text:00401510 ; int __cdecl main(int argc, const char **argv, const char **envp)
  4. .text:00401510 public _main
  5. .text:00401510 _main proc near ; CODE XREF: ___tmainCRTStartup+236↑p
  6. .text:00401510
  7. .text:00401510 Destination = byte ptr -0Fh
  8. .text:00401510 argc = dword ptr 8
  9. .text:00401510 argv = dword ptr 0Ch
  10. .text:00401510 envp = dword ptr 10h
  11. .text:00401510
  12. .text:00401510 push ebp
  13. .text:00401511 mov ebp, esp
  14. .text:00401513 and esp, 0FFFFFFF0h
  15. .text:00401516 sub esp, 40h
  16. .text:00401519 call ___main
  17. .text:0040151E mov dword ptr [esp+2Bh], 35706635h
  18. .text:00401526 mov word ptr [esp+2Fh], 73h ; 's'
  19. .text:0040152D mov dword ptr [esp+1Fh], 6866234Ah
  20. .text:00401535 mov dword ptr [esp+23h], 7667236Fh
  21. .text:0040153D mov dword ptr [esp+27h], 776C21h
  22. .text:00401545 mov dword ptr [esp+1Ah], 37333331h
  23. .text:0040154D mov byte ptr [esp+1Eh], 0
  24. .text:00401552 mov dword ptr [esp], offset VarName ; "GREENIE"
  25. .text:00401559 call _getenv
  26. .text:0040155E mov [esp+38h], eax
  27. .text:00401562 cmp [ebp+argc], 1
  28. .text:00401566 jle short loc_40156F
  29. .text:00401568 cmp dword ptr [esp+38h], 0
  30. .text:0040156D jnz short loc_401587
  31. .text:0040156F
  32. .text:0040156F loc_40156F: ; CODE XREF: _main+56↑j
  33. .text:0040156F mov dword ptr [esp], offset Buffer ; "An error occurred"
  34. .text:00401576 call _puts
  35. .text:0040157B mov dword ptr [esp], 0 ; Code
  36. .text:00401582 call _exit
  37. .text:00401587 ; ---------------------------------------------------------------------------
  38. .text:00401587
  39. .text:00401587 loc_401587: ; CODE XREF: _main+5D↑j
  40. .text:00401587 mov eax, [ebp+argv]
  41. .text:0040158A add eax, 4
  42. .text:0040158D mov eax, [eax]
  43. .text:0040158F mov dword ptr [esp+8], 5 ; Count
  44. .text:00401597 mov [esp+4], eax ; Source
  45. .text:0040159B lea eax, [esp+40h+Destination]
  46. .text:0040159F mov [esp], eax ; Destination
  47. .text:004015A2 call _strncpy
  48. .text:004015A7 mov dword ptr [esp+3Ch], 0
  49. .text:004015AF jmp short loc_4015FD
  50. .text:004015B1 ; ---------------------------------------------------------------------------
  51. .text:004015B1
  52. .text:004015B1 loc_4015B1: ; CODE XREF: _main+F2↓j
  53. .text:004015B1 lea edx, [esp+31h]
  54. .text:004015B5 mov eax, [esp+3Ch]
  55. .text:004015B9 add eax, edx
  56. .text:004015BB movzx eax, byte ptr [eax]
  57. .text:004015BE mov edx, eax
  58. .text:004015C0 mov eax, [esp+3Ch]
  59. .text:004015C4 add eax, edx
  60. .text:004015C6 add eax, 1
  61. .text:004015C9 mov [esp+36h], al
  62. .text:004015CD lea edx, [esp+2Bh]
  63. .text:004015D1 mov eax, [esp+3Ch]
  64. .text:004015D5 add eax, edx
  65. .text:004015D7 movzx eax, byte ptr [eax]
  66. .text:004015DA cmp [esp+36h], al
  67. .text:004015DE jz short loc_4015F8
  68. .text:004015E0 mov dword ptr [esp], offset aWrong ; "wrong"
  69. .text:004015E7 call _puts
  70. .text:004015EC mov dword ptr [esp], 0 ; Code
  71. .text:004015F3 call _exit
  72. .text:004015F8 ; ---------------------------------------------------------------------------
  73. .text:004015F8
  74. .text:004015F8 loc_4015F8: ; CODE XREF: _main+CE↑j
  75. .text:004015F8 add dword ptr [esp+3Ch], 1
  76. .text:004015FD
  77. .text:004015FD loc_4015FD: ; CODE XREF: _main+9F↑j
  78. .text:004015FD cmp dword ptr [esp+3Ch], 4
  79. .text:00401602 jle short loc_4015B1
  80. .text:00401604 mov dword ptr [esp+3Ch], 0
  81. .text:0040160C jmp short loc_401671
  82. .text:0040160E ; ---------------------------------------------------------------------------
  83. .text:0040160E
  84. .text:0040160E loc_40160E: ; CODE XREF: _main+166↓j
  85. .text:0040160E mov eax, [esp+3Ch]
  86. .text:00401612 cdq
  87. .text:00401613 shr edx, 1Eh
  88. .text:00401616 add eax, edx
  89. .text:00401618 and eax, 3
  90. .text:0040161B sub eax, edx
  91. .text:0040161D movzx eax, byte ptr [esp+eax+1Ah]
  92. .text:00401622 mov [esp+37h], al
  93. .text:00401626 movsx eax, byte ptr [esp+37h]
  94. .text:0040162B lea ecx, [eax-30h]
  95. .text:0040162E mov edx, [esp+3Ch]
  96. .text:00401632 mov eax, [esp+38h]
  97. .text:00401636 add eax, edx
  98. .text:00401638 movzx eax, byte ptr [eax]
  99. .text:0040163B movsx eax, al
  100. .text:0040163E add ecx, eax
  101. .text:00401640 lea edx, [esp+1Fh]
  102. .text:00401644 mov eax, [esp+3Ch]
  103. .text:00401648 add eax, edx
  104. .text:0040164A movzx eax, byte ptr [eax]
  105. .text:0040164D movsx eax, al
  106. .text:00401650 cmp ecx, eax
  107. .text:00401652 jz short loc_40166C
  108. .text:00401654 mov dword ptr [esp], offset aWrong ; "wrong"
  109. .text:0040165B call _puts
  110. .text:00401660 mov dword ptr [esp], 0 ; Code
  111. .text:00401667 call _exit
  112. .text:0040166C ; ---------------------------------------------------------------------------
  113. .text:0040166C
  114. .text:0040166C loc_40166C: ; CODE XREF: _main+142↑j
  115. .text:0040166C add dword ptr [esp+3Ch], 1
  116. .text:00401671
  117. .text:00401671 loc_401671: ; CODE XREF: _main+FC↑j
  118. .text:00401671 cmp dword ptr [esp+3Ch], 0Ah
  119. .text:00401676 jle short loc_40160E
  120. .text:00401678 mov eax, [esp+38h]
  121. .text:0040167C movzx eax, byte ptr [eax]
  122. .text:0040167F movsx eax, al
  123. .text:00401682 add eax, 1Dh
  124. .text:00401685 mov [esp], eax ; Character
  125. .text:00401688 call _putchar
  126. .text:0040168D mov eax, [esp+38h]
  127. .text:00401691 add eax, 1
  128. .text:00401694 movzx eax, byte ptr [eax]
  129. .text:00401697 movsx eax, al
  130. .text:0040169A add eax, 4Ch ; 'L'
  131. .text:0040169D mov [esp], eax ; Character
  132. .text:004016A0 call _putchar
  133. .text:004016A5 mov eax, [esp+38h]
  134. .text:004016A9 add eax, 2
  135. .text:004016AC movzx eax, byte ptr [eax]
  136. .text:004016AF movsx eax, al
  137. .text:004016B2 sub eax, 2
  138. .text:004016B5 mov [esp], eax ; Character
  139. .text:004016B8 call _putchar
  140. .text:004016BD mov eax, [esp+38h]
  141. .text:004016C1 add eax, 3
  142. .text:004016C4 movzx eax, byte ptr [eax]
  143. .text:004016C7 movsx eax, al
  144. .text:004016CA add eax, 6
  145. .text:004016CD mov [esp], eax ; Character
  146. .text:004016D0 call _putchar
  147. .text:004016D5 mov eax, [esp+38h]
  148. .text:004016D9 add eax, 4
  149. .text:004016DC movzx eax, byte ptr [eax]
  150. .text:004016DF movsx eax, al
  151. .text:004016E2 add eax, 0Dh
  152. .text:004016E5 mov [esp], eax ; Character
  153. .text:004016E8 call _putchar
  154. .text:004016ED mov eax, [esp+38h]
  155. .text:004016F1 add eax, 5
  156. .text:004016F4 movzx eax, byte ptr [eax]
  157. .text:004016F7 movsx eax, al
  158. .text:004016FA add eax, 23h ; '#'
  159. .text:004016FD mov [esp], eax ; Character
  160. .text:00401700 call _putchar
  161. .text:00401705 mov eax, [esp+38h]
  162. .text:00401709 add eax, 6
  163. .text:0040170C movzx eax, byte ptr [eax]
  164. .text:0040170F movsx eax, al
  165. .text:00401712 add eax, 15h
  166. .text:00401715 mov [esp], eax ; Character
  167. .text:00401718 call _putchar
  168. .text:0040171D mov eax, [esp+38h]
  169. .text:00401721 add eax, 7
  170. .text:00401724 movzx eax, byte ptr [eax]
  171. .text:00401727 movsx eax, al
  172. .text:0040172A sub eax, 0Dh
  173. .text:0040172D mov [esp], eax ; Character
  174. .text:00401730 call _putchar
  175. .text:00401735 mov eax, [esp+38h]
  176. .text:00401739 add eax, 8
  177. .text:0040173C movzx eax, byte ptr [eax]
  178. .text:0040173F movsx eax, al
  179. .text:00401742 add eax, 13h
  180. .text:00401745 mov [esp], eax ; Character
  181. .text:00401748 call _putchar
  182. .text:0040174D mov eax, [esp+38h]
  183. .text:00401751 add eax, 9
  184. .text:00401754 movzx eax, byte ptr [eax]
  185. .text:00401757 movsx eax, al
  186. .text:0040175A add eax, 9
  187. .text:0040175D mov [esp], eax ; Character
  188. .text:00401760 call _putchar
  189. .text:00401765 mov eax, [esp+38h]
  190. .text:00401769 add eax, 0Ah
  191. .text:0040176C movzx eax, byte ptr [eax]
  192. .text:0040176F movsx eax, al
  193. .text:00401772 add eax, 9
  194. .text:00401775 mov [esp+4], eax
  195. .text:00401779 mov dword ptr [esp], offset Format ; "%c\n"
  196. .text:00401780 call _printf
  197. .text:00401785 mov eax, 0
  198. .text:0040178A leave
  199. .text:0040178B retn
  200. .text:0040178B _main endp
  201. .text:0040178B
Add Comment
Please, Sign In to add comment