Sunday, May 28, 2023

Emulating Shellcodes - Chapter 2

 Lets check different  Cobalt Strike shellcodes and stages in the shellcodes emulator SCEMU.




This stages are fully emulated well and can get the IOC and the behavior of the shellcode.

But lets see another first stage big shellcode with c runtime embedded in a second stage.


In this case is loading tons of API using GetProcAddress at the beginning, then some encode/decode pointer and tls get/set values to store an address. And ends up crashing because is jumping an address that seems more code than address 0x9090f1eb.

Here there are two types of allocations:


Lets spawn a console on -c 3307548 and see if some of this allocations has the next stage.

The "m" command show all the memory maps but the "ma" show only the allocations done by the shellcode.



Dumping memory with "md" we see that there is data, and dissasembling this address with "d" we see the prolog of a function.

So we have second stage unpacked in alloc_e40064


With "mdd" we do a memory dump to disk we found the size in previous screenshot,  and we can do  some static reversing of stage2 in radare/ghidra/ida

In radare we can verify that the extracted is the next stage:


I usually do correlation between the emulation and ghidra, to understand the algorithms.

If wee look further we can realize that the emulator called a function on the stage2, we can see the change of code base address and  is calling the allocated buffer in 0x4f...



And this  stage2 perform several API calls let's check it in ghidra.


We can see in the emulator that enters in the IF block, and what are the (*DAT_...)() calls

Before a crash lets continue to the SEH pointer, in this case is the way, and the exception routine checks IsDebuggerPresent() which is not any debugger pressent for sure, so eax = 0;



So lets say yes and continue the emulation.


Both IsDebuggerPresent() and UnHandledExceptionFilter() can be used to detect a debugger, but the emulator return what has to return to not be detected. 

Nevertheless the shellcode detects something and terminates the process.

Lets trace the branches to understand the logic:


target/release/scemu -f shellcodes/unsuported_cs.bin -vv | egrep '(\*\*|j|cmp|test)'



Continuing the emulation it's setting the SEH  pointer to previous stage:


Lets see from the console where is pointing the SEH chain item:


to be continued ...


https://github.com/sha0coder/scemu






More info


  1. Nsa Hacker Tools
  2. Easy Hack Tools
  3. Hacker Tool Kit
  4. Pentest Tools Url Fuzzer
  5. Github Hacking Tools
  6. Hack Tools Online
  7. Hacking Tools Kit
  8. Hack Tools For Windows
  9. Pentest Box Tools Download
  10. Hacker Tools Mac
  11. Tools Used For Hacking
  12. Pentest Reporting Tools
  13. Pentest Tools For Mac
  14. Hackrf Tools
  15. Pentest Tools Github
  16. Pentest Tools Windows
  17. Hack Tools For Windows
  18. Hacking Apps
  19. Wifi Hacker Tools For Windows
  20. Hacking Tools For Windows Free Download
  21. Hack Tools For Mac
  22. Hack Website Online Tool
  23. Hacker Tool Kit
  24. Hacking Tools For Pc
  25. Hacking Tools Kit
  26. Hacker Tool Kit
  27. Hacker Search Tools
  28. Hack And Tools
  29. Hack Tools For Mac
  30. Hacking Tools And Software
  31. Hacking Tools Mac
  32. Hackers Toolbox
  33. Hacking Tools Kit
  34. Hack Tools
  35. Tools Used For Hacking
  36. New Hack Tools
  37. Hacking Tools Download
  38. Hacker Tools 2020
  39. Hacker Tools List
  40. Hacker Tools For Mac
  41. What Is Hacking Tools
  42. Hacker Tool Kit
  43. Hacker
  44. Pentest Tools List
  45. Hack Website Online Tool
  46. Hacker Tools Mac
  47. Pentest Tools Github
  48. Hack Tool Apk
  49. Game Hacking
  50. Usb Pentest Tools
  51. Hacking Tools
  52. Pentest Tools Review
  53. Hak5 Tools
  54. Hacks And Tools
  55. Hack Tools For Ubuntu
  56. What Is Hacking Tools
  57. Hacking Tools For Windows Free Download
  58. Hack Rom Tools
  59. Hack Tool Apk No Root
  60. Pentest Tools Download
  61. Hackrf Tools
  62. Pentest Tools Android
  63. Pentest Tools Website Vulnerability
  64. Hacking Tools For Beginners
  65. Pentest Box Tools Download
  66. Ethical Hacker Tools
  67. Growth Hacker Tools
  68. Hacking Tools Pc
  69. Hacking Tools For Games
  70. Hack Tools For Mac
  71. Pentest Tools Url Fuzzer
  72. Github Hacking Tools
  73. Hacker Security Tools
  74. Hack Tools 2019
  75. Pentest Tools Review
  76. How To Install Pentest Tools In Ubuntu
  77. Pentest Tools Framework
  78. Hack Tools Download
  79. Hack Tools For Ubuntu
  80. What Is Hacking Tools
  81. Hacking Tools Hardware
  82. Hack Tools For Mac
  83. Hacking Tools Mac
  84. Hack Tools Mac
  85. Hacker Security Tools
  86. Hack Tools Pc
  87. Pentest Tools Download
  88. Hacking Tools For Mac
  89. Game Hacking
  90. Hacker Tool Kit
  91. Pentest Tools Apk
  92. Pentest Tools Port Scanner
  93. Hack Tools 2019
  94. Hacking Tools For Windows
  95. Pentest Reporting Tools
  96. Hacking Tools For Kali Linux
  97. Hacker Tools Linux
  98. New Hacker Tools
  99. Hacker Tools
  100. Hack Tools Online
  101. Pentest Tools
  102. Hack Rom Tools
  103. Hacker Tools Free
  104. Hacking Tools Online
  105. Hacker Tools 2020
  106. Termux Hacking Tools 2019
  107. Hacking Tools Mac
  108. Pentest Tools Online
  109. Pentest Tools Review
  110. Github Hacking Tools
  111. Hacker Tools
  112. Install Pentest Tools Ubuntu
  113. Hack And Tools
  114. What Is Hacking Tools
  115. Hack App
  116. Tools Used For Hacking
  117. Hack Tool Apk
  118. Black Hat Hacker Tools
  119. Pentest Tools Website Vulnerability
  120. Hacker Tools Free
  121. Hacking Tools Github
  122. Nsa Hacker Tools
  123. Hack Tool Apk No Root
  124. Hacker Tools For Mac
  125. Nsa Hacker Tools
  126. Hacker Tool Kit
  127. Kik Hack Tools
  128. Hacking App
  129. Pentest Tools Apk
  130. Hacker Tools List
  131. Nsa Hack Tools
  132. Hacker Tools Apk
  133. Hacker Tools 2020
  134. Hacker
  135. Physical Pentest Tools
  136. Hacker Techniques Tools And Incident Handling
  137. Hacking App
  138. Hacking Tools Pc
  139. Hacker Hardware Tools
  140. Hack Tools Pc
  141. Hacking Tools Download
  142. Growth Hacker Tools
  143. Android Hack Tools Github
  144. Computer Hacker
  145. Hacker Tools Github
  146. Hacker Tools Software
  147. Pentest Tools Linux
  148. Pentest Tools Website Vulnerability
  149. Nsa Hacker Tools
  150. Hacker Tools
  151. Hacker Tools For Windows
  152. Hacker Tools List
  153. Hacker Tools For Windows
  154. Pentest Tools Bluekeep
  155. Pentest Tools Subdomain
  156. Hacking Tools 2020
  157. Hacking Tools Online
  158. Hacking Tools For Windows Free Download
  159. Pentest Tools Nmap
  160. Ethical Hacker Tools
  161. Hack Rom Tools
  162. Hacking Tools Usb
  163. Kik Hack Tools
  164. Hak5 Tools
  165. Pentest Tools Find Subdomains
  166. Game Hacking
  167. Hacking Tools 2019
  168. Tools Used For Hacking
  169. Pentest Tools Url Fuzzer

No comments: