Skip to content

Commit

Permalink
Merge pull request #54 from RyosukeDTomita/feature/syn-rst-packet
Browse files Browse the repository at this point in the history
Send RST packets in the half open state of SYN scan
  • Loading branch information
RyosukeDTomita authored Aug 30, 2024
2 parents 4627f6c + 460d6a4 commit 3a1f499
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/my_portscanner/scan_tools/SynScan.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,13 @@ def _port_scan(self, port: int) -> dict:
except AttributeError:
return

# SYN/ACKパケットが返ってきた場合には,openとする
if response_packet[TCP].flags == "SA":
# RSTパケットを送信することで,コネクションを切断し,ハーフオープン状態を解消する
sr1(
IP(dst=self.target_ip) / TCP(dport=port, flags="RA"),
timeout=self.max_rtt_timeout / 1000,
)
return {"port": port, "state": "open"}
# RSTパケットが変えてきたときにはclosedとする
elif response_packet[TCP].flags == "RA":
Expand Down

0 comments on commit 3a1f499

Please sign in to comment.