27

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!

enter image description here

  • How many files do you want to transfer? Can you paste somewhere output of busybox --help and ls -l /bin and ls -l /usr/bin, please. – jofel Dec 04 '14 at 13:00
  • actually 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 – PRdeep Kumawat Dec 05 '14 at 05:17
  • If you want to add information the next time, please edit your question instead of adding comments. – jofel Dec 05 '14 at 10:36

8 Answers8

20

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 or socat or with bash and /dev/tcp
  • upload / download with wget or curl 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).

AdminBee
  • 22,803
jofel
  • 26,758
9

I have no ssh or ftp(or etc) on the device.

So, I do next:

  1. telnet a.b.c.d | tee telnet.log
  2. login and go to the file
  3. cat file.txt
  4. close session (I close tmux pane)
  5. clear telnet.log from trash

It should be easy to write utility to download/upload file over telnet

Anthon
  • 79,293
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.

Kaz
  • 8,273
1

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?

YoMismo
  • 4,015
1

On your PC:

ncat -l -p 3000 > file.name

On remote device:

busybox nc -w 3 <your PC IP> 3000 < file.name

MyroslavN
  • 111
0

@jofel and all others, Thank you very much for your kind assistance. I think device has a customized os installed as it recognized some specific linux commands only. netcat is not recognized by the device. However today I got success to transfer the file using tftp command. I successfully replaced desktop.jpg file with this command. What I did is, created tftp server on window system. login via telnet on device and run these commands:

download file tftp -l -p tftp -l desktop.jpg - 192.168.0.249 69

upload file tftp -l desktop.jpg -g 192.168.0.249 69

0

I have done this now by these methods:

Create ftp server (by installing solerwinds) on window system. login via telnet on device and run these commands:

To download a file:

tftp -l <FileName> -p <TFTP Server IP> <Port No of TFTP>

Example:

tftp -l desktop.jpg -p 192.168.0.249 69

or to upload file:

tftp -l <FileName> -g <TFTP Server IP> <Port No of TFTP>

Example:

tftp -l desktop.jpg -g 192.168.0.249 69

default location of tftp file is C:\TFTP-Root

HalosGhost
  • 4,790
-1

I use the following method to download small binary files via telnet into my windows box:

  1. execute hexdump -v -e '16/1 "%02x"' myfile.bin
  2. copy hex dump from screen
  3. paste hex dump into this online tool to create binary file: http://tomeko.net/online_tools/hex_to_file.php?lang=en