diff --git a/README.md b/README.md index 2f1d707..58ac1da 100644 --- a/README.md +++ b/README.md @@ -81,7 +81,13 @@ Some outputs that are too large will be saved in a file in the output folder / d ## Usage ```bash -# normal (passive and aggresive scans) it needs to be run as root. +# normal (passive and aggresive scans) + +python3 gsec.py -t https://domain.com + +# For GSec to detect the OS you will need to run it as root. Just make sure to install requirements as root as well. + +sudo pip3 install -r requirements.txt sudo python3 gsec.py -t https://domain.com diff --git a/utils/osdetect.py b/utils/osdetect.py index 112967f..71e2839 100644 --- a/utils/osdetect.py +++ b/utils/osdetect.py @@ -8,6 +8,7 @@ warnings.filterwarnings('ignore', category=CryptographyDeprecationWarning) from scapy.all import sr1 from scapy.layers.inet import IP, ICMP +import scapy def osdetection_scan(url: str): @@ -19,16 +20,19 @@ def osdetection_scan(url: str): url = url.replace("https://www.", "") if "http://www." in url: url = url.replace("http://www.", "") - os = '' - pack = IP(dst=url)/ICMP() - resp = sr1(pack, timeout=3, verbose=0) - if resp: - if IP in resp: - ttl = resp.getlayer(IP).ttl - if ttl <= 64: - os = 'Linux' - elif ttl > 64: - os = 'Windows' - else: - print('Not Found') - print(f"{Fore.MAGENTA}[+] {Fore.CYAN}-{Fore.WHITE} OS: {Fore.GREEN} {os}") \ No newline at end of file + try: + os = '' + pack = IP(dst=url)/ICMP() + resp = sr1(pack, timeout=3, verbose=0) + if resp: + if IP in resp: + ttl = resp.getlayer(IP).ttl + if ttl <= 64: + os = 'Linux' + elif ttl > 64: + os = 'Windows' + else: + print(f"{Fore.MAGENTA}[+] {Fore.CYAN}-{Fore.WHITE} OS: {Fore.RED} Not Detected!") + print(f"{Fore.MAGENTA}[+] {Fore.CYAN}-{Fore.WHITE} OS: {Fore.GREEN} {os}") + except scapy.error.Scapy_Exception: + pass \ No newline at end of file