-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
93 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#! /usr/bin/env python3 | ||
# -*- coding: utf-8 -*- | ||
|
||
import traceback | ||
from requests import get, post | ||
from ikabot.helpers.dns import getAddress | ||
from ikabot.config import * | ||
|
||
|
||
def getNewBlackBoxToken(session): | ||
"""This function returns a newly generated blackbox token from the API | ||
Parameters | ||
---------- | ||
session : ikabot.web.session.Session | ||
Session object | ||
Returns | ||
------- | ||
token : str | ||
blackbox token | ||
""" | ||
address = getAddress(session, publicAPIServerDomain) + '/v1/token' + '?user_agent=' + session.user_agent | ||
response = get(address, verify=do_ssl_verify, timeout=900) | ||
assert response.status_code == 200, 'API response code is not OK: ' + str(response.status_code) + '\n' + response.text | ||
response = response.json() | ||
if 'status' in response and response['status'] == 'error': | ||
raise Exception(response['message']) | ||
return 'tra:' + response | ||
|
||
def getInteractiveCaptchaSolution(session, text_image, drag_icons): | ||
"""This function returns the solution of the interactive captcha | ||
Parameters | ||
---------- | ||
session : ikabot.web.session.Session | ||
Session object | ||
drag_icons : bytes | ||
the image that contains 4 other images | ||
text_image : bytes | ||
the image that contaisn the text | ||
Returns | ||
------- | ||
solution : str | ||
solution of the captcha | ||
""" | ||
address = getAddress(session, publicAPIServerDomain) + '/v1/decaptcha/lobby' | ||
files = {'text_image': text_image, 'drag_icons': drag_icons} | ||
response = post(address, files=files, verify=do_ssl_verify, timeout=900) | ||
assert response.status_code == 200, 'API response code is not OK: ' + str(response.status_code) + '\n' + response.text | ||
response = response.json() | ||
if 'status' in response and response['status'] == 'error': | ||
raise Exception(response['message']) | ||
return response | ||
|
||
def getPiratesCaptchaSolution(session, image): | ||
"""This function returns the solution of the pirates captcha | ||
Parameters | ||
---------- | ||
session : ikabot.web.session.Session | ||
Session object | ||
image : bytes | ||
the image to be solved | ||
Returns | ||
------- | ||
solution : str | ||
solution of the captcha | ||
""" | ||
address = getAddress(session, publicAPIServerDomain) + '/v1/decaptcha/pirate' | ||
files = {'image': image} | ||
response = post(address, files=files, verify=do_ssl_verify, timeout=900) | ||
assert response.status_code == 200, 'API response code is not OK: ' + str(response.status_code) + '\n' + response.text | ||
response = response.json() | ||
if 'status' in response and response['status'] == 'error': | ||
raise Exception(response['message']) | ||
return response | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters