def RunSmbFinger(host): try: s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect(host) s.settimeout(0.7) h = SMBHeader(cmd="\x72", flag1="\x18", flag2="\x53\xc8") n = SMBNego(data=SMBNegoFingerData()) n.calculate() Packet = str(h) + str(n) Buffer = struct.pack(">i", len(''.join(Packet))) + Packet s.send(Buffer) data = s.recv(2048) if data[8:10] == "\x72\x00": Header = SMBHeader(cmd="\x73", flag1="\x18", flag2="\x17\xc8", uid="\x00\x00") Body = SMBSessionFingerData() Body.calculate() Packet = str(Header) + str(Body) Buffer = struct.pack(">i", len(''.join(Packet))) + Packet s.send(Buffer) data = s.recv(2048) if data[8:10] == "\x73\x16": return OsNameClientVersion(data) except: print color("[!] ", 1, 1) + " Fingerprint failed" return None
def RunSmbFinger(host): try: s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect(host) s.settimeout(0.7) h = SMBHeader(cmd="\x72",flag1="\x18",flag2="\x53\xc8") n = SMBNego(data = SMBNegoFingerData()) n.calculate() Packet = str(h)+str(n) Buffer = struct.pack(">i", len(''.join(Packet)))+Packet s.send(Buffer) data = s.recv(2048) if data[8:10] == "\x72\x00": Header = SMBHeader(cmd="\x73",flag1="\x18",flag2="\x17\xc8",uid="\x00\x00") Body = SMBSessionFingerData() Body.calculate() Packet = str(Header)+str(Body) Buffer = struct.pack(">i", len(''.join(Packet)))+Packet s.send(Buffer) data = s.recv(2048) if data[8:10] == "\x73\x16": return OsNameClientVersion(data) except: print color("[!] ", 1, 1) +" Fingerprint failed" return None
def RunSmbFinger(host): try: s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect(host) s.settimeout(0.7) h = SMBHeader(cmd='\x72', flag1='\x18', flag2='\x53\xc8') n = SMBNego(data=str(SMBNegoFingerData())) n.calculate() Packet = str(h) + str(n) Buffer1 = StructPython2or3('>i', str(Packet)) + str(Packet) s.send(NetworkSendBufferPython2or3(Buffer1)) data = s.recv(2048) if data[8:10] == b'\x72\x00': Header = SMBHeader(cmd="\x73", flag1="\x18", flag2="\x17\xc8", uid="\x00\x00") Body = SMBSessionFingerData() Body.calculate() Packet = str(Header) + str(Body) Buffer1 = StructPython2or3('>i', str(Packet)) + str(Packet) s.send(NetworkSendBufferPython2or3(Buffer1)) data = s.recv(2048) if data[8:10] == b'\x73\x16': return OsNameClientVersion(data) except: print(color("[!] ", 1, 1) + " Fingerprint failed") return None
def run(host): s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect(host) s.settimeout(5) Header = SMBHeader(Cmd="\x72",Flag1="\x18",Flag2="\x53\xc8") Nego = SMBNego(Data = SMBNegoData()) Nego.calculate() Packet = str(Header)+str(Nego) Buffer = NbtLen(Packet)+Packet s.send(Buffer) try: data = s.recv(1024) if data[4:5] == "\xff": print "This host doesn't support SMBv2" if data[4:5] == "\xfe": IsDCVuln(GetBootTime(data[116:124])) except Exception: s.close() raise
def run(host): s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect(host) s.settimeout(5) Header = SMBHeader(Cmd="\x72", Flag1="\x18", Flag2="\x53\xc8") Nego = SMBNego(Data=SMBNegoData()) Nego.calculate() Packet = str(Header) + str(Nego) Buffer = NbtLen(Packet) + Packet s.send(Buffer) try: data = s.recv(1024) if data[4:5] == "\xff": print "This host doesn't support SMBv2" if data[4:5] == "\xfe": IsDCVuln(GetBootTime(data[116:124])) except Exception: s.close() raise