Headless Cobalt Strike
In a previous chapter, we configured the Cobalt Strike team server to start automatically via a service. When the team server starts the listeners we had running are started, but any hosted files we had (e.g. via the scripted web delivery) will not be. This presents a problem for these persistence mechanisms, as they're relying on a hosted payload being present. For the RTO lab in particular - the hosted payload must be available before persistence tasks are triggered for them to be of any use.
One solution is to use a headless Cobalt Strike client via the agscript
utility, to execute an aggressor script on launch. The syntax is: agscript [host] [port] [user] [password] [/path/to/script.cna]
. The aggressor script itself can use the artifact_payload and site_host functions to both generate a payload for a listener and host it on Cobalt Strike's web server.
Begin by creating host_payloads.cna
.
\
Cobalt Strike has various events that we can react to inside aggressor. The ready event fires once the current CS client is connected to the team server and has finished synchronising data. This is important to wait for, otherwise the client will not have information about the running listeners, etc.
\
artifact_payload takes 3 arguments:
Listener name.
Payload type.
Payload architecture.
\
Generating an x64 PowerShell payload for our HTTP listener is as simple as:
Strings must match exactly.
\
site_host takes 7 arguments:
Local IP address of the server.
Port number to host on.
The URI.
File content.
Mime-type.
A friendly description.
Use HTTP or HTTPS.
\
To host $payload
under the /a
URI, we can do:
\
The complete script:
\
Time to test the script:
\
You will see the associated events in the Event Log:
\
And the payload will also be hosted.
\
We can add this to our existing start up service by including a ExecStartPost line.
Last updated