Created
February 21, 2024 14:25
-
-
Save reginaldojunior/42bd162f7517123916adf7f5b699b3c8 to your computer and use it in GitHub Desktop.
syscan-example-book.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from scapy.all import * | |
import ipaddress | |
ports = [25,80,53,443,445,8080,8443] | |
def SynScan(host): | |
ans, uans = sr( | |
IP(dst=host)/ | |
TCP(sport=65535,dport=ports,flags="S"), | |
timeout=2, verbose=0) | |
print("Open ports at %s:" % host) | |
for (s,r,) in ans: | |
if s[TCP].dport == r[TCP].sport and r[TCP].flags=="SA": | |
print(s[TCP].dport) | |
def DNSScan(host): | |
ans,unans = sr( | |
IP(dst=host)/ | |
UDP(dport=53)/ | |
DNS(rd=1,qd=DNSQR(qname="google.com")) | |
,timeout=2,verbose=0) | |
if ans and ans[UDP]: | |
print("DNS Server at %s"%host) | |
host = input("Enter IP Address: ") | |
try: | |
ipaddress.ip_address(host) | |
except: | |
print("Invalid address") | |
exit(-1) | |
SynScan(host) | |
DNSScan(host) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment