Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python3
- #coding: utf-8
- import re, sys, subprocess
- # python3 wichSystem.py 10.10.10.188
- if len(sys.argv) != 2:
- print("\n[!] Uso: python3 " + sys.argv[0] + " <direccion-ip>\n")
- sys.exit(1)
- def get_ttl(ip_address):
- proc = subprocess.Popen(["/usr/bin/ping -c 1 %s" % ip_address, ""], stdout=subprocess.PIPE, shell=True)
- (out,err) = proc.communicate()
- out = out.split()
- out = out[12].decode('utf-8')
- ttl_value = re.findall(r"\d{1,3}", out)[0]
- return ttl_value
- def get_os(ttl):
- ttl = int(ttl)
- if ttl >= 0 and ttl <= 64:
- return "Linux"
- elif ttl >= 65 and ttl <= 128:
- return "Windows"
- else:
- return "Not Found"
- if __name__ == '__main__':
- ip_address = sys.argv[1]
- ttl = get_ttl(ip_address)
- os_name = get_os(ttl)
- print("\n%s (ttl -> %s): %s\n" % (ip_address, ttl, os_name))
Advertisement
Comments
-
- me sale este error zsh: /usr/bin/whichSystem.py: bad interpreter: /usr/bin/python3^M: no existe el fichero o el directorio
Add Comment
Please, Sign In to add comment