· 5 years ago · Aug 07, 2020, 06:04 PM
1var Nagibaka = {
2
3
4 /**
5 * Solve Google reCaptcha v.2 with rucaptcha.com service
6 *
7 * @author: Nagibaka<nagibaka.ru>
8 * @date: 18.01.2017
9 * @version : 1.0
10 *
11 * @param {String} ruCaptchaKey [API key from rucaptcha.com]
12 * @return {JSON} [Object with info about success or errors]
13 */
14 fuckReCaptcha2: function (ruCaptchaKey) {
15
16 iimPlayCode('SET !EXTRACT_TEST_POPUP NO');
17 iimPlayCode('SET !ERRORIGNORE YES');
18 iimPlayCode('SET !TIMEOUT_STEP 0');
19
20 var out = {
21 isSolved: false,
22 hasError: false,
23 errorText: "no text"
24 };
25
26 var reqCount = 0;
27
28
29 function checkSolution (gkey, rucapKey) {
30
31 if (reqCount > 14) { // 14 * 5 = 70 second timeout
32
33 out = {
34 isSolved: false,
35 hasError: true,
36 errorText: "Rucaptcha timeout error."
37 };
38
39 return;
40
41 }
42
43 iimPlayCode('WAIT SECONDS=5');
44
45 var XMLHttpRequestT = Components.Constructor("@mozilla.org/xmlextras/xmlhttprequest;1");
46 var xhr = new XMLHttpRequestT();
47 var url = "http://rucaptcha.com/res.php?key=" + ruCaptchaKey + "&action=get&id=" + gkey + "&json=1"
48 xhr.open('GET', url, false);
49 xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
50 xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
51
52 xhr.timeout = 60000;
53
54
55 // processing results
56 try {
57
58 xhr.send();
59
60 if (xhr.status != 200) {
61 out = {
62 isSolved: false,
63 hasError: true,
64 errorText: xhr.statusText
65 };
66 } else {
67 var res = JSON.parse(xhr.responseText);
68 if (res.status == 1) {
69 window.document.querySelector('.g-recaptcha-response').style = "";
70 window.document.querySelector('.g-recaptcha-response').textContent = res.request;
71 out = {
72 isSolved: true,
73 hasError: false,
74 errorText: "Success!"
75 };
76
77 } else {
78 reqCount++;
79 checkSolution (gkey, ruCaptchaKey)
80 }
81 }
82
83 } catch (e) {
84 out = {
85 isSolved: false,
86 hasError: true,
87 errorText: e.name
88 };
89
90 }
91
92
93 }
94
95
96
97 if (window.document.querySelector('.g-recaptcha') == null) {
98 return {
99 isSolved: false,
100 hasError: true,
101 errorText: "Recaptcha not found on page."
102 };
103 }
104
105 var dataSiteKey = window.document.querySelector('.g-recaptcha').getAttribute('data-sitekey');
106 var domen = window.location.host;
107
108 var params = "key=" + ruCaptchaKey + "&method=userrecaptcha&googlekey=" + dataSiteKey + "&pageurl=" + domen + "&json=true&header_acao=1";
109
110 var XMLHttpRequest = Components.Constructor("@mozilla.org/xmlextras/xmlhttprequest;1");
111 var xhr = new XMLHttpRequest();
112 xhr.open('POST', "http://rucaptcha.com/in.php", false);
113 xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
114 xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
115 xhr.timeout = 60000;
116
117 try {
118
119 xhr.send(params);
120
121 if (xhr.status != 200) {
122 out = {
123 isSolved: false,
124 hasError: true,
125 errorText: xhr.statusText
126 };
127 } else {
128 var res = JSON.parse(xhr.responseText);
129 if (res.status == 1) {
130 checkSolution(res.request, ruCaptchaKey);
131 } else {
132 out = {
133 isSolved: false,
134 hasError: true,
135 errorText: xhr.statusText
136 };
137 }
138 }
139
140 } catch (e) {
141 out = {
142 isSolved: false,
143 hasError: true,
144 errorText: e.name
145 };
146
147 }
148
149 return out;
150
151 }
152
153};
154
155
156
157// Пример использования на сайте https://www.google.com/recaptcha/api2/demo
158iimPlayCode('SET !TIMEOUT 30\r\nURL GOTO=https://www.google.com/recaptcha/api2/demo');
159
160var result = Nagibaka.fuckReCaptcha2("XXXXX");
161window.console.log(result);
162
163// Check if captcha solved
164if (result.isSolved) {
165 window.document.querySelector('#recaptcha-demo-submit').click();
166} else {
167 window.console.log(result.errorText)
168}[/