Beispiel #1
0
   def interactive(self, data):
      output = "Starting Manual Mode\n"
      servers = self.data.get_all_servers()

      for (key, value), i in zip(servers.items(), range(0, len(servers))):
         output += "\t" + str(i) +") " + value['server_ip'] + " on " + value['client_mount'] + "\n"
      output += "Which server would you like to test on " + str(range(0, len(servers))) + ": "
     
      options = range(0, len(servers))
  
      user = self.data.log(output, log_input=True)

      while True:
         try:
            user = int(user)
         except:
            self.data.log("\n*** Invalid selection ***\n")
            user = self.data.log(str("Which server would you like to test on " + str(range(0, len(servers))) + ": "), log_input=True)
            continue

         if user in options:
            for key, value in servers.items():
               if value['mapping'] == user:
                  tcp = TcpDump(self.data, value['server_ip'], value['interface'])

                  try:
                     
                     if tcp.error == False: 
                        self.data.log("\nIf you want to exit hit \"CTRL + c\"")

                     while True:
                        time.sleep(0.5)
                        if tcp.process_check.is_alive() == False and tcp.process.is_alive() == False:
                           self.data.log("*** Exiting ***")
                           self.data.log("*** Done ***")
                           sys.exit(1)
                        continue
                  

                  except KeyboardInterrupt:
                     self.data.log("\n*** Exiting ***")
                     tcp.kill_tcpdump()
                     self.data.log("*** Done ***")
                     sys.exit()
         else:
            self.data.log("\n*** Invalid selection ***\n")
            user = self.data.log(str("Which server would you like to test on " + str(range(0, len(servers))) + ": "), log_input=True)
Beispiel #2
0
   def run(self, ip, interface):
      try:
         output = "Starting Manual Mode"
         self.data.log(output)

         tcp = TcpDump(self.data, ip, interface)
         if tcp.error == False:
            self.data.log("\nIf you want to exit hit \"CTRL + c\"")

            while True:
               time.sleep(0.5)
               if tcp.process_check.is_alive() == False and tcp.process.is_alive() == False:
                  self.data.log("*** Exiting ***")
                  self.data.log("*** Done ***")
                  sys.exit()
               continue

      except KeyboardInterrupt:
         self.data.log("\n*** Exiting ***")
         tcp.kill_tcpdump()
         self.data.log("*** Done ***")
         sys.exit()