TFTP

Posted on April 9, 2022
Tags: hacksoft

1 Summary

2 Server

apt-get install xinetd tftpd

2.1 step 1

touch /etc/inetd.d/tftp
# default: off
# description: The tftp server serves files using the Trivial File Transfer \
#    Protocol.  The tftp protocol is often used to boot diskless \
#    workstations, download configuration files to network-aware printers, \
#    and to start the installation process for some operating systems.
service tftp
{
   protocol = udp
   port = 69
   socket_type = dgram
   wait = yes
   user = nobody
   server = /usr/sbin/in.tftpd
   server_args = /tftpboot -s
   disable = no
}

3 step 2

nano /etc/inetd.conf
#tftp   dgram   udp     wait    root    /usr/sbin/tcpd  /usr/sbin/in.tftpd
tftp   dgram   udp   wait   root   /usr/sbin/tcpd  /usr/sbin/in.tftpd -s /tftpboot

4 step 3

mkdir /tftpboot
sudo chmod 777 /tftpboot
sudo chown -R nobody /tftpboot
service restart inetd

put your files to send and recv in /tftpboot

cd /tftpboot
touch somefile
sudo chmod 777 somefile #important

5 Client

sudo apt install tftp
tftp
#starts tftp shell
tftp> get somefile #downloads /tftpboot/somefile from the tftpd server
tftp> put otherfile #overwrites /tftpboot/otherfile with otherfile in current directory of this client

some tftp binaries are trimmed down, to run tftp without entering the shell you can do something like
(echo put somefile) | tftp 192.168.1.243

6 dnsmasq READ-ONLY tftpd server

# Enable dnsmasq's built-in TFTP server
enable-tftp

# Set the root directory for files available via FTP.
tftp-root=/tftpboot

7 Openwrt atftpd