Skip to content

Instantly share code, notes, and snippets.

@reginaldojunior
Created February 21, 2024 14:25
Show Gist options
  • Save reginaldojunior/42bd162f7517123916adf7f5b699b3c8 to your computer and use it in GitHub Desktop.
Save reginaldojunior/42bd162f7517123916adf7f5b699b3c8 to your computer and use it in GitHub Desktop.
syscan-example-book.py
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