Advertisement
Guest User

Untitled

a guest
Aug 8th, 2015
382
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.43 KB | None | 0 0
  1. Club Penguin Follow Bot
  2.  
  3. Aurora's (Arthur) Python PCL (Penguin)
  4.  
  5. Features (v1.0) (v2.0) (v3.0):
  6.  
  7. Copies target penguin's message (uses pcam)
  8. Copies target penguin's emotes
  9. Copies target penguin's position in room
  10. Copies target penguin's joined room
  11. Copies target penguin's frame
  12. Copies target penguin's action
  13. Copies target penguin's snowballs
  14. Set an offset for each bot
  15. Option to load accounts from a file
  16. Create formations w/ offset for each bot
  17. Script
  18.  
  19. from Penguin.ClubPenguin import ClubPenguin
  20. from Penguin.Penguin import Penguin
  21. from Penguin.ClubPenguin import PenguinFactory
  22.  
  23. '''
  24. Followbot Script - CPKarth123
  25. Penguin (PCL) - Aurora (Arthur)
  26. '''
  27.  
  28. class MyPenguin(Penguin):
  29.  
  30. def __init__(self, player, offset_x, offset_y):
  31. super(MyPenguin, self).__init__(player)
  32.  
  33. self.name = 'Billybob' #Change this to the penguin you wish to follow!
  34. self.mixTarget = ''
  35.  
  36. self.offset_x = offset_x
  37. self.offset_y = offset_y
  38.  
  39. self.addListener("sp", self.handleMove)
  40. self.addListener("se", self.handleEmote)
  41. self.addListener("sm", self.handleMessage)
  42. self.addListener("sb", self.handleSnowball)
  43. self.addListener("sf", self.handleFrame)
  44. self.addListener("sa", self.handleAction)
  45. self.addListener("jr", self.handleJoinRoom)
  46. self.addListener("pbn",self.handlePlayerByName)
  47. self.addListener("bf", self.handleBf)
  48. self.addListener("rp", self.handleRp)
  49.  
  50.  
  51. def handleMove(self, data):
  52. if data[3] == self.mixTarget:
  53. self.sendPosition(int(data[4]) + self.offset_x, int(data[5]) + self.offset_y)
  54.  
  55. def handleEmote(self, data):
  56. if data[3] == self.mixTarget:
  57. self.sendEmote(data[4])
  58.  
  59. def handleMessage(self, data):
  60. if data[3] == self.mixTarget:
  61. self.sendPhraseMessage(data[4])
  62.  
  63. def handleSnowball(self, data):
  64. if data[3] == self.mixTarget:
  65. self.sendSnowball(data[4], data[5])
  66.  
  67. def handleFrame(self, data):
  68. if data[3] == self.mixTarget:
  69. self.sendFrame(data[4])
  70.  
  71. def handleAction(self, data):
  72. if data[3] == self.mixTarget:
  73. self.sendAction(data[4])
  74.  
  75. def handleJoinRoom(self, data):
  76. self.getPlayerInfoByName(self.name)
  77.  
  78.  
  79. def handlePlayerByName(self, data):
  80. self.mixTarget = data[4]
  81. self.findBuddy(self.mixTarget)
  82.  
  83. def handleBf(self, data):
  84. if data[3] == '-1':
  85. self.logger.error("Target is offline!")
  86. exit()
  87. self.joinRoom(data[3])
  88.  
  89. def handleRp(self, data):
  90. if data[3] == self.mixTarget:
  91. self.findBuddy(self.mixTarget)
  92.  
  93. class FollowBotFactory(PenguinFactory):
  94.  
  95. def __init__(self, offset_x=0, offset_y=0):
  96. self.offset_x = offset_x
  97. self.offset_y = offset_y
  98. super(FollowBotFactory, self).__init__()
  99.  
  100. self.logger.debug("FollowBotFactory constructed")
  101.  
  102. def buildProtocol(self, addr):
  103. player = self.queue.pop()
  104.  
  105. penguin = MyPenguin(player, self.offset_x, self.offset_y)
  106.  
  107. return penguin
  108.  
  109.  
  110. cp = ClubPenguin()
  111.  
  112. accounts = []
  113. for account in open("accounts.txt", "r").read().split("\n"):
  114. if account!= "":
  115. accounts.append(dict({"username":account.split(":")[0], "password":account.split(":")[1]}))
  116. else:
  117. break
  118.  
  119. '''
  120. Cube Formation
  121. '''
  122.  
  123. cp.connect(username=accounts[0]["username"], password=accounts[0]["password"], server="Ice Pond", \
  124. factory=FollowBotFactory(45,0))
  125.  
  126. cp.connect(username=accounts[1]["username"], password=accounts[1]["password"], server="Ice Pond", \
  127. factory=FollowBotFactory(-45,0))
  128.  
  129. cp.connect(username=accounts[2]["username"], password=accounts[2]["password"], server="Ice Pond", \
  130. factory=FollowBotFactory(45,45))
  131.  
  132. cp.connect(username=accounts[3]["username"], password=accounts[3]["password"], server="Ice Pond", \
  133. factory=FollowBotFactory(45,-45))
  134.  
  135. cp.connect(username=accounts[4]["username"], password=accounts[4]["password"], server="Ice Pond", \
  136. factory=FollowBotFactory(0,45))
  137.  
  138. cp.connect(username=accounts[5]["username"], password=accounts[5]["password"], server="Ice Pond", \
  139. factory=FollowBotFactory(0,-45))
  140.  
  141. cp.connect(username=accounts[6]["username"], password=accounts[6]["password"], server="Ice Pond", \
  142. factory=FollowBotFactory(-45,-45))
  143.  
  144. cp.connect(username=accounts[7]["username"], password=accounts[7]["password"], server="Ice Pond", \
  145. factory=FollowBotFactory(-45,45))
  146.  
  147.  
  148. cp.start()
  149.  
  150. Reveal hidden contents
  151. NOTE: Please add the following methods in the Penguin class of Penguin.py:
  152.  
  153. def findBuddy(self, id):
  154. self.sendXt("s", "u#bf", id)
  155. def sendEmote(self, id):
  156. self.sendXt("s", "u#se", id)
  157. def sendAction(self, id):
  158. self.sendXt("s", "u#sa", id)
  159. def sendSnowball(self, x, y):
  160. self.sendXt("s", "u#sb", x, y)
  161. def sendFrame(self, id):
  162. self.sendXt("s", "u#sf", id)
  163.  
  164.  
  165. Usage
  166.  
  167. Download all the files from the GitHub repo then open FollowBot.py, the first thing you need to change is the 'self.name' variable - change this to the penguin you wish to follow. Now you will need a file called 'accounts.txt' w/ a lot of accounts OR you can simply fill in the username and password for the bot manually like so:
  168.  
  169. cp.connect(username="USERNAME HERE", password="PASSWORD HERE", server="SERVER HERE", \
  170. factory=FollowBotFactory())
  171. If you were to load an account from accounts.txt it will be:
  172.  
  173. cp.connect(username=accounts[0]["username"], password=accounts[0]["password"], server="Ice Pond", \
  174. factory=FollowBotFactory())
  175. Offset: To set an offset for each bot:
  176.  
  177. cp.connect(username=accounts[0]["username"], password=accounts[0]["password"], server="Ice Pond", \
  178. factory=FollowBotFactory(10,10))
  179. You can change 10,10 to anything w/ multiple different bots and the right offset you can create cool formations.
  180.  
  181.  
  182.  
  183. Formations (For formations I recommend having an accounts.txt file)
  184.  
  185. Cube Formation
  186.  
  187. cp.connect(username=accounts[0]["username"], password=accounts[0]["password"], server="Ice Pond", \
  188. factory=FollowBotFactory(45,0))
  189.  
  190. cp.connect(username=accounts[1]["username"], password=accounts[1]["password"], server="Ice Pond", \
  191. factory=FollowBotFactory(-45,0))
  192.  
  193. cp.connect(username=accounts[2]["username"], password=accounts[2]["password"], server="Ice Pond", \
  194. factory=FollowBotFactory(45,45))
  195.  
  196. cp.connect(username=accounts[3]["username"], password=accounts[3]["password"], server="Ice Pond", \
  197. factory=FollowBotFactory(45,-45))
  198.  
  199. cp.connect(username=accounts[4]["username"], password=accounts[4]["password"], server="Ice Pond", \
  200. factory=FollowBotFactory(0,45))
  201.  
  202. cp.connect(username=accounts[5]["username"], password=accounts[5]["password"], server="Ice Pond", \
  203. factory=FollowBotFactory(0,-45))
  204.  
  205. cp.connect(username=accounts[6]["username"], password=accounts[6]["password"], server="Ice Pond", \
  206. factory=FollowBotFactory(-45,-45))
  207.  
  208. cp.connect(username=accounts[7]["username"], password=accounts[7]["password"], server="Ice Pond", \
  209. factory=FollowBotFactory(-45,45))
  210.  
  211. Reveal hidden contents
  212. Circle Formation
  213.  
  214. cp.connect(username=accounts[0]["username"], password=accounts[0]["password"], server="Ice Pond", \
  215. factory=FollowBotFactory(-0,-60))
  216.  
  217. cp.connect(username=accounts[1]["username"], password=accounts[1]["password"], server="Ice Pond", \
  218. factory=FollowBotFactory(0,60))
  219.  
  220. cp.connect(username=accounts[2]["username"], password=accounts[2]["password"], server="Ice Pond", \
  221. factory=FollowBotFactory(60,0))
  222.  
  223. cp.connect(username=accounts[3]["username"], password=accounts[3]["password"], server="Ice Pond", \
  224. factory=FollowBotFactory(-60,-0))
  225.  
  226. cp.connect(username=accounts[4]["username"], password=accounts[4]["password"], server="Ice Pond", \
  227. factory=FollowBotFactory(-40,40))
  228.  
  229. cp.connect(username=accounts[5]["username"], password=accounts[5]["password"], server="Ice Pond", \
  230. factory=FollowBotFactory(40,40))
  231.  
  232. cp.connect(username=accounts[6]["username"], password=accounts[6]["password"], server="Ice Pond", \
  233. factory=FollowBotFactory(-40,-40))
  234.  
  235. cp.connect(username=accounts[7]["username"], password=accounts[7]["password"], server="Ice Pond", \
  236. factory=FollowBotFactory(40,-40))
  237.  
  238. Reveal hidden contents
  239.  
  240.  
  241. Account Generator (For accounts.txt file) - Written by Aurora (Arthur) w/ a slight modification so it writes accounts in accounts.txt file (Original Post)
  242.  
  243. from string import join
  244. from random import choice, randrange
  245. from urllib import urlencode
  246. from operator import xor
  247. from urllib2 import urlopen, Request
  248. from bs4 import BeautifulSoup
  249.  
  250. class AccountMaker(object):
  251.  
  252. header = {
  253. "User-Agent": "Mozilla/5.0 (X11; U; Linux i686) Gecko/20071127 Firefox/2.0.0.11"
  254. }
  255.  
  256. def __init__(self, username, password, email, color="random", amount=1):
  257. if len(username) > 12:
  258. print "Username is too long!"
  259. elif len(username) < 3:
  260. print "Username is too short."
  261. elif amount != 1 and len(username) > 9:
  262. print "Username is too long!"
  263. elif xor(type(amount) != int, amount < 1):
  264. print "Invalid amount specified."
  265. else:
  266. self.username = username
  267. self.password = password
  268. self.email = email
  269. self.color = color if color != "random" else randrange(1, 13)
  270. self.amount = amount
  271.  
  272. self.create()
  273.  
  274. def generateRandomString(self, length=8):
  275. return join((choice("qwertyuiopasdfghjklzxcvbnm") for _ in range(length)), "")
  276.  
  277. def retrieveCookies(self):
  278. initialRequest = Request("https://secured.clubpenguin.com/penguin/create", headers=self.header)
  279.  
  280. initialResponse = urlopen(initialRequest)
  281.  
  282. cookie = initialResponse.info().getheader("Set-Cookie")
  283.  
  284. initialMarkup = initialResponse.read()
  285. initialResponse.close()
  286.  
  287. soup = BeautifulSoup(initialMarkup)
  288.  
  289. self.anonToken = soup.find("input", {"name": "anon_token"})["value"]
  290. self.formBuildId = soup.find("input", {"name": "form_build_id"})["value"]
  291.  
  292. randomString = self.generateRandomString()
  293. self.header["Cookie"] = "{0} playspanTRANSID=arthur-{1}; cpBROWSERID=vortexal-{1};".format(cookie, randomString)
  294. self.header["Content-Type"] = "application/x-www-form-urlencoded"
  295. self.header["Origin"] = "https://secured.clubpenguin.com"
  296. self.header["Referer"] = "https://secured.clubpenguin.com/penguin/create"
  297.  
  298. def register(self, username, email):
  299. self.retrieveCookies()
  300.  
  301. if username == "random":
  302. username = self.generateRandomString(randrange(5, 11))
  303.  
  304. if email == "random":
  305. randomLocal = self.generateRandomString()
  306. email = "{0}@gmail.com".format(randomLocal)
  307.  
  308. print "Registering with {0} and {1}".format(username, email)
  309.  
  310. data = {
  311. "anon_token": self.anonToken,
  312. "color": self.color,
  313. "name": username,
  314. "pass": self.password,
  315. "pass_show": randrange(0, 1),
  316. "email": email,
  317. "email_confirm": email,
  318. "terms": 1,
  319. "op":"Next",
  320. "form_build_id": self.formBuildId,
  321. "form_id": "penguin_create_form"
  322. }
  323.  
  324. finalRequest = Request("https://secured.clubpenguin.com/penguin/create", urlencode(data), self.header)
  325. finalResponse = urlopen(finalRequest)
  326.  
  327. setCookieResponse = finalResponse.info().getheader("Set-Cookie")
  328. finalResponse.close()
  329.  
  330. if setCookieResponse != None:
  331. print "Registration Success"
  332. with open("accounts.txt", "a") as file:
  333. file.write(username + ":" + self.password + "\n")
  334. else:
  335. print "Registration failed"
  336.  
  337. del self.header["Cookie"], self.header["Content-Type"], \
  338. self.header["Origin"], self.header["Referer"]
  339.  
  340. def create(self):
  341. if self.amount > 1:
  342. for account in range(self.amount):
  343. if self.username == "random":
  344. self.register(self.username, self.email)
  345. else:
  346. self.register(self.username + str(account), self.email)
  347. else:
  348. self.register(self.username, self.email)
  349.  
  350. try:
  351. AccountMaker(username="random", password="ComplexPassword1", email="random", amount=100)
  352. except KeyboardInterrupt:
  353. print "Stopping.."
  354.  
  355. Reveal hidden contents
  356. View the GitHub Repo
  357.  
  358. Update Log
  359.  
  360. Release. (v1.0)
  361. Added more handlers (snowball, frames, actions). Tidied the program up. (v2.0)
  362. Ability to add an offset for each bot. Option to load accounts from accounts.txt file. Create cool formations (v3.0)
  363. If you have any problems using this script or have any suggestions for improvements please comment down below and I will respond ASAP
  364.  
  365. Enjoy!
  366.  
  367. Edited Tuesday at 11:55 PM by Karth123
  368. v3.0 - Ability to add an offset for each bot. Option to load accounts from accounts.txt file. Create cool formations (Updated post w/ GitHub repo)
  369. Logan, Dote, Hidden Files and 6 others like this Like this
  370.  
  371. Screen_Shot_2015-07-11_at_16.28.10.thumb Reveal hidden contents
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement