diff --git a/.gitignore b/.gitignore index b6fbd9d..8752d39 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,4 @@ /data/* *.html *.code-workspace -workspace.code-workspace +workspace.code-workspace \ No newline at end of file diff --git a/facebook/__pycache__/arangodb.cpython-37.pyc b/facebook/__pycache__/arangodb.cpython-37.pyc index 42d42c2..d469ec0 100644 Binary files a/facebook/__pycache__/arangodb.cpython-37.pyc and b/facebook/__pycache__/arangodb.cpython-37.pyc differ diff --git a/facebook/profile_create.py b/facebook/profile_create.py new file mode 100644 index 0000000..9d60d6c --- /dev/null +++ b/facebook/profile_create.py @@ -0,0 +1,181 @@ +import random +import subprocess +from getopt import getopt +from sys import argv +from time import sleep + +from arangodb import db, get_profile, remove_profile + + +def profile_generator(db, n): + + cursor = db.aql.execute( + """ + FOR doc IN @@col + FILTER doc._to == 'members/krisjohngethin' + RETURN doc._from + """, + bind_vars={"@col": "picture_reactions"}, + ) + + count = 0 + first_names = [] + last_names = [] + n = int(n) + 1 + for doc in cursor: + name = db.collection("members").get(doc)["name"] + first_names.append(name[: name.find(" ")]) + last_names.append(name[name.rfind(" ") :]) + + with open("../data/passwords.txt") as f: + words = [word for word in f.readlines()] + + with open("../data/servers.txt") as f: + servers = [] + for line in f.readlines(): + if "@" in line: + line = line.strip() + city = line[: line.find("@")].strip() + + if "WireGuard" in line and line.strip()[:2] in [ + "gb", + "us", + ]: # "au", "ca" #För senare när det behövs + line = line.strip() + country_short = line[:2] + server = line[: line.find("-")] + city_short = city[city.find("(") + 1 : city.find(")")] + server_name = [country_short, city_short, server + "-wireguard"] + servers.append( + { + "server_city": city, + "server": server + "-wg.socks5.mullvad.net:1080", + "server_connect": server_name, + } + ) + + count = 0 + for i in range(0, n - 1): + name = ( + first_names[random.randrange(0, len(first_names), 1)].strip() + + " " + + last_names[random.randrange(0, len(last_names), 1)].strip() + ) + print(name, end="\r") + sleep(0.1) + year = str(random.randrange(74, 90)) + email = name.lower().replace(" ", ".") + year + "@outlook.com" + pwd = "" + for _ in range(0, random.randrange(3, 6)): + w = words[random.randrange(0, 10000, 1)].strip() + if random.randrange(0, 3) == 0: + w = w.upper() + pwd = pwd + "_" + w + pwd = pwd.strip("_") + str(random.randrange(5, 35)) + server_info = servers.pop(random.randrange(0, len(servers))) + server = server_info["server"].strip() + birthday = f"{year}-{random.randrange(1, 13)}-{random.randrange(1, 30)}" + _key = server[: server.find("-")] + doc = { + "_id": "profiles/" + _key, + "_key": _key, + "name": name, + "email": email, + "pwd": pwd, + "server": server, + "server_connect": server_info["server_connect"], + "birthday": birthday, + "created": False, + "in_use": False, + } + # Skriv till databasen (skriver inte profiler med servarar som redan används) + try: + db.insert_document("profiles", doc) + count += 1 + except: + pass + + print(f"Skrev {count} profiler till databasen. ") + + +def mullvad(server): + """ Anslut till Mullvad-server. """ + subprocess.run( + [ + "mullvad", + "relay", + "set", + "location", + server[0], + server[1], + server[2], + ] + ) + connect_to_mullvad = subprocess.Popen(["mullvad", "connect"]) + connect_to_mullvad.wait() + sleep(3) + +def create_profile(): + """ Supports during the creation of a profile """ + + arango_server = ["se", "sto", "se2-wireguard"] + + while True: + mullvad(arango_server) + + # Hämta profil + profile = get_profile(created=False) + + # Asnlut till profilens VPN-server + mullvad(profile["server_connect"]) + + # Öppna Brave med Outlook och Facebook + subprocess.run(["open", "-a", "Brave Browser", "https://outlook.com"]) + + # Printa användaruppgfifter för Outlook och Facebook + print() + print(profile["email"][: profile["email"].find("@")]) + print(profile["pwd"]) + print(profile["birthday"]) + print(profile["name"]) + + print() + print() + print(profile["name"]) + print(profile["email"]) + print(profile["pwd"]) + print(profile["birthday"]) + + user_input = input("Done/Next/Delete/Quit: ") + user_input = user_input.lower() + + if user_input in ["done", "d", ""]: + subprocess.run(["osascript", "-e", 'quit app "Brave Browser"']) + sleep(1) + profile["created"] = True + mullvad(arango_server) + db.update_document(profile) + + elif user_input in ["delete", "d"]: + subprocess.run(["osascript", "-e", 'quit app "Brave Browser"']) + sleep(1) + mullvad(arango_server) + remove_profile(profile) + + elif user_input in ["quit", "q"]: + subprocess.run(["osascript", "-e", 'quit app "Brave Browser"']) + sleep(1) + mullvad(arango_server) + exit() + else: + continue + +if __name__ == "__main__": + argv = argv[1:] + opts, args = getopt(argv, "cg:", ["create", "generate"]) + + for o, a in opts: + if o in ["-g", "--generate"]: + profile_generator(db, a) + if o in ['-c', '--create']: + create_profile() diff --git a/facebook/scrapers.py b/facebook/scrapers.py index 20fcc94..bf1d124 100644 --- a/facebook/scrapers.py +++ b/facebook/scrapers.py @@ -80,7 +80,14 @@ def profile_picture_reactions(profile, user, all_pictures, first_user=False, mod user.url_timeline = url_bas + a["href"] if "Cover photos" in a.text: user.url_coverphotos = url_bas + a["href"] - + + # Om det inte finns något profilalbum + # Testa ta bort mellanrum och små bokstäver + if not hasattr(user, "url_album"): + for a in profile.viewing().find_all("a", href=True): + if "profilepictures" in a.text.lower().replace(' ', ''): + user.url_album = url_bas + a["href"] + user.add_to_db() # Gå till profilbilden (den första som kommer upp när man går till profilen) @@ -169,7 +176,7 @@ def profile_picture_reactions(profile, user, all_pictures, first_user=False, mod write_error(8, e=e, soup=profile.viewing(), url=pic, url_name='picture url', user=user.name, traceback=traceback.format_exc()) # TODO #3 lägg till fler bilder som kan gås igenom om det är få profilbilder. - # Hämta länkar för bilden att userända sen + # Hämta länkar för bilden att anvrända sen #print(profile.viewing().prettify()) for a in profile.viewing().find_all("a", href=True): if all( @@ -206,7 +213,7 @@ def profile_picture_reactions(profile, user, all_pictures, first_user=False, mod url_limit = a["href"] picture.no_reactions = re.search(r"total_count=(\d+)", url_limit).group(1) - limit = re.search(r"limit=(\d+)", url_limit).group(1) + limit = re.search(r"limit=(\d+)", url_limit).group(1) # TODO Fortfarande problem med det här except UnboundLocalError: #fel9 write_error(9, soup=profile.viewing(), traceback=traceback.format_exc(), url=url_reactions, url_name='url_reactions') # Bilder med väldigt många likes går inte att visa så här?