Gistrec

vk auth

Oct 12th, 2020
174
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const axios = require('axios');
  2. const qs = require("querystring");
  3.  
  4. axios.defaults.headers.common['Accept'] = 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8';
  5. axios.defaults.headers.common['User-Agent'] = 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36';
  6. axios.defaults.headers.common['Content-Type'] = 'application/x-www-form-urlencoded';
  7.  
  8. const vk = axios.create({
  9.     withCredentials: true
  10. });
  11.  
  12. (async() => {
  13.     // Получаем главную страницу, чтобы справсить параметры ip_h и lg_h
  14.     const main_page = await vk.get('https://vk.com');
  15.  
  16.     let ip_h = null;
  17.     let lg_h = null;
  18.     let to   = null;
  19.  
  20.     if (match = /name="ip_h" value="([a-zA-Z0-9]*)"/.exec(main_page.data)) {
  21.         ip_h = match[1];
  22.     }
  23.     if (match = /name="lg_h" value="([a-zA-Z0-9]*)"/.exec(main_page.data)) {
  24.         lg_h = match[1];
  25.     }
  26.     if (match = /,"to":"([a-zA-Z0-9]*)","/.exec(main_page.data)) {
  27.         to = match[1];
  28.     }
  29. //console.log(main_page.data)
  30.     console.debug(`ip_h => ${ip_h}, lg_h => ${lg_h}, to => ${to}`);
  31. //return;
  32.     const res = await vk.post('https://login.vk.com/?act=login',
  33.         qs.stringify({
  34.             'act': 'login',
  35.             'role': 'al_frame',
  36.             'expire': '',
  37.             'to': to,
  38.             'recaptcha': '',
  39.             'captcha_sid': '',
  40.             'captcha_key': '',
  41.             '_origin': 'https://vk.com',
  42.             'ip_h': ip_h,
  43.             'lg_h': lg_h,
  44.             'ul': '',
  45.             'email': '+79617370099',
  46.             'pass': 'LagySy123'
  47.         }), {
  48.         headers: {
  49.             Cookie: main_page.headers["set-cookie"]
  50.         }}
  51.  
  52.     );
  53.     //console.log(res);
  54.  
  55.     console.log(res.headers)
  56.     //console.log(res.headers["set-cookie"]);
  57.     const page = await axios.get('https://vk.com/adsmarket', {
  58.         withCredentials: true,
  59.             headers: {
  60.                 Cookie: res.headers["set-cookie"]
  61.             }
  62.     });
  63.     console.log(page.data)
  64. })();
Comments
  • User was banned
Add Comment
Please, Sign In to add comment