Saturday, May 27, 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 posts


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

0 Comments:

Post a Comment

<< Home