This repository has been archived by the owner on Mar 5, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexample.pl
executable file
·145 lines (124 loc) · 6.5 KB
/
example.pl
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
#!/bin/perl
use warnings;
use strict;
use File::Basename;
use File::Spec;
# set library path
use lib File::Spec->catfile(dirname(__FILE__), 'lib');
use ImageTyperzAPI;
sub test_api {
# access token, get from: http://www.imagetyperz.com/Forms/ClientHome.aspx
my $access_token = 'access_token_here';
# set your own username and password, legacy way, use access_token instead
# ----------------------------------
my $username = 'your_username'; # legacy authentication, will be deprecated at some point
my $password = 'your_password'; # legacy
# check account balance
# ----------------------
#printf 'Balance token: %s\n', ImageTyperzAPI::account_balance_token($access_token);
printf 'Balance legacy: %s\n', ImageTyperzAPI::account_balance_legacy($username, $password);
# solve normal captcha
# --------------------
my $captcha_text = ImageTyperzAPI::solve_captcha_token($access_token, 'captcha.jpg');
printf 'Captcha text: %s\n', $captcha_text;
# ==============================================================================
# solve recaptcha
# -------------------------
# submit
# -------
my $recaptcha_params = [
token => $access_token,
#username => $username, # for legacy auth
#password => $password, # for legacy auth
action => 'UPLOADCAPTCHA',
pageurl => 'page_url_here', # add --capy or --hcaptcha at the end, to submit capy or hCaptcha
googlekey => 'sitekey_here',
# v3
# recaptchatype => '3', # optional, 1 - normal recaptcha, 2 - invisible recaptcha, 3 - v3 recaptcha, default: 1
# captchaaction => 'homepage', # optional, used in solving v3 recaptcha
# score => '0.3', # optional, min score to target when solving v3 recaptcha
# proxy
# proxy => '12.34.54.56:123', # or '123.43.45.65:123:user:password' with auth - optional
# proxytype => 'HTTP', # if proxy is used, un-comment this as well, only HTTP supported for now
# other optional parameters
# useragent => 'Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0', # optional
# 'data-s' => 'recaptcha data-s value', # optional
# affiliateid => '12344' # affiliate id - optional
];
my $captcha_id = ImageTyperzAPI::submit_recaptcha_token($recaptcha_params);
#my $captcha_id = ImageTyperzAPI::submit_recaptcha_legacy($recaptcha_params);
printf 'Recaptcha ID: %s', $captcha_id;
# retrieve
# -------
while (ImageTyperzAPI::in_progress_token($access_token, $captcha_id)) # while in progress
#while(ImageTyperzAPI::in_progress_legacy($username, $password, $captcha_id)) # while in progress
{
sleep(10); # sleep for 10 seconds
}
printf 'Recaptcha response token: %s\n', ImageTyperzAPI::retrieve_recaptcha_token($access_token, $captcha_id);
#printf 'Recaptcha response token: %s\n', ImageTyperzAPI::retrieve_recaptcha_legacy($username, $password, $captcha_id);
#recaptcha
#----------
#while(ImageTyperzAPI::in_progress_legacy($username, $password, $captcha_id2)) # while in progress
#{
# sleep(10); # sleep for 10 seconds
#}
#printf 'Recaptcha response legacy: %s\n', ImageTyperzAPI::retrieve_recaptcha_legacy($username, $password, $captcha_id2);
## Geetest
my $geetest_params = [(
token => $access_token,
username => $username, # legacy
password => $password, # legacy
action => 'UPLOADCAPTCHA',
domain => 'domain',
challenge => 'geetest challenge',
gt => 'geetest gt'
# proxy
# proxy => '12.34.54.56:123', # or '123.43.45.65:123:user:password' with auth - optional
# proxytype => 'HTTP', # if proxy is used, un-comment this as well, only HTTP supported for now
# other optional parameters
# useragent => 'Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0', # optional
# affiliateid => '12344' # affiliate id - optional
)];
#my $geetest_id = ImageTyperzAPI::submit_geetest_token($geetest_params);
my $geetest_id = ImageTyperzAPI::submit_geetest_legacy($geetest_params);
printf 'Geetest ID: %s', $geetest_id;
while(ImageTyperzAPI::in_progress_geetest([(
token => $access_token,
username => $username, # legacy
password => $password, # legacy
captchaid => $geetest_id,
action => 'GETTEXT'
)])) # while in progress
{
sleep(10); # sleep for 10 seconds
}
printf 'Geetest response: %s\n', ImageTyperzAPI::retrieve_geetest([(
token => $access_token,
username => $username, # legacy
password => $password, # legacy
captchaid => $geetest_id,
action => 'GETTEXT'
)]);
# challenge;;;validate;;;seccode
# 5fcc6e26a128024f7327a355350043007t;;;cb9d32041e4765e9f825a0fa03e3ebeb;;;cb9d32041e4765e9f825a0fa03e3ebeb|jordan
# Other examples
# ---------------------------------------------------------------------------------------------------------------------------------
# solve image captcha with optional parameters
# token [or username & password if legacy], image, case sensitive, is phrase, is math, alphanumeric, minlength, maxlength, refid
# my $captcha_text = ImageTyperzAPI::solve_captcha_token($access_token, 'captcha.jpg', 'true', 'true', 'true', '2', '1', '7', '123');
# my $captcha_text = ImageTyperzAPI::solve_captcha_legacy($username, $password, 'captcha.jpg', 'true', 'true', 'true', '2', '1', '7', '123');
# method to check if proxy was used, response is json
# {
# "Result": "gresponse from solving, or empty if not solved yet",
# "Proxy_client": "proxy submitted by client (if any)",
# "Proxy_worker": "proxy used by worker, in case client submitted, and no errors with proxy",
# "Proxy_reason": "in case of proxy not working, reason will be found here"
# }
#printf 'Was proxy used: %s\n', ImageTyperzAPI::was_proxy_used_token($access_token, $captcha_id);
#printf 'Was proxy used: %s\n', ImageTyperzAPI::was_proxy_used_legacy($username, $password, $captcha_id);
# printf 'Set captcha bad response token: %s\n', ImageTyperzAPI::set_captcha_bad_token($access_token, $captcha_id); # set captcha as bad
# printf 'Set captcha bad response legacy: %s\n', ImageTyperzAPI::set_captcha_bad_legacy($username, $password, $captcha_id2); # set captcha as bad, legacy
}
test_api(); # test API
1;