From af4bae183dc7d762698254ddb8d2ce61f9ef71d5 Mon Sep 17 00:00:00 2001 From: Marat Date: Tue, 4 Mar 2025 11:55:53 +0600 Subject: [PATCH] update --- roles/dots/files/home/.gitconfig | 8 +- roles/dots/files/home/bin/easy_http.py | 148 -------------------- roles/dots/files/home/bin/easy_http_bak.py | 139 ------------------ roles/dots/files/home/bin/wifi_passwords.db | Bin 12288 -> 0 bytes 4 files changed, 6 insertions(+), 289 deletions(-) delete mode 100644 roles/dots/files/home/bin/easy_http.py delete mode 100644 roles/dots/files/home/bin/easy_http_bak.py delete mode 100644 roles/dots/files/home/bin/wifi_passwords.db diff --git a/roles/dots/files/home/.gitconfig b/roles/dots/files/home/.gitconfig index d74da2b..4b73818 100644 --- a/roles/dots/files/home/.gitconfig +++ b/roles/dots/files/home/.gitconfig @@ -1,9 +1,10 @@ [user] - email = mars6358@gmail.com - name = Marat + email = mars6358@gmail.com + name = Marat [core] pager = delta + pager = less -R [interactive] diffFilter = delta --color-only @@ -17,3 +18,6 @@ [diff] colorMoved = default + +[color] + ui = always diff --git a/roles/dots/files/home/bin/easy_http.py b/roles/dots/files/home/bin/easy_http.py deleted file mode 100644 index 12fb9ba..0000000 --- a/roles/dots/files/home/bin/easy_http.py +++ /dev/null @@ -1,148 +0,0 @@ -import re -import uuid -import random -import os -import sys -import requests -import json -import pickle - -methods = { - 'POST': requests.post, - 'GET': requests.get, - 'PUT': requests.put, - 'PATCH': requests.patch, - 'DELETE': requests.delete -} - -headers = {} - -def string_to_header(s): - key, value = s.split(": ") - headers[key] = value.strip() - -def read_default_headers(default_headers_file): - if os.path.isfile(default_headers_file): - with open(default_headers_file, 'r') as file: - headers.update(json.load(file)) - -def save_cookies(requests_cookiejar, filename): - if os.path.exists(filename): - with open(filename, 'rb') as f: - try: - existing_cookies = pickle.load(f) - except EOFError: - existing_cookies = requests_cookiejar - else: - existing_cookies = requests_cookiejar - - for cookie in requests_cookiejar: - existing_cookies.set_cookie(cookie) - - with open(filename, 'wb') as f: - pickle.dump(existing_cookies, f) - -def load_cookies(filename): - try: - with open(filename, 'rb') as f: - return pickle.load(f) - except FileNotFoundError: - return None - -def set_vars(_body): - def set_to_dict(body): - for key, value in body.items(): - if isinstance(value, str): - value = value.replace('{{hex}}', uuid.uuid4().hex) - value = value.replace('{{uuid}}', str(uuid.uuid4())) - - pattern = r'\{\{uuid\[(\d+)\]\}\}' - def replace_uuid_slice(match): - slice = int(match.group(1)) - return uuid.uuid4().hex[:slice] - value = re.sub(pattern, replace_uuid_slice, value) - - body[key] = str(value) - - if isinstance(value, dict): - set_vars(value) - - if type(_body) is dict: - set_to_dict(_body) - elif type(_body) is list: - for i in _body: - set_to_dict(i) - return _body - -def send_req(method, url, body_txt): - func = methods[method] - cookie = load_cookies(session_path) - - body = json.loads(body_txt) if '{' in body_txt else {} - body = set_vars(body) - - if method == 'GET': - resp = func(url, headers=headers, params=body, cookies=cookie) - else: - resp = func(url, headers=headers, json=body, cookies=cookie) - - print(f"// status_code {'':<18} {resp.status_code}") - - for header_name, header_value in resp.headers.items(): - print(f"// {header_name:<30} {header_value}") - try: - resp_content = resp.json() - print(json.dumps(resp_content, indent=2)) - except ValueError: - print(resp.content) - - save_cookies(resp.cookies, session_path) - - -if len(sys.argv) != 3: - print("Usage: python script.py ") - sys.exit(1) - -file_path = sys.argv[1] -project_path = sys.argv[2] - -session_path = os.path.join(project_path, 'pysession') -default_headers = os.path.join(project_path, 'headers.json') - -url = '' -body_txt = "" -_body_start = False - -try: - with open(file_path) as file: - lines = file.readlines() - url = lines[0] - - for line in lines[1:]: - line = line.strip() - if not line: - continue - if (_body_start or ('{' in line or '[' in line)) and not line.startswith('#'): - _body_start = True - body_txt += line - elif line.startswith('#'): - break - elif line: - string_to_header(line.strip()) - - method, url = url.strip('\n').split(' ') -except Exception as e: - print('got error when read body/headrs') - print(e) - -try: - read_default_headers(default_headers) -except Exception as e: - print('got error when read default headrs') - print(e) - -try: - send_req(method, url, body_txt) -except Exception as e: - print('got error when send request') - print(e) diff --git a/roles/dots/files/home/bin/easy_http_bak.py b/roles/dots/files/home/bin/easy_http_bak.py deleted file mode 100644 index d2c8d00..0000000 --- a/roles/dots/files/home/bin/easy_http_bak.py +++ /dev/null @@ -1,139 +0,0 @@ -import uuid -import random -import os -import sys -import requests -import json -import pickle - -methods = { - 'POST': requests.post, - 'GET': requests.get, - 'PUT': requests.put, - 'PATCH': requests.patch -} - -headers = {} - -def string_to_header(s): - key, value = s.split(": ") - headers[key] = value.strip() - -def read_default_headers(default_headers_file): - if os.path.isfile(default_headers_file): - with open(default_headers_file, 'r') as file: - headers.update(json.load(file)) - -def save_cookies(requests_cookiejar, filename): - if os.path.exists(filename): - with open(filename, 'rb') as f: - try: - existing_cookies = pickle.load(f) - except EOFError: - existing_cookies = requests_cookiejar - else: - existing_cookies = requests_cookiejar - - for cookie in requests_cookiejar: - existing_cookies.set_cookie(cookie) - - with open(filename, 'wb') as f: - pickle.dump(existing_cookies, f) - -def load_cookies(filename): - try: - with open(filename, 'rb') as f: - return pickle.load(f) - except FileNotFoundError: - return None - -def set_vars(body): - for key, value in body.items(): - if isinstance(value, str): - value = value.replace('{{hex}}', uuid.uuid4().hex) - value = value.replace('{{uuid}}', str(uuid.uuid4())) - if ':code:' in value: - value = value.replace(':code:', '') - value = eval(f"{value}") - print(value) - - body[key] = str(value) - - if isinstance(value, dict): - set_vars(value) - - return body - -def send_req(method, url, body_txt): - func = methods[method] - cookie = load_cookies(session_path) - - body = json.loads(body_txt) if '{' in body_txt else {} - body = set_vars(body) - - if method == 'GET': - resp = func(url, headers=headers, params=body, cookies=cookie) - else: - resp = func(url, headers=headers, json=body, cookies=cookie) - - print(f"status_code {'':<18} {resp.status_code}") - - for header_name, header_value in resp.headers.items(): - print(f"{header_name:<30} {header_value}") - try: - resp_content = resp.json() - print(json.dumps(resp_content, indent=2)) - except ValueError: - print(resp.content) - - save_cookies(resp.cookies, session_path) - - -if len(sys.argv) != 3: - print("Usage: python script.py ") - sys.exit(1) - -file_path = sys.argv[1] -project_path = sys.argv[2] - -session_path = os.path.join(project_path, 'pysession') -default_headers = os.path.join(project_path, 'headers.json') - -url = '' -body_txt = "" -_body_start = False - -try: - with open(file_path) as file: - lines = file.readlines() - url = lines[0] - - for line in lines[1:]: - line = line.strip() - if not line: - continue - if (_body_start or '{' in line) and not line.startswith('#'): - _body_start = True - body_txt += line - elif line.startswith('#'): - break - elif line: - string_to_header(line.strip()) - - method, url = url.strip('\n').split(' ') -except Exception as e: - print('got error when read body/headrs') - print(e) - -try: - read_default_headers(default_headers) -except Exception as e: - print('got error when read default headrs') - print(e) - -try: - send_req(method, url, body_txt) -except Exception as e: - print('got error when send request') - print(e) - diff --git a/roles/dots/files/home/bin/wifi_passwords.db b/roles/dots/files/home/bin/wifi_passwords.db deleted file mode 100644 index 70032f8825b6f4ff736b4b9c370f3cbc11143730..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12288 zcmeI%ze~eF6bJBki9~H_&w!BimVyBhOsR{DsRR)#YLdZD;Yt$-^oMOC6}SFf{vrMk zF0Q(H2?PuXT~)ph-X-r|!jaE*m*8%Y=CMfT%c;yom-dJ;IunA3xJq4R6-?c1RfW11 z^`_u-^t@>C57M|p+~F^qUO*oL5P$##AOHafKmY;|fB*y_@H+(72HUo5o2@T$Ihw?) zG)bcenPsc_a-7vG?cDd=&=aBCA9$kPYlt7?pnPg3r?CjV`%v8am)EX86j$ExP*ls5 zE&Eh6tQ(tAIvdAN*