Source Code for network and port scanner, TRW algorithm, and reduction method implementations.

simulate.py 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #Plan:
  2. #Create a program where it will receive a string of data
  3. #That string will be added to a dictionary, with the ip attributes as its keys
  4. #simulate a filter. Like give it a shell script input with one of the attributes
  5. #And have it present the thingies...
  6. #check in Julios visualization what is presented when filtered
  7. import socket
  8. import argparse
  9. import sys
  10. import select
  11. import json
  12. parser = argparse.ArgumentParser()
  13. parser.add_argument('filter', type = str)
  14. args = parser.parse_args()
  15. soc = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
  16. #soc.setblocking(0)
  17. soc.bind(('localhost', 2702))
  18. temp = 1
  19. num = 0
  20. filterArray = []
  21. soc.settimeout(5)
  22. while temp:
  23. print ("waiting to receive message")
  24. num = num + 1
  25. #ready = select.select([soc], [], [], timeout_in_seconds)
  26. try:
  27. data, address = soc.recvfrom(2702)
  28. print "\nreceived %s message" %num
  29. newData = json.loads(data)
  30. except socket.error:
  31. print "\nNo message to receive, leave loop"
  32. temp = 0
  33. for k, v in newData.items():
  34. if k == args.filter:
  35. print k
  36. filterArray.append(v)
  37. print filterArray