boku7 / BokuLoader

A proof-of-concept Cobalt Strike Reflective Loader which aims to recreate, integrate, and enhance Cobalt Strike's evasion features!
MIT License
1.26k stars 244 forks source link

PrependBytes functionality issue #26

Open Nightbringer21 opened 1 year ago

Nightbringer21 commented 1 year ago

Hi,

There seems to be two issues with the way the PrependBytes functionality works within the aggressor script:

How to replicate the issue:

  1. Edit BokuLoader.cna
  2. Go to line 1032 and uncomment the call to prependBytes
  3. Go to line 431 and add 4 characters at the start of the $Nops variable (e.g. "AAAAPS[X"). This is due to the fact that they will be overwritten by the magic_mz
  4. Compile and load the Agressor Script on CS
  5. Create a Payload with the prepended bytes
  6. Check the binary created for the existence of the original reflective loader (simplest way is to run the YARA rule for the Windows_Trojan_Cobaltsrike indicator by Elastic: https://github.com/elastic/protections-artifacts/blob/main/yara/rules/Windows_Trojan_CobaltStrike.yar

Example output before and after uncommenting prepend:

image

boku7 commented 1 year ago

Thank you for the descriptive issue post! There was some issue with parsing the beacons for the obfuscation and I think that is what is breaking it. I haven’t had time to look into this. Feel free to send a pull request to fix. Alternatively you can just build the beacon shell code and prepend the bytes on the command line