Beispiel #1
0
    def run(self):
        global queue
        while True:
            dict_response = dict()
            condition.acquire()
            if not queue:
                print "Nothing in queue, consumer is waiting"
                condition.wait()
                print "Producer added something to queue and notified the consumer"
            request = queue.pop(0)
            print "Consumed" + str(request.ip_addr)
            logger.info(" Got Request from Server IP = " +
                        str(request.ip_addr) + " Type = " + str(request.type))
            condition.release()
            print >> sys.stderr, 'received "%s"' % request.ip_addr
            if request.type == 1:
                logger.info(" Single Host Scanning Mode Requested ")
                print " For scanning IP " + str(request.ip_addr)
                if (True == is_up(request.ip_addr)):
                    dict_response[request.ip_addr] = True
                else:
                    dict_response[request.ip_addr] = False
            elif request.type == 2:
                logger.info(" Multiple Host Scanning Mode Requested ")
                dict_response = scan_ip(request.port_list)

            elif request.type == 3:  ### For port scanning
                logger.info(" Port Scanning Mode Requested ")
                if request.port_scanning_mode == 1:
                    logger.info("Requested SYN mode")
                    dict_response = scan_port_ack(request.port_list,
                                                  request.ip_addr,
                                                  logger)  ### Add modes
                elif request.port_scanning_mode == 2:
                    logger.info("Requested Full connect ")
                    dict_response = scan_port_connect(request.port_list,
                                                      request.ip_addr, logger)
                elif request.port_scanning_mode == 3:
                    logger.info(" Requested Fin mode ")
                    dict_response = scan_port_fin(request.port_list,
                                                  request.ip_addr,
                                                  logger)  ##change this to Fin
                else:
                    print "Scanning mode invalid"

            else:
                logger.info("GOT WRONG PACKET")
            resp = Response(request.type, request.ip_addr, request.ip_subnet,
                            request.port_start, request.port_end,
                            request.port_list, request.date_today,
                            dict_response, request.date_only)
            logger.info("Sending Results back to Server " + str(dict_response))
            print "Sending to the server"
            server_send(resp)
Beispiel #2
0
def scan_ip(port_list):

    response = dict()
    for i in range(0, len(port_list)):

        logger.info(" Pinging for IP " + str(port_list[i]))
        if (True == is_up(port_list[i])):
            response[port_list[i]] = True
        else:
            response[port_list[i]] = False
    return response
Beispiel #3
0
def scan_ip(port_list):

 response = dict()
 for i in range(0,len(port_list)):

      logger.info(" Pinging for IP " + str(port_list[i]))
      if(True == is_up(port_list[i])):
          response[port_list[i]] = True
      else:
          response[port_list[i]]  = False
 return response
Beispiel #4
0
    def run(self):
        global queue
        while True:
            dict_response = dict()
            condition.acquire()
            if not queue:
                print "Nothing in queue, consumer is waiting"
                condition.wait()
                print "Producer added something to queue and notified the consumer"
            request = queue.pop(0)
            print "Consumed" + str (request.ip_addr)
            logger.info(" Got Request from Server IP = " + str(request.ip_addr) + " Type = " + str(request.type))
            condition.release()
            print >>sys.stderr, 'received "%s"' % request.ip_addr
            if  request.type == 1:                                   
                logger.info (" Single Host Scanning Mode Requested ")
                print " For scanning IP " + str(request.ip_addr)
                if(True == is_up(request.ip_addr)):
                   dict_response[request.ip_addr] = True
                else:
                  dict_response[request.ip_addr]  = False
            elif request.type == 2:
                logger.info(" Multiple Host Scanning Mode Requested ")
                dict_response = scan_ip(request.port_list)

            elif request.type == 3:                                          ### For port scanning 
                 logger.info(" Port Scanning Mode Requested ")
                 if request.port_scanning_mode == 1:
                    logger.info("Requested SYN mode")
                    dict_response=scan_port_ack(request.port_list,request.ip_addr,logger)  ### Add modes
                 elif request.port_scanning_mode == 2:
                    logger.info("Requested Full connect ")
                    dict_response=scan_port_connect(request.port_list,request.ip_addr,logger)
                 elif request.port_scanning_mode == 3:
                    logger.info(" Requested Fin mode ")
                    dict_response=scan_port_fin(request.port_list,request.ip_addr,logger)    ##change this to Fin
                 else :
                     print "Scanning mode invalid"
                 
            else:
                 logger.info( "GOT WRONG PACKET")
            resp = Response(request.type,request.ip_addr,request.ip_subnet,request.port_start,request.port_end,request.port_list,request.date_today,dict_response,request.date_only)
            logger.info( "Sending Results back to Server " + str(dict_response))
            print "Sending to the server"
            server_send(resp)