04 June 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





More info


  1. Pentest Tools Tcp Port Scanner
  2. Hacking Tools Free Download
  3. Hack Tools
  4. Hack Tools For Games
  5. Pentest Tools Nmap
  6. Growth Hacker Tools
  7. Hacker Tools Github
  8. Pentest Tools Bluekeep
  9. Top Pentest Tools
  10. Pentest Tools
  11. Hack Apps
  12. Pentest Tools Subdomain
  13. Hacking Tools Hardware
  14. Pentest Tools Android
  15. Hacker Tools For Windows
  16. Hacking Tools Download
  17. Hacking Tools Github
  18. Wifi Hacker Tools For Windows
  19. Hacking Tools For Mac
  20. Pentest Automation Tools
  21. Hacker
  22. Hacker Tools 2020
  23. Nsa Hack Tools
  24. Hacker Tools For Ios
  25. Termux Hacking Tools 2019
  26. Hack Tools
  27. Hacker Techniques Tools And Incident Handling
  28. Pentest Tools Url Fuzzer
  29. World No 1 Hacker Software
  30. Hacking Tools Pc
  31. Hacking Tools Free Download
  32. Free Pentest Tools For Windows
  33. Pentest Tools Website
  34. Hacking App
  35. Hack Tools Github
  36. Hacking Tools For Windows Free Download
  37. Hacker Techniques Tools And Incident Handling
  38. Pentest Tools For Android
  39. Nsa Hacker Tools
  40. Hacking Tools For Pc
  41. Hacking Tools Kit
  42. Install Pentest Tools Ubuntu
  43. Pentest Tools Find Subdomains
  44. Computer Hacker
  45. Pentest Tools Windows
  46. Pentest Tools Kali Linux
  47. Install Pentest Tools Ubuntu
  48. Hacking Tools 2019
  49. Pentest Box Tools Download
  50. Hacks And Tools
  51. Hacker Tools Software
  52. Hack Tools Online
  53. Hacking Tools For Mac
  54. Wifi Hacker Tools For Windows
  55. Hacking Tools Software
  56. Best Hacking Tools 2020
  57. Hack Website Online Tool
  58. Pentest Tools Linux
  59. Game Hacking
  60. Hack Tool Apk No Root
  61. What Is Hacking Tools
  62. Hacking Tools Free Download
  63. Hacker Tools Free
  64. What Is Hacking Tools
  65. Hacker Tools 2019
  66. Blackhat Hacker Tools
  67. Install Pentest Tools Ubuntu
  68. Top Pentest Tools
  69. Best Pentesting Tools 2018
  70. Hacking Tools Windows
  71. Pentest Tools Framework
  72. Blackhat Hacker Tools
  73. How To Make Hacking Tools
  74. Hack Tools For Ubuntu
  75. Hack Tool Apk
  76. Hacker Tools Software
  77. Hacking Tools For Windows 7
  78. Hacking Tools Download
  79. Hacking Tools And Software
  80. Hacker
  81. Pentest Reporting Tools
  82. Pentest Tools Url Fuzzer
  83. Hacking Tools Name
  84. Hacking Tools
  85. Pentest Tools Alternative

No comments:

Post a Comment