def get_args(): """Returns parsed CL arguments """ # define CL arguments aparser = argparse.ArgumentParser( description="Distributed Filesystem Client.") aparser.add_argument("--nameserver", "-n", required=True, help="IP address & port of name server") aparser.add_argument( "--fileinfo", "-f", required=True, help="SURL of file to be downloaded; Protocol in URL is always fsp") args = aparser.parse_args() # validate nameserver address addr = args.nameserver.split(":") if (len(addr) < 2) or (not addr[1].isdigit()): Exit("ERROR: Invalid nameserver address") try: socket.inet_aton(addr[0]) except socket.error: Exit("ERROR: Invalid nameserver address") # validate fileserver SURL surl = re.split("://|/", args.fileinfo, maxsplit=2) if (len(surl) < 3) or (surl[0] != "fsp"): Exit("ERROR: Invalid SURL of file server") return args
def main(): """_____get nameserver & file(s) options_____""" args = get_args() ns_ip, ns_port = args.nameserver.split(":") ns_port = int(ns_port) protocol, fs_name, filename = re.split("://|/", args.fileinfo, maxsplit=2) """_____get IP address & port of file server_____""" # send request to nameserver using UDP with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as nserver: try: nserver.sendto(b"WHEREIS " + str.encode(fs_name), (ns_ip, ns_port)) nserver.settimeout(2) data, _ = nserver.recvfrom(ns_port) except socket.timeout: nserver.close() Exit("ERROR: Failed to reach nameserver") # parse reply status, fs_ip, fs_port = re.split(" |:", data.decode()) if status != "OK": Exit("ERROR: Failed to find server \"%s\"" % fs_name) fs_port = int(fs_port) """_____get file(s) from file server_____""" if filename == "*": get_all((fs_ip, fs_port), fs_name) else: get((fs_ip, fs_port), fs_name, filename)
def menuchoose3(self, system): self.header() print("") print(system) print("Type ctrl+c to go back") print("Please enter the name of the game") while True: try: game = raw_input("=> ") break except KeyboardInterrupt: self.menuchoose2(system) except: print("Invalid data") print("") #C = Crawler(game, system) try: C = Crawler(game, system) except: print("Unknown error") self.enter() Exit() if len(C.games) <= 75: counter = 1 for x in C.games: print("%s) %s" %(counter, x[1])) counter += 1 print("%s) Back" %(counter)) elif len(C.games) > 75: print("Too many listings, try to refine your search") self.menuchoose3(system) self.enter() Exit() choice = self.getchoice(1, counter) counter = 1 ## if C.multi == 0: ## for x in C.games: ## if choice == counter: ## self.menudownload(x, system) ## counter += 1 ## elif C.multi == 1: ## for x in C.games: ## if choice == counter: ## self.menumultidownload(x, system) ## counter += 1 for x in C.games: if choice == counter: self.menumultidownload(x, system) counter += 1 if choice == counter: self.menuchoose2(system)
def Run(*self, Source_IP, Victim_IP, Source_Port, Victim_Ports, Count, Message): from scapy.all import sendp as Send, TCP as tcp, IP as ip from time import sleep as Sleep from sys import exit as Exit print("This Operation Needs Administrator Permission") print("Running UAC") Victim_Ports = Victim_Ports.split() if Count != "-1": print("Press Ctrl + C To Stop The Process") for i in range(0, Count): try: IP = ip(src=Source_IP, dst=Victim_IP) TCP = tcp(sport=Source_Port, dport=([Victim_Port for Victim_Port in Victim_Ports])) Packet = IP / TCP / Message Send(Packet) print( "Send Packet To Target {} from IP {} And Port {} To Port {}" .format(Victim_IP, Source_IP, Source_Port, Victim_Port)) except KeyboardInterrupt: print( "Already Send {} Packets To Target {} from IP {} And Port {} To Port {}" .format(i, Victim_IP, Source_IP, Source_Port, Victim_Port)) break Sleep(2) Exit(0) else: i = 0 while True: try: print("Press Ctrl + C To Stop The Process") IP = ip(source_IP=Source_IP, destination=Victim_IP) TCP = tcp( srcport=Source_Port, dstport=([Victim_Port for Victim_Port in Victim_Ports])) Packet = IP / TCP / Message Send(Packet) print( "Send Packet To Target {} from IP {} And Port {} To Port {}" .format(Victim_IP, Source_IP, Source_Port, Victim_Port)) i += 1 except KeyboardInterrupt: print( "Already Send {} Packets To Target {} from IP {} And Port {} To Port {}" .format(i, Victim_IP, Source_IP, Source_Port, Victim_Port)) Sleep(2) Exit(0)
def get_all(address, servername): """Copies filesystem of files & non-empty dirs of specified server """ # connect with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as fserver: try: fserver.connect(address) # get index file fserver.send( b"GET %s FSP/1.0\r\nHostname: %s\r\nAgent: xbartk07\r\n\r\n" % ("index".encode(), servername.encode())) fserver.settimeout(2) # get file list files = [ x for x in recvall(fserver).decode().split("\r\n") if x != "" ] except socket.timeout: fserver.close() Exit("ERROR: Failed to reach nameserver") for file in files: # create path for file Path(dirname(file)).mkdir(parents=True, exist_ok=True) # get file get(address, servername, file)
def airDumpParse(self,cleanedDump): """ Function takes parsed dump file list and does some more cleaning. Returns a list of 2 dictionaries (Clients and APs) """ try: #some very basic error handeling to make sure they are loading up the correct file try: apStart = cleanedDump.index('BSSID, First time seen, Last time seen, Channel, Speed, Privacy, Power, # beacons, # data, LAN IP, ESSID') except Exception: apStart = cleanedDump.index('BSSID, First time seen, Last time seen, channel, Speed, Privacy, Cipher, Authentication, Power, # beacons, # IV, LAN IP, ID-length, ESSID, Key') del cleanedDump[apStart] #remove the first line of text with the headings try: stationStart = cleanedDump.index('Station MAC, First time seen, Last time seen, Power, # packets, BSSID, Probed ESSIDs') except Exception: stationStart = cleanedDump.index('Station MAC, First time seen, Last time seen, Power, # packets, BSSID, ESSID') except Exception: print "You Seem to have provided an improper input file please make sure you are loading an airodump txt file and not a pcap" Exit(1) del cleanedDump[stationStart] #Remove the heading line clientList = cleanedDump[stationStart:] #Splits all client data into its own list del cleanedDump[stationStart:] #The remaining list is all of the AP information apDict = self.apTag(cleanedDump) clientDict = self.clientTag(clientList) resultDicts = [clientDict,apDict] #Put both dictionaries into a list return resultDicts
def airDumpOpen(self,file): """ Takes one argument (the input file) and opens it for reading Returns a list full of data """ try: openedFile = open(file, "r") except TypeError: print("Missing Airodump-ng file") Exit(1) except IOError: print("Error Airodump File",file,"does not exist") Exit(1) cleanedData = [line.rstrip() for line in openedFile] openedFile.close() return cleanedData
def privcheck(): x = execute("whoami").read() if "root" in x: pass if "root" not in x: print "Run as root" z = raw_input("Run Data Analytics: [Y/N]") if "Yy" in z: pass if "Nn" in z: Exit()
def menudownload(self, game, system): self.header() print("") print("Downloading %s for the %s" %(game[1], system)) print("Note, depending on the size of the game, it may take a while") print("Please be patient") DL = DownloadLink(game[0], system) print("Download complete, it should be a .rar or a .7z") print("Have fun!") self.enter() Exit()
def ssl_check(ip): try: import grc z = grc.fetch_server_certificate(ip,443) print z except KeyboardInterrupt: z = raw_input("Quit Scan [Y/N]: ") if "Yy" in z: Exit() if "Nn" in z: pass except OSError: print "Fetch Error!" pass
def recvall(sock): """Returns complete message of reply from server as string """ buf_size = 4096 # receive first packet data = sock.recv(buf_size) # split to: [Status, Length, FileContents] tmp = re.split(b"Length:\s*|\r\n\r\n", data) if b"Not Found" in tmp[0]: Exit("ERROR: File not found") elif b"Success" not in tmp[0]: Exit("ERROR: Failed to get file from server") if len(tmp) < 2: # header + empty message tmp.append(b"") received = [tmp[2]] remaining = int(tmp[1].decode()) - len(tmp[2]) while remaining > 0: data = sock.recv(min(remaining, buf_size)) received.append(data) remaining -= len(data) return b"".join(received)
def ssh_check(ip): try: r = redis.StrictRedis(host='localhost', port=6379, db=0) import GIS GIS.GIS(ip) x = execute("ssh-keyscan {0}".format(ip)).read() r.set(name=ip, value=x) print x return x except KeyboardInterrupt: z = raw_input("Quit Scan [Y/N]: ") if "Yy" in z: Exit() and exit() if "Nn" in z: pass
def airDumpOpen(self, file): """ Takes one argument (the input file) and opens it for reading Returns a list full of data """ try: openedFile = open(file, "r") except IOError: print "Error Airodump File", file, "does not exist" Exit(1) data = openedFile.xreadlines() cleanedData = [] for line in data: cleanedData.append(line.rstrip()) openedFile.close() return cleanedData
def menu1(self): self.header() print("""\ 1) Search for roms 2) Catalog games 3) Copyright 4) Help 5) Quit """) choice = self.getchoice(1, 5) if choice == 1: self.menu2() elif choice == 2: self.catalog() elif choice == 3: self.copyright() elif choice == 4: self.help() elif choice == 5: Exit()
def get(address, servername, filename): """Copies specified file from given server """ # connect with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as fserver: try: fserver.connect(address) fserver.send( b"GET %s FSP/1.0\r\nHostname: %s\r\nAgent: xbartk07\r\n\r\n" % (filename.encode(), servername.encode())) fserver.settimeout(2) # get contents contents = recvall(fserver) except socket.timeout: fserver.close() Exit("ERROR: Failed to reach nameserver") # output contents to file file = open(filename, "wb") file.write(contents) file.close()
cherrypy.tree.graft(app) cherrypy.engine.start() cherrypy.engine.block() def main(**kwargs): app = DjangoApplication() app.run(**kwargs) class server(Daemon): def run(self): main(host='0.0.0.0', port=int(settings.PORT)) if __name__ == '__main__': daemon = server('/tmp/apkstore.pid', ) if len(argv) == 2: if argv[1] == 'start': daemon.start() elif argv[1] == 'stop': daemon.stop() elif argv[1] == 'restart': daemon.restart() else: Exit('Use: apkstore start|stop|restart') else: main(host='0.0.0.0', port=int(settings.PORT)) #Exit('Invalid params number\nUse: apkstore start|stop|restart')
print(str(k) + ' => ' + str(v)) pass work() return 0 except KeyboardInterrupt: ### handle keyboard interrupt ### return 0 except Exception as e: if DEBUG: raise (e) pass indent = len(program_name) * " " from sys import stderr stderr.write(program_name + ": " + repr(e) + "\n") stderr.write(indent + " for help use --help") return 2 pass if __name__ == "__main__": if DEBUG: from sys import argv argv.append("-n 700") pass from sys import exit as Exit Exit(main()) pass
app = cherrypy.wsgi.VirtualHost(app, self.domains) cherrypy.tree.graft(app) cherrypy.engine.start() cherrypy.engine.block() def main(**kwargs): app = DjangoApplication() app.run(**kwargs) class server(Daemon): def run(self): main(host='0.0.0.0',port=int(settings.PORT)) if __name__ == '__main__': daemon = server('/tmp/apkstore.pid',) if len(argv) == 2: if argv[1] == 'start': daemon.start() elif argv[1] == 'stop': daemon.stop() elif argv[1] == 'restart': daemon.restart() else: Exit('Use: rcserver start|stop|restart') else: main(host='0.0.0.0',port=int(settings.PORT)) #Exit('Invalid params number\nUse: rcserver start|stop|restart')
def __print(self, keluar=False): print(self.text) if keluar: Exit()
GenshinLyrePlayer.Raise(Home.Name) for Screen in GenshinLyrePlayer.Screens: GenshinLyrePlayer.Screens[Screen].place(anchor= 'n', relx= 0.5, rely = 0, relheight = 1, relwidth = 1) else: #if the user has no admin rights self.AlternativeStart() #show a warning to restart with admin rights def AlternativeStart(self): #this function is a warning to restart as admin self.title('Warning') #setting a different title Warning = Label(self, text = 'Restart this program as', font = ('Courier', 24)) #warning label first line WarningBottom = Label(self, text = 'Admin', font = ('Courier',24)) #warning label second line Warning.pack() #automatically position the first label WarningBottom.pack() #automatically positioning the second label self.update() #update of the screen (needed for position) X = int((self.winfo_screenwidth() - Warning.winfo_width()) / 2) #setting the starting x as center of the screen Y = int((self.winfo_screenheight() - Warning.winfo_height() * 2) / 2) #setting the starting y as center of the screen Pos = '+' + str(X) + '+' + str(Y) #formatting the position self.geometry(Pos) # setting size and position of the window def Raise(ScreenName = str()): #raising the selected screen to the top GenshinLyrePlayer.Screens[ScreenName].tkraise() #accessing the screen from the dictionary and raising it GenshinLyrePlayer.Screens[ScreenName].Refresh() #update the page for eventual changes if __name__ == '__main__': Application = GenshinLyrePlayer() #app initialization Application.mainloop() Exit(0)