-
Notifications
You must be signed in to change notification settings - Fork 75
/
Copy pathARL-Finger-ADD.py
133 lines (107 loc) · 4.39 KB
/
ARL-Finger-ADD.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/usr/bin/ python
# -*- coding:utf-8 -*-
"""
-------------------------------------------------
Author: loecho
Datetime: 2021-07-23 12:47
ProjectName: getFinger.py
Blog: https://loecho.me
Email: [email protected]
-------------------------------------------------
"""
import sys
import json
import requests
requests.packages.urllib3.disable_warnings()
'''
-----ARL支持字段:-------
body = " "
title = ""
header = ""
icon_hash = ""
'''
def main(url, token):
f = open("./finger.json",'r', encoding="utf-8")
content =f.read()
load_dict = json.loads(content)
#dump_dict = json.dump(f)
body = "body=\"{}\""
title = "title=\"{}\""
hash = "icon_hash=\"{}\""
for i in load_dict['fingerprint']:
finger_json = json.loads(json.dumps(i))
if finger_json['method'] == "keyword" and finger_json['location'] == "body":
name = finger_json['cms']
if len(finger_json['keyword']) > 0:
for rule in finger_json['keyword']:
rule = body.format(rule)
else:
rule = body.format(finger_json['keyword'][0])
add_Finger(name, rule, url, token)
elif finger_json['method'] == "keyword" and finger_json['location'] == "title":
name = finger_json['cms']
if len(finger_json['keyword']) > 0:
for rule in finger_json['keyword']:
rule = title.format(rule)
else:
rule = title.format(finger_json['keyword'][0])
add_Finger(name, rule, url, token)
else:
name = finger_json['cms']
if len(finger_json['keyword']) > 0:
for rule in finger_json['keyword']:
rule = hash.format(rule)
else:
rule = hash.format(finger_json['keyword'][0])
add_Finger(name, rule, url, token)
def add_Finger(name, rule, url, token):
headers = {
"Accept": "application/json, text/plain, */*",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36",
"Connection": "close",
"Token": "{}".format(token),
"Accept-Encoding": "gzip, deflate",
"Accept-Language": "zh-CN,zh;q=0.9",
"Content-Type": "application/json; charset=UTF-8"
}
url = "{}/api/fingerprint/".format(url)
data = {"name" : name,"human_rule": rule}
data_json = json.dumps(data)
try:
response = requests.post(url, data=data_json, headers=headers, verify=False)
if response.status_code == 200:
print(''' Add: [\033[32;1m+\033[0m] {}\n Rsp: [\033[32;1m+\033[0m] {}'''.format(data_json, response.text))
except Exception as e:
print(e)
def test(name,rule):
return print("name: {}, rule: {}".format(name, rule))
if __name__ == '__main__':
try:
if 1 < len(sys.argv) < 5 :
login_url = sys.argv[1]
login_name = sys.argv[2]
login_password = sys.argv[3]
# login
str_data = {"username": login_name, "password": login_password}
login_data = json.dumps(str_data)
login_res = requests.post(url="{}api/user/login".format(login_url), headers={
"Accept": "application/json, text/plain, */*",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36",
"Content-Type": "application/json; charset=UTF-8"}, data=login_data, verify=False)
# 判断是否登陆成功:
if "401" not in login_res.text:
#print(type(login_res.text))
token = json.loads(login_res.text)['data']['token']
print("[+] Login Success!!")
# main
main(login_url,token)
else:
print("[-] login Failure! ")
else:
print('''
usage:
python3 ARl-Finger-ADD.py https://192.168.1.1:5003/ admin password
by loecho
''')
except Exception as a:
print(a)