SHARE
TWEET

getport

EnergyWolf May 30th, 2015 (edited) 438 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env python
  2. #
  3. # Maps:
  4. # Port <=> Service/keyword
  5. #
  6. # intended use on kali linux
  7. # to make usable on other linux change PORT_FILE
  8. # to 'etc/services'
  9. #
  10. # EnergyWolf May 2015
  11. #
  12.  
  13.  
  14. import argparse
  15. import re
  16.  
  17.  
  18. PORT_FILE = '/etc/unicornscan/ports.txt'
  19. PATTERN = re.compile(r'[\w\-\']+')
  20.  
  21.  
  22. def get_info(arg):
  23.     with open(PORT_FILE) as f:
  24.         for line in f:
  25.             matches = re.findall(PATTERN, line.lower())
  26.             if arg in matches:
  27.                 print line
  28.             elif not arg.isdigit() and any(arg in m for m in matches):
  29.                 print line
  30.  
  31.  
  32. if __name__ == "__main__":
  33.     parser = argparse.ArgumentParser(
  34.         description="Port to Service/Service to Port Mapper",
  35.         usage="""
  36.        getport [port]/[service]/[keyword]
  37.        Ex:
  38.            getport 123
  39.            getport ssh
  40.            getport mysql
  41.            getport remote
  42.  
  43.            etc.""")
  44.     parser.add_argument(
  45.         'arg', help="Provide a port number or a service/keyword")
  46.     args = parser.parse_args()
  47.  
  48.     get_info(args.arg.lower())
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top