lundi 5 juin 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






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

Aucun commentaire:

Enregistrer un commentaire