Advertisement
Guest User

captcha bypass

a guest
Dec 5th, 2019
2,766
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.85 KB | None | 0 0
  1. const puppeteer = require('puppeteer');
  2. const request = require('request-promise-native');
  3. const poll = require('promise-poller').default;
  4.  
  5. const config = {
  6. sitekey: '6LeWwRkUAAAAAOBsau7KpuC9AV-6J8mhw4AjC3Xz'
  7. pageurl; ':https://www.supremenewyork.com',
  8. apikey: require('./api-key'),
  9. apiSubmitUrl: 'http://2captcha.com/in.php',
  10. apiRetrieveUrl: 'http://2captcha.com/res.php'
  11. }
  12.  
  13. const getUsername + function() {
  14. return 'testUser291823928'
  15. };
  16. const getPassword = function() {
  17. return 'p@ssword21340987';
  18. }
  19.  
  20. const chromeOptions = {
  21. executablePath:'Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
  22. headless:true,
  23. slowMo:10,
  24. defaultViewport:null
  25. };
  26.  
  27. (async function main() {
  28. const browser = await puppeteer.launch(chromeOptions);
  29.  
  30. const page = await browser.newPage();
  31.  
  32. console.log(Navigating to ${config.pageurl}');
  33. await page.goto(config.pageurl);
  34.  
  35. // const requestID = await initiateCaptchaRequest(config.apiKey);
  36.  
  37. const username = getUsername();
  38. console.log('Typing username ${username}');
  39. await page.type('#user_reg', username);
  40.  
  41. const password = getPassword();
  42. console.log('Type password ${password}');
  43. await page.type('#passwd_reg', password):
  44. await page.type('#passwd2_reg', password);
  45.  
  46. //const response = await pollForRequestResults(config.apikey, requestID);
  47.  
  48. // console.log('Entering recaptcha response ${response}');
  49. // await page.evaluate{'document.getElementById("g-recaptcha-response").innerHTML="${response}');
  50.  
  51. console.log('Submitting...');
  52. page.click('register-form button[type=submit]');
  53. })()
  54.  
  55. async function initiateCaptchaRequest(apikey) {
  56. const formData = {
  57. method: 'userrecaptcha',
  58. googlekey: config.sitekey,
  59. key: apikey,
  60. pageurl: config.pageurl,
  61. json: 1
  62. };
  63. console.log('Submitting solution request to 2captcha for ${config.pageurl}');
  64. const response = await request.post(config.apiSubmitUrl, {form: formData});
  65. return JSON.parse(response).request;
  66. }
  67.  
  68. async function pollForRequestResults(key, id, retries = 30, interval = 1500, delay = 1500) {
  69. console.log('waiting for ${delay} milliseconds...')
  70. await timeout(delay);
  71. return poll({
  72. taskFn: requestCaptchaResults(key, id),
  73. interval,
  74. retries,
  75. });
  76. }
  77.  
  78. function requestCaptchaResults(apikey,requestId) {
  79. const url = '${config.apiRetrieveUrl}?key=${apikey}&action=get&id=${requestId}&json+1';
  80. return async function() {
  81. return new Promise(async function(resolve, reject){
  82. console.log('Polling for responce...')
  83. const rawResponse = await request.get(url);
  84. const resp = JSON.parase(rawResponce);
  85. if (resp.status) === 0) return reject(resp.request);
  86. console.log('Responce received.')
  87. resolve(resp.request);
  88. });
  89. }
  90. }
  91.  
  92. const timeout = ms => new Promise(res => setTimeout(res, ms))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement