Friday, May 26, 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





Related word


  1. Hacker Tools Online
  2. Hacker Tools Online
  3. Hackrf Tools
  4. Pentest Recon Tools
  5. Hacking Tools Mac
  6. Pentest Tools Free
  7. What Are Hacking Tools
  8. Underground Hacker Sites
  9. Hacker
  10. Pentest Tools Nmap
  11. New Hacker Tools
  12. Hacker Tools Apk Download
  13. Pentest Automation Tools
  14. Hacker Tools Apk
  15. Pentest Tools Website Vulnerability
  16. Pentest Reporting Tools
  17. Hacker Tools For Ios
  18. Hacking Tools Usb
  19. Hak5 Tools
  20. Pentest Tools Online
  21. Hacker Tools
  22. Hacking Tools Online
  23. Hacker Security Tools
  24. Hacking Tools For Windows
  25. Pentest Tools Android
  26. Hack Tool Apk No Root
  27. Pentest Tools Subdomain
  28. Hacking Tools Software
  29. Kik Hack Tools
  30. Pentest Tools Website
  31. Hack And Tools
  32. Pentest Tools Find Subdomains
  33. Pentest Tools Apk
  34. Hacking Tools
  35. Pentest Tools Free
  36. Hack Tools For Games
  37. Hacking App
  38. Physical Pentest Tools
  39. Pentest Tools Port Scanner
  40. Hack Tools Online
  41. Hacker Tools Software
  42. Hack Tools 2019
  43. Pentest Tools Free
  44. Nsa Hacker Tools
  45. Hack Tools 2019
  46. Hacker Tools Online
  47. Hacker Tools Free
  48. Usb Pentest Tools
  49. Hacks And Tools
  50. Hack Tools Download
  51. Hacker Tools For Mac
  52. Hacker Tools For Pc
  53. Pentest Tools Android
  54. Hacker Tools For Windows
  55. Hacker Tools Free
  56. Ethical Hacker Tools
  57. Tools 4 Hack
  58. Usb Pentest Tools
  59. Pentest Tools For Mac
  60. Hacker Tools Hardware
  61. Pentest Tools List
  62. Hacking Tools For Beginners
  63. Computer Hacker
  64. Pentest Box Tools Download
  65. Tools For Hacker
  66. Hacking Tools 2019
  67. Tools For Hacker
  68. Android Hack Tools Github
  69. Hacker Tools For Ios
  70. Hack Tools
  71. Hacking Tools For Mac
  72. Pentest Tools For Ubuntu
  73. Pentest Tools Android
  74. Hacking Tools For Kali Linux
  75. Pentest Tools Bluekeep
  76. Best Pentesting Tools 2018
  77. Hacking Tools Pc
  78. Growth Hacker Tools
  79. Physical Pentest Tools
  80. Pentest Tools Framework
  81. Hack Tools Pc
  82. Hacker Tools Apk
  83. Pentest Tools Website
  84. Pentest Tools List
  85. Hacking Tools Hardware
  86. Hacking Tools For Windows 7
  87. Pentest Recon Tools
  88. Tools Used For Hacking
  89. Android Hack Tools Github
  90. Wifi Hacker Tools For Windows
  91. Best Hacking Tools 2019
  92. Pentest Tools Open Source
  93. Hacker Security Tools
  94. Pentest Tools Apk
  95. New Hacker Tools
  96. Hacking Tools 2020
  97. Hacking Tools Usb
  98. Pentest Tools Alternative
  99. Pentest Tools Online
  100. Tools 4 Hack
  101. Free Pentest Tools For Windows
  102. Hack Tools For Ubuntu
  103. Hacking Tools Software
  104. Hack Tools For Mac
  105. Hak5 Tools
  106. How To Hack
  107. Pentest Tools List
  108. Hacking Tools 2020
  109. Pentest Tools
  110. Pentest Tools Download
  111. Pentest Tools Website Vulnerability
  112. Pentest Tools Download
  113. Hacking Tools Software
  114. Best Hacking Tools 2020
  115. Hacker Tools Apk
  116. Hack Rom Tools
  117. Nsa Hack Tools
  118. New Hack Tools
  119. Hacking Tools Hardware
  120. Hacker Tools List
  121. Pentest Tools For Mac
  122. Install Pentest Tools Ubuntu

No comments: