def call(self, command): """ Stub for now """ command_string = "dash-cli " command_string += command subprocess.checkoutput(command_string) return
def remove_block_ip(): """REMOVER BLOQUEIO DE IP""" ip = raw_input("Digite o IP que deseja remover o bloqueio: ") comando = "iptables -A INPUT -s %s -j DROP --delete" % ip print subprocess.check_output(comando, shell=True) with open("/root/.firewall/firewall.sh", "r+") as arq: conteudo = arq.read() conteudo.replace(comando, "") arq.seek(0) arq.write(conteudo) atualizascript = "./root/.firewall/firewall.sh" print subprocess.checkoutput(atualizascript, shell=True) print "Comandos executados." click.pause("Pressione ENTER para continuar")
def sdrWifiTests(): wifi_return_code = subprocess.checkoutput("") #If wifi_return_code is true than a wireless service has been turned off if (wifi_return_code): print("\t Wifi: {} \n".format(passedCheck)) else: passedCheck = "On" print("\t Wifi: {} \n".format(passedCheck))
def remove_block_url(): """REMOVER BLOQUEIO DE URL""" end = raw_input("Digite o endereco que deseja remover o bloqueio: ") comando = "iptables -A FORWARD -i eth1 -m string --algo bm --string %s -j DROP --delete" % end comandoatualiza = "iptables -A FORWARD -i eth1 -m string --algo bm --string %s -j DROP" % end print subprocess.check_output(comando, shell=True) with open("/root/.firewall/firewall.sh", "r+") as arq: conteudo = arq.read() conteudo.remove(comandoatualiza) arq.seek(0) arq.write(conteudo) atualizascript = "./root/.firewall/firewall.sh" print subprocess.checkoutput(comando, shell=True) print subprocess.checkoutput(atualizascript, shell=True) print "Comandos executados." click.pause("Pressione ENTER para continuar")
def run_command(): #trim the newline command = command.restrip() #run the command and get the output back try: output = subprocess.checkoutput(command, stderr=subprocess.STDOUT, shell=True) except: output = "Failed to execute command. \r\n" #send the output back to the client return output
def run_command(command): command = command.rstrip() try: output = subprocess.checkoutput(command, stderr=subprocess.STDOUT, shell=True) except: output = "Failed to execute command. \r\n" return output
def AOSX_12_000605(): verification = '' cmd = '' fix = '' outputcheck = subprocess.check_output(cmd, shell=True) if(outputcheck != verification): os.system(fix) #confirm everything was fixed confirmation = subprocess.checkoutput(cmd, shell=True) if cmd != verification: print me + 'ERROR>unable to verify system check for AOSX-12-000605' else: print me + 'INFO> verified and fixed system check for AOSX-12-000605' else: print me + 'INFO>Verified AOSX_12_000035 is Satisfied'
def AOSX_12_000050(): verification = '' cmd = '/usr/sbin/system_profiler SPConfigurationProfileDataType | /usr/bin/grep "wvous-bl-corner = 0;"' cmd2 = '/usr/sbin/system_profiler SPConfigurationProfileDataType | /usr/bin/grep "wvous-tl-corner = 0;"' cmd3 = '/usr/sbin/system_profiler SPConfigurationProfileDataType | /usr/bin/grep "wvous-br-corner = 0;"' cmd4 = '/usr/sbin/system_profiler SPConfigurationProfileDataType | /usr/bin/grep "wvous-tr-corner = 0;"' fix = '' outputcheck = subprocess.check_output(cmd, shell=True) if(outputcheck == verification): os.system(fix) #confirm everything was fixed confirmation = subprocess.checkoutput(cmd, shell=True) if cmd != verification: print me + 'ERROR>unable to verify system check for AOSX_12_000050' else: print me + 'INFO> verified and fixed system check for AOSX_12_000050' else: print me + 'INFO>Verified AOSX_12_000050 is Satisfied'
import subprocess try: print (subprocess.checkoutput(["run_workflow.sh", "Delly", donor, gnos_or_igcg])) except Exception, e: with open('jt.log', 'w') as f: f.write(str(e)) sys.exit(1)
import subprocess task = 'BWA-Mem' donor = "DO46792" source = "ICGC" try: print (subprocess.checkoutput(["run_workflow.sh", task, donor, source])) except Exception, e: with open('jt.log', 'w') as f: f.write(str(e)) sys.exit(1)
import subprocess import shutil destination = '/home/mark/File-Entropy-master/malware' print(destination) for filename in os.listdir(destination): print(filename) file = os.path.join(destination, filename) magictype = magic.from_file(file) if any(x in magictype for x in ['upx', 'packed', 'compressed', 'extracting']): packedname = os.path.join(destination, 'packed-' + filename) os.rename(file, packedname) print('file was packed:', packedname) if 'upx' in magictype: print('found upx, attempting to unpack') # if its upx we can try to unpack it unpackedname = os.path.join(destination, 'upx-unpacked-' + filename) shutil.copyfile(packedname, unpackedname) try: subprocess.checkoutput(['upx', '-d', unpackedname]) print('unpacked as :', unpackedname) except: # bad practice but I don't care why upx failed os.remove(unpackedname) print('failed to unpack')
if args.url: response = requests.get(args.url) img = Image.open(BytesIO(response.content)) qr_decoded = decode(img) data = str(qr_decoded[0].data) print(data) exit(0) elif args.date: time_str = time.strftime(DATE_TIME_FORMAT, time.localtime(args.date)) print(time_str) exit(0) elif args.check_wifi: a = subprocess.checkoutput(['netsh', 'wlan', 'show', 'profiles']).decode('utf-8').split('\n') a = [i.split(':')[1][1:-1] for i in a if "All User Profile" in i] for i in a: results = subprocess.checkoutput(['netsh', 'wlan', 'show', 'profiles'], i, 'key=clear').decode('utf-8').split('\n') results = [b.split(':')[1][1:-1] for b in results if "Key Content" in b] try: print("{:<30}| {:<}".format(i, results[0])) except IndexError: print("{:<30}| {:<}".format(i, "")) exit(0) def convert_str_to_date_time(list_obj):
sys.exit("Return code for '" + str(" ".join(git_pull_err.cmd)) + "' was " + str(git_pull_err.returncode) + "\n") time_closed = time.strftime("%c") process_file = open('PIDS.json', 'w') process_file.write('{\n') process_file.write('\t"time-opened": "' + time_opened + '",\n') for k, v in ret_codes.iteritems(): process_file.write('\t"' + k + '": ' + str(v) + ',\n') process_file.write('\t"time-closed": "' + time_closed + '"\n') process_file.write('}') process_file.close() try: git_pull = subprocess.check_output(["git", "pull"], cwd=lair_dir) update_dois = subprocess.check_output(["python", "grab_doi_metadata.py"], cwd=lair_dir + "/_data") git_add = subprocess.check_output(["git", "add", "--all"], cwd=lair_dir) git_commit = subprocess.checkoutput([ 'git', 'commit', '-m', '"auto-commit; close time ' + time_closed + '"' ], cwd=lair_dir) git_push = subprocess.checkoutput(['git', 'push', 'origin', 'gh-pages'], cwd=lair_dir) #requires user input except subprocess.CalledProcessError as git_pull_err: sys.exit("Return code for '" + str(" ".join(git_pull_err.cmd)) + "' was " + str(git_pull_err.returncode) + "\n")
import subprocess print( subprocess.checkoutput( ["run_workflow.sh", "SV-Merge", donor, gnos_or_igcg]))
import subprocess print( subprocess.checkoutput( ["run_workflow.sh", "Consensus", donor, gnos_or_igcg]))
base_index = srv_dir.find(base) + len(base) srv_dir = srv_dir[base_index:] srv_dir = "/srv/shiny_server/" + srv_dir try: #requires user input for sudo access sudo_deploy = subprocess.check_output(["sudo", "mkdir", "-p", srv_dir]) sudo_mv = subprocess.check_output(["sudo", "cp", k + "/so.rds", k + "/app.R", srv_dir]) sudo_sed = subprocess.check_output(["sudo", "sed", "-i", """'1i .libPaths(c(.libPaths(), "/home/psturm/R/x86_64-pc-linux-gnu-library/3.3"))'""", srv_dir + "app.R"]) except subprocess.CalledProcessError as git_pull_err: sys.exit("Return code for '" + str(" ".join(git_pull_err.cmd)) + "' was " + str(git_pull_err.returncode) + "\n") time_closed = time.strftime("%c") process_file = open('PIDS.json', 'w') process_file.write('{\n') process_file.write('\t"time-opened": "' + time_opened + '",\n') for k, v in ret_codes.iteritems(): process_file.write('\t"' + k + '": ' + str(v) + ',\n') process_file.write('\t"time-closed": "' + time_closed + '"\n') process_file.write('}') process_file.close() try: git_pull = subprocess.check_output(["git", "pull"], cwd=lair_dir) update_dois = subprocess.check_output(["python", "grab_doi_metadata.py"], cwd=lair_dir+"/_data") git_add = subprocess.check_output(["git", "add", "--all"], cwd=lair_dir) git_commit = subprocess.checkoutput(['git', 'commit', '-m', '"auto-commit; close time ' + time_closed + '"'], cwd=lair_dir) git_push = subprocess.checkoutput(['git', 'push', 'origin', 'gh-pages'], cwd=lair_dir) #requires user input except subprocess.CalledProcessError as git_pull_err: sys.exit("Return code for '" + str(" ".join(git_pull_err.cmd)) + "' was " + str(git_pull_err.returncode) + "\n")