Commits

gbrindisi  committed 253273f

Fixed cli in engine.py, improved SIGINT messages and colorized warnings and errors

  • Participants
  • Parent commits a30aa94
  • Branches clint-integration

Comments (0)

Files changed (3)

 
 from packages.clint.textui import colored
 
+def info(message, prefix, label=''):
+    print prefix + label + message
+
 def success(message, prefix, label='SUCCESS: '):
     print prefix + colored.green(label) + message
 

File core/engine.py

                 #x sys.stdout.write("\r    Remaining targets: %s" % queue.qsize())
                 #sys.stdout.flush()
             except KeyboardInterrupt:
-                print colored.red("\n[X] Interrupt! Killing threads...")
+                print"\n |- " + colored.yellow("INTERRUPT!") + " Killing threads..."
                 queue = Queue.Queue()
                 break
         
         results = set(results)
         
         if errors:
-            print " |- " + colored.red("CRAWL ERRORS!")
+            print " |-[+] " + colored.red("CRAWL ERRORS!")
             for ek, ev in errors.iteritems():
-                print " ||-- %s times %s" % (len(ev), ek)
+                print " |  |- %s times %s" % (len(ev), ek)
         if len(results) > 0:
             print " |- " + colored.green("SUCCESS: ") +  "Found %s unique targets." % len(results)
         else:
             try:
                 if queue.empty() is True:
                     break
-                #sys.stdout.write("\r    Remaining targets: %s" % queue.qsize())
-                #sys.stdout.flush()
+                sys.stderr.write("\r |- Remaining targets: %s" % queue.qsize())
+                sys.stderr.flush()
             except KeyboardInterrupt:
-                print "\n[X] Interrupt! Killing threads..."
+                print "\n |- " + colored.yellow("INTERRUPT!") + " Killing threads..."
                 queue = Queue.Queue()
                 break
         
         results = set(results)
 
         if errors:
-            print " |- " + colored.red("CRAWL ERRORS!")
+            print " |-[+] " + colored.red("CRAWL ERRORS!")
             for ek, ev in errors.iteritems():
-                print " ||- %s times %s" % (len(ev), ek)
+                print " |  |- %s times %s" % (len(ev), ek)
 
         if len(results) > 0:
             print " |- " + colored.green("SUCCESS: ") + "Found %s unique forms." % len(results)
             try:
                 if queue.empty() is True:
                     break
-                sys.stdout.write("\r    Remaining urls: %s" % queue.qsize())
-                sys.stdout.flush()
+                sys.stderr.write("\r |- Remaining urls: %s" % queue.qsize())
+                sys.stderr.flush()
             except KeyboardInterrupt:
-                print "[X] Interrupt! Killing threads..."
+                print "\r |- " + colored.yellow("INTERRUPT!") + " Killing threads..."
                 queue = Queue.Queue()
                 break
 
             self.results.append(r)
 
         if errors:
-            print " |- " + colored.red("SCAN ERRORS!")
+            print " |-[+] " + colored.red("SCAN ERRORS!")
             for ek, ev in errors.iteritems():
-                print " ||- %s times %s" % (len(ev), ek)
+                print " |  |- %s times %s" % (len(ev), ek)
 
     def _scanDOMTargets(self):
         print "\n[+] Start DOM scanning (%s threads)" % self.getOption('threads')
             try:
                 if queue.empty() is True:
                     break
-                #sys.stdout.write("\r    Remaining urls: %s" % queue.qsize())
-                #sys.stdout.flush()
+                sys.stderr.write("\r |- Remaining urls: %s" % queue.qsize())
+                sys.stderr.flush()
             except KeyboardInterrupt:
-                print "[X] Interrupt! Killing threads..."
+                print "\r |- " + colored.yellow("INTERRUPT!") + " Killing threads..."
                 queue = Queue.Queue()
                 break
 
                 self.javascript.append(r)
 
         if errors:
-            print " |- " + colored.red("SCAN ERRORS!")
+            print " |-[+] " + colored.red("SCAN ERRORS!")
             for ek, ev in errors.iteritems():
-                print " ||- %s times %s" % (len(ev), ek)
+                print " |  |- %s times %s" % (len(ev), ek)
        
 
     def start(self):         
 
         print "[-] Scan completed in %s seconds" % (time.time() - start)
                         
-        print "[+] Processing results..."
+        print "\n[+] Processing results..."
+        self._compactResults()
+        print " |- Done."
 
-        self._compactResults()
         self.printResults()
         
         return True

File xsssniper.py

     # Check for updates
     if options.update is True:
         try:
+            info('Checking for updates...', '[+] ')
             print "[+] Checking for updates..."
             path = os.path.split(os.path.realpath(__file__))[0]
             repo = hgapi.Repo(path)
-            #print repo.hg_command("pull")
-            #print repo.hg_update("tip")
-            #print " |- " + colored.green("Updated to rev: %s" % repo.hg_rev())
+            print repo.hg_command("pull")
+            print repo.hg_update("tip")
             success('Updated to rev %s' % repo.hg_rev(), ' |- ')
             exit()
         except Exception: