def color_cyan(text):
return Fore.CYAN+text+Fore.WHITE
python类CYAN的实例源码
def loopeth():
global clock
global old_price
global etheur_sell_price
# Current local time getter
clock = datetime.now().strftime('[%Y-%m-%d %H:%M]')
# Print LOOP ETH price
etheur_sell_price = get_etheur_sell_price()
etheur_buy_price = get_etheur_buy_price()
""" print colors
Fore.GREEN
Fore.RED
Fore.CYAN """
if old_price < etheur_sell_price:
logthis(clock+color_green(" ETH sell price raised: "
+ str(etheur_sell_price)+" EUR, ")
+ color_cyan('Balance: ')
+ str(get_etheur_balance(etheur_sell_price))+color_cyan(' EUR')
+ color_cyan(', BUY: ')
+ str(get_etheur_buy_price())+color_cyan(' EUR'))
elif old_price > etheur_sell_price:
logthis(clock+color_red(" ETH sell price dropped: "
+ str(etheur_sell_price)+" EUR, ")
+ color_cyan('Balance: ')
+ str(get_etheur_balance(etheur_sell_price))
+ color_cyan(' EUR')
+ color_cyan(', BUY: ')
+ str(get_etheur_buy_price())+color_cyan(' EUR'))
#else:
# Optional tick for the current price
#print clock+color_cyan(" ETH sell price: ")+str(etheur_sell_price),
color_cyan("EUR, ")+str(etheur_sell_price * CURR_EUR) \
+ color_cyan(" "+CURRENCY)
eth_monitor()
old_price = etheur_sell_price
threading.Timer(60, loopeth).start()
def render(self, separator):
return separator + '{}{}{} {}{}: {}{}'.format(
Fore.CYAN,
Reference.TOKEN,
Style.RESET_ALL,
Fore.GREEN,
Reference.TEXT,
self.url,
Style.RESET_ALL,
)
def NODE_INFO(IP_ADDR):
resp = urllib2.urlopen("https://onionoo.torproject.org/details?search=%s"%(IP_ADDR))
json_data = resp.read()
data = json.loads(json_data, object_pairs_hook=OrderedDict)
rp = bp = None
colors_lst = [Fore.GREEN + Style.BRIGHT, Fore.RED + Style.BRIGHT, Fore.YELLOW + Style.BRIGHT, Fore.WHITE + Style.BRIGHT, Fore.CYAN + Style.BRIGHT]
for key, value in data.items():
if key == "version" or key == "bridges":
continue
if key == "relays_published":
rp = value
if key == "bridges_published":
bp = value
if key == "relays":
for each in value:
for e_key, e_val in each.items():
#if lists
if e_key == "or_addresses":
print (Fore.GREEN + Style.BRIGHT + e_key.upper() + Fore.WHITE + Style.BRIGHT + " : " + ','.join(e_val))
continue
if e_key.lower() == "exit_policy_summary" or e_key.lower() == "exit_policy" or e_key.lower() == "exit_policy_v6_summary":
continue
if str(e_val).startswith("[") and str(e_val).endswith(']'):
print (Fore.GREEN + Style.BRIGHT + e_key.upper() + Style.RESET_ALL)
for ef in e_val:
print Fore.BLUE + Style.BRIGHT + "\t=> "+ ef + Style.RESET_ALL
continue
try:
print (Fore.GREEN + Style.BRIGHT + e_key.upper().replace('_',' ') + Style.RESET_ALL + " : " + \
Fore.WHITE + Style.BRIGHT + str(e_val))
except: pass
print
if (rp!=None and bp!= None):
print (Fore.GREEN + Style.BRIGHT + "RELAYS PUBLISHED" + Style.RESET_ALL + " : " + Fore.WHITE + Style.BRIGHT + rp)
print (Fore.GREEN + Style.BRIGHT + "BRIDGES PUBLISHED" + Style.RESET_ALL + " : " + Fore.WHITE + Style.BRIGHT + bp)
def parseLine(line):
severity = getSeverity(line)
# Add color based on severity
if 'severity' not in locals():
severity = 3
if severity == 0:
color = Style.DIM + Fore.WHITE
elif severity == 1:
color = Style.NORMAL + Fore.BLUE
elif severity == 2:
color = Style.NORMAL + Fore.CYAN
elif severity == 3:
color = Style.NORMAL + Fore.WHITE
elif severity == 4:
color = Style.NORMAL + Fore.RED
elif severity == 5:
color = Style.NORMAL + Fore.BLACK + Back.RED
else:
color = Style.NORMAL + Fore.BLACK + Back.YELLOW
# Replace html tab entity with actual tabs
line = clearTags(line)
line = line.replace('	', "\t")
return color + line + Style.RESET_ALL
def send(self, str, mode):
if str: print(Back.CYAN + str + Style.RESET_ALL)
if str and mode == 'hex':
print(Fore.CYAN + conv().hex(str, ':') + Style.RESET_ALL)
# show recv commands (debug mode)
def info(self, message):
print(Fore.CYAN + "[INFO] " + self.timestamp() + " " +
message.encode('ascii', 'ignore').decode('ascii')
+ Fore.RESET)
def member(self, message):
print(Fore.CYAN + "[MEMBER] " + self.timestamp() + " " +
message.encode('ascii', 'ignore').decode('ascii')
+ Fore.RESET)
def color_debug(message, logger_name = "root"):
__log(LEVEL_DEBUG, '%s%s%s'%(Fore.CYAN, message, Fore.RESET), logger_name)
def Host_Discovery():
live_hosts=[]
a=str(raw_input(Fore.CYAN +"\nEnter network octects (net id) of ip e.g 192.168.10.*: "+Fore.RESET))
if a=='' or a is None or a.isalpha():
print Fore.RED+"Enter correct input...!!!"+Fore.RESET
return
else:
print Fore.GREEN + "\n\t\tLive Hosts are....."+Fore.RESET
ans,unans=arping(a,verbose=False)
print Fore.GREEN+"\n IP ADDRESS\t\t MAC ADDRESS\n"+Fore.RESET
for i in ans:
print Fore.GREEN+i[0].pdst +'\t\t'+ i[1].src + Fore.RESET
if i[0].pdst not in live_hosts:
live_hosts.append(i[0].pdst)
print Fore.GREEN + "\n%s hosts up..." %len(live_hosts)+Fore.RESET
def OS_Detection():
targetip=str(raw_input( Fore.CYAN +"\nEnter Target IP: " +Fore.RESET))
print ''
if targetip == '' or targetip is None:
print Fore.RED+"Enter correct input...!!!"+Fore.RESET
if targetip==self_ip:
print Fore.GREEN+EX+"%s belongs to Linux family..." % targetip + Fore.RESET
return
ans,unans=arping(targetip,timeout=2,verbose=False)
ip=IP()
ip.dst=targetip
icmp=ICMP()
icmp.type=8
icmp.code=0
z=sr1(ip/icmp,timeout=10,verbose=False)
if z is None and len(ans)==1:
print Fore.YELLOW+"Host is up...but seems to be filtered..." + Fore.RESET
elif z is None and len(ans)==0:
print Fore.RED+"Host is unreachable..."+Fore.RESET
else:
if z.ttl==128:
print Fore.GREEN+"%s belongs to Windows family..." % targetip + Fore.RESET
elif z.ttl==64:
print Fore.GREEN+"%s belongs to Linux family..." % targetip + Fore.RESET
elif z.ttl==56:
print Fore.GREEN+"%s belongs to Mac family..."% targetip + Fore.RESET
else:
print Fore.GREEN+"Unknown OS..." + Fore.RESET
def Brute_Force():
global flag1
ip=str(raw_input( Fore.CYAN +"Enter ip: " + Fore.RESET ))
useroption=str(raw_input( Fore.CYAN +"Known User??(Enter y or n): "+Fore.RESET))
passwdoption=str(raw_input( Fore.CYAN +"Known Dictionary??(Enter y or n): "+Fore.RESET))
if useroption =='y' and passwdoption =='y':
username=str(raw_input( Fore.CYAN +"Enter known username: "+Fore.RESET))
filename=str(raw_input( Fore.CYAN +"Enter password file: "+Fore.RESET))
ready_Dict(ip,username,filename)
elif useroption == 'n' and passwdoption == 'y':
usernames=["root","admin","administrator","god","webmaster","webadmin",
"godfather","ditiss","tiger","matriux","hackit","ghost"]
filename=str(raw_input( Fore.CYAN +"Enter password file: " ))
for username in usernames:
if flag1 == 0:
bt=threading.Thread(ready_Dict(ip,username,filename))
bt.start()
else:
flag1=0
return
elif useroption == 'y' and passwdoption == 'n':
username=str(raw_input( Fore.CYAN +"Enter known username: "+Fore.RESET))
Gen_Dict()
ready_Dict(ip,username,"tempwlist")
elif useroption =='n' and passwdoption =='n':
usernames=["root","admin","administrator","god","webmaster","webadmin",
"godfather","ditiss","tiger","matriux","hackit","ghost"]
Gen_Dict()
for username in usernames:
if flag1 == 0:
bt1=threading.Thread(ready_Dict(ip,username,"tempwlist"))
bt1.start()
else:
flag1=0
return
def main():
print Fore.GREEN + " #### ## ########## "
print " ## ## ## ##### ####### ## ## ##### ##### ##### ##### "
print " ## ## ## # # ## # # # # # # # # # "
print " ## ## ## #### # ## ## ###### ##### ##### ### ##### "
print " ## ## ## # # ## # # # # # # # "
print " ## #### ##### # ######### # # # # ##### # ## " + Fore.RESET
while(True):
try:
print Fore.CYAN + "\n1.Hosts Discovery" +Fore.RESET
print Fore.CYAN + "2.Ports Scanning" +Fore.RESET
print Fore.CYAN+"3.OS Detection" + Fore.RESET
print Fore.CYAN+"4.Brute Force SSH" +Fore.RESET
print Fore.YELLOW+"Press ctrl+c to exit..." +Fore.RESET
opt=int(input(Fore.CYAN+"\nEnter choice: "+Fore.RESET))
if opt==1:
Host_Discovery()
elif opt==2:
tcp_scan()
elif opt==3:
OS_Detection()
elif opt==4:
Brute_Force()
else:
print Fore.RED+"\nEnter correct choice...!!" +Fore.RESET
except KeyboardInterrupt:
print Fore.RED+"\nABORTED PROGRAM....!!" +Fore.RESET
sys.exit(0)
except:
print Fore.RED+"\nEnter correct choice...!!" +Fore.RESET
def print_blue(*args):
""""""
raw = str(args)
init(autoreset=True)
print((Fore.CYAN + raw))
#----------------------------------------------------------------------
def print_cyan(*args):
""""""
raw = str(args)
init(autoreset=True)
print((Fore.CYAN + raw))
#----------------------------------------------------------------------
def print_blue(*args):
""""""
raw = str(args)
init(autoreset=True)
print((Fore.CYAN + raw))
#----------------------------------------------------------------------
def print_cyan(*args):
""""""
raw = str(args)
init(autoreset=True)
print((Fore.CYAN + raw))
#----------------------------------------------------------------------
def __init__(self):
self.colors = {'red':Fore.RED,'green':Fore.GREEN,'cyan':Fore.CYAN,'yellow':Fore.LIGHTYELLOW_EX,'magenta':Fore.MAGENTA,'bold':Style.BRIGHT,'reset':Style.RESET_ALL}
self.translator = Translator()
self.select_languages = "tr"
self.database = "dictionary.db"
self.connection = sqlite3.connect(self.database)
self.cursor = self.connection.cursor()
self.columns = {'isim':'i_anlam','fiil':'f_anlam','zarf':'z_anlam','edat':'e_anlam','baglac':'b_anlam','sifat':'s_anlam','zamir':'zz_anlam'}
self.names2 = {'isim':'isim','zarf':'zarf','ba?laç':'baglac','s?fat':'sifat','zamir':'zamir','fiil':'fiil','edat':'edat'}
self.c_word = ""
self.c_word_last = ""
self.c_word_new = ""
def __init__(self):
from colorama import init, Fore, Style
init(autoreset=True)
self.colors = {'red': Fore.RED,
'yellow': Fore.YELLOW,
'green': Fore.GREEN,
'white': Fore.WHITE,
'cyan': Fore.CYAN,
'reset': Style.RESET_ALL
}
def print_cyan(*objs):
print_color(Fore.CYAN,*objs)