Exemple #1
0
    def ping_sweep(self, subnet):
        #subnet => '192.168.1.0/30'
        scanTime = strftime("%H:%M:%S", gmtime())
        import __builtin__
        from network import hosts
        from pprint import pprint

        subnet_hosts = []
        list_of_hosts_created = hosts.get_hosts()
        count = 0

        nma = nmap.PortScanner()

        print nma.scan(hosts=subnet, arguments='-sP')

        hosts_list = [(x, nma[x]['status']['state'], nma[x]['hostname'])
                      for x in nma.all_hosts()]

        # from pprint import pprint
        # pprint(nma)
        # print hosts_list

        for host, status, hostname in hosts_list:
            if status == 'up' or hostname != '':
                hosts.create_host(host, hostname=hostname)

        msg = str(scanTime) + " => Ping sweeped " + subnet
        self.record.append(msg)

        leftBottom_frame.print_bottom_panel("[+] Finished Ping Sweep ")
Exemple #2
0
    def ping_sweep(self, subnet):
        # subnet => '192.168.1.0/30'
        scanTime = strftime("%H:%M:%S", gmtime())
        import __builtin__
        from network import hosts
        from pprint import pprint

        subnet_hosts = []
        list_of_hosts_created = hosts.get_hosts()
        count = 0

        nma = nmap.PortScanner()

        print nma.scan(hosts=subnet, arguments="-sP")

        hosts_list = [(x, nma[x]["status"]["state"], nma[x]["hostname"]) for x in nma.all_hosts()]

        # from pprint import pprint
        # pprint(nma)
        # print hosts_list

        for host, status, hostname in hosts_list:
            if status == "up" or hostname != "":
                hosts.create_host(host, hostname=hostname)

        msg = str(scanTime) + " => Ping sweeped " + subnet
        self.record.append(msg)

        leftBottom_frame.print_bottom_panel("[+] Finished Ping Sweep ")
Exemple #3
0
    def scan_one_host_ports(self, host, tgtPorts):
        from pprint import pprint

        scanTime = strftime("%H:%M:%S", gmtime())
        self.host = host
        address = host.address

        nmScan = nmap.PortScanner()
        self.targetHost = {'id': host.id, 'ip': address, 'ports': []}
        host.scanned = True
        host.openPorts = []

        threads = []

        #-------------- PING RECON ---------------
        # if self.start_ping(address) == "up":

        #--------------OS DETECTION---------------
        def start_os_recon():
            try:
                nmScan.scan(address, arguments="-O")
                pprint(nmScan[address])
                return
            except:
                pass
            printB("[!] Os recognition failed.")

        t = Thread(target=start_os_recon, args=())
        threads.append(t)
        t.start()

        #-------------- PORT SCAN-----------------

        for port in tgtPorts.keys():
            t = Thread(target=self.scan, args=(host, port, tgtPorts[port]))
            threads.append(t)
            t.start()

        # Wait for all of them to finish
        [x.join() for x in threads]

        hosts_list = [(x, nmScan[x]['status']['state'])
                      for x in nmScan.all_hosts()]

        for addr, status in hosts_list:
            if addr == address:
                #-------------- SAVING RECORDS -----------
                if nmScan[address].has_key('osclass'):
                    for osclass in nmScan[address]['osclass']:
                        host.os_type = osclass['type']
                        host.os_vendor = osclass['vendor']
                        host.os_family = osclass['osfamily']
                        host.os_gen = osclass['osgen']
                        host.os_accuracy = osclass['accuracy']

                msg = str(scanTime) + " => Scanned host: " + str(host.id)

                self.record.append(msg)
        leftBottom_frame.print_bottom_panel("[+]Finished Scan.")
Exemple #4
0
    def scan_one_host_ports(self, host, tgtPorts):
        from pprint import pprint

        scanTime = strftime("%H:%M:%S", gmtime())
        self.host = host
        address = host.address

        nmScan = nmap.PortScanner()
        self.targetHost = {"id": host.id, "ip": address, "ports": []}
        host.scanned = True
        host.openPorts = []

        threads = []

        # -------------- PING RECON ---------------
        # if self.start_ping(address) == "up":

        # --------------OS DETECTION---------------
        def start_os_recon():
            try:
                nmScan.scan(address, arguments="-O")
                pprint(nmScan[address])
                return
            except:
                pass
            printB("[!] Os recognition failed.")

        t = Thread(target=start_os_recon, args=())
        threads.append(t)
        t.start()

        # -------------- PORT SCAN-----------------

        for port in tgtPorts.keys():
            t = Thread(target=self.scan, args=(host, port, tgtPorts[port]))
            threads.append(t)
            t.start()

            # Wait for all of them to finish
        [x.join() for x in threads]

        hosts_list = [(x, nmScan[x]["status"]["state"]) for x in nmScan.all_hosts()]

        for addr, status in hosts_list:
            if addr == address:
                # -------------- SAVING RECORDS -----------
                if nmScan[address].has_key("osclass"):
                    for osclass in nmScan[address]["osclass"]:
                        host.os_type = osclass["type"]
                        host.os_vendor = osclass["vendor"]
                        host.os_family = osclass["osfamily"]
                        host.os_gen = osclass["osgen"]
                        host.os_accuracy = osclass["accuracy"]

                msg = str(scanTime) + " => Scanned host: " + str(host.id)

                self.record.append(msg)
        leftBottom_frame.print_bottom_panel("[+]Finished Scan.")
Exemple #5
0
 def assign(self, host, tgtPorts):
     if host.bot_assigned == -1 or host.bot_assigned == self.id:
         self.status = "ASSIGNED"
         if host.scanned:
             self.exploit_all_host(host)
         else:
             self.scan_one_host_ports(host, tgtPorts)
             self.exploit_all_host(host)
     else:
         leftBottom_frame.print_bottom_panel(
             "[!] Host " + str(host.id) + " is already assigned to BOT " +
             str(host.bot_assigned))
Exemple #6
0
 def assign(self, host, tgtPorts):
     if host.bot_assigned == -1 or host.bot_assigned == self.id:
         self.status = "ASSIGNED"
         if host.scanned:
             self.exploit_all_host(host)
         else:
             self.scan_one_host_ports(host, tgtPorts)
             self.exploit_all_host(host)
     else:
         leftBottom_frame.print_bottom_panel(
             "[!] Host " + str(host.id) + " is already assigned to BOT " + str(host.bot_assigned)
         )
Exemple #7
0
    def full_mode(self, host, PORTS):
        if host.bot_assigned == -1 or host.bot_assigned == self.id:
            self.status = "PERMANENT ASSIGNMENT"
            self.targetHost = {'id': host.id, 'ip': host.address, 'ports': []}
            host.bot_assigned = self.id

            self.full_mode_os_recognition(host, PORTS)

            self.full_mode_module(host, PORTS)

        else:
            leftBottom_frame.print_bottom_panel(
                "[!] Host " + str(host.id) + " is already assigned to BOT " +
                str(host.bot_assigned))
Exemple #8
0
    def full_mode(self, host, PORTS):
        if host.bot_assigned == -1 or host.bot_assigned == self.id:
            self.status = "PERMANENT ASSIGNMENT"
            self.targetHost = {"id": host.id, "ip": host.address, "ports": []}
            host.bot_assigned = self.id

            self.full_mode_os_recognition(host, PORTS)

            self.full_mode_module(host, PORTS)

        else:
            leftBottom_frame.print_bottom_panel(
                "[!] Host " + str(host.id) + " is already assigned to BOT " + str(host.bot_assigned)
            )