EG Information
Training Missions
Knowledge Bank
Pimp Us Out!
Has Enigma Group Helped You? Then Help Us By Advertising For Us. Place One Of The Following Images On Your Site And Create A Link Back To Enigma Group.
|
| |
Affiliates
|
|
Enigma Group's Code Bank
Simple Unix IRC ClientBy: Arameus - Date Submitted: 2011-05-20 12:13:22 #!/usr/bin/python import socket # needed to connect to server's, send data, and receive data import re # used for formatting other user's messages to look pretty from os import fork # used to allow simultaneous input and output class Server: commandhash = {"/list":"LIST", "/join":"JOIN", "/nick":"NICK"} openchannels = [] channel = None ## This constructor does the housekeeping presumed for any irc connection and represents ## a single server. As of now this program only supports connection to one server at a time ## (and in fact, one channel as well) but this will be addressed in future versions. def __init__(self, address, protocol=6667): self.address = address # record the server address for future use self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # set up the socket ## Get identity information needed by the server. self.realname = raw_input("REALNAME: ") self.ident = raw_input("IDENT: ") self.nick = raw_input("NICK: ") self.sock.connect((socket.gethostbyname(address), protocol)) # connect to the server self.sock.send("USER %s %s %s :%s\r\n" % (self.ident, address, "UNIX-SERVER", self.realname)) # send identity stuff self.sock.send("NICK %s\r\n" % self.nick) # tell the server our desired nick def parseMessage(self, message): nick = message[message.index(":"):message.index("!")] message = message[message.index(":") + 1:] message = message[message.index(":"):] return "%s %s" % (nick, message) def server_response(self): response = self.sock.recv(1024) if "!" in response and ":" in response[response.index(":") + 1:]: return self.parseMessage(response) if "PING :" in response: self.sock.send(response.replace("PING", "PONG")) return 0 return response def send_message(self, message): if not message: return False for i in self.commandhash: if message[:len(i)] == i: message = message.split(" ") if len(message) == 2: if message[0] == "/join": self.channel = message[1] return self.sock.send(self.commandhash[i] + " " + message[1] + "\r\n") return self.sock.send(self.commandhash[i] + "\r\n") if self.channel: message_tuple = (self.nick, self.ident, self.address, self.channel, message) return self.sock.send(":%s!%s@%s PRIVMSG %s :%s\r\n" % message_tuple) else: print "No channel selected" return False def close(self): self.sock.close() return connection = Server(raw_input("server: ")) connected = 1 pid = fork() while connected: if pid: connection.send_message(raw_input()) else: response = connection.server_response() if response: print response connection.close()
|
| Return to
python category list |
|
|
Who Visited EnigmaGroup Today?
1385 Guests, 225 Users (216 Spiders)
TheCheeseDemon, MineDweller, Pabz, lolzsec, terrorbyte, dark_void, Nightraven, cat1vo, interspirehost, lamb, tgm001, plex, Edika, rockcraft, recoveryToolbox, saraf, soufiaane, sickmind, mjneat, famous0123, Galagatron, CJ_Omaha, junaid_junaid59, JohnJohnJohn, ssmaslov, psychomarine, Dregoon, Patrickk, Aska, Beat_Slayer, M0rdak, Ausome1, Imre, Vreality2007, mmndglxuwn, m0rt, unholyblood, iterrumzz, VurbTrurb, Mayonoula, MAMWOURBROR, mutabor, gobinda, cossyDrybrich, Razin, zaCruBumas8, hunja, johny34, pantoufle, bagy, arctica, hackarchives, UsedDeteKef, Peculator, Fadhilat606, TheTrueMonarch, Pascall01, hackaday, Tjm, arndevil, flairvelocity, lol, alphbond, kdivanov, elizbethallis6, Rik, bn11, BorgBot, SHASHANK101hello, 4poc4lyptic, ksajxai, nbmorri1, electro-technic, شمالي عرعر, AutobotPrime, Underleaf, The End, tomtombomb, killobyte, snowgirlx, so_saucey, zerolife, Althor, Cramps, Hekser, Hyperborn, cyber-guard, jhgrunn, cobra, Partisan, MAZI_, cyborg, GenbreedX, moel77, cliptoX, pwnpwnlolz, letshavepie, Mrwormz, yshiau, mirmo, roozyoppomo, soft_devil, cls777, scoobywan, Reiversed, joshua, st3alth, Afrika, PaiffDryday, venter, Anthony12796, sh3llcod3, 8FIGURE, Rannim, Evil1, maloaboy, BACanON, SlayingDragons, Repuhlsive, IvanDimitriev, 1RiB, mzungudo, Micro_Geek, iMaxx, aciboummamymn, k0unterkulcher, somebody777, m14m16, GoododotAlcob, negasora, Rastii, UninueMem, Swifsolja, ad.conquest, ngolatkar, Infinity8, Jigoku, thesupervisor, p0is0n5ting, kernel_mod, AKL, GothicLogic, themastersinner, dnatrixene135, ChewBigRed, kalak55, sejem, cve916, pollolololo, triecturn, Violatedsmurf, Ops, jmp, xsiemich, generalisimo, strudels, ga3ttpom, KingOfBritains, epoch_qwert, suten, FriskyKat, Ryuske, Adonis Achilles, ubqbcdzzhf, 3vil, US£RNAM£, Weindittewcon, Batesheelocot, GSmyrlis, MaxMeier, Elite.America, rabbidmind, Psiber_Syn, phoenix22, imittyerrotte, peewster, cyberturtle, ctb, dexgeda, sdw, Pizza, White_widdow, devarian, finesse, Nature112091777, Danc7171, Alphadragon, Estadagause, 53QR10U5, Xargos, Alkomage, hardlock, Barry Gonzoles, Gkjt, N4g4c3N, [I]nfectedbug, wimsteege, aqr5zdcw, xin214, Bugshuppy, SnoopSky, Hessesian, voodooKobra, sKcarr, IROverRated, W1F1G3NJU75U, Baddy, ziadmosaan, gamble86, realzs, CruelDemon, Shinju, aVoid, aquiredanonymity, kukumumu, web_request, callmeneon, KissMyDAFFODIL, Feld Grau, Abhinav2107, prabhataditya, mbuyiselo, shumer, phenom216, princennamdi |
| |
|
|
|
|
|