segunda-feira, 22 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






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

Nenhum comentário: