Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

str/byte, new server message check, agents listing bug #103

Merged
merged 14 commits into from Feb 29, 2020
2 changes: 1 addition & 1 deletion data/agent/agent.py
Expand Up @@ -1057,7 +1057,7 @@ def get_file_part(filePath, offset=0, chunkSize=512000, base64=True):
except Exception as e:
result = build_response_packet(0, str('[!] Failed to check job buffer!: ' + str(e)))
process_job_tasking(result)
if data == defaultResponse:
if data.strip() == defaultResponse.strip():
missedCheckins = 0
else:
decode_routing_packet(data)
Expand Down
12 changes: 7 additions & 5 deletions lib/common/empire.py
Expand Up @@ -2215,7 +2215,7 @@ def do_sysinfo(self, line):


def do_download(self, line):
"Task an agent to download a file."
"Task an agent to download a file into the C2."

line = line.strip()

Expand All @@ -2236,7 +2236,7 @@ def do_download(self, line):


def do_upload(self, line):
"Task an agent to upload a file."
"Task the C2 to upload a file into an agent."

# "upload /path/file.ext" or "upload /path/file/file.ext newfile.ext"
# absolute paths accepted
Expand Down Expand Up @@ -3286,7 +3286,7 @@ def do_sysinfo(self, line):


def do_download(self, line):
"Task an agent to download a file."
"Task an agent to download a file into the C2."

line = line.strip()

Expand All @@ -3308,7 +3308,7 @@ def do_download(self, line):


def do_upload(self, line):
"Task an agent to upload a file."
"Task the C2 to upload a file into an agent."

# "upload /path/file.ext" or "upload /path/file/file.ext newfile.ext"
# absolute paths accepted
Expand All @@ -3327,7 +3327,7 @@ def do_upload(self, line):
# TODO: reimplement Python file upload

# # read in the file and base64 encode it for transport
f = open(parts[0], 'r')
f = open(parts[0], 'rb')
fileData = f.read()
f.close()
# Get file size
Expand All @@ -3350,6 +3350,8 @@ def do_upload(self, line):
# get final file size
fileData = helpers.encode_base64(fileData)
# upload packets -> "filename | script data"
if isinstance(fileData, bytes):
fileData = fileData.decode("utf-8")
data = uploadname + "|" + fileData

# dispatch this event
Expand Down
2 changes: 1 addition & 1 deletion lib/common/helpers.py
Expand Up @@ -822,7 +822,7 @@ def decode_base64(data):

def encode_base64(data):
"""
Decode data as a base64 string.
Encode data as a base64 string.
"""
return base64.encodebytes(data).strip()

Expand Down
6 changes: 3 additions & 3 deletions lib/common/messages.py
Expand Up @@ -199,9 +199,9 @@ def display_agents(agents):
print(" %.8s %.2s %.15s %.17s %.23s %.18s %.6s %.8s %.31s %.16s" % ('{0: <8}'.format(agent['name']),
'{0: <2}'.format(agent['language']),
'{0: <15}'.format(str(agent['internal_ip']).split(" ")[0]),
'{0: <17}'.format(agent['hostname']),
'{0: <23}'.format(agent['username']),
'{0: <18}'.format(agent['process_name']),
'{0: <17}'.format(str(agent['hostname'])),
'{0: <23}'.format(str(agent['username'])),
'{0: <18}'.format(str(agent['process_name'])),
'{0: <6}'.format(str(agent['process_id'])),
'{0: <8}'.format(str(agent['delay']) + "/" +str(agent['jitter'])),
'{0: <31}'.format(str(helpers.lastseen(agent['lastseen_time'], agent['delay'], agent['jitter']))),
Expand Down