本文整理汇总了Python中Process.Process类的典型用法代码示例。如果您正苦于以下问题:Python Process类的具体用法?Python Process怎么用?Python Process使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Process类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: strip
def strip(self, outfile=None):
# XXX: This method might break aircrack-ng, use at own risk.
'''
Strips out packets from handshake that aren't necessary to crack.
Leaves only handshake packets and SSID broadcast (for discovery).
Args:
outfile - Filename to save stripped handshake to.
If outfile==None, overwrite existing self.capfile.
'''
if not outfile:
outfile = self.capfile + '.temp'
replace_existing_file = True
else:
replace_existing_file = False
cmd = [
'tshark',
'-r', self.capfile, # input file
'-R', 'wlan.fc.type_subtype == 0x08 || eapol', # filter
'-w', outfile # output file
]
proc = Process(cmd)
proc.wait()
if replace_existing_file:
from shutil import copy
copy(outfile, self.capfile)
os.remove(outfile)
pass
示例2: print_targets
def print_targets(self):
'''
Prints targets to console
'''
if len(self.targets) == 0:
Color.p('\r')
return
if self.previous_target_count > 0:
# We need to "overwrite" the previous list of targets.
if self.previous_target_count > len(self.targets) or \
Scanner.get_terminal_height() < self.previous_target_count + 3:
# Either:
# 1) We have less targets than before, so we can't overwrite the previous list
# 2) The terminal can't display the targets without scrolling.
# Clear the screen.
from Process import Process
Process.call('clear')
else:
# We can fit the targets in the terminal without scrolling
# "Move" cursor up so we will print over the previous list
Color.pl(Scanner.UP_CHAR * (3 + self.previous_target_count))
self.previous_target_count = len(self.targets)
# Overwrite the current line
Color.p('\r')
Target.print_header()
for (index, target) in enumerate(self.targets):
index += 1
Color.pl(' {G}%s %s' % (str(index).rjust(3), target))
示例3: print_oclhashcat
def print_oclhashcat(self, cap_file):
if not Process.exists("hashcat"): return
Color.pl("\n {O}# OCLHASHCAT: GPU-based cracking. Fast.")
hccapx_file = "generated.hccapx"
if Process.exists("cap2hccapx"):
Color.pl(" {G}cap2hccapx {C}%s %s{W}" % (cap_file, hccapx_file))
else:
Color.pl(" {O}# Visit https://hashcat.net/cap2hccapx to generate a .hccapx file{W}")
Color.pl(" {O}# Browse -> %s -> Convert" % cap_file)
Color.pl(" {G}hashcat {W}-m 2500 {C}%s %s{W}" % (hccapx_file, self.wordlist))
示例4: _clientDisconnect
def _clientDisconnect(self):
if self._client:
log.info("Disconnecting client '%s'" % self._cfg.get('name', 'jack'))
try:
jack.set_info_function(None)
jack.set_error_function(None)
self._client.deactivate()
self._client.close()
except Exception as e:
log.error("Unable to gracefully disconnect '%s' client: %s" % (self._cfg.get('name', 'jack'), e))
Process._clientDisconnect(self)
示例5: addProcess
def addProcess(self, process_name, req_skill, worker):
p = Process()
p.assign_to_taskgroup(worker)
p.set_req_skills(req_skill)
print(p._Process__req_skills)
self.__processes[process_name]=p
示例6: run
def run(self):
with Airodump(channel=self.target.channel,
target_bssid=self.target.bssid,
skip_wash=True,
output_file_prefix='wps_pin') as airodump:
# Wait for target
Color.clear_entire_line()
Color.pattack("WPS",
self.target,
self.attack_type(),
"Waiting for target to appear...")
self.target = self.wait_for_target(airodump)
# Start bully
self.bully_proc = Process(self.cmd,
stderr=Process.devnull(),
bufsize=0,
cwd=Configuration.temp())
t = Thread(target=self.parse_line_thread)
t.daemon = True
t.start()
try:
while self.bully_proc.poll() is None:
try:
self.target = self.wait_for_target(airodump)
except Exception as e:
Color.clear_entire_line()
Color.pattack("WPS",
self.target,
self.attack_type(),
"{R}failed: {O}%s{W}" % e)
Color.pl("")
self.stop()
break
Color.clear_entire_line()
Color.pattack("WPS",
self.target,
self.attack_type(),
self.get_status())
time.sleep(0.5)
except KeyboardInterrupt as e:
self.stop()
raise e
except Exception as e:
self.stop()
raise e
if self.crack_result is None:
Color.clear_entire_line()
Color.pattack("WPS",
self.target,
self.attack_type(),
"{R}Failed{W}\n")
示例7: cowpatty_handshakes
def cowpatty_handshakes(self):
''' Returns True if cowpatty identifies a handshake, False otherwise '''
if not Process.exists('cowpatty'):
return []
if not self.essid:
return [] # We need a essid for cowpatty :(
proc = Process(self.cowpatty_command(), devnull=False)
for line in proc.stdout().split('\n'):
if 'Collected all necessary data to mount crack against WPA' in line:
return [(None, self.essid)]
return []
示例8: start
def start(self):
JSONRPCConfig.append_string = "\n"
self._command = [
"guitarix",
"--nogui",
"--name",
self._cfg.get("name", "guitarix"),
"--rpcport",
self._cfg.get("rpc_port", 8881),
"--server-name",
self._cfg.get("jack", "jack"),
]
Process.start(self)
示例9: __init__
def __init__(self, target, attack_type, client_mac=None, replay_file=None):
'''
Starts aireplay process.
Args:
target - Instance of Target object, AP to attack.
attack_type - int, str, or WEPAttackType instance.
client_mac - MAC address of an associated client.
'''
cmd = Aireplay.get_aireplay_command(target,
attack_type,
client_mac=client_mac,
replay_file=replay_file)
# TODO: set 'stdout' when creating process to store output to file.
# AttackWEP will read file to get status of attack.
# E.g., chopchop will regex "(\d+)% done" to get percent complete.
'''
from subprocess import PIPE
sout = PIPE
if '--chopchop' in cmd:
sout = open(Configuration.temp('chopchop'), 'w')
'''
self.pid = Process(cmd,
devnull=False,
cwd=Configuration.temp())
示例10: __init__
def __init__(self):
Gtk.Window.__init__(self)
self.set_size_request(320, 240)
basebox = Gtk.HPaned()
drawing = Gtk.DrawingArea()
drawing.modify_bg(0, Gdk.Color(0, 0, 0))
vbox = Gtk.VBox()
boton1 = Gtk.Button("Sin Efecto")
boton2 = Gtk.Button("Con Efecto")
vbox.pack_start(boton1, False, False, 0)
vbox.pack_start(boton2, False, False, 0)
basebox.pack1(drawing, True, True)
basebox.pack2(vbox, False, True)
self.add(basebox)
self.show_all()
self.realize()
self.process = Process(
drawing.get_property('window').get_xid())
self.process.play()
self.connect("delete-event", self.__exit)
示例11: __enter__
def __enter__(self):
'''
Setting things up for this context.
Called at start of 'with Airodump(...) as x:'
Actually starts the airodump process.
'''
self.delete_airodump_temp_files()
self.csv_file_prefix = Configuration.temp() + self.output_file_prefix
# Build the command
command = [
'airodump-ng',
self.interface,
'-a', # Only show associated clients
'-w', self.csv_file_prefix # Output file prefix
]
if self.channel:
command.extend(['-c', str(self.channel)])
if self.encryption:
command.extend(['--enc', self.encryption])
if self.wps:
command.extend(['--wps'])
if self.target_bssid:
command.extend(['--bssid', self.target_bssid])
if self.ivs_only:
command.extend(['--output-format', 'ivs,csv'])
else:
command.extend(['--output-format', 'pcap,csv'])
# Start the process
self.pid = Process(command, devnull=True)
return self
示例12: print_john
def print_john(self, cap_file):
if not Process.exists("pyrit"): return
Color.pl("\n {O}# JOHN: CPU or GPU-based cracking. Fast.")
Color.pl(" {O}# Use --format=wpapsk-cuda (or wpapsk-opengl) to enable GPU acceleration")
Color.pl(" {O}# See http://openwall.info/wiki/john/WPA-PSK for more info on this process")
Color.pl(" {G}aircrack-ng {W}-J hccap {C}%s{W}" % cap_file)
Color.pl(" {G}hccap2john {W}hccap.hccap > hccap.john{W}")
Color.pl(" {G}john {W}--wordlist {C}\"%s\" {W}--format=wpapsk {C}\"hccap.john\"{W}" % (self.wordlist))
示例13: aircrack_handshakes
def aircrack_handshakes(self):
if not self.bssid:
return []
(stdout, stderr) = Process.call(self.aircrack_command())
if 'passphrase not in dictionary' in stdout.lower():
return [(self.bssid, None)]
else:
return []
示例14: runExternalFilter
def runExternalFilter(self, inputStream, outputStream):
if self.__use_stdin:
inFile = None
else:
inFile = self.newTempFile("%s.in" % self.__class__.__name__)
Pump.stream2file(inputStream, inFile)
if self.__use_stdout:
outFile = None
else:
outFile = self.newTempFile("%s.out" % self.__class__.__name__)
cmd = self.getCommandLine(inFile, outFile)
try:
assert trace("Starting %s: %s" % (self.__name, cmd))
xfilter = Process(cmd, separate_stderr=self.__separate_stderr)
if self.__use_stdin:
assert trace("Writing file to %s stdin" % self.__name)
Pump.stream2stream(inputStream, xfilter.getInputStream())
if self.__use_stdout:
# output
assert trace("Pumping %s stdout to outputStream" % self.__name)
Pump.stream2stream(xfilter.getOutputStream(), outputStream)
if self.__separate_stderr:
assert trace("Handling %s stderr" % self.__name)
self.handleErrorOutput(xfilter.getErrorStream())
else:
assert trace("Handling %s stdout" % self.__name)
self.handleOutput(xfilter.getOutputStream())
if self.__separate_stderr:
assert trace("Handling %s stderr" % self.__name)
self.handleErrorOutput(xfilter.getErrorStream())
rc = xfilter.waitFor()
assert trace("%s finished with exit code: 0x%X" % (self.__name, rc))
if not (rc in self.__normalReturnCodes):
raise ExternalFilterException, "Return code 0x%X" % (rc,)
if not self.__use_stdout:
if os.path.exists(outFile):
try:
if os.path.getsize(outFile) > 0:
Pump.file2stream(outFile, outputStream, "b")
else:
raise ExternalFilterException, "Output file is empty: %s" % (outFile,)
finally:
self.removeTempFile(outFile)
else:
raise ExternalFilterException, "Output file not found: %s" % (outFile,)
finally:
if inFile is not None:
self.removeTempFile(inFile)
pass
return rc
示例15: pyrit_handshakes
def pyrit_handshakes(self):
''' Returns True if pyrit identifies a handshake, False otherwise '''
if not Process.exists('pyrit'):
return []
bssid_essid_pairs = set()
hit_target = False
current_bssid = self.bssid
current_essid = self.essid
proc = Process(self.pyrit_command(), devnull=False)
for line in proc.stdout().split('\n'):
mac_regex = ('[a-zA-Z0-9]{2}:' * 6)[:-1]
match = re.search("^#\d+: AccessPoint (%s) \('(.*)'\):$"
% (mac_regex), line)
if match:
# We found a BSSID and ESSID
(bssid, essid) = match.groups()
# Compare to what we're searching for
if self.bssid and self.bssid.lower() == bssid.lower():
current_essid = essid
hit_target = True
continue
elif self.essid and self.essid == essid:
current_bssid = bssid
hit_target = True
continue
elif not self.bssid and not self.essid:
# We don't know either
current_bssid = bssid
current_essid = essid
hit_target = True
else:
# This AccessPoint is not what we're looking for
hit_Target = False
else:
# Line does not contain AccessPoint
if hit_target and ', good,' in line:
bssid_essid_pairs.add( (current_bssid, current_essid) )
return [x for x in bssid_essid_pairs]