Skip to content

Commit 64a1042

Browse files
added turnstile captcha ; added custom domain for reCAPTCHA and hCaptcha
1 parent fc1592e commit 64a1042

File tree

5 files changed

+133
-3
lines changed

5 files changed

+133
-3
lines changed

hcaptcha.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ def test_api
1919
d['sitekey'] = '1c7062c7-cae6-4e12-96fb-303fbec7fe4f'
2020
# d['invisible'] = '1' # if invisible hcaptcha - optional
2121

22+
# d['domain'] = 'hcaptcha.com' # domain used in loading of hcaptcha interface, default: hcaptcha.com - optional
23+
2224
# extra parameters, useful for enterprise
2325
# submit userAgent from requests too, when this is used
2426
# d['HcaptchaEnterprise'] = {'rqdata': 'take value from web requests'}
@@ -38,7 +40,7 @@ def main
3840
begin
3941
test_api
4042
rescue => details
41-
puts "[!] Error occured: #{details}"
43+
puts "[!] Error occurred: #{details}"
4244
end
4345
end
4446

lib/imagetyperzapi.rb

+59
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
FUNCAPTCHA_ENDPOINT = 'http://captchatypers.com/captchaapi/UploadFunCaptcha.ashx'
2626
TASK_ENDPOINT = 'http://captchatypers.com/captchaapi/UploadCaptchaTask.ashx'
2727
TASK_PUSH_ENDPOINT = 'http://captchatypers.com/CaptchaAPI/SaveCaptchaPush.ashx'
28+
TURNSTILE_ENDPOINT = 'http://captchatypers.com/captchaapi/Uploadturnstile.ashx'
2829

2930
CAPTCHA_ENDPOINT_CONTENT_TOKEN = '/Forms/UploadFileAndGetTextNEWToken.ashx'
3031
CAPTCHA_ENDPOINT_URL_TOKEN = '/Forms/FileUploadAndGetTextCaptchaURLToken.ashx'
@@ -192,6 +193,9 @@ def submit_recaptcha(d)
192193
data['enterprise_type'] = 'v3'
193194
end
194195
end
196+
if d.key? 'domain'
197+
data['domain'] = d['domain']
198+
end
195199
if d.key? 'v3_action'
196200
data['captchaaction'] = d['v3_action']
197201
end
@@ -383,6 +387,11 @@ def submit_hcaptcha(d)
383387
d['HcaptchaEnterprise'] = JSON.generate(d['HcaptchaEnterprise'])
384388
end
385389

390+
if d.key? 'domain'
391+
d['apiEndpoint'] = d['domain']
392+
d.delete('domain')
393+
end
394+
386395
# affiliate id
387396
if @_affiliateid.to_s != '0'
388397
d["affiliateid"] = @_affiliateid.to_s
@@ -444,6 +453,56 @@ def submit_funcaptcha(d)
444453
(JSON.parse response_text)[0]['CaptchaId']
445454
end
446455

456+
def submit_turnstile(d)
457+
# user or token ?
458+
if !@_username.empty?
459+
d["username"] = @_username
460+
d["password"] = @_password
461+
else
462+
d["token"] = @_access_token
463+
end
464+
465+
# affiliate id
466+
if @_affiliateid.to_s != '0'
467+
d["affiliateid"] = @_affiliateid.to_s
468+
end
469+
470+
if d.key? 'user_agent'
471+
d['useragent'] = d['user_agent']
472+
d.delete('user_agent')
473+
end
474+
if d.key? 'domain'
475+
d['apiEndpoint'] = d['domain']
476+
d.delete('domain')
477+
end
478+
if d.key? 'action'
479+
d['taction'] = d['action']
480+
end
481+
if d.key? 'cdata'
482+
d['data'] = d['cdata']
483+
d.delete('cdata')
484+
end
485+
486+
d['action'] = 'UPLOADCAPTCHA'
487+
# create url
488+
params = URI.encode_www_form(d)
489+
url = '%s?%s' % [TURNSTILE_ENDPOINT, params]
490+
491+
# make request
492+
uri = URI.parse(url)
493+
http = Net::HTTP.new(uri.host, uri.port)
494+
data = http.get(uri.request_uri)
495+
response_text = data.body
496+
497+
# check if error
498+
if response_text.include?("ERROR:")
499+
response_err = response_text.split('ERROR:')[1].strip() # get only the
500+
@_error = response_err
501+
raise @_error
502+
end
503+
(JSON.parse response_text)[0]['CaptchaId']
504+
end
505+
447506
def submit_task(d)
448507
d['action'] = 'UPLOADCAPTCHA'
449508
d['captchatype'] = '16'

readme.md

+24-1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ For recaptcha submission there are two things that are required.
6868
- `3` - v3
6969
- `4` - enterprise v2
7070
- `5` - enterprise v3
71+
- domain - used in loading of reCAPTCHA interface, default: `www.google.com` (alternative: `recaptcha.net`) - `optional`
7172
- v3_min_score - minimum score to target for v3 recaptcha `- optional`
7273
- v3_action - action parameter to use for v3 recaptcha `- optional`
7374
- proxy - proxy to use when solving recaptcha, eg. `12.34.56.78:1234` or `12.34.56.78:1234:user:password` `- optional`
@@ -80,6 +81,7 @@ d = {}
8081
d['page_url'] = 'https://your-site.com'
8182
d['sitekey'] = '7LrGJmcUABBAALFtIb_FxC0LXm_GwOLyJAfbbUCL'
8283
# d['type'] = 3 # optional, defaults to 1
84+
# d['domain'] = 'www.google.com' # used in loading reCAPTCHA interface - optional
8385
# d['v3_min_score'] = 0.3 # min score to target when solving v3 - optional
8486
# d['v3_action'] = 'homepage' # action to use when solving v3 - optional
8587
# d['proxy'] = '126.45.34.53:123' # - HTTP proxy - optional
@@ -156,6 +158,9 @@ d['pageurl'] = 'https://your-site.com'
156158
d['sitekey'] = '1c7062c7-cae6-4e12-96fb-303fbec7fe4f'
157159
# d['invisible'] = '1' # if invisible hcaptcha - optional
158160

161+
# domain used in loading of hcaptcha interface, default: hcaptcha.com - optional
162+
# d['domain'] = 'hcaptcha.com'
163+
159164
# extra parameters, useful for enterprise
160165
# submit userAgent from requests too, when this is used
161166
# d['HcaptchaEnterprise'] = {'rqdata': 'take value from web requests'}
@@ -206,6 +211,25 @@ d['surl'] = 'https://api.arkoselabs.com'
206211
captcha_id = ita.submit_funcaptcha d
207212
```
208213

214+
### Turnstile (Cloudflare)
215+
216+
Requires pageurl, sitekey
217+
218+
```ruby
219+
d = {}
220+
d['pageurl'] = 'https://your-site.com'
221+
d['sitekey'] = 'Fme7hXLvuCRNMC3uj10F52D3uNmg5c'
222+
223+
# optional parameters, specific to loading of turnstile interface
224+
# d['domain'] = 'challenges.cloudflare.com' # domain used in loading turnstile interface, default: challenges.cloudflare.com - optional
225+
# d['action'] = 'homepage' # used in loading turnstile interface, similar to reCAPTCHA - optional
226+
# d['cdata'] = 'your cdata information' # used in loading turnstile interface - optional
227+
228+
# d['proxy'] = '126.45.34.53:123' # - HTTP proxy - optional
229+
# d['user_agent'] = 'Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0' # optional
230+
captcha_id = ita.submit_turnstile d
231+
```
232+
209233
### Task
210234

211235
Requires template_name, page_url and usually variables
@@ -265,7 +289,6 @@ The response is a JSON object that looks like this:
265289
"Response": "03AGdBq24PBCbwiDRaS_MJ7Z...mYXMPiDwWUyEOsYpo97CZ3tVmWzrB",
266290
"Cookie_OutPut": "",
267291
"Proxy_reason": "",
268-
"Recaptcha score": 0.0,
269292
"Status": "Solved"
270293
}
271294
```

recaptcha.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ def test_api
2828
#
2929
# d['type'] = 1 # optional, defaults to 1
3030
#
31+
# d['domain'] = 'www.google.com' # used in loading reCAPTCHA interface, default: www.google.com (alternative: recaptcha.net) - optional
3132
# d['v3_min_score'] = 0.3 # min score to target when solving v3 - optional
3233
# d['v3_action'] = 'homepage' # action to use when solving v3 - optional
3334
# d['proxy'] = '126.45.34.53:123' # - HTTP proxy - optional
@@ -53,7 +54,7 @@ def main
5354
begin
5455
test_api
5556
rescue => details
56-
puts "[!] Error occured: #{details}"
57+
puts "[!] Error occurred: #{details}"
5758
end
5859
end
5960

turnstile.rb

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/ruby
2+
3+
# Imagetypers API test
4+
load "lib/imagetyperzapi.rb"
5+
6+
def test_api
7+
# grab token from https://imagetyperz.com
8+
access_token = "access_token_here"
9+
ita = ImageTyperzAPI.new(access_token)
10+
11+
# check account balance
12+
balance = ita.account_balance # get balance
13+
puts "Account balance: #{balance}" # print balance
14+
15+
# submit image captcha, and check for solution
16+
puts "Waiting for captcha to be solved..."
17+
d = {}
18+
d['pageurl'] = 'https://your-site.com'
19+
d['sitekey'] = '0x4ABBBBAABrfvW5vKbx11FZ'
20+
21+
# optional parameters, specific to loading of turnstile interface
22+
# d['domain'] = 'challenges.cloudflare.com' # domain used in loading turnstile interface, default: challenges.cloudflare.com - optional
23+
# d['action'] = 'homepage' # used in loading turnstile interface, similar to reCAPTCHA - optional
24+
# d['cdata'] = 'your cdata information' # used in loading turnstile interface - optional
25+
26+
# d['proxy'] = '126.45.34.53:123' # - HTTP proxy - optional
27+
# d['user_agent'] = 'Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0' # optional
28+
captcha_id = ita.submit_turnstile d
29+
response = nil
30+
while response == nil
31+
sleep 10
32+
response = ita.retrieve_response captcha_id
33+
end
34+
puts "Response: #{response}"
35+
end
36+
37+
def main
38+
begin
39+
test_api
40+
rescue => details
41+
puts "[!] Error occurred: #{details}"
42+
end
43+
end
44+
45+
main

0 commit comments

Comments
 (0)