mirror of
http://git.nowherejezfoltodf4jiyl6r56jnzintap5vyjlia7fkirfsnfizflqd.onion/nihilist/darknet-lantern.git
synced 2025-07-01 22:26:41 +00:00
77 lines
2.2 KiB
Python
77 lines
2.2 KiB
Python
#!/bin/python3
|
|
############################################################
|
|
# Python script to setup docker containers on debian machines.
|
|
#
|
|
#
|
|
|
|
|
|
import subprocess
|
|
from string import Template
|
|
from typing import Optional
|
|
|
|
# Constants
|
|
dep_install = ["php-gd", "php8.2-fpm", "nginx"]
|
|
lantern_dep = ["python3-pandas", "python3-requests", "python3-socks", "python3-dotenv", "python3-pip"]
|
|
shell = "python3 -c 'import pty; pty.spawn(\"/bin/sh\")'"
|
|
nginx_conf = Template("""server {
|
|
listen 4443;
|
|
listen [::]:4443;
|
|
server_name lantern.$onion_domain;
|
|
|
|
root /srv/darknet-lantern/www/;
|
|
location ~ \\.php$ {
|
|
include snippets/fastcgi-php.conf;
|
|
fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
|
|
}
|
|
index index.php;
|
|
}""")
|
|
|
|
tor_conf = """
|
|
HiddenServiceDir /var/lib/tor/lantern/
|
|
HiddenServicePort 80 127.0.0.1:4443
|
|
SocksPort 127.0.0.1:9050
|
|
"""
|
|
|
|
def update_and_install(to_be_installed: Optional[list]) -> None:
|
|
""" APT Update and Install
|
|
|
|
This function handles all updates and installs needed in this script.
|
|
Args:
|
|
|
|
to_be_installed -> a list of string(packages) that will be installed
|
|
|
|
return -> None
|
|
"""
|
|
packages = to_be_installed
|
|
subprocess.run(["torsocks","apt-get","update"])
|
|
if packages is None:
|
|
return
|
|
else:
|
|
print(f"Installing {len(packages)} package(s)")
|
|
for package in packages:
|
|
subprocess.run(["torsocks","apt-get", "install", package])
|
|
|
|
def main():
|
|
|
|
# Install dependencies
|
|
update_and_install(to_be_installed=dep_install)
|
|
|
|
# Change tor conf file
|
|
subprocess.run(["rm", "/etc/tor/torrc"])
|
|
subprocess.run(["cp","torrc", "/etc/tor/torrc"])
|
|
subprocess.run(["service", "tor", "restart"])
|
|
domain = subprocess.run(["cat", "/var/lib/tor/lantern/hostname"], capture=True)
|
|
nginx_conf.safe_substitute(onion_domain=domain)
|
|
subprocess.run(["service", "tor", "restart"])
|
|
|
|
subprocess(["ln","-s","/etc/nginx/sites-available/lantern.conf","/etc/nginx/sites-enabled/"])
|
|
subprocess(["nginx", "-s", "reload"])
|
|
|
|
update_and_install(to_be_installed=lantern_dep)
|
|
|
|
print(f"Here i {domain}")
|
|
|
|
|
|
main()
|
|
print(shell)
|
|
print()
|