def make_requests_url(HostList, min_url, new_headers, bool_https, tag, old_data_request=None): new_url = set_url_sipoint(HostList, min_url, tag) http_string = 'http{}://'.format('s' if bool_https else '') if not new_url.count(http_string): new_url = http_string + new_url prstd('Proxy Request HTTP(s) in make_requests_url using URL: {}'.format( new_url)) new_data_request = None if old_data_request: new_data_request = {} for (key, value) in old_data_request.items(): new_data_request[key] = set_url_sipoint( HostList, value, 'import DATA on: {}'.format( tag)) if type(value) is str else value prstd('Proxy Request HTTP(s) in make_requests_url using JSON-DATA: {}'. format(str(new_data_request))) return requests.post(new_url, headers=new_headers, verify=False, data=new_data_request, allow_redirects=False) else: return requests.get(new_url, headers=new_headers, verify=False, allow_redirects=False)
def callme_after_every_response(response): request_response = """ ****************************************** After request id: {g_id} Response: {response} """ if not request.host == 'logs.samael.proxy.ka': prstd(request_response.format(g_id=g.id, response=str(response))) return response
def callme_before_every_request(): g.id = str(random.randint(0, 9)) for i in range(8): g.id += str(random.randint(0, 9)) request_detail = """ ****************************************** Before Request id: {g_id} Before URL: {url} Before Methods: {methods} Before Headers: {headers} """ if not request.host == 'logs.samael.proxy.ka': prstd( request_detail.format(g_id=g.id, url=request.url, methods=request.method, headers=str(request.headers)[:-4]))
def root(): if not request.host == 'logs.samael.proxy.ka': prstd('route root request.host: {}'.format(request.host)) if not request.host == 'logs.samael.proxy.ka': prstd('route root request.url: {}'.format(request.url)) if not request.host == 'logs.samael.proxy.ka': prstd('route root request.method: {}'.format(request.method)) if request.host == 'main.samael.proxy.ka': return send_from_directory('static', 'Assassin.jpg') elif request.host == 'root.samael.proxy.ka': return send_from_directory('static', 'root.samael.pem', as_attachment=True) elif request.host == 'logs.samael.proxy.ka': return send_from_directory('static', 'HackLogs.txt') elif request.host == 'deep.samael.proxy.ka': return '<br>'.join(HostLista.join_content()) else: return proxy.route(request, HostLista) # FOR: GET , POST
def path(default): prstd('route path request.host: {}'.format(request.host)) prstd('route path request.url: {}'.format(request.url)) prstd('route path request.method: {}'.format(request.method)) return proxy.route(request, HostLista)
from forall import array_methods, prstd, HostList, proxy_domain, filter_point, filter_minus from flask import Flask, request, send_from_directory, g import random, proxy, threading, time # -------------------------------------------------------- HostLista = HostList([], [], True) app = Flask(__name__, static_folder=None) prstd('', True) prstd('') prstd('main check for domain : {} '.format(proxy_domain)) prstd('main check for regex point : {}'.format(filter_point)) prstd('main check for regex minus : {}'.format(filter_minus)) # -------------------------------------------------------- @app.route('/', methods=array_methods) def root(): if not request.host == 'logs.samael.proxy.ka': prstd('route root request.host: {}'.format(request.host)) if not request.host == 'logs.samael.proxy.ka': prstd('route root request.url: {}'.format(request.url)) if not request.host == 'logs.samael.proxy.ka': prstd('route root request.method: {}'.format(request.method)) if request.host == 'main.samael.proxy.ka': return send_from_directory('static', 'Assassin.jpg') elif request.host == 'root.samael.proxy.ka': return send_from_directory('static',
def set_url_nopoint(HostList, content, tag): for domain in regxMatch(content): prstd('proxy route set_url_nopoint find? cont/point: {} on: {} => ???'. format(domain, tag)) if not domain in HostList.join_content(): prstd( 'proxy route set_url_nopoint using cont/point: {} on: {} => no.' .format(domain, tag)) if not HostList.automatic: continue if not domain.count('.'): HostList.content += [domain] prstd( 'proxy route set_url_nopoint using content: {} on: {} => added.' .format(domain, tag)) if domain.count('.'): HostList.nopoint[domain] = HostList.nopoints(domain) prstd( 'proxy route set_url_nopoint using nopoint: {} on: {} => added.' .format(HostList.nopoint[domain], tag)) elif domain in HostList.nopoint: prstd( 'proxy route set_url_nopoint using nopoint: {} on: {} => si. ' .format(HostList.nopoint[domain], tag)) else: prstd( 'proxy route set_url_nopoint using content: {} on: {} => si. ' .format(domain, tag)) # -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- for host in HostList.join_content(): if host in HostList.content: if content.count(host + '/'): prstd( 'proxy route set_url_nopoint pure url for host: {} on: {}'. format(host, tag)) while content.count(host + '/'): content = content.replace(host, host + proxy_domain) prstd( 'proxy route set_url_nopoint + samael for host: {} on: {}'. format(host + proxy_domain, tag)) elif host in HostList.nopoint: if content.count(host): prstd( 'proxy route set_url_nopoint pure url for host: {} on: {}'. format(host, tag)) prstd( 'proxy route set_url_nopoint si minus for host: {} on: {}'. format(HostList.nopoint[host], tag)) while content.count(host): content = content.replace( host, HostList.nopoint[host] + proxy_domain) prstd( 'proxy route set_url_nopoint + samael for host: {} on: {}'. format(HostList.nopoint[host] + proxy_domain, tag)) return content
def set_url_sipoint(HostList, content, tag): for minus in regxMatch(content, False): prstd('proxy route set_url_sipoint for original: {} on: {}'.format( minus, tag)) while minus.count(proxy_domain): minus = minus.replace(proxy_domain, '') while content.count(proxy_domain): content = content.replace(proxy_domain, '') prstd('proxy route set_url_sipoint for - samael: {} on: {}'.format( minus, tag)) if minus.count('-'): if HostList.automatic: while content.count(minus): content = content.replace( minus, HostList.auto_sipoint(minus, tag)) prstd('proxy route set_url_sipoint for rm - done: {} on: {}'. format(HostList.auto_sipoint(minus, tag), tag)) elif not HostList.automatic and minus in HostList.invr_nopoint(): while content.count(minus): content = content.replace(minus, HostList.invr_nopoint()[minus]) prstd('proxy route set_url_sipoint for get invr: {} on: {}'. format(HostList.invr_nopoint()[minus], tag)) # -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- for minus in HostList.invr_nopoint(): if content.count(minus): prstd( 'proxy route set_url_sipoint in no minus for minus set: {} on: {}' .format(minus, tag)) while content.count(minus): content = content.replace(minus, HostList.invr_nopoint()[minus]) prstd( 'proxy route set_url_sipoint in no minus for point-mod: {} on: {}' .format(HostList.invr_nopoint()[minus], tag)) return content
def request_method(method, data_request=None): prstd('proxy route start {}'.format(method)) # ------------------------------------------------------------------------------------- new_headers_request = {} for (key, value) in request.headers.items(): new_headers_request[key] = set_url_sipoint( HostList, value, 'HEADERS {} REQUEST'.format( method)) if type(value) is str else value # The follow instructions make python proxy free to return the code with its encryption code new_headers_request['Accept'] = '*' new_headers_request['Accept-Language'] = '*' new_headers_request['Accept-Encoding'] = '*' prstd('Proxy Request HTTP(s) headers {} Dict: {}'.format( method, str(new_headers_request))) # ------------------------------------------------------------------------------------- if not url.count('https://'): new_headers_request['Upgrade-Insecure-Requests'] = '1' prstd('proxy Request continue {} for HTTP '.format(method)) else: prstd('proxy Request continue {} for HTTPS'.format(method)) response = make_requests_url( HostList, str(url), new_headers_request, True if url.count('https://') else False, 'MAKE {} REQUEST'.format(method), data_request) # response will return a complex class # ------------------------------------------------------------------------------------- new_headers_response = {} for (key, value) in response.headers.items(): if key.lower() not in excluded_headers_response: new_headers_response[key] = set_url_nopoint( HostList, value, 'HEADERS {} RESPONSE'.format( method)) if type(value) is str else value # ------------------------------------------------------------------------------------- response_content = response.content # fixing Response has not set Attribute prstd('Proxy Response HTTP(s) {} Content-Type: {}'.format( method, new_headers_response['Content-Type'])) if 'Content-Type' in new_headers_response: foundType = False if 'javascript' in new_headers_response['Content-Type']: foundType = True elif 'html' in new_headers_response['Content-Type']: foundType = True elif 'text' in new_headers_response['Content-Type']: foundType = True elif 'json' in new_headers_response['Content-Type']: foundType = True if foundType: response_content = set_url_nopoint(HostList, str(response.text), 'RESPONSE') if foundType: prstd('Proxy Response HTTP(s) {} Text: {}'.format( method, response_content[:-2])) # ------------------------------------------------------------------------------------- new_headers_response['Accept-Ranges'] = '*' new_headers_response["Access-Control-Allow-Origin"] = "*" new_headers_response[ "Access-Control-Allow-Credentials"] = "false" # Credential is not supported if the CORS header 'Access-Control-Allow-Origin' is '*' new_headers_response[ "Access-Control-Allow-Methods"] = "*" # like to put: ', '.join ( array_methods ) new_headers_response[ "Access-Control-Allow-Headers"] = "*" # Accept, Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization new_headers_response[ "Content-Security-Policy"] = police.csp # Disable CSP on response headers ( Content-Security-Policy ) new_headers_response[ "Strict-Transport-Security"] = 'max-age=0' # Strict-Transport-Security: The connection to the site is untrustworthy # ------------------------------------------------------------------------------------- prstd('Proxy Response HTTP(s) Status {} Code: {}'.format( method, response.status_code)) prstd('Proxy Response HTTP(s) headers {} Dict: {}'.format( method, str(new_headers_response))) # ------------------------------------------------------------------------------------- return Response(response_content, response.status_code, new_headers_response)