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