Tuesday, January 23, 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






More info
  1. Hacker Tools Free Download
  2. Best Hacking Tools 2019
  3. Hacker Tools Github
  4. Game Hacking
  5. Pentest Tools Url Fuzzer
  6. Hacker Tools Hardware
  7. Hacking Tools Github
  8. Hacking Tools Kit
  9. Nsa Hack Tools Download
  10. Hacker Tools Windows
  11. Hack Tools Pc
  12. Hacking Apps
  13. Hacker Tools Mac
  14. Hacker Tools For Pc
  15. Pentest Tools Github
  16. Hacking Tools For Beginners
  17. Hack And Tools
  18. Termux Hacking Tools 2019
  19. Tools 4 Hack
  20. Hacking Tools For Windows 7
  21. Hacking Tools Mac
  22. Hacker Hardware Tools
  23. Hacking Tools Windows 10
  24. Pentest Reporting Tools
  25. Hacker Tools Free Download
  26. Ethical Hacker Tools
  27. Hacking Tools Usb
  28. Hack Tools For Pc
  29. Pentest Tools For Windows
  30. Pentest Tools Subdomain
  31. Hack Tools Pc
  32. Hack Tools Download
  33. Hacker Tools Mac
  34. Hacking Tools Online
  35. Best Hacking Tools 2020
  36. Hacker Tools Software
  37. Hacking Tools For Windows Free Download
  38. Hacking Tools And Software
  39. Hacker Search Tools
  40. World No 1 Hacker Software
  41. Pentest Box Tools Download
  42. Hacking Tools For Beginners
  43. Hacker Tools Apk
  44. Pentest Tools For Ubuntu
  45. Hacking Tools And Software
  46. Hacker Tools Apk Download
  47. Pentest Tools Port Scanner
  48. Ethical Hacker Tools
  49. Hacker Tools For Pc
  50. How To Make Hacking Tools
  51. Hacker Tools For Ios
  52. Hacker Tools Linux
  53. Hacking Tools For Beginners
  54. Hacking Tools For Windows
  55. Hack Tools For Games
  56. Hacker Tools Hardware
  57. Tools For Hacker
  58. Nsa Hacker Tools
  59. Hack Tools For Games
  60. Pentest Tools Windows
  61. Hacker Tools 2020
  62. Pentest Tools Android
  63. Kik Hack Tools
  64. Pentest Tools Review
  65. Black Hat Hacker Tools
  66. Pentest Tools
  67. Usb Pentest Tools
  68. Hacker Tools Online
  69. Pentest Automation Tools
  70. Hack Tools For Games
  71. Black Hat Hacker Tools
  72. Tools 4 Hack
  73. Github Hacking Tools
  74. Hack Tools Download
  75. Hacking Tools For Windows 7
  76. Hacking Tools For Windows Free Download
  77. Hack Tools Pc

No comments: