Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pour les challs rootme
- import socket, time, base64
- socket.setdefaulttimeout(1000)
- class IRCBOT :
- ircbot = socket.socket()
- #here a func to define the socket
- def __init__(self):
- self.ircbot = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
- time.sleep(1)
- #here a func to PONG
- def pong(self):
- self.ircbot.send(bytes("PONG"+"\n","UTF-8"))
- #Here a func to connect our socket
- def connect(self,serv,port = 6667):
- self.ircbot.connect((serv,port))
- print("Connected to",serv)
- time.sleep(1)
- #here a func to authentify our bot
- def auth(self,nickname = "Lybie",pseudo = "Lybie") :
- self.ircbot.send(bytes("USER " + nickname + " " + nickname + " " + nickname + " " + nickname + "\n","UTF-8"))
- self.ircbot.send(bytes("NICK " + pseudo + "\n","UTF-8"))
- print("authentification done."+"\n"+" Nickname = " + pseudo + "\n" + " Username = " + pseudo)
- #here a func to join a chan
- def joinchan(self,chan):
- self.ircbot.send(bytes("JOIN #" + chan + "\n","UTF-8"))
- print("Chan "+chan+" joined")
- time.sleep(0.1)
- #here a func to send a message to any chan or user
- def msg(self,recipient ,content):
- self.ircbot.send(bytes("PRIVMSG "+ recipient + " " + content + "\n","UTF-8"))
- time.sleep(1)
- #Here a func to get a message (non finie)
- def rcv(self):
- message = self.ircbot.recv(2040).decode("UTF-8")
- return message
- #here a func to clear chat, used
- def clear(self):
- self.ircbot.send(bytes("CLEAR " + "\n","UTF-8"))
- #here a func to get a string with the answer of LIST request
- def getlist(self):
- listbrut = ""
- self.ircbot.send(bytes("LIST"+"\n","UTF-8"))
- while 1 :
- listbrut += self.ircbot.recv(10000).decode("UTF-8")
- if "End of channel list" in listbrut :
- break
- return(listbrut)
- #here a func to split a string with the answer of LIST request, to get a list of chans
- def splitchan(self,brutmsg):
- listchan = brutmsg.split(" ")
- a = 0
- b = len(listchan)
- while a != b :
- if "#" in listchan[a] :
- a += 1
- pass
- if not "#" in listchan[a] :
- listchan.remove(listchan[a])
- b -= 1
- return(listchan)
- # here a func to get the content of a message :
- def getmsg(self,botpseudo,sender = ""):
- while 1 :
- rcvd = self.ircbot.recv(2040).decode("UTF-8")
- if botpseudo in rcvd and sender in rcvd and "PRIV" in rcvd :
- break
- return rcvd.split("PRIVMSG " + botpseudo + " :")[1][:-2]
- chall = IRCBOT()
- chall.connect("irc.root-me.org")
- chall.auth("Lybie", "Lybie")
- time.sleep(5)
- chall.clear()
- chall.pong()
- chall.joinchan("challenges")
- chall.clear()
- chall.msg("candy","!ep2")
- truc = str(base64.b64decode(bytes(chall.getmsg("Lybie"),"UTF-8")))
- truc = truc.split("'")[1]
- print(truc)
- chall.msg("candy","!ep2 -rep " + truc)
- print(chall.getmsg("Lybie"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement