From 17ea7c96c91ffafced167a63bab66e662b43d926 Mon Sep 17 00:00:00 2001 From: Lasse Date: Wed, 6 Oct 2021 07:43:40 +0200 Subject: [PATCH] . --- fb-webbapp/app.py | 81 ++++++++ fb-webbapp/config.py | 19 ++ fb-webbapp/html_page.py | 14 ++ mrkoll/mrkoll_oxylabs.py | 7 +- mrkoll/servers_oxylabs.py | 422 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 540 insertions(+), 3 deletions(-) create mode 100644 fb-webbapp/app.py create mode 100644 fb-webbapp/config.py create mode 100644 fb-webbapp/html_page.py create mode 100644 mrkoll/servers_oxylabs.py diff --git a/fb-webbapp/app.py b/fb-webbapp/app.py new file mode 100644 index 0000000..c46803a --- /dev/null +++ b/fb-webbapp/app.py @@ -0,0 +1,81 @@ +from flask import Flask, render_template, redirect, url_for, request +from time import sleep +from sshtunnel import open_tunnel +import paramiko +from getpass import getpass +from arango import ArangoClient +from config import host_adress, db_arango +from html_page import html_text + +# Route for handling the login page logic + + +# import the Flask class from the flask module +from flask import Flask, render_template + +# create the application object +app = Flask(__name__) + +# use decorators to link the function to a url +@app.route("/") +def home(): + return "Hello, World!" # return a string + + +@app.route("/welcome") +def welcome(): + return render_template("welcome.html") # render a template + +@app.route("/result") +def result(url): + return render_template(url) # render a template + +@app.route("/login", methods=["GET", "POST"]) +def login(): + error = None + if request.method == "POST": + credentials = { + "lasse": "test" + } + if ( + request.form["username"] not in credentials + or request.form["password"] != credentials[request.form["username"]] + ): + sleep(2) + error = "Fel lösenord. Testa igen." + else: + sleep(2) + username = 'Webbapp' + pwd = 'jagged-CUTTER-lyon-yourself-scavenge' + path_to_key="/Users/Lasse/.ssh/id_rsa" + pwd_key = getpass('Key pwd: ') + + with open_tunnel( + (host_adress, 2210), + ssh_username="lasse", + ssh_pkey=paramiko.RSAKey.from_private_key_file( + path_to_key, password=pwd_key + ), + ssh_private_key_password=pwd_key, + remote_bind_address=("127.0.0.1", 8529)) as server: + + port_arango = server.local_bind_port # En annan port än den "vanliga", ska användas nedan. + + db = ArangoClient(hosts=f'{"http://127.0.0.1"}:{port_arango}').db( + db_arango, username=username, password=pwd, + ) + + r = db.collection('members').random() + html = html_text.replace('RESULTAT', r['_key']) + with open('/Users/Lasse/Datorgemensamt/Programmeringsprojekt/Facebook/fb-scraper/fb-webbapp/templates/test.html', 'w') as page: + page.write(html) + # Gör söking, skapa sida, returnera den.a + return render_template('test.html') + + return render_template("login.html", error=error) + + + +# start the server with the 'run()' method +if __name__ == "__main__": + app.run(debug=False) diff --git a/fb-webbapp/config.py b/fb-webbapp/config.py new file mode 100644 index 0000000..713e569 --- /dev/null +++ b/fb-webbapp/config.py @@ -0,0 +1,19 @@ +from getpass import getpass + +def set_pwd(_pwd=None): + global pwd + if _pwd == None: + _pwd = getpass('Lösenord för Arango-användaren:') + pwd = _pwd + +# Info för arangodb +user_arango = "Lasse" +db_arango = "facebook" +host_arango = 'http://192.168.1.10' +port_arango = '8529' +host_adress = "studio-garda.asuscomm.com" #IP/adress till där db finns + +# Andra uppgifter +url_bas = "https://mbasic.facebook.com" +user_agent = "Mozilla/5.0 (iPhone; CPU iPhone OS 10_3 like Mac OS X) AppleWebKit/602.1.50 (KHTML, like Gecko) CriOS/56.0.2924.75 Mobile/14E5239e Safari/602.1" +mullvad = '8155249667566524' \ No newline at end of file diff --git a/fb-webbapp/html_page.py b/fb-webbapp/html_page.py new file mode 100644 index 0000000..a821788 --- /dev/null +++ b/fb-webbapp/html_page.py @@ -0,0 +1,14 @@ +html_text = """ + + + Resultat + + + +
+ +
+

RESULTAT

+
+ +""" \ No newline at end of file diff --git a/mrkoll/mrkoll_oxylabs.py b/mrkoll/mrkoll_oxylabs.py index 4aee884..ec82a09 100644 --- a/mrkoll/mrkoll_oxylabs.py +++ b/mrkoll/mrkoll_oxylabs.py @@ -14,6 +14,7 @@ import urllib import urllib.request as request from bs4 import BeautifulSoup from arango import ArangoClient +from servers_oxylabs import servers def find_person(number, errors, server): @@ -26,7 +27,7 @@ def find_person(number, errors, server): url = f'https://mrkoll.se/resultat?n={number}' user_agent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36" headers = {'User-agent': user_agent} - query = request.build_opener(request.ProxyHandler({'http': proxy})) + query = request.build_opener(request.ProxyHandler({'https': proxy})) req = request.Request(url, headers=headers) n = 0 @@ -163,13 +164,13 @@ if __name__ == "__main__": # proxies = { 'https': 'https://il061376:"typical-humidify-upheave-aback-rusty"@lexvpn.integrity.st:1723' } - servers_json = json.load(open('oxylabs_servers_trail.json')) + servers_json = servers # Info för arangodb user_arango = "Phone" db_arango = "facebook" - host_arango = "http://192.168.1.20:8529" + host_arango = "http://192.168.1.10:8529" # Starta koppling till arangodb # Avkryptera lösen till arango diff --git a/mrkoll/servers_oxylabs.py b/mrkoll/servers_oxylabs.py new file mode 100644 index 0000000..39a8d32 --- /dev/null +++ b/mrkoll/servers_oxylabs.py @@ -0,0 +1,422 @@ +servers = [ + { + "ip": "149.71.186.1", + "port": "60000", + "country": "SE", + "city": "Stockholm", + "created_at": "2021-09-09 12:48:31", + }, + { + "ip": "149.71.186.101", + "port": "60000", + "country": "SE", + "city": "Stockholm", + "created_at": "2021-09-09 12:48:31", + }, + { + "ip": "149.71.186.112", + "port": "60000", + "country": "SE", + "city": "Stockholm", + "created_at": "2021-09-09 12:48:31", + }, + { + "ip": "149.71.186.114", + "port": "60000", + "country": "SE", + "city": "Stockholm", + "created_at": "2021-09-09 12:48:31", + }, + { + "ip": "149.71.186.116", + "port": "60000", + "country": "SE", + "city": "Stockholm", + "created_at": "2021-09-09 12:48:31", + }, + { + "ip": "149.71.186.118", + "port": "60000", + "country": "SE", + "city": "Stockholm", + "created_at": "2021-09-09 12:48:31", + }, + { + "ip": "149.71.186.124", + "port": "60000", + "country": "SE", + "city": "Stockholm", + "created_at": "2021-09-09 12:48:31", + }, + { + "ip": "149.71.186.129", + "port": "60000", + "country": "SE", + "city": "Stockholm", + "created_at": "2021-09-09 12:48:31", + }, + { + "ip": "149.71.186.131", + "port": "60000", + "country": "SE", + "city": "Stockholm", + "created_at": "2021-09-09 12:48:31", + }, + { + "ip": "149.71.186.133", + "port": "60000", + "country": "SE", + "city": "Stockholm", + "created_at": "2021-09-09 12:48:31", + }, + { + "ip": "149.71.186.144", + "port": "60000", + "country": "SE", + "city": "Stockholm", + "created_at": "2021-09-09 12:48:31", + }, + { + "ip": "149.71.186.146", + "port": "60000", + "country": "SE", + "city": "Stockholm", + "created_at": "2021-09-09 12:48:31", + }, + { + "ip": "149.71.186.148", + "port": "60000", + "country": "SE", + "city": "Stockholm", + "created_at": "2021-09-09 12:48:31", + }, + { + "ip": "149.71.186.150", + "port": "60000", + "country": "SE", + "city": "Stockholm", + "created_at": "2021-09-09 12:48:31", + }, + { + "ip": "149.71.186.156", + "port": "60000", + "country": "SE", + "city": "Stockholm", + "created_at": "2021-09-09 12:48:31", + }, + { + "ip": "149.71.186.16", + "port": "60000", + "country": "SE", + "city": "Stockholm", + "created_at": "2021-09-09 12:48:31", + }, + { + "ip": "149.71.186.161", + "port": "60000", + "country": "SE", + "city": "Stockholm", + "created_at": "2021-09-09 12:48:31", + }, + { + "ip": "149.71.186.163", + "port": "60000", + "country": "SE", + "city": "Stockholm", + "created_at": "2021-09-09 12:48:31", + }, + { + "ip": "149.71.186.165", + "port": "60000", + "country": "SE", + "city": "Stockholm", + "created_at": "2021-09-09 12:48:31", + }, + { + "ip": "149.71.186.176", + "port": "60000", + "country": "SE", + "city": "Stockholm", + "created_at": "2021-09-09 12:48:31", + }, + { + "ip": "149.71.186.178", + "port": "60000", + "country": "SE", + "city": "Stockholm", + "created_at": "2021-09-09 12:48:31", + }, + { + "ip": "149.71.186.18", + "port": "60000", + "country": "SE", + "city": "Stockholm", + "created_at": "2021-09-09 12:48:31", + }, + { + "ip": "149.71.186.180", + "port": "60000", + "country": "SE", + "city": "Stockholm", + "created_at": "2021-09-09 12:48:31", + }, + { + "ip": "149.71.186.188", + "port": "60000", + "country": "SE", + "city": "Stockholm", + "created_at": "2021-09-09 12:48:31", + }, + { + "ip": "149.71.186.193", + "port": "60000", + "country": "SE", + "city": "Stockholm", + "created_at": "2021-09-09 12:48:31", + }, + { + "ip": "149.71.186.195", + "port": "60000", + "country": "SE", + "city": "Stockholm", + "created_at": "2021-09-09 12:48:31", + }, + { + "ip": "149.71.186.197", + "port": "60000", + "country": "SE", + "city": "Stockholm", + "created_at": "2021-09-09 12:48:31", + }, + { + "ip": "149.71.186.20", + "port": "60000", + "country": "SE", + "city": "Stockholm", + "created_at": "2021-09-09 12:48:31", + }, + { + "ip": "149.71.186.208", + "port": "60000", + "country": "SE", + "city": "Stockholm", + "created_at": "2021-09-09 12:48:31", + }, + { + "ip": "149.71.186.210", + "port": "60000", + "country": "SE", + "city": "Stockholm", + "created_at": "2021-09-09 12:48:31", + }, + { + "ip": "149.71.186.212", + "port": "60000", + "country": "SE", + "city": "Stockholm", + "created_at": "2021-09-09 12:48:31", + }, + { + "ip": "149.71.186.22", + "port": "60000", + "country": "SE", + "city": "Stockholm", + "created_at": "2021-09-09 12:48:31", + }, + { + "ip": "149.71.186.220", + "port": "60000", + "country": "SE", + "city": "Stockholm", + "created_at": "2021-09-09 12:48:31", + }, + { + "ip": "149.71.186.225", + "port": "60000", + "country": "SE", + "city": "Stockholm", + "created_at": "2021-09-09 12:48:31", + }, + { + "ip": "149.71.186.227", + "port": "60000", + "country": "SE", + "city": "Stockholm", + "created_at": "2021-09-09 12:48:31", + }, + { + "ip": "149.71.186.229", + "port": "60000", + "country": "SE", + "city": "Stockholm", + "created_at": "2021-09-09 12:48:31", + }, + { + "ip": "149.71.186.240", + "port": "60000", + "country": "SE", + "city": "Stockholm", + "created_at": "2021-09-09 12:48:31", + }, + { + "ip": "149.71.186.242", + "port": "60000", + "country": "SE", + "city": "Stockholm", + "created_at": "2021-09-09 12:48:31", + }, + { + "ip": "149.71.186.244", + "port": "60000", + "country": "SE", + "city": "Stockholm", + "created_at": "2021-09-09 12:48:31", + }, + { + "ip": "149.71.186.252", + "port": "60000", + "country": "SE", + "city": "Stockholm", + "created_at": "2021-09-09 12:48:31", + }, + { + "ip": "149.71.186.3", + "port": "60000", + "country": "SE", + "city": "Stockholm", + "created_at": "2021-09-09 12:48:31", + }, + { + "ip": "149.71.186.33", + "port": "60000", + "country": "SE", + "city": "Stockholm", + "created_at": "2021-09-09 12:48:31", + }, + { + "ip": "149.71.186.35", + "port": "60000", + "country": "SE", + "city": "Stockholm", + "created_at": "2021-09-09 12:48:31", + }, + { + "ip": "149.71.186.37", + "port": "60000", + "country": "SE", + "city": "Stockholm", + "created_at": "2021-09-09 12:48:31", + }, + { + "ip": "149.71.186.48", + "port": "60000", + "country": "SE", + "city": "Stockholm", + "created_at": "2021-09-09 12:48:31", + }, + { + "ip": "149.71.186.5", + "port": "60000", + "country": "SE", + "city": "Stockholm", + "created_at": "2021-09-09 12:48:31", + }, + { + "ip": "149.71.186.50", + "port": "60000", + "country": "SE", + "city": "Stockholm", + "created_at": "2021-09-09 12:48:31", + }, + { + "ip": "149.71.186.52", + "port": "60000", + "country": "SE", + "city": "Stockholm", + "created_at": "2021-09-09 12:48:31", + }, + { + "ip": "149.71.186.54", + "port": "60000", + "country": "SE", + "city": "Stockholm", + "created_at": "2021-09-09 12:48:31", + }, + { + "ip": "149.71.186.60", + "port": "60000", + "country": "SE", + "city": "Stockholm", + "created_at": "2021-09-09 12:48:31", + }, + { + "ip": "149.71.186.65", + "port": "60000", + "country": "SE", + "city": "Stockholm", + "created_at": "2021-09-09 12:48:31", + }, + { + "ip": "149.71.186.67", + "port": "60000", + "country": "SE", + "city": "Stockholm", + "created_at": "2021-09-09 12:48:31", + }, + { + "ip": "149.71.186.69", + "port": "60000", + "country": "SE", + "city": "Stockholm", + "created_at": "2021-09-09 12:48:31", + }, + { + "ip": "149.71.186.80", + "port": "60000", + "country": "SE", + "city": "Stockholm", + "created_at": "2021-09-09 12:48:31", + }, + { + "ip": "149.71.186.82", + "port": "60000", + "country": "SE", + "city": "Stockholm", + "created_at": "2021-09-09 12:48:31", + }, + { + "ip": "149.71.186.84", + "port": "60000", + "country": "SE", + "city": "Stockholm", + "created_at": "2021-09-09 12:48:31", + }, + { + "ip": "149.71.186.86", + "port": "60000", + "country": "SE", + "city": "Stockholm", + "created_at": "2021-09-09 12:48:31", + }, + { + "ip": "149.71.186.92", + "port": "60000", + "country": "SE", + "city": "Stockholm", + "created_at": "2021-09-09 12:48:31", + }, + { + "ip": "149.71.186.97", + "port": "60000", + "country": "SE", + "city": "Stockholm", + "created_at": "2021-09-09 12:48:31", + }, + { + "ip": "149.71.186.99", + "port": "60000", + "country": "SE", + "city": "Stockholm", + "created_at": "2021-09-09 12:48:31", + }, +]