master^2
parent
b135eb9b82
commit
17ea7c96c9
5 changed files with 540 additions and 3 deletions
@ -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) |
||||
@ -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' |
||||
@ -0,0 +1,14 @@ |
||||
html_text = """<!DOCTYPE html> |
||||
<html> |
||||
<head> |
||||
<title>Resultat</title> |
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> |
||||
</head> |
||||
<body> |
||||
<div class="container"> |
||||
|
||||
<br> |
||||
<p>RESULTAT</p> |
||||
</div> |
||||
</body> |
||||
</html>""" |
||||
@ -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", |
||||
}, |
||||
] |
||||
Loading…
Reference in new issue