DeathByCapture provides a .NET assembly for interaction with the mighty workforce overseas that lets you overcome those nasty captchas. Unfortunately you cannot use the assembly when you want to ‘[System.Reflection.Assembly]::LoadFile()’ as the ‘DeathByCaptcha.HttpClient’ is an abstract base class where you cannot pass the login credentials as arguments to the constructor.

Adding the assembly to the GAC is not possible without recompiling as it is missing a strong name. The easiest way when you don’t have Visual Studio is disassemble and reassemble the assembly with a strong name as described on OJ’s blog or elsewhere on the web.

You can then use the assembly as usual, after you added it to the GAC; for example like this:

$credDbc = Get-Credential;
$c = New-Object DeathByCaptcha.HttpClient -ArgumentList $credDbc.UserName, $credDbc.GetNetworkCredential().Password;
$CaptchaPathAndFileName = "$PWD\SomeCaptchaFile.jpg";
$Captcha = $c.Decode($CaptchaPathAndFileName, 30);

Id : 12345678
Uploaded : True
Text : abcd
Solved : True
Correct : True

Note: the HTTPClient uses (plain) ‘HTTP’ (as the name implies) and not a secure connection. The same holds true when using the SocketClient by the way.

POST /api/captcha HTTP/1.1
Accept: application/json
User-Agent: DBC/.NET v4.1.2
Content-Type: multipart/form-data; boundary=7e1ffbf616984adaa2896b35de9baafb
Content-Length: 2934
Connection: Close

Content-Disposition: form-data; name="swid"
Content-Length: 1

Content-Disposition: form-data; name="username"
Content-Length: 27

Content-Disposition: form-data; name="password"
Content-Length: 16

Content-Disposition: form-data; name="captchafile"; filename="captcha.jpeg"
Content-Type: application/octet-stream
Content-Length: 2311

HTTP/1.1 303 See Other
Server: nginx/1.2.3
Date: Sat, 11 May 2013 08:58:04 GMT
Content-Type: text/html
Content-Length: 71
Connection: close
Set-Cookie: BACKEND=B|ABCDE|ABCDE; path=/

{"status": 0, "captcha": 12345678, "is_correct": true, "text": "abcd"}

By the way: a quick way to save a capture to disk is via the clipboard:

if([System.Windows.Forms.Clipboard]::ContainsImage()) {

$Image = = [System.Windows.Forms.Clipboard]::GetImage();

Tag                  :
PhysicalDimension    : {Width=180, Height=103}
Size                 : {Width=180, Height=103}
Width                : 180
Height               : 103
HorizontalResolution : 96
VerticalResolution   : 96
Flags                : 335888
RawFormat            : [ImageFormat: b96b3caa-0728-11d3-9d7b-0000f81ef32e]
PixelFormat          : Format32bppRgb
Palette              : System.Drawing.Imaging.ColorPalette
FrameDimensionsList  : {7462dc86-6180-4c7e-8e3f-ee7333a7a483}
PropertyIdList       : {}
PropertyItems        : {}

$CaptchaPathandFileName = Join-Path -Path $PWD -ChildPath 'captcha.png';
$Image.Save($CaptchaPathandFileName, [System.Drawing.Imaging.ImageFormat]::Png);
} # if

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.