Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Miguel Sanchez authored and Miguel Sanchez committed Dec 14, 2022
1 parent e1b2462 commit 19976d1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
30 changes: 17 additions & 13 deletions utils/osdetect.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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}")
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

0 comments on commit 19976d1

Please sign in to comment.