Saturday, January 27, 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 articles


  1. Pentest Tools Bluekeep
  2. Hacking Apps
  3. Pentest Tools Windows
  4. Hacker Tools Software
  5. Beginner Hacker Tools
  6. Hacking Tools For Windows 7
  7. Kik Hack Tools
  8. Android Hack Tools Github
  9. Pentest Tools Windows
  10. Hacker
  11. Hacking Tools Kit
  12. Growth Hacker Tools
  13. Hack Tools For Games
  14. Nsa Hack Tools Download
  15. Hack Tools For Pc
  16. Hacking Tools Online
  17. Hacking Tools Hardware
  18. Hacking Tools 2020
  19. Hack Tools
  20. Pentest Tools Windows
  21. Hacks And Tools
  22. Black Hat Hacker Tools
  23. How To Install Pentest Tools In Ubuntu
  24. Hack Tools For Windows
  25. Pentest Tools Tcp Port Scanner
  26. Hack Tools Pc
  27. Best Hacking Tools 2020
  28. Bluetooth Hacking Tools Kali
  29. Pentest Tools Find Subdomains
  30. Physical Pentest Tools
  31. Hacker Security Tools
  32. Hack Tools
  33. Hacking Tools 2019
  34. Install Pentest Tools Ubuntu
  35. Pentest Tools Download
  36. Easy Hack Tools
  37. Hack Tool Apk
  38. Hacking Tools For Windows Free Download
  39. Hacker Tools Mac
  40. Best Hacking Tools 2019
  41. Hack Rom Tools
  42. Hack Tools
  43. Hack Tools For Mac
  44. Pentest Tools Framework
  45. Install Pentest Tools Ubuntu
  46. Pentest Recon Tools
  47. How To Hack
  48. Pentest Tools Apk
  49. Pentest Tools Apk
  50. Hacking Tools For Windows
  51. Pentest Tools Nmap
  52. Hack And Tools
  53. Hacking Tools Pc
  54. New Hacker Tools
  55. Hacker Tools Windows
  56. Hacker Tools List
  57. Beginner Hacker Tools
  58. Hacker Tools Free Download
  59. Pentest Tools Tcp Port Scanner
  60. Hacking Tools For Windows Free Download
  61. Hacker Tools For Windows
  62. Pentest Tools Subdomain
  63. Pentest Tools For Mac
  64. Beginner Hacker Tools
  65. Hacker Search Tools
  66. New Hack Tools
  67. Hak5 Tools
  68. Top Pentest Tools
  69. How To Install Pentest Tools In Ubuntu
  70. Pentest Tools Port Scanner
  71. Game Hacking
  72. Hacking Tools And Software
  73. Hacking Tools Github
  74. Hacking Tools 2020
  75. Hacking Apps
  76. Hacking Tools For Windows 7
  77. Tools Used For Hacking
  78. Kik Hack Tools
  79. Hacker Tools Free Download
  80. Android Hack Tools Github
  81. Pentest Box Tools Download
  82. Pentest Tools Online
  83. Hacking Tools Free Download
  84. Hacking Tools For Games
  85. Computer Hacker
  86. Hacking Tools Usb
  87. Pentest Tools Port Scanner
  88. Pentest Tools Port Scanner
  89. Pentest Tools Online
  90. Hacker Tools Apk
  91. Hackers Toolbox
  92. Hacking Apps
  93. Hacking Tools Pc
  94. Hacker Tools For Windows
  95. Pentest Tools Free
  96. Hacking Tools Online
  97. Hacking Tools Free Download
  98. Hacking Tools For Kali Linux
  99. Hacker Tools Free Download
  100. Hacker Tools Windows
  101. How To Hack
  102. Hacking Tools Windows
  103. Nsa Hacker Tools

No comments: