本文整理汇总了Python中colorama.Fore方法的典型用法代码示例。如果您正苦于以下问题:Python colorama.Fore方法的具体用法?Python colorama.Fore怎么用?Python colorama.Fore使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类colorama
的用法示例。
在下文中一共展示了colorama.Fore方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _map
# 需要导入模块: import colorama [as 别名]
# 或者: from colorama import Fore [as 别名]
def _map(self, ip, port):
request = self.open('http://{}:{}/Home/h_dhcp.htm'.format(ip, port), timeout=3.0)
html = request.get_data().splitlines()
for line in html:
try:
parts = line.split('","')
if len(parts) >= 3 and valid_ip(parts[1]):
if 'ist=[' not in line and 'erver=[' not in line:
name = parts[0].strip('["')
lan_ip = parts[1]
mac = parts[2]
lan_device = {"router": ip, "device": name, "ip": lan_ip, "mac": mac}
self._devices.append(lan_device)
print(' |')
print(colorama.Fore.CYAN + colorama.Style.BRIGHT + '[+]' + colorama.Fore.RESET + ' Device {}'.format(len(self._devices)) + colorama.Style.NORMAL)
print(' | Device Name: ' + colorama.Style.DIM + name + colorama.Style.NORMAL)
print(' | Internal IP: ' + colorama.Style.DIM + lan_ip + colorama.Style.NORMAL)
print(' | MAC Address: ' + colorama.Style.DIM + mac + colorama.Style.NORMAL)
except Exception as e:
debug(str(e))
示例2: try_url
# 需要导入模块: import colorama [as 别名]
# 或者: from colorama import Fore [as 别名]
def try_url(self, fetcher, url):
result = None
failed = False
try:
result = fetcher("/%s" % url)
except Exception:
logging.exception('Error in %s' % url)
failed = True
if result is not None and result.code == 200 and not failed:
print("{0.GREEN} SUCCESS ({1}){0.RESET}".format(Fore, url))
return
self.failed_items.append(url)
print("{0.RED} FAILED ({1}) - ERR({2}) {0.RESET}".format(Fore, url, result and result.code))
示例3: settings
# 需要导入模块: import colorama [as 别名]
# 或者: from colorama import Fore [as 别名]
def settings(self):
"""
Show the server's currently configured settings
"""
text_color = [color for color in filter(str.isupper, dir(colorama.Fore)) if color == self._text_color][0]
text_style = [style for style in filter(str.isupper, dir(colorama.Style)) if style == self._text_style][0]
prompt_color = [color for color in filter(str.isupper, dir(colorama.Fore)) if color == self._prompt_color][0]
prompt_style = [style for style in filter(str.isupper, dir(colorama.Style)) if style == self._prompt_style][0]
util.display('\n\t OPTIONS', color='white', style='bright')
util.display('text color/style: ', color='white', style='normal', end=' ')
util.display('/'.join((self._text_color.title(), self._text_style.title())), color=self._text_color, style=self._text_style)
util.display('prompt color/style: ', color='white', style='normal', end=' ')
util.display('/'.join((self._prompt_color.title(), self._prompt_style.title())), color=self._prompt_color, style=self._prompt_style)
util.display('debug: ', color='white', style='normal', end=' ')
util.display('True\n' if globals()['debug'] else 'False\n', color='green' if globals()['debug'] else 'red', style='normal')
示例4: __init__
# 需要导入模块: import colorama [as 别名]
# 或者: from colorama import Fore [as 别名]
def __init__(self, message, color):
import colorama
self._message = message
self._color = getattr(colorama.Fore, color.upper(), None)
示例5: __str__
# 需要导入模块: import colorama [as 别名]
# 或者: from colorama import Fore [as 别名]
def __str__(self):
import colorama
if not self._color:
return self._message
return self._color + self._message + colorama.Fore.RESET
示例6: _scan
# 需要导入模块: import colorama [as 别名]
# 或者: from colorama import Fore [as 别名]
def _scan(self, ip, port):
target = 'http://{}:{}'.format(ip, port)
debug("Requesting {}".format(target))
try:
self._semaphore.acquire()
conn = self.open(target, timeout=2.0)
html = conn.get_data()
if not html or not self.viewing_html():
return
elif conn.code == 200:
for signature in self.__signatures:
if signature in html:
model = str(self.title())
self._backdoors.append({"ip": ip, "port": port, "model": model, "vulnerability": self.__vulnerability, "signature": signature})
print(" | ")
print(" | " + colorama.Fore.GREEN + colorama.Style.BRIGHT + "[+] " + colorama.Fore.RESET + " Backdoor {}".format(str(len(self._backdoors))) + colorama.Style.NORMAL)
print(" | IP: " + colorama.Style.DIM + ip + colorama.Style.NORMAL)
print(" | Port: " + colorama.Style.DIM + "{}/tcp".format(port) + colorama.Style.NORMAL)
print(" | Model: " + colorama.Style.DIM + model + colorama.Style.NORMAL)
print(" | Vulnerability: " + colorama.Style.DIM + self.__vulnerability + colorama.Style.NORMAL)
print(" | Signature: " + colorama.Style.DIM + signature + colorama.Style.NORMAL)
else:
return
self._semaphore.release()
except KeyboardInterrupt:
return
except Exception as e:
debug(str(e))
示例7: pharm
# 需要导入模块: import colorama [as 别名]
# 或者: from colorama import Fore [as 别名]
def pharm(self, dns):
"""
Change the primary DNS server of vulnerable routers
`Required`
:param str dns: IP address of a user-controlled DNS server
"""
try:
if not len(self._backdoors):
error("no backdoored routers to pharm (use 'scan' to detect vulnerable targets)")
elif not valid_ip(dns):
error("invalid IP address entered for DNS server")
else:
for i, router in enumerate(self._backdoors):
self._pharm(router['ip'], router['port'], dns)
devices = self._database.execute("SELECT (SELECT count() from tbl_devices WHERE router=:router) as count", {"router": ip}).fetchall()[0][0]
print(colorama.Fore.MAGENTA + colorama.Style.NORMAL + '[+]' + colorama.Fore.RESET + ' Router {}:{} - DNS Server Modified'.format(ip, port))
print(' | DNS Server: ' + colorama.Style.DIM + '{}:53'.format(dns) + colorama.Style.NORMAL)
print(' | Connected Devices: ' + colorama.Style.DIM + '{}\n'.format(size) + colorama.Style.NORMAL)
except KeyboardInterrupt:
return
except Exception as e:
debug(str(e))
示例8: scan
# 需要导入模块: import colorama [as 别名]
# 或者: from colorama import Fore [as 别名]
def scan(self, *args):
"""
Scan target hosts for signatures of a backdoor
`Optional`
:param str ip: IP address of target router
:param int port: Port number of router administration panel
"""
try:
print("\nScanning {} targets...".format(len(self._targets)))
startlen = len(self._backdoors)
if len(args):
ip, _, port = args[0].partition(' ')
if valid_ip(ip) and port.isdigit(port):
self._targets[ip] = int(port)
self._scan(ip, port)
print(colorama.Fore.CYAN + "\n[+]" + colorama.Fore.RESET + " Scan complete - " + colorama.Style.BRIGHT + "1" + colorama.Style.NORMAL + " backdoor(s) found\n")
else:
error("invalid IP address or port number")
else:
if len(self._targets):
for ip, port in self._targets.items():
self._scan(ip, port)
print(colorama.Fore.CYAN + "\n[+]" + colorama.Fore.RESET + " Scan complete - " + colorama.Style.BRIGHT + str(len(self._backdoors) - startlen) + colorama.Style.NORMAL + " backdoor(s) found\n")
else:
error("no targets to scan")
self.help()
self._save()
except KeyboardInterrupt:
return
except Exception as e:
debug(str(e))
示例9: help
# 需要导入模块: import colorama [as 别名]
# 或者: from colorama import Fore [as 别名]
def help(self, *args):
"""
Show usage information
"""
print('\n' + colorama.Fore.YELLOW + colorama.Style.BRIGHT + ' COMMAND DESCRIPTION' + colorama.Fore.RESET + colorama.Style.NORMAL)
print(' search ' + colorama.Style.DIM + ' query the Shodan IoT search engine for targets' + colorama.Style.NORMAL)
print(' scan [ip] ' + colorama.Style.DIM + ' scan target host(s) for backdoors' + colorama.Style.NORMAL)
print(' map [ip] ' + colorama.Style.DIM + ' map local network(s) of vulnerable routers' + colorama.Style.NORMAL)
print(' pharm <dns> ' + colorama.Style.DIM + ' modify the dns server of vulnerable routers' + colorama.Style.NORMAL)
print(' targets ' + colorama.Style.DIM + ' show current targets' + colorama.Style.NORMAL)
print(' backdoors ' + colorama.Style.DIM + ' show backdoors detected this sessions' + colorama.Style.NORMAL)
print(' devices ' + colorama.Style.DIM + ' show devices connected to backdoored routers'+ colorama.Style.NORMAL)
print(' exit/quit ' + colorama.Style.DIM + ' end session and exit program\n' + colorama.Style.NORMAL)
示例10: targets
# 需要导入模块: import colorama [as 别名]
# 或者: from colorama import Fore [as 别名]
def targets(self, *args):
"""
Show all target hosts
"""
pprint.pprint(self._targets)
print(colorama.Fore.GREEN + '\n[+] ' + colorama.Style.BRIGHT + colorama.Fore.RESET + str(len(self._targets)) + colorama.Style.NORMAL + ' targets ready to scan\n')
示例11: devices
# 需要导入模块: import colorama [as 别名]
# 或者: from colorama import Fore [as 别名]
def devices(self, *args):
"""
Show all discovered devices connected to vulnerable routers
"""
pprint.pprint(self._devices)
print(colorama.Fore.CYAN + '\n[+] ' + colorama.Style.BRIGHT + colorama.Fore.RESET + str(len(self._devices)) + colorama.Style.NORMAL + ' devices connected to vulnerable routers\n')
示例12: error
# 需要导入模块: import colorama [as 别名]
# 或者: from colorama import Fore [as 别名]
def error(msg, color='RED'):
print ('\n' + getattr(colorama.Fore, color) + colorama.Style.BRIGHT + '[-] ' + colorama.Fore.WHITE + 'Error - ' + colorama.Style.NORMAL + msg + '\n')
示例13: warn
# 需要导入模块: import colorama [as 别名]
# 或者: from colorama import Fore [as 别名]
def warn(msg, color='YELLOW'):
print ('\n' + getattr(colorama.Fore, color) + colorama.Style.BRIGHT + '[!] ' + colorama.Fore.WHITE + 'Warning - ' + colorama.Style.NORMAL + msg + '\n')
示例14: info
# 需要导入模块: import colorama [as 别名]
# 或者: from colorama import Fore [as 别名]
def info(msg, color='GREEN'):
print (getattr(colorama.Fore, color) + colorama.Style.BRIGHT + '[+] ' + colorama.Fore.WHITE + colorama.Style.NORMAL + msg)
示例15: prompt
# 需要导入模块: import colorama [as 别名]
# 或者: from colorama import Fore [as 别名]
def prompt(q, *args, **kwargs):
color = kwargs.get('color') if 'color' in kwargs else 'YELLOW'
if len(args):
return raw_input('\n' + colorama.Style.NORMAL + getattr(colorama.Fore, color) + "[?] " + colorama.Fore.WHITE + q + '? ' + '(' + '/'.join(args) + '): ' + colorama.Style.NORMAL).lower()
else:
return raw_input('\n' + colorama.Style.NORMAL + getattr(colorama.Fore, color) + "[?] " + colorama.Fore.WHITE + q + '? ' + colorama.Style.NORMAL).lower()