Skip to content

Instantly share code, notes, and snippets.

@m-Phoenix852
Created August 26, 2020 07:45
Show Gist options
  • Select an option

  • Save m-Phoenix852/b47fffb0fd579bc210420cedbda30b61 to your computer and use it in GitHub Desktop.

Select an option

Save m-Phoenix852/b47fffb0fd579bc210420cedbda30b61 to your computer and use it in GitHub Desktop.
Simple script to log in to discord account using token.
let token = "your token";
function login(token) {
setInterval(() => {
document.body.appendChild(document.createElement `iframe`).contentWindow.localStorage.token = `"${token}"`
}, 50);
setTimeout(() => {
location.reload();
}, 2500);
}
login(token);
@kyan0045

kyan0045 commented Dec 24, 2024

Copy link
Copy Markdown

it literally does work, try in chrome, operagx, or zen, tried all 3

@Maxhem2

Maxhem2 commented Dec 29, 2024

Copy link
Copy Markdown

Just paste and run it about three to four times quickly it will work

@spekly

spekly commented Dec 30, 2024

Copy link
Copy Markdown

it doesnt work for me, when i put the token in the brackets and press enter it says Uncaught SyntaxError: missing ) after argument list

@yum1234

yum1234 commented Dec 30, 2024

Copy link
Copy Markdown

it doesnt work for me, when i put the token in the brackets and press enter it says Uncaught SyntaxError: missing ) after argument list

You have to put it in the quote at the first line, not the brackets. I tested it like a week ago.
let token = "your token"; #put here!!!

@spekly

spekly commented Dec 30, 2024

Copy link
Copy Markdown

i just realized that, i did it but it still says Uncaught SyntaxError: missing ) after argument list
!
Uploading Screenshot 2024-12-30 151959.png…

@yum1234

yum1234 commented Dec 30, 2024

Copy link
Copy Markdown

Did you leave the quotes? Paste ur token, but only replace the (your token) part and leave the quotes surrounding it?

@spekly

spekly commented Dec 30, 2024

Copy link
Copy Markdown

yep i left the quotes, idk if u can see the screenshot

@yum1234

yum1234 commented Dec 30, 2024

Copy link
Copy Markdown

Oh sorry it still is loading for me

@spekly

spekly commented Dec 30, 2024

Copy link
Copy Markdown

Screenshot 2024-12-30 151959

@yum1234

yum1234 commented Dec 30, 2024

Copy link
Copy Markdown

I think I see the issue...?
document.body.appendChild(document.createElement `iframe`).contentWindow.localStorage.token = `"${token}"`
}, 50);

`"${token}"`
What happened to ' and ' ?

Same for iframe? ' ' is missing
I'm not sure if it disappears, in fact I'll go look in my own editor in a few min

I'll prob ask chatgpt too

@spekly

spekly commented Dec 30, 2024

Copy link
Copy Markdown

thanks

@yum1234

yum1234 commented Dec 30, 2024

Copy link
Copy Markdown

Copy this! there is now a () that covers the iframe.

let token = "your token";

function login(token) {
    setInterval(() => {
        const iframe = document.createElement("iframe");
        document.body.appendChild(iframe);
        iframe.contentWindow.localStorage.token = `${token}`;
    }, 50);

    setTimeout(() => {
        location.reload();
    }, 2500);
}

let token = "your_token_here"; // Replace with your actual token value
login(token);

Tell me if this works, i think it will help everyone else who has been having issues...

@spekly

spekly commented Dec 30, 2024

Copy link
Copy Markdown

i got an unexpected token error? wait i forgot to paste it in the other spot

@spekly

spekly commented Dec 30, 2024

Copy link
Copy Markdown

image

@yum1234

yum1234 commented Dec 30, 2024

Copy link
Copy Markdown

The backticks are missing for ${token}

"Use backticks () for embedding variables or expressions, like ${token}`."

is ur editor like deleting the backticks? try inserting them manually


let token = "your token";


function login(token) {
    setInterval(() => {
        const iframe = document.createElement("iframe");
        document.body.appendChild(iframe);
        iframe.contentWindow.localStorage.token = `${token}`;
    }, 50);

    setTimeout(() => {
        location.reload();
    }, 2500);
}

let token = "your_token_here"; // Replace with your actual token value
login(token);

@spekly

spekly commented Dec 30, 2024

Copy link
Copy Markdown

they are added now but a new error comes up
image

@pxldevv

pxldevv commented Dec 30, 2024

Copy link
Copy Markdown

Yeah @yum1234 is correct, your back ticks are being deleted, if this is an unavoidable issue, I have a one line version you can use as a bookmark.

@pxldevv

pxldevv commented Dec 30, 2024

Copy link
Copy Markdown

@spekly reload, you declared your variable one too many times

@yum1234

yum1234 commented Dec 30, 2024

Copy link
Copy Markdown

sorry i accidentally pasted let token twice

let token = "your_token_here"; // Replace with your actual token value

function login(token) {
    setInterval(() => {
        const iframe = document.createElement("iframe");
        document.body.appendChild(iframe);
        iframe.contentWindow.localStorage.token = `${token}`;
    }, 50);

    setTimeout(() => {
        location.reload();
    }, 2500);
}


login(token);

@pxldevv

pxldevv commented Dec 30, 2024

Copy link
Copy Markdown

Oh that makes sense 😄

@spekly

spekly commented Dec 30, 2024

Copy link
Copy Markdown

it just says this then reloads the page
image

@yum1234

yum1234 commented Dec 30, 2024

Copy link
Copy Markdown

that means it works! close ur console and u should be logged in

@spekly

spekly commented Dec 30, 2024

Copy link
Copy Markdown

i mean it refreshes the page and the login screen still stays the same, maybe the token is wrong?

@yum1234

yum1234 commented Dec 30, 2024

Copy link
Copy Markdown

Did you get your token from the authorization header? And not from local storage? They are different

@spekly

spekly commented Dec 30, 2024

Copy link
Copy Markdown

how do i get a token from an authorization header?

@yum1234

yum1234 commented Dec 30, 2024

Copy link
Copy Markdown

Have your developer console open, with it switched to the network tab. Log in normally with your credentials. Do anything, and you will see a bunch of network requests pop up. Click on one of them, and switch to the header tab of the network request. Scroll down to authorization. Copy the string (this is your REAL token). (note if you don't see an authorization header please check a different packet. Send a message too and you will see even more network requests)

image

@spekly

spekly commented Dec 30, 2024

Copy link
Copy Markdown

do i need to be in my account to get this? im trying to get into my old account and all i have is the token, idk if its from local storage or not

@spekly

spekly commented Dec 30, 2024

Copy link
Copy Markdown

@yum1234 actually, i think my token IS from my network tab in console. I've tested using the authorization token to log in with the script and it still doesn't work.

@yum1234

yum1234 commented Dec 30, 2024

Copy link
Copy Markdown

I was in the same boat and to be honest I am not entirely sure. There might be a way to change your token so that its valid. A token is made out of 3 parts. The first part is a user ID. The second part is a timestamp. The third part is a crytographic string representing your username and password. You can very easily get the first and second part. The third part not so much. But if you have the third part, you might be able to manipulate the first and second part.

It seems like discord changed their token structure several times over, and there are many false or i guess old tokens that no longer fit the new system? There isn't much infomation aside from a few advanced programs...

Your old token may contain that third cryptographic part. It is now jsut a matter of modifying it to match the authorization header.

image

@yum1234

yum1234 commented Dec 30, 2024

Copy link
Copy Markdown

Are you still possibly logged into your old account?

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