Guest User

TCPDUMP

a guest
Dec 17th, 2010
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.25 KB | None | 0 0
  1. import subprocess, datetime
  2. class MainLoop(object):
  3.     def filename(self):
  4.         now = datetime.datetime.now()
  5.         time = now.strftime("%Y-%m-%d(%H:%M)")
  6.         print time
  7.         option = raw_input("Would you like to set filename? (y/n):").lower()
  8.         try:
  9.             if option == "y":
  10.                 self.inputname()
  11.             if option == "n":
  12.                 self.host()
  13.             else:
  14.                 print "invalid option"
  15.                 self.filename()
  16.         except ValueError:
  17.             print "invalid option"
  18.             self.filename()
  19.     def inputname(self):
  20.         self.raw = self.time
  21.         self.raw = raw_input("Filename:")
  22.         self.host()
  23.     def host(self):
  24.         self.input_host = raw_input("Host:").lower()
  25.         option2 = raw_input("Would you like to compare Hosts? (y/n):")
  26.         try:
  27.             if option2 == "y":
  28.                 self.input_host2 = raw_input("Host 2:")
  29.                 self.cmd2()
  30.             if option2 == "n":
  31.                 self.cmd()
  32.             else:
  33.                 print "invalid option, quitting"
  34.         except ValueError:
  35.             print "invalid option, quitting"
  36.     def cmd2(self):
  37.         command = 'tcpdump -c5 -tttt -w {0} host {1} and host {2}'.format(raw, input_host, input_host2)
  38.         subprocess.call(command.split(), shell=False)
  39.     def cmd(self):
  40.         command = 'tcpdump -c5 -tttt -w {0} host {1}'.format(raw, input_host)
  41.         subprocess.call(command.split(), shell=False)
  42. if __name__ == '__main__':
  43.     MainLoop().filename()
Add Comment
Please, Sign In to add comment