Repository navigation
Expand file tree
/
Copy pathCaptchaService.py
More file actions
82 lines (58 loc) · 2.73 KB
/
Copy pathCaptchaService.py
File metadata and controls
82 lines (58 loc) · 2.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# -*- coding: utf-8 -*-
"""
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License,
or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, see <http://www.gnu.org/licenses/>.
@author: zoidberg
"""
import re
class CaptchaService():
__version__ = "0.02"
def __init__(self, plugin):
self.plugin = plugin
class ReCaptcha():
def __init__(self, plugin):
self.plugin = plugin
def challenge(self, id):
js = self.plugin.req.load("http://www.google.com/recaptcha/api/challenge", get={"k": id}, cookies=True)
try:
challenge = re.search("challenge : '(.*?)',", js).group(1)
server = re.search("server : '(.*?)',", js).group(1)
except:
self.plugin.fail("recaptcha error")
result = self.result(server, challenge)
return challenge, result
def result(self, server, challenge):
return self.plugin.decryptCaptcha("%simage" % server, get={"c": challenge}, cookies=True, forceUser=True, imgtype="jpg")
class AdsCaptcha(CaptchaService):
def challenge(self, src):
js = self.plugin.req.load(src, cookies=True)
try:
challenge = re.search("challenge: '(.*?)',", js).group(1)
server = re.search("server: '(.*?)',", js).group(1)
except:
self.plugin.fail("adscaptcha error")
result = self.result(server, challenge)
return challenge, result
def result(self, server, challenge):
return self.plugin.decryptCaptcha("%sChallenge.aspx" % server, get={"cid": challenge, "dummy": random()}, cookies=True, imgtype="jpg")
class SolveMedia(CaptchaService):
def __init__(self, plugin):
self.plugin = plugin
def challenge(self, src):
html = self.plugin.req.load("http://api.solvemedia.com/papi/challenge.noscript?k=%s" % src, cookies=True)
try:
challenge = re.search(r'<input type=hidden name="adcopy_challenge" id="adcopy_challenge" value="([^"]+)">', html).group(1)
except:
self.plugin.fail("solvmedia error")
result = self.result(challenge)
return challenge, result
def result(self, challenge):
return self.plugin.decryptCaptcha("http://api.solvemedia.com/papi/media?c=%s" % challenge, imgtype="gif")