Advertisement
Guest User

GT4 Site Ban Script (for admins/mods)

a guest
Jul 3rd, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.97 KB | None | 0 0
  1. ## Graphictoria Quick Banner
  2.  
  3. import requests
  4. import pyotp
  5. import os
  6. import time
  7. cls = lambda: os.system('cls')
  8. from bs4 import BeautifulSoup
  9.  
  10. x=int(input("ID:"))
  11.  
  12. print("\n<Please enter your account credentials>\n")
  13.  
  14. #account credentials
  15. user=""
  16. password=""
  17.  
  18. #2fa "secret key"
  19. auth = pyotp.TOTP("")
  20.  
  21. #newSession
  22. session = requests.Session()
  23.  
  24. #login
  25. login = session.post("https://xdiscuss.net/core/func/api/auth/login.php", data={"username": user, "passwd": password, "csrf":" "})
  26.  
  27. #get CSRF token
  28. twofactor = session.get("https://xdiscuss.net/account/verification/twostepauth")
  29. soup = BeautifulSoup(twofactor.text, "html.parser")
  30. token = soup.find("meta", {"name":"csrf-token"})
  31.  
  32.  
  33. #ban function
  34.  
  35.  
  36. #ban menu
  37. login2fa = session.post("https://xdiscuss.net/core/func/api/auth/twostep.php", data={"factorCode": auth.now(), "csrf": token["content"]})
  38. soup = BeautifulSoup(login2fa.text,"html.parser")
  39. if soup.find(text="success"):
  40.     print("\n==Logged in as: {}".format(user) + "==")
  41.     print("\n<Graphictoria Ban Menu>\n")
  42.     while True:
  43.         friends=session.get('https://xdiscuss.net/friends/show/' + str(x))
  44.         soup = BeautifulSoup(friends.text, 'html.parser')
  45.         if soup.find(text="""
  46.    User not found"""):
  47.             print("User not found")
  48.             x += 1
  49.         else:
  50.             found = soup.find('h4', text=True).text
  51.             #username = found.replace("'s", "")
  52.             offender=username = found.split("'s")[0]
  53.             x += 1
  54.             ban = session.post("https://xdiscuss.net/core/func/api/admin/post/banUser.php", data={"csrf":token["content"], "username": offender, "banReason": "", "duration": "5"}) ## termination
  55.             soup = BeautifulSoup(ban.text,'html.parser')
  56.             if not soup.find(text='success'):
  57.                 print('\nError: {}'.format(soup))
  58.             else:
  59.                 print("\nBanned {}".format(offender) + " [ID={}]".format(x))
  60. else:
  61.     print("\nWrong account information.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement