My attempt to reverse the Discord nitro token generation function.

Overview

discord-theory-I

PART: I

My attempt to reverse the Discord nitro token generation function.

The Nitro generation tools thing is common in Discord now, but none of the tools actually works, so I decided to take it to the next level, and reverse the actual tokens in hopes of finding a better way of generation.

- NOTE: This is just for research, I will and I hope no one uses it for bad purposes.

Introduction:

If you are not familiar with Discord, nitro is a kind of membership, you pay to get access and do some cool things on Discord, like get a GIF profile picture or upload large size photos and videos, and in order to get it you must either buy it directly or having someone offer it to you, in the second case it would be something like this: https://discord.gift/hNN5SBsnHTPFFh3Z

The Discord Gift URL followed by a 16-length code will redirect you to the claim page.

First look:

At first sight it looks like Base64 encoded, using Burp Suite Decoder we will be able to get this result:

00000000 84 d3 79 48 1b 27 1d 33 c5 16 1d d9 -- -- -- -- �ÓyH�'�3Å��Ù

After searching for what each byte in a 12-byte string is, I was able to sort each character and see what the code actually consisted of, 4 extended characters and 8 printable/non-printable characters, you can check https://www.rapidtables.com/code/text/ascii-table.html to know more about those type of characters.

  • Extended:

    0x84 0xd3 0xc5 0xd9
  • Printable/Non-Printable:

    0x79 0x48 0x1b 0x27 0x1d 0x33 0x16 0x1d

Doing this over and over again will take a lot of time, so I coded this function that automates the work, feel free to use it:

import re, base64

def sorting(code):
    list = [ord(chr(eval(j))) for j in ['0x'+ i for i in re.findall('..', base64.b64decode(code).hex())]]
    ex = []
    no = []
    for i in list:
        if i >= 0 and i <= 127:
            no.append(i)
        elif i >= 128 and i <= 255:
            ex.append(i)
    print(f"Extended: {' '.join(map(hex, ex))}")
    print(f"Normal: {' '.join(map(hex, no))}")
    print(f"Extended: {len(ex)}, Normal: {len(no)}")

Finding a Pattern:

In order to find a pattern, I used the function above to sort different valid codes, and the result I got is:

Extended: 0x8e 0xf0 0x8f 0xcb 0xe0 0xba 0xe3
Normal: 0x5f 0x2d 0x59 0x5e 0x4a
Extended: 7, Normal: 5

Extended: 0xc2 0xeb 0xe1 0xe1
Normal: 0x62 0x75 0x70 0x1c 0x40 0x37 0x77 0x14    
Extended: 4, Normal: 8

Extended: 0xac 0xb0 0x9b
Normal: 0x28 0x72 0x5c 0x30 0x4 0x75 0x72 0x1c 0x6c
Extended: 3, Normal: 9

Extended: 0xbb 0xa1 0xf9 0x96 0xf5
Normal: 0x71 0x72 0x1d 0x49 0x20 0x1 0x14
Extended: 5, Normal: 7

Extended: 0xbf 0x96 0xf2 0xb3 0xb0 0x9d 0x8a       
Normal: 0x3b 0x4 0x5b 0x4c 0x5c
Extended: 7, Normal: 5

Extended: 0xd0 0xf1 0x91 0xa9
Normal: 0x65 0x5b 0x17 0x6a 0x1d 0x50 0x70 0x3d    
Extended: 4, Normal: 8

From this I was able to know a few rules that must be followed in creating the code:

  • Extended characters can be lower or higher than normal (printable / non-printable) characters.
  • There are no duplicate characters.
  • There is a pattern with 3,4,5,7,8,9.

Looking at the numbers we can see a pattern, if we choose 3 extended characters from the other side, we'll have a 9 normal characters, it's something like Caesar Cipher, and to simplify it:

image

Putting everything together, we can create a function that generates valid instructions for our code:

import random

_map = [3, 4, 5, 7, 8, 9]

def generate_map():
    e = random.choice(_map)
    if e >= 3 and e <= 5:
        n = _map[::-1][0:3][_map[0:3].index(e)]
    else:
        n = _map[0:3][_map[::-1][0:3].index(e)]
    return {"Extended": e, "Normal": n}

An example:

PS C:\Users\ayman\Desktop\discord-theory> python .\generate_map.py
{'Extended': 5, 'Normal': 7}
PS C:\Users\ayman\Desktop\discord-theory> 

Note that I've seen some 24-length nitro codes, but I'm assuming you can just find the right map to generate this type of codes.

Generation:

In order to create a generation function, by putting everything together according to the rules above, by creating a function that takes the coordinates from generate_map() function, a random extended and printable/non-printable characters and shuffle them together and convert them to hex, we will end up with this:

import random

_map = [3, 4, 5, 7, 8, 9]

def generate_map():
    e = random.choice(_map)
    if e >= 3 and e <= 5:
        n = _map[::-1][0:3][_map[0:3].index(e)]
    else:
        n = _map[0:3][_map[::-1][0:3].index(e)]
    return {"Extended": e, "Normal": n}

def generate():
    c = generate_map()
    ex, no = c["Extended"], c["Normal"]
    _chars = random.sample(range(128,255), ex)
    _chars.extend(random.sample(range(1,126), no))
    random.shuffle(_chars)
    return " ".join(list(map(hex ,_chars)))

print(generate())

An example (Hex):

0xd3 0x38 0xe3 0x68 0xd0 0xf6 0xa9 0xfe 0xa7 0xad 0x13 0xb9

Base64:

0zjjaND2qf6nrRO5
Extended: 0xd3 0xe3 0xd0 0xf6 0xa9 0xfe 0xa7 0xad 0xb9
Normal: 0x38 0x68 0x13
Extended: 9, Normal: 3

Problems:

  • Nitro code should contain no padding.
  • An ethical way to validate the generated codes.

Thanks for reading <3.

Owner
Jakom
sigma rule #00: automate everything, email: [email protected]
Jakom
股票量化

StockQuant Gary-Hertel 请勿提交issue!可以加入交流群与其他朋友一起自学交流,加微信mzjimmy 一、配置文件的设置 启动框架需要先导入必要的模块,并且载入一次配置文件! 配置文件是一个json格式的文件config.json,在docs文件夹中有模板

218 Dec 25, 2022
Make your Pass (sanitaire) Fun Again

Make Your Pass (Sanitaire) Fun Again Customize your Pass Sanitaire (French name for EU digital Covide19 Certificate) with colors and images, thus make

101 Dec 01, 2022
Bringing Ethereum Virtual Machine to StarkNet at warp speed!

Warp Warp brings EVM compatible languages to StarkNet, making it possible to transpile Ethereum smart contracts to Cairo, and use them on StarkNet. Ta

Nethermind 700 Dec 26, 2022
Unofficial GoPro API Library for Python - connect to GoPro via WiFi.

GoPro API for Python Unofficial GoPro API Library for Python - connect to GoPro cameras via WiFi. Compatibility: HERO3 HERO3+ HERO4 (including HERO Se

Konrad Iturbe 1.3k Jan 01, 2023
Repo-cloner - Script takes user public liked repos and clone it to a local folder

Liked repos cloner Script takes user public liked repos and clone it to a local

Aleksei 2 Jun 18, 2022
The official Pushy SDK for Python apps.

pushy-python The official Pushy SDK for Python apps. Pushy is the most reliable push notification gateway, perfect for real-time, mission-critical app

Pushy 1 Dec 21, 2021
QR-Code-Grabber - A python script that allows a person to create a qr code token grabber

Qr Code Grabber Description Un script python qui permet a une personne de creer

5 Jun 28, 2022
Tsar-Bot - Crypto auto trade bot that use sentiment analysis from twitter

Tsar Bot - Crypto Sentiment Bot Tsar Bot is a Twitter Crypto Sentiment Bot that

Hilmi Azizi 26 Dec 15, 2022
A bot to share Facebook posts.

bot_share_facebook a bot to share Facebook posts. install & clone untuk menjalankan anda bisa melalui terminal contohnya termux, cmd, dan terminal lai

Muhammad Latif Harkat 7 Dec 07, 2022
Python client to do LispTick requests

lisptick-python LispTick Python client library It allows to send request and receive result from a LispTick server. Get a socket connection to a LispT

Kereon Intelligence 1 Oct 25, 2021
A Discord bot that generates inspirational quotes & motivating messages whenever a user is sad

Encourage bot is a discord bot that allows users to randomly get Inspirational quotes messages and gives motivational encouragements whenever someone says that he's sad/depressed.

1 Nov 25, 2021
OSINT tool to get information from a Github and Gitlab profile and find user's email addresses leaked on commits.

gitrecon OSINT tool to get information from a Github or Gitlab profile and find user's email addresses leaked on commits. 📚 How does this work? GitHu

GOΠZO 211 Dec 17, 2022
Python library to connect to Firebots API

This is a firebot library to connect to Firebots API. https://firebot.app/ From Firebots Website: "Firebot is a fully featured open-source bot that c

1 Jan 08, 2022
Request based Python module(s) to help with the Newegg raffle.

Newegg Shuffle Python module(s) to help you with the Newegg raffle How to use $ git clone https://github.com/Matthew17-21/Newegg-Shuffle $ cd Newegg-S

Matthew 45 Dec 01, 2022
Create CDK projects with projen

The Projenator: I'll be back! Description This is a CDKv2 project that takes the grind out of setting up new cdk projects/implementations by using aut

Andrew 2 Dec 11, 2021
ChairBot is designed to be reliable, easy to use, and lightweight for every user, and easliy to code add-ons for ChairBot.

ChairBot is designed to be reliable, easy to use, and lightweight for every user, and easliy to code add-ons for ChairBot. Ready to see whats possible with ChairBot?

1 Nov 08, 2021
LEC_Ditto is a bot that tracks the follows and unfollows of Twitter accounts

✨ LEC_Ditto ✨ I'm Ditto, and I'm a bot 🤖 . Getting Started | Installation | Usage Getting Started LEC_Ditto is a bot that tracks the follows and unfo

2 Mar 30, 2022
This program is an automated trading bot that uses TDAmeritrades Thinkorswim trading platform's scanners and alerts system.

Python Trading Bot w/ Thinkorswim Description This program is an automated trading bot that uses TDAmeritrades Thinkorswim trading platform's scanners

Trey Thomas 201 Jan 03, 2023
Telegram bot that sends new offers from otomoto.pl

Telegram bot that sends new offers under certain filters from otomoto.pl How to use this bot? Install requirements with pip install -r requirements.tx

Mikhail Zanka 1 Feb 14, 2022
Auto Join: A GitHub action script to automatically invite everyone to the organization who comment at the issue page.

Auto Invite To Org By Issue Comment A GitHub action script to automatically invite everyone to the organization who comment at the issue page. What is

Max Base 6 Jun 08, 2022