Skip to content

Add PY3 compatibility using six. #29

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions detect_doublepulsar_rdp.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import threading
import ssl

from six import print_

# Packets
ssl_negotiation_request = binascii.unhexlify("030000130ee000000000000100080001000000")
Expand Down Expand Up @@ -39,7 +40,7 @@ def print_status(ip, message):
global print_lock

with print_lock:
print "[*] [%s] %s" % (ip, message)
print_("[*] [%s] %s" % (ip, message))


def check_ip(ip):
Expand Down Expand Up @@ -91,7 +92,7 @@ def check_ip(ip):
# Server requires NLA which implant does not support
elif len(negotiation_response) >= 19 and negotiation_response[11] == "\x03" and negotiation_response[15] == "\x05":
with print_lock:
print "[-] [%s] Server requires NLA, which DOUBLEPULSAR does not support" % ip
print_("[-] [%s] Server requires NLA, which DOUBLEPULSAR does not support" % ip)

s.close()
return
Expand All @@ -115,13 +116,13 @@ def check_ip(ip):

with print_lock:
if len(ping_response) == 288:
print "[+] [%s] DOUBLEPULSAR RDP IMPLANT DETECTED!!!" % ip
print_("[+] [%s] DOUBLEPULSAR RDP IMPLANT DETECTED!!!" % ip)
else:
print "[-] [%s] Status Unknown - Response received but length was %d not 288" % (ip, len(ping_response))
print_("[-] [%s] Status Unknown - Response received but length was %d not 288" % (ip, len(ping_response)))
s.close()
except socket.error as e:
with print_lock:
print "[-] [%s] No presence of DOUBLEPULSAR RDP implant" % ip
print_("[-] [%s] No presence of DOUBLEPULSAR RDP implant" % ip)


def threaded_check(ip_address):
Expand All @@ -131,7 +132,7 @@ def threaded_check(ip_address):
check_ip(ip_address)
except Exception as e:
with print_lock:
print "[ERROR] [%s] - %s" % (ip_address, e)
print_("[ERROR] [%s] - %s" % (ip_address, e))
finally:
semaphore.release()

Expand All @@ -151,7 +152,7 @@ def threaded_check(ip_address):
network = IPNetwork(net)
for addr in network:
# Skip the network and broadcast addresses
if ((network.size != 1) and ((addr == network.network) or (addr == network.broadcast))):
if network.size != 1 and ((addr == network.network) or (addr == network.broadcast)):
continue
semaphore.acquire()
ip_address = str(addr)
Expand Down
10 changes: 5 additions & 5 deletions detect_doublepulsar_smb.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def print_status(ip, message):
global print_lock

with print_lock:
print "[*] [%s] %s" % (ip, message)
print_("[*] [%s] %s" % (ip, message))


def check_ip(ip):
Expand Down Expand Up @@ -123,7 +123,7 @@ def check_ip(ip):
key = calculate_doublepulsar_xor_key(signature_long)
arch = calculate_doublepulsar_arch(signature_long)
with print_lock:
print "[+] [%s] DOUBLEPULSAR SMB IMPLANT DETECTED!!! Arch: %s, XOR Key: %s" % (ip, arch, hex(key))
print_("[+] [%s] DOUBLEPULSAR SMB IMPLANT DETECTED!!! Arch: %s, XOR Key: %s" % (ip, arch, hex(key)))

if uninstall:
# Update MID and op code via timeout
Expand All @@ -141,11 +141,11 @@ def check_ip(ip):
uninstall_response = s.recv(1024)
if uninstall_response[34] == "\x52":
with print_lock:
print "[+] [%s] DOUBLEPULSAR uninstall successful" % ip
print_("[+] [%s] DOUBLEPULSAR uninstall successful" % ip)

else:
with print_lock:
print "[-] [%s] No presence of DOUBLEPULSAR SMB implant" % ip
print_("[-] [%s] No presence of DOUBLEPULSAR SMB implant" % ip)

s.close()

Expand All @@ -157,7 +157,7 @@ def threaded_check(ip_address):
check_ip(ip_address)
except Exception as e:
with print_lock:
print "[ERROR] [%s] - %s" % (ip_address, e)
print_("[ERROR] [%s] - %s" % (ip_address, e))
finally:
semaphore.release()

Expand Down