0

I'm trying to download a zip file from : https://download.sysinternals.com/files/ProcessExplorer.zip (no curl and no WGET). I want to do that by netcat i used this command :

echo -e "GET
https://download.sysinternals.com/files/ProcessExplorer.zip HTTP/1.1\r\nHost: download.sysinternals.com\r\n\r\n" | nc download.sysinternals.com 80 > q.zip

The file is written on the HDD but when I try to open it its corrupted.

  • So you're trying to download a Windows tool onto a Linux system, from a remote server over HTTPS, without making use of the curl & wget tools which are written specifically to work with the HTTP protocol. I'm wondering why this whole thing is so convoluted. – Haxiel Feb 17 at 13:00
3

So, as far as I know, netcat cannot use HTTPS, but in your code you were connecting to port 80, which means HTTP, not HTTPS.

After the GET you should add the relative address, not the full one.

Something like this will work:

echo -e "GET /files/ProcessExplorer.zip HTTP/1.1\r\nHost: download.sysinternals.com\r\n\r\n" | nc download.sysinternals.com 80 > q.temp

It will not close when the transfer is finished, you'll have to close it manually.

At this point the q.temp file have also the HTTP header included, you'll have to remove it. You can check the line number where the binary content starts with:

nl q.temp | less

In this case the binary content starts at line 16, so you can remove the header with:

tail -n +16 q.temp > q.zip

And there you have your zip file!

  • It just works by pure chance, but it works. Congrats on your answer. – Rui F Ribeiro Feb 17 at 12:47
  • Cool! Mine deleted, yours upvoted. – Fabby Feb 17 at 13:35

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.