Monday, 29 May 2023

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





Continue reading


  1. Pentest Tools Port Scanner
  2. Pentest Tools Port Scanner
  3. Pentest Tools For Mac
  4. Hacking Tools 2020
  5. Pentest Box Tools Download
  6. Pentest Tools Windows
  7. Pentest Tools Github
  8. Game Hacking
  9. Hacking Tools For Pc
  10. New Hacker Tools
  11. Hacking Apps
  12. Game Hacking
  13. Pentest Tools Framework
  14. Hacker Tools For Ios
  15. Pentest Tools Find Subdomains
  16. Hacking Tools Mac
  17. Underground Hacker Sites
  18. Hacking Tools For Pc
  19. Pentest Tools For Mac
  20. Pentest Tools For Mac
  21. Termux Hacking Tools 2019
  22. Hacking Tools Name
  23. Hacker Tool Kit
  24. Best Pentesting Tools 2018
  25. Physical Pentest Tools
  26. Hacker Techniques Tools And Incident Handling
  27. Hackrf Tools
  28. Hack Tools Online
  29. Hacker Search Tools
  30. Hacker
  31. Pentest Tools Subdomain
  32. Hacker Tools For Ios
  33. Pentest Tools For Android
  34. Pentest Tools Online
  35. Hacking Tools
  36. Hacker Tools Linux
  37. Hacking Tools Mac
  38. Hacker Tools Online
  39. Pentest Tools Nmap
  40. Hacking Tools 2019
  41. Hacking Tools Windows
  42. Hack Tool Apk No Root
  43. Hack Tools
  44. Hacker Tools Linux
  45. Pentest Tools Port Scanner
  46. Hack Tools Github
  47. Hacking Tools Kit
  48. Pentest Tools For Mac
  49. Pentest Tools Tcp Port Scanner
  50. Hacking Tools Free Download
  51. Hacking Apps
  52. Game Hacking
  53. Hacking Tools Usb
  54. Hack Website Online Tool
  55. Pentest Tools For Windows
  56. Pentest Tools For Windows
  57. Android Hack Tools Github
  58. Usb Pentest Tools
  59. Black Hat Hacker Tools
  60. Pentest Tools For Android
  61. Pentest Tools Subdomain
  62. World No 1 Hacker Software
  63. Black Hat Hacker Tools
  64. Hack Website Online Tool
  65. Hacker Tools Apk Download
  66. Hacking Tools Pc
  67. Best Hacking Tools 2019
  68. Hack Tools
  69. Hacking Tools Usb
  70. Hack Tools For Mac
  71. Pentest Box Tools Download
  72. Hack Tools For Mac
  73. Hacker Tools Apk Download
  74. Hacking Tools Online
  75. Android Hack Tools Github
  76. New Hacker Tools
  77. Hacker Tools 2020
  78. Hack Tool Apk No Root
  79. Install Pentest Tools Ubuntu
  80. Hacking Tools Kit
  81. Hacking Tools Software
  82. Pentest Tools Download
  83. Hacking Tools
  84. Blackhat Hacker Tools
  85. Easy Hack Tools
  86. Hacker Tools Free
  87. Hacking Tools For Windows 7
  88. Hak5 Tools
  89. Hack Tools
  90. Bluetooth Hacking Tools Kali
  91. Hacking Tools For Pc
  92. Hacking Tools Mac
  93. Pentest Automation Tools
  94. Pentest Tools For Ubuntu
  95. Easy Hack Tools
  96. Hacking Tools And Software
  97. Hack Tools For Windows
  98. Hacker Tools Apk Download
  99. Pentest Tools Bluekeep
  100. Free Pentest Tools For Windows
  101. Pentest Tools Port Scanner
  102. Pentest Box Tools Download
  103. Hack Tools For Pc
  104. Pentest Tools Website Vulnerability
  105. Best Hacking Tools 2019
  106. Kik Hack Tools
  107. Hacker Tools Hardware
  108. Hacking Tools Windows
  109. Hack Tools Github
  110. Pentest Tools Online
  111. How To Install Pentest Tools In Ubuntu
  112. How To Make Hacking Tools
  113. Hack Tools Download
  114. Termux Hacking Tools 2019
  115. Hacker
  116. Hackers Toolbox
  117. Pentest Tools Tcp Port Scanner
  118. Hacker Tools Free
  119. Hacking Tools For Beginners
  120. Hack Tools 2019
  121. Wifi Hacker Tools For Windows
  122. New Hacker Tools
  123. Hacker Techniques Tools And Incident Handling
  124. Hacking Tools Download
  125. Pentest Tools
  126. Pentest Tools Subdomain
  127. Termux Hacking Tools 2019
  128. Hacking Tools Windows 10
  129. Hacking Tools For Mac
  130. Hacker Tools
  131. Top Pentest Tools
  132. Hack Tools Pc
  133. Hack Tools For Ubuntu
  134. Free Pentest Tools For Windows
  135. Hack Tools Github
  136. Hack And Tools
  137. Hack Tools
  138. Hacker Tools 2020
  139. Hacker Tools Apk
  140. Hacking Tools Pc
  141. Hacker Tools For Mac
  142. Pentest Tools List
  143. Hacking Tools For Mac
  144. Hacking Tools Usb

No comments:

Post a Comment