Mohamed Habib
Junior Member
- Aug 16, 2018
- 163
- 18
Capmonster is a product i'm trialing at BHW Marketplace, it emulates captcha services' API (ie. 2captcha). https://www.blackhatworld.com/seo/c...cha-google-hotmail-facebook-yahoo-etc.796581/
So i'm mainly using selenium to automate some webbrowing activity on my testsite: omegle.com.
API code:
https://github.com/2captcha/2captch...Python Example/2captcha_python_api_example.py
combined with the omegle code found here:
https://www.blackhatworld.com/seo/omegle-chat-bot-python-selenium.1025085/
So here is the procedure:
2captcha API code gets run first, sends code to capmonster. capmonster takes 20-30 seconds to solve the captcha images and then nothing happens. The captcha box does not get checked, and even refreshing the browser does not work... so where exactly did recaptcha_answer key get sent to?
Can anyone please help me solve this problem?
So i'm mainly using selenium to automate some webbrowing activity on my testsite: omegle.com.
API code:
https://github.com/2captcha/2captch...Python Example/2captcha_python_api_example.py
Code:
import requests
from time import sleep
# Add these values
API_KEY = '' # Your 2captcha API KEY
site_key = '' # site-key, read the 2captcha docs on how to get this
url = 'http://somewebsite.com' # example url
proxy = '127.0.0.1:6969' # example proxy
proxy = {'http': 'http://' + proxy, 'https': 'https://' + proxy}
s = requests.Session()
# here we post site key to 2captcha to get captcha ID (and we parse it here too)
captcha_id = s.post("http://2captcha.com/in.php?key={}&method=userrecaptcha&googlekey={}&pageurl={}".format(API_KEY, site_key, url), proxies=proxy).text.split('|')[1]
# then we parse gresponse from 2captcha response
recaptcha_answer = s.get("http://2captcha.com/res.php?key={}&action=get&id={}".format(API_KEY, captcha_id), proxies=proxy).text
print("solving ref captcha...")
while 'CAPCHA_NOT_READY' in recaptcha_answer:
sleep(5)
recaptcha_answer = s.get("http://2captcha.com/res.php?key={}&action=get&id={}".format(API_KEY, captcha_id), proxies=proxy).text
recaptcha_answer = recaptcha_answer.split('|')[1]
# we make the payload for the post data here, use something like mitmproxy or fiddler to see what is needed
payload = {
'key': 'value',
'gresponse': recaptcha_answer # This is the response from 2captcha, which is needed for the post request to go through.
}
# then send the post request to the url
response = s.post(url, payload, proxies=proxy)
# And that's all there is to it other than scraping data from the website, which is dynamic for every website.
combined with the omegle code found here:
https://www.blackhatworld.com/seo/omegle-chat-bot-python-selenium.1025085/
Code:
from selenium import webdriver
from selenium.common.exceptions import InvalidElementStateException
from selenium.common.exceptions import UnexpectedAlertPresentException
import time,os
interest = input("Enter the interests seperate by a comma ")
msg1 = input("Enter your first message (1/4) >> ")
msg2 = input("Enter your second message (2/4) >> ")
msg3 = input("Enter your third message (3/4) >> ")
msg4 = input("Enter your fourth message (4/4) >> ")
driver = webdriver.Firefox()
def main():
try:
driver.get('http://www.omegle.com')
time.sleep(2)
driver.find_element_by_xpath('//textarea[@rows="3"]').clear()
message = driver.find_element_by_xpath('//textarea[@rows="3"]')
message.send_keys(msg1)
send = driver.find_element_by_xpath('//button[@class="sendbtn"]')
send.click()
message.send_keys(msg2)
send = driver.find_element_by_xpath('//button[@class="sendbtn"]')
send.click()
message.send_keys(msg3)
send = driver.find_element_by_xpath('//button[@class="sendbtn"]')
send.click()
message.send_keys(msg4)
send = driver.find_element_by_xpath('//button[@class="sendbtn"]')
send.click()
disconnect = driver.find_element_by_xpath('//button[@class="disconnectbtn"]')
disconnect.click()
disconnect = driver.find_element_by_xpath('//button[@class="disconnectbtn"]')
disconnect.click()
disconnect = driver.find_element_by_xpath('//button[@class="disconnectbtn"]')
disconnect.click()
except (InvalidElementStateException, UnexpectedAlertPresentException):
main2()
def main2():
try:
driver.get('http://www.omegle.com')
interest1 = driver.find_element_by_xpath('//input[@class="newtopicinput"]')
interest1.send_keys(interest)
btn = driver.find_element_by_id("textbtn")
btn.click()
time.sleep(5)
driver.find_element_by_xpath('//textarea[@rows="3"]').clear()
message = driver.find_element_by_xpath('//textarea[@rows="3"]')
message.send_keys(msg1)
send = driver.find_element_by_xpath('//button[@class="sendbtn"]')
send.click()
message.send_keys(msg2)
send.click()
message.send_keys(msg3)
send.click()
message.send_keys(msg4)
send.click()
send.click()
disconnect = driver.find_element_by_xpath('//button[@class="disconnectbtn"]')
disconnect.click()
except (InvalidElementStateException,UnexpectedAlertPresentException) :
disconnect = driver.find_element_by_xpath('//button[@class="disconnectbtn"]')
disconnect.click()
else:
main2()
while True:
try:
main2()
except (InvalidElementStateException,UnexpectedAlertPresentException) :
main()
So here is the procedure:
2captcha API code gets run first, sends code to capmonster. capmonster takes 20-30 seconds to solve the captcha images and then nothing happens. The captcha box does not get checked, and even refreshing the browser does not work... so where exactly did recaptcha_answer key get sent to?
Can anyone please help me solve this problem?