def helpInfo(): printc.printf( """++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -m MD5 encryption -s SH1 encryption --h Show help information -b64 Base64 encode -b32 Base32 encode -b16 Base16 encode -db64 Base64 decode -db32 Base32 decode -db16 Base16 decode -urlen URL encode -urlde URL decode -unien Unicode Encode Example: -unien "A" Result: \\u0061 -unide Unicode Decode Example: -unide "\\u0061" Result: A -hten HTML Encode Example: -hten "A" Result: a -htde HTML Decode Example: -htde "a" Result: A -bin Binary To Decimal -octal Octal Decimal to Decimal -hex Hexadecimal to Decimal -dbin Decimal To Binary -doctal Decimal to Octal -dhex Decimal to Hexadecimal -ord Letter To ASCII attention Example: -ord asdfasfa -ord="dfafs afasfa asfasf" -chr ASCII To Letters Example: -chr 105 -chr = "102 258 654" -roten Rot Encode Example: -roten dafsdfa -offset 13 Means rot_13 Encode -rotde Rot Decode Example: -rotde dafsdfa -offset 13 Means rot_13 Decode -offset Rot Encode or Decode Offset -gqr Generate QRcode images Example: -gqr = "I love you" -pqr Parse QRcode images Example: -pqr = "C:\QR.png" ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++""", "skyblue")
def scan_all_hosts_from_file(hosts_file_add): try: global openNum, nThread, PortList tool = Tool() f = open(hosts_file_add, "rb") #从文件中读取主机 #lines = f.readlines()#逐条读取主机 content = str(f.read()) hosts_content = re.findall("[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+", content) start_time = time.time() ThreadList = [] hostLists = [] #存放扫描范围的主机 hostLists = hosts_content #lines if len(PortList) > 2: SingleQueue = tool.GetQueue(hostLists) while not SingleQueue.empty(): ip = SingleQueue.get() tool.scan_host_ports(ip) else: SingleQueue = tool.GetQueue(hostLists) for i in range(0, nThread): t = scanHosts(0, SingleQueue) ThreadList.append(t) for t in ThreadList: t.start() for t in ThreadList: t.join() s1 = '[*] The scanning is finished' #s2 = '[*] A total of %d hosts are open' % (openNum) s3 = '[*] Time cost :' + str((time.time() - start_time)) + ' s' printc.printf(s1, "skyblue") #printc.printf(s2, "skyblue") printc.printf(s3, "skyblue") except: print("结束")
def helpInfo(): helpInformaiton = """ _ _ _ _ _ _ _ _ (c).-.(c) (c).-.(c) (c).-.(c) (c).-.(c) / ._. \\ / ._. \\ / ._. \\ / ._. \\ __\\( Y )/__ __\\( Y )/__ __\\( Y )/__ __\\( Y )/__ (_.-/'-'\\-._)(_.-/'-'\\-._)(_.-/'-'\\-._)(_.-/'-'\\-._) || S || || C || || A || || N || _.' `-' '._ _.' `-' '._ _.' `-' '._ _.' `-' '._ (.-./`-`\\.-.)(.-./`-'\\.-.)(.-./`-'\\.-.)(.-./`-'\\.-.) `-' `-' `-' `-' `-' `-' `-' `-' Author:ba1ma0 E-mail:[email protected] Usage: -host To scan the open ports of the Host Default scanning ports are most usual ports -sh Specific Host Detective Example: -sh 127.0.0.1 -ah All alive Hosts .Find all alive hosts Example: -ah 192.168.1.1-255 Default ports is 80 443 -t Threads(1-200) Default is 80 -r Read hosts file Example: -r "hosts.txt" -p Ports Example: -p="80,8080,443" or -p 1-255 default are most usual ports -o Output file address Example: -o recoder.txt or -o D:\\recoder.txt -dir Scanning visible background directory Example: -dir http://127.0.0.1 -add Dictionary File Address Example: -dir http://127.0.0.1 -add C:\\dic.txt -sdn Subdomain names Example: -sdn baidu.com -types 3 -sdn pku.edu.cn -types 1 -pro Protocol Example: -pro https Default Protocol is http -types Using different dictionary txt file 1 2 3 means school gov company website,it can make the result more reliable -url Butian SRC list url Example: -url https://butian.net/Reward/pub -page 1-10 -page Butian SRC Pages Default is 10 -urldetect UrlDetect Example: -urldetect baidu.com or -urldetect urls.txt -ip Find ip information Example: -ip 127.0.0.1 or -ip ip.txt -help To show help information """ printc.printf(helpInformaiton, "yellow")
def unidecode(s): original = s temp = '' s = s.replace("\\u00", " 0x") s = s.split(" ") del s[0] for i in range(len(s)): if i < len(s) - 1: temp = temp + str(s[i]) + " " else: temp = temp + str(s[i]) s = temp s = tool.hexToDec(s) s = s.split(" ") temp = '' del s[0] for i in range(len(s)): if i < len(s) - 1: temp = temp + str(s[i]) + " " else: temp = temp + str(s[i]) s = temp s = tool.asciiToLett(s) info1 = "String: " + original info2 = "UnicodeDecode: " + s printc.printf(info1, "blue") printc.printf(info2, "green")
def split2List(s): p="\w+" try: return re.findall(p,s) except: msg="\n[-]您输入的数据好像不合法哦" printc.printf(msg,'red')
def run(self): global lock, count domain = self.domain while not self.subdomains.empty(): subdomain = self.subdomains.get() # domain=httpOrHttps(domain)+"://" +subdomain+"."+domain domain = httpOrHttps( self.protocol) + "://" + subdomain + "." + domain # print(domain) #lock.acquire() try: res = requests.get(domain, timeout=2) result = change2standard(res) # print(result) # if ifExist(res)==True: if (re.findall(self.p, result)): title = (re.findall(self.p, result)[0]) elif re.findall(self.p1, result): title = (re.findall(self.p1, result)[0]) else: title = ' ' title = title.replace("\n", "") title = title.replace("\r", "") title = title.replace("\t", "") title = title.replace(" ", '') count = count + 1 msg1 = "[+] " + domain + " " + title printc.printf(msg1, 'green') except: # msg2=domain+"不可访问" # printc.printf(msg2,'red') pass
def run(self): global openNum, lock openedPort = '' isAlive = False try: #lock.acquire() while not self.SingleQueue.empty(): host = self.SingleQueue.get() for port in ports: if (self.ping_hosts(host, port) == True): isAlive = True openedPort = port #lock.release() break lock.acquire() if (isAlive == True): openNum += 1 host = host.replace("\n", '') s = "[+] " + str(host) + ":" + str(openedPort) + " " + "存活" printc.printf(s, "green") isAlive = False lock.release() else: lock.release() except: pass
def run(self): global Queue, lock, OpenHost tool = Tool() while not Queue.empty(): try: url = self.host + "/" + str(Queue.get()) res = tool.Requests(url) lock.acquire() try: if tool.visible(res) == True: s1 = "[+]:" + " Exist " + url printc.printf(s1, "green") # print(threading.get_ident())#线程ID lock.release() OpenHost.append(s1) # break else: s2 = "[-]:" + " notExist " + url #printc.printf(s2, "cyan") print(s2) # print(threading.get_ident())#线程ID lock.release() except: pass except: msg1 = "[-]:Trying to connect again..." printc.printf(msg1, 'red') pass
def importModules(): try: # import PIL from PIL import Image except: msg="\n[-] 检测到你还没有安装依赖包PIL,请使用命令pip install PIL 进行安装" printc.printf(msg,'red')
def showChangeInfo(path): msg = """ ______ _ _ _ _ | ____(_| | (_| | | |__ _| | ___ _ __ ___ ___ _ __ _| |_ ___ _ __ | __| | | |/ _ \ | '_ ` _ \ / _ \| '_ \| | __/ _ \| '__| | | | | | __/ | | | | | | (_) | | | | | || (_) | | |_| |_|_|\___| |_| |_| |_|\___/|_| |_|_|\__\___/|_| """ printc.printf(msg, 'yellow') class LoggingEventHandler(FileSystemEventHandler): """Logs all the events captured.""" #文件被移动时显示白色 def on_moved(self, event): super(LoggingEventHandler, self).on_moved(event) t = time.strftime("%Y-%m-%d %X", time.localtime()) what = 'directory' if event.is_directory else 'file' msg = t + " - Moved %s: from %s to %s" % (what, event.src_path, event.dest_path) print(msg) #文件创建时显示绿色(green) def on_created(self, event): super(LoggingEventHandler, self).on_created(event) t = time.strftime("%Y-%m-%d %X", time.localtime()) what = 'directory' if event.is_directory else 'file' msg = t + " - Created %s: %s" % (what, event.src_path) printc.printf(msg, 'green') #文件删除时显示红色(red) def on_deleted(self, event): super(LoggingEventHandler, self).on_deleted(event) t = time.strftime("%Y-%m-%d %X", time.localtime()) what = 'directory' if event.is_directory else 'file' msg = t + " - Deleted %s: %s" % (what, event.src_path) printc.printf(msg, 'red') #文件修改时显示蓝色(blue) def on_modified(self, event): super(LoggingEventHandler, self).on_modified(event) t = time.strftime("%Y-%m-%d %X", time.localtime()) what = 'directory' if event.is_directory else 'file' msg = t + " - Modified %s: %s" % (what, event.src_path) printc.printf(msg, 'blue') # path = sys.argv[1] if len(sys.argv) > 1 else '.' event_handler = LoggingEventHandler() observer = Observer() observer.schedule(event_handler, path, recursive=True) observer.start() try: while True: time.sleep(1) except KeyboardInterrupt: observer.stop() observer.join()
def helpInfo(): printc.printf( """ $$\ $$\ $$ | $$ | $$$$$$\ $$$$$$\ $$$$$$\ $$ | $$$$$$$\ \_$$ _| $$ __$$\ $$ __$$\ $$ |$$ _____| $$ | $$ / $$ |$$ / $$ |$$ |\$$$$$$\ $$ |$$\ $$ | $$ |$$ | $$ |$$ | \____$$\ \$$$$ |\$$$$$$ |\$$$$$$ |$$ |$$$$$$$ | \____/ \______/ \______/ \__|\_______/ Author:ba1ma0 E-mail:[email protected] Encoding&Decoding: -m MD5 encryption -s SH1 encryption -help Show help information -b64 Base64 encode -b32 Base32 encode -b16 Base16 encode -db64 Base64 decode -db32 Base32 decode -db16 Base16 decode -urlen URL encode -urlde URL decode -unien Unicode Encode Example: -unien "A" Result: \\u0061 -unide Unicode Decode Example: -unide "\\u0061" Result: A -hten HTML Encode Example: -hten "A" Result: a -htde HTML Decode Example: -htde "a" Result: A -bin Binary To Decimal -octal Octal Decimal to Decimal -hex Hexadecimal to Decimal -dbin Decimal To Binary -doctal Decimal to Octal -dhex Decimal to Hexadecimal -roten Rot Encode Example: -roten dafsdfa -offset 13 Means rot_13 Encode -rotde Rot Decode Example: -rotde dafsdfa -offset 13 Means rot_13 Decode Useful: -ip2int Convert IP to Decimal Example: -ip2int 127.0.0.1 -int2ip Convert int to IP Example: -int2ip 2130706433 -ord Letter To ASCII attention Example: -ord asdfasfa -ord "dfafs afasfa asfasf" -chr ASCII To Letters Example: -chr 105 -chr "102 258 654" -offset Rot Encode or Decode Offset -rename Rename files with 1 same extension to new one Example : -rename C:\\test -old_ext txt -new_ext php -old_ext Old file extension -new_ext New file extension -gqr Generate QRcode images Example: -gqr "I love you" -pqr Parse QRcode images Example: -pqr "C:\\QR.png" -add File address Example: -add "C:\\1.txt" -delete Delete File's repeated info Example: -delete "C:\\1.txt" -r2i Convert RGB txt to Images Example: -r2i "C:\\rgb.txt" -x 100 -y 200 -monitor Directory file changes monitor Example: -monitor "C:\directory" -x X -y y """, "yellow")
def b32ToString(s): origin = tools.change2Str(s) decode = base64.b32decode(s) decode = tools.change2Str(decode) info1 = '\nBase32:' + origin info2 = 'Base32 decode:' + decode printc.printf(info1, 'blue') printc.printf(info2, 'green')
def sh1(s): original = s sh = hashlib.sha1() s = s.encode(encoding='utf-8') info1 = 'Original:' + original info2 = 'SH1 Encryption:' + sh.hexdigest() printc.printf(info1, 'blue') printc.printf(info2, 'green')
def b16ToString(s): origin = tools.change2Str(s) s = tools.change2Bytes(s) decode = base64.b16decode(s) encode = tools.change2Str(s) info1 = '\nBase16:' + s info2 = 'Base16 decode:' + decode printc.printf(info1, 'blue') printc.printf(info2, 'green')
def md5(s): original = s md = hashlib.md5() s = s.encode(encoding='utf-8') md.update(s) info1 = 'Original:' + original info2 = 'Md5 Encryption:' + md.hexdigest() printc.printf(info1, 'blue') printc.printf(info2, 'green')
def stringToB16(s): origin = tools.change2Str(s) s = tools.change2Bytes(s) encode = base64.b16encode(s) encode = tools.change2Str(encode) info1 = '\nOriginal:' + origin info2 = 'Base16 encode:' + encode printc.printf(info1, 'blue') printc.printf(info2, 'green')
def b64ToString(s): origin = s s = tools.change2Bytes(s) decode = base64.b64decode(s) decode = tools.change2Str(decode) info1 = '\nBase64:' + origin info2 = 'Base64 decode:' + decode printc.printf(info1, 'blue') printc.printf(info2, 'green')
def lettToASCII(s): result = '' for i in s: result = result + str(ord(i)) + ' ' info1 = 'Letters:' + s info2 = 'ASCII :' + result printc.printf(info1, 'blue') printc.printf(info2, 'green')
def hexToDec(s): original = s #s = s.split(" ") s = tools.split2List(s) result = '' for i in s: result = result + " " + str(int(i, 16)) info1 = '\nHex :' + str(original) info2 = 'Decimal :' + str(result) printc.printf(info1, 'green') printc.printf(info2, 'green')
def importModules(): try: import json except: msg1 = "\n[-] 检测到您还没有安装Python3的json依赖包,请使用 pip install json 安装\n" printc.printf(msg1, 'red') try: import requests except: msg1 = "\n[-] 检测到您还没有安装Python3的requests依赖包,请使用 pip install requests 安装\n" printc.printf(msg1, 'red')
def uniencode(s): original = s s = tool.lettToASCII(s) s = tool.decToHex(s) s = " " + s s = s.replace(" 0x", "\\u00") info1 = "String : " + original info2 = "UnicodeEncode: " + s printc.printf(info1, "blue") printc.printf(info2, "green")
def asciiToLett(s): list = s.split(' ') result = '' for i in list: i = int(i) result = result + chr(i) info1 = 'ASCII :' + s info2 = 'Letters :' + result printc.printf(info1, 'blue') printc.printf(info2, 'green')
def hexToDec(s): original = s s = s.split(" ") result = '' for i in s: result = result + " " + str(int(i, 16)) info1 = 'Hex :' + str(original) info2 = 'Decimal :' + str(result) printc.printf(info1, 'blue') printc.printf(info2, 'green')
def urlEncode(s): encodeString = '' for i in s: if (isVisibleCharacter(i)): encodeString = encodeString + visibleCharacter[i] else: encodeString = encodeString + urllib.parse.quote(i) info1 = '\nOriginal:' + s info2 = 'URL encode:' + encodeString printc.printf(info1, 'green') printc.printf(info2, 'green')
def decToHex(s): original = s #s = s.split(" ") s = tools.split2List(s) result = '' for i in s: i = int(i) result = result + " " + hex(i) info1 = '\nDecimal :' + str(original) info2 = 'Hex :' + str(result) printc.printf(info1, 'green') printc.printf(info2, 'green')
def asciiToLett(s): #list=s.split(' ') list = tools.split2List(s) result = '' for i in list: i = int(i) result = result + chr(i) info1 = '\nASCII :' + s info2 = 'Letters :' + result printc.printf(info1, 'green') printc.printf(info2, 'green')
def decToHex(s): original = s s = s.split(" ") result = '' for i in s: i = int(i) result = result + " " + hex(i) info1 = 'Decimal :' + str(original) info2 = 'Hex :' + str(result) printc.printf(info1, 'blue') printc.printf(info2, 'green')
def helpInfo(): helpInformaiton = """Usage: -host To scan the open ports of the Host -sh Specific Host Detective Example: -sh 127.0.0.1 -ah All alive Hosts Find all alive alive hosts Example: -ah 192.168.1.1-255 -t Threads(1-200) Default is 80 -r Read hosts file Example: -r "hosts.txt" -p Port ping special ports,It was used to detective alive hosts Example: -p="80,8080,443" default was 80 443 -o Output file address Example: -o recoder.txt or -o D:\\recoder.txt -help To show help information """ printc.printf(helpInformaiton, "blue")
def htmlencode(s): original = s temp = "" s = tool.lettToASCII(s) s = s.split() for i in range(len(s)): temp = temp + "&#" + str(s[i]) + ";" s = temp info1 = "Original String: " + original info2 = "HTML Encoding: " + s printc.printf(info1, "blue") printc.printf(info2, "green")
def parseQR(filename): #filename=input("请输入二维码照片路径:") img = Image.open(filename) ran = int(random.random() * 100000) img.save('%s%s.jpg' % (os.path.basename(filename).split('.')[0], ran)) zx = zxing.BarCodeReader() data = '' zxdata = zx.decode('%s%s.jpg' % (os.path.basename(filename).split('.')[0], ran)) info1 = "二维码路径:" + filename info2 = "二维码详情:" + str(zxdata) printc.printf(info1, "blue") printc.printf(info2, "green")