Ejemplo n.º 1
0
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()
Ejemplo n.º 2
0
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()
Ejemplo n.º 3
0
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()
Ejemplo n.º 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()
Ejemplo n.º 5
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()
Ejemplo n.º 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()
Ejemplo n.º 7
0
def POP3ThreadFunc():
    ServiceListener.startListener(POP3Service.pop3Handler, int(config.get("default", "POP3Port")), "POP3/servers.config")
Ejemplo n.º 8
0
def NetBIOSThreadFunc():
    ServiceListener.startListener(NetBIOSService.netbiosHandler, int(config.get("default", "NetBIOSPort")), "NetBIOS/servers.config")
Ejemplo n.º 9
0
def SMTPThreadFunc():
    ServiceListener.startListener(SMTPService.smtpHandler, int(config.get("default", "SMTPPort")), "SMTP/servers.config")
Ejemplo n.º 10
0
def HTTPSThreadFunc():
    ServiceListener.startListener(HTTPSService.httpsHandler, int(config.get("default", "HTTPSPort")), "HTTPS/servers.config")
Ejemplo n.º 11
0
def SSHThreadFunc():
    ServiceListener.startListener(SSHService.sshHandler, int(config.get("default", "SSHPort")), "SSH/servers.config")
Ejemplo n.º 12
0
def POP3ThreadFunc():
    ServiceListener.startListener(POP3Service.pop3Handler,
                                  int(config.get("default", "POP3Port")),
                                  "POP3/servers.config")
Ejemplo n.º 13
0
def NetBIOSThreadFunc():
    ServiceListener.startListener(NetBIOSService.netbiosHandler,
                                  int(config.get("default", "NetBIOSPort")),
                                  "NetBIOS/servers.config")
Ejemplo n.º 14
0
def SMTPThreadFunc():
    ServiceListener.startListener(SMTPService.smtpHandler,
                                  int(config.get("default", "SMTPPort")),
                                  "SMTP/servers.config")
Ejemplo n.º 15
0
def HTTPSThreadFunc():
    ServiceListener.startListener(HTTPSService.httpsHandler,
                                  int(config.get("default", "HTTPSPort")),
                                  "HTTPS/servers.config")
Ejemplo n.º 16
0
def SSHThreadFunc():
    ServiceListener.startListener(SSHService.sshHandler,
                                  int(config.get("default", "SSHPort")),
                                  "SSH/servers.config")