Changeset 5839
- Timestamp:
- 08/19/10 23:56:55 (3 years ago)
- Location:
- network-scanner/branches/GSoC2010/umit/gui/qs
- Files:
-
- 2 modified
-
EntryField.py (modified) (15 diffs)
-
Main.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
network-scanner/branches/GSoC2010/umit/gui/qs/EntryField.py
r5588 r5839 23 23 import re 24 24 from datetime import datetime 25 from subprocess import Popen, PIPE 25 26 26 27 import gobject 27 28 import gtk 29 import shlex 30 import traceback 28 31 from gtk import gdk 29 32 … … 38 41 from umit.core.qs.Nmap import Nmap 39 42 from umit.core.TargetList import TargetList 43 from umit.core.UmitLogging import log 44 from umit.gui.NmapOutputViewer import NmapOutputViewer 40 45 41 46 #TODO: Import this of core, changing it from ScanNotebook to core … … 128 133 self.entry.set_max_length(1000) 129 134 130 #if not self.completion.get_model(): 131 #self.load_data("host") 135 self.nmap_output = NmapOutputViewer() 136 # remove some buttons 137 self.nmap_output.hbox_buttons.remove(self.nmap_output.btn_output_properties) 138 self.nmap_output.hbox_buttons.remove(self.nmap_output.btn_refresh) 139 # add button to launch result in umit 140 self.btn_umit = gtk.Button ("Open Result") 141 self.nmap_output.hbox_buttons.pack_start(self.btn_umit) 142 143 self.results_opened = False 144 132 145 self.load_data(None) 133 134 self.result_text = HIGTextView() 135 self.result_text.set_editable(False) 136 self.result_text.set_cursor_visible(False) 137 self.result_text.set_justification(gtk.JUSTIFY_LEFT) 138 139 # Menu to launch Network Scanner 140 #menu = gtk.Menu() 141 #menu_item = gtk.MenuItem("Open result on the Network Scanner") 142 #menu_item.connect('activate', self.launch_umit, self.result_text) 143 #menu.append(menu_item) 144 145 #self.result_text.connect('activate', self.launch_umit) 146 147 self.buffer = self.result_text.get_buffer() 146 147 self.btn_umit.connect("clicked", self._launch_umit, None) 148 148 149 149 self.entry.show() 150 151 def show_results(self): 152 """ 153 Show scan output 154 """ 155 if not self.results_opened: 156 self.vbox.pack_end(self.nmap_output) 157 self.vbox.show_all() 158 self.results_opened = True 159 160 def hide_results(self): 161 """ 162 Hide scan output 163 """ 164 if self.results_opened: 165 self.vbox.remove(self.nmap_output) 166 self.results_opened = False 150 167 151 168 def menu_to_umit(self, widget, button, time, data=None): … … 156 173 data.show_all() 157 174 158 def launch_umit(self, widget, button):175 def _launch_umit(self, widget, event): 159 176 """ 160 177 Here will go the call to NetWork Scanner to display results previously 161 178 loaded here. 162 179 """ 163 nscanner_call = "umit -f %s" % self.command_execution.get_normal_output_file() 164 if button == 3: 165 self.command_process = Popen(nscanner_call , bufsize=1, stdin=PIPE, 180 nscanner_call = "umit -f %s" % self.command_execution.get_xml_output_file() 181 args = shlex.split(nscanner_call) 182 print args 183 self.command_process = Popen(args, bufsize=1, stdin=PIPE, 166 184 stdout=PIPE, stderr=PIPE) 167 185 … … 173 191 liststore = gtk.ListStore(str) 174 192 175 #if option == "host":176 #for _d in self.qs_data.get_target_list():177 #liststore.append([_d])178 #elif option == "profile":179 #for _d in self.qs_data.get_profiles("profile_name"):180 #liststore.append([_d])181 #elif option == "nmap_options":182 #for _d in self.qs_data.get_nmap_options():183 #liststore.append([_d])184 #else:185 for _d in self.qs_data.get_all().values():186 for _i in _d:187 liststore.append([_i])193 if option == "host": 194 for _d in self.qs_data.get_target_list(): 195 liststore.append([_d]) 196 elif option == "profile": 197 for _d in self.qs_data.get_profiles("profile_name"): 198 liststore.append([_d]) 199 elif option == "nmap_options": 200 for _d in self.qs_data.get_nmap_options(): 201 liststore.append([_d]) 202 else: 203 for _d in self.qs_data.get_all().values(): 204 for _i in _d: 205 liststore.append([_i]) 188 206 189 207 self.completion.set_model(liststore) … … 194 212 self.entry.set_completion(self.completion) 195 213 self.completion.set_text_column(0) 196 197 #try: 198 #column = self.completion.get_text_column() + 1 199 #except: 200 #column = 0 201 202 return 214 203 215 204 216 #def load_if_not_complete(self, widget, event): … … 221 233 return modelstr.lower().startswith(key.lower()) 222 234 235 223 236 def on_completion_not_match(self, widget): 224 237 """ … … 228 241 target_list = TargetList() 229 242 230 231 243 entered_text = self.entry.get_text() 232 244 … … 283 295 alive = self.command_execution.scan_state() 284 296 297 file = self.command_execution.get_normal_output_file() 298 self.nmap_output.show_nmap_output(file) 299 self.show_results() 285 300 286 301 287 text_out = self.scan_result.set_nmap_output(possible_host,288 self.command_execution.get_normal_output(),289 possible_profile)302 #text_out = self.scan_result.set_nmap_output(possible_host, 303 # self.command_execution.get_normal_output(), 304 # possible_profile) 290 305 291 self.buffer.set_text(text_out)292 self.vbox.pack_start(self.result_text, False, False, 0)293 self.result_text.show()306 #self.buffer.set_text(text_out) 307 #self.vbox.pack_start(self.result_text, False, False, 0) 308 #self.result_text.show() 294 309 295 310 self.save_scan(possible_host) … … 302 317 except: 303 318 pass 319 304 320 305 321 def on_completion_match(self, completion, model, iter): 306 322 #get the text entered by the user 307 323 entered_text = self.entry.get_text() 308 309 324 310 325 if model[iter][0]: … … 336 351 text_out += "%s: %s\n" % (_t[0], _t[1]) 337 352 338 self.buffer.set_text(text_out)339 self.vbox.pack_start(self.result_text, False, False, 0)340 self.result_text.show()353 #self.buffer.set_text(text_out) 354 #self.vbox.pack_start(self.result_text, False, False, 0) 355 #self.result_text.show() 341 356 342 357 … … 349 364 if not alive: 350 365 break 351 352 text_out = self.scan_result.set_nmap_output(possible_host, 353 self.command_execution.get_normal_output(), 354 possible_profile) 355 356 self.buffer.set_text(text_out) 357 self.vbox.pack_start(self.result_text, False, False, 0) 358 self.result_text.show() 366 367 file = self.command_execution.get_normal_output_file() 368 self.nmap_output.show_nmap_output(file) 369 self.show_results() 370 371 #text_out = self.scan_result.set_nmap_output(possible_host, 372 # self.command_execution.get_normal_output(), 373 # possible_profile) 374 375 #self.buffer.set_text(text_out) 376 #self.vbox.pack_start(self.result_text, False, False, 0) 377 #self.result_text.show() 359 378 360 379 self.save_scan(possible_host) … … 365 384 366 385 except: 367 pass 386 print("exception") 387 traceback.print_exc(file=sys.stdout) 368 388 369 389 del data_from_db … … 373 393 374 394 def on_backspace(self, entry): 375 if self.buffer.get_char_count() > 1: 376 self.buffer.set_text("") 377 #self.vbox.pack_start(self.result_text, False, False, 0) 378 self.vbox.remove(self.result_text) 379 self.resize(500,30) 380 self.result_text.show() 381 395 self.hide_results() 396 self.resize(500,30) 382 397 self.b_text = "" 383 398 … … 499 514 500 515 def set_nmap_output(self, host, msg, command): 516 517 # Nmap output in parameter msg 501 518 502 519 text_out = "Running a %s on %s...\n" % (command, host) -
network-scanner/branches/GSoC2010/umit/gui/qs/Main.py
r5778 r5839 52 52 HIGMainWindow.__init__(self) 53 53 self.vbox = HIGVBox() 54 self.main_hbox = gtk.HBox() 54 55 self.set_default_size(500, 30) 55 56 self.set_border_width(0) … … 69 70 EntryField.__init__(self) 70 71 self.set_title("Umit QuickScan") 71 self.add(self. vbox)72 self.add(self.main_hbox) 72 73 self.set_position(gtk.WIN_POS_CENTER) 73 74 … … 91 92 status_icon.set_visible(True) 92 93 93 self.vbox.show() 94 95 self.main_hbox.pack_start(self.vbox, True, True, 6) 96 self.vbox.pack_start(self.entry, False, True, 6) 94 97 self.show_all() 95 self.vbox.pack_start(self.entry,False)96 98 97 libkeybinder.bind(libkeybinder.Modifiers[' ctrl'], 'x', unhide_callback, self)99 libkeybinder.bind(libkeybinder.Modifiers['alt'], 'q', unhide_callback, self) 98 100 99 101 def minimize_to_tray(self, widget):
