-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgibdd.js
155 lines (131 loc) · 4.65 KB
/
gibdd.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
const puppeteer = require('puppeteer')
const { getV3Token, reportAnswer } = require('./solverv3.js')
var qs = require('querystring')
const targetUrl = 'https://xn--90adear.xn--p1ai/check/auto'
const attemptsLimit = 9
const interceptUrls = [
{
url: 'https://xn--b1afk4ade.xn--90adear.xn--p1ai/proxy/check/auto/history',
checkType: 'history',
action: 'check_auto_history',
attempts: 0,
success: false
},
{
url: 'https://xn--b1afk4ade.xn--90adear.xn--p1ai/proxy/check/auto/dtp',
checkType: 'aiusdtp',
action: 'check_auto_dtp',
attempts: 0,
success: false
},
{
url: 'https://xn--b1afk4ade.xn--90adear.xn--p1ai/proxy/check/auto/wanted',
checkType: 'wanted',
action: 'check_auto_wanted',
attempts: 0,
success: false
},
{
url: 'https://xn--b1afk4ade.xn--90adear.xn--p1ai/proxy/check/auto/restrict',
checkType: 'restricted',
action: 'check_auto_restricted',
attempts: 0,
success: false
}
]
let params = {
action: undefined,
min_score: '0.7',
googlekey: '6Lc66nwUAAAAANZvAnT-OK4f4D_xkdzw5MLtAYFL',
pageurl: 'http://xn--b1afk4ade.xn--90adear.xn--p1ai/'
}
const formFillData = {
checkAutoVIN: 'Z94CB41ABHR428327'
}
const browserParams = {
headless: false,
args: [
'--no-sandbox',
'--disable-setuid-sandbox'
],
// executablePath: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome' //let's use real chrome instead of Chromium
}
const checkUrl = (url) => {
let match = interceptUrls.find(u => u.url === url)
if (!match) return false
return match
}
let currentLink = 0
let doThat = async (browser) => {
const page = await browser.newPage()
const clickTheLink = async (ind) => {
try {
await page.evaluate(i => {
if (i < document.querySelectorAll('a.checker').length) {
document.querySelectorAll('a.checker')[i].click()
}
}, ind)
} catch (e) {
console.log(e)
}
}
page.on('request', async (r) => {
let urlObj = checkUrl(r.url())
if (r.method() === 'POST' && urlObj) {
params.action = urlObj.action
let captcha = await getV3Token(params) // getting V3 token from 2captcha/rucaptcha
console.log(captcha.id + ' : ' + captcha.token)
try {
console.log('request intercepted')
const initData = r.postData()
const parsedData = qs.parse(initData)
parsedData.reCaptchaToken = captcha.token // replacing the token in POST data
parsedData.checkType = urlObj.checkType
await r.continue({ postData: qs.stringify(parsedData) }) // sending the request with replaced token
urlObj.attempts++
console.log('Link: ' + currentLink + ' attempt: ' + urlObj.attempts)
const finalResponse = await page.waitForResponse(response => response.url() === r.url() && response.status() === 200, { timeout: 180 * 1000 })
const data = await finalResponse.json()
console.log(data)
if (data.status === 200) {
urlObj.success = true
console.log("passed: " + captcha.id)
await reportAnswer(captcha.id, true)
if (currentLink < 3) {
clickTheLink(++currentLink)
}
} else {
console.log("failed: " + captcha.id)
await reportAnswer(captcha.id, false)
if (currentLink <= 3 && urlObj.attempts <= attemptsLimit) {
clickTheLink(currentLink)
} else {
clickTheLink(++currentLink)
}
}
} catch (e) {
console.log('Huston we have a problem: ' + e)
}
} else {
r.continue()
}
})
await page.setViewport({
width: 1200,
height: 1000
})
await page.setUserAgent('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36')
await page.setRequestInterception(true)
await page.goto(targetUrl);
await page.waitFor(5000)
for (var field in formFillData) {
await page.type('#' + field, formFillData[field])
}
clickTheLink(currentLink)
}
puppeteer.launch(browserParams)
.then((browser) => {
doThat(browser).catch(e => {
console.log(e)
})
})