Sunday, January 21, 2024

Emulating Shellcodes - Chapter 2

 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






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

No comments:

Post a Comment