Example #1
0
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
Example #2
0
def RapFinger(Host, Domain, Type):
    try:
        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        s.connect((Host, 445))
        s.settimeout(0.3)

        Header = SMBHeader(cmd="\x72", mid="\x01\x00")
        Body = SMBNegoData()
        Body.calculate()

        Packet = str(Header) + str(Body)
        Buffer = struct.pack(">i", len(''.join(Packet))) + Packet

        s.send(Buffer)
        data = s.recv(1024)

        # Session Setup AndX Request, Anonymous.
        if data[8:10] == "\x72\x00":
            Header = SMBHeader(cmd="\x73", mid="\x02\x00")
            Body = SMBSessionData()
            Body.calculate()

            Packet = str(Header) + str(Body)
            Buffer = struct.pack(">i", len(''.join(Packet))) + Packet

            s.send(Buffer)
            data = s.recv(1024)

            # Tree Connect IPC$.
            if data[8:10] == "\x73\x00":
                Header = SMBHeader(cmd="\x75",
                                   flag1="\x08",
                                   flag2="\x01\x00",
                                   uid=data[32:34],
                                   mid="\x03\x00")
                Body = SMBTreeConnectData(Path="\\\\" + Host + "\\IPC$")
                Body.calculate()

                Packet = str(Header) + str(Body)
                Buffer = struct.pack(">i", len(''.join(Packet))) + Packet

                s.send(Buffer)
                data = s.recv(1024)

                # Rap ServerEnum.
                if data[8:10] == "\x75\x00":
                    Header = SMBHeader(cmd="\x25",
                                       flag1="\x08",
                                       flag2="\x01\xc8",
                                       uid=data[32:34],
                                       tid=data[28:30],
                                       pid=data[30:32],
                                       mid="\x04\x00")
                    Body = SMBTransRAPData(
                        Data=RAPNetServerEnum3Data(ServerType=Type,
                                                   DetailLevel="\x01\x00",
                                                   TargetDomain=Domain))
                    Body.calculate()

                    Packet = str(Header) + str(Body)
                    Buffer = struct.pack(">i", len(''.join(Packet))) + Packet

                    s.send(Buffer)
                    data = s.recv(64736)

                    # Rap ServerEnum, Get answer and return what we're looking for.
                    if data[8:10] == "\x25\x00":
                        s.close()
                        return ParsePacket(data)
    except:
        pass
Example #3
0
def RapFinger(Host, Domain, Type):
	try:
		s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
		s.connect((Host,445))
		s.settimeout(0.3)

		Header = SMBHeader(cmd="\x72",mid="\x01\x00")
		Body = SMBNegoData()
		Body.calculate()

		Packet = str(Header)+str(Body)
		Buffer = struct.pack(">i", len(''.join(Packet))) + Packet

		s.send(Buffer)
		data = s.recv(1024)

		# Session Setup AndX Request, Anonymous.
		if data[8:10] == "\x72\x00":
			Header = SMBHeader(cmd="\x73",mid="\x02\x00")
			Body = SMBSessionData()
			Body.calculate()

			Packet = str(Header)+str(Body)
			Buffer = struct.pack(">i", len(''.join(Packet))) + Packet

			s.send(Buffer)
			data = s.recv(1024)

			# Tree Connect IPC$.
			if data[8:10] == "\x73\x00":
				Header = SMBHeader(cmd="\x75",flag1="\x08", flag2="\x01\x00",uid=data[32:34],mid="\x03\x00")
				Body = SMBTreeConnectData(Path="\\\\"+Host+"\\IPC$")
				Body.calculate()

				Packet = str(Header)+str(Body)
				Buffer = struct.pack(">i", len(''.join(Packet))) + Packet

				s.send(Buffer)
				data = s.recv(1024)

				# Rap ServerEnum.
				if data[8:10] == "\x75\x00":
					Header = SMBHeader(cmd="\x25",flag1="\x08", flag2="\x01\xc8",uid=data[32:34],tid=data[28:30],pid=data[30:32],mid="\x04\x00")
					Body = SMBTransRAPData(Data=RAPNetServerEnum3Data(ServerType=Type,DetailLevel="\x01\x00",TargetDomain=Domain))
					Body.calculate()

					Packet = str(Header)+str(Body)
					Buffer = struct.pack(">i", len(''.join(Packet))) + Packet

					s.send(Buffer)
					data = s.recv(64736)

					# Rap ServerEnum, Get answer and return what we're looking for.
					if data[8:10] == "\x25\x00":
						s.close()
						return ParsePacket(data)
	except:
		pass