Advertisement
Guest User

Untitled

a guest
Sep 20th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Awk 0.56 KB | None | 0 0
  1. # Lists open ports coming from nmap.
  2.  
  3. # It assumes the file is in PYX format and complies with the appropriate DTD.
  4.  
  5.  
  6. function reset()
  7. {
  8.     protocol = "";
  9.     portid = 0;
  10.     state = ""
  11.     service = "";
  12.     in_port = 0;
  13. }
  14.  
  15. BEGIN {
  16.     reset();
  17. }
  18.  
  19. /\(port$/ {
  20.     in_port = 1;
  21. }
  22.  
  23. /\)port$/ {
  24.     printf("%s %u %s %s\n", protocol, portid, state, service);
  25.  
  26.     reset();
  27. }
  28.  
  29. /^Aprotocol / {
  30.     if (in_port)
  31.         protocol = $2;
  32. }
  33.  
  34. /^Aportid / {
  35.     if (in_port)
  36.         portid = $2;
  37. }
  38.  
  39. /^Astate / {
  40.     if (in_port)
  41.         state = $2;
  42. }
  43.  
  44. /^Aname / {
  45.     if (in_port)
  46.         service = $2;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement