Created
September 8, 2013 16:06
-
-
Save trietptm/6485981 to your computer and use it in GitHub Desktop.
Programming [Root Me: dedicated to Hacking and Security learning platform Information]
http://www.root-me.org/fr/Challenges/Programmation/Uncompress-me
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys, socket, ssl, time | |
import urllib, re, math | |
import base64, zlib | |
NICK = 'trietptm' | |
IDENT = 'trietptm' | |
REALNAME = 'trietptm' | |
CHAN = '#Root-Me_Challenge' | |
PASSWORD = 'mypassword' | |
data = '' | |
start = 'Start to connect.' | |
connected = 'Connection estblished.' | |
# LOGIN IRC CHAT | |
print start | |
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
s.connect(('irc.root-me.org', 6697)) | |
ircsock=ssl.wrap_socket(s) | |
ircsock.send("USER %s %s %s :%s\r\n" %(NICK, IDENT, REALNAME, NICK)) | |
ircsock.send("NICK %s\r\n" % NICK) | |
print connected | |
while True: | |
# STAY CONNECTED | |
data = ircsock.recv(4096) | |
print data | |
if data.find('PING') != -1: | |
ircsock.send('PONG ' + data.split() [ 1 ] + '\r\n') | |
# JOIN CHANNEL and IDENTIFY PASSWORD | |
if data.find('001') != -1: | |
ircsock.send("JOIN %s\r\n" % CHAN) | |
data = ircsock.recv(4096) | |
print data | |
ircsock.send('PRIVMSG NickServ : IDENTIFY %s\r\n' % PASSWORD) | |
data = ircsock.recv (4096) | |
print data | |
ircsock.send('PRIVMSG Candy :!ep4\r\n') | |
if data.find('KICK') != -1: | |
ircsock.send('JOIN %s\r\n' % CHAN) | |
data = ircsock.recv(4096) | |
print data | |
ircsock.send('PRIVMSG Candy :!ep4\r\n') | |
if data.find('PRIVMSG') != -1: | |
message = data.split(':')[2] | |
print message | |
result = zlib.decompress(base64.b64decode(message)) | |
ircsock.send('PRIVMSG Candy :!ep4 -rep ' + result + '\r\n') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment