def main(): from ui import Image USER_APPS = 0 SYSTEM_APPS = 1 UIImage = ObjCClass('UIImage') allApps = defaultWorkspace.applicationsOfType_(USER_APPS) for i, app in enumerate(allApps): #print('hidden' in str(app.appTags())) console.write_link( '{} : {}, version {}. By {}'.format(app.bundleIdentifier(), app.localizedName(), app.shortVersionString(), app.vendorName()), 'pythonista://{}?action=run&argv={}'.format( __file__.rsplit('/Pythonista3/Documents/')[-1], app.bundleIdentifier())) Image.from_data( uiimage_to_png( UIImage._applicationIconImageForBundleIdentifier_format_scale_( app.bundleIdentifier(), 1, 100))).show() print('\n')
def print_session(): print sys.stdout.write("///Regulatory Scan Initiated") sys.stdout.write(" " * (21 - (len(args.level) + 8))) sys.stdout.write("..: %s :..\n" % args.level.upper()) time.sleep(0.5) loads = ["Initializing Scan"] for _ in loads: loading(0.001, bmsg="..: %s :.. " % _, percent=True, length=28 - (len(_)), asyn=" ..: %s :..") time.sleep(0.1) scanid = str(stattrack.scanid) while len(scanid) < 3: scanid = "0" + scanid print "..: Scan Identification :.." + (" " * 11) + "..: %s :.." % scanid getauth() print "..: Security Auth :.." + (" " * 14) + "..: %s :.." % secauth nl = netaddr.localhost print "..: Local Address" + (" " * (24 - len(nl))) + "..: " + nl + " :.." time.sleep(2) if "--hd" not in sys.argv: if sys.platform == "ios": print "..: Donate :..", " " * 20, sys.stdout.write("..: ") console.write_link("PayPal", "https://paypal.me/russianotter") sys.stdout.write(" :..") print else: print "..: Donate :..", " " * 3, "https://paypal.me/russianotter" print "_" * 6, "_" * 41
def main(): now = datetime.datetime.now() ymd = now.strftime('%Y-%m-%d') doc_path = os.path.expanduser('~/Documents') os.chdir(doc_path) backup_path = os.path.join(doc_path, 'Backup-'+ymd+'.zip') if os.path.exists(backup_path): os.remove(backup_path) print('Creating backup archive...') shutil.make_archive(os.path.join(tempfile.gettempdir(), 'Backup-'+ymd), 'zip') shutil.move(os.path.join(tempfile.gettempdir(), 'Backup-'+ymd+'.zip'), backup_path) print('Backup archive created, starting HTTP server...\n') local_url = 'http://localhost:{}/Backup-{}.zip'.format(PORT, ymd) wifi_url = 'http://%s:%i/Backup-%s.zip' % (get_ip_address(), PORT, ymd) server = HTTPServer(('', PORT), SimpleHTTPRequestHandler) console.clear() print('You can tap the following link to open the backup Zip archive in Safari (from where you can transfer it to other apps on this device):') console.write_link(local_url + '\n', 'safari-' + local_url) print('\nIf you want to transfer the backup to another device in your local WiFi network, enter the following URL in a web browser on the other device:') print(wifi_url) print('\n====\nTap the stop button in the editor or console when you\'re done.') try: server.serve_forever() except KeyboardInterrupt: server.shutdown() server.socket.close() print('Server stopped')
def cpoint(loc=""): loc = loc.replace("./", "") while 1: console.write_link("msf", "") if loc == "": sys.stdout.write(" ") else: loco = loc.split("/") sys.stdout.write(" %s(" % (loco[0])) console.set_color(1, 0, 0) sys.stdout.write("%s" % (loco[1])) console.set_color(1, 1, 1) sys.stdout.write(") ") try: data = raw_input("> ") except: print data = "" pass if data == "clear": console.clear() if data.startswith("use ") and len(data) > 4: data = data[4:] if data in sets: try: cpoint(fdir(sets[data])) except: pass else: try: cpoint(fdir(data)) except: pass if data == "back": break if data == "exit": exit() if data == "banner": unilogo() meta_help(data, loc) if data.startswith("size ") and len(data) > 4: data = data[4:] try: console.set_font("Menlo", int(data)) except: pass if data == "size": console.set_font("Menlo", 9.5) if data.startswith("remove ") and len(data) > 6: data = data[7:] try: if data in sets: t = data + " => " + sets.get(data) sets.pop(data) var.remove(t) print "Removed Values For \"%s\"" % data except Exception as e: print e pass
def backup(path=backpath, dst=dstpath): now = datetime.datetime.now() ymd = now.strftime('%Y-%m-%d') number = 1 if not os.path.exists(dstpath): os.makedirs(dstpath) while True: basename = 'Backup' + ymd + '_' + str(number) + '.zip' zipFilename = os.path.join(dst + basename) if not os.path.exists(zipFilename): break number += 1 a, b = 0, 0 for f in os.listdir(path): if os.path.isdir(path + f): a += 1 else: b += 1 dispath = path.replace(os.path.expanduser('~'), '~') console.alert('备份{}'.format(dispath), '{}个文件夹和{}个文件,可能需要几秒钟'.format(a, b), '确定') backupzip = zipfile.ZipFile(zipFilename, 'w') n = 1 for foldername, subfolders, filenames in os.walk(path): #console.hud_alert('备份第{}个文件夹'.format(n), '1') if Trashpath in foldername and EXCLUDE_Trash: continue #print('备份第{}个子文件夹:{}'.format(n,foldername.replace(os.path.expanduser('~'),'~'))+'\n') backupzip.write(foldername) n += 1 for filename in filenames: if filename.startswith('Backup') and filename.endswith('.zip'): continue backupzip.write(os.path.join(foldername, filename)) backupzip.close() console.hud_alert('备份完成!开始进行HTTP服务器部署...', '3') os.chdir(dstpath) local_url = 'http://localhost:{}/{}'.format(PORT, os.path.basename(zipFilename)) wifi_url = 'http://{}:{}/{}'.format(get_ip_address(), PORT, os.path.basename(zipFilename)) server = HTTPServer(('', PORT), SimpleHTTPRequestHandler) console.clear() print('① 点击下面链接选择在Safari打开备份文件,再分享到其他App:') console.set_color(0, 0, 1) console.write_link(local_url + '\n', 'safari-' + local_url) console.set_color(1, 1, 1) print('\n② 如果想在局域网中其他设备访问该备份,请在其他设备中输入以下链接:') print(wifi_url) print('\n====\n完成分享后请在 console 中点停止.') try: server.serve_forever() except KeyboardInterrupt: server.shutdown() server.socket.close() print('服务器终止')
def print_pragma_help_links(self): rec = _pragmas.copy() for k , v in rec.items(): link = k if k in _web_help_link_adjustments.keys(): link = _web_help_link_adjustments[k] console.write_link(k, _web_help_link.format(link)) if v: print ' -({0})'.format(pragma_messages[v]) print '\n'
def print_pragma_help_links(self): rec = _pragmas.copy() for k, v in rec.items(): link = k if k in _web_help_link_adjustments.keys(): link = _web_help_link_adjustments[k] console.write_link(k, _web_help_link.format(link)) if v: print(' -({0})'.format(pragma_messages[v])) print('\n')
def print_session(): print sys.stdout.write("///Regulatory Scan Initiated") sys.stdout.write(" " * (21 - (len(args.level) + 8))) sys.stdout.write("..: %s :..\n" % args.level.upper()) time.sleep(0.5) loads = ["Initializing Scan"] for _ in loads: loading(0.001, bmsg="..: %s :.. " % _, percent=True, length=28 - (len(_)), asyn=" ..: %s :..") time.sleep(0.1) scanid = str(stattrack.scanid) while len(scanid) < 3: scanid = "0" + scanid print "..: Scan Identification :.." + (" " * 11) + "..: %s :.." % scanid getauth() print "..: Security Auth :.." + (" " * 14) + "..: %s :.." % secauth nl = netaddr.localhost print "..: Local Address :.." + (" " * (20 - len(nl))) + "..: " + nl + " :.." if args.verbose: avde = len(os.listdir(tracking.mdir)) - 1 minpd = 24.0 * 60.0 Spd = minpd / args.rate spd = (((Spd * 66.0) / 1000.0) / 1000.0) * avde sph = (spd / 24.0) * 1000.0 spd = eval(str(spd)[:6]) sph = eval(str(sph)[:6]) Spd = int(Spd) Spd = eval(str(Spd)[:6]) if spd <= 0.0: spd = "N/A" sph = "N/A" print "..: Scans Per Day :.." + ( " " * (20 - len(str(Spd)))) + "..: " + str(Spd) + " :.." print "..: Storage Per Day :.." + ( " " * (15 - len(str(spd)))) + "..: " + str(spd) + " MB :.." print "..: Storage Per Hour :.." + ( " " * (14 - len(str(sph)))) + "..: " + str(sph) + " KB :.." time.sleep(2) time.sleep(3) if "--hd" not in sys.argv: if sys.platform == "ios": print "..: Donate :..", " " * 20, sys.stdout.write("..: ") console.write_link("PayPal", "https://paypal.me/russianotter") sys.stdout.write(" :..") print else: print "..: Donate :..", " " * 3, "https://paypal.me/russianotter" print "_" * 6, "_" * 41
def write_filename(path): if path.startswith(u"<") and path.endswith(u">"): print(path, end=u"") else: short_path = path for prefix in REMOVE_PREFIXES: if short_path.startswith(prefix): short_path = path[len(prefix):] break console.write_link(short_path, (u"pythonista3://" if os.path.basename(sys.executable) == "Pythonista3" else u"pythonista://") + quote(os.path.relpath(path, DOCUMENTS)))
def write_filename(path, lineno): if path.startswith(u"<") and path.endswith(u">"): print(path, end=u"") else: short_path = path for prefix in REMOVE_PREFIXES: if short_path.startswith(prefix): short_path = path[len(prefix):] break console.write_link( short_path, (u"pythonista3://" if os.path.basename( sys.executable) == "Pythonista3" else u"pythonista://") + u"?exec=import editor;%20editor.open_file('{p}', new_tab %3D True); editor.annotate_line({l})" .format(p=os.path.realpath(path), l=lineno).replace( ' ', '%20'))
def run(): import ctypes import datetime import errno import io import objc_util import os import shutil import sys try: unicode except NameError: unicode = str print(u"Enabling fault handler and Objective-C exception handler...") LOGDIR = os.path.expanduser(u"~/Documents/faultlog") LOGNAME_TEMPLATE = u"faultlog-{:%Y-%m-%d-%H-%M-%S}.txt" LOGNAME_DEFAULT = u"faultlog-temp.txt" EXCEPTIONLOGNAME_DEFAULT = u"exceptionlog-temp.txt" # Create the faultlog directory if necessary try: os.mkdir(LOGDIR) except (IOError, OSError) as err: if err.errno != errno.EEXIST: raise # Check whether an Objective-C exception log exists and append it to the fault log try: fin = io.open(os.path.join(LOGDIR, EXCEPTIONLOGNAME_DEFAULT), "rb") except (IOError, OSError) as err: if err.errno != errno.ENOENT: raise else: with fin: data = fin.read() if data: with io.open(os.path.join(LOGDIR, LOGNAME_DEFAULT), "ab") as fout: # If the faultlog is not empty, add a separator if fout.tell() != 0: fout.write(b"\n" + b"-"*72 + b"\n\n") fout.write(data) os.remove(os.path.join(LOGDIR, EXCEPTIONLOGNAME_DEFAULT)) # Check whether a faultlog was written did_fault = False try: f = io.open(os.path.join(LOGDIR, LOGNAME_DEFAULT), "rb") except (IOError, OSError) as err: if err.errno != errno.ENOENT: raise else: with f: if f.read(1): did_fault = True # Notify the user that a crash has happened if did_fault: import console try: from urllib.parse import quote except ImportError: from urllib import quote print(u"Pythonista quit abnormally last time.", file=sys.stderr) default_path = os.path.join(LOGDIR, LOGNAME_DEFAULT) stamped_name = LOGNAME_TEMPLATE.format(datetime.datetime.fromtimestamp(os.stat(default_path).st_mtime)) stamped_path = os.path.join(LOGDIR, stamped_name) shutil.move(default_path, stamped_path) print(u"For details, see the following log file: ", file=sys.stderr, end=u"") console.write_link(stamped_name, "file://" + quote(stamped_path)) print(file=sys.stderr) if sys.version_info < (3,): print(u"Setting exception handler.") # Set the Objective-C exception handler only under Python 2. # Otherwise under Pythonista 3 it would be set twice - once by Python 2 and once by Python 3. # This way the exception handler is set exactly once and works under Pythonista 2 and 3. # typedef void (*objc_uncaught_exception_handler)(id exception); objc_uncaught_exception_handler = ctypes.CFUNCTYPE(None, ctypes.c_void_p) # objc_uncaught_exception_handler objc_setUncaughtExceptionHandler(objc_uncaught_exception_handler fn); objc_util.c.objc_setUncaughtExceptionHandler.argtypes = [objc_uncaught_exception_handler] objc_util.c.objc_setUncaughtExceptionHandler.restype = objc_uncaught_exception_handler # Set Objective-C uncaught exception handler @objc_uncaught_exception_handler def handler(exc_pointer): exc = objc_util.ObjCInstance(exc_pointer) name = exc.name() reason = exc.reason() user_info = exc.userInfo() call_stack_symbols = exc.callStackSymbols() with io.open(os.path.join(LOGDIR, EXCEPTIONLOGNAME_DEFAULT), "wb") as f: try: f.write(b"Objective-C exception details:\n\n") if reason is None: f.write(str(name).encode("utf-8") + b"\n") else: f.write(str(name).encode("utf-8") + b": " + str(reason).encode("utf-8") + b"\n") if user_info is not None: f.write(str(user_info).encode("utf-8") + b"\n") f.write(b"\nStack trace:\n\n") for sym in call_stack_symbols: f.write(str(sym).encode("utf-8") + b"\n") f.write(b"\nEnd of exception details.\n") except Exception as err: import traceback f.write(b"I messed up! Python exception:\n") f.write(traceback.format_exc().encode("utf-8")) raise # The exception handler must be kept in some kind of permanent location, otherwise it will be collected by the garbage collector, because there are no more references to it from Python. objc_util._dgelessus_pythonista_startup_exception_handler = handler objc_util.c.objc_setUncaughtExceptionHandler(handler) else: # The faulthandler module is only available under Python 3. print("Setting fault handler.") import faulthandler logfile = io.open(os.path.join(LOGDIR, LOGNAME_DEFAULT), "wb") faulthandler.enable(logfile) print(u"Done enabling fault handler and Objective-C exception handler.")
console.set_color() time.sleep(1) else: time.sleep(1) print "\nCommands:" print "[QUIT, AUTH, SHODAN, CENSYS, ABOUT, ALL, BACK, DIRECT]\n" mode = "Menu" while 1: try: if mode == "Shodan" and shodan_active: while 1: if iOS: sys.stdout.write("\n[") console.write_link("Shodan","https://shodan.io") sys.stdout.write("-%s]" %id) q = raw_input(" >>> ") else: q = raw_input("\n[Shodan-%s] >>> "%id) if len(q) > 1: i = menu(q) if i is "break": mode = "Menu" break if i is "Shodan": mode = i break if i is "Censys": mode = i break
def print_link(title, link): try: import console console.write_link(title, link) except ImportError: print 'Title: {0}, Link: {1}'.format(title, link)
def begin(): path1 = os.path.abspath(inspect.stack()[0][1]) path1 = re.sub(r'.*ents/', '', path1) path1 = "pythonista3://" + path1 path1 = path1.replace("<string>","") path1 = path1.replace("r3cord3r.py","r3cord3r.py?action=run&argv=b") path2 = path1.replace("b","s") #start_recording() import string, time, console time.sleep(2) console.clear() mix = string.ascii_uppercase + string.digits word = "R3CORD3R" amt = len(word) console.set_font("Menlo",30) print "" def mk(size=1): data = [] for i in range(size): data.append(random.choice(mix)) return "".join(data) for i in range(amt): temp = mk(amt) sys.stdout.write("\r\t\t "+temp) time.sleep(0.05) for i in range(amt): temp = mk(amt-2) sys.stdout.write("\r\t\t "+temp+word[6]+mk(1)) time.sleep(0.05) for i in range(amt): temp = mk(amt-7) sys.stdout.write("\r\t\t "+temp+word[1]+mk(4)+word[6]+mk()) time.sleep(0.05) for i in range(amt): temp = mk(amt-7) sys.stdout.write("\r\t\t "+temp+word[1]+mk()+word[3]+word[6]+mk()) time.sleep(0.05) for i in range(amt): temp = mk(amt-7) sys.stdout.write("\r\t\t "+word[:2]+mk(4)+word[6]+mk()) time.sleep(0.05) for i in range(amt): temp = mk(amt-7) sys.stdout.write("\r\t\t "+word[:2]+mk(4)+word[6]+"R") time.sleep(0.05) for i in range(amt): temp = mk(amt-7) sys.stdout.write("\r\t\t "+word[:3]+mk(3)+word[6]+"R") time.sleep(0.05) for i in range(amt): temp = mk(amt-7) sys.stdout.write("\r\t\t "+word[:3]+mk(2)+"D3R") time.sleep(0.05) for i in range(amt): temp = mk(amt-7) sys.stdout.write("\r\t\t "+word) time.sleep(0.05) print "\r\t\t R3CORD3R" console.set_font() print " " * 9 + "By: Russian Otter\n" sys.stdout.write(" \r") console.write_link("Start Recording",path1) print "" sys.stdout.write(" \r") console.write_link("End Recording",path2)
def run(): import ctypes import datetime import errno import io import objc_util import os import shutil import sys import console try: unicode except NameError: unicode = str print(u"Enabling fault handler and Objective-C exception handler...") LOGDIR = os.path.expanduser(u"~/Documents/faultlog") LOGNAME_TEMPLATE = u"faultlog-{:%Y-%m-%d-%H-%M-%S}.txt" LOGNAME_DEFAULT = u"faultlog-temp.txt" EXCEPTIONLOGNAME_DEFAULT = u"exceptionlog-temp.txt" # Create the faultlog directory if necessary try: os.mkdir(LOGDIR) except (IOError, OSError) as err: if err.errno != errno.EEXIST: raise # Check whether an Objective-C exception log exists and append it to the fault log try: fin = io.open(os.path.join(LOGDIR, EXCEPTIONLOGNAME_DEFAULT), "rb") except (IOError, OSError) as err: if err.errno != errno.ENOENT: raise else: with fin: data = fin.read() if data: with io.open(os.path.join(LOGDIR, LOGNAME_DEFAULT), "ab") as fout: # If the faultlog is not empty, add a separator if fout.tell() != 0: fout.write(b"\n" + b"-"*72 + b"\n\n") fout.write(data) os.remove(os.path.join(LOGDIR, EXCEPTIONLOGNAME_DEFAULT)) # Check whether a faultlog was written did_fault = False try: f = io.open(os.path.join(LOGDIR, LOGNAME_DEFAULT), "rb") except (IOError, OSError) as err: if err.errno != errno.ENOENT: raise else: with f: if f.read(1): did_fault = True # Notify the user that a crash has happened if did_fault: print(u"Pythonista quit abnormally last time.", file=sys.stderr) stamped_name = LOGNAME_TEMPLATE.format(datetime.datetime.fromtimestamp(os.stat(os.path.join(LOGDIR, LOGNAME_DEFAULT)).st_mtime)) shutil.move(os.path.join(LOGDIR, LOGNAME_DEFAULT), os.path.join(LOGDIR, stamped_name)) console.write_link(u"For details, see the log file '{}'.".format(stamped_name), str(objc_util.nsurl(os.path.join(LOGDIR, stamped_name)))) if sys.version_info < (3,): print(u"Setting exception handler.") # Set the Objective-C exception handler only under Python 2. # Otherwise under Pythonista 3 it would be set twice - once by Python 2 and once by Python 3. # This way the exception handler is set exactly once and works under Pythonista 2 and 3. # typedef void (*objc_uncaught_exception_handler)(id exception); objc_uncaught_exception_handler = ctypes.CFUNCTYPE(None, ctypes.c_void_p) # objc_uncaught_exception_handler objc_setUncaughtExceptionHandler(objc_uncaught_exception_handler fn); objc_util.c.objc_setUncaughtExceptionHandler.argtypes = [objc_uncaught_exception_handler] objc_util.c.objc_setUncaughtExceptionHandler.restype = objc_uncaught_exception_handler # Set Objective-C uncaught exception handler @objc_uncaught_exception_handler def handler(exc_pointer): exc = objc_util.ObjCInstance(exc_pointer) name = exc.name() reason = exc.reason() user_info = exc.userInfo() call_stack_symbols = exc.callStackSymbols() with io.open(os.path.join(LOGDIR, EXCEPTIONLOGNAME_DEFAULT), "wb") as f: try: f.write(b"Objective-C exception details:\n\n") if reason is None: f.write(str(name).encode("utf-8") + b"\n") else: f.write(str(name).encode("utf-8") + b": " + str(reason).encode("utf-8") + b"\n") if user_info is not None: f.write(str(user_info).encode("utf-8") + b"\n") f.write(b"\nStack trace:\n\n") for sym in call_stack_symbols: f.write(str(sym).encode("utf-8") + b"\n") f.write(b"\nEnd of exception details.\n") except Exception as err: import traceback f.write(b"I messed up! Python exception:\n") f.write(traceback.format_exc().encode("utf-8")) raise # The exception handler must be kept in some kind of permanent location, otherwise it will be collected by the garbage collector, because there are no more references to it from Python. objc_util._dgelessus_pythonista_startup_exception_handler = handler objc_util.c.objc_setUncaughtExceptionHandler(handler) else: # The faulthandler module is only available under Python 3. print("Setting fault handler.") import faulthandler logfile = io.open(os.path.join(LOGDIR, LOGNAME_DEFAULT), "wb") faulthandler.enable(logfile) print(u"Done enabling fault handler and Objective-C exception handler.")
It also has optional support for LaunchCenterPro if it is installed. Source code at: https://github.com/HyShai/url-cleaner''' import clipboard, console, re, requests, sys, urllib, webbrowser def url_lengthen(url): # recursively lengthen the url try: new_url = requests.head(url).headers.get('location') except ValueError: return None return url_lengthen(new_url) if new_url else url url = url_lengthen(sys.argv[1] if len(sys.argv) > 1 else clipboard.get()) if not url: print(welcome_msg) sys.exit() #strip analytics garbage url = re.sub(r'(?<=\&|\?)utm\w+=[^\&]+(\&)?','',url) if webbrowser.can_open('launch://'): params = urllib.quote('[prompt:Set Clipboard=%s]' % url) launch = 'launch://clipboard?text=%s' % params webbrowser.open(launch) else: print('Copying '), console.write_link(url, url) print('to the clipboard') clipboard.set(url)
def commandline(loc=""): loc = loc.replace("./","") while 1: console.write_link("msf","") if loc == "": sys.stdout.write(" ") else: loco = loc.split("/") sys.stdout.write(" %s(" %(loco[0])) if console._get_screen_size()[0] > 500 or len("/".join(loco[1:])) < 23: sys.stderr.write("%s"%("/".join(loco[1:]).replace(".py",""))) else: sys.stderr.write("%s" %(loco[-1].replace(".py",""))) sys.stdout.write(") ") try: cmd = raw_input("> ") cmd,post = cmd.split(" ")[0].lower(),cmd.split(" ")[1:] except: print cmd, post = "",[""] if cmd == "clear": console.clear() full_banner() elif cmd == "locate" and len(post) > 0: print " =>",fdir(post[0]) elif cmd == "use" and len(post) == 1: try: commandline(fdir(post[0])) except Exception as e: sys.stderr.write(" => %s\n"%str(e)) pass elif cmd == "back": break elif cmd == "exit": exit() elif cmd == "banner": full_banner() elif cmd == "rename" and len(post) > 1: tgpg = fdir(post[0]) if len(post[1]) > 3: if not post[1].endswith(".py"): post[1] += ".py" tf = "/".join(tgpg.split("/")[:-1])+ "/" + post[1] shutil.move(tgpg, tf) collectprograms() sys.stderr.write("[*] ") sys.stdout.write("Renamed %s -> %s\n"%(tgpg, tf)) elif cmd == "search" and post[0] == "posts" and len(post) > 1: selected = [] for ps in fdir("", get=True, end=".txt"): inf = open(ps).read() for srch in post[1:]: if srch in inf: selected.append(ps) break tmsg = "Search Results for (%s)"%" ".join(post[1:]) print print tmsg print "="*len(tmsg) print print " File\n ----\n" for pst in selected: print " ",pst print elif cmd == "search" and len(post) > 0: tmsg = "Search Results for (%s)"%post[0] print print tmsg print "="*len(tmsg) print print " Name Rank Description" print " ---- ---- -----------" for prgrm in fdir(post[0], get=True): descript(prgrm, prgrm.split("/")[1]) print elif cmd == "size" and len(post) == 0: console.set_font("Menlo", size) elif cmd == "size" and len(post[0]) > 1: try: console.set_font("Menlo", int(post[0])) globals()["size"] = int(post[0]) except: pass elif cmd == "add_header" and len(post) > 1: if len(post[0]) > 3: tgf = fdir(post[0]) if os.path.isfile(tgf) and len(post[1]) > 2: acode = open(tgf).read() acode = "# "+post[1]+"\n"+acode f = open(tgf,"w") f.write(acode) f.close() sys.stderr.write("[*] ") sys.stdout.write("Header added to %s\n"%tgf) elif cmd == "python" and len(post) > 0: if post[0].endswith(".py") and os.path.isfile(post[0]): try: t = threading.Thread(target=MetaThread, args=(post[0]," ".join(post[1:],))) t.name = "python_app" t.daemon = True t.start() while pause and "python_app" in threading._active: time.sleep(0.5) time.sleep(1.2) print except Exception as e: sys.stderr.write(" => %s\n"%str(e)) print else: sys.stderr.write(" => Invalid file path\n") elif cmd == "remove" and len(post) > 0: try: if post[0] in sets and post[0] != "slowsearch": t = post[0]+" => "+sets.get(post[0]) sets.pop(post[0]) var.remove(t) print "Removed Values For \"%s\"" %data except Exception as e: pass elif cmd == "read" and len(post) > 0: if len(post[0]) > 0: post[0] = fdir(post[0]) if os.path.isfile(post[0]): print open(post[0]).read() print else: sys.stderr.write(" => Invalid file path\n") elif cmd == "install" and len(post) > 0: if post[0] == "exploitdb": db = "https://github.com/offensive-security/exploit-database/archive/master.zip" resp = urllib.urlopen(db) try: file_size = int(resp.info().getheaders("Content-Length")[0]) except AttributeError: file_size = int(resp.info().get("Content-Length")) downloaded_size = 0 block_size = 4096 sys.stderr.write("[*] ") sys.stdout.write("Downloading exploit-db\n") with open("./master.zip", "wb") as outfile: buff = resp.read(block_size) while buff: outfile.write(buff) downloaded_size += len(buff) downloaded_part = float(downloaded_size) / file_size progress_size = int(downloaded_part * 39) status = "[{0}{1}] {2:.2%}".format( "#" * progress_size, " " * (39 - progress_size), downloaded_part) sys.stdout.write("\r"+status+'\b' * (len(status) + 1)) buff = resp.read(block_size) print sys.stderr.write("[*] ") sys.stdout.write("Unpackaging files (inturrupt process if it takes over 5 minutes)") try: zip_ref = zipfile.ZipFile("master.zip", "r") if raw_input(" => Run unzipping in background? [Y/n]\n =>").lower() == "y": threading.Thread(target=zip_ref.extractall, args=("./",)).start() else: zip_ref.extractall("./") zip_ref.close() except: pass if os.path.isdir("./exploit-database-master"): if os.path.isdir("./exploits"): os.remove("./exploits") shutil.move("./exploit-database-master/exploits","./exploits") shutil.rmtree("./exploit-database-master/") if os.path.isfile("master.zip"): os.remove("master.zip") sys.stderr.write("[*] ") sys.stdout.write("Unpackaging process complete! Files have been added to your database!\n") else: sys.stderr.write("[!] ") sys.stdout.write("Unpackaging process interrupt too earily\n") elif cmd == "uninstall" and len(post) > 0: if len(post[0]) > 0: if post[0] == "notpy" or post[0] == "nonpy": end = "non python" else: end = ".%s"%post[0] sys.stderr.write("[!] ") sys.stdout.write("Are you sure you wish to uninstall all %s files? [Y/n]\n => "%end) if raw_input().lower() == "y": if post[0] == "notpy": for prg in fdir("", get=True, end=""): ldir = "" if ".py" not in prg: ndir = "/".join(prg.split("/")[:-1])[2:] if ldir != ndir: sys.stdout.write(("\r[*] Cleaning: %s"+(" "*15))%ndir) ldir = ndir if sets["slowsearch"] == "true": time.sleep(0.005) if "exploit" in prg or "payload" in prg or "auxiliary" in prg: os.remove(prg) else: for prg in fdir("", get=True, end=end): ldir = "" if "."+post[0] in prg: ndir = "/".join(prg.split("/")[:-1])[2:] if ldir != ndir: sys.stdout.write(("\r[*] Cleaning: %s"+(" "*15))%ndir) ldir = ndir if sets["slowsearch"] == "true": time.sleep(0.005) os.remove(prg) clean_folders() print "\n" extended_cmd(cmd, post, loc)
def run_cli(): global response table_headers = ['Tool', 'Current Version', 'Latest Version', 'Update?'] gather_used_tools('aim') gather_used_tools('aleapp') gather_used_tools('atola') gather_used_tools('autopsy') gather_used_tools('avml') gather_used_tools('axiom') gather_used_tools('bec') gather_used_tools('blacklight') gather_used_tools('caine') gather_used_tools('cyberchef') gather_used_tools('deft') gather_used_tools('eift') gather_used_tools('encase') gather_used_tools('exiftool') gather_used_tools('ez_amcacheparser') gather_used_tools('ez_appcompatcacheparser') gather_used_tools('ez_bstrings') gather_used_tools('ez_evtxex') gather_used_tools('ez_jlecmd') gather_used_tools('ez_jumplistex') gather_used_tools('ez_lecmd') gather_used_tools('ez_mftecmd') gather_used_tools('ez_mftexplorer') gather_used_tools('ez_pecmd') gather_used_tools('ez_rbcmd') gather_used_tools('ez_recentfilecacheparser') gather_used_tools('ez_registryex') gather_used_tools('ez_sdbex') gather_used_tools('ez_shellbagex') gather_used_tools('ez_timelineex') gather_used_tools('ez_vscmount') gather_used_tools('ez_wxtcmd') gather_used_tools('fec') gather_used_tools('forensicexplorer') gather_used_tools('ffn') gather_used_tools('fresponse') gather_used_tools('ftk') gather_used_tools('ftkimager') gather_used_tools('hashcat') gather_used_tools('hstex') gather_used_tools('ileapp') gather_used_tools('irec') gather_used_tools('ive') gather_used_tools('kali') gather_used_tools('lime') gather_used_tools('macquisition') gather_used_tools('mobiledit') gather_used_tools('mountimagepro') gather_used_tools('netanalysis') gather_used_tools('nirsoft') gather_used_tools('nsrl') gather_used_tools('osf') gather_used_tools('oxygen') gather_used_tools('paraben') gather_used_tools('passware') gather_used_tools('physicalanalyzer') gather_used_tools('sleuthkit') gather_used_tools('tzworks') gather_used_tools('ufed4pc') gather_used_tools('usbdetective') gather_used_tools('veracrypt') gather_used_tools('xamn') gather_used_tools('xways') console.show_activity() response = list(crawl()) update_cli('aim', 'AIM', aim_parser) update_cli('aleapp', 'ALEAPP', aleapp_parser) update_cli('atola', 'Atola TaskForce', atola_parser) update_cli('autopsy', 'Autopsy', autopsy_parser) update_cli('avml', 'AVML', avml_parser) update_cli('axiom', 'AXIOM', axiom_parser) update_cli('bec', 'BEC', bec_parser) update_cli('blacklight', 'BlackLight', blacklight_parser) update_cli('caine', 'CAINE', caine_parser) update_cli('cyberchef', 'CyberChef', cyberchef_parser) update_cli('deft', 'DEFT', deft_parser) update_cli('eift', 'EIFT', eift_parser) update_cli('encase', 'Encase', encase_parser) update_cli('exiftool', 'ExifTool', exiftool_parser) update_cli('ez_amcacheparser', 'EZ AmcacheParser', ez_amcacheparser_parser) update_cli('ez_appcompatcacheparser', 'EZ AppCompatCacheParser', ez_appcompatcacheparser_parser) update_cli('ez_bstrings', 'EZ bstrings', ez_bstrings_parser) update_cli('ez_evtxex', 'EZ Evtx Explorer/EvtxECmd', ez_evtxex_parser) update_cli('ez_jlecmd', 'EZ JLECmd', ez_jlecmd_parser) update_cli('ez_jumplistex', 'EZ JumpList Explorer', ez_jumplistex_parser) update_cli('ez_lecmd', 'EZ LECmd', ez_lecmd_parser) update_cli('ez_mftecmd', 'EZ MFTECmd', ez_mftecmd_parser) update_cli('ez_mftexplorer', 'EZ MFTExplorer', ez_mftexplorer_parser) update_cli('ez_pecmd', 'EZ PECmd', ez_pecmd_parser) update_cli('ez_rbcmd', 'EZ RBCmd', ez_rbcmd_parser) update_cli('ez_recentfilecacheparser', 'EZ RecentFileCacheParser', ez_recentfilecacheparser_parser) update_cli('ez_registryex', 'EZ Registry Explorer/RECmd', ez_registryex_parser) update_cli('ez_sdbex', 'EZ SDB Explorer', ez_sdbex_parser) update_cli('ez_shellbagex', 'EZ ShellBags Explorer', ez_shellbagex_parser) update_cli('ez_timelineex', 'EZ Timeline Explorer', ez_timelineex_parser) update_cli('ez_vscmount', 'EZ VSCMount', ez_vscmount_parser) update_cli('ez_wxtcmd', 'EZ WxTCmd', ez_wxtcmd_parser) update_cli('fec', 'Forensic Email Collector', fec_parser) update_cli('forensicexplorer', 'Forensic Explorer', forensicexplorer_parser) update_cli('ffn', 'Forensic Falcon Neo', ffn_parser) update_cli('fresponse', 'F-Response', fresponse_parser) update_cli('ftk', 'FTK', ftk_parser) update_cli('ftkimager', 'FTK Imager', ftkimager_parser) update_cli('hashcat', 'hashcat', hashcat_parser) update_cli('hstex', 'HstEx', hstex_parser) update_cli('ileapp', 'iLEAPP', ileapp_parser) update_cli('irec', 'IREC', irec_parser) update_cli('ive', 'iVe', ive_parser) update_cli('kali', 'Kali', kali_parser) update_cli('lime', 'LiME', lime_parser) update_cli('macquisition', 'MacQuisition', macquisition_parser) update_cli('mobiledit', 'MobilEdit', mobiledit_parser) update_cli('mountimagepro', 'Mount Image Pro', mountimagepro_parser) update_cli('netanalysis', 'NetAnalysis', netanalysis_parser) update_cli('nirsoft', 'NirSoft Launcher', nirsoft_parser) update_cli('nsrl', 'NSRL hash set', nsrl_parser) update_cli('osf', 'OSForensics', osf_parser) update_cli('oxygen', 'Oxygen Forensic', oxygen_parser) update_cli('paraben', 'Paraben E3', paraben_parser) update_cli('passware', 'Passware', passware_parser) update_cli('physicalanalyzer', 'Physical Analyzer', physicalanalyzer_parser) update_cli('sleuthkit', 'The Sleuth Kit', sleuthkit_parser) update_cli('tzworks', 'TZWorks', tzworks_parser) update_cli('ufed4pc', 'UFED 4PC', ufed4pc_parser) update_cli('usbdetective', 'USB Detective', usbdetective_parser) update_cli('veracrypt', 'VeraCrypt', veracrypt_parser) update_cli('xamn', 'XAMN', xamn_parser) update_cli('xways', 'X-Ways', xways_parser) update_urls = { 'xways': 'http://www.x-ways.net/winhex/license.html', 'xamn': 'https://www.msab.com/downloads/', 'veracrypt': 'https://www.veracrypt.fr/en/Downloads.html', 'usbdetective': 'https://usbdetective.com/release-notes/', 'ufed4pc': 'https://www.cellebrite.com/en/support/product-releases/', 'tzworks': 'https://tzworks.net/download_links.php', 'sleuthkit': 'https://github.com/sleuthkit/sleuthkit/releases/latest', 'physicalanalyzer': 'https://www.cellebrite.com/en/support/product-releases/', 'passware': 'https://www.passware.com/kit-forensic/whatsnew/', 'paraben': 'https://paraben.com/paraben-downloads/', 'oxygen': 'http://www.oxygen-forensic.com/download/whatsnew/OFD/WhatsNew.html', 'osf': 'https://www.osforensics.com/download.html', 'nsrl': 'https://www.nist.gov/itl/ssd/software-quality-group/national-software-reference-library-nsrl/nsrl-download/current-rds', 'nirsoft': 'https://launcher.nirsoft.net/downloads/index.html', 'netanalysis': 'https://www.digital-detective.net/start/netanalysis-quick-start/', 'mountimagepro': 'http://www.forensicexplorer.com/download.php', 'mobiledit': 'https://www.mobiledit.com/downloads', 'macquisition': 'https://www.blackbagtech.com/downloads/', 'lime': 'https://github.com/504ensicsLabs/LiME/releases/latest', 'kape': 'https://ericzimmerman.github.io/KapeDocs/#!Pages\\0.-Changelog.md', 'kali': 'https://www.kali.org/downloads/', 'ive': 'https://berla.co/customer-support/', 'irec': 'https://binalyze.com/products/irec/release-notes/', 'ileapp': 'https://github.com/abrignoni/iLEAPP', 'hstex': 'https://www.digital-detective.net/start/hstex-quick-start/', 'hashcat': 'https://hashcat.net/beta/', 'ftkimager': 'https://accessdata.com/product-download', 'ftk': 'https://accessdata.com/product-download', 'fresponse': 'https://www.f-response.com/support/downloads', 'ffn': 'https://www.logicube.com/knowledge/forensic-falcon-neo/', 'forensicexplorer': 'http://www.forensicexplorer.com/download.php', 'fec': 'http://www.metaspike.com/fec-change-log/', 'ez_wxtcmd': 'https://ericzimmerman.github.io/#!index.md', 'ez_vscmount': 'https://ericzimmerman.github.io/#!index.md', 'ez_timelineex': 'https://ericzimmerman.github.io/#!index.md', 'ez_shellbagex': 'https://ericzimmerman.github.io/#!index.md', 'ez_sdbex': 'https://ericzimmerman.github.io/#!index.md', 'ez_registryex': 'https://ericzimmerman.github.io/#!index.md', 'ez_recentfilecacheparser': 'https://ericzimmerman.github.io/#!index.md', 'ez_rbcmd': 'https://ericzimmerman.github.io/#!index.md', 'ez_pecmd': 'https://ericzimmerman.github.io/#!index.md', 'ez_mftexplorer': 'https://ericzimmerman.github.io/#!index.md', 'ez_mftecmd': 'https://ericzimmerman.github.io/#!index.md', 'ez_lecmd': 'https://ericzimmerman.github.io/#!index.md', 'ez_jumplistex': 'https://ericzimmerman.github.io/#!index.md', 'ez_jlecmd': 'https://ericzimmerman.github.io/#!index.md', 'ez_evtxex': 'https://ericzimmerman.github.io/#!index.md', 'ez_bstrings': 'https://ericzimmerman.github.io/#!index.md', 'ez_appcompatcacheparser': 'https://ericzimmerman.github.io/#!index.md', 'ez_amcacheparser': 'https://ericzimmerman.github.io/#!index.md', 'exiftool': 'https://owl.phy.queensu.ca/~phil/exiftool/', 'encase': 'https://www.guidancesoftware.com/encase-forensic', 'eift': 'https://www.elcomsoft.com/eift.html', 'deft': 'http://na.mirror.garr.it/mirrors/deft/zero/', 'cyberchef': 'https://github.com/gchq/CyberChef/releases/latest', 'caine': 'https://www.caine-live.net/', 'blacklight': 'https://www.blackbagtech.com/downloads/', 'bec': 'https://belkasoft.com/get', 'axiom': 'https://www.magnetforensics.com/downloadaxiom/', 'avml': 'https://github.com/microsoft/avml/releases/latest', 'autopsy': 'https://github.com/sleuthkit/autopsy/releases/latest', 'atola': 'https://atola.com/products/taskforce/download.html', 'aleapp': 'https://github.com/abrignoni/ALEAPP', 'aim': 'https://arsenalrecon.com/downloads/' } results = tabulate(table, headers=table_headers, disable_numparse=True) results_split = results.split('¿') for idx, result in enumerate(results_split): if (idx % 2 == 0): print(result, end='') else: for key in update_urls.keys(): if key == result: result = result.replace(key, update_urls[key]) console.write_link('Update available!', result) ### Forensic Version Checker try: soup = BeautifulSoup(response[0].text, 'html.parser') version = soup.find('div', { 'class': 'release-header' }).select_one('a').text.strip() version = version.replace('v', '') except: version = '1.16' if (version == '1.16'): pass else: print('\n') console.write_link( 'FVC update available!', 'https://github.com/jankais3r/Forensic-Version-Checker/releases/latest' )
# http://dev.evernote.com/documentation/cloud/chapters/ENML.php note.content = '<?xml version="1.0" encoding="UTF-8"?>' note.content += '<!DOCTYPE en-note SYSTEM ' \ '"http://xml.evernote.com/pub/enml2.dtd">' note.content += '<en-note>' note.content += text note.content += '</en-note>' note.content = note.content.encode('utf-8') # assign the result to change original string print "Uploading clip to Evernote..." created_note = note_store.createNote(note) noteGuid = created_note.guid #Get user shardID and the note's unique share key user = userStore.getUser(auth_token).shardId shareKey = note_store.shareNote(auth_token, noteGuid) console.hide_activity() print "Note URL set to clipboard. The note has been shared with the following URL:\n\n", # Last, create two separate URLs for the browser you want to use # and the link you want to share in the clipboard final = "%s/shard/%s/sh/%s/%s" % \ (EN_URL, user, noteGuid, shareKey) shareable = "%s/shard/%s/sh/%s/%s" % \ ("https://www.evernote.com", user, noteGuid, shareKey) console.write_link(shareable, final) clipboard.set(shareable)
def romap(): """ This is the main script inside Romap that processes the scans and controls the outputs. One of the most useful peices of code inside this script, allows ip addresses to be clicked on after scanning. When the ip is clicked romap will run a scan on that ip! """ path1 = os.path.abspath(inspect.stack()[0][1]) path1 = re.sub(r'.*ents/', '', path1) path1 = "pythonista3://" + path1 path1 = path1.replace("<string>", "") path1 = path1.replace("romap.py", "romap.py?action=run&argv=-n&argv=-P&argv=") path1 = path1 + rng + "&argv=-t&argv=" + str(tot) + "&argv=-D&argv=" s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) try: s.connect(("google.com", 80)) host = s.getsockname()[0] except: host = "N/A" lan = host try: my_ip = "N/A" my_ip = urlopen('http://ip.42.pl/raw').read() except: pass if len(my_ip) > 18: my_ip = 'N/A' macaddr = hex(uuid.getnode()).replace('0x', '').upper() mac = ':'.join(macaddr[i:i + 2] for i in range(0, 11, 2)) time.sleep(0.4) print "LAN: %s" % (lan) time.sleep(0.4) print "MAC: %s" % (mac) time.sleep(0.4) print "PUB: %s" % (my_ip) time.sleep(0.4) print "IPv6: %s" % (getIPv6Addr(my_ip)) time.sleep(0.4) print "RFC IPv6: %s" % (rfc3056(my_ip)) CNCopyCurrentNetworkInfo = c.CNCopyCurrentNetworkInfo CNCopyCurrentNetworkInfo.restype = c_void_p CNCopyCurrentNetworkInfo.argtypes = [c_void_p] wifiid = ObjCInstance(CNCopyCurrentNetworkInfo(ns('en0'))) print "SSID: %s" % (wifiid["SSID"]) time.sleep(0.4) print "BSSID: %s" % (wifiid["BSSID"]) time.sleep(0.4) print(uuid.uuid5(uuid.NAMESPACE_DNS, "0.0.0.0")) time.sleep(0.4) byte = random._urandom(16) print(uuid.UUID(bytes=byte)) time.sleep(0.4) print(uuid.uuid4()) time.sleep(0.4) print(uuid.uuid3(uuid.NAMESPACE_DNS, "0.0.0.0")) time.sleep(0.4) print(uuid.uuid1()) time.sleep(0.4) byte = random._urandom(16) print(uuid.UUID(bytes=byte)) time.sleep(0.4) print "" s.close() start_time = time.time() try: if len(args.public) > 1: host = args.public except: pass host = host.split(".") bkmid = host[2] host[3] = "%s" host[2] = "%s" if args.Mid != "None": host[1] = "%s" host = ".".join(host) s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) network = str(host) td = 0 if args.mid != "None" and args.Mid != "None": srng = args.mid.split("-") srng2 = args.Mid.split("-") for tend in range(int(srng2[0]), int(srng2[1]) + 1): for mend in range(int(srng[0]), int(srng[1]) + 1): for end in range(256): ip = network % (tend, mend, end) try: info = socket.gethostbyaddr(ip) info2 = str(info[2]).replace("[", "").replace( "]", "").replace("'", "") info3 = info[0] + " -- " sys.stdout.write(info3) if log: f = open(log, "a") f.write(str(info[0]) + " -- " + str(info2) + "\n") console.write_link(info2, path1 + info2) if dtl: print "\n" deepscan(info2) print "" time.sleep(0.05) if sl: sslc(info2) td = td + 1 print "" if srch: s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) result = s.connect_ex((info2, prt)) if result == 0: print "Port {}: Open".format(prt) s.close() except: pass if args.mid == "None": for end in range(256): ip = network % (bkmid, end) try: info = socket.gethostbyaddr(ip) info2 = str(info[2]).replace("[", "").replace("]", "").replace("'", "") info3 = info[0] + " -- " sys.stdout.write(info3) if log: f = open(log, "a") f.write(str(info[0]) + " -- " + str(info2) + "\n") console.write_link(info2, path1 + info2) if dtl: print "\n" deepscan(info2) print "" time.sleep(0.05) td = td + 1 print "" if srch: s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) result = s.connect_ex((info2, prt)) if result == 0: print "Port {}: Open".format(prt) s.close() try: if dtl: deepscan(info2) time.sleep(0.05) except: pass except: pass if args.mid != "None" and args.Mid == "None": srng = args.mid.split("-") for mend in range(int(srng[0]), int(srng[1]) + 1): for end in range(256): ip = network % (mend, end) try: info = socket.gethostbyaddr(ip) info2 = str(info[2]).replace("[", "").replace("]", "").replace( "'", "") info3 = info[0] + " -- " sys.stdout.write(info3) if log: f = open(log, "a") f.write(str(info[0]) + " -- " + str(info2) + "\n") console.write_link(info2, path1 + info2) if dtl: print "\n" deepscan(info2) print "" time.sleep(0.05) td = td + 1 print "" if srch: s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) result = s.connect_ex((info2, prt)) if result == 0: print "Port {}: Open".format(prt) s.close() try: if dtl: deepscan(info2) time.sleep(0.05) except: pass except: pass print "" elapsed_time = time.time() - start_time time.sleep(0.5) times = str(timedelta(seconds=elapsed_time)) sys.stdout.write("Time Elapsed: ") sys.stdout.write(str(times)) print "\nTotal Device(s) Found:", td try: if acp: print "\n" discover() except: pass