示例#1
0
    def add(self):
        # increase the task count
        self.count = self.count + 1

        # calculate the percentage done using the given end count
        fraction = self.count / self.total
        percent = int(round(fraction * 100, 0))

        # set a calss field for the progress bar to use
        self.progress = percent

        # pass progress bar count through gauge event
        evt = NewIntEvent(gaugeEventType, -1)
        evt.setValue(percent)
        wx.PostEvent(self.output_window, evt)
示例#2
0
    def add(self):
        #increase the task count
        self.count = self.count + 1

        #calculate the percentage done using the given end count
        fraction = self.count / self.total
        percent = int(round(fraction * 100, 0))

        #set a calss field for the progress bar to use
        self.progress = percent

        #pass progress bar count through gauge event
        evt = NewIntEvent(gaugeEventType, -1)
        evt.setValue(percent)
        wx.PostEvent(self.output_window, evt)
示例#3
0
    def Scan(self):
        self.start = time.time()

        #Send info to text window via our text event
        evt = NewTextEvent(TextEventType, -1)
        evt.setText('Scanning host: ' + self.host + ' over ' +
                    str(self.portrange) + ' ports, with a timeout of ' +
                    str(self.timeout))
        wx.PostEvent(self.output_window, evt)

        #send message to status bar
        evt2 = NewTextEvent(StatusEventType, -1)
        evt2.setText('Scanning...')
        wx.PostEvent(self.output_window, evt2)

        #output for terminal
        print 'Scanning host: ', self.host, ' over ', self.portrange, ' ports, with a timeout of ', self.timeout

        #Generate all the consumer threads, pass the queue object,
        #the host, reference to port_list array, timeout criteria, and
        #status object instance
        for i in range(self.threadcount):
            t = ThreadScan(self.queue, self.host, self.port_list, self.timeout,
                           self.status)
            t.setDaemon(True)
            t.start()
            self.threads.append(t)

        #fill queue with ports needing to be scanned depending on type
        #long scan
        if self.full_scan == True:
            for a in range(1, self.portrange):
                self.queue.put(a)
                self.count = self.count + 1

        #short scan
        elif self.full_scan == False:
            for a in self.common_ports:
                self.queue.put(a)
                self.count = self.count + 1

#wait on the queue until everything has been processed
        self.queue.join()

        #send poison pills to kill threads. If the threads aren't killed
        #then if this class is run multiple times, the threads will exceed
        #limit
        for a in range(self.threadcount):
            self.queue.put(123456789)

        #wait for threads to die, not working right now	, not sure if need
        #self.queue.join()

        #recored ending time
        self.end = time.time()

        #send message to status bar
        evt2 = NewTextEvent(StatusEventType, -1)
        evt2.setText('Scan done')
        wx.PostEvent(self.output_window, evt2)

        #reset progress bar
        evt3 = NewIntEvent(gaugeEventType, -1)
        evt3.setValue(0)
        wx.PostEvent(self.output_window, evt3)

        #build a string with the host name and open ports for writing to disk
        self.Data()

        #call the method for handling gui elements
        self.GUIReport()
示例#4
0
 def reset(self):
     evt = NewIntEvent(gaugeEventType, -1)
     evt.setValue(0)
     wx.PostEvent(self.output_window, evt)
示例#5
0
 def reset(self):
     evt = NewIntEvent(gaugeEventType, -1)
     evt.setValue(0)
     wx.PostEvent(self.output_window, evt)