Friday, May 26, 2023

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






Continue reading
  1. Ethical Hacker Tools
  2. Hack Tools
  3. Hack And Tools
  4. Pentest Tools Download
  5. Hacker Tools Software
  6. Hacker Tools Apk
  7. Ethical Hacker Tools
  8. Pentest Tools Free
  9. Pentest Tools Review
  10. Pentest Tools List
  11. Best Pentesting Tools 2018
  12. Hacker Tools Github
  13. Easy Hack Tools
  14. Hacking Tools For Beginners
  15. Pentest Tools For Windows
  16. Hacking Tools 2020
  17. Hacking Tools For Mac
  18. Hacking Tools For Mac
  19. Blackhat Hacker Tools
  20. Hack Tools Download
  21. Tools Used For Hacking
  22. Hacker Techniques Tools And Incident Handling
  23. Game Hacking
  24. World No 1 Hacker Software
  25. Hacking Apps
  26. Hacker Tools Github
  27. Pentest Tools Alternative
  28. Hacker Tools For Ios
  29. Pentest Tools Review
  30. New Hacker Tools
  31. Hacker Tools Hardware
  32. How To Hack
  33. Pentest Tools Github
  34. Hack Tools
  35. Hack Tools Download
  36. Hacking Tools For Pc
  37. Pentest Reporting Tools
  38. Hack Tools For Mac
  39. Pentest Tools Online
  40. Hacker Tools For Mac
  41. Hacker Tool Kit
  42. Hacking Tools And Software
  43. Hacker Tools Free Download
  44. Hacker Tools 2019
  45. Usb Pentest Tools
  46. Hacker Tools 2020
  47. Hacker Security Tools
  48. Hacker Tools For Pc
  49. Hack Tools Pc
  50. Pentest Tools For Android
  51. Growth Hacker Tools
  52. Pentest Tools Download
  53. Hacking Tools Hardware
  54. Easy Hack Tools
  55. Hacking Tools Free Download
  56. Hack Tool Apk
  57. Install Pentest Tools Ubuntu
  58. Hacker
  59. Pentest Tools Framework
  60. Hacking Tools Free Download
  61. Pentest Tools For Ubuntu
  62. Pentest Tools Free
  63. Pentest Tools List
  64. Pentest Tools Download
  65. World No 1 Hacker Software
  66. Hacker Tools Hardware
  67. Hacker Tools For Ios
  68. Pentest Tools Free
  69. Hack Website Online Tool
  70. Pentest Tools Nmap
  71. Hacker Tools Windows
  72. Pentest Automation Tools
  73. Best Pentesting Tools 2018
  74. Top Pentest Tools
  75. Hacker Tools For Ios
  76. Nsa Hack Tools
  77. Tools Used For Hacking
  78. Hack Tools For Games
  79. Hacking Tools Name
  80. Best Hacking Tools 2020
  81. Pentest Tools Kali Linux
  82. Beginner Hacker Tools
  83. Hacker Tools Github
  84. Beginner Hacker Tools
  85. Pentest Tools Tcp Port Scanner
  86. Hacker Tools List
  87. Pentest Tools Bluekeep
  88. Pentest Tools Find Subdomains
  89. Hacking Tools Pc
  90. Pentest Tools Kali Linux
  91. Beginner Hacker Tools
  92. Hacker Tools For Mac
  93. Hack Tool Apk
  94. Hacking Tools Free Download
  95. Blackhat Hacker Tools
  96. Pentest Tools Url Fuzzer
  97. Physical Pentest Tools
  98. Hacking Apps
  99. Hacking Tools Mac
  100. Growth Hacker Tools
  101. Hacking Tools 2020
  102. Hack Apps
  103. Tools For Hacker
  104. Pentest Tools For Android
  105. Hacking Tools For Beginners
  106. Hacking Tools For Mac
  107. New Hacker Tools
  108. Hacking Tools For Beginners
  109. Hacking Tools Software
  110. Hacking Tools Windows 10
  111. Pentest Tools Linux
  112. Hacking App
  113. Hack Rom Tools
  114. Nsa Hacker Tools
  115. Kik Hack Tools
  116. Tools Used For Hacking
  117. Hacking Tools Mac
  118. Hacking Tools For Windows Free Download
  119. Hacking Tools For Windows 7
  120. Hacking Tools Windows 10
  121. Easy Hack Tools
  122. Hacking Tools Github
  123. Hacking Tools For Mac
  124. Hacker Tools For Ios
  125. Hack Tools 2019
  126. Nsa Hack Tools Download
  127. Hacking Tools Windows
  128. Hack Tools
  129. Hacking Tools Name
  130. Free Pentest Tools For Windows
  131. Hack Tools 2019

No comments:

Post a Comment