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

No comments:

Post a Comment