14

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 4 '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 5 '14 at 5:17
  • If you want to add information the next time, please edit your question instead of adding comments. – jofel Dec 5 '14 at 10:36
12

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 is wrong and you can stop it with Ctrl+C

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).

  • I 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. – PRdeep Kumawat Dec 4 '14 at 12:49
  • Probably your device does not have a ssh or ftp server running. – jofel Dec 4 '14 at 12:50
  • Well I don't know that.. Is there any other way to get/upload files from that device? – PRdeep Kumawat Dec 4 '14 at 12:53
  • You can also use sz to send the files through the terminal. You'll need it on both sides. – slm Dec 4 '14 at 13:11
  • @PRdeepKumawat I extended the answer with an example. – jofel Dec 5 '14 at 10:33
5

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

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?

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

0

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.

-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
  • Not sure about your link in #3! – user88036 Sep 15 '18 at 8:24
  • 3
    @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. – RalfFriedl Sep 15 '18 at 14:46
  • Thanks @RalfFriedl. I edited my answer for clarification. – Igor Zelaya Sep 17 '18 at 0:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.