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
46 changes: 46 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ Examples of API requests for different captcha types are available on the [C# ca
- [DataDome](#datadome)
- [atbCAPTCHA](#atbcaptcha)
- [Tencent](#tencent)
- [Prosopo](#prosopo)
- [Captchafox](#captchafox)
- [Temu](#temu)
- [Other methods](#other-methods)
- [send / getResult](#send--getresult)
- [balance](#balance)
Expand Down Expand Up @@ -488,6 +491,49 @@ tencent.SetAppId("190014885");
tencent.SetPageUrl("https://www.example.com/");
```

### Prosopo

<sup>[API method description.](https://2captcha.com/2captcha-api#prosopo-procaptcha)</sup>

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


```csharp
Prosopo captcha = new Prosopo();

captcha.SetSiteKey("5EZVvsHMrKCFKp5NYNoTyDjTjetoVo1Z4UNNbTwJf1GfN6Xm");
captcha.SetUrl("https://www.twickets.live/");
```

### Captchafox

<sup>[API method description.](https://2captcha.com/2captcha-api#captchafox)</sup>

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


```csharp
Captchafox captcha = new Captchafox();
captcha.SetSiteKey("sk_ILKWNruBBVKDOM7dZs59KHnDLEWiH");
captcha.SetUrl("https://mysite.com/page/with/captchafox");
captcha.SetUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36");
captcha.SetProxy("HTTPS", "login:password@IP_address:PORT");
```

### Temu

<sup>[API method description.](https://2captcha.com/2captcha-api#temucaptcha)</sup>

This method can be used to solve Temu. Returns a coordinates.

```csharp
Temu captcha = new Temu();
captcha.SetBody(bodyStr);
captcha.SetPart1(part1Str);
captcha.SetPart2(part2Str);
captcha.SetPart3(part3Str);
```


## Other methods

Expand Down
30 changes: 30 additions & 0 deletions TwoCaptcha.Examples/CaptchafoxExample.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;
using System.Linq;
using TwoCaptcha.Captcha;

namespace TwoCaptcha.Examples
{
public class CaptchafoxExample
{
public CaptchafoxExample(string apiKey)
{
TwoCaptcha solver = new TwoCaptcha(apiKey);

Captchafox captcha = new Captchafox();
captcha.SetSiteKey("sk_ILKWNruBBVKDOM7dZs59KHnDLEWiH");
captcha.SetUrl("https://mysite.com/page/with/captchafox");
captcha.SetUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36");
captcha.SetProxy("HTTPS", "login:password@IP_address:PORT");

try
{
solver.Solve(captcha).Wait();
Console.WriteLine("Captcha solved: " + captcha.Code);
}
catch (AggregateException e)
{
Console.WriteLine("Error occurred: " + e.InnerExceptions.First().Message);
}
}
}
}
28 changes: 28 additions & 0 deletions TwoCaptcha.Examples/ProsopoExample.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System;
using System.Linq;
using TwoCaptcha.Captcha;

namespace TwoCaptcha.Examples
{
public class ProsopoExample
{
public ProsopoExample(string apiKey)
{
TwoCaptcha solver = new TwoCaptcha(apiKey);

Prosopo captcha = new Prosopo();
captcha.SetSiteKey("5EZVvsHMrKCFKp5NYNoTyDjTjetoVo1Z4UNNbTwJf1GfN6Xm");
captcha.SetUrl("https://www.twickets.live/");

try
{
solver.Solve(captcha).Wait();
Console.WriteLine("Captcha solved: " + captcha.Code);
}
catch (AggregateException e)
{
Console.WriteLine("Error occurred: " + e.InnerExceptions.First().Message);
}
}
}
}
12 changes: 12 additions & 0 deletions TwoCaptcha.Examples/Run.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,18 @@ public static void Main(string[] args)
case "YandexOptionsExample":
YandexOptionsExample YandexOptionsExample = new YandexOptionsExample(apiKey);
break;

case "ProsopoExample":
ProsopoExample ProsopoExample = new ProsopoExample(apiKey);
break;

case "CaptchafoxExample":
CaptchafoxExample CaptchafoxExample = new CaptchafoxExample(apiKey);
break;

case "TemuExample":
TemuExample TemuExample = new TemuExample(apiKey);
break;
}
}
}
43 changes: 43 additions & 0 deletions TwoCaptcha.Examples/TemuExample.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using System;
using System.IO;
using System.Linq;
using TwoCaptcha.Captcha;

namespace TwoCaptcha.Examples
{
public class TemuExample
{
public TemuExample(string apiKey)
{
TwoCaptcha solver = new TwoCaptcha(apiKey);

byte[] bodyBytes = File.ReadAllBytes("resources/temu/body.png");
string bodyStr = Convert.ToBase64String(bodyBytes);

byte[] part1Bytes = File.ReadAllBytes("resources/temu/part1.png");
string part1Str = Convert.ToBase64String(part1Bytes);

byte[] part2Bytes = File.ReadAllBytes("resources/temu/part2.png");
string part2Str = Convert.ToBase64String(part2Bytes);

byte[] part3Bytes = File.ReadAllBytes("resources/temu/part3.png");
string part3Str = Convert.ToBase64String(part3Bytes);

Temu captcha = new Temu();
captcha.SetBody(bodyStr);
captcha.SetPart1(part1Str);
captcha.SetPart2(part2Str);
captcha.SetPart3(part3Str);

try
{
solver.Solve(captcha).Wait();
Console.WriteLine("Captcha solved: " + captcha.Code);
}
catch (AggregateException e)
{
Console.WriteLine("Error occurred: " + e.InnerExceptions.First().Message);
}
}
}
}
42 changes: 40 additions & 2 deletions TwoCaptcha.Examples/TwoCaptcha.Examples.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project Sdk="Microsoft.NET.Sdk" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1;net5.0;net6.0;net7.0</TargetFrameworks>
Expand All @@ -10,6 +10,21 @@
<ProjectReference Include="..\TwoCaptcha\TwoCaptcha.csproj" />
</ItemGroup>

<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>

<ItemGroup>
<EmbeddedResource Update="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>

<ItemGroup>
<None Update="resources\audio-en.mp3">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
Expand Down Expand Up @@ -81,5 +96,28 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>


<ItemGroup>
<None Update="resources\temu\body.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

<ItemGroup>
<None Update="resources\temu\part1.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

<ItemGroup>
<None Update="resources\temu\part2.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

<ItemGroup>
<None Update="resources\temu\part3.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
Binary file added TwoCaptcha.Examples/resources/temu/body.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added TwoCaptcha.Examples/resources/temu/part1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added TwoCaptcha.Examples/resources/temu/part2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added TwoCaptcha.Examples/resources/temu/part3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 32 additions & 0 deletions TwoCaptcha.Tests/CaptchafoxTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using NUnit.Framework;
using TwoCaptcha.Captcha;

namespace TwoCaptcha.Tests
{
[TestFixture]
public class CaptchafoxTest : AbstractWrapperTestCase
{
[Test]
public async Task TestAllOptions()
{
Captchafox captcha = new Captchafox();
captcha.SetSiteKey("sk_ILKWNruBBVKDOM7dZs59KHnDLEWiH");
captcha.SetUrl("https://mysite.com/page/with/captchafox");
captcha.SetUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36");
captcha.SetProxy("HTTPS", "username:password@1.2.3.4:5678");

var parameters = new Dictionary<string, string>();
parameters["method"] = "captchafox";
parameters["sitekey"] = "sk_ILKWNruBBVKDOM7dZs59KHnDLEWiH";
parameters["pageurl"] = "https://mysite.com/page/with/captchafox";
parameters["userAgent"] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36";
parameters["proxy"] = "username:password@1.2.3.4:5678";
parameters["proxytype"] = "HTTPS";
parameters["soft_id"] = "4582";

await CheckIfCorrectParamsSendAndResultReturned(captcha, parameters);
}
}
}
27 changes: 27 additions & 0 deletions TwoCaptcha.Tests/ProsopoTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using NUnit.Framework;
using TwoCaptcha.Captcha;

namespace TwoCaptcha.Tests
{
[TestFixture]
public class ProsopoTest : AbstractWrapperTestCase
{
[Test]
public async Task TestAllOptions()
{
Prosopo captcha = new Prosopo();
captcha.SetSiteKey("5EZVvsHMrKCFKp5NYNoTyDjTjetoVo1Z4UNNbTwJf1GfN6Xm");
captcha.SetUrl("https://www.twickets.live/");

var parameters = new Dictionary<string, string>();
parameters["method"] = "prosopo";
parameters["sitekey"] = "5EZVvsHMrKCFKp5NYNoTyDjTjetoVo1Z4UNNbTwJf1GfN6Xm";
parameters["pageurl"] = "https://www.twickets.live/";
parameters["soft_id"] = "4582";

await CheckIfCorrectParamsSendAndResultReturned(captcha, parameters);
}
}
}
49 changes: 49 additions & 0 deletions TwoCaptcha.Tests/TemuTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using NUnit.Framework;
using TwoCaptcha.Captcha;

namespace TwoCaptcha.Tests
{
[TestFixture]
public class TemuTest : AbstractWrapperTestCase
{

[Test]
public async Task TestAllParameters()
{
byte[] bodyBytes = File.ReadAllBytes("resources/temu/body.png");
string bodyStr = Convert.ToBase64String(bodyBytes);

byte[] part1Bytes = File.ReadAllBytes("resources/temu/part1.png");
string part1Str = Convert.ToBase64String(part1Bytes);

byte[] part2Bytes = File.ReadAllBytes("resources/temu/part2.png");
string part2Str = Convert.ToBase64String(part2Bytes);

byte[] part3Bytes = File.ReadAllBytes("resources/temu/part3.png");
string part3Str = Convert.ToBase64String(part3Bytes);

Temu captcha = new Temu();
captcha.SetBody(bodyStr);
captcha.SetPart1(part1Str);
captcha.SetPart2(part2Str);
captcha.SetPart3(part3Str);


var parameters = new Dictionary<string, string>();
parameters["method"] = "temuimage";
parameters["body"] = bodyStr;
parameters["part1"] = part1Str;
parameters["part2"] = part2Str;
parameters["part3"] = part3Str;
parameters["soft_id"] = "4582";


await CheckIfCorrectParamsSendAndResultReturned(captcha, parameters);
}

}
}
15 changes: 15 additions & 0 deletions TwoCaptcha.Tests/TwoCaptcha.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,19 @@
<ProjectReference Include="..\TwoCaptcha\TwoCaptcha.csproj" />
</ItemGroup>

<ItemGroup>
<None Update="resources\temu\body.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="resources\temu\part1.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="resources\temu\part2.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="resources\temu\part3.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
Binary file added TwoCaptcha.Tests/resources/temu/body.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added TwoCaptcha.Tests/resources/temu/part1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added TwoCaptcha.Tests/resources/temu/part2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added TwoCaptcha.Tests/resources/temu/part3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions TwoCaptcha/Captcha/Captcha.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,10 @@ public Dictionary<string, FileInfo> GetFiles()
{
return new Dictionary<string, FileInfo>(files);
}

public void SetUserAgent(string userAgent)
{
parameters["userAgent"] = userAgent;
}
}
}
Loading