Skip to content

Commit

Permalink
Fix TFTP_RRQ server (#4469)
Browse files Browse the repository at this point in the history
  • Loading branch information
gpotter2 committed Jul 16, 2024
1 parent 4a852fe commit 9e461cd
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion scapy/layers/tftp.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,13 @@ def answers(self, other):
bind_layers(TFTP_OACK, TFTP_Options)


# Automatons

class TFTP_read(Automaton):
"""
TFTP automaton to read a remote file on a TFTP server.
"""

def parse_args(self, filename, server, sport=None, port=69, **kargs):
Automaton.parse_args(self, **kargs)
self.filename = filename
Expand Down Expand Up @@ -221,6 +227,10 @@ def END(self):


class TFTP_write(Automaton):
"""
TFTP automaton to write a local file onto a TFTP server.
"""

def parse_args(self, filename, data, server, sport=None, port=69, **kargs):
Automaton.parse_args(self, **kargs)
self.filename = filename
Expand Down Expand Up @@ -301,6 +311,9 @@ def END(self):


class TFTP_WRQ_server(Automaton):
"""
TFTP automaton to wait for incoming files
"""

def parse_args(self, ip=None, sport=None, *args, **kargs):
Automaton.parse_args(self, *args, **kargs)
Expand Down Expand Up @@ -378,6 +391,10 @@ def END(self):


class TFTP_RRQ_server(Automaton):
"""
TFTP automaton to serve local files
"""

def parse_args(self, store=None, joker=None, dir=None, ip=None, sport=None, serve_one=False, **kargs): # noqa: E501
Automaton.parse_args(self, **kargs)
if store is None:
Expand Down Expand Up @@ -410,7 +427,7 @@ def receive_rrq(self, pkt):
@ATMT.state()
def RECEIVED_RRQ(self, pkt):
ip = pkt[IP]
options = pkt[TFTP_Options]
options = pkt.getlayer(TFTP_Options)
self.l3 = IP(src=ip.dst, dst=ip.src) / UDP(sport=self.my_tid, dport=ip.sport) / TFTP() # noqa: E501
self.filename = pkt[TFTP_RRQ].filename.decode("utf-8", "ignore")
self.blk = 1
Expand Down

0 comments on commit 9e461cd

Please sign in to comment.