TFTP
Posted on April 9, 2022
Tags: hacksoft
1 Summary
- tftpd is the server
- the server DOES NOT ALLOW files to be CREATED ,BUT it DOES ALLOW files to be OVERWRITTEN
- this means if you much create a file of the SAME NAME FIRST on the server
- give it full rights chmod
- then on the client tftp use
put
to “overwrite” the file on the tftpd server
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
- The DNS server dnsmasq also has a built-in READ-ONLY tftpd server meaning you can only GET/fetch files from the server not PUT/upload them.
- In openwrt you can enable this in luci >> Network >> DHCP and DNS >> PXE/TFTP
# Enable dnsmasq's built-in TFTP server
enable-tftp
# Set the root directory for files available via FTP.
tftp-root=/tftpboot
7 Openwrt atftpd
- The way to get a real-working tftp is installing
opkg install atftpd
- this creates your server file directory on
/srv/tftp
- the config is in /etc/config/atftpd
/etc/init.d/atftpd restart