Criei um BOT para fazer login automático no Itaú!

Acho um saco ficar fazendo login nos sites dos bancos, então resolvi criar um script em python para fazer isso automaticamente pra mim!

Requisitos

Debian ou Ubuntu

Entrar no website do Itau, tentar fazer o login, receber um aviso e baixar o warsaw(alguma_coisa).deb

Instale o Warsaw

Instale as dependências que faltam

Baixe e instale o Gecko Driver (firefox ou chrome)

Instale o Python3

Instale o pip para python3

Instale o selenium pelo pip

Precisa do Selenium e do GeckoDriver para funcionar!

Crie um arquivo de configuração chamado credentials.json

{    "agencia": "1234",    "conta_corrente": "123123",    "cpf": "12341234123",    "senha_eletronica": "123123"}

E aí vai o código!

from selenium import webdriverfrom selenium.webdriver.common.by import Byfrom selenium.webdriver.support.ui import WebDriverWait as Waitfrom selenium.webdriver.common.keys import Keysfrom selenium.webdriver.support import expected_conditions as ecfrom selenium.common.exceptions import TimeoutException, ElementClickInterceptedExceptionfrom selenium.webdriver.support.ui import Selectimport timeimport datetimefrom datetime import timedeltafrom dateutil import rruledef start_local_driver():    profile = webdriver.FirefoxProfile()    profile.set_preference("general.useragent.override", "Mozilla/5.0 (X11; FreeBSD OS x86_64) Gecko/20100101 Firefox/60.0")    options = webdriver.FirefoxOptions()    # Set this to true if you want to hide the browser window    options.headless = False    return webdriver.Firefox(firefox_profile=profile, options=options)def log_in(driver, account_data):       driver.get('https://www.itau.com.br/sobre')    driver.set_window_size(1023, 696)        while True:        try:            driver.find_element(By.ID, 'campo_agencia').click()            driver.find_element(By.ID, 'campo_agencia').send_keys(account_delata['agencia'])            driver.find_element(By.ID, 'campo_conta').click()            driver.find_element(By.ID, 'campo_conta').send_keys(account_data['conta_corrente'])            Wait(driver, 10).until(ec.element_to_be_clickable((By.CLASS_NAME, 'btnSubmit')))            driver.find_element(By.CLASS_NAME, 'btnSubmit').click()            print('Clicking submit button.')            print(str(datetime.datetime.now()) + ' - Waiting for new page to be loaded...')            Wait(driver, 10).until(ec.text_to_be_present_in_element((By.TAG_NAME, 'h1'), 'Selecione um tipo de identificação'))            break        except TimeoutException as ex:            print('Is taking to long to ')            print(ex)    while True:        try:            print(str(datetime.datetime.now()) + ' - CPF page loaded.')            print(str(datetime.datetime.now()) + ' - Waiting for CPF field...')            Wait(driver, 10).until(ec.element_to_be_clickable((By.ID, 'campoCpf')))            time.sleep(2)            print(str(datetime.datetime.now()) + ' - CPF field found.')            driver.find_element('id', 'campoCpf').click()            driver.find_element('id', 'campoCpf').send_keys(account_data['cpf'])            time.sleep(1)            Wait(driver, 5).until(ec.element_to_be_clickable((By.ID, 'botao-continuar')))            driver.find_element('id', 'botao-continuar').click()            print('Waiting for password-click screen.')            Wait(driver, 10).until(ec.text_to_be_present_in_element((By.TAG_NAME, 'h1'), 'Bem-vindo,'))            print('Password-click screen loaded.')            break        except TimeoutException as ex:            print('Timeout error!!!!')            print(ex)    # Página de senha por click    # exemplo de campo no teclado:    # 2 ou 8    Wait(driver, 10).until(ec.element_to_be_clickable((By.ID, 'senha')))    Wait(driver, 10).until(ec.element_to_be_clickable((By.ID, 'acessar')))    while True:        try:            time.sleep(3)            campo_teclado = driver.find_elements('id', 'campoTeclado')            for numero in account_data['senha_eletronica']:                for botao_senha in campo_teclado:                    if numero in botao_senha.text:                        Wait(driver, 10).until(ec.element_to_be_clickable((By.ID, 'campoTeclado')))                        botao_senha.click()            break        except ElementClickInterceptedException as e:            print(e)            time.sleep(1)    while True:        try:            Wait(driver, 10).until(ec.element_to_be_clickable((By.ID, 'acessar')))            print('Clicando em "Acessar"')            driver.find_element('id', 'acessar').click()            break        except TimeoutException as e:            print(e)    while True:        try:            print('Esperando o radio button basico aparecer')            Wait(driver, 10).until(ec.element_to_be_clickable((By.ID, 'rdBasico')))            driver.find_element('id', 'rdBasico').click()            Wait(driver, 10).until(ec.element_to_be_clickable((By.ID, 'btn-continuar')))            driver.find_element('id', 'btn-continuar').click()            print('Waiting for main menu screen.')            Wait(driver, 5).until(                ec.text_to_be_present_in_element(                    (By.LINK_TEXT, 'rede e recebimentos')                    , 'rede e recebimentos')            )            print('Main menu screen detected from Rede e recebimentos menu!')            break        except ElementClickInterceptedException as e:            print(e)            time.sleep(1)        except TimeoutException as e:            print(e)((_driver = start_local_driver()import jsoncredentials = {}with open('credentials.json', 'r') as credentials_file:    credentials = json.load(credentials_file)print(credentials)log_in(_driver, credentials)

You should also read:

Capturando pacotes de rede para analises no Wireshark

Forma fácil, rápida e roots. Referências boas: BosonTreinamentos http://www.bosontreinamentos.com.br/redes-computadores/tcpdump-capturar-e-analisar-trafego-de-rede-no-linux/ LinuxTechi https://www.linuxtechi.com/capture-analyze-packets-tcpdump-command-linux/#:~:text=In%20tcpdump%20command%20we%20can,ssh%20%3E%20169.144. Outra forma roots. Forma mais gourmet

Verificando débitos do seu veículo no Paraná

http://transito.curitiba.pr.gov.br/processos/consulta-de-andamento-de-processos-renavam/22 http://www.detran.pr.gov.br/servico/extratodebito https://www.governodigital.pr.gov.br/servicos/Veiculo/Guias-para-pagamento-e-certidoes/Emitir-guia-para-pagamento-do-licenciamento-de-veiculos-ERrZWjo6