SHARE
TWEET

Untitled

a guest Jan 22nd, 2020 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #pour les challs rootme
  2. import socket, time, base64
  3. socket.setdefaulttimeout(1000)
  4. class IRCBOT :
  5.     ircbot = socket.socket()
  6.     #here a func to define the socket
  7.     def __init__(self):
  8.         self.ircbot = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
  9.         time.sleep(1)
  10.     #here a func to PONG
  11.     def pong(self):
  12.         self.ircbot.send(bytes("PONG"+"\n","UTF-8"))
  13.     #Here a func to connect our socket
  14.     def connect(self,serv,port = 6667):
  15.         self.ircbot.connect((serv,port))
  16.         print("Connected to",serv)
  17.         time.sleep(1)
  18.     #here a func to authentify our bot
  19.     def auth(self,nickname = "Lybie",pseudo = "Lybie") :
  20.         self.ircbot.send(bytes("USER " + nickname + " " + nickname + " " + nickname + " " + nickname + "\n","UTF-8"))
  21.         self.ircbot.send(bytes("NICK " + pseudo + "\n","UTF-8"))
  22.         print("authentification done."+"\n"+" Nickname = " + pseudo + "\n" +  " Username = " + pseudo)
  23.     #here a func to join a chan
  24.     def joinchan(self,chan):
  25.         self.ircbot.send(bytes("JOIN #" + chan + "\n","UTF-8"))
  26.         print("Chan "+chan+" joined")
  27.         time.sleep(0.1)
  28.     #here a func to send a message to any chan or user
  29.     def msg(self,recipient ,content):
  30.         self.ircbot.send(bytes("PRIVMSG "+ recipient + " " + content + "\n","UTF-8"))
  31.         time.sleep(1)
  32.     #Here a func to get a message (non finie)
  33.     def rcv(self):
  34.         message = self.ircbot.recv(2040).decode("UTF-8")
  35.         return message
  36.     #here a func to clear chat, used
  37.     def clear(self):
  38.         self.ircbot.send(bytes("CLEAR " + "\n","UTF-8"))
  39.     #here a func to get a string with the answer of LIST request
  40.     def getlist(self):
  41.         listbrut = ""
  42.         self.ircbot.send(bytes("LIST"+"\n","UTF-8"))
  43.         while 1 :
  44.             listbrut += self.ircbot.recv(10000).decode("UTF-8")
  45.             if "End of channel list" in listbrut :
  46.                 break
  47.         return(listbrut)
  48.     #here a func to split a string with the answer of LIST request, to get a list of chans
  49.     def splitchan(self,brutmsg):
  50.         listchan = brutmsg.split(" ")
  51.         a = 0
  52.         b = len(listchan)
  53.         while a != b :
  54.             if "#" in listchan[a] :
  55.                 a += 1
  56.                 pass
  57.             if not "#" in listchan[a] :
  58.                 listchan.remove(listchan[a])
  59.                 b -= 1
  60.         return(listchan)
  61.     # here a func to get the content of a message :
  62.     def getmsg(self,botpseudo,sender = ""):
  63.         while 1 :
  64.             rcvd = self.ircbot.recv(2040).decode("UTF-8")
  65.             if botpseudo in rcvd and sender in rcvd and "PRIV" in rcvd :
  66.                 break
  67.         return rcvd.split("PRIVMSG " + botpseudo + " :")[1][:-2]
  68. chall = IRCBOT()
  69. chall.connect("irc.root-me.org")
  70. chall.auth("Lybie", "Lybie")
  71. time.sleep(5)
  72. chall.clear()
  73. chall.pong()
  74. chall.joinchan("challenges")
  75. chall.clear()
  76. chall.msg("candy","!ep2")
  77. truc = str(base64.b64decode(bytes(chall.getmsg("Lybie"),"UTF-8")))
  78. truc = truc.split("'")[1]
  79. print(truc)
  80. chall.msg("candy","!ep2 -rep " + truc)
  81. print(chall.getmsg("Lybie"))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top