Changeset 5736
- Timestamp:
- 07/13/10 02:46:16 (3 years ago)
- Location:
- zion/trunk/umit
- Files:
-
- 1 added
- 3 modified
-
scan/zion/gui/ZionScanNotebookPage.py (modified) (13 diffs)
-
zion/core/connector.py (added)
-
zion/core/options.py (modified) (2 diffs)
-
zion/core/zion.py (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
zion/trunk/umit/scan/zion/gui/ZionScanNotebookPage.py
r5735 r5736 40 40 from umit.scan.zion.gui.AttractorWidget import AttractorWidget 41 41 from umit.zion.scan import probe 42 from umit.zion.core import address, options, zion, host 42 from umit.zion.core import address, options, zion, host, connector 43 43 from umit.zion.core.host import PORT_STATE_OPEN 44 44 … … 160 160 """ 161 161 self.__hbox = HIGHBox() 162 self.__info = gtk.Label(_(' Information'))162 self.__info = gtk.Label(_('No information available')) 163 163 self.__attractor = AttractorWidget() 164 164 self.__frame_attractor = HIGFrameRNet(_('Attractor')) 165 165 self.__frame_attractor._add(self.__attractor) 166 167 self.__table = gtk.Table(2, 2, False) 168 self.__table.set_col_spacings(3) 169 self.__table.set_row_spacings(3) 170 self.__table.attach(gtk.Label('Vendor:'), 0, 1, 0, 1) 171 self.vendor = gtk.Label('') 172 self.__table.attach(self.vendor, 1, 2, 0, 1) 173 self.__table.attach(gtk.Label('OS name:'), 0, 1, 1, 2) 174 self.os_name = gtk.Label('') 175 self.__table.attach(self.os_name, 1, 2, 1, 2) 166 176 167 177 self.__hbox._pack_expand_fill(self.__info) 168 178 self.__hbox._pack_noexpand_nofill(self.__frame_attractor) 169 179 170 180 self._pack_noexpand_nofill(self.__hbox) 181 self.pack_end(self.__table, True, True, 0) 171 182 172 183 def update_attractors(self,attractors): 173 184 """ 185 Update the attractors at widget to plot them. 174 186 """ 175 187 self.__attractor.update(attractors) 176 188 177 189 def update_os_info(self, info): 190 """ 191 Update information about OS running on host. 192 """ 193 print 'updated' 194 self.__info.set_text('Information:') 195 self.vendor.set_text(info['vendor_name']) 196 os = '%s %s' % (info['os_name'], info['os_version']) 197 self.os_name.set_text(os) 198 178 199 class ZionHostsList(gtk.ScrolledWindow): 179 200 """ … … 326 347 327 348 self.pack_end(self.result) 349 350 # signals needed to update info 351 self.connector = connector.Connector() 328 352 329 353 def update_target(self, target): … … 337 361 if self.target: 338 362 return True 339 340 363 return False 364 365 def update_info(self, obj, text): 366 """ 367 Update information page. 368 """ 369 self.result.get_hosts_view().get_scans_page().write(text) 370 371 def update_port_info(self, obj, host): 372 """ 373 Update the port scan information of host. 374 """ 375 self.result.update_host_info(host) 376 self.update_info(None, 'Obtaining TPC ISN samples\n') 377 378 def update_attractors(self, obj, attractors): 379 """ 380 Update the identification page with the graph of attractors 381 """ 382 self.result.get_hosts_view().get_identification_page().update_attractors(attractors) 383 self.update_info(None, 'Building fingerprint\n') 384 385 def update_host_information(self, obj, info): 386 """ 387 Update information about OS running on host. 388 """ 389 self.result.get_hosts_view().get_identification_page().update_os_info(info) 390 self.update_info(None, 'OS detection finished\n') 341 391 342 392 class ZionProfileHoneyd(ZionProfile): … … 351 401 """ 352 402 """ 353 z = zion.Zion(options.Options(), []) 403 self.connector.connect('scan_finished', self.update_port_info) 404 self.connector.connect('honeyd_finished', self.honeyd_finished) 405 self.connector.connect('update_status', self.update_info) 354 406 355 407 self.result.get_hosts_list().clear_hosts() … … 362 414 targets.append(host.Host(i, self.target)) 363 415 host_str = '%s\n%s' % (i, self.target) 364 self.result.get_hosts_list().add_host(host_str , PIXBUF_FIREWALL)416 self.result.get_hosts_list().add_host(host_str) 365 417 except: 366 418 print "Unimplemented support to address: %s." % i 367 419 else: 368 420 targets.append(host.Host(self.target)) 369 self.result.get_hosts_list().add_host(i , PIXBUF_FIREWALL)421 self.result.get_hosts_list().add_host(i) 370 422 371 423 device = get_default_device() 372 424 saddr = get_ip_address(device) 373 z.get_option_object().add("-c",device) 374 z.get_option_object().add("--forge-addr",saddr) 425 426 opts = options.Options() 427 opts.add("-c",device) 428 opts.add("--forge-addr",saddr) 429 # honeyd option 430 opts.add("-n") 431 432 self.update_info(None, 'Honeyd Detection Started\n') 375 433 376 434 for target in targets: 377 if z.honeyd_detection(target): 378 print 'target is honeyd' 379 else: 380 print 'target isnt honeyd' 381 435 z = zion.Zion(opts, [target], self.connector) 436 z.start() 437 438 def honeyd_finished(self, obj, result): 439 """ 440 Write information about honeyd detection result 441 """ 442 if result: 443 self.update_info(None, 'Target is honeyd\n') 444 else: 445 self.update_info(None, 'Target isnt honeyd\n') 382 446 383 447 class ZionProfileOS(ZionProfile): … … 389 453 ZionProfile.__init__(self, target) 390 454 455 self.connector.connect('scan_finished', self.update_port_info) 456 self.connector.connect('isn_samples_finished', self.update_info, 'Creating time series\n') 457 self.connector.connect('timeseries_created', self.update_info, 'Building attractors\n') 458 self.connector.connect('attractors_built', self.update_attractors) 459 self.connector.connect('fingerprint_finished', self.update_info, 'Performing OS fingerprint matching\n') 460 self.connector.connect('matching_finished', self.update_host_information) 461 391 462 def start(self): 392 463 """ 393 464 """ 394 z = zion.Zion(options.Options(), [] )465 z = zion.Zion(options.Options(), [], self.connector) 395 466 396 467 self.result.clear_port_list() … … 406 477 z.append_target(host.Host(i, self.target)) 407 478 host_str = '%s\n%s' % (i, self.target) 479 self.result.get_hosts_list().add_host(host_str) 408 480 except: 409 481 print "Unimplemented support to address: %s." % i … … 412 484 self.result.get_hosts_list().add_host(self.target) 413 485 414 self.result.get_hosts_list().add_host(host_str)415 416 486 # configure zion options 417 487 device = get_default_device() … … 420 490 z.get_option_object().add("-d") 421 491 z.get_option_object().add("--forge-addr",saddr) 422 z.run() 423 #z.start() 424 425 # update host information 426 self.result.update_host_info(z.get_target_list()[0]) 427 428 attractors = z.get_attractors() 429 430 self.result.get_hosts_view().get_identification_page().update_attractors(attractors) 431 492 z.start() 493 494 self.update_info(None, 'OS Detection Started\n') 495 self.update_info(None, 'Scanning host\n') 432 496 433 497 class ZionProfilePrompt(ZionProfile): … … 467 531 """ 468 532 """ 469 z = zion.Zion(options.Options(), []) 533 self.connector.connect('scan_finished', self.update_port_info) 534 self.connector.connect('synproxy_finished', self.synproxy_finished) 535 self.connector.connect('update_status', self.update_info) 470 536 471 537 self.result.get_hosts_list().clear_hosts() … … 478 544 targets.append(host.Host(i, self.target)) 479 545 host_str = '%s\n%s' % (i, self.target) 480 self.result.get_hosts_list().add_host(host_str , PIXBUF_FIREWALL)546 self.result.get_hosts_list().add_host(host_str) 481 547 except: 482 548 print "Unimplemented support to address: %s." % i 483 549 else: 484 550 targets.append(host.Host(self.target)) 485 self.result.get_hosts_list().add_host(i , PIXBUF_FIREWALL)551 self.result.get_hosts_list().add_host(i) 486 552 487 553 device = get_default_device() 488 554 saddr = get_ip_address(device) 489 z.get_option_object().add("-c",device) 490 z.get_option_object().add("--forge-addr",saddr) 555 556 opts = options.Options() 557 opts.add("-c",device) 558 opts.add("--forge-addr",saddr) 559 # synproxy option 560 opts.add("-y") 561 562 self.update_info(None, 'Syn Proxy Detection Started\n') 491 563 492 564 for target in targets: 493 if z.synproxy_detection(target): 494 print 'target is syn proxy' 495 else: 496 print 'target isnt syn proxy' 565 self.update_info(None, 'Scanning host\n') 566 z = zion.Zion(opts, [target], self.connector) 567 z.start() 568 569 def synproxy_finished(self, obj, result): 570 """ 571 Write information about synproxy detection result 572 """ 573 if result: 574 self.update_info(None, 'Target is synproxy\n') 575 else: 576 self.update_info(None, 'Target isnt synproxy\n') 497 577 498 578 … … 610 690 611 691 # TODO: read device from options 612 device = " eth0"692 device = "wlan0" 613 693 #device = netifaces.interfaces()[0] 614 694 return device -
zion/trunk/umit/zion/core/options.py
r5703 r5736 57 57 OPTION_SEND_INTERVAL = 11 58 58 OPTION_HELP = 12 59 OPTION_HONEYD = 13 60 OPTION_SYNPROXY = 14 59 61 60 62 FORGE_MODE_SYN = 'syn' … … 77 79 '-i': OPTION_SEND_INTERVAL, 78 80 '-d': OPTION_DETECT, 79 '--detect': OPTION_DETECT} 81 '--detect': OPTION_DETECT, 82 '-y': OPTION_SYNPROXY, 83 '-n': OPTION_HONEYD} 80 84 81 OPTIONS_SHORT = 'c:i:p:f:svhd '85 OPTIONS_SHORT = 'c:i:p:f:svhdyn' 82 86 OPTIONS_LONG = ['capture=', 83 87 'capture-amount=', -
zion/trunk/umit/zion/core/zion.py
r5735 r5736 37 37 FORGE_FILTER = 'src host %s and src port %s and dst host %s and dst port %s' 38 38 AMOUNT_OS_DETECTION = 50 39 AMOUNT_HONEYD_DETECTION = 2539 AMOUNT_HONEYD_DETECTION = 5 40 40 SEND_INTERVAL = 0.1 41 41 SYNPROXY_INTERVAL = 1 … … 48 48 """ 49 49 """ 50 def __init__(self, option, target=[] ):50 def __init__(self, option, target=[], connector=None): 51 51 """ 52 52 """ … … 55 55 self.__capture_result = [] 56 56 self.__attractors = [] 57 self.__connector = connector 57 58 threading.Thread.__init__ (self) 58 59 … … 94 95 for target in self.__target: 95 96 print target 97 98 self.notify('scan_finished', self.__target[0]) 96 99 97 100 def do_capture(self, dev=None): … … 186 189 187 190 print options.HELP_TEXT 188 189 if self.__option.has(options.OPTION_FORGE): 191 192 elif self.__option.has(options.OPTION_SYNPROXY): 193 synproxy = self.synproxy_detection() 194 if synproxy==True: 195 print 'Target is synproxy' 196 else: 197 print 'Target isnt synproxy' 198 self.notify('synproxy_finished', synproxy) 199 200 elif self.__option.has(options.OPTION_HONEYD): 201 honeyd = self.honeyd_detection() 202 if honeyd==False: 203 print 'Target isnt honeyd' 204 else: 205 print 'Target is honeyd' 206 self.notify('honeyd_finished', honeyd) 207 208 elif self.__option.has(options.OPTION_FORGE): 190 209 191 210 print … … 218 237 print 'Capturing packets' 219 238 self.do_forge() 239 240 self.notify('isn_samples_finished') 220 241 221 242 print 'Calculating PRNG' 222 243 Rt = self.calculate_PRNG() 223 244 245 self.notify('timeseries_created') 246 224 247 print 'Creating attractors' 225 248 self.__classification(Rt) 226 249 250 self.notify('fingerprint_finished') 251 227 252 print 'Matching' 228 return self.__matching() 253 result = self.__matching() 254 255 self.notify('matching_finished', result) 229 256 230 257 elif self.__option.has(options.OPTION_CAPTURE): … … 240 267 241 268 242 def honeyd_detection(self,target): 243 """ Detect if target are an honeyd. """ 244 245 print 'start honeyd detection' 246 self.__target = [] 247 self.append_target(target) 248 269 def honeyd_detection(self): 270 """ Detect if target are an honeyd. """ 249 271 # configure parameters for honeyd detection 250 272 if not self.__option.has(options.OPTION_CAPTURE_AMOUNT): … … 272 294 if increments.count(k)==4: 273 295 return True 274 275 return False 276 else: 296 277 297 return False 278 279 280 def synproxy_detection(self, target): 298 else: 299 return False 300 301 302 303 def synproxy_detection(self): 281 304 """ Detect if target is an syn proxy. """ 282 283 print 'start syn proxy detection' 284 self.__target = [] 285 self.append_target(target) 286 305 287 306 # configure parameters for honeyd detection 288 307 if not self.__option.has(options.OPTION_CAPTURE_AMOUNT): … … 290 309 self.__option.add('-f','syn') 291 310 311 self.notify('update_status','Searching for open ports\n') 312 313 target = self.__target[0] 314 292 315 # search for open ports in target 293 316 self.do_scan() 294 317 ports = target.get_open_ports() 318 319 self.notify('update_status','Generate random ports\n') 295 320 296 321 origin_port1 = random.randint(1024, 65535) … … 303 328 addr = self.__option.get(options.OPTION_FORGE_ADDR) 304 329 330 self.notify('update_status','Sending packets\n') 305 331 self.do_forge_mode_syn(s, target, ports[0], addr, origin_port1) 306 332 isn1 = self.__capture_result[0][1] … … 316 342 else: 317 343 return False 318 344 319 345 320 346 def calculate_PRNG(self): … … 367 393 matrix.set(self.__matrix, i, 0, x) 368 394 matrix.set(self.__matrix, i, 1, y) 395 396 self.notify('attractors_built', self.__attractors) 369 397 370 398 som.caracterization(self.__som, self.__matrix, EPOCHS) … … 403 431 return self.__attractors 404 432 433 def notify(self, signal, param=None): 434 """ 435 If a connector exists, emits the signal. 436 """ 437 if self.__connector!=None: 438 if param==None: 439 self.__connector.emit(signal) 440 else: 441 self.__connector.emit(signal, param)
