diff options
| author | jerome <jerome@xlinfo.fr> | 2025-06-20 14:17:15 +0200 |
|---|---|---|
| committer | jerome <jerome@xlinfo.fr> | 2025-06-20 14:17:15 +0200 |
| commit | 34b5518fa596845b557639fea86a3b59cdff5d2d (patch) | |
| tree | 0e6e2dd994eb7c4995848d448009a3a1a1e9541b /scapy/scan_tcp.py | |
| parent | ae8ae69ce17974dc7a1d26ca02d7c0ba1f7f2515 (diff) | |
| download | python-34b5518fa596845b557639fea86a3b59cdff5d2d.tar.gz python-34b5518fa596845b557639fea86a3b59cdff5d2d.zip | |
scapy
Diffstat (limited to 'scapy/scan_tcp.py')
| -rw-r--r-- | scapy/scan_tcp.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/scapy/scan_tcp.py b/scapy/scan_tcp.py new file mode 100644 index 0000000..390c2b2 --- /dev/null +++ b/scapy/scan_tcp.py @@ -0,0 +1,17 @@ +#!/usr/bin/env python
+
+import sys
+from scapy.all import *
+
+def scapy_scan(host,*ports):
+ for port in ports:
+ ans,unans = sr(IP(dst=host)/TCP(sport=RandShort(),dport=int(port)),verbose=0)
+ ans.summary(lambda s,r: r.sprintf("%IP.dst% \t %TCP.sport% \t %TCP.flags%"))
+
+try:
+ scapy_scan(sys.argv[1],*sys.argv[2:])
+except PermissionError:
+ print(f"{sys.argv[0]} nécessite les droits root")
+except IndexError:
+ print(f"{sys.argv[0]} un host et des ports à scanner")
+
|
