Script made by S4vitar, modified by me by adding a function to analyze open ports.
The complete code can be found on GitHub
Simple tool.
#PYTHON1#!/usr/bin/python3 2#coding: utf-8 3 4import re, sys, subprocess 5 6print("W1hchSystem2") 7 8#Usage python3 wh1chSystem.py 10.10.10.205 9 10ip = re.compile("\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}") 11 12def dato_erroneo(): 13 14 if len(sys.argv) != 2 or sys.argv[1] 15 != ip: 16 print("\n[!] Usage: python3 " 17 + sys.argv[0] + " <ip-direction>\n") 18 sys.exit(1) 19 20def get_ttl(ip_address): 21 22 proc = subprocess.Popen(["/usr/bin/ping 23 -c 1 %s" % 24ip_address, ""], stdout=subprocess.PIPE, 25shell=True) 26 27 (out,err) = proc.communicate() 28 29 out = out.split() 30 out = out[12].decode('utf-8') 31 32 try: 33 34 ttl_value = re.findall(r"\d{1,3}", 35 out)[0] 36 37 return ttl_value 38 39 except IndexError: 40 41 if ttl_value is IndexError: 42 print("Machine out of order") 43 sys.exit(1) 44 45 46def get_os(ttl): 47 48 ttl = int(ttl) 49 50 if ttl >=0 and ttl <=64: 51 return "Linux" 52 53elif ttl >= 65 and ttl <= 128: 54 return "Windows" 55 56 else: 57 return "Not Found" 58