Generate an agent
...that will connect to the first listener and then make another request that downloads this as agent.exe
| import requests
import base64
import json
# Configuration
baseUrl = "https://localhost:8443"
username = "---USERNAME---"
password = "---PASSWORD---"
listenerId = 1
payloadTemplateId = "shelldot.payload.windows-x64"
outputFilename = "agent.exe"
# Login & get JWT token
headers = {
"Authorization":
"Basic " +
base64
.b64encode(
(username + ":" + password)
.encode('utf-8')
)
.decode('utf-8')
}
response = requests.request("POST", "%s/api/v1/auth/login" % baseUrl, headers=headers, verify=False)
if response.status_code != 200:
print("Login failed")
exit()
authToken = response.text
headers = {"Authorization": "Bearer " + authToken}
# Create agent
conf = {
"payloadTemplateId": "shelldot.payload.windows-x64",
"configuration": {
"type": "debug_executable"
},
"listenerId": 1,
"encrypted": True
}
response = requests.post("%s/api/v1/payloads" % (baseUrl), headers=headers, json=conf, verify=False)
if response.status_code != 200:
print("Creating payload failed")
print(response.text)
exit()
payload_data = json.loads(response.text)
# Generate agent
response = requests.get("%s/api/v1/payloads/%d/download" % (baseUrl, payload_data["id"]),
headers=headers, verify=False)
if response.status_code != 200:
print("Could not download agent")
print(response.text)
exit()
open(outputFilename, "wb").write(response.content)
print("Agent written to file %s" % outputFilename)
|