Skip to content

Commit

Permalink
Selfbot update
Browse files Browse the repository at this point in the history
added headers to discord hard to detect selfbot
'x-fingerprint'
cookies
'x-super-properties'
  • Loading branch information
aiko-chan-ai committed Apr 8, 2022
1 parent 590a778 commit f361bed
Show file tree
Hide file tree
Showing 5 changed files with 212 additions and 165 deletions.
1 change: 1 addition & 0 deletions DOCUMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const client = new Client({
new Client({
checkUpdate: true, // Check Package Update (Bot Ready) [Enable Default]
readyStatus: false, // Set Custom Status sync from Account (Bot Ready) [Disable Default]
autoCookie: true, // Auto added Cookie and Fingerprint [Enable Default](https://github.com/aiko-chan-ai/discord.js-selfbot-v13/blob/main/DOCUMENT.md#http-options)
})
```
</details>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "discord.js-selfbot-v13",
"version": "1.2.8",
"version": "1.3.0",
"description": "A unofficial discord.js fork for creating selfbots [Based on discord.js v13]",
"main": "./src/index.js",
"types": "./typings/index.d.ts",
Expand Down
40 changes: 40 additions & 0 deletions src/client/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,46 @@ class Client extends BaseClient {
.join('.')}`,
);

if (this.options.autoCookie) {
/* Auto find fingerprint and add Cookie */
let cookie = '';
await require('axios')({
method: 'get',
url: 'https://discord.com/api/v9/experiments',
headers: this.options.http.headers,
})
.then((res) => {
if (!'set-cookie' in res.headers) return;
res.headers['set-cookie'].map((line) => {
line.split('; ').map((arr) => {
if (
arr.startsWith('Expires') ||
arr.startsWith('Path') ||
arr.startsWith('Domain') ||
arr.startsWith('HttpOnly') ||
arr.startsWith('Secure') ||
arr.startsWith('Max-Age') ||
arr.startsWith('SameSite')
) {
return;
} else {
cookie += `${arr}; `;
}
});
});
this.options.http.headers['Cookie'] = `${cookie}locale=en`;
this.options.http.headers['x-fingerprint'] = res.data.fingerprint;
this.emit(Events.DEBUG, `Added Cookie: ${cookie}`);
this.emit(Events.DEBUG, `Added Fingerprint: ${res.data.fingerprint}`);
})
.catch((err) => {
this.emit(
Events.DEBUG,
`Finding Cookie and Fingerprint failed: ${err.message}`,
);
});
}

if (this.options.presence) {
this.options.ws.presence = this.presence._parse(this.options.presence);
}
Expand Down
172 changes: 87 additions & 85 deletions src/util/Options.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,91 +132,93 @@ class Options extends null {
*/
static createDefault() {
return {
jsonTransformer: (object) => JSONBig.stringify(object),
checkUpdate: true,
readyStatus: false,
waitGuildTimeout: 15_000,
shardCount: 1,
makeCache: this.cacheWithLimits(this.defaultMakeCacheSettings),
messageCacheLifetime: 0,
messageSweepInterval: 0,
invalidRequestWarningInterval: 0,
intents: 65535,
partials: [
'USER',
'CHANNEL',
'GUILD_MEMBER',
'MESSAGE',
'REACTION',
'GUILD_SCHEDULED_EVENT',
], // Enable the partials
restWsBridgeTimeout: 5_000,
restRequestTimeout: 15_000,
restGlobalRateLimit: 0,
retryLimit: 1,
restTimeOffset: 500,
restSweepInterval: 60,
failIfNotExists: false,
userAgentSuffix: [],
presence: {},
sweepers: {},
ws: {
large_threshold: 50,
compress: false,
properties: {
//$os: 'iPhone14,5',
//$browser: 'Discord iOS',
//$device: 'iPhone14,5 OS 15.2',
$os: 'Windows',
$browser: 'Discord Client',
$device: 'ASUS ROG Phone 5',
},
version: 9,
},
http: {
headers: {
Accept: '*/*',
'Accept-Encoding': 'gzip, deflate, br',
'Accept-Language': 'en-US,en;q=0.9',
'Cache-Control': 'no-cache',
Pragma: 'no-cache',
Referer: 'https://discord.com/channels/@me',
'Sec-Ch-Ua': '" Not A;Brand";v="99" "',
'Sec-Ch-Ua-Mobile': '?0',
'Sec-Ch-Ua-Platform': '"iOS"',
'Sec-Fetch-Dest': 'empty',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Site': 'same-origin',
'X-Debug-Options': 'bugReporterEnabled',
// https://github.com/Merubokkusu/Discord-S.C.U.M/issues/66#issuecomment-1009171667
'x-super-properties': `${Buffer.from(
JSONBig.stringify({
os: 'Windows',
browser: 'Discord Client',
release_channel: 'stable',
client_version: '1.0.9004',
os_version: '10.0.22000',
os_arch: 'x64',
system_locale: 'en-US',
client_build_number: 122087,
client_event_source: null,
}),
'ascii',
).toString('base64')}`,
'X-Discord-Locale': 'en-US',
Origin: 'https://discord.com',
'user-agent':
'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) discord/1.0.9004 Chrome/91.0.4472.164 Electron/13.6.6 Safari/537.36',
},
agent: {},
version: 9,
api: 'https://discord.com/api',
cdn: 'https://cdn.discordapp.com',
invite: 'https://discord.gg',
template: 'https://discord.new',
scheduledEvent: 'https://discord.com/events',
},
};
jsonTransformer: (object) => JSONBig.stringify(object),
checkUpdate: true,
readyStatus: false,
autoCookie: true,
waitGuildTimeout: 15_000,
shardCount: 1,
makeCache: this.cacheWithLimits(this.defaultMakeCacheSettings),
messageCacheLifetime: 0,
messageSweepInterval: 0,
invalidRequestWarningInterval: 0,
intents: 65535,
partials: [
'USER',
'CHANNEL',
'GUILD_MEMBER',
'MESSAGE',
'REACTION',
'GUILD_SCHEDULED_EVENT',
], // Enable the partials
restWsBridgeTimeout: 5_000,
restRequestTimeout: 15_000,
restGlobalRateLimit: 0,
retryLimit: 1,
restTimeOffset: 500,
restSweepInterval: 60,
failIfNotExists: false,
userAgentSuffix: [],
presence: {},
sweepers: {},
ws: {
large_threshold: 50,
compress: false,
properties: {
//$os: 'iPhone14,5',
//$browser: 'Discord iOS',
//$device: 'iPhone14,5 OS 15.2',
$os: 'Windows',
$browser: 'Discord Client',
$device: 'ASUS ROG Phone 5',
},
version: 9,
},
http: {
headers: {
Accept: '*/*',
// 'Accept-Encoding': 'gzip, deflate, br', => cause axios bug
'Accept-Language': 'en-US,en;q=0.9',
'Cache-Control': 'no-cache',
Pragma: 'no-cache',
Referer: 'https://discord.com/channels/@me',
'Sec-Ch-Ua':
'"Not A;Brand";v="99", "Chromium";v="100", "Google Chrome";v="100',
'Sec-Ch-Ua-Mobile': '?0',
'Sec-Ch-Ua-Platform': '"Windows"',
'Sec-Fetch-Dest': 'empty',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Site': 'same-origin',
'X-Debug-Options': 'bugReporterEnabled',
// https://github.com/Merubokkusu/Discord-S.C.U.M/issues/66#issuecomment-1009171667
'x-super-properties': `${Buffer.from(
JSONBig.stringify({
os: 'Windows',
browser: 'Discord Client',
release_channel: 'stable',
client_version: '1.0.9004',
os_version: '10.0.22000',
os_arch: 'x64',
system_locale: 'en-US',
client_build_number: 122087,
client_event_source: null,
}),
'ascii',
).toString('base64')}`,
'X-Discord-Locale': 'en-US',
Origin: 'https://discord.com',
'user-agent':
'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) discord/1.0.9004 Chrome/91.0.4472.164 Electron/13.6.6 Safari/537.36',
},
agent: {},
version: 9,
api: 'https://discord.com/api',
cdn: 'https://cdn.discordapp.com',
invite: 'https://discord.gg',
template: 'https://discord.new',
scheduledEvent: 'https://discord.com/events',
},
};
}

/**
Expand Down
Loading

0 comments on commit f361bed

Please sign in to comment.