Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 021a540
Showing
7 changed files
with
368 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2013 Ran Mizrahi <ran@cocycles.com> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
BestCaptchaSolver.com php API wrapper | ||
========================================= | ||
|
||
bestcaptchasolver-php is a super easy to use bypass captcha php API wrapper for bestcaptchasolver.com captcha service | ||
|
||
## Installation | ||
|
||
composer require bestcaptchasolver/bestcaptchasolver | ||
|
||
or | ||
|
||
git clone https://github.com/bestcaptchasolver/bestcaptchasolver-php | ||
|
||
## How to use? | ||
|
||
Simply require the module, set the auth details and start using the captcha service: | ||
|
||
``` php | ||
require('lib/bestcaptchasolver.php'); | ||
``` | ||
|
||
Initialize library with access token | ||
|
||
Get token from [https://bestcaptchasolver.com/account](https://bestcaptchasolver.com/account) | ||
``` php | ||
$bcs = new BestCaptchaSolver($ACCESS_TOKEN); | ||
``` | ||
|
||
Once you've set your authentication details, you can start using the API | ||
|
||
**Get balance** | ||
|
||
Returns balance in USD | ||
``` php | ||
$balance = $bcs->account_balance(); | ||
``` | ||
|
||
**Submit image captcha** | ||
|
||
You can give it a b64 encoded string or a file path | ||
|
||
``` php | ||
$id = $bcs->submit_image_captcha('captcha.jpg'); | ||
``` | ||
Optionally, you can give it a 2nd argument (boolean), for case sensitivity | ||
|
||
**Retrieve image text** | ||
|
||
Once you have the captcha ID, you can check for completion of captcha | ||
```php | ||
$image_text = NULL; | ||
while($image_text === NULL) { | ||
$image_text = $bcs->retrieve($id); // get the image text (if completed) | ||
sleep(2); // retry every 2 seconds | ||
} | ||
``` | ||
|
||
**Submit recaptcha details** | ||
|
||
For recaptcha submission there are two things that are required. | ||
- page_url | ||
- site_key | ||
``` php | ||
$id = $bcs->submit_recaptcha($PAGE_URL, $SITE_KEY); | ||
``` | ||
Optionally, you can give it a 3rd argument (string) for proxy, in the following format: | ||
`12.34.56.78:1234` or `user:password@12.34.56.78:1234` if authentication is required | ||
|
||
**Retrieve recaptcha gresponse** | ||
|
||
Just as the image captcha, once you have the ID, you can start checking for it's | ||
completion using the same retrieve method. The response (when ready) will be a gresponse code | ||
|
||
```php | ||
$gresponse = NULL; | ||
while($image_text === NULL) { | ||
$gresponse = $bcs->retrieve($id); // get the image text (if completed) | ||
sleep(2); // retry every 2 seconds | ||
} | ||
``` | ||
**Set captcha bad** | ||
|
||
When a captcha was solved wrong by our workers, you can notify the server with it's ID, | ||
so we know something went wrong. | ||
|
||
``` php | ||
$bcs->set_captcha_bad(50); | ||
``` | ||
|
||
## Examples | ||
Check example.php | ||
|
||
## License | ||
API library is licensed under the MIT License | ||
|
||
## More information | ||
More details about the server-side API can be found [here](https://bestcaptchasolver.com/api) | ||
|
||
|
||
<sup><sub>captcha, bypasscaptcha, decaptcher, decaptcha, 2captcha, deathbycaptcha, anticaptcha, | ||
bypassrecaptchav2, bypassnocaptcharecaptcha, bypassinvisiblerecaptcha, captchaservicesforrecaptchav2, | ||
recaptchav2captchasolver, googlerecaptchasolver, recaptchasolverpython, recaptchabypassscript, bestcaptchasolver</sup></sub> | ||
|
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"name": "bestcaptchasolver/bestcaptchasolver", | ||
"type": "library", | ||
"description": "bestcaptchasolver is a super easy to use bypass captcha php API wrapper for bestcaptchasolver.com captcha service", | ||
"keywords": [ | ||
"captcha", | ||
"bypasscaptcha", | ||
"decaptcher", | ||
"decaptcha", | ||
"2captcha", | ||
"deathbycaptcha", | ||
"anticaptcha", | ||
"bypass recaptcha v2", | ||
"bypass no captcha recaptcha", | ||
"bypass invisible recaptcha", | ||
"captcha services for recaptcha v2", | ||
"recaptcha v2 captcha solver", | ||
"google recaptcha solver", | ||
"recaptcha solver python", | ||
"recaptcha bypass script", | ||
"bestcaptchasolver" | ||
], | ||
"homepage": "https://github.com/bestcaptchasolver/bestcaptchasolver-php", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "BestCaptchaSolver", | ||
"email": "bcsolver@gmail.com", | ||
"homepage": "https://bestcaptchasolver.com", | ||
"role": "Developer" | ||
} | ||
], | ||
"require": { | ||
"php": ">=5.3.0", | ||
"ext-curl": "*" | ||
} | ||
} | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#!/usr/bin/php | ||
|
||
<?php | ||
|
||
require('lib/bestcaptchasolver.php'); // load API library | ||
// Test method | ||
|
||
function test_api() { | ||
$ACCESS_TOKEN = 'your_access_token'; | ||
$PAGE_URL = 'recaptcha_page_url'; | ||
$SITE_KEY = 'recaptcha_site_key'; | ||
|
||
$bcs = new BestCaptchaSolver($ACCESS_TOKEN); // get token from https://bestcaptchasolver.com/account | ||
// check account balance | ||
$balance = $bcs->account_balance(); // get balance | ||
echo "Balance: $balance"; | ||
|
||
// works | ||
echo 'Solving captcha ...'; | ||
$id = $bcs->submit_image_captcha('captcha.jpg'); | ||
$image_text = NULL; | ||
while($image_text === NULL) { | ||
$image_text = $bcs->retrieve($id); // get the image text (if completed) | ||
sleep(2); // retry every 2 seconds | ||
} | ||
echo "Captcha text: $image_text"; | ||
// solve recaptcha | ||
echo 'Submitting recaptcha...'; | ||
$id = $bcs->submit_recaptcha($PAGE_URL, $SITE_KEY); | ||
// get response now that we have the ID | ||
$gresponse = NULL; | ||
while($gresponse === NULL) { | ||
$gresponse = $bcs->retrieve($id); // get the image text (if completed) | ||
sleep(5); // retry every 5 seconds | ||
} | ||
|
||
// completed at this point | ||
echo "Recaptcha response: $gresponse"; | ||
|
||
// $bcs->submit_image_captcha('captcha.jpg', true); // case sensitive completion of image captcha | ||
// $bcs->submit_recaptcha($PAGE_URL, $SITE_KEY, '126.34.43.3:123'); // use proxy, works with user:pass@ip:port as well | ||
// $bcs->set_captcha_bad(50); // set bad captcha for specific id | ||
} | ||
|
||
// Main method | ||
function main() { | ||
try { | ||
test_api(); // test API | ||
} catch (Exception $ex) { | ||
echo "Error occured: " . $ex->getMessage(); // print error | ||
} | ||
} | ||
|
||
main(); // run main function | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
<?php | ||
|
||
define('BASE_URL', 'https://bcsapi.xyz/api'); | ||
define('USER_AGENT', 'phpAPI1.0'); | ||
|
||
// Utils class | ||
class Utils { | ||
// Check if string starts with | ||
public static function starts_with($haystack, $needle) { | ||
$length = strlen($needle); | ||
return (substr($haystack, 0, $length) === $needle); | ||
} | ||
|
||
// Make get request | ||
public static function GET($url, $user_agent, $timeout) { | ||
$ch = curl_init(); | ||
curl_setopt($ch, CURLOPT_URL, $url); | ||
curl_setopt($ch, CURLOPT_USERAGENT, $user_agent); | ||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | ||
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); | ||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); | ||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); | ||
$results = curl_exec($ch); | ||
curl_close($ch); | ||
$js = json_decode($results, true); | ||
if(isset($js['status'])) if($js['status'] === 'error') throw new Exception($js['message']); | ||
return $js; | ||
} | ||
|
||
// Make post request | ||
public static function POST($url, $params, $user_agent, $timeout) { | ||
$ch = curl_init(); | ||
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json')); | ||
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params)); | ||
curl_setopt($ch, CURLOPT_URL, $url); | ||
curl_setopt($ch, CURLOPT_USERAGENT, $user_agent); | ||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | ||
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); | ||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); | ||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); | ||
$results = curl_exec($ch); | ||
curl_close($ch); | ||
$js = json_decode($results, true); | ||
if(isset($js['status'])) if($js['status'] === 'error') throw new Exception($js['message']); | ||
return $js; | ||
} | ||
|
||
// Read file | ||
public static function read_file($file_path) { | ||
$fp = fopen($file_path, "rb"); // open file | ||
if (!$fp) | ||
throw new Exception("cannot read captcha file: " . $file_path); | ||
$file_size = filesize($file_path); // get file size | ||
|
||
if ($file_size <= 0) // check it's length (if OK) | ||
throw new Exception("cannot read captcha file: " . $file_path); | ||
|
||
$data = fread($fp, $file_size); // read file | ||
fclose($fp); // close file | ||
|
||
$b64_data = base64_encode($data); // encode it to base64 | ||
return $b64_data; // return it | ||
} | ||
|
||
} | ||
|
||
class BestCaptchaSolver { | ||
private $_access_token; | ||
private $_timeout; | ||
|
||
function __construct($access_token, $timeout = 120) { | ||
$this->_access_token = $access_token; | ||
$this->_timeout = $timeout; | ||
} | ||
|
||
// Get balance for account | ||
function account_balance(){ | ||
$url = BASE_URL . "/user/balance?access_token=$this->_access_token"; | ||
$response = Utils::GET($url, USER_AGENT, $this->_timeout); | ||
return "$" . $response['balance']; | ||
} | ||
|
||
// Solve captcha | ||
function submit_image_captcha($captcha_file, $case_sensitive = FALSE) { | ||
$data = array(); | ||
if(file_exists($captcha_file)) $captcha_file = Utils::read_file($captcha_file); | ||
$data['access_token'] = $this->_access_token; | ||
$data['b64image'] = $captcha_file; | ||
if($case_sensitive) $data['case_sensitive'] = '1'; | ||
$url = BASE_URL . "/captcha/image"; | ||
$response = Utils::POST($url, $data, USER_AGENT, $this->_timeout); | ||
return $response['id']; | ||
} | ||
|
||
// Submit recaptcha | ||
function submit_recaptcha($page_url, $site_key, $proxy = '') { | ||
$data = array( | ||
"access_token" => $this->_access_token, | ||
"page_url" => $page_url, | ||
"site_key" => $site_key, | ||
); | ||
// if proxy was given, add it | ||
if(!empty($proxy)) { | ||
$data['proxy'] = $proxy; | ||
$data['proxy_type'] = 'HTTP'; | ||
} | ||
$url = BASE_URL . "/captcha/recaptcha"; | ||
$response = Utils::POST($url, $data, USER_AGENT, $this->_timeout); | ||
return $response['id']; | ||
} | ||
|
||
// Get recaptcha response using captcha ID | ||
function retrieve($captcha_id) { | ||
$url = BASE_URL . "/captcha/$captcha_id?access_token=$this->_access_token"; | ||
$response = Utils::GET($url, USER_AGENT, $this->_timeout); | ||
if($response['status'] === 'pending') return NULL; // still pending | ||
if(isset($response['gresponse'])) return $response['gresponse']; | ||
else if(isset($response['text'])) return $response['text']; | ||
} | ||
|
||
// Set captcha bad | ||
function set_captcha_bad($captcha_id) { | ||
// set data array | ||
$data = array( | ||
"access_token" => $this->_access_token, | ||
); | ||
$url = BASE_URL . "/captcha/bad/$captcha_id"; | ||
$resp = Utils::POST($url, $data, USER_AGENT, $this->_timeout); | ||
return $resp['status']; | ||
} | ||
} | ||
?> |