From 5de80f0008517878e84b4d9c2640798398fe95ed Mon Sep 17 00:00:00 2001 From: msmoshang <79931113+msmoshang@users.noreply.github.com> Date: Fri, 9 Aug 2024 17:35:03 +0800 Subject: [PATCH] Update ADD-ARL-finger.py --- ADD-ARL-finger.py | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/ADD-ARL-finger.py b/ADD-ARL-finger.py index b602542..29d142c 100644 --- a/ADD-ARL-finger.py +++ b/ADD-ARL-finger.py @@ -49,21 +49,25 @@ def upload_finger_file(file_path, url, token): "Accept": "application/json, text/plain, */*", "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36", "token": token, - "Content-Type": "multipart/form-data" } files = {'file': ('finger.json', open(file_path, 'rb'), 'application/json')} response = requests.post(upload_url, files=files, headers=headers, verify=False) if response.status_code == 200: print(f"[+] File upload success: {file_path}\nRsp: [\033[32;1m+\033[0m] {response.text}") else: - print(f"[-] Failed to upload file: {file_path}") + print(f"[-] Failed to upload file: {file_path}\nStatus Code: {response.status_code}\nResponse: {response.text}") -def main(url, token, file_path=None): - if file_path: +def main(url, token, method, file_path=None): + if method == "new": + if not file_path: + file_path = "./finger.json" upload_finger_file(file_path, url, token) - else: - with open("./finger.json", 'r', encoding="utf-8") as f: + elif method == "old": + if not file_path: + file_path = "./finger.json" + + with open(file_path, 'r', encoding="utf-8") as f: load_dict = json.loads(f.read()) body_template = "body=\"{}\"" @@ -92,31 +96,37 @@ def main(url, token, file_path=None): else: formatted_rule = template.format(finger_json['keyword'][0]) add_finger(name, formatted_rule, url, token) + else: + print("[-] Invalid method. Use 'new' or 'old'.") if __name__ == '__main__': - if len(sys.argv) == 4 or len(sys.argv) == 5: + if len(sys.argv) == 5 or len(sys.argv) == 6: login_url = sys.argv[1] login_name = sys.argv[2] login_password = sys.argv[3] - file_path = sys.argv[4] if len(sys.argv) == 5 else None + method = sys.argv[4] + file_path = sys.argv[5] if len(sys.argv) == 6 else None token = login(login_url, login_name, login_password) if token: - main(login_url, token, file_path) + main(login_url, token, method, file_path) else: print(''' usage: - python3 ARL-finger-ADD.py https://192.168.1.1:5003/ admin password 支持老形式如 - { + python3 ADD-ARL-Finger.py https://127.0.0.1:5003/ admin password old [file_path] 使用旧方式添加指纹 + 指纹文件格式 + { "cms": "致远OA", "method": "keyword", "location": "rule: body", "keyword": [ "/seeyon/USER-DATA/IMAGES/LOGIN/login.gif" ] - } - - python3 script.py https://192.168.1.1:5003/ admin password [file_path] 支持ARL导出的指纹 + } + python3 ADD-ARL-Finger.py https://127.0.0.1:5003/ admin password new [file_path] 使用新方式上传指纹文件 + 指纹文件格式为: + - name: 致远OA + rule: body="/seeyon/USER-DATA/IMAGES/LOGIN/login.gif" ''')