Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- #
- # Maps:
- # Port <=> Service/keyword
- #
- # intended use on kali linux
- # to make usable on other linux change PORT_FILE
- # to 'etc/services'
- #
- # EnergyWolf May 2015
- #
- import argparse
- import re
- PORT_FILE = '/etc/unicornscan/ports.txt'
- PATTERN = re.compile(r'[\w\-\']+')
- def get_info(arg):
- with open(PORT_FILE) as f:
- for line in f:
- matches = re.findall(PATTERN, line.lower())
- if arg in matches:
- print line
- elif not arg.isdigit() and any(arg in m for m in matches):
- print line
- if __name__ == "__main__":
- parser = argparse.ArgumentParser(
- description="Port to Service/Service to Port Mapper",
- usage="""
- getport [port]/[service]/[keyword]
- Ex:
- getport 123
- getport ssh
- getport mysql
- getport remote
- etc.""")
- parser.add_argument(
- 'arg', help="Provide a port number or a service/keyword")
- args = parser.parse_args()
- get_info(args.arg.lower())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement