User creation automated + server port configurable
* Make sure user input can never contain an invalid character as it might create a shell exploit vulnerability otherwise
This commit is contained in:
parent
c88a1c1c5b
commit
ece785b02e
|
@ -1,3 +1,5 @@
|
|||
cache/*
|
||||
headers/*
|
||||
db/*
|
||||
scripts/user_create
|
||||
__pycache__/*
|
||||
|
|
21
igmirror.py
21
igmirror.py
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/python3
|
||||
import requests
|
||||
import hashlib
|
||||
import string
|
||||
import random
|
||||
import time
|
||||
import json
|
||||
|
@ -8,8 +9,26 @@ import os
|
|||
import re
|
||||
|
||||
def add_igaccount(acc_id):
|
||||
accfile = './db/accounts/{}'.format(acc_id)
|
||||
if not os.path.exists(accfile):
|
||||
data = getig_user_data(acc_id)
|
||||
print(data)
|
||||
name = data['graphql']['user']['full_name']
|
||||
name = re.sub(r'[^a-zA-Z0-9_\s]', '', name)
|
||||
account = {
|
||||
'name': name,
|
||||
'username': acc_id,
|
||||
'password': random_string()
|
||||
}
|
||||
if os.path.exists('./scripts/user_create'):
|
||||
os.system('./scripts/user_create \'{}\' \'{}\' \'{}\''.format(\
|
||||
account['name'], account['username'], account['password']))
|
||||
w = open(accfile, 'w')
|
||||
w.write(json.dumps(account))
|
||||
w.close()
|
||||
#data = getig_user_data(acc_id)
|
||||
|
||||
def random_string(count=32):
|
||||
return ''.join(random.choices(string.ascii_uppercase + string.ascii_lowercase + string.digits, k=count))
|
||||
|
||||
# get all profile data from user:
|
||||
# - display name
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
#!/bin/bash
|
||||
cd /var/www/html
|
||||
php artisan user:create --name="$1" --username="$2" --email="pixelfed.$2@localhost" --password="$3" --confirm_email=1 -q -n
|
11
server.py
11
server.py
|
@ -1,10 +1,8 @@
|
|||
from http.server import BaseHTTPRequestHandler, HTTPServer
|
||||
import igmirror
|
||||
import sys
|
||||
import re
|
||||
|
||||
hostName = "localhost"
|
||||
serverPort = 8080
|
||||
|
||||
def update_igaccount(name):
|
||||
print(name)
|
||||
|
||||
|
@ -25,8 +23,11 @@ class MyServer(BaseHTTPRequestHandler):
|
|||
self.wfile.write(bytes('OK', "utf-8"))
|
||||
|
||||
if __name__ == "__main__":
|
||||
webServer = HTTPServer(('localhost', 8080), MyServer)
|
||||
print("Server started http://%s:%s" % (hostName, serverPort))
|
||||
port = 8080
|
||||
if len(sys.argv) > 1:
|
||||
port = int(sys.argv[1])
|
||||
webServer = HTTPServer(('0.0.0.0', port), MyServer)
|
||||
print("Server started http://%s:%s" % ('0.0.0.0', port))
|
||||
|
||||
try:
|
||||
webServer.serve_forever()
|
||||
|
|
Loading…
Reference in New Issue