Patch b64decode padding error
parent
0eb4cd02d3
commit
cfdc5d5556
|
@ -134,6 +134,9 @@ def build_response_packet(taskingID, packetData, resultID=0):
|
|||
|
||||
if packetData:
|
||||
packetData = base64.b64encode(packetData.decode('utf-8').encode('utf-8',errors='ignore'))
|
||||
if len(packetData) % 4:
|
||||
packetData += '=' * (4 - len(packetData) % 4)
|
||||
|
||||
length = struct.pack('=L',len(packetData))
|
||||
return packetType + totalPacket + packetNum + resultID + length + packetData
|
||||
else:
|
||||
|
|
|
@ -1481,10 +1481,10 @@ class Agents:
|
|||
conn = self.get_db_connection()
|
||||
cur = conn.cursor()
|
||||
data = cur.execute("SELECT data FROM taskings WHERE agent=? AND id=?", [sessionID,taskID]).fetchone()[0]
|
||||
cur.close()
|
||||
theSender="Agents"
|
||||
if data.startswith("function Get-Keystrokes"):
|
||||
theSender += "PsKeyLogger"
|
||||
cur.close()
|
||||
theSender="Agents"
|
||||
if data.startswith("function Get-Keystrokes"):
|
||||
theSender += "PsKeyLogger"
|
||||
if results:
|
||||
# signal that this agent returned results
|
||||
dispatcher.send("[*] Agent %s returned results." % (sessionID), sender=theSender)
|
||||
|
|
|
@ -199,14 +199,7 @@ def parse_result_packet(packet, offset=0):
|
|||
taskID = struct.unpack('=H', packet[6+offset:8+offset])[0]
|
||||
length = struct.unpack('=L', packet[8+offset:12+offset])[0]
|
||||
if length != '0':
|
||||
if length % 4:
|
||||
#padding fix
|
||||
datapart = packet[12+offset:12+offset+length]
|
||||
datapart += '=' * (4 - length % 4)
|
||||
data = base64.b64decode(datapart)
|
||||
else:
|
||||
data = base64.b64decode(packet[12+offset:12+offset+length])
|
||||
#data = base64.b64decode(packet[12+offset:12+offset+length])
|
||||
data = base64.b64decode(packet[12+offset:12+offset+length])
|
||||
else:
|
||||
data = None
|
||||
remainingData = packet[12+offset+length:]
|
||||
|
|
Loading…
Reference in New Issue