Emulating Shellcodes - Chapter 2

Posted by Daniel Vievo

 Lets check different  Cobalt Strike shellcodes and stages in the shellcodes emulator SCEMU.




This stages are fully emulated well and can get the IOC and the behavior of the shellcode.

But lets see another first stage big shellcode with c runtime embedded in a second stage.


In this case is loading tons of API using GetProcAddress at the beginning, then some encode/decode pointer and tls get/set values to store an address. And ends up crashing because is jumping an address that seems more code than address 0x9090f1eb.

Here there are two types of allocations:


Lets spawn a console on -c 3307548 and see if some of this allocations has the next stage.

The "m" command show all the memory maps but the "ma" show only the allocations done by the shellcode.



Dumping memory with "md" we see that there is data, and dissasembling this address with "d" we see the prolog of a function.

So we have second stage unpacked in alloc_e40064


With "mdd" we do a memory dump to disk we found the size in previous screenshot,  and we can do  some static reversing of stage2 in radare/ghidra/ida

In radare we can verify that the extracted is the next stage:


I usually do correlation between the emulation and ghidra, to understand the algorithms.

If wee look further we can realize that the emulator called a function on the stage2, we can see the change of code base address and  is calling the allocated buffer in 0x4f...



And this  stage2 perform several API calls let's check it in ghidra.


We can see in the emulator that enters in the IF block, and what are the (*DAT_...)() calls

Before a crash lets continue to the SEH pointer, in this case is the way, and the exception routine checks IsDebuggerPresent() which is not any debugger pressent for sure, so eax = 0;



So lets say yes and continue the emulation.


Both IsDebuggerPresent() and UnHandledExceptionFilter() can be used to detect a debugger, but the emulator return what has to return to not be detected. 

Nevertheless the shellcode detects something and terminates the process.

Lets trace the branches to understand the logic:


target/release/scemu -f shellcodes/unsuported_cs.bin -vv | egrep '(\*\*|j|cmp|test)'



Continuing the emulation it's setting the SEH  pointer to previous stage:


Lets see from the console where is pointing the SEH chain item:


to be continued ...


https://github.com/sha0coder/scemu






More articles


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

0 comments:

Post a Comment