allt möjligt...

pull/6/head
Lasse Edfast 5 years ago
parent d53e7a081b
commit 0d45c22d86
  1. 13
      facebook/__main__.py
  2. 63
      facebook/arangodb.py
  3. 4
      facebook/classes.py
  4. 5
      facebook/config.py
  5. 7
      facebook/gephi.py
  6. 24
      facebook/proxytest.py
  7. 2
      facebook/scrapers.py
  8. 104
      facebook/search_leak.py
  9. 2
      facebook/stats.py

@ -18,7 +18,7 @@ if __name__ == "__main__":
url_other_pictures = [] # Fylls eventuellt på url_other_pictures = [] # Fylls eventuellt på
test = False test = False
write = True write = True
mode = 'all' mode = 'few'
pwd = None pwd = None
proxieservers = 'mullvad' proxieservers = 'mullvad'
container = 'container' # Todo ska den här bort? container = 'container' # Todo ska den här bort?
@ -107,6 +107,7 @@ if __name__ == "__main__":
print('Write:', write) print('Write:', write)
# Hämta en användare att kolla upp # Hämta en användare att kolla upp
print('userdoc[_key]', userdoc['_key'])
user = User(str(userdoc['_key']).strip(), mode, other_pictures=url_other_pictures) user = User(str(userdoc['_key']).strip(), mode, other_pictures=url_other_pictures)
if "url_other_pictures" in globals(): if "url_other_pictures" in globals():
@ -126,9 +127,12 @@ if __name__ == "__main__":
if lookups == "leak_lookups": if lookups == "leak_lookups":
id = user.username id = user.username
check_profile_status(profile, user) while True:
if profile.blocked: check_profile_status(profile, user)
profile = blocked_profile(profile, proxieservers=proxieservers) if profile.blocked:
profile = blocked_profile(profile, proxieservers=proxieservers)
else:
break
profile.open(url_bas + "/" + user.username) profile.open(url_bas + "/" + user.username)
url = profile.browser.state.url.strip("/").strip("?_rdr") url = profile.browser.state.url.strip("/").strip("?_rdr")
if "php?" not in url: if "php?" not in url:
@ -145,6 +149,7 @@ if __name__ == "__main__":
profile.users_checked += 1 profile.users_checked += 1
# Hämta reaktioner för den första användaren # Hämta reaktioner för den första användaren
print(user.username)
if any([not check_for_user(user.username, mode=mode), mode == "force"]): if any([not check_for_user(user.username, mode=mode), mode == "force"]):
try: try:
while True: while True:

@ -9,30 +9,38 @@ from arango import ArangoClient
from config import * from config import *
if __name__ == '__main__.py':
for i in range(0, 6, 1):
if i == 5:
exit()
try:
# Om scriptet körs på Macbook finns lösenordet i en fil
with open("../password_arango.txt") as f:
pwd = f.readline()
except FileNotFoundError:
if 'pwd' not in globals():
pwd = getpass(f'Lösenord för {user_arango}: ')
for i in range(0, 6, 1): try:
if i == 5: db = ArangoClient(hosts=host_arango).db(db_arango, username=user_arango, password=pwd)
exit() db.collection('members').random() # För att testa löseordet/kopplingen.
try: break
# Om scriptet körs på Macbook finns lösenordet i en fil except:
with open("../password_arango.txt") as f: print("Fel lösenord.")
pwd = f.readline() sleep(1)
except FileNotFoundError: else:
if 'pwd' not in globals(): db = None # Om db importeras separat.
pwd = getpass(f'Lösenord för {user_arango}: ')
try:
db = ArangoClient(hosts=host_arango).db(db_arango, username=user_arango, password=pwd)
db.collection('members').random() # För att testa löseordet/kopplingen.
break
except:
print("Fel lösenord.")
sleep(1)
from helpers import now, _print, nowstamp, sleep_ from helpers import now, _print, nowstamp, sleep_
from classes import Profile from classes import Profile
def arango_connect(pwd, username='Lasse', db_arango = 'facebook', host_arango='http://192.168.1.20', port_arango='8529'):
return ArangoClient(hosts=f'{host_arango}:{port_arango}').db(
db_arango, username=username, password=pwd,
)
def checked_members(): def checked_members():
cursor = db.aql.execute( cursor = db.aql.execute(
""" """
@ -78,6 +86,7 @@ def report_blocked(profile):
def get_profile(db=db, collection='mullvad'): def get_profile(db=db, collection='mullvad'):
""" Hämtar profil från profiles """ """ Hämtar profil från profiles """
collection = f'profiles_{collection}'
while True: while True:
cursor = db.aql.execute( cursor = db.aql.execute(
@ -86,7 +95,7 @@ def get_profile(db=db, collection='mullvad'):
FILTER doc.in_use < @inuse FILTER doc.in_use < @inuse
RETURN doc RETURN doc
""", """,
bind_vars={"inuse": nowstamp() - 1200, '@col': f'profiles_{collection}'} bind_vars={"inuse": nowstamp() - 1200, '@col': collection}
) )
profiles = [profile for profile in cursor] profiles = [profile for profile in cursor]
@ -114,7 +123,9 @@ def remove_profile(profile, proxieservers='mullvad'):
""" Tar bort en blockerad profil från databasen. """ """ Tar bort en blockerad profil från databasen. """
_print(profile, None, f"Tar bort {profile.name}.") _print(profile, None, f"Tar bort {profile.name}.")
db.collection(f'profiles_{proxieservers}').delete( collection = f'profiles_{proxieservers}'
db.collection(collection).delete(
profile.doc["_key"], silent=True, ignore_missing=True profile.doc["_key"], silent=True, ignore_missing=True
) )
_print(profile, profile.container, f"{profile.name} blockerad och borttagen {now()}.") _print(profile, profile.container, f"{profile.name} blockerad och borttagen {now()}.")
@ -122,13 +133,9 @@ def remove_profile(profile, proxieservers='mullvad'):
# TODO #2 Bättre funktion för backup av databasen # TODO #2 Bättre funktion för backup av databasen
def arango_connect(pwd):
return ArangoClient(hosts=host_arango).db(
db_arango, username=user_arango, password=pwd
)
def check_for_user(username, mode=''): def check_for_user(username, mode=''):
print(username)
""" Checks if a user exist in db and if it's checked """ """ Checks if a user exist in db and if it's checked """
checked = False checked = False
if db.collection("members").has(username): if db.collection("members").has(username):
@ -229,7 +236,7 @@ def write_stats(continuous=False):
# Hur många konton per säljare som finns kvar # Hur många konton per säljare som finns kvar
cursor = db.aql.execute( cursor = db.aql.execute(
''' '''
for doc in profiles for doc in profiles_mullvad
filter has(doc, "vendor") filter has(doc, "vendor")
COLLECT vendor = doc.vendor WITH COUNT INTO length COLLECT vendor = doc.vendor WITH COUNT INTO length
RETURN { RETURN {
@ -268,7 +275,7 @@ def blocked_profile(profile, proxieservers):
def new_profile(container, proxieservers): def new_profile(container, proxieservers):
""" Hämtar en ny profil. """ """ Hämtar en ny profil. """
profile = Profile(get_profile(proxieservers=proxieservers), container, proxieservers) profile = Profile(get_profile(collection=proxieservers), container, proxieservers)
_print(profile, None, f'Hämtade profilen {profile.name}. Login = {profile.logged_in}.') _print(profile, None, f'Hämtade profilen {profile.name}. Login = {profile.logged_in}.')
if profile.logged_in == False: if profile.logged_in == False:
profile.accept_cookies() profile.accept_cookies()
@ -312,4 +319,4 @@ def find_id():
db = ArangoClient(hosts=host_arango).db(db_arango, username=user_arango, password=pwd) #db = ArangoClient(hosts=host_arango).db(db_arango, username=user_arango, password=pwd)

@ -135,8 +135,8 @@ class Profile:
# Starta browser # Starta browser
user_agent = self.useragent user_agent = self.useragent
self.browser = RoboBrowser( self.browser = RoboBrowser(
session=session, user_agent=user_agent, history=False, parser="lxml" session=session, user_agent=user_agent, history=False, parser="lxml", timeout=20
) ) #TODO Kolla timeout på den här
# TODO Ta bort gamla metoden om nya (hämta från doc) fungerar # TODO Ta bort gamla metoden om nya (hämta från doc) fungerar
# try: # try:

@ -7,10 +7,9 @@ def set_pwd(_pwd=None):
# Info för arangodb # Info för arangodb
user_arango = "Lasse" user_arango = "Lasse"
pwd_arango = "4c071768bedc259288361c07aafd8535fca546086fada4e7b5de4e2bb26b0e70fa8d348c998b90d032a5b8f3fdbae1881b843021e3475198e6fb45f58d8dc450bd52f77d"
db_arango = "facebook" db_arango = "facebook"
host_arango = 'http://192.168.0.4:8529' host_arango = 'http://192.168.1.20'
#host_arango = "http://arango.lasseedfast.se" port_arango = '8529'
# Andra uppgifter # Andra uppgifter
url_bas = "https://mbasic.facebook.com" url_bas = "https://mbasic.facebook.com"

@ -6,10 +6,12 @@ from sys import argv
import networkx as nx import networkx as nx
import pandas as pd import pandas as pd
from numpy.core.numeric import NaN from numpy.core.numeric import NaN
from getpass import getpass
import arangodb
locale.setlocale(locale.LC_TIME, "en_US") locale.setlocale(locale.LC_TIME, "en_US")
from arangodb import db
def nodes_from_list( def nodes_from_list(
@ -240,6 +242,9 @@ def common_friends(d, n=2):
return l return l
pwd = getpass('Password for Lasse: ')
db = arangodb.arango_connect(pwd)
if __name__ == "__main__": if __name__ == "__main__":

@ -0,0 +1,24 @@
import re
from time import sleep
from getpass import getpass
from bs4 import BeautifulSoup
from arango import ArangoClient
import requests
from urllib.parse import urlencode
def check_ip():
"""
Checks the current IP.
"""
url = f'https://mrkoll.se/resultat?n={46706111785}'
proxies = {'https': 'http://sgz2bkt7:TtLyyPGKMmjabg7R_country-Sweden@proxy.proxy-cheap.com:31112'}
ip = requests.get(url, proxies=proxies).text
return ip
print(check_ip())

@ -157,7 +157,7 @@ def profile_picture_reactions(profile, user, first_user=False, mode="all"):
if first_user == False: if first_user == False:
if mode == "single" and user.reactions > 30: if mode == "single" and user.reactions > 30:
break break
elif all([any[mode == "few", mode == "solo"], user.reactions > 80, pic != url_pics[-1]]): elif all([any([mode == "few", mode == "solo"]), user.reactions > 80, pic != url_pics[-1]]):
# Kolla den sista bilder # Kolla den sista bilder
check_picture(url_bas + url_pics[-1], user, profile) check_picture(url_bas + url_pics[-1], user, profile)
user.checked_pictures.append(url_bas + pic) user.checked_pictures.append(url_bas + pic)

@ -0,0 +1,104 @@
"""
Skript för att söka i FB-läckan.
"""
import re
import paramiko
import arangodb
from getpass import getpass
from sshtunnel import open_tunnel
import paramiko
from termcolor import cprint
def search(db, attribute, value):
"""
Search for attribute in db.
Returns list of matching documents.
"""
if '%' in value or '_' in value:
match = 'like'
else:
match = '=='
cursor = db.aql.execute(
f"""
FOR doc IN leak
FILTER doc.@attribute {match} @value
RETURN doc
""",
bind_vars={"attribute": attribute, "value": value},
)
return [doc for doc in cursor]
pwd_key = getpass(f"Password key: ")
with open_tunnel(
("studio-garda.asuscomm.com", 2200),
ssh_username="Lasse",
ssh_pkey=paramiko.RSAKey.from_private_key_file(
"/Users/Lasse/.ssh/id_rsa", password=pwd_key
),
ssh_private_key_password=pwd_key,
remote_bind_address=("127.0.0.1", 8529),
) as server:
# server.start()
port_arango = server.local_bind_port
db = arangodb.arango_connect(
"gruel-ADOBE-foolish-winy-borax",
username="Leak",
host_arango="http://127.0.0.1",
port_arango=port_arango,
)
cprint("\n\nVad vill du söka efter?", attrs=['bold'])
print("1 - Telefonnummer")
print("2 - Facebook-ID")
print('3 - Namn')
print("4 - Arbete")
print('5 - Bostadsort')
print("6 - Födelseort")
print("7 - Epost")
# Få input för attribut
attribute = input("\n>>> ")
attributes = {
"1": ("telefonnummer", "phone"),
"2": ("Facebook-ID", "_key"),
"3": ("namn", "full_name"),
"4": ("arbete", "work"),
"5": ('bostadsort', "lives_in"),
"6": ('födelseort', 'from'),
"7": ('epost', 'email')
}
# Bestäm n- eller t-form och få input för värde.
if attribute in ['5', '6', '7']:
genus = 'n'
else:
genus = 't'
cprint(f"\nVilke{genus} {attributes[attribute][0]}? ", attrs=['bold'])
cprint('Använd % för att ersätta flera okända tecken, _ för att ersätta ett.', attrs=['dark'])
value = input('\n>>> ')
if attribute == '1': # telefonnummer
value = ''.join(re.findall(r'\d+', value))
if value[0] == '0':
value = f'46{value[1:]}'
elif attribute == '3': # namn
value = value.upper()
# Sök i databasen.
result = search(db, attributes[attribute][1], value)
# Presentera reultaten #TODO hur vill man få dem? Spara ner?
for i in result:
print('\n', i['full_name'])
for key, value in i.items():
print(f'{key}: {value}')
print(f'https://facebook.com/{i["_key"]}')
print(f'\nAntal träffar: {len(result)}\n')

@ -59,7 +59,7 @@ def write_stats(db, continuous=False):
break break
# Info för arangodb # Info för arangodb
user_arango = "Lasse" user_arango = "Stats"
db_arango = "facebook" db_arango = "facebook"
host_arango = "http://192.168.0.4:8529" host_arango = "http://192.168.0.4:8529"

Loading…
Cancel
Save