Translate

terça-feira, 23 de janeiro de 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 information


  1. Pentest Automation Tools
  2. Hacking Tools And Software
  3. Hacking Tools Hardware
  4. Hack App
  5. Hack Apps
  6. Hack Tools Online
  7. Hacker Tools Linux
  8. Hackers Toolbox
  9. Best Hacking Tools 2020
  10. Nsa Hacker Tools
  11. Pentest Tools For Windows
  12. Hack Tools Mac
  13. What Are Hacking Tools
  14. Pentest Recon Tools
  15. Termux Hacking Tools 2019
  16. Pentest Tools Kali Linux
  17. Pentest Tools Bluekeep
  18. Pentest Tools Free
  19. Pentest Tools For Android
  20. Hacker Tools Hardware
  21. Hacker Tools For Ios
  22. Hack Rom Tools
  23. Hackers Toolbox
  24. Hack Tools For Windows
  25. Hack Tools 2019
  26. Hacker Tools Free
  27. Ethical Hacker Tools
  28. World No 1 Hacker Software
  29. Android Hack Tools Github
  30. Best Pentesting Tools 2018
  31. Hack Tool Apk
  32. Hack Tools For Pc
  33. Hack Tools For Windows
  34. Hacker Tools For Mac
  35. Hack And Tools
  36. Hacker Tools Apk
  37. Pentest Recon Tools
  38. Usb Pentest Tools
  39. Hacking Tools
  40. Bluetooth Hacking Tools Kali
  41. Hacker Tools Linux
  42. Ethical Hacker Tools
  43. Hacking Tools For Windows
  44. Nsa Hacker Tools
  45. Hacking Tools Windows 10
  46. Hacks And Tools
  47. Hack Tools Online
  48. Hacking Tools For Windows 7
  49. Tools 4 Hack
  50. Hacker Search Tools
  51. Best Pentesting Tools 2018
  52. Tools 4 Hack
  53. Hacker Tools Free Download
  54. New Hacker Tools
  55. Pentest Tools Download
  56. Tools 4 Hack
  57. Pentest Tools Open Source
  58. Pentest Tools Android
  59. Hacker Techniques Tools And Incident Handling
  60. Pentest Tools Alternative
  61. Top Pentest Tools
  62. Wifi Hacker Tools For Windows
  63. Hacker Tools
  64. Pentest Recon Tools
  65. Hacker
  66. Pentest Tools Review
  67. Pentest Tools Online
  68. Pentest Recon Tools
  69. What Are Hacking Tools
  70. Pentest Tools Open Source
  71. Hacker Tools Apk
  72. Easy Hack Tools
  73. Top Pentest Tools
  74. Hacking Tools Pc
  75. Hacking Tools For Windows Free Download
  76. Hack Tools
  77. Hacking Tools Software
  78. Hack Tools For Games
  79. Hack Tool Apk No Root
  80. Pentest Automation Tools
  81. Game Hacking
  82. Hacking Tools For Games
  83. Hacking Tools Online
  84. What Are Hacking Tools
  85. Hacking Tools Pc
  86. Hacker Tools 2020
  87. Hacking Tools Download
  88. Easy Hack Tools
  89. Hacking Tools Windows 10
  90. Hack Rom Tools
  91. Game Hacking
  92. Hack Tools For Windows
  93. Hacking Tools Free Download
  94. Hack Tool Apk No Root
  95. Hacking Tools For Games
  96. World No 1 Hacker Software
  97. Hacker Hardware Tools
  98. Hacking Tools Software
  99. Pentest Tools Free
  100. Nsa Hacker Tools
  101. Pentest Tools For Android
  102. Hacker Tools Windows

Arquivo do blog