Downloading and uploading files via telnet session
Solution 1
This depends which tools are installed on the client device / supported by the kernel.
Possible methods for file transfer (unordered):
- ssh / sftp
- encoding binary files into displayable format with base64/uuencode and then copy from/into your telnet terminal window.
- over a simple tcp connection with
netcat
orsocat
or withbash
and /dev/tcp - upload / download with
wget
orcurl
from a web server - ftp server with a command line ftp client
- samba or nfs mount
Read Simple file transfer and How to get file to a host when all you have is a serial console? for more possibilites.
Copy desktop.jpg
from the device to your pc with the netcat/nc method:
On your pc, disable temporarily (or reconfigure if possible) any firewall and run
netcat -l -p 10000 > desktop.jpg
and on the device
busybox nc A.B.C.D -p 10000 < desktop.jpg
where you need to replace A.B.C.D with the IP address of your pc. As soon as the transfer was successful, the netcat process on your pc should stop automatically. If not, something could have gone wrong and you can stop it with Ctrl+C (compare source and destination checksums to verify).
For the other direction, just exchange <
and >
on both sides. Make first a backup of the original desktop.jpg
(cp desktop.jpg desktop_orig.jpg
).
Solution 2
I have no ssh or ftp(or etc) on the device.
So, I do next:
telnet a.b.c.d | tee telnet.log
- login and go to the file
cat file.txt
- close session (I close tmux pane)
- clear
telnet.log
from trash
It should be easy to write utility to download/upload file over telnet
Solution 3
I just uploaded a ~7 Kb firmware file to a BusyBox based Linux embedded system over the serial port.
No networking, no file transfer utilities; no Base64 utils or anything remotely useful on the device.
On the host, I trivially encoded a firmware into the following format; a kind of hex-dump consisting of shell literals combined with printf
commands:
printf "\xDE\xAD\xBE\xEF\x...\xF0"
printf "\xCA\xFE\x33\xE1\x...\xD3"
basically shell printf
commands with \x
escape sequences that printf
interprets. On the device I did:
device $ cat > firmware.sh
then used the minicom
's ASCII file send (Ctrl-AS) to send this file to the host. I could just have used copy and paste, since the amount of data is small.
Then, marked executable and ran the printf
script:
device $ chmod a+x firmware.sh
device $ ./firmware.sh > firmware.bin
Checked using BusyBox's md5sum
that the firmware.bin
checksum on the device matches the original firmware image on the host.
P.S. The shell double quote syntax passes through \x
verbatim because it's not a recognized escape sequence; hence we don't have to double up the backslashes.
Solution 4
Try with rcp
command.
Use man rcp
for more information in case you want to automate transfers.
By the way, you do know this is very insecure, right?
Solution 5
On your PC:
ncat -l -p 3000 > file.name
On remote device:
busybox nc -w 3 <your PC IP> 3000 < file.name
Related videos on Youtube
PRdeep Kumawat
Updated on September 18, 2022Comments
-
PRdeep Kumawat over 1 year
I have an attendance device running
Linux OS
. I can connect this device via telnet session. There are some files in the device that I would like to download and upload with new files. How can I do that? I have very low knowledge on Linux OS. Would you please help!-
Admin over 9 yearsHow many files do you want to transfer? Can you paste somewhere output of
busybox --help
andls -l /bin
andls -l /usr/bin
, please. -
Admin over 9 yearsactually I wanna change desktop background of this attendance device, and want to upload our company logo there in the device. Such options is not available in device menu (I already asked for this option to vendor). So I connected it via telnet session and found desktop.jpg and other image files in the device. Now I want to get these file on My local system. and after verifying the same I will upload my desirable images in the device. So it will update device image according to my desirable images. I want to change at least desktop image which is available in the device at /mnt/mtdblock/image
-
Admin over 9 yearsIf you want to add information the next time, please edit your question instead of adding comments.
-
-
PRdeep Kumawat over 9 yearsI tried WinSCP utility and tried to connect the device using ftp/sftp/scp protocol. but it is not getting connected. I am able to connect the device via telnet command and able to see the files that I want to get and upload again into device.
-
YoloTats.com over 9 yearsProbably your device does not have a ssh or ftp server running.
-
PRdeep Kumawat over 9 yearsWell I don't know that.. Is there any other way to get/upload files from that device?
-
slm over 9 yearsYou can also use
sz
to send the files through the terminal. You'll need it on both sides. -
YoloTats.com over 9 years@PRdeepKumawat I extended the answer with an example.
-
Admin over 5 yearsNot sure about your link in #3!
-
RalfFriedl over 5 years@Goro The link in this case is not an explanation that can be quoted, it is an online tool that is essential for the answer. It would be better to have a local program for that task.
-
Igor Zelaya over 5 yearsThanks @RalfFriedl. I edited my answer for clarification.
-
Alexandre Schmidt almost 3 yearsOn the device side, I had to remove
-p
from the command line for it to work:busybox nc A.B.C.D 10000 < desktop.jpg
.