Last active
August 6, 2019 19:24
-
-
Save SapphicCode/0431f46b5e969375ea011f803b0bd92e to your computer and use it in GitHub Desktop.
A simple discrim changer for Discord
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import discord | |
import asyncio | |
USERNAME = '' | |
PASSWORD = '' | |
TOKEN = '' | |
class Bot(discord.Client): | |
def __init__(self, **kwargs): | |
super().__init__(**kwargs) | |
self.loop.create_task(self.discrim_changer()) | |
async def discrim_changer(self): | |
await asyncio.sleep(10) | |
print('Started!') | |
while True: | |
try: | |
print('Attempting to change discriminator...') | |
users = list({x.name for x in self.get_all_members() if x.discriminator == self.user.discriminator}) | |
users.remove(self.user.name) | |
if len(users) == 0: | |
print('Unable to find suitable discriminator.') | |
await self.logout() | |
return | |
await self.edit_profile(username=users[0], password=PASSWORD) | |
await self.edit_profile(username=USERNAME, password=PASSWORD) | |
await asyncio.sleep(10) | |
print('Changed to {}!'.format(self.user.discriminator)) | |
if int(self.user.discriminator) < 100: | |
await self.logout() | |
return | |
except: | |
print('Failed :(') | |
await asyncio.sleep(3650) | |
bot = Bot() | |
bot.run(TOKEN, bot=False) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
import requests | |
import threading | |
import logging | |
import time | |
import random | |
parser = argparse.ArgumentParser() | |
parser.add_argument('-d', '--target-discrims', help='takes a list of comma-seperated discriminators to try and get', | |
default='') | |
parser.add_argument('client_strings', nargs='+', help='Client strings, strings that look like this:\n' | |
'token:password\n' | |
'password can be filled in with something random if the token ' | |
'in question is a bot\'s account') | |
logger = logging.getLogger('discrim_changer') | |
session = requests.Session() | |
session.headers['User-Agent'] = 'PandentiaDiscrimChanger/1.1' | |
args = parser.parse_args() | |
targets = args.target_discrims.split(',') | |
account_strings = args.client_strings | |
accounts = [] | |
ME_ENDPOINT = 'https://discordapp.com/api/users/@me' | |
DISCRIM_ENDPOINT = 'https://api.pandentia.cf/discord/users/discriminator/{}' | |
def get_me(token): | |
return session.get(ME_ENDPOINT, headers={'Authorization': token}) | |
def change_username(account, username, send_password=True): | |
if send_password: | |
return session.patch(ME_ENDPOINT, json={'username': username, 'password': account[1]}, | |
headers={'Authorization': account[0]}) | |
else: | |
return session.patch(ME_ENDPOINT, json={'username': username}, headers={'Authorization': account[0]}) | |
def verify_token(token): | |
me = get_me(token) | |
if me.status_code == 200: | |
return True | |
else: | |
return False | |
for string in account_strings: | |
account = string.split(':', 1) | |
if len(account) != 2: | |
logger.error('the client string "{}" has been ignored, it is invalid'.format(string)) | |
continue | |
if not verify_token(account[0]): | |
logger.error('the token "{}" is invalid, ignoring'.format(string)) | |
continue | |
accounts.append(tuple(account)) | |
def changer_thread(account): | |
while True: | |
me = get_me(account[0]) | |
me = me.json() | |
_id = me['id'] | |
discrim = me['discriminator'] | |
bot = me.get('bot', False) | |
while True: | |
discrims = session.get(DISCRIM_ENDPOINT.format(discrim)) | |
if discrims.status_code == 200: | |
discrims = discrims.json() | |
break | |
else: | |
time.sleep(60) | |
choices = [x['username'] for x in discrims['response'] if x['username'] != me['username']] | |
resp = change_username(account, random.choice(choices), send_password=not bot) | |
if resp.status_code != 200: | |
logger.critical('[{}] invalid password given, exiting thread...'.format(_id)) | |
break | |
discrim = resp.json()['discriminator'] | |
logger.info('[{}] got a new discrim, {}'.format(_id, discrim)) | |
if discrim in targets: | |
logger.info('[{}] reached a target discrim, exiting thread...'.format(_id)) | |
break | |
time.sleep(1810) | |
if __name__ == '__main__': | |
for account in accounts: | |
threading.Thread(target=changer_thread, args=(account,)).start() | |
time.sleep(5) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import time | |
import datetime | |
DISCORD_TOKEN = '' | |
DISCORD_PASSWORD = '' | |
PUSHBULLET_TOKEN = '' # https://pushbullet.com/#settings/account | |
discord = requests.Session() | |
discord.headers.update({'Authorization': DISCORD_TOKEN}) | |
pushbullet = requests.Session() | |
pushbullet.headers.update({'Access-Token': PUSHBULLET_TOKEN}) | |
# Discord setup | |
ME_ENDPOINT = 'https://discordapp.com/api/users/@me' | |
me = discord.get(ME_ENDPOINT).json() | |
# Pushbullet setup | |
PUSHBULLET_API_ROOT = 'https://api.pushbullet.com/v2/{}' | |
_device_name = 'Discrim Discrim Changer {}'.format(datetime.datetime.now()) | |
push_device_id = pushbullet.post(PUSHBULLET_API_ROOT.format('devices'), json={'nickname': _device_name, | |
'icon': 'system'}).json()['iden'] | |
# Pandentia API setup | |
PANDENTIA_API_ROOT = 'https://api.pandentia.cf/discord/users/discriminator/{}' | |
# loop | |
print('Discrim changer started.') | |
IDS_SEEN = [] | |
while True: | |
resp = requests.get(PANDENTIA_API_ROOT.format(me['discriminator'])).json()['response'] | |
choices = [x for x in resp if x['username'] != me['username']] | |
choice = choices[0] | |
resp = discord.patch(ME_ENDPOINT, json={'username': choice['username'], 'password': DISCORD_PASSWORD}) | |
time.sleep(5) # give Discord time to realize | |
me = discord.get(ME_ENDPOINT).json() | |
print('Got a new discrim: {}'.format(me['discriminator'])) | |
time.sleep(60 * 30 + 10) # ratelimits | |
print('Asking pushbullet...') | |
body = 'Hi. I changed your discrim to {}. Want it to stay this way?'.format(me['discriminator']) | |
pushbullet.post(PUSHBULLET_API_ROOT.format('pushes'), json={'title': _device_name, 'body': body, 'type': 'note'}) | |
_continue = False | |
while not _continue: | |
resp = pushbullet.get(PUSHBULLET_API_ROOT.format('pushes?limit=100')).json()['pushes'] | |
valid = [x for x in resp if x.get('target_device_iden') == push_device_id] | |
for i in valid: | |
if not i['active']: | |
continue | |
if i['iden'] not in IDS_SEEN: | |
IDS_SEEN.append(i['iden']) | |
else: | |
continue | |
if i.get('body') == 'no': | |
print('OK!') | |
_continue = True | |
if i.get('body') == 'yes': | |
exit(0) | |
time.sleep(5) | |
body = 'Okay, continuing...' | |
pushbullet.post(PUSHBULLET_API_ROOT.format('pushes'), json={'title': _device_name, 'body': body, 'type': 'note'}) |
It also likely won't work anymore because it's a script from 2017 which was pre-rewrite.
not to mention the new ratelimits on username changes
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
you don't need to install asyncio, argparse, threading, logging, time, random or datetime, silly, those are stdlib.