Changeset 5742
- Timestamp:
- 07/15/10 23:40:31 (3 years ago)
- Location:
- zion/trunk/umit
- Files:
-
- 3 modified
-
scan/zion/gui/Plot.py (modified) (1 diff)
-
scan/zion/gui/ZionScanNotebookPage.py (modified) (12 diffs)
-
zion/core/zion.py (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
zion/trunk/umit/scan/zion/gui/Plot.py
r5705 r5742 140 140 """ 141 141 self.__input = input 142 self.__draw_content(self) -
zion/trunk/umit/scan/zion/gui/ZionScanNotebookPage.py
r5741 r5742 25 25 import thread 26 26 import getopt 27 from multiprocessing import Process, Queue 27 28 28 29 from higwidgets.higframe import HIGFrameRNet … … 41 42 from umit.scan.zion.gui.AttractorWidget import AttractorWidget 42 43 from umit.zion.scan import probe 43 from umit.zion.core import address, options, zion, host , connector44 from umit.zion.core import address, options, zion, host 44 45 from umit.zion.core.host import PORT_STATE_OPEN 45 46 … … 333 334 334 335 self.pack_end(self.result) 335 336 # signals needed to update info337 self.connector = connector.Connector()338 339 self.connector.connect('scan_finished', self.update_port_info)340 self.connector.connect('isn_samples_finished', self.update_info, 'Creating time series\n')341 self.connector.connect('timeseries_created', self.update_info, 'Building attractors\n')342 self.connector.connect('attractors_built', self.update_attractors)343 self.connector.connect('fingerprint_finished', self.update_info, 'Performing OS fingerprint matching\n')344 self.connector.connect('matching_finished', self.update_host_information)345 self.connector.connect('honeyd_finished', self.honeyd_finished)346 self.connector.connect('synproxy_finished', self.synproxy_finished)347 self.connector.connect('update_status', self.update_info)348 349 336 self.result.get_hosts_view().set_current_page(0) 337 338 # construct communication queues 339 self.q1 = Queue() 340 self.q2 = Queue() 341 fd = self.q2._reader.fileno() 342 # observe received messages in queue 343 gobject.io_add_watch(fd, gobject.IO_IN, self.update) 350 344 351 345 def update_target(self, target): … … 361 355 return False 362 356 363 def update_info(self, obj,text):357 def update_info(self, text): 364 358 """ 365 359 Update information page. … … 367 361 self.result.get_hosts_view().get_scans_page().write(text) 368 362 369 def update_port_info(self, obj,host):363 def update_port_info(self, host): 370 364 """ 371 365 Update the port scan information of host. 372 366 """ 373 367 self.result.update_host_info(host) 374 self.update_info( None,'Host scanning finished\n')375 376 def update_attractors(self, obj,attractors):368 self.update_info('Host scanning finished\n') 369 370 def update_attractors(self, attractors): 377 371 """ 378 372 Update the scans page with the graph of attractors 379 373 """ 380 374 self.result.get_hosts_view().get_scans_page().update_attractors(attractors) 381 self.update_info(None, 'Building fingerprint\n') 382 383 def update_host_information(self, obj, info): 375 376 def update_host_information(self, info): 384 377 """ 385 378 Update information about OS running on host. 386 379 """ 387 380 self.result.get_hosts_view().get_scans_page().update_os_info(info) 388 self.update_info( None,'OS detection finished\n')389 390 def honeyd_finished(self, obj,result):381 self.update_info('OS detection finished\n') 382 383 def honeyd_finished(self, result): 391 384 """ 392 385 Write information about honeyd detection result 393 386 """ 394 387 if result: 395 self.update_info( None,'Target is honeyd\n')388 self.update_info('Target is honeyd\n') 396 389 else: 397 self.update_info( None,'Target isnt honeyd\n')398 399 def synproxy_finished(self, obj,result):390 self.update_info('Target isnt honeyd\n') 391 392 def synproxy_finished(self, result): 400 393 """ 401 394 Write information about synproxy detection result 402 395 """ 403 396 if result: 404 self.update_info( None,'Target is synproxy\n')397 self.update_info('Target is synproxy\n') 405 398 else: 406 self.update_info(None, 'Target isnt synproxy\n') 399 self.update_info('Target isnt synproxy\n') 400 401 def update(self, fd, cond): 402 """ 403 Update interface with the information received by zion process 404 """ 405 signal, params = self.q2.get() 406 407 if signal=='update_status': 408 self.update_info(params) 409 elif signal=='scan_finished': 410 self.update_port_info(params) 411 elif signal=='attractors_built': 412 self.update_attractors(params) 413 elif signal=='matching_finished': 414 self.update_host_information(params) 415 elif signal=='honeyd_finished': 416 self.honeyd_finished(params) 417 elif signal=='synproxy_finished': 418 self.synproxy_finished(params) 419 return True 407 420 408 421 class ZionProfileHoneyd(ZionProfile): … … 445 458 446 459 for target in targets: 447 z = zion.Zion(opts, [target], self.connector) 448 z.start() 460 z = zion.Zion(opts, [target]) 461 p = Process(target=z.run, args=(self.q2,)) 462 p.start() 449 463 450 464 class ZionProfileOS(ZionProfile): … … 459 473 """ 460 474 """ 461 z = zion.Zion(options.Options(), [] , self.connector)475 z = zion.Zion(options.Options(), []) 462 476 463 477 self.result.get_hosts_view().get_scans_page().clean() … … 487 501 z.get_option_object().add("-d") 488 502 z.get_option_object().add("--forge-addr",saddr) 489 z.start() 503 504 p = Process(target=z.run, args=(self.q2,)) 505 p.start() 506 490 507 491 508 class ZionProfilePrompt(ZionProfile): … … 538 555 self.result.get_hosts_view().get_scans_page().show_attractor_box() 539 556 540 z = zion.Zion(zion_options, [] , self.connector)557 z = zion.Zion(zion_options, []) 541 558 542 559 for a in addrs: … … 552 569 553 570 # run zion 554 z.start() 571 p = Process(target=z.run, args=(self.q2,)) 572 p.start() 555 573 556 574 … … 562 580 """ 563 581 ZionProfile.__init__(self, target) 582 # remove attractor box 583 self.result.get_hosts_view().get_scans_page().hide_attractor_box() 564 584 565 585 def start(self): … … 592 612 593 613 for target in targets: 594 z = zion.Zion(opts, [target], self.connector) 595 z.start() 614 z = zion.Zion(opts, [target]) 615 p = Process(target=z.run, args=(self.q2,)) 616 p.start() 596 617 597 618 PROFILE_CLASS = {'1': ZionProfileHoneyd, -
zion/trunk/umit/zion/core/zion.py
r5741 r5742 24 24 import random 25 25 import time 26 import thread, threading27 26 import sqlite3 28 27 import sys … … 45 44 ALPHA_LIMIT = 0.1 46 45 47 class Zion( threading.Thread):46 class Zion(object): 48 47 """ 49 48 """ 50 def __init__(self, option, target=[] , connector=None):49 def __init__(self, option, target=[]): 51 50 """ 52 51 """ … … 55 54 self.__capture_result = [] 56 55 self.__attractors = [] 57 self.__connector = connector58 threading.Thread.__init__ (self)59 56 60 57 def get_option_object(self): … … 185 182 186 183 187 def run(self): 188 """ 189 """ 184 def run(self, outq=None): 185 """ 186 """ 187 self.__outq = outq 188 190 189 if self.__option.has(options.OPTION_HELP): 191 190 … … 210 209 self.do_forge(['tcp.seq']) 211 210 212 self.notify(' isn_samples_finished')211 self.notify('update_status', 'Creating time series\n') 213 212 214 213 print 'Calculating PRNG' 215 214 Rt = self.calculate_PRNG() 216 215 217 self.notify(' timeseries_created')216 self.notify('update_status', 'Building attractors\n') 218 217 219 218 print 'Creating attractors' 220 219 self.__classification(Rt) 221 220 222 self.notify(' fingerprint_finished')221 self.notify('update_status', 'Performing OS fingerprint matching\n') 223 222 224 223 print 'Matching' … … 451 450 def notify(self, signal, param=None): 452 451 """ 453 If a connector exists, emits the signal. 454 """ 455 if self.__connector!=None: 456 if param==None: 457 self.__connector.emit(signal) 458 else: 459 self.__connector.emit(signal, param) 452 If a out queue exists, output the information. 453 """ 454 if self.__outq!=None: 455 self.__outq.put((signal, param))
