Skip to content

Commit b5ebda1

Browse files
authored
Add some missing parameters to TCP_Client (#4821)
* Add some missing parameters to TCP_Client * Also add source port
1 parent f97890d commit b5ebda1

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

scapy/layers/inet.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2165,16 +2165,20 @@ class TCP_client(Automaton):
21652165
:param ip: the ip to connect to
21662166
:param port:
21672167
:param src: (optional) use another source IP
2168+
:param sport: (optional) the TCP source port (default: random)
2169+
:param seq: (optional) initial TCP sequence number (default: random)
21682170
"""
21692171

2170-
def parse_args(self, ip, port, srcip=None, **kargs):
2172+
def parse_args(self, ip, port, srcip=None, sport=None, seq=None, ack=0, **kargs):
21712173
from scapy.sessions import TCPSession
21722174
self.dst = str(Net(ip))
21732175
self.dport = port
2174-
self.sport = random.randrange(0, 2**16)
2176+
self.sport = sport if sport is not None else random.randrange(0, 2**16)
21752177
self.l4 = IP(dst=ip, src=srcip) / TCP(
21762178
sport=self.sport, dport=self.dport,
2177-
flags=0, seq=random.randrange(0, 2**32)
2179+
flags=0,
2180+
seq=seq if seq is not None else random.randrange(0, 2**32),
2181+
ack=ack,
21782182
)
21792183
self.src = self.l4.src
21802184
self.sack = self.l4[TCP].ack

0 commit comments

Comments
 (0)