Search code examples
pythonwgetsimplehttpserver

Unable to download an existing file with wget and python http server


so I mounted an http server with python -m SimpleHTTPServer I get:

Serving HTTP on 0.0.0.0 port 8000 ... But when I try to download with

wget http://192.168.100.65:8000/tmp/postgres_default_pass.txt

I got:

    192.168.100.74 - - [09/Sep/2020 23:32:30] code 404, message File not found
192.168.100.74 - - [09/Sep/2020 23:32:30] "GET /tmp/postgres_default_pass.txt HTTP/1.1" 404 -

In the wget machine:

    Connecting to 192.168.100.65:8000... connected.
HTTP request sent, awaiting response... 404 File not found
2020-09-09 23:32:31 ERROR 404: File not found.

But the file exists, doing an ls I can find the file.

 ls
hsperfdata_kali
postgres_default_pass.txt
sqlmaprgl22hl623598

Solution

  • SimpleHTTPServer serves relative to its current directory. Try wget http://localhost:8000/postgres_default_pass.txt

    That being said, please do note that in python3 it has been moved into http as http.server. python2.7 is officially unsupported so it's probably a good idea to move any systems over to python3.