Starting Point Foothold, cannot establish http.server 80

When I run the command I get the following:

Traceback (most recent call last):
File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/usr/lib/python3.6/http/server.py", line 1211, in
test(HandlerClass=handler_class, port=args.port, bind=args.bind)
File "/usr/lib/python3.6/http/server.py", line 1185, in test
with ServerClass(server_address, HandlerClass) as httpd:
File "/usr/lib/python3.6/socketserver.py", line 456, in init
self.server_bind()
File "/usr/lib/python3.6/http/server.py", line 136, in server_bind
socketserver.TCPServer.server_bind(self)
File "/usr/lib/python3.6/socketserver.py", line 470, in server_bind
self.socket.bind(self.server_address)
OSError: [Errno 98] Address already in use

It says address already in use. I run and see:

COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
apache2 1143 root 4u IPv6 29530 0t0 TCP *:http (LISTEN)
apache2 1148 www-data 4u IPv6 29530 0t0 TCP *:http (LISTEN)
apache2 1149 www-data 4u IPv6 29530 0t0 TCP *:http (LISTEN)
apache2 1150 www-data 4u IPv6 29530 0t0 TCP *:http (LISTEN)
apache2 1154 www-data 4u IPv6 29530 0t0 TCP *:http (LISTEN)
apache2 1155 www-data 4u IPv6 29530 0t0 TCP *:http (LISTEN)
apache2 2339 www-data 4u IPv6 29530 0t0 TCP *:http (LISTEN)
apache2 2365 www-data 4u IPv6 29530 0t0 TCP *:http (LISTEN)
apache2 2366 www-data 4u IPv6 29530 0t0 TCP *:http (LISTEN)
apache2 2367 www-data 4u IPv6 29530 0t0 TCP *:http (LISTEN)
apache2 2368 www-data 4u IPv6 29530 0t0 TCP *:http (LISTEN)

What should I do to correct?

Comments

  • You already have something running on port 80. I assume you've used lsof to produce that list.

    Try net stat and p s -auxww to drill into what is running, but it looks like you've already got a webserver active (I've had to add spaces to the commands because the HTB waf is dumb)

    TazWake

    Note: https://www.nohello.com/

    Happy to help people but PLEASE explain your problem in as much detail as possible! If you say vague things like "It's not working", I cant help. This isn't Twitter so my DMs are always open.

  • Yes, I ran the lsof command for port 80. I typed the commands I ran in my post, but they were stripped out, probably because I enclosed them in chevrons and it thinks I am trying to insert a script tag or something. Anyway, what returned was included in my post. It was a bunch of Apache stuff on port 80. I don't know why all that is running. Since I am completely clueless, I have no idea why it's there, if it belongs to the HTB lab or what. I just continued with the lab, but when i ran the netcat command on port 443, it said nc was already running and that port was already in use. This was actually yesterday and I tried again today with the same results. I just started cursing and crying. Is there a way to to reset the lab? Is that even the issue?

  • Sorry, I did include the commands I ran, but they were stripped out of my post. So the command I ran from the tutorial was: sudo python3 -m http.server 80.

  • Are you running the commands on your machine or the remote machine?

    TazWake

    Note: https://www.nohello.com/

    Happy to help people but PLEASE explain your problem in as much detail as possible! If you say vague things like "It's not working", I cant help. This isn't Twitter so my DMs are always open.

  • I am running them on my VM

  • Hi, do you manage to solve it. I stuck here too, google it for more than 1 week yet can't solve it. please help! thanks

  • @mightyfei said:

    Hi, do you manage to solve it. I stuck here too, google it for more than 1 week yet can't solve it. please help! thanks

    Just to check, you are running sudo python3 -m http.server 80 and it isn't working?

    Is it generating any error messages?

    TazWake

    Note: https://www.nohello.com/

    Happy to help people but PLEASE explain your problem in as much detail as possible! If you say vague things like "It's not working", I cant help. This isn't Twitter so my DMs are always open.

  • Isnt it python3 http-server instead of http.server ? Also try to omit the port 80 and just run python3 -m http-server to run on the default port 8000

    From your paste (and i dont remember the full behavior of that module) i see only ipv6 services running.

    Also turn off the apache2 service and re-run the python server. if you still have issues, run a sudo netstat -plant to view the pid and service name, then do a ps aux and look for that pid....might give you some hints as to what is going on.

    Hack The Box

Sign In to comment.