Advertisement
Guest User

Untitled

a guest
Aug 7th, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 6.59 KB | None | 0 0
  1. import urllib2
  2. import cookielib
  3. import thread
  4. import re
  5. import os
  6. import sys
  7. from time import localtime, sleep, strftime, time
  8. import socket
  9. import threading
  10. import datetime
  11.  
  12.  
  13. #------------------Cookie-Jar----------
  14. socket.setdefaulttimeout(90.0)
  15.  
  16. cj = cookielib.CookieJar()
  17. user_agent = ('Mozilla/5.0 (Windows NT 6.1; WOW64; rv:13.0) ' +
  18.     'Gecko/20100101 Firefox/13.0.1 ID:20120614114901')
  19. opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
  20. opener.addheaders = [('User-agent', user_agent)]
  21.  
  22. #--------------------SETTINGS-----------
  23. suid = 0 # do not change
  24.  
  25.  
  26. ## change these
  27. logins = [["username", "password"], ["username1","password2"]]
  28. server = "sigil"
  29. secword = ""#dont edit
  30. numruns = 0 #can specify a number of runs. if you select 0, it will run forever
  31. enemyIDlist = ["939937"] #can specify one or multiple id's
  32. myMessage = "http://i.imgur.com/J3tjrIS.png" #can update this to whatever
  33.  
  34. logging = True
  35.  
  36. if server.lower() == 'sigil':
  37.     server_id = '1'
  38. elif server.lower() == 'torax':
  39.     server_id = '2'
  40. else:
  41.     server_id = '1'
  42.  
  43. #--------------------Go to site-----------
  44. def url_opener(url, pData=None):
  45.     lagsafe = 1
  46.     while lagsafe == 1:
  47.         try:
  48.             if not pData:
  49.                 site = opener.open(url)
  50.                 #sleep(0.3)
  51.                 lagsafe = 0
  52.             else:
  53.                 site = opener.open(url, pData)
  54.                 #sleep(0.3)
  55.                 lagsafe = 0
  56.             break
  57.         except IOError, e:
  58.             print e
  59.         except Exception:
  60.             print 'Unknown error, retrying...'
  61.         except socket.timeout, e:
  62.             print "Timeout error, retrying"
  63.     return site
  64.  
  65. #--------------------Create Character-----------
  66.  
  67. def sub_string(source, start, end):
  68.     try:
  69.         return source.split(start)[1].split(end)[0]
  70.     except IndexError:
  71.         print('Could not retrieve the inbetween value')
  72.         return False
  73.  
  74. #------------Get Char Name------------
  75. def char_name(source):
  76.     try:
  77.         char_name = source.split('" selected>')[1].split('</option>')[0]
  78.     except IndexError:
  79.         char_name = "Unknown"
  80.         print("Could not retrieve the inbetween value")
  81.     finally:
  82.         return char_name
  83.  
  84.    
  85. #--------------------LOGIN-----------  
  86.  
  87. def login(username, password):
  88.     loginrpg = url_opener("http://"+server+".outwar.com/myaccount.php", "login_username=%s&login_password=%s" % (username,password)).read()
  89.     #loginrpg = url_opener("http://"+server+".outwar.com/accounts.php?ac_serverid="+server_id+"&rg_sess_id="+rgSessId).read()
  90.     page = url_opener("http://%s.outwar.com/myaccount.php?ac_serverid=%s" % (server, server_id))
  91.     loginData = loginrpg.split('value="0">--Change Server')[0].split('option value=')[1:]
  92.     #print loginData
  93.     chars = {}
  94.     for char in loginData:
  95.         name = char.split('>')[1].split("</")[0]
  96.         ID = char.split('"')[1]
  97.         chars[name] = ID
  98.         print name
  99.        
  100.     print("Logged in, %s chars found" % str(len(chars)))
  101.  
  102.     return chars
  103. def castBrute(server, myID):
  104.     pots = url_opener("http://"+server+".outwar.com/backpack.php?potion=1&suid="+myID+"&serverid="+server_id).read()
  105.     if "potion1.jpg" in pots:
  106.         mybrut = pots.split("potion1.jpg")[1].split("event,")[1].split("'")[1]
  107.         cast = url_opener("http://"+server+".outwar.com/home.php?itemaction="+mybrut+"&suid="+myID+"&serverid="+server_id).read()
  108. def changeChar(server, server_id, charName, charID):
  109.    
  110.     changechar = url_opener("http://"+server+".outwar.com/world.php?suid=%s&serverid=%s" % (charID,server_id))
  111.    
  112.     print("Changed chars to %s" % charName)
  113.  
  114.            
  115.  
  116. def attack(server, charID):
  117.     #castBrute(server, charID)
  118.     for enemy in enemyIDlist:
  119.         profile = url_opener("http://"+server+".outwar.com/profile.php?id=" + enemy + "&suid=" + charID + "&serverid=%s" % server_id).read()
  120.         if "attackWindow" in profile:
  121.             hash = profile.split("attackWindow('")
  122.             hash = hash[1].split(')">')
  123.             hash = hash[0].split("','")
  124.             name = hash[0]
  125.             hash = hash[3].replace("'",'')
  126.             attack = url_opener("http://"+server+".outwar.com/somethingelse.php?attackid=" + enemy + "&r=undefined&suid=" + charID + "&serverid=%s" % server_id, "message="+myMessage+"&hash="+hash+"&rage=500").read()
  127.             #print attack
  128.  
  129.        
  130.  
  131. class ThreadClass(threading.Thread):
  132.  
  133.     #__init__ is always passed "self" first, then pass in any variables the threads will need to access
  134.     #In this case: server, serverID, charName, and charID are the only variables used by threads
  135.     #These variables will have to be passed into ThreadClass when you first call it
  136.     def __init__(self, server, serverID, charName, charID, secword):
  137.  
  138.         #After you pass into __init__, assign each of the variables into self
  139.         self.server = server
  140.         self.serverID = serverID
  141.         self.charName = charName
  142.         self.charID = charID
  143.         self.secword = secword
  144.        
  145.          
  146.        
  147.         threading.Thread.__init__(self)
  148.  
  149.     def run(self):
  150.         #In this definition, put all the functions the thread needs to accomplish
  151.         #But use the self. versions of the variables because those are specific to each threads
  152.        
  153.         changeChar(self.server, self.serverID, self.charName, self.charID)
  154.         attack(self.server, self.charID)
  155.        
  156.        
  157.  
  158.  
  159.    
  160. #--------------------Main Function-----------
  161. def main(secword):
  162.     for lg in logins:
  163.         print("Warming up...")
  164.         print lg
  165.        
  166.         START_TIME = datetime.datetime.now()
  167.         chars = login(lg[0], lg[1])
  168.  
  169.         threads = []
  170.        
  171.         for char in chars:
  172.  
  173.             thread = ThreadClass(server, server_id, char, chars[char], secword)
  174.             threads += [thread]
  175.             thread.start()
  176.  
  177.         for t in threads:
  178.             t.join()
  179.            
  180.     ##        charChange = changeChar(server, server_id, char, chars[char])
  181.     ##        clearBP(server)
  182.     ##        equipTrainingItems(server)
  183.            
  184.         END_TIME = datetime.datetime.now()
  185.         total = END_TIME - START_TIME
  186.        
  187.         sec = total.seconds
  188.         d = str(datetime.timedelta(seconds=sec))
  189.        
  190.         print('TOTAL RUN TIME: %s' % d)
  191.     ##    print "Exiting in 15 seconds.."
  192.     ##    sleep(15)
  193. if numruns > 0:
  194.     curruns = 0
  195.     while curruns < numruns:
  196.         main(secword)
  197.         curruns += 1
  198.         print('Sleeping for 61 minutes')
  199.         sleep(3660)
  200. else:
  201.     while True:
  202.         main(secword)
  203.         print('Sleeping for 61 minutes')
  204.         sleep(3660)
  205. s
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement