def run(self): proxy.main(loop=self.loop, verbose_level=self.verbose, ip=self.ip, port=self.port, bport=self.banned_port, special=self.special)
def test_proxy(self): mock_args = mock.MagicMock(port=8080) mock_empty = mock.MagicMock(port=False) test = list() test.append(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) test.append(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) asyncio.run(proxy.main(mock_empty, test=test)) asyncio.run(proxy.main(mock_args, test=test))
def _process(self): log.info("Starting") self.running.set() import proxy proxy.main(input_args=[]) while not self.shutdown.is_set(): time.sleep(1) sys.exit()
def engage(self, certfile=None, privfile=None): self.__clear() try: if not self.is_https: proxy.main(self.inargs, hostname=ipaddress.IPv4Address(self.ip_address), port=self.port, num_workers=1, plugins=self.plugins) else: if not certfile or not privfile: if not os.path.isfile(self.home_paths['privname']): raise FileNotFoundError( "Given private key file doesn't exists") if not os.path.isfile(self.home_paths['certname']): raise FileNotFoundError( "Given certificate file doesn't exists") else: if not os.path.isfile(certfile): raise FileNotFoundError( "Given private key file doesn't exists") if not os.path.isfile(privfile): raise FileNotFoundError( "Given certificate file doesn't exists") proxy.main(self.inargs, hostname=ipaddress.IPv4Address(self.ip_address), port=self.port, num_workers=1, ca_key_file=self.home_paths['privname'] if not privfile else privfile, ca_cert_file=self.home_paths['certname'] if not certfile else certfile, ca_signing_key_file=self.home_paths['privname'] if not privfile else privfile, plugins=self.plugins) except KeyboardInterrupt: pass if self.sysprox: self.del_sysprox()
def check(): prox = {'http': proxy.main()} www = 'https://offerup.com/search/?q=iphone#offers' r = requests.get(www, proxies=prox) soup = BS(r.content, 'lxml') item = soup.find_all('div', {'class': 'item-pic'}) item_price = soup.find_all( 'span', {'class': 'size-large-xx color-gray-darker medium'}) urls = [] sell_average = '' for x in item: url = x.find_all('a') for y in url: urls.append(y.get('href')) return urls[0]
def test_main_thread(self) -> None: with mock.patch('sys.argv') as mock_argv: mock_argv.return_value = 'proxy.py thread' self.assertEqual(proxy.main(), None)
#!/usr/bin/env python2 import sys, os, os.path as ospath # os.environ['DISABLE_GEVENT'] = '1' dir = ospath.dirname(sys.argv[0]) sys.path.insert(0, ospath.abspath(ospath.join(dir, "src.zip"))) del sys, os, ospath, dir from proxy import main main()
#!/usr/bin/env python import sys, os, os.path as ospath #os.environ['DISABLE_GEVENT'] = '1' dir = ospath.dirname(sys.argv[0]) sys.path.insert(0, ospath.abspath(ospath.join(dir, 'src.zip'))) del sys, os, ospath, dir from proxy import main main()
path_str = text_(request.path) downloaded = 0 match = re.search('(?:^|\\?|&)downloaded=(\\d+)(?:&|$)', path_str) if match: downloaded = int(match.group(1)) match = re.search('(?:^|\\?|&)uploaded=(\\d+)(?:&|$)', path_str) if match: uploaded = int(downloaded * 1.2 if downloaded > 0 else int(match.group(1)) * 1.2) path_str = path_str[:match.start(1)] + str( uploaded) + path_str[match.end(1):] request.path = bytes_(path_str) return request def handle_upstream_chunk(self, chunk: memoryview) -> memoryview: return chunk def on_upstream_connection_close(self) -> None: pass if __name__ == '__main__': proxy.main([ '--log-level', 'd', '--plugins', '__main__.TrackerRequestRewritePlugin', '--ca-key-file', '/Users/imagi/ca-key.pem', '--ca-cert-file', '/Users/imagi/ca-cert.pem', '--ca-signing-key-file', '/Users/imagi/ca-signing-key.pem' ])
def main(): proxy.main(hostname=ipaddress.IPv4Address('0.0.0.0'), port=PROXY_PORT, plugins=['indevproxy.IndevProxyPlugin'])
def main(): VERSION_FILE_NAME = os.path.dirname(__file__) + "/VERSION" with open(VERSION_FILE_NAME, "r") as fh: version = fh.read() parser = configargparse.ArgumentParser( description="obf v" + version + " - an obfuscation tool", epilog="More information/homepage: https://github.com/hossg/obf", default_config_files=['/etc/obf.conf', '~/.obf']) # command line only arguments that are relevant only for "interactive" use of the tool parser.add('--config', required=False, is_config_file=True, help='Config file path') parser.add_argument('plaintext',nargs="?", help="A plaintext to obfuscate. If no plaintext is provided, then obf " \ "will look at stdin instead.") parser.add_argument('-c', action="store_true", default=False, help="Display a crib showing the mapping of blocked " \ "values to their obfuscated values. Only works " \ "when a specific blockfile is used with the -b " \ "option.") parser.add_argument('-l', '--list-algos', action="store_true", help="List available hash algorithms.") parser.add_argument('-v', action="store_true", help="Verbose mode = show key parameters, etc") parser.add_argument('--proxy', nargs=1, help="A hostname and port to proxy for") parser.add_argument('-j','--json', nargs='?', help = "Treat the input as JSON, and apply the obfuscation rules to "\ "each of the fields/keys specified in this space-delimited list") # arguments for config file, environment variables or config file, useful for configuring the obfuscator parser.add_argument('-b', '--blockedwords', metavar='blockedwords file',nargs='?', help="A file containing specific words to block. " \ "If missing the entire input is obfuscated.") parser.add_argument('-w', metavar='codewords file', nargs='?', default=os.path.dirname(__file__) + '/' + "codewords.txt", help="A file containing code words to use. ") parser.add_argument('-n','--n_offset', type=int,default=0,nargs='?', help="An index to indicate which bytes of the generated hash " \ "to use as a lookup into the codewords file. Defaults " "to 0.") parser.add_argument('-e', nargs='?', help="A string of comma-separated domain name components that should be exempt from obfuscation"\ " to aid readability. Dots are not permitted/valid. Defaults to 'com,co,uk,org' and any that "\ "are specified on the command line are added to this list.") parser.add_argument( '-a', '--algo', nargs='?', default="SHA256", help= "The hash algorithm to use as a basis for indexing the codewords file; defaults to SHA256" ) parser.add_argument( '-s', '--salt', nargs='?', default='', help="A salt for the hash function to ensure uniqueness of encoding.") args = parser.parse_args() if args.list_algos: print(sorted(hashlib.algorithms_available)) quit() codewords_file = args.w excluded_domains = ['com', 'org', 'co', 'uk'] if (parser.parse_args().e): for i in parser.parse_args().e.split(','): excluded_domains.append(i.strip()) # Is a blockedwords file provided? blockedwords = [] if args.blockedwords: with open(args.blockedwords) as f: lines = f.read().splitlines() for line in lines: for word in line.split(): blockedwords.append(word.strip()) else: blockedwords = False o = obf.obfuscator( algo=args.algo, salt=args.salt, blockedwords=blockedwords, hash_index=args.n_offset, hash_index_length=4, codewords_file=codewords_file, codewords_hash= '25e011f81127ec5b07511850b3c153ce6939ff9b96bc889b2e66fb36782fbc0e', # TODO remove this from the constructor, as we should really be able to rely on the core package for the DEFAULT codewords hash value excluded_domains=excluded_domains) d = o.describe() # Verbose mode? if args.v: print(d) # and if so, is a crib sheet required? if (blockedwords and args.c): for entry in blockedwords: s = [] for item in entry.split(): s.append(o.encode(item)) print("{} -> {}".format(entry, ' '.join(s))) quit() # is some plaintext provided directly on the command line? if args.plaintext: print(' '.join(map(o.encode_text, args.plaintext.split()))) # else take plaintext from stdin, line at a time elif args.json: j = '' for line in sys.stdin: j = j + line # j = demjson.decode(j) # j = demjson.encode(j,compactly=False) # do our best to make the JSON valid and presentable # # print(demjson.encode(o.encode_json(j,args.json.split()),compactly=False)) j = json.loads(j) j = json.dumps( j, indent=2) # do our best to make the JSON valid and presentable j_o = o.encode_json(j, args.json.split()) print(json.dumps(j_o, indent=2)) elif args.proxy: proxy.main( ['--enable-web-server', '--plugin', 'obf.obf_reverse_proxy']) else: for line in sys.stdin: line = line[:-1] print(o.encode_text(line))
import os import shutil import proxy import subprocess if __name__ == '__main__': # if os.path.exists('repos/0x00-pl'): # shutil.rmtree('repos/0x00-pl') subprocess.Popen(['python3', '-m', 'http.server', '8080'], cwd='repos') proxy.main([ '--hostname', '::1', '--port', '8899', '--plugins', 'redirect_to_custom_server.RedirectToCustomServerPlugin2' ])
def run(self): proxy.main()
daemon.start() pid = daemon.get_pid() if not pid: print ("RAFPA starting ..." + "\t\t" + '[' + '\033[92m' + '\033[91m' + 'FAILED' + '\033[0m' + ']') else: print ("RAFPA starting ..." + "\t\t" + '[' + '\033[92m' + '\033[1m' + 'OK' + '\033[0m' + ']') elif 'restart' == operation: proxy.port = port daemon.restart() else: print "Port parameter(-p) is not using with stop|status operation" sys.exit(2) sys.exit(0) elif foreground == True and port == None: if 'start' == operation: proxy.main() else: print "foreground parameter(-f) is only used to start RAFPA service not with stop|status|restart" sys.exit(2) sys.exit(0) elif foreground == True and port != None: if 'start' == operation: proxy.port = port proxy.main() else: print "foreground parameter(-f) is only used to start RAFPA service not with stop|status|restart" sys.exit(2) sys.exit(0) else: print "usage: RAFPA start|stop|restart|status|(start -p <port_num>)" sys.exit(2)
def main(): prox = {'http': proxy.main()} www = 'https://offerup.com/search/?q=iphone#offers' r = requests.get(www) soup = BS(r.content, 'lxml') item = soup.find_all('div', {'class': 'item-pic'}) item_url = [] for x in item: a = x.find_all('a') for y in a: print('Current iphone listing: ' + y.get('href')) www = y.get('href') r = requests.get(www) soup = BS(r.content, 'lxml') item_price = soup.find_all( 'span', {'class': 'size-large-xx color-gray-darker medium'}) item_desc = soup.find_all( 'div', {'class': 'left base-size medium color-gray-darker'}) item_img = soup.find_all('li', {'class': 'flex-active-slide'}) item_desc2 = soup.find_all('div', {'class': 'pad-more'}) item_dict = { 'url': '', 'price': '', 'location': '', 'title': '', 'post_time': '', 'item_desc': '', 'sell_average': '' } item_dict['url'] = y.get('href') for z in item_price: print('Current listing price $: ' + z.text) item_dict['price'] = z.text for z in item_desc: item_title = z.find_all('h1') item_loc = z.find_all('a', {'class': 'color-gray-darker'}) item_time = z.find_all( 'div', {'class': 'pad-less-top color-text'}) for item in item_loc: print('Current listing location: ' + item.text) item_dict['location'] = item.text for title in item_title: print('Current listing title: ' + title.text) item_dict['title'] = title.text www = 'http://www.thepricegeek.com/results/' + title.text + '?country=us' r = requests.get(www) soup = BS(r.content, 'lxml') item = soup.find_all('em', {'class': 'median'}) for mean in item: print("Current listing selling price: " + mean.text.replace(' ', '')) item_dict['sell_average'] = mean.text.replace(' ', '') ##### Price Check ###### www = 'http://www.thepricegeek.com/results/' + title.text + '?country=us' r = requests.get(www) soup = BS(r.content, 'lxml') item = soup.find_all('span', {'class': 'complavgprice'}) for mean in item: print("Current listing selling price: " + mean.text.replace(' ', '')) item_dict['sell_average'] = mean.text.replace(' ', '') ##### Price Check ###### for time in item_time: print("Current listing post time: " + time.text.replace(' ', '')) item_dict['post_time'] = time.text.replace(' ', '') for z in item_desc2: item_description = z.find_all('div', {"class": 'pad-less-top-bottom'}) for desc in item_description: print("Current item description: " + desc.text + "\n" + "\n") item_dict['item_desc'] = desc.text ###################### GET OFFERUP DATA END ################################### ########### STAR CONFIG ######### it = item_dict['sell_average'].replace('$', '') if item_dict['sell_average'] != '': one_star = float(it) - (float(it) * .1) two_star = float(it) - (float(it) * .2) three_star = float(it) - (float(it) * .3) four_star = float(it) - (float(it) * .4) five_star = float(it) - (float(it) * .5) nine_star = float(it) - (float(it) * .9) else: pass # #if( item_dict['sell_average'] == '' ): # pass # #elif( float(item_dict['price'].replace(',','')) < float(item_dict['sell_average'].replace('$', '').replace(',','')) ): #float(item_dict['sell_average'].replace('$', ''))): # print 'less then sell average price' # client.api.account.messages.create( # to="+17866832638", # from_="+18333946893", # body="Less the average sell price" + '\n' +'Title - ' + item_dict['title'] + '\n' + "Price - " + item_dict['price'] + '\n' + 'Selling Price - ' + item_dict['sell_average'] + '\n' + 'Post Time - ' + item_dict['post_time'] + '\n' + 'Location - ' + item_dict['location'] + '\n' + 'Description - ' + item_dict['item_desc'] + '\n' + 'Url - ' + item_dict['url']) #else: # pass return str(item_dict).encode('utf-8')