A blog for Confluence group.

Saturday, 27 January 2024

Fast Emulator For Shellcodes In Rust

I have developed a fast emulator for modern shellcodes, that perform huge loops of millions of instructions emulated for resolving API or for other stuff.

The emulator is in Rust and all the few dependencies as well, so the rust safety is good for emulating malware.  

There are shellcodes that can be emulated from the beginning to the end, but when this is not possible the tool has many features that can be used like a console, a memory tracing, register tracing, and so on.

https://github.com/sha0coder/scemu



In less than two seconds we have emulated 7 millions of instructions arriving to the recv. 

At this point we have some  IOC like  the ip:port where it's connecting and other details.

Lets see what happens after the recv() spawning a console at position: 7,012,204


target/release/scemu -f shellcodes/shikata.bin -vv -c 7012204



In the console, pressing "enter" several times to emulate  step into several steps and we arrive to a return instruction.


Let's see the stack in this moment:


The "ret" instruction is going to jump to the buffer read with recv() so is a kind of stager.

The option "-e" or "--endpoint" is not ready for now, but it will allow to proxy the calls to get the next  stage automatically, but for now we have the details to get the stage.


SCEMU also identify all the Linux  syscalls for 32bits shellcodes:



The encoder used in shellgen is also supported https://github.com/MarioVilas/shellgen

Let's check with cobalt-strike:


We can see where is connecting and which headers is using, so right now we can replicate the communications.



In verbose mode we could do several greps to see the calls and correlate with ghidra/ida/radare or  for example grep the branches to study the emulation flow.


target/release/scemu -f shellcodes/rshell_sgn.bin -vv | grep j


target/release/scemu -f shellcodes/rshell_sgn.bin -vv -c 44000 -l


The -l --loops options makes the emulation a bit slower but track the number of iterations.

Is possible to print all the registers in every step with  -r or --registers  but also is possible to track  specific register for example with --reg esi


target/release/scemu -f shellcodes/shikata.bin --reg esi 


In this case ESI register points to the API name, if we track EAX or ECX will see that are the counters of the loop. These shellcodes  contains a hard loop to locate the API names.

The flag -i or --inspect allow to monitor memory using expressions like "dword ptr [eax + 0xa]"

target/release/scemu -f shellcodes/shikata.bin -i 'dword ptr [esi]'

And more things to come...  find a demo below:

https://www.youtube.com/watch?v=qTYmMjW3DFs





Related posts


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

No comments: