Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ Examples of API requests for different captcha types are available on the [C++ c
- [GeeTest v4](#geetest-v4)
- [Amazon WAF](#amazon-waf)
- [Altchacaptcha](#altchacaptcha)
- [Atbcaptcha](#atbcaptcha)
- [Mtcaptcha](#mtcaptcha)
- [Friendlycaptcha](#friendlycaptcha)
- [Tencent](#tencent)
- [Datadome](#datadome)
- [Other methods](#other-methods)
- [send / getResult](#send--get_result)
- [balance](#balance)
Expand Down Expand Up @@ -416,6 +421,60 @@ Use this method to solve Altchacaptcha and obtain a token to bypass the protecti
cap.set_page_url ("https://site.com/");
```

### Atbcaptcha
Use this method to solve Atbcaptcha and obtain a token to bypass the protection.

```c++
api2captcha::captcha_t cap;
cap.set_param("method", "atb_captcha");
cap.set_param("app_id", "af23e041b22d000a11e22a230fa7777c");
cap.set_param("api_server", "https://cap.aisecurius.com");
cap.set_param("pageurl", "https://mysite.com/page/with/atbcaptcha");
```

### Mtcaptcha
Use this method to solve Mtcaptcha and obtain a token to bypass the protection.

```c++
api2captcha::captcha_t cap;
cap.set_param("method", "mt_captcha");
cap.set_param("sitekey", "MTPublic-KzqLY1cKH");
cap.set_param("pageurl", "https://2captcha.com/demo/mtcaptcha");
```

### Friendlycaptcha
Use this method to solve Friendlycaptcha and obtain a token to bypass the protection.

```c++
api2captcha::captcha_t cap;
cap.set_param("method", "friendly_captcha");
cap.set_param("sitekey", "FCMST5VUMCBOCGQ9");
cap.set_param("pageurl", "https://mysite.com/page/with/FriendlyCaptcha");
```

### Tencent
Use this method to solve Tencent and obtain a token to bypass the protection.

```c++
api2captcha::captcha_t cap;
cap.set_param("method", "tencent");
cap.set_param("app_id", "2092215077");
cap.set_param("pageurl", "https://mysite.com/page/with/tencent");
```

### Datadome
Use this method to solve Datadome and obtain a token to bypass the protection.

```c++
api2captcha::captcha_t cap;
cap.set_param("method", "datadome");
cap.set_param("captcha_url", "https://geo.captcha-delivery.com/captcha/?initialCid=AHrlqAAA...");
cap.set_param("pageurl", "https://example.com/");
cap.set_param("userAgent", "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Mobile Safari/537.3");
cap.set_param("proxytype", "HTTPS");
cap.set_param("proxy", "login:password@IP_address:PORT");
```

## Other methods

### send / get_result
Expand Down
35 changes: 19 additions & 16 deletions api2captcha.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ namespace api2captcha
files_t files_;

protected:
public:
captcha_t() {};
// make polymorphic
virtual ~captcha_t() {}

void set_param(const std::string &name, const std::string &value)
{
params_[name] = value;
Expand All @@ -70,19 +75,13 @@ namespace api2captcha
files_[name] = value;
}

captcha_t() {};

public:
// make polymorphic
virtual ~captcha_t() {}

const std::string &id() const { return id_; }
const std::string &code() const { return code_; }

void set_id(const std::string &s) { id_ = s; }
void set_code(const std::string &s) { code_ = s; }

void set_user_agent(const std::string &s)
void set_user_agent(const std::string &s)
{
params_["userAgent"] = s;
};
Expand Down Expand Up @@ -198,7 +197,7 @@ namespace api2captcha

void set_challenge_script(const std::string &challenge_script) { set_param("challenge_script", challenge_script); };
void set_captcha_script(const std::string &captcha_script) { set_param("captcha_script", captcha_script); };
void set_header_acao(const int header_acao) { set_param("header_acao", std::to_string(header_acao)); }
void set_header_acao(const int header_acao) { set_param("header_acao", std::to_string(header_acao)); }
};

class geetest_v4_t : public captcha_t
Expand All @@ -211,7 +210,7 @@ namespace api2captcha

void set_captcha_id(const std::string &captcha_id) { set_param("captcha_id", captcha_id); };
void set_risk_type(const std::string &risk_type) { set_param("risk_type", risk_type); };
void set_header_acao(const int header_acao) { set_param("header_acao", std::to_string(header_acao)); }
void set_header_acao(const int header_acao) { set_param("header_acao", std::to_string(header_acao)); }
void set_pingback(const std::string &pingback) { set_param("pingback", pingback); };
void set_pageurl(const std::string &pageurl) { set_param("pageurl", pageurl); };
};
Expand Down Expand Up @@ -399,7 +398,8 @@ namespace api2captcha
class prosopo_t : public captcha_t
{
public:
prosopo_t(){
prosopo_t()
{
set_param("method", "prosopo");
}

Expand All @@ -410,7 +410,8 @@ namespace api2captcha
class captchafox_t : public captcha_t
{
public:
captchafox_t(){
captchafox_t()
{
set_param("method", "captchafox");
}

Expand Down Expand Up @@ -453,7 +454,8 @@ namespace api2captcha
class yandex_t : public captcha_t
{
public:
yandex_t(){
yandex_t()
{
set_param("method", "yandex");
}

Expand All @@ -464,15 +466,15 @@ namespace api2captcha
class turnstile_t : public captcha_t
{
public:
turnstile_t(){
turnstile_t()
{
set_param("method", "turnstile");
}

void set_site_key(const std::string &s) { set_param("sitekey", s); };
void set_url(const std::string &s) { set_param("pageurl", s); };
};


class vk_t : public captcha_t
{
public:
Expand All @@ -491,7 +493,8 @@ namespace api2captcha
class altchacaptcha_t : public captcha_t
{
public:
altchacaptcha_t(){
altchacaptcha_t()
{
set_param("method", "altcha");
}

Expand All @@ -509,7 +512,7 @@ namespace api2captcha
std::string api_key_;
int soft_id_ = 4586;
std::string callback_;
int default_timeout_ = 120; // sec
int default_timeout_ = 120; // sec
int recaptcha_timeout_ = 600; // sec
int polling_interval_ = 10; // sec
bool last_captcha_has_callback_ = false;
Expand Down
22 changes: 19 additions & 3 deletions examples/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ GPP = g++
CC_OPT = $(OPTIM) -std=c++17 -Wall -pipe $(INC_DIR)

all: normal canvas capy coordinates funcaptcha geetest grid keycaptcha recaptcha \
rotate text vkimage vkcaptcha temu yandex turnstile geetest_v4 amazonwaf
rotate text vkimage vkcaptcha temu yandex turnstile geetest_v4 amazonwaf \
atbcaptcha mtcaptcha friendlycaptcha tencent datadome

normal: normal.o
$(GPP) ${OPTIM} -Wall -o normal normal.o $(LIB_DIR) $(LIB_FILES)
Expand Down Expand Up @@ -78,15 +79,30 @@ geetest_v4: geetest_v4.o
$(GPP) ${OPTIM} -Wall -o geetest_v4 geetest_v4.o $(LIB_DIR) $(LIB_FILES)

amazonwaf: amazonwaf.o
$(GPP) ${OPTIM} -Wall -o amazonwaf amazonwaf.o $(LIB_DIR) $(LIB_FILES)
$(GPP) ${OPTIM} -Wall -o amazonwaf amazonwaf.o $(LIB_DIR) $(LIB_FILES)

atbcaptcha: atbcaptcha.o
$(GPP) ${OPTIM} -Wall -o atbcaptcha atbcaptcha.o $(LIB_DIR) $(LIB_FILES)

mtcaptcha: mtcaptcha.o
$(GPP) ${OPTIM} -Wall -o mtcaptcha mtcaptcha.o $(LIB_DIR) $(LIB_FILES)

friendlycaptcha: friendlycaptcha.o
$(GPP) ${OPTIM} -Wall -o friendlycaptcha friendlycaptcha.o $(LIB_DIR) $(LIB_FILES)

tencent: tencent.o
$(GPP) ${OPTIM} -Wall -o tencent tencent.o $(LIB_DIR) $(LIB_FILES)

datadome: datadome.o
$(GPP) ${OPTIM} -Wall -o datadome datadome.o $(LIB_DIR) $(LIB_FILES)

.cpp.o:
$(GPP) $(CC_OPT) $(DEFINES) -o $@ -c $<

clean:
rm -rf core *~ *.o normal canvas capy coordinates funcaptcha geetest grid hcaptcha \
keycaptcha recaptcha rotate text lemin vkimage vkcaptcha temu yandex turnstile geetest_v4 \
amazonwaf
amazonwaf atbcaptcha mtcaptcha friendlycaptcha tencent datadome

strip: $(PROG)
strip $(PROG)
42 changes: 42 additions & 0 deletions examples/atbcaptcha.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#include <cstdio>
#include <filesystem>
#include <iostream>

#include "curl_http.hpp"
#include "api2captcha.hpp"

using namespace std;

int main (int ac, char ** av)
{
if (ac < 2)
{
printf ("Usage: ./atbcaptcha \"API KEY\"\n");
return 0;
}

api2captcha::curl_http_t http;
http.set_verbose (true);

api2captcha::client_t client;
client.set_http_client (&http);
client.set_api_key (av[1]);

api2captcha::captcha_t cap;
cap.set_param("method", "atb_captcha");
cap.set_param("app_id", "af23e041b22d000a11e22a230fa7777c");
cap.set_param("api_server", "https://cap.aisecurius.com");
cap.set_param("pageurl", "https://mysite.com/page/with/atbcaptcha");

try
{
client.solve (cap);
printf ("code '%s'\n", cap.code ().c_str ());
}
catch (std::exception & e)
{
fprintf (stderr, "Failed: %s\n", e.what ());
}

return 0;
}
46 changes: 46 additions & 0 deletions examples/datadome.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#include <cstdio>
#include <filesystem>
#include <iostream>

#include "curl_http.hpp"
#include "api2captcha.hpp"

using namespace std;

int main (int ac, char ** av)
{
if (ac < 2)
{
printf ("Usage: ./datadome \"API KEY\"\n");
return 0;
}

api2captcha::curl_http_t http;
http.set_verbose (true);

api2captcha::client_t client;
client.set_http_client (&http);
client.set_api_key (av[1]);

api2captcha::captcha_t cap;

cap.set_param("method", "datadome");
cap.set_param("captcha_url", "https://geo.captcha-delivery.com/captcha/?initialCid=AHrlqAAA...");
cap.set_param("pageurl", "https://example.com/");
cap.set_param("userAgent", "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Mobile Safari/537.3");
cap.set_param("proxytype", "HTTPS");
cap.set_param("proxy", "login:password@IP_address:PORT");


try
{
client.solve (cap);
printf ("code '%s'\n", cap.code ().c_str ());
}
catch (std::exception & e)
{
fprintf (stderr, "Failed: %s\n", e.what ());
}

return 0;
}
41 changes: 41 additions & 0 deletions examples/friendlycaptcha.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#include <cstdio>
#include <filesystem>
#include <iostream>

#include "curl_http.hpp"
#include "api2captcha.hpp"

using namespace std;

int main (int ac, char ** av)
{
if (ac < 2)
{
printf ("Usage: ./friendlycaptcha \"API KEY\"\n");
return 0;
}

api2captcha::curl_http_t http;
http.set_verbose (true);

api2captcha::client_t client;
client.set_http_client (&http);
client.set_api_key (av[1]);

api2captcha::captcha_t cap;
cap.set_param("method", "friendly_captcha");
cap.set_param("sitekey", "FCMST5VUMCBOCGQ9");
cap.set_param("pageurl", "https://mysite.com/page/with/FriendlyCaptcha");

try
{
client.solve (cap);
printf ("code '%s'\n", cap.code ().c_str ());
}
catch (std::exception & e)
{
fprintf (stderr, "Failed: %s\n", e.what ());
}

return 0;
}
Loading