pax_global_header 0000666 0000000 0000000 00000000064 13435444765 0014531 g ustar 00root root 0000000 0000000 52 comment=139760e841ad4875b59fe11e052af1bb56dc06ea
woob-139760e841ad4875b59fe11e052af1bb56dc06ea-modules-deathbycaptcha/ 0000775 0000000 0000000 00000000000 13435444765 0024104 5 ustar 00root root 0000000 0000000 woob-139760e841ad4875b59fe11e052af1bb56dc06ea-modules-deathbycaptcha/modules/ 0000775 0000000 0000000 00000000000 13435444765 0025554 5 ustar 00root root 0000000 0000000 woob-139760e841ad4875b59fe11e052af1bb56dc06ea-modules-deathbycaptcha/modules/deathbycaptcha/ 0000775 0000000 0000000 00000000000 13435444765 0030520 5 ustar 00root root 0000000 0000000 __init__.py 0000664 0000000 0000000 00000001600 13435444765 0032547 0 ustar 00root root 0000000 0000000 woob-139760e841ad4875b59fe11e052af1bb56dc06ea-modules-deathbycaptcha/modules/deathbycaptcha # -*- coding: utf-8 -*-
# Copyright(C) 2018 Vincent A
#
# This file is part of a weboob module.
#
# This weboob module is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This weboob module 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this weboob module. If not, see .
from __future__ import unicode_literals
from .module import DeathbycaptchaModule
__all__ = ['DeathbycaptchaModule']
browser.py 0000664 0000000 0000000 00000004121 13435444765 0032474 0 ustar 00root root 0000000 0000000 woob-139760e841ad4875b59fe11e052af1bb56dc06ea-modules-deathbycaptcha/modules/deathbycaptcha # -*- coding: utf-8 -*-
# Copyright(C) 2018 Vincent A
#
# This file is part of a weboob module.
#
# This weboob module is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This weboob module 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this weboob module. If not, see .
from __future__ import unicode_literals
from base64 import b64encode
from collections import OrderedDict
from io import BytesIO
from weboob.capabilities.captcha import UnsolvableCaptcha
from weboob.browser import DomainBrowser
from weboob.tools.compat import parse_qsl
def parse_qs(d):
return dict(parse_qsl(d))
class DeathbycaptchaBrowser(DomainBrowser):
BASEURL = 'http://api.dbcapi.me'
def __init__(self, username, password, *args, **kwargs):
super(DeathbycaptchaBrowser, self).__init__(*args, **kwargs)
self.username = username
self.password = password
def check_correct(self, reply):
if reply.get('is_correct', '1') == 0:
raise UnsolvableCaptcha()
def create_job(self, data):
data64 = b'base64:%s' % b64encode(data)
files = {
'captchafile': ('captcha.jpg', BytesIO(data64)),
}
post = OrderedDict([
('username', self.username),
('password', self.password),
])
r = self.open('/api/captcha', data=post, files=files)
reply = parse_qs(r.text)
self.check_correct(reply)
return reply['captcha']
def poll(self, id):
r = self.open('/api/captcha/%s' % id)
reply = parse_qs(r.text)
self.check_correct(reply)
return reply['text'] or None
module.py 0000664 0000000 0000000 00000003517 13435444765 0032306 0 ustar 00root root 0000000 0000000 woob-139760e841ad4875b59fe11e052af1bb56dc06ea-modules-deathbycaptcha/modules/deathbycaptcha # -*- coding: utf-8 -*-
# Copyright(C) 2018 Vincent A
#
# This file is part of a weboob module.
#
# This weboob module is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This weboob module 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this weboob module. If not, see .
from __future__ import unicode_literals
from weboob.tools.backend import Module, BackendConfig
from weboob.tools.value import ValueBackendPassword, Value
from weboob.capabilities.captcha import CapCaptchaSolver, ImageCaptchaJob
from .browser import DeathbycaptchaBrowser
__all__ = ['DeathbycaptchaModule']
class DeathbycaptchaModule(Module, CapCaptchaSolver):
NAME = 'deathbycaptcha'
DESCRIPTION = 'Death By Captcha'
MAINTAINER = 'Vincent A'
EMAIL = 'dev@indigo.re'
LICENSE = 'AGPLv3+'
VERSION = '1.5'
CONFIG = BackendConfig(
Value('login'),
ValueBackendPassword('password'),
)
BROWSER = DeathbycaptchaBrowser
def create_default_browser(self):
return self.create_browser(self.config['login'].get(), self.config['password'].get())
def create_job(self, job):
if not isinstance(job, ImageCaptchaJob):
raise NotImplementedError()
job.id = self.browser.create_job(job.image)
def poll_job(self, job):
job.solution = self.browser.poll(job.id)
return job.solution is not None
woob-139760e841ad4875b59fe11e052af1bb56dc06ea-modules-deathbycaptcha/modules/deathbycaptcha/test.py 0000664 0000000 0000000 00000002473 13435444765 0032057 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright(C) 2018 Vincent A
#
# This file is part of a weboob module.
#
# This weboob module is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This weboob module 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this weboob module. If not, see .
from __future__ import unicode_literals
from weboob.capabilities.captcha import ImageCaptchaJob
from weboob.tools.test import BackendTest
class DeathbycaptchaTest(BackendTest):
MODULE = 'deathbycaptcha'
def test_image(self):
url = 'https://upload.wikimedia.org/wikipedia/commons/b/b6/Modern-captcha.jpg'
data = self.backend.browser.open(url).content
job = ImageCaptchaJob()
job.image = data
self.assertTrue(self.backend.solve_catpcha_blocking(job))
self.assertEqual(job.solution, 'following finding')