forked from mandatoryprogrammer/xsshunter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate_config.py
executable file
·178 lines (152 loc) · 5.18 KB
/
generate_config.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
#!/usr/bin/env python
import binascii
import yaml
import os
nginx_template = """
server {
# Redirect HTTP to www
listen 80;
server_name fakedomain.com;
location / {
rewrite ^/(.*)$ https://www.fakedomain.com/$1 permanent;
}
}
server {
# Redirect payloads to HTTPS
listen 80;
server_name *.fakedomain.com;
proxy_set_header X-Forwarded-For $remote_addr;
return 307 https://$host$request_uri;
client_max_body_size 500M; # In case we have an extra large payload capture
}
server {
# Redirect HTTPS to www
listen 443;
ssl on;
ssl_certificate /etc/nginx/ssl/fakedomain.com.crt; # Wildcard SSL certificate
ssl_certificate_key /etc/nginx/ssl/fakedomain.com.key; # Wildcard SSL certificate key
server_name fakedomain.com;
location / {
rewrite ^/(.*)$ https://www.fakedomain.com/$1 permanent;
}
}
server {
# API proxy
listen 443;
ssl on;
ssl_certificate /etc/nginx/ssl/fakedomain.com.crt; # Wildcard SSL certificate
ssl_certificate_key /etc/nginx/ssl/fakedomain.com.key; # Wildcard SSL certificate key
server_name *.fakedomain.com;
access_log /var/log/nginx/fakedomain.com.vhost.access.log;
error_log /var/log/nginx/fakedomain.com.vhost.error.log;
client_max_body_size 500M;
location / {
proxy_pass http://localhost:8888;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
}
}
server {
# Redirect api to HTTPS
listen 80;
server_name api.fakedomain.com; # Subdomain for API server
proxy_set_header X-Forwarded-For $remote_addr;
return 307 https://api.fakedomain.com$request_uri;
client_max_body_size 500M; # In case we have an extra large payload capture
}
server {
# Redirect www to HTTPS
listen 80;
server_name www.fakedomain.com;
location / {
rewrite ^/(.*)$ https://www.fakedomain.com/$1 permanent;
}
}
server {
# GUI proxy
listen 443;
server_name www.fakedomain.com;
client_max_body_size 500M;
ssl on;
ssl_certificate /etc/nginx/ssl/fakedomain.com.crt; # Wildcard SSL certificate
ssl_certificate_key /etc/nginx/ssl/fakedomain.com.key; # Wildcard SSL certificate key
location / {
proxy_pass http://localhost:1234;
proxy_set_header Host $host;
}
}
"""
settings = {
"email_from":"",
"mailgun_api_key":"",
"mailgun_sending_domain":"",
"domain": "",
"abuse_email": "",
"cookie_secret": "",
}
print """
__ __ _____ _____ _ _ _
\ \ / // ____/ ____| | | | | | |
\ V /| (___| (___ | |__| |_ _ _ __ | |_ ___ _ __
> < \___ \\\\___ \ | __ | | | | '_ \| __/ _ \ '__|
/ . \ ____) |___) | | | | | |_| | | | | || __/ |
/_/ \_\_____/_____/ |_| |_|\__,_|_| |_|\__\___|_|
Setup Utility
"""
print "What is the base domain name you will be using? "
print "(ex. localhost, www.example.com)"
hostname = raw_input( "Domain? ")
if hostname != "":
settings["domain"] = hostname
nginx_template = nginx_template.replace( "fakedomain.com", settings["domain"] )
print "Great! Now let's setup your Mailgun account to send XSS alerts to."
print ""
print "Enter your API key: "
print "(ex. key-8da843ff65205a61374b09b81ed0fa35)"
settings["mailgun_api_key"] = raw_input( "Mailgun API key: ")
print ""
print "What is your Mailgun domain? "
print "(ex. example.com)"
settings["mailgun_sending_domain"] = raw_input( "Mailgun domain: ")
print ""
print "What email address is sending the payload fire emails?: "
print "(ex. [email protected])"
settings["email_from"] = raw_input( "Sending email address: ")
print ""
print "Where should abuse/contact emails go?: "
print "(ex. [email protected])"
settings["abuse_email"] = raw_input( "Abuse/Contact email: ")
print ""
print ""
print "What postgres user is this service using? "
print "(ex. xsshunter)"
settings["postgreql_username"] = raw_input( "Postgres username: ")
print ""
print "What is the postgres user's password? "
print "(ex. @!$%@^%UOFGJOEJG$)"
settings["postgreql_password"] = raw_input( "Postgres password: ")
print ""
print "What is the postgres user's DB? "
print "(ex. xsshunter)"
settings["postgres_db"] = raw_input( "Postgres DB: ")
print ""
print "Generating cookie secret..."
settings["cookie_secret"] = binascii.hexlify( os.urandom(50) )
yaml_config = yaml.dump( settings, default_flow_style=False)
file_handler = open( "config.yaml", "w" )
file_handler.write( yaml_config )
file_handler.close()
print "Minting new nginx configuration file..."
file_handler = open( "default", "w" )
file_handler.write( nginx_template )
file_handler.close()
print """
Setup complete! Please now copy the 'default' file to /etc/nginx/sites-enabled/default
This can be done by running the following:
sudo cp default /etc/nginx/sites-enabled/default
Also, please ensure your wildcard SSL certificate and key are available at the following locations:
/etc/nginx/ssl/""" + hostname + """.crt; # Wildcard SSL certificate
/etc/nginx/ssl/""" + hostname + """.key; # Wildcard SSL key
Good luck hunting for XSS!
-mandatory
"""