ronin-app 0.1.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.dockerignore +3 -0
- data/.document +6 -0
- data/.env.dev +1 -0
- data/.github/workflows/ruby.yml +44 -0
- data/.gitignore +16 -0
- data/.rspec +1 -0
- data/.rubocop.yml +26 -0
- data/.ruby-version +1 -0
- data/.yardopts +1 -0
- data/CONTRIBUTING.md +34 -0
- data/COPYING.txt +661 -0
- data/ChangeLog.md +38 -0
- data/Dockerfile +27 -0
- data/Gemfile +61 -0
- data/Procfile +2 -0
- data/Procfile.dev +2 -0
- data/README.md +215 -0
- data/Rakefile +44 -0
- data/app/db.rb +680 -0
- data/app/scanning.rb +173 -0
- data/app.rb +372 -0
- data/bin/ronin-app +34 -0
- data/config/database.rb +17 -0
- data/config/puma.rb +24 -0
- data/config/redis.rb +4 -0
- data/config/sidekiq.rb +23 -0
- data/config/sidekiq.yml +12 -0
- data/config.ru +33 -0
- data/docker-compose.yml +45 -0
- data/etc/systemd/user/ronin-app-sidekiq.1.service +17 -0
- data/etc/systemd/user/ronin-app-web.1.service +18 -0
- data/etc/systemd/user/ronin-app.target +5 -0
- data/gemspec.yml +55 -0
- data/lib/middleware/sidekiq/active_record_connection_pool.rb +47 -0
- data/lib/ronin/app/cli.rb +197 -0
- data/lib/ronin/app/helpers/html.rb +71 -0
- data/lib/ronin/app/root.rb +28 -0
- data/lib/ronin/app/schemas/params_schema.rb +66 -0
- data/lib/ronin/app/schemas/payloads/build_schema.rb +56 -0
- data/lib/ronin/app/schemas/payloads/encoders/encode_schema.rb +60 -0
- data/lib/ronin/app/types/import.rb +35 -0
- data/lib/ronin/app/types/nmap.rb +81 -0
- data/lib/ronin/app/types/spider.rb +49 -0
- data/lib/ronin/app/types/vulns.rb +69 -0
- data/lib/ronin/app/types.rb +66 -0
- data/lib/ronin/app/validations/import_params.rb +71 -0
- data/lib/ronin/app/validations/install_repo_params.rb +78 -0
- data/lib/ronin/app/validations/masscan_params.rb +122 -0
- data/lib/ronin/app/validations/nmap_params.rb +183 -0
- data/lib/ronin/app/validations/recon_params.rb +86 -0
- data/lib/ronin/app/validations/spider_params.rb +103 -0
- data/lib/ronin/app/validations/vulns_params.rb +83 -0
- data/lib/ronin/app/version.rb +26 -0
- data/log/.gitkeep +0 -0
- data/man/ronin-app.1 +63 -0
- data/man/ronin-app.1.md +61 -0
- data/public/images/favicon.png +0 -0
- data/public/images/favicon.svg +78 -0
- data/public/images/logo.svg +78 -0
- data/public/images/sidekiq.svg +24 -0
- data/public/javascript/app.js +60 -0
- data/public/javascript/notes.js +28 -0
- data/public/javascript/tabs.js +40 -0
- data/public/stylesheets/app.css +216 -0
- data/public/stylesheets/bulma.min.css +1 -0
- data/ronin-app.gemspec +63 -0
- data/scripts/console +7 -0
- data/scripts/server +134 -0
- data/scripts/setup +447 -0
- data/scripts/update +55 -0
- data/tmp/.gitkeep +0 -0
- data/views/_authors.erb +62 -0
- data/views/_delete.erb +4 -0
- data/views/_delete_all.erb +4 -0
- data/views/_encoding_tabs.erb +25 -0
- data/views/_notes.erb +33 -0
- data/views/_pagination.erb +1 -0
- data/views/_param_fields.erb +66 -0
- data/views/_params.erb +35 -0
- data/views/about.erb +30 -0
- data/views/db/advisories/index.erb +30 -0
- data/views/db/advisories/show.erb +105 -0
- data/views/db/asns/index.erb +19 -0
- data/views/db/asns/show.erb +61 -0
- data/views/db/credentials/index.erb +30 -0
- data/views/db/credentials/show.erb +51 -0
- data/views/db/email_addresses/index.erb +30 -0
- data/views/db/email_addresses/show.erb +44 -0
- data/views/db/host_names/index.erb +30 -0
- data/views/db/host_names/show.erb +52 -0
- data/views/db/ip_addresses/index.erb +19 -0
- data/views/db/ip_addresses/show.erb +98 -0
- data/views/db/mac_addresses/index.erb +19 -0
- data/views/db/mac_addresses/show.erb +62 -0
- data/views/db/open_ports/index.erb +19 -0
- data/views/db/open_ports/show.erb +87 -0
- data/views/db/organizations/departments/show.erb +82 -0
- data/views/db/organizations/index.erb +28 -0
- data/views/db/organizations/members/show.erb +87 -0
- data/views/db/organizations/show.erb +111 -0
- data/views/db/oses/index.erb +19 -0
- data/views/db/oses/show.erb +46 -0
- data/views/db/passwords/index.erb +30 -0
- data/views/db/passwords/show.erb +52 -0
- data/views/db/people/index.erb +31 -0
- data/views/db/people/show.erb +120 -0
- data/views/db/phone_numbers/index.erb +30 -0
- data/views/db/phone_numbers/show.erb +63 -0
- data/views/db/ports/index.erb +30 -0
- data/views/db/ports/show.erb +70 -0
- data/views/db/services/index.erb +30 -0
- data/views/db/services/show.erb +65 -0
- data/views/db/software/index.erb +19 -0
- data/views/db/software/show.erb +52 -0
- data/views/db/software_vendors/index.erb +19 -0
- data/views/db/software_vendors/show.erb +36 -0
- data/views/db/street_addresses/index.erb +19 -0
- data/views/db/street_addresses/show.erb +63 -0
- data/views/db/url_query_param_names/index.erb +19 -0
- data/views/db/url_query_param_names/show.erb +50 -0
- data/views/db/url_schemes/index.erb +19 -0
- data/views/db/url_schemes/show.erb +36 -0
- data/views/db/urls/index.erb +30 -0
- data/views/db/urls/show.erb +103 -0
- data/views/db/user_names/index.erb +30 -0
- data/views/db/user_names/show.erb +48 -0
- data/views/db/vulns/index.erb +19 -0
- data/views/db/vulns/show.erb +104 -0
- data/views/db.erb +152 -0
- data/views/exploits/index.erb +9 -0
- data/views/exploits/show.erb +100 -0
- data/views/import.erb +30 -0
- data/views/index.erb +7 -0
- data/views/layout.erb +98 -0
- data/views/masscan.erb +459 -0
- data/views/nmap.erb +1009 -0
- data/views/payloads/build.erb +19 -0
- data/views/payloads/encoders/encode.erb +35 -0
- data/views/payloads/encoders/index.erb +9 -0
- data/views/payloads/encoders/show.erb +47 -0
- data/views/payloads/index.erb +9 -0
- data/views/payloads/show.erb +47 -0
- data/views/queue.erb +28 -0
- data/views/recon.erb +55 -0
- data/views/repos/index.erb +30 -0
- data/views/repos/install.erb +45 -0
- data/views/repos/show.erb +39 -0
- data/views/spider.erb +372 -0
- data/views/vulns.erb +214 -0
- data/workers/import.rb +96 -0
- data/workers/install_repo.rb +40 -0
- data/workers/masscan.rb +135 -0
- data/workers/nmap.rb +216 -0
- data/workers/purge_repos.rb +40 -0
- data/workers/recon.rb +95 -0
- data/workers/remove_repo.rb +40 -0
- data/workers/spider.rb +148 -0
- data/workers/update_repo.rb +42 -0
- data/workers/update_repos.rb +40 -0
- data/workers/vulns.rb +111 -0
- data/workers.rb +37 -0
- metadata +538 -0
data/scripts/server
ADDED
@@ -0,0 +1,134 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
#
|
4
|
+
# Prints a log message.
|
5
|
+
#
|
6
|
+
function log()
|
7
|
+
{
|
8
|
+
if [[ -t 1 ]]; then
|
9
|
+
echo -e "\x1b[1m\x1b[32m>>>\x1b[0m \x1b[1m$1\x1b[0m"
|
10
|
+
else
|
11
|
+
echo ">>> $1"
|
12
|
+
fi
|
13
|
+
}
|
14
|
+
|
15
|
+
#
|
16
|
+
# Prints a warn message.
|
17
|
+
#
|
18
|
+
function warn()
|
19
|
+
{
|
20
|
+
if [[ -t 1 ]]; then
|
21
|
+
echo -e "\x1b[1m\x1b[33m***\x1b[0m \x1b[1m$1\x1b[0m" >&2
|
22
|
+
else
|
23
|
+
echo "*** $1" >&2
|
24
|
+
fi
|
25
|
+
}
|
26
|
+
|
27
|
+
#
|
28
|
+
# Prints an error message.
|
29
|
+
#
|
30
|
+
function error()
|
31
|
+
{
|
32
|
+
if [[ -t 1 ]]; then
|
33
|
+
echo -e "\x1b[1m\x1b[31m!!!\x1b[0m \x1b[1m$1\x1b[0m" >&2
|
34
|
+
else
|
35
|
+
echo "!!! $1" >&2
|
36
|
+
fi
|
37
|
+
}
|
38
|
+
|
39
|
+
#
|
40
|
+
# Prints an error message and exists with -1.
|
41
|
+
#
|
42
|
+
function fail()
|
43
|
+
{
|
44
|
+
error "$@"
|
45
|
+
exit -1
|
46
|
+
}
|
47
|
+
|
48
|
+
environment="development"
|
49
|
+
port=1337
|
50
|
+
|
51
|
+
#
|
52
|
+
# Print the --help usage.
|
53
|
+
#
|
54
|
+
function print_usage()
|
55
|
+
{
|
56
|
+
cat <<USAGE
|
57
|
+
usage: ./scripts/server [OPTIONS]
|
58
|
+
|
59
|
+
Options:
|
60
|
+
-e, --environment production|development
|
61
|
+
Sets the environment
|
62
|
+
-p, --port PORT Sets the web server port
|
63
|
+
-V, --version Prints the version
|
64
|
+
-h, --help Prints this message
|
65
|
+
|
66
|
+
USAGE
|
67
|
+
}
|
68
|
+
|
69
|
+
#
|
70
|
+
# Parse additional command-line options.
|
71
|
+
#
|
72
|
+
function parse_options()
|
73
|
+
{
|
74
|
+
while [[ $# -gt 0 ]]; do
|
75
|
+
case "$1" in
|
76
|
+
-e|--environment)
|
77
|
+
case "$2" in
|
78
|
+
production|development)
|
79
|
+
environment="$2"
|
80
|
+
shift 2
|
81
|
+
;;
|
82
|
+
*)
|
83
|
+
echo "server: invalid environment $2" >&2
|
84
|
+
return 1
|
85
|
+
;;
|
86
|
+
esac
|
87
|
+
;;
|
88
|
+
-p|--port)
|
89
|
+
port="$2"
|
90
|
+
shift 2
|
91
|
+
;;
|
92
|
+
-h|--help)
|
93
|
+
print_usage
|
94
|
+
exit
|
95
|
+
;;
|
96
|
+
-*)
|
97
|
+
echo "server: unrecognized option $1" >&2
|
98
|
+
return 1
|
99
|
+
;;
|
100
|
+
*)
|
101
|
+
echo "server: unexpected argument $1" >&2
|
102
|
+
return 1
|
103
|
+
;;
|
104
|
+
esac
|
105
|
+
done
|
106
|
+
}
|
107
|
+
|
108
|
+
parse_options "$@" || exit $?
|
109
|
+
|
110
|
+
pids=()
|
111
|
+
|
112
|
+
if [[ -z "$(pgrep redis-server)" ]]; then
|
113
|
+
if ! command -v redis-server >/dev/null; then
|
114
|
+
fail "server: redis-server is not installed!"
|
115
|
+
fi
|
116
|
+
|
117
|
+
redis-server &
|
118
|
+
pids+=($!)
|
119
|
+
fi
|
120
|
+
|
121
|
+
log "Starting Web server on localhost:${port} and Sidekiq ..."
|
122
|
+
|
123
|
+
case "$environment" in
|
124
|
+
development)
|
125
|
+
bundle exec foreman start -p "$port" -f Procfile.dev -e .env.dev
|
126
|
+
;;
|
127
|
+
production)
|
128
|
+
bundle exec foreman start -p "$port"
|
129
|
+
;;
|
130
|
+
esac
|
131
|
+
|
132
|
+
for pid in "${pids[@]}"; do
|
133
|
+
wait "$pid"
|
134
|
+
done
|
data/scripts/setup
ADDED
@@ -0,0 +1,447 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
gem="gem"
|
4
|
+
gem_opts=(--no-format-executable)
|
5
|
+
|
6
|
+
bundler_version="~> 2.0"
|
7
|
+
|
8
|
+
#
|
9
|
+
# Prints a log message.
|
10
|
+
#
|
11
|
+
function log()
|
12
|
+
{
|
13
|
+
if [[ -t 1 ]]; then
|
14
|
+
echo -e "\x1b[1m\x1b[32m>>>\x1b[0m \x1b[1m$1\x1b[0m"
|
15
|
+
else
|
16
|
+
echo ">>> $1"
|
17
|
+
fi
|
18
|
+
}
|
19
|
+
|
20
|
+
#
|
21
|
+
# Prints a warn message.
|
22
|
+
#
|
23
|
+
function warn()
|
24
|
+
{
|
25
|
+
if [[ -t 1 ]]; then
|
26
|
+
echo -e "\x1b[1m\x1b[33m***\x1b[0m \x1b[1m$1\x1b[0m" >&2
|
27
|
+
else
|
28
|
+
echo "*** $1" >&2
|
29
|
+
fi
|
30
|
+
}
|
31
|
+
|
32
|
+
#
|
33
|
+
# Prints an error message.
|
34
|
+
#
|
35
|
+
function error()
|
36
|
+
{
|
37
|
+
if [[ -t 1 ]]; then
|
38
|
+
echo -e "\x1b[1m\x1b[31m!!!\x1b[0m \x1b[1m$1\x1b[0m" >&2
|
39
|
+
else
|
40
|
+
echo "!!! $1" >&2
|
41
|
+
fi
|
42
|
+
}
|
43
|
+
|
44
|
+
#
|
45
|
+
# Prints an error message and exists with -1.
|
46
|
+
#
|
47
|
+
function fail()
|
48
|
+
{
|
49
|
+
error "$@"
|
50
|
+
exit -1
|
51
|
+
}
|
52
|
+
|
53
|
+
#
|
54
|
+
# Checks that $LANG is set correctly.
|
55
|
+
#
|
56
|
+
function check_lang()
|
57
|
+
{
|
58
|
+
if [[ "$LANG" == "C" ]]; then
|
59
|
+
error "ruby will not work properly with LANG=C"
|
60
|
+
fail "Please set LANG to en_US.UTF-8 or another UTF-8 language"
|
61
|
+
fi
|
62
|
+
}
|
63
|
+
|
64
|
+
#
|
65
|
+
# Sets os_platform and os_arch.
|
66
|
+
#
|
67
|
+
function detect_os()
|
68
|
+
{
|
69
|
+
os_platform="$(uname -s)"
|
70
|
+
os_arch="$(uname -m)"
|
71
|
+
}
|
72
|
+
|
73
|
+
#
|
74
|
+
# Don't use sudo if already root.
|
75
|
+
#
|
76
|
+
function detect_sudo()
|
77
|
+
{
|
78
|
+
if (( UID == 0 )); then sudo=""
|
79
|
+
else sudo="sudo"
|
80
|
+
fi
|
81
|
+
}
|
82
|
+
|
83
|
+
#
|
84
|
+
# Auto-detect the package manager.
|
85
|
+
#
|
86
|
+
function detect_package_manager()
|
87
|
+
{
|
88
|
+
case "$os_platform" in
|
89
|
+
Linux)
|
90
|
+
if [[ -f /etc/redhat-release ]]; then
|
91
|
+
if command -v dnf >/dev/null; then
|
92
|
+
package_manager="dnf"
|
93
|
+
elif command -v yum >/dev/null; then
|
94
|
+
package_manager="yum"
|
95
|
+
fi
|
96
|
+
elif [[ -f /etc/debian_version ]]; then
|
97
|
+
if command -v apt-get >/dev/null; then
|
98
|
+
package_manager="apt"
|
99
|
+
fi
|
100
|
+
elif [[ -f /etc/SuSE-release ]]; then
|
101
|
+
if command -v zypper >/dev/null; then
|
102
|
+
package_manager="zypper"
|
103
|
+
fi
|
104
|
+
elif [[ -f /etc/arch-release ]]; then
|
105
|
+
if command -v pacman >/dev/null; then
|
106
|
+
package_manager="pacman"
|
107
|
+
fi
|
108
|
+
elif [[ -f /etc/os-release ]]; then
|
109
|
+
if command -v pacman >/dev/null; then
|
110
|
+
package_manager="pacman"
|
111
|
+
elif command -v zypper >/dev/null; then
|
112
|
+
package_manager="zypper"
|
113
|
+
fi
|
114
|
+
fi
|
115
|
+
;;
|
116
|
+
Darwin)
|
117
|
+
if command -v brew >/dev/null; then
|
118
|
+
package_manager="brew"
|
119
|
+
elif command -v port >/dev/null; then
|
120
|
+
package_manager="port"
|
121
|
+
fi
|
122
|
+
;;
|
123
|
+
*BSD)
|
124
|
+
if command -v pkg >/dev/null; then
|
125
|
+
package_manager="pkg"
|
126
|
+
fi
|
127
|
+
;;
|
128
|
+
esac
|
129
|
+
}
|
130
|
+
|
131
|
+
#
|
132
|
+
# Detect the ruby version.
|
133
|
+
#
|
134
|
+
function detect_ruby_version()
|
135
|
+
{
|
136
|
+
if command -v ruby >/dev/null; then
|
137
|
+
ruby_version="$(ruby -e 'print RUBY_VERSION')"
|
138
|
+
fi
|
139
|
+
}
|
140
|
+
|
141
|
+
#
|
142
|
+
# Detect the system.
|
143
|
+
#
|
144
|
+
function detect_system()
|
145
|
+
{
|
146
|
+
check_lang
|
147
|
+
detect_os
|
148
|
+
detect_sudo
|
149
|
+
detect_package_manager
|
150
|
+
detect_ruby_version
|
151
|
+
}
|
152
|
+
|
153
|
+
#
|
154
|
+
# Detect where rubygems installs gems into and whether it's writable.
|
155
|
+
#
|
156
|
+
function detect_rubygems_install_dir()
|
157
|
+
{
|
158
|
+
local gem_dir="$(gem env gemdir)"
|
159
|
+
|
160
|
+
if (( UID == 0 )); then
|
161
|
+
gem_opts+=(--no-user-install)
|
162
|
+
elif [[ -d "$gem_dir" ]] && [[ ! -w "$gem_dir" ]]; then
|
163
|
+
gem="sudo $gem"
|
164
|
+
gem_opts+=(--no-user-install)
|
165
|
+
fi
|
166
|
+
}
|
167
|
+
|
168
|
+
#
|
169
|
+
# Installs a list of package names using the detected package manager.
|
170
|
+
#
|
171
|
+
function install_packages()
|
172
|
+
{
|
173
|
+
case "$package_manager" in
|
174
|
+
apt) $sudo apt-get install -y "$@" || return $? ;;
|
175
|
+
dnf|yum)$sudo $package_manager install -y "$@" || return $? ;;
|
176
|
+
port) $sudo port install "$@" || return $? ;;
|
177
|
+
pkg) $sudo pkg install -y "$@" || return $? ;;
|
178
|
+
brew)
|
179
|
+
local brew_owner="$(/usr/bin/stat -f %Su "$(command -v brew)")"
|
180
|
+
sudo -u "$brew_owner" brew install "$@" ||
|
181
|
+
sudo -u "$brew_owner" brew upgrade "$@" || return $?
|
182
|
+
;;
|
183
|
+
pacman)
|
184
|
+
local missing_pkgs=($(pacman -T "$@"))
|
185
|
+
|
186
|
+
if (( ${#missing_pkgs[@]} > 0 )); then
|
187
|
+
$sudo pacman -Sy --noconfirm "${missing_pkgs[@]}" || return $?
|
188
|
+
fi
|
189
|
+
;;
|
190
|
+
zypper) $sudo zypper -n in -l $* || return $? ;;
|
191
|
+
"") warn "Could not determine Package Manager. Proceeding anyway." ;;
|
192
|
+
esac
|
193
|
+
}
|
194
|
+
|
195
|
+
#
|
196
|
+
# Install redis-server if it's not already installed.
|
197
|
+
#
|
198
|
+
function auto_install_redis()
|
199
|
+
{
|
200
|
+
if ! command redis-server >/dev/null; then
|
201
|
+
log "Installing redis ..."
|
202
|
+
case "$package_manager" in
|
203
|
+
apt) install_packages redis-server ;;
|
204
|
+
*) install_packages redis ;;
|
205
|
+
esac
|
206
|
+
fi
|
207
|
+
}
|
208
|
+
|
209
|
+
#
|
210
|
+
# Installs git, if it's not installed.
|
211
|
+
#
|
212
|
+
function auto_install_git()
|
213
|
+
{
|
214
|
+
if ! command -v git >/dev/null; then
|
215
|
+
log "Installing git ..."
|
216
|
+
install_packages git || fail "Failed to install git!"
|
217
|
+
fi
|
218
|
+
}
|
219
|
+
|
220
|
+
#
|
221
|
+
# Installs ruby via homebrew and configures it.
|
222
|
+
#
|
223
|
+
function homebrew_install_ruby()
|
224
|
+
{
|
225
|
+
install_packages ruby
|
226
|
+
brew pin ruby
|
227
|
+
|
228
|
+
# make the homebrew ruby the default ruby for the script
|
229
|
+
PATH="$(brew --prefix ruby)/bin:$PATH"
|
230
|
+
hash -r
|
231
|
+
|
232
|
+
# make the homebrew ruby the default ruby for zshrc
|
233
|
+
cat >> ~/.zshrc <<CONFIG
|
234
|
+
PATH="\$(brew --prefix ruby)/bin:\$PATH"
|
235
|
+
PATH="\$(gem env gemdir)/bin:\$PATH"
|
236
|
+
CONFIG
|
237
|
+
}
|
238
|
+
|
239
|
+
#
|
240
|
+
# Installs ruby 3, if it's not installed.
|
241
|
+
#
|
242
|
+
function auto_install_ruby()
|
243
|
+
{
|
244
|
+
# check if ruby-3.x is already installed
|
245
|
+
if [[ ! "$ruby_version" == "3."* ]]; then
|
246
|
+
log "Installing ruby 3.x ..."
|
247
|
+
case "$package_manager" in
|
248
|
+
brew) homebrew_install_ruby ;;
|
249
|
+
dnf|yum) install_packages ruby-devel ruby-bundled-gems ;;
|
250
|
+
zypper) install_packages ruby-devel ;;
|
251
|
+
apt) install_packages ruby-full ;;
|
252
|
+
pacman) install_packages community/ruby ;;
|
253
|
+
*) install_packages ruby ;;
|
254
|
+
esac || fail "Failed to install ruby!"
|
255
|
+
fi
|
256
|
+
|
257
|
+
auto_install_rubygems
|
258
|
+
}
|
259
|
+
|
260
|
+
#
|
261
|
+
# Install rubygems if it's missing.
|
262
|
+
#
|
263
|
+
function auto_install_rubygems()
|
264
|
+
{
|
265
|
+
if ! command -v gem >/dev/null; then
|
266
|
+
log "Installing rubygems ..."
|
267
|
+
case "$package_manager" in
|
268
|
+
dnf|yum) install_packages rubygems ;;
|
269
|
+
pacman) install_packages community/rubygems ;;
|
270
|
+
*)
|
271
|
+
fail "rubygems was not installed along with ruby. Aborting!"
|
272
|
+
;;
|
273
|
+
esac
|
274
|
+
fi
|
275
|
+
|
276
|
+
detect_rubygems_install_dir
|
277
|
+
}
|
278
|
+
|
279
|
+
#
|
280
|
+
# Install gcc if there's no C compiler on the system.
|
281
|
+
#
|
282
|
+
function auto_install_gcc()
|
283
|
+
{
|
284
|
+
if ! command -v cc >/dev/null; then
|
285
|
+
log "Installing gcc ..."
|
286
|
+
install_packages gcc || fail "Failed to install gcc!"
|
287
|
+
fi
|
288
|
+
}
|
289
|
+
|
290
|
+
#
|
291
|
+
# Install g++ if there's no C++ compiler on the system.
|
292
|
+
#
|
293
|
+
function auto_install_gpp()
|
294
|
+
{
|
295
|
+
if ! command -v c++ >/dev/null; then
|
296
|
+
log "Installing g++ ..."
|
297
|
+
case "$package_manager" in
|
298
|
+
dnf|yum) install_packages gcc-g++ ;;
|
299
|
+
zypper) install_packages gcc-c++ ;;
|
300
|
+
*) install_packages g++ ;;
|
301
|
+
esac || fail "Failed to install g++!"
|
302
|
+
fi
|
303
|
+
}
|
304
|
+
|
305
|
+
#
|
306
|
+
# Install make if it's not already installed.
|
307
|
+
#
|
308
|
+
function auto_install_make()
|
309
|
+
{
|
310
|
+
if ! command -v make >/dev/null; then
|
311
|
+
log "Install make ..."
|
312
|
+
install_packages make || fail "Failed to install make!"
|
313
|
+
fi
|
314
|
+
}
|
315
|
+
|
316
|
+
#
|
317
|
+
# Installs bundler, if it's not installed.
|
318
|
+
#
|
319
|
+
function auto_install_bundler()
|
320
|
+
{
|
321
|
+
if ! command -v bundle >/dev/null; then
|
322
|
+
log "Installing bundler ..."
|
323
|
+
$gem install ${gem_opts[@]} bundler -v "$bundler_version" ||
|
324
|
+
fail "Failed to install bundler!"
|
325
|
+
elif [[ "$(bundle --version)" == "Bundler version 1."* ]]; then
|
326
|
+
log "Updating bundler 1.x to 2.x ..."
|
327
|
+
$gem update ${gem_opts[@]} bundler
|
328
|
+
fi
|
329
|
+
}
|
330
|
+
|
331
|
+
#
|
332
|
+
# Install external dependencies for ronin.
|
333
|
+
#
|
334
|
+
function install_dependencies()
|
335
|
+
{
|
336
|
+
case "$package_manager" in
|
337
|
+
dnf|yum)libraries=(readline-devel sqlite-devel nmap masscan) ;;
|
338
|
+
zypper) libraries=(readline-devel sqlite3-devel nmap masscan) ;;
|
339
|
+
apt) libraries=(libreadline-dev libsqlite3-dev nmap masscan) ;;
|
340
|
+
*) libraries=(readline sqlite nmap masscan) ;;
|
341
|
+
esac
|
342
|
+
|
343
|
+
log "Installing external dependencies ..."
|
344
|
+
install_packages "${libraries[@]}" || \
|
345
|
+
warn "Failed to install external dependencies. Proceeding anyways."
|
346
|
+
}
|
347
|
+
|
348
|
+
#
|
349
|
+
# Set the capabilities of nmap and masscan so they can be ran without root or
|
350
|
+
# sudo.
|
351
|
+
#
|
352
|
+
function set_caps()
|
353
|
+
{
|
354
|
+
if command -v setcap >/dev/null; then
|
355
|
+
local caps="cap_net_raw,cap_net_admin,cap_net_bind_service+eip"
|
356
|
+
|
357
|
+
log "Setting capabilities for nmap so it does not require sudo/root ..."
|
358
|
+
sudo setcap "$caps" "$(which nmap)"
|
359
|
+
|
360
|
+
log "Setting capabilities for masscan so it does not require sudo/root ..."
|
361
|
+
sudo setcap "$caps" "$(which masscan)"
|
362
|
+
fi
|
363
|
+
}
|
364
|
+
|
365
|
+
#
|
366
|
+
# Print the --help usage.
|
367
|
+
#
|
368
|
+
function print_usage()
|
369
|
+
{
|
370
|
+
cat <<USAGE
|
371
|
+
usage: ./scripts/setup [OPTIONS] [REPO ...]
|
372
|
+
|
373
|
+
Options:
|
374
|
+
--package-manager [apt|dnf|yum|pacman|zypper|brew|pkg|port]
|
375
|
+
Sets the package manager to use
|
376
|
+
-V, --version Prints the version
|
377
|
+
-h, --help Prints this message
|
378
|
+
|
379
|
+
USAGE
|
380
|
+
}
|
381
|
+
|
382
|
+
#
|
383
|
+
# Parse additional command-line options.
|
384
|
+
#
|
385
|
+
function parse_options()
|
386
|
+
{
|
387
|
+
local argv=()
|
388
|
+
|
389
|
+
while [[ $# -gt 0 ]]; do
|
390
|
+
case "$1" in
|
391
|
+
--package-manager)
|
392
|
+
package_manager="$2"
|
393
|
+
shift 2
|
394
|
+
;;
|
395
|
+
-V|--version)
|
396
|
+
echo "setup: $ronin_install_version"
|
397
|
+
exit
|
398
|
+
;;
|
399
|
+
-h|--help)
|
400
|
+
print_usage
|
401
|
+
exit
|
402
|
+
;;
|
403
|
+
-*)
|
404
|
+
echo "setup: unrecognized option $1" >&2
|
405
|
+
return 1
|
406
|
+
;;
|
407
|
+
*)
|
408
|
+
argv+=($1)
|
409
|
+
shift
|
410
|
+
;;
|
411
|
+
esac
|
412
|
+
done
|
413
|
+
|
414
|
+
if (( ${#argv[@]} > 0 )); then
|
415
|
+
github_repos=("${argv[@]}")
|
416
|
+
fi
|
417
|
+
}
|
418
|
+
|
419
|
+
parse_options "$@" || exit $?
|
420
|
+
detect_system
|
421
|
+
auto_install_redis
|
422
|
+
auto_install_git
|
423
|
+
auto_install_gcc
|
424
|
+
auto_install_gpp
|
425
|
+
auto_install_make
|
426
|
+
auto_install_ruby
|
427
|
+
auto_install_bundler
|
428
|
+
install_dependencies
|
429
|
+
set_caps
|
430
|
+
|
431
|
+
# default to installing gems into vendor/bundle
|
432
|
+
if [[ ! -f .bundle/config ]]; then
|
433
|
+
bundle config set --local path vendor/bundle >/dev/null || \
|
434
|
+
fail "Failed to run 'bundle config'"
|
435
|
+
fi
|
436
|
+
|
437
|
+
bundle install || fail "Failed to install gems!"
|
438
|
+
|
439
|
+
log "Setting up the project ..."
|
440
|
+
bundle exec rake setup || fail "Failed to setup project!"
|
441
|
+
|
442
|
+
log "ronin-app is now ready to be ran!"
|
443
|
+
echo
|
444
|
+
echo " $ ./scripts/server"
|
445
|
+
echo
|
446
|
+
echo "Then open http://localhost:1337 in your browser"
|
447
|
+
echo
|
data/scripts/update
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
#
|
4
|
+
# Prints a log message.
|
5
|
+
#
|
6
|
+
function log()
|
7
|
+
{
|
8
|
+
if [[ -t 1 ]]; then
|
9
|
+
echo -e "\x1b[1m\x1b[32m>>>\x1b[0m \x1b[1m$1\x1b[0m"
|
10
|
+
else
|
11
|
+
echo ">>> $1"
|
12
|
+
fi
|
13
|
+
}
|
14
|
+
|
15
|
+
#
|
16
|
+
# Prints a warn message.
|
17
|
+
#
|
18
|
+
function warn()
|
19
|
+
{
|
20
|
+
if [[ -t 1 ]]; then
|
21
|
+
echo -e "\x1b[1m\x1b[33m***\x1b[0m \x1b[1m$1\x1b[0m" >&2
|
22
|
+
else
|
23
|
+
echo "*** $1" >&2
|
24
|
+
fi
|
25
|
+
}
|
26
|
+
|
27
|
+
#
|
28
|
+
# Prints an error message.
|
29
|
+
#
|
30
|
+
function error()
|
31
|
+
{
|
32
|
+
if [[ -t 1 ]]; then
|
33
|
+
echo -e "\x1b[1m\x1b[31m!!!\x1b[0m \x1b[1m$1\x1b[0m" >&2
|
34
|
+
else
|
35
|
+
echo "!!! $1" >&2
|
36
|
+
fi
|
37
|
+
}
|
38
|
+
|
39
|
+
#
|
40
|
+
# Prints an error message and exists with -1.
|
41
|
+
#
|
42
|
+
function fail()
|
43
|
+
{
|
44
|
+
error "$@"
|
45
|
+
exit -1
|
46
|
+
}
|
47
|
+
|
48
|
+
log "Updating git repository ..."
|
49
|
+
git pull origin main || fail "Failed to update git repository!"
|
50
|
+
|
51
|
+
log "Updating gems ..."
|
52
|
+
bundle update || fail "Failed to update gems!"
|
53
|
+
|
54
|
+
log "Migrating up the database ..."
|
55
|
+
bundle exec rake db:migrate || fail "Failed to migrate the database!"
|
data/tmp/.gitkeep
ADDED
File without changes
|
data/views/_authors.erb
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
<% authors.each do |author| %>
|
2
|
+
<p>
|
3
|
+
<%=h author.name %>
|
4
|
+
|
5
|
+
<% if author.email %>
|
6
|
+
(<a href="mailto:<%=h author.email %>"><%= author.email %></a>)
|
7
|
+
<% end %>
|
8
|
+
</p>
|
9
|
+
|
10
|
+
<ul>
|
11
|
+
<% if author.website? %>
|
12
|
+
<li>
|
13
|
+
Website:
|
14
|
+
<a href="<%=h author.website %>">
|
15
|
+
<%=h author.website %>
|
16
|
+
</a>
|
17
|
+
</li>
|
18
|
+
<% end %>
|
19
|
+
|
20
|
+
<% if author.blog? %>
|
21
|
+
<li>
|
22
|
+
Blog:
|
23
|
+
<a href="<%=h author.blog %>">
|
24
|
+
<%=h author.blog %>
|
25
|
+
</a>
|
26
|
+
</li>
|
27
|
+
<% end %>
|
28
|
+
|
29
|
+
<% if author.github? %>
|
30
|
+
<li>
|
31
|
+
GitHub:
|
32
|
+
<a href="<%=h author.github_url %>">
|
33
|
+
<%=h author.github %>
|
34
|
+
</a>
|
35
|
+
</li>
|
36
|
+
<% end %>
|
37
|
+
|
38
|
+
<% if author.gitlab? %>
|
39
|
+
<li>
|
40
|
+
GitLab:
|
41
|
+
<a href="<%=h author.gitlab_url %>">
|
42
|
+
<%=h author.gitlab %>
|
43
|
+
</a>
|
44
|
+
</li>
|
45
|
+
<% end %>
|
46
|
+
|
47
|
+
<% if author.twitter? %>
|
48
|
+
<li>
|
49
|
+
Twitter:
|
50
|
+
<a href="<%=h author.twitter_url %>">
|
51
|
+
<%=h author.twitter %>
|
52
|
+
</a>
|
53
|
+
</li>
|
54
|
+
<% end %>
|
55
|
+
|
56
|
+
<% if author.discord? %>
|
57
|
+
<li>
|
58
|
+
Discord: <%=h author.discord %>
|
59
|
+
</li>
|
60
|
+
<% end %>
|
61
|
+
</ul>
|
62
|
+
<% end %>
|
data/views/_delete.erb
ADDED