Advertisement
Guest User

Untitled

a guest
Sep 21st, 2016
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  *
  3.  * This script does a POST request to https://discord.me/login using these paramaters:
  4.  *  headers:
  5.  *    Content-Type: application/x-www-form-urlencoded
  6.  *  body:
  7.  *    username=[username]&password=[password]
  8.  *
  9.  * Make sure the username and password are suitable as a query string. (Escape &,=,?,@ etc.)
  10.  *
  11.  * After the post request is made, two cookie paramaters are returned that should be stored in the format of "__cfduid=[id]; session=[session_id]"
  12.  *
  13.  * Once this is done, two simple HEAD requests are made to /server/bump/[SERVER_ID] and /signout with the cookie in the headers.
  14.  *
  15.  */
  16.  
  17. 'use strict';
  18. const https = require('https');
  19. const querystring = require('querystring');
  20. let cookie;
  21. const username = '';
  22. const password = '';
  23.  
  24. // Sign in and store the cookie.
  25. let signinRequest = https.request({
  26.   "hostname": 'discord.me',
  27.   "path": '/signin',
  28.   "method": 'POST',
  29.   "headers": {
  30.     "Content-Type": 'application/x-www-form-urlencoded'
  31.   }
  32. }, (res) => {
  33.   let tempCookie = res.headers['set-cookie'].join(';').split(';');
  34.   for (let i = 0; tempCookie[i]; i++) { // After going through this for loop, cookie contains 'session=[session_id]'
  35.     if (tempCookie[i].indexOf('__cfduid') !== -1) {
  36.       cookie += tempCookie[i];
  37.     }
  38.     if (tempCookie[i].indexOf('session') !== -1) {
  39.       cookie += '; ' + tempCookie[i];
  40.     }
  41.   }
  42.   res.on('data', (chunk) => {
  43.     // No data is returned for a HEAD request.
  44.   });
  45.   res.on('end', () => {
  46.     console.log(res.headers);
  47.     bumpServer();
  48.   });
  49. });
  50. signinRequest.write('username=' + querystring.escape(username) + '&password=' + querystring.escape(password));
  51. signinRequest.end();
  52.  
  53. // Bump the server using the cookie.
  54. let bumpServer = () => {
  55.   let bumpRequest = https.request({
  56.     "hostname": 'discord.me',
  57.     "path": '/server/bump/8835',
  58.     "method": 'HEAD',
  59.     "headers": {
  60.       "Cookie": cookie
  61.     }
  62.   }, (res) => {
  63.     res.on('data', (chunk) => {
  64.       // No data is returned for a HEAD request.
  65.     });
  66.     res.on('end', () => {
  67.       console.log(res.headers);
  68.       signOut();
  69.     })
  70.   }).end();
  71. }
  72.  
  73. // Sign out using the cookie.
  74. let signOut = () => {
  75.   https.request({
  76.     "hostname": 'discord.me',
  77.     "path": '/logout',
  78.     "method": 'HEAD',
  79.     "headers": {
  80.       "Cookie": cookie
  81.     }
  82.   }, (res) => {
  83.     res.on('data', (chunk) => {
  84.       // No data is returned for a HEAD request.
  85.     });
  86.     res.on('end', () => {
  87.       console.log(res.headers);
  88.     });
  89.   }).end();
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement