コード例 #1
0
ファイル: FTPService.py プロジェクト: FadXploit/MagBastard
def ftpHandler(s, server, details, plat_id):
    request = ServiceListener.getMessage(s)
    logger.updateTimestamp(details[0])
    if request != None:
        logger.logEvent(details[2], details[3], details[0], details[1],
                        request)
        print(request)
        honeypot = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        honeypot.connect((inetaddr, inetFTPport + plat_id * 1000))
        # Forward the request to inetsim
        honeypot.send(request)
        #data = 'blah'
        #while data != Nont and data != '':

        # Forward the response from inetsim to client
        data = honeypot.recv(65535)
        ServiceListener.sendResponse(s, data)
        logger.logEvent(details[2], details[3], details[0], details[1], data)
        '''
        properRequest = (request.find("\r\n") != -1)
        if properRequest:
            response = server["Version"]
            ServiceListener.sendResponse(s, response)
            logger.logEvent(details[2], details[3], details[0], details[1], response)
	'''

    s.close()
コード例 #2
0
ファイル: FTPService.py プロジェクト: uiucseclab/MagBastard
def ftpHandler(s, server, details, plat_id):
    request = ServiceListener.getMessage(s)
    logger.updateTimestamp(details[0])
    if request != None:
        logger.logEvent(details[2], details[3], details[0], details[1], request)
        print(request)
	honeypot = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
	honeypot.connect((inetaddr, inetFTPport + plat_id * 1000))
	# Forward the request to inetsim
	honeypot.send(request)
	#data = 'blah'
	#while data != Nont and data != '':
	
	# Forward the response from inetsim to client
	data = honeypot.recv(65535)
	ServiceListener.sendResponse(s, data)
	logger.logEvent(details[2], details[3], details[0], details[1], data)
	'''
        properRequest = (request.find("\r\n") != -1)
        if properRequest:
            response = server["Version"]
            ServiceListener.sendResponse(s, response)
            logger.logEvent(details[2], details[3], details[0], details[1], response)
	'''
	
    s.close()
コード例 #3
0
ファイル: SMTPService.py プロジェクト: FadXploit/MagBastard
def smtpHandler(s, server, details, plat_id):
    request = ServiceListener.getMessage(s)
    logger.updateTimestamp(details[0])
    print request
    honeypot = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    honeypot.connect((inetaddr, inetSMTPport + plat_id * 1000))
    honeypot.send(request)
    response = honeypot.recv(65535)
    '''
    response = server["Version"]
    '''
    ServiceListener.sendResponse(s, response)
    logger.logEvent(details[2], details[3], details[0], details[1], response)     
    s.close()
コード例 #4
0
def httpHandler(s, server, details, plat_id):
    request = ServiceListener.getMessage(s)
    logger.updateTimestamp(details[0])
    if request != None:
        logger.logEvent(details[2], details[3], details[0], details[1],
                        request)
        print(request)
        honeypot = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        honeypot.connect((inetaddr, inetHTTPport + plat_id * 1000))
        honeypot.send(request)
        response = honeypot.recv(65535)
        logger.logEvent(details[2], details[3], details[0], details[1],
                        response)
        ServiceListener.sendResponse(s, response)
        '''
        properRequest = (request.find("\r\n\r\n") != -1)
        # Chain of messages to support
        if (request.startswith("GET ") and properRequest):
            URL = request.split("\r\n")[0][3:].strip()
            properRequest = (URL.endswith("HTTP/1.0") or URL.endswith("HTTP/1.1"))
            response = None
            if properRequest:
                URL = urlparse.urlparse(URL[:URL.rfind("HTTP/")].strip())
                properRequest = (URL.params == URL.query == URL.fragment == "")
                path = URL.path.lower()
                if properRequest:
                    if (path == "/index.html" or path == "index.html" or path == "/"):
                        response = httpResponse(server, filename="HTTP/"+server["GET"]["Filename"], body="HTTP/index.html")
                    elif (path == "/orly_owl.jpg" or path == "orly_owl.jpg"):
                        response = httpResponse(server, filename="HTTP/"+server["GET"]["Filename"], body="HTTP/orly_owl.jpg", ContentType="image/jpeg")
                    elif (path == "/no_wai_owl.jpg" or path == "no_wai_owl.jpg"):
                        response = httpResponse(server, filename="HTTP/"+server["GET"]["Filename"], body="HTTP/no_wai_owl.jpg", ContentType="image/jpeg")
            if response == None:
                response = httpResponse(server, filename="HTTP/"+server["GET"]["Filename"])
            # Determine what flags to use when sending the response based on the FIN settings
            flags = 0
            ###if server["GET"]["FIN_w_response"]:
            ###    flags = 0
            ServiceListener.sendResponse(s, response, flags)
            logger.logEvent(details[2], details[3], details[0], details[1], response)

        elif (request.startswith("OPTIONS ") and "RTSP" in request and properRequest):
            response = httpResponse(server, filename="HTTP/"+server["OPTIONS_RTSP"]["Filename"], body="HTTP/nobody.html")
            ServiceListener.sendResponse(s, response)
        elif (request.startswith("OPTIONS ") and "HTTP" in request and properRequest):
            response = httpResponse(server, filename="HTTP/"+server["OPTIONS_HTTP"]["Filename"], body="HTTP/nobody.html")
            ServiceListener.sendResponse(s, response)
	'''
    s.close()
コード例 #5
0
ファイル: HTTPService.py プロジェクト: uiucseclab/MagBastard
def httpHandler(s, server, details, plat_id):
    request = ServiceListener.getMessage(s)
    logger.updateTimestamp(details[0])
    if request != None:
        logger.logEvent(details[2], details[3], details[0], details[1], request)
        print(request)
	honeypot = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
	honeypot.connect((inetaddr, inetHTTPport + plat_id * 1000))
	honeypot.send(request)
	response = honeypot.recv(65535)
        logger.logEvent(details[2], details[3], details[0], details[1], response)
	ServiceListener.sendResponse(s, response)
	'''
        properRequest = (request.find("\r\n\r\n") != -1)
        # Chain of messages to support
        if (request.startswith("GET ") and properRequest):
            URL = request.split("\r\n")[0][3:].strip()
            properRequest = (URL.endswith("HTTP/1.0") or URL.endswith("HTTP/1.1"))
            response = None
            if properRequest:
                URL = urlparse.urlparse(URL[:URL.rfind("HTTP/")].strip())
                properRequest = (URL.params == URL.query == URL.fragment == "")
                path = URL.path.lower()
                if properRequest:
                    if (path == "/index.html" or path == "index.html" or path == "/"):
                        response = httpResponse(server, filename="HTTP/"+server["GET"]["Filename"], body="HTTP/index.html")
                    elif (path == "/orly_owl.jpg" or path == "orly_owl.jpg"):
                        response = httpResponse(server, filename="HTTP/"+server["GET"]["Filename"], body="HTTP/orly_owl.jpg", ContentType="image/jpeg")
                    elif (path == "/no_wai_owl.jpg" or path == "no_wai_owl.jpg"):
                        response = httpResponse(server, filename="HTTP/"+server["GET"]["Filename"], body="HTTP/no_wai_owl.jpg", ContentType="image/jpeg")
            if response == None:
                response = httpResponse(server, filename="HTTP/"+server["GET"]["Filename"])
            # Determine what flags to use when sending the response based on the FIN settings
            flags = 0
            ###if server["GET"]["FIN_w_response"]:
            ###    flags = 0
            ServiceListener.sendResponse(s, response, flags)
            logger.logEvent(details[2], details[3], details[0], details[1], response)

        elif (request.startswith("OPTIONS ") and "RTSP" in request and properRequest):
            response = httpResponse(server, filename="HTTP/"+server["OPTIONS_RTSP"]["Filename"], body="HTTP/nobody.html")
            ServiceListener.sendResponse(s, response)
        elif (request.startswith("OPTIONS ") and "HTTP" in request and properRequest):
            response = httpResponse(server, filename="HTTP/"+server["OPTIONS_HTTP"]["Filename"], body="HTTP/nobody.html")
            ServiceListener.sendResponse(s, response)
	'''
    s.close()
コード例 #6
0
def netbiosHandler(s, server, details):
    request = ServiceListener.getMessage(s)
    logger.updateTimestamp(details[0])
    if request != None: 
        logger.logEvent(details[2], details[3], details[0], details[1], request)
	print request
	honeypot = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
	honeypot.connect((inetaddr, inetNetBiosport))
	honeypot.send(request)
	response = honeypot.recv(65535)
	ServiceListener.sendResponse(response)
	logger.logEvent(details[2], details[3], details[0], details[1], response)
    '''
    if request != None and request == '\0\0\0\xa4\xff\x53\x4d\x42\x72\0\0\0\0\x08\x01\x40\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x40\x06\0\0\x01\0\0\x81\0\x02PC NETWORK PROGRAM 1.0\0\x02MICROSOFT NETWORKS 1.03\0\x02MICROSOFT NETWORKS 3.0\0\x02LANMAN1.0\0\x02LM1.2X002\0\x02Samba\0\x02NT LANMAN 1.0\0\x02NT LM 0.12\0':
#		if request != None:
        response = server["Version"]
        ServiceListener.sendResponse(s, response)
        logger.logEvent(details[2], details[3], details[0], details[1], response)
    '''
    s.close()