testarash2 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/GemFile +2 -0
- data/GemFile.lock +11 -0
- data/README.md +141 -0
- data/lib/auth/auth.rb +72 -0
- data/lib/auth/metabypass.token +1 -0
- data/lib/helpers.rb +53 -0
- data/lib/metabypass.rb +122 -0
- data/lib/modules/captcha_solver.rb +54 -0
- data/lib/modules/recaptcha.rb +201 -0
- data/metabypass.log +2 -0
- data/samples/icaptcha1.jpg +0 -0
- data/samples/icaptcha2.png +0 -0
- data/testarash2.gemspec +26 -0
- data/usage.rb +45 -0
- metadata +58 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9950fb352a5e855a124f7812c4177fd55304de0156f83dc921da82739ecce511
|
4
|
+
data.tar.gz: e65412cb6fe2f6e246da09ba4a838b6a5a0d3b599fde926cb4644957334c6d9b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a9f39ba33a261f7e3d7a878fbd934b9cd4463ead5a4ee47ef1cbbcfd991151c765b055865eb1a1545417c0994984f88794b9703a5e98601600379579a826742f
|
7
|
+
data.tar.gz: 4153695261e34e7dc248dcea572eb9a6ad79e6d5b7ac037b96ef9f9cb717b6fdd3a97a6f16c556fb5a7d3178c5b8a7e7b0dfab99fb57967195cfd358f6cc0f1b
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
*.gem
|
data/GemFile
ADDED
data/GemFile.lock
ADDED
data/README.md
ADDED
@@ -0,0 +1,141 @@
|
|
1
|
+
# MetaBypass ( AI Captcha Solver )
|
2
|
+
## Ruby class to work with [MetaBypass](https://metabypass.tech) services
|
3
|
+
|
4
|
+
Free demo (no credit card required) -> https://app.metabypass.tech/application
|
5
|
+
|
6
|
+
<br/>
|
7
|
+
|
8
|
+
### Features
|
9
|
+
|
10
|
+
Solve image captcha , reCaptcha v2 & v3 <br/>
|
11
|
+
Auto handler for reCaptcha v2 <br/>
|
12
|
+
Simple syntax <br/>
|
13
|
+
Error logger <br/>
|
14
|
+
|
15
|
+
<br/>
|
16
|
+
<br/>
|
17
|
+
|
18
|
+
## Install via Gem
|
19
|
+
|
20
|
+
Go to your project root directory and run this command in terminal:
|
21
|
+
|
22
|
+
<br/>
|
23
|
+
|
24
|
+
```
|
25
|
+
gem install ruby-metabypass
|
26
|
+
```
|
27
|
+
|
28
|
+
<br/>
|
29
|
+
<br/>
|
30
|
+
|
31
|
+
|
32
|
+
## Usage
|
33
|
+
|
34
|
+
<br/>
|
35
|
+
|
36
|
+
**Image Captcha** <br />
|
37
|
+
```ruby
|
38
|
+
require_relative __dir__+'/lib/metabypass'
|
39
|
+
|
40
|
+
|
41
|
+
# ---------------------------- CREDENTIALS -----------------------------
|
42
|
+
#get your credentials from https://app.metabypass.tech/application
|
43
|
+
|
44
|
+
client_id = 'YOUR_CLIENT_ID'
|
45
|
+
client_secret = 'YOUR_CLIENT_SECRET'
|
46
|
+
email = 'YOUR_EMAIL'
|
47
|
+
password = 'YOUR_PASSWORD'
|
48
|
+
|
49
|
+
|
50
|
+
# Metabypass instance
|
51
|
+
metabypass = Metabypass.new(client_id,client_secret,email,password)
|
52
|
+
|
53
|
+
# ----------------------------IMAGE CAPTCHA SAMPLE -----------------------------
|
54
|
+
#you can pass base64 encoded image file or path of image file
|
55
|
+
img="samples/icaptcha1.jpg"
|
56
|
+
#you can pass some optional params too. more details: https://app.metabypass.tech/docs.html?#api_3
|
57
|
+
numeric=0; #default
|
58
|
+
min_len=0; #default
|
59
|
+
max_len=0; #default
|
60
|
+
image_captcha= metabypass.image_captcha(img,numeric,min_len,max_len)
|
61
|
+
puts metabypass.end_result
|
62
|
+
```
|
63
|
+
<br/><br/>
|
64
|
+
|
65
|
+
**reCaptcha v2** <br />
|
66
|
+
```ruby
|
67
|
+
require_relative __dir__+'/lib/metabypass'
|
68
|
+
|
69
|
+
|
70
|
+
# ---------------------------- CREDENTIALS -----------------------------
|
71
|
+
#get your credentials from https://app.metabypass.tech/application
|
72
|
+
|
73
|
+
client_id = 'YOUR_CLIENT_ID'
|
74
|
+
client_secret = 'YOUR_CLIENT_SECRET'
|
75
|
+
email = 'YOUR_EMAIL'
|
76
|
+
password = 'YOUR_PASSWORD'
|
77
|
+
|
78
|
+
# Metabypass instance
|
79
|
+
metabypass = Metabypass.new(client_id,client_secret,email,password)
|
80
|
+
|
81
|
+
# --------------------------- reCAPTCHA V2 SAMPLE -----------------------------
|
82
|
+
url="SITE_URL"
|
83
|
+
sitekey="SITE_KEY"
|
84
|
+
recaptcha_v2= metabypass.recaptcha_v2_handler(url,sitekey)
|
85
|
+
puts metabypass.end_result
|
86
|
+
```
|
87
|
+
<br/><br/>
|
88
|
+
|
89
|
+
|
90
|
+
**reCaptcha v3** <br />
|
91
|
+
```ruby
|
92
|
+
require_relative __dir__+'/lib/metabypass'
|
93
|
+
|
94
|
+
|
95
|
+
# ---------------------------- CREDENTIALS -----------------------------
|
96
|
+
#get your credentials from https://app.metabypass.tech/application
|
97
|
+
|
98
|
+
client_id = 'YOUR_CLIENT_ID'
|
99
|
+
client_secret = 'YOUR_CLIENT_SECRET'
|
100
|
+
email = 'YOUR_EMAIL'
|
101
|
+
password = 'YOUR_PASSWORD'
|
102
|
+
|
103
|
+
|
104
|
+
# Metabypass instance
|
105
|
+
metabypass = Metabypass.new(client_id,client_secret,email,password)
|
106
|
+
|
107
|
+
# --------------------------- reCAPTCHA V3 SAMPLE -----------------------------
|
108
|
+
url="SITE_URL"
|
109
|
+
sitekey="SITE_KEY"
|
110
|
+
recaptcha_v3= metabypass.recaptcha_v3(url,sitekey)
|
111
|
+
puts metabypass.end_result
|
112
|
+
|
113
|
+
```
|
114
|
+
<br/><br/>
|
115
|
+
|
116
|
+
|
117
|
+
**reCaptcha invisible** <br />
|
118
|
+
```ruby
|
119
|
+
require_relative __dir__+'/lib/metabypass'
|
120
|
+
|
121
|
+
|
122
|
+
# ---------------------------- CREDENTIALS -----------------------------
|
123
|
+
#get your credentials from https://app.metabypass.tech/application
|
124
|
+
|
125
|
+
client_id = 'YOUR_CLIENT_ID'
|
126
|
+
client_secret = 'YOUR_CLIENT_SECRET'
|
127
|
+
email = 'YOUR_EMAIL'
|
128
|
+
password = 'YOUR_PASSWORD'
|
129
|
+
|
130
|
+
|
131
|
+
# Metabypass instance
|
132
|
+
metabypass = Metabypass.new(client_id,client_secret,email,password)
|
133
|
+
|
134
|
+
# --------------------------- reCAPTCHA INVISIBLE SAMPLE -----------------------------
|
135
|
+
url="SITE_URL"
|
136
|
+
sitekey="SITE_KEY"
|
137
|
+
recaptcha_invisible= metabypass.recaptcha_invisible(url,sitekey)
|
138
|
+
puts metabypass.end_result
|
139
|
+
|
140
|
+
```
|
141
|
+
<br/><br/>
|
data/lib/auth/auth.rb
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
require_relative __dir__+"/../helpers"
|
2
|
+
require 'net/http'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
|
6
|
+
class Auth
|
7
|
+
|
8
|
+
# attr_reader :email, :password, :client_id, :client_secret,
|
9
|
+
|
10
|
+
def initialize(client_id,client_secret,email,password)
|
11
|
+
@client_id = client_id
|
12
|
+
@client_secret = client_secret
|
13
|
+
@password = password
|
14
|
+
@email = email
|
15
|
+
@access_token_file_path = File.join(__dir__, 'metabypass.token')
|
16
|
+
@access_token = retrieve_access_token || generate_access_token
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
def generate_access_token
|
21
|
+
|
22
|
+
request_url = 'https://app.metabypass.tech/CaptchaSolver/oauth/token'
|
23
|
+
|
24
|
+
params = {
|
25
|
+
'grant_type' => 'password',
|
26
|
+
'client_id' => @client_id,
|
27
|
+
'client_secret' => @client_secret,
|
28
|
+
'username' => @email,
|
29
|
+
'password' => @password
|
30
|
+
}
|
31
|
+
|
32
|
+
headers = {
|
33
|
+
'Content-Type' => 'application/json',
|
34
|
+
'Accept' => 'application/json'
|
35
|
+
}
|
36
|
+
|
37
|
+
#webservice response
|
38
|
+
response = send_request(request_url, params, 'POST', headers)
|
39
|
+
|
40
|
+
if response.empty?
|
41
|
+
message = 'error! server response is empty'
|
42
|
+
|
43
|
+
#logger
|
44
|
+
logger.error(message)
|
45
|
+
return false
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
headers = JSON.parse(response['headers'])
|
50
|
+
body = JSON.parse(response['body'])
|
51
|
+
|
52
|
+
if headers['http_code'] == 200
|
53
|
+
@access_token = body['access_token']
|
54
|
+
|
55
|
+
File.write(@access_token_file_path, body['access_token'])
|
56
|
+
return body['access_token']
|
57
|
+
else
|
58
|
+
message = 'error! unauth'
|
59
|
+
#logger
|
60
|
+
logger.error(message)
|
61
|
+
return false
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
private
|
67
|
+
|
68
|
+
def retrieve_access_token
|
69
|
+
File.read(@access_token_file_path) if File.exist?(@access_token_file_path)
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiI5NiIsImp0aSI6IjY0NDVjOTY5OTcyNTZiOWU2YTJkZDA3Y2RiYzBhZWI4NDJmYmEzNzg3MmQwYWRlOWMxYTQ2MDQzMWYxMDExZTY2ZjBlN2VlN2U0NTE1MGVhIiwiaWF0IjoxNjg3MjYwMjIxLjY3ODA4NCwibmJmIjoxNjg3MjYwMjIxLjY3ODA4NSwiZXhwIjoxNzE4ODgyNjIxLjY3MDQ5NCwic3ViIjoiMSIsInNjb3BlcyI6W119.NomNdoEQdE3eIG_TbOl8zovfZxcyVs1tD3fl9vfIqZWlVM1C71_FjJoS_2PS2GmuTaxHGrfqMDYvUu_wPMHnltySX7HBZK_jUYomzVd7qGdu9rg5sWqHqV63Z7pktJlcdRmV9Jbp4YW4I1cx-_ULimFd_COyLmYQCy1HcfE73SM18D75wS_Xh-OcOkwjpOhjP0g5YAXEEd_lEMjaC3zjPrr7ai-4AzsqWWouXz0z7O67XZuF_MGIWvsLdyF0yhUYJDNmODdV-s9qw_yVhJ38ILY2IkOLo-9vcePyw6MmwL8rkvsQ2Lbn9SBqf8WCieT9BUK9OQsk_TmCbyemeivUHTq5GwnwZIcQGacbh3-buOf1scKXvDQ054N17dPaFo-3FFCRfBpCdDR-ogTCa03qJRZuz6Fb1-3s93tQj9UcJI7yKBTXJCO662wntHeXht9kil6hOBlPrh3SqsTpgTHOctIws2uo6EIzxwibOReZFwp8Ws9m_5f2mj_nqQOiq-IA2HDhrJK9hhiwlc_fN3ay_qwQP_Ze54GGMUjV3shnfEHZcrq4fS4GmhLJ--Nnq6g09jmyHKFF_QWjIyC7pdoQt6QMjWvxa0ukj4CtfsK4S-nDw_Ag2MzdgdE4o_P_QObs_0S0Dg9MkUWQ15JRGTWIHUCGOT7zyBt4IWe45zaxGfY
|
data/lib/helpers.rb
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'uri'
|
3
|
+
|
4
|
+
|
5
|
+
def send_request(url, params, method, headers)
|
6
|
+
|
7
|
+
#prepare
|
8
|
+
uri = URI(url)
|
9
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
10
|
+
http.use_ssl = true if uri.scheme == 'https'
|
11
|
+
|
12
|
+
#method types
|
13
|
+
case method
|
14
|
+
when 'GET'
|
15
|
+
uri.query = URI.encode_www_form(params)
|
16
|
+
request = Net::HTTP::Get.new(uri)
|
17
|
+
when 'POST'
|
18
|
+
request = Net::HTTP::Post.new(uri)
|
19
|
+
request.body = params.to_json
|
20
|
+
when 'PUT'
|
21
|
+
request = Net::HTTP::Put.new(uri)
|
22
|
+
request.body = params.to_json
|
23
|
+
when 'DELETE'
|
24
|
+
uri.query = URI.encode_www_form(params)
|
25
|
+
request = Net::HTTP::Delete.new(uri)
|
26
|
+
else
|
27
|
+
return {}
|
28
|
+
end
|
29
|
+
|
30
|
+
headers.each { |key, value| request[key] = value }
|
31
|
+
|
32
|
+
response = http.request(request)
|
33
|
+
|
34
|
+
headers= response.to_hash
|
35
|
+
headers['http_code']=response.code.to_i
|
36
|
+
|
37
|
+
{
|
38
|
+
'headers' =>headers.to_json,
|
39
|
+
'body' => response.body
|
40
|
+
}
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
def is_base64_format?(str)
|
45
|
+
|
46
|
+
# Remove whitespace characters from the string
|
47
|
+
cleaned_str = str.gsub(/\s+/, '')
|
48
|
+
|
49
|
+
# Check if the cleaned string is in the valid base64 format
|
50
|
+
# by matching it against the base64 regular expression pattern
|
51
|
+
base64_pattern = /^[a-zA-Z0-9+\/]+={0,2}$/
|
52
|
+
base64_pattern.match?(cleaned_str)
|
53
|
+
end
|
data/lib/metabypass.rb
ADDED
@@ -0,0 +1,122 @@
|
|
1
|
+
require_relative __dir__+'/helpers'
|
2
|
+
require_relative __dir__+'/auth/auth'
|
3
|
+
require_relative __dir__+'/modules/captcha_solver'
|
4
|
+
require_relative __dir__+'/modules/recaptcha'
|
5
|
+
require 'base64'
|
6
|
+
include CaptchaSolver
|
7
|
+
include ReCaptcha
|
8
|
+
require 'logger'
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
class Metabypass < Auth
|
14
|
+
|
15
|
+
attr_accessor :end_result, :logger , :logger_file_path
|
16
|
+
|
17
|
+
|
18
|
+
def initialize(client_id,client_secret,email,password)
|
19
|
+
@end_result = nil
|
20
|
+
@logger_file_path=__dir__+'/../metabypass.log'
|
21
|
+
@logger = Logger.new(@logger_file_path)
|
22
|
+
super(client_id,client_secret,email,password)
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
# Image captcha requester
|
27
|
+
def image_captcha(image, numeric = 0, minLen = 0, maxLen = 0)
|
28
|
+
|
29
|
+
@end_result=nil
|
30
|
+
|
31
|
+
# Check if the image is a file or base64
|
32
|
+
if File.exist?(image)
|
33
|
+
|
34
|
+
begin
|
35
|
+
|
36
|
+
context = File.binread(image)
|
37
|
+
base64EncodedFile = Base64.encode64(context).delete("\r\n")
|
38
|
+
|
39
|
+
rescue Errno::ENOENT => e
|
40
|
+
#logger
|
41
|
+
message='file did not read'
|
42
|
+
logger.error(message)
|
43
|
+
false
|
44
|
+
end
|
45
|
+
|
46
|
+
elsif is_base64_format?(image)
|
47
|
+
base64EncodedFile = image
|
48
|
+
else
|
49
|
+
#logger
|
50
|
+
message='invalid image. pass image path or valid base64 of image'
|
51
|
+
logger.error(message)
|
52
|
+
false
|
53
|
+
end
|
54
|
+
|
55
|
+
image_captcha_requester(base64EncodedFile, numeric, minLen, maxLen)
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
|
60
|
+
# Simple reCaptcha v2 requester without handling the result
|
61
|
+
def recaptcha_v2(url, siteKey)
|
62
|
+
@end_result=nil
|
63
|
+
# This is just an API caller for developers
|
64
|
+
recaptcha_v2_requester(url, siteKey)
|
65
|
+
end
|
66
|
+
|
67
|
+
|
68
|
+
# reCaptcha v2 requester & result handler
|
69
|
+
def recaptcha_v2_handler(url, siteKey)
|
70
|
+
|
71
|
+
@end_result=nil
|
72
|
+
# Request reCaptcha v2 API
|
73
|
+
recaptcha_response = recaptcha_v2_requester(url, siteKey)
|
74
|
+
|
75
|
+
false unless recaptcha_response
|
76
|
+
|
77
|
+
if recaptcha_response['data']['RecaptchaId'].nil?
|
78
|
+
#logger
|
79
|
+
mwssage='invalid reCaptcha v2 response. RecaptchaId not found in response body. '
|
80
|
+
logger.error(message)
|
81
|
+
message
|
82
|
+
false
|
83
|
+
end
|
84
|
+
|
85
|
+
result=nil
|
86
|
+
# Handle getting the result (max: 100 seconds)
|
87
|
+
puts "to get result wait 10 seconds ... (to disable this message go to metabypass.rb file and comment line #{__LINE__})"
|
88
|
+
10.times do
|
89
|
+
|
90
|
+
# Sleep for 10 seconds to get the result
|
91
|
+
sleep(10)
|
92
|
+
|
93
|
+
# Request get result API
|
94
|
+
result = recaptchav2_get_result_requester(recaptcha_response['data']['RecaptchaId'])
|
95
|
+
# puts result.inspect # Show get result response
|
96
|
+
|
97
|
+
if result['status_code'] == 200
|
98
|
+
break
|
99
|
+
else
|
100
|
+
@end_result = false
|
101
|
+
puts "reCAPTCHA result not ready. Wait 10 seconds again... (to disable this message go to metabypass.rb file and comment line #{__LINE__})"
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
result
|
106
|
+
end
|
107
|
+
|
108
|
+
|
109
|
+
# reCaptcha v3 requester
|
110
|
+
def recaptcha_v3(url, siteKey)
|
111
|
+
@end_result=nil
|
112
|
+
recaptcha_v3_requester(url, siteKey)
|
113
|
+
end
|
114
|
+
|
115
|
+
|
116
|
+
# reCaptcha invisible requester
|
117
|
+
def recaptcha_invisible(url, siteKey)
|
118
|
+
@end_result=nil
|
119
|
+
re_captcha_invisible_requester(url, siteKey)
|
120
|
+
end
|
121
|
+
|
122
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require_relative __dir__+'/../helpers'
|
2
|
+
|
3
|
+
module CaptchaSolver
|
4
|
+
|
5
|
+
def image_captcha_requester(image, numeric = 0, min_len = 0, max_len = 0)
|
6
|
+
|
7
|
+
request_url = 'https://app.metabypass.tech/CaptchaSolver/api/v1/services/captchaSolver'
|
8
|
+
|
9
|
+
params = {
|
10
|
+
'image' => image,
|
11
|
+
'numeric' => numeric,
|
12
|
+
'min_len' => min_len,
|
13
|
+
'max_len' => max_len
|
14
|
+
}
|
15
|
+
|
16
|
+
headers = {
|
17
|
+
'Content-Type' => 'application/json',
|
18
|
+
'Authorization' => 'Bearer ' + @access_token.delete("\r\n"),
|
19
|
+
'Accept' => 'application/json'
|
20
|
+
}
|
21
|
+
|
22
|
+
response = send_request(request_url, params, 'POST', headers)
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
if response.empty?
|
27
|
+
message = 'error! server response is empty'
|
28
|
+
logger.error(message)
|
29
|
+
false
|
30
|
+
end
|
31
|
+
|
32
|
+
response_headers = JSON.parse(response['headers'])
|
33
|
+
response_body = JSON.parse(response['body'])
|
34
|
+
|
35
|
+
if response_headers['http_code'] == 200
|
36
|
+
if response_body['status_code'].to_i == 200
|
37
|
+
@end_result = response_body['data']['result']
|
38
|
+
end
|
39
|
+
response_body
|
40
|
+
elsif response_headers['http_code'] == 401
|
41
|
+
status = generate_access_token
|
42
|
+
if status == false
|
43
|
+
puts 'unauth'
|
44
|
+
exit
|
45
|
+
end
|
46
|
+
image_captcha_requester(image, numeric, min_len, max_len)
|
47
|
+
else
|
48
|
+
message = 'error! image captcha'
|
49
|
+
#logger
|
50
|
+
logger.error(message)
|
51
|
+
false
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,201 @@
|
|
1
|
+
require_relative __dir__+'/../helpers'
|
2
|
+
|
3
|
+
|
4
|
+
module ReCaptcha
|
5
|
+
|
6
|
+
# recaptcha v2 requester
|
7
|
+
def recaptcha_v2_requester(url, siteKey)
|
8
|
+
request_url = "https://app.metabypass.tech/CaptchaSolver/api/v1/services/bypassReCaptcha"
|
9
|
+
|
10
|
+
params = {
|
11
|
+
"url" => url,
|
12
|
+
"version" => 2,
|
13
|
+
"sitekey" => siteKey
|
14
|
+
}
|
15
|
+
|
16
|
+
headers = {
|
17
|
+
'Content-Type' => 'application/json',
|
18
|
+
'Authorization' => 'Bearer ' + @access_token.delete("\r\n"),
|
19
|
+
'Accept' => 'application/json'
|
20
|
+
}
|
21
|
+
|
22
|
+
# send request to metabypass
|
23
|
+
response = send_request(request_url, params, 'POST', headers)
|
24
|
+
|
25
|
+
if response.empty?
|
26
|
+
message = 'error! server response is empty'
|
27
|
+
logger.error(message)
|
28
|
+
false
|
29
|
+
end
|
30
|
+
|
31
|
+
response_headers = JSON.parse(response['headers'])
|
32
|
+
response_body = JSON.parse(response['body'])
|
33
|
+
|
34
|
+
if response_headers['http_code'] == 200
|
35
|
+
response_body
|
36
|
+
elsif response_headers['http_code'] == 401
|
37
|
+
status = generate_access_token
|
38
|
+
if status == false
|
39
|
+
puts 'unauth'
|
40
|
+
logger.error('unauth')
|
41
|
+
exit
|
42
|
+
end
|
43
|
+
recaptcha_v2_requester(url, siteKey)
|
44
|
+
else
|
45
|
+
message = 'error! image captcha'
|
46
|
+
#logger
|
47
|
+
logger.error(message)
|
48
|
+
false
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# reCaptcha v3 requester
|
53
|
+
def recaptcha_v3_requester(url, siteKey)
|
54
|
+
request_url = "https://app.metabypass.tech/CaptchaSolver/api/v1/services/bypassReCaptcha"
|
55
|
+
|
56
|
+
params = {
|
57
|
+
"url" => url,
|
58
|
+
"version" => 3,
|
59
|
+
"sitekey" => siteKey
|
60
|
+
}
|
61
|
+
|
62
|
+
headers = {
|
63
|
+
'Content-Type' => 'application/json',
|
64
|
+
'Authorization' => 'Bearer ' + @access_token.delete("\r\n"),
|
65
|
+
'Accept' => 'application/json'
|
66
|
+
}
|
67
|
+
|
68
|
+
# send request to metabypass
|
69
|
+
response = send_request(request_url, params, 'POST', headers)
|
70
|
+
|
71
|
+
if response.empty?
|
72
|
+
message = 'error! server response is empty'
|
73
|
+
#logger
|
74
|
+
logger.error(message)
|
75
|
+
false
|
76
|
+
end
|
77
|
+
|
78
|
+
response_headers = JSON.parse(response['headers'])
|
79
|
+
response_body = JSON.parse(response['body'])
|
80
|
+
|
81
|
+
if response_headers['http_code'] == 200
|
82
|
+
if response_body['status_code'].to_i == 200
|
83
|
+
@end_result = response_body['data']['RecaptchaResponse']
|
84
|
+
end
|
85
|
+
response_body
|
86
|
+
elsif response_headers['http_code'] == 401
|
87
|
+
status = generate_access_token
|
88
|
+
if status == false
|
89
|
+
puts 'unauth'
|
90
|
+
logger.error('unauth')
|
91
|
+
exit
|
92
|
+
end
|
93
|
+
re_captcha_v3_requester(url, siteKey)
|
94
|
+
else
|
95
|
+
message = 'error! image captcha'
|
96
|
+
#logger
|
97
|
+
logger.error(message)
|
98
|
+
false
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
# reCaptcha v3 requester
|
103
|
+
def re_captcha_invisible_requester(url, siteKey)
|
104
|
+
request_url = "https://app.metabypass.tech/CaptchaSolver/api/v1/services/bypassReCaptcha"
|
105
|
+
|
106
|
+
params = {
|
107
|
+
"url" => url,
|
108
|
+
"version" =>'invisible',
|
109
|
+
"sitekey" => siteKey
|
110
|
+
}
|
111
|
+
|
112
|
+
headers = {
|
113
|
+
'Content-Type' => 'application/json',
|
114
|
+
'Authorization' => 'Bearer ' + @access_token.delete("\r\n"),
|
115
|
+
'Accept' => 'application/json'
|
116
|
+
}
|
117
|
+
|
118
|
+
# send request to metabypass
|
119
|
+
response = send_request(request_url, params, 'POST', headers)
|
120
|
+
|
121
|
+
if response.empty?
|
122
|
+
message = 'error! server response is empty'
|
123
|
+
#logger
|
124
|
+
logger.error(message)
|
125
|
+
false
|
126
|
+
end
|
127
|
+
|
128
|
+
response_headers = JSON.parse(response['headers'])
|
129
|
+
response_body = JSON.parse(response['body'])
|
130
|
+
|
131
|
+
if response_headers['http_code'] == 200
|
132
|
+
if response_body['status_code'].to_i == 200
|
133
|
+
@end_result = response_body['data']['RecaptchaResponse']
|
134
|
+
end
|
135
|
+
response_body
|
136
|
+
elsif response_headers['http_code'] == 401
|
137
|
+
status = generate_access_token
|
138
|
+
if status == false
|
139
|
+
puts 'unauth'
|
140
|
+
logger.error('unauth')
|
141
|
+
exit
|
142
|
+
end
|
143
|
+
re_captcha_v3_requester(url, siteKey)
|
144
|
+
else
|
145
|
+
message = 'error! image captcha'
|
146
|
+
#logger
|
147
|
+
logger.error(message)
|
148
|
+
false
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
# reCaptcha get result requester
|
153
|
+
def recaptchav2_get_result_requester(recaptcha_id)
|
154
|
+
|
155
|
+
request_url = "https://app.metabypass.tech/CaptchaSolver/api/v1/services/getCaptchaResult"
|
156
|
+
|
157
|
+
params = {
|
158
|
+
"recaptcha_id" => recaptcha_id
|
159
|
+
}
|
160
|
+
|
161
|
+
headers = {
|
162
|
+
'Content-Type' => 'application/json',
|
163
|
+
'Authorization' => 'Bearer ' + @access_token.delete("\r\n"),
|
164
|
+
'Accept' => 'application/json'
|
165
|
+
}
|
166
|
+
|
167
|
+
# send request to metabypass
|
168
|
+
response = send_request(request_url, params, 'GET', headers)
|
169
|
+
|
170
|
+
if response.empty?
|
171
|
+
message = 'error! server response is empty'
|
172
|
+
|
173
|
+
#logger
|
174
|
+
logger.error(message)
|
175
|
+
false
|
176
|
+
end
|
177
|
+
|
178
|
+
response_headers = JSON.parse(response['headers'])
|
179
|
+
response_body = JSON.parse(response['body'])
|
180
|
+
|
181
|
+
if response_headers['http_code'] == 200
|
182
|
+
if response_body['status_code'].to_i == 200
|
183
|
+
@end_result = response_body['data']['RecaptchaResponse']
|
184
|
+
end
|
185
|
+
response_body
|
186
|
+
elsif response_headers['http_code'] == 401
|
187
|
+
status = generate_access_token
|
188
|
+
if status == false
|
189
|
+
puts 'unauth'
|
190
|
+
logger.error('unauth')
|
191
|
+
exit
|
192
|
+
end
|
193
|
+
recaptchav2_get_result_requester(recaptcha_id)
|
194
|
+
else
|
195
|
+
message = 'error! image captcha'
|
196
|
+
#logger
|
197
|
+
logger.error(message)
|
198
|
+
false
|
199
|
+
end
|
200
|
+
end
|
201
|
+
end
|
data/metabypass.log
ADDED
Binary file
|
Binary file
|
data/testarash2.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$LOAD_PATH.push File.expand_path("lib", __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "testarash2"
|
6
|
+
s.version = '1.0.0'
|
7
|
+
s.platform = Gem::Platform::RUBY
|
8
|
+
s.licenses = ['MIT']
|
9
|
+
s.authors = ["Arash"]
|
10
|
+
s.email = ["arashabedi998@gmail.com"]
|
11
|
+
s.summary = 'test 1.'
|
12
|
+
s.description = 'test 1 easy.'
|
13
|
+
|
14
|
+
s.required_ruby_version = '>= 2.3.0'
|
15
|
+
|
16
|
+
|
17
|
+
# If this line is removed, all hard partying will cease.
|
18
|
+
s.post_install_message = "When you HTTParty, you must party hard!"
|
19
|
+
|
20
|
+
all_files = `git ls-files`.split("\n")
|
21
|
+
|
22
|
+
|
23
|
+
s.files = all_files
|
24
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
25
|
+
s.require_paths = ["lib"]
|
26
|
+
end
|
data/usage.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
require_relative __dir__+'/lib/metabypass'
|
2
|
+
|
3
|
+
|
4
|
+
# ---------------------------- CREDENTIALS -----------------------------
|
5
|
+
|
6
|
+
client_id = 'YOUR_CLIENT_ID'
|
7
|
+
client_secret = 'YOUR_CLIENT_SECRET'
|
8
|
+
email = 'YOUR_EMAIL'
|
9
|
+
password = 'YOUR_PASSWORD'
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
# Metabypass instance
|
14
|
+
metabypass = Metabypass.new(client_id,client_secret,email,password)
|
15
|
+
|
16
|
+
|
17
|
+
# ----------------------------IMAGE CAPTCHA SAMPLE -----------------------------
|
18
|
+
img="samples/icaptcha1.jpg"
|
19
|
+
numeric=0; #default
|
20
|
+
min_len=0; #default
|
21
|
+
max_len=0; #default
|
22
|
+
image_captcha= metabypass.image_captcha(img,numeric,min_len,max_len)
|
23
|
+
puts metabypass.end_result
|
24
|
+
|
25
|
+
|
26
|
+
# # --------------------------- reCAPTCHA V2 SAMPLE -----------------------------
|
27
|
+
# url="SITE_URL"
|
28
|
+
# sitekey="SITE_KEY"
|
29
|
+
# recaptcha_v2= metabypass.recaptcha_v2_handler(url,sitekey)
|
30
|
+
# puts metabypass.end_result
|
31
|
+
|
32
|
+
# --------------------------- reCAPTCHA V3 SAMPLE -----------------------------
|
33
|
+
url="SITE_URL"
|
34
|
+
sitekey="SITE_KEY"
|
35
|
+
recaptcha_v3= metabypass.recaptcha_v3(url,sitekey)
|
36
|
+
puts metabypass.end_result
|
37
|
+
|
38
|
+
|
39
|
+
# --------------------------- reCAPTCHA INVISIBLE SAMPLE -----------------------------
|
40
|
+
url="SITE_URL"
|
41
|
+
sitekey="SITE_KEY"
|
42
|
+
recaptcha_invisible= metabypass.recaptcha_invisible(url,sitekey)
|
43
|
+
puts metabypass.end_result
|
44
|
+
|
45
|
+
|
metadata
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: testarash2
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Arash
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-06-21 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: test 1 easy.
|
14
|
+
email:
|
15
|
+
- arashabedi998@gmail.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- ".gitignore"
|
21
|
+
- GemFile
|
22
|
+
- GemFile.lock
|
23
|
+
- README.md
|
24
|
+
- lib/auth/auth.rb
|
25
|
+
- lib/auth/metabypass.token
|
26
|
+
- lib/helpers.rb
|
27
|
+
- lib/metabypass.rb
|
28
|
+
- lib/modules/captcha_solver.rb
|
29
|
+
- lib/modules/recaptcha.rb
|
30
|
+
- metabypass.log
|
31
|
+
- samples/icaptcha1.jpg
|
32
|
+
- samples/icaptcha2.png
|
33
|
+
- testarash2.gemspec
|
34
|
+
- usage.rb
|
35
|
+
homepage:
|
36
|
+
licenses:
|
37
|
+
- MIT
|
38
|
+
metadata: {}
|
39
|
+
post_install_message: When you HTTParty, you must party hard!
|
40
|
+
rdoc_options: []
|
41
|
+
require_paths:
|
42
|
+
- lib
|
43
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 2.3.0
|
48
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0'
|
53
|
+
requirements: []
|
54
|
+
rubygems_version: 3.4.10
|
55
|
+
signing_key:
|
56
|
+
specification_version: 4
|
57
|
+
summary: test 1.
|
58
|
+
test_files: []
|