ronin-vulns 0.1.5 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.ruby-version +1 -1
  4. data/ChangeLog.md +43 -0
  5. data/Gemfile +14 -4
  6. data/README.md +7 -3
  7. data/Rakefile +9 -0
  8. data/data/completions/ronin-vulns +139 -0
  9. data/gemspec.yml +7 -1
  10. data/lib/ronin/vulns/cli/command.rb +1 -1
  11. data/lib/ronin/vulns/cli/commands/command_injection.rb +163 -0
  12. data/lib/ronin/vulns/cli/commands/completion.rb +63 -0
  13. data/lib/ronin/vulns/cli/commands/irb.rb +59 -0
  14. data/lib/ronin/vulns/cli/commands/lfi.rb +21 -9
  15. data/lib/ronin/vulns/cli/commands/open_redirect.rb +13 -1
  16. data/lib/ronin/vulns/cli/commands/reflected_xss.rb +13 -1
  17. data/lib/ronin/vulns/cli/commands/rfi.rb +13 -1
  18. data/lib/ronin/vulns/cli/commands/scan.rb +21 -9
  19. data/lib/ronin/vulns/cli/commands/sqli.rb +13 -1
  20. data/lib/ronin/vulns/cli/commands/ssti.rb +13 -1
  21. data/lib/ronin/vulns/cli/importable.rb +76 -0
  22. data/lib/ronin/vulns/cli/printing.rb +184 -0
  23. data/lib/ronin/vulns/cli/ruby_shell.rb +53 -0
  24. data/lib/ronin/vulns/cli/web_vuln_command.rb +216 -20
  25. data/lib/ronin/vulns/cli.rb +5 -2
  26. data/lib/ronin/vulns/command_injection.rb +267 -0
  27. data/lib/ronin/vulns/importer.rb +116 -0
  28. data/lib/ronin/vulns/lfi/test_file.rb +1 -1
  29. data/lib/ronin/vulns/lfi.rb +1 -1
  30. data/lib/ronin/vulns/open_redirect.rb +1 -1
  31. data/lib/ronin/vulns/reflected_xss/context.rb +1 -1
  32. data/lib/ronin/vulns/reflected_xss/test_string.rb +1 -1
  33. data/lib/ronin/vulns/reflected_xss.rb +1 -1
  34. data/lib/ronin/vulns/rfi.rb +64 -9
  35. data/lib/ronin/vulns/root.rb +1 -1
  36. data/lib/ronin/vulns/sqli/error_pattern.rb +1 -1
  37. data/lib/ronin/vulns/sqli.rb +36 -28
  38. data/lib/ronin/vulns/ssti/test_expression.rb +1 -1
  39. data/lib/ronin/vulns/ssti.rb +69 -53
  40. data/lib/ronin/vulns/url_scanner.rb +10 -1
  41. data/lib/ronin/vulns/version.rb +2 -2
  42. data/lib/ronin/vulns/vuln.rb +1 -1
  43. data/lib/ronin/vulns/web_vuln/http_request.rb +40 -1
  44. data/lib/ronin/vulns/web_vuln.rb +86 -16
  45. data/man/ronin-vulns-command-injection.1 +109 -0
  46. data/man/ronin-vulns-command-injection.1.md +112 -0
  47. data/man/ronin-vulns-completion.1 +76 -0
  48. data/man/ronin-vulns-completion.1.md +78 -0
  49. data/man/ronin-vulns-irb.1 +27 -0
  50. data/man/ronin-vulns-irb.1.md +26 -0
  51. data/man/ronin-vulns-lfi.1 +54 -51
  52. data/man/ronin-vulns-lfi.1.md +52 -20
  53. data/man/ronin-vulns-open-redirect.1 +51 -47
  54. data/man/ronin-vulns-open-redirect.1.md +50 -18
  55. data/man/ronin-vulns-reflected-xss.1 +50 -45
  56. data/man/ronin-vulns-reflected-xss.1.md +49 -17
  57. data/man/ronin-vulns-rfi.1 +54 -52
  58. data/man/ronin-vulns-rfi.1.md +52 -20
  59. data/man/ronin-vulns-scan.1 +68 -69
  60. data/man/ronin-vulns-scan.1.md +61 -29
  61. data/man/ronin-vulns-sqli.1 +54 -52
  62. data/man/ronin-vulns-sqli.1.md +52 -20
  63. data/man/ronin-vulns-ssti.1 +52 -48
  64. data/man/ronin-vulns-ssti.1.md +50 -18
  65. data/man/ronin-vulns.1 +73 -0
  66. data/man/ronin-vulns.1.md +69 -0
  67. data/scripts/setup +58 -0
  68. metadata +37 -6
  69. data/lib/ronin/vulns/cli/logging.rb +0 -81
@@ -2,7 +2,7 @@
2
2
  #
3
3
  # ronin-vulns - A Ruby library for blind vulnerability testing.
4
4
  #
5
- # Copyright (c) 2022-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
5
+ # Copyright (c) 2022-2024 Hal Brodigan (postmodern.mod3 at gmail.com)
6
6
  #
7
7
  # ronin-vulns is free software: you can redistribute it and/or modify
8
8
  # it under the terms of the GNU Lesser General Public License as published
@@ -34,9 +34,20 @@ module Ronin
34
34
  #
35
35
  # ## Options
36
36
  #
37
+ # --db NAME The database to connect to (Default: default)
38
+ # --db-uri URI The database URI to connect to
39
+ # --db-file PATH The sqlite3 database file to use
40
+ # --import Imports discovered vulnerabilities into the database
37
41
  # --first Only find the first vulnerability for each URL
38
42
  # -A, --all Find all vulnerabilities for each URL
43
+ # --print-curl Also prints an example curl command for each vulnerability
44
+ # --print-http Also prints an example HTTP request for each vulnerability
45
+ # -M COPY|DELETE|GET|HEAD|LOCK|MKCOL|MOVE|OPTIONS|PATCH|POST|PROPFIND|PROPPATCH|PUT|TRACE|UNLOCK,
46
+ # --request-method The HTTP request method to use
39
47
  # -H, --header "Name: value" Sets an additional header
48
+ # -U, --user-agent-string STRING Sets the User-Agent header
49
+ # -u chrome-linux|chrome-macos|chrome-windows|chrome-iphone|chrome-ipad|chrome-android|firefox-linux|firefox-macos|firefox-windows|firefox-iphone|firefox-ipad|firefox-android|safari-macos|safari-iphone|safari-ipad|edge,
50
+ # --user-agent Sets the User-Agent to use
40
51
  # -C, --cookie COOKIE Sets the raw Cookie header
41
52
  # -c, --cookie-param NAME=VALUE Sets an additional cookie param
42
53
  # -R, --referer URL Sets the Referer header
@@ -47,10 +58,11 @@ module Ronin
47
58
  # --test-cookie-param NAME Tests the HTTP Cookie name
48
59
  # --test-all-cookie-params Test all Cookie param names
49
60
  # --test-form-param NAME Tests the form param name
61
+ # --test-all-form-params Test all form param names
50
62
  # -i, --input FILE Reads URLs from the list file
51
63
  # -O, --os unix|windows Sets the OS to test for
52
64
  # -D, --depth COUNT Sets the directory depth to escape up
53
- # -B null_byte|double_escape|base64|rot13|zlib,
65
+ # -B null-byte|double-escape|base64|rot13|zlib,
54
66
  # --filter-bypass Sets the filter bypass strategy to use
55
67
  # -h, --help Print help information
56
68
  #
@@ -81,13 +93,13 @@ module Ronin
81
93
 
82
94
  option :filter_bypass, short: '-B',
83
95
  value: {
84
- type: [
85
- :null_byte,
86
- :double_escape,
87
- :base64,
88
- :rot13,
89
- :zlib
90
- ]
96
+ type: {
97
+ 'null-byte' => :null_byte,
98
+ 'double-escape' => :double_escape,
99
+ 'base64' => :base64,
100
+ 'rot13' => :rot13,
101
+ 'zlib' => :zlib
102
+ }
91
103
  },
92
104
  desc: 'Sets the filter bypass strategy to use' do |filter_bypass|
93
105
  scan_kwargs[:filter_bypass] = filter_bypass
@@ -2,7 +2,7 @@
2
2
  #
3
3
  # ronin-vulns - A Ruby library for blind vulnerability testing.
4
4
  #
5
- # Copyright (c) 2022-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
5
+ # Copyright (c) 2022-2024 Hal Brodigan (postmodern.mod3 at gmail.com)
6
6
  #
7
7
  # ronin-vulns is free software: you can redistribute it and/or modify
8
8
  # it under the terms of the GNU Lesser General Public License as published
@@ -34,9 +34,20 @@ module Ronin
34
34
  #
35
35
  # ## Options
36
36
  #
37
+ # --db NAME The database to connect to (Default: default)
38
+ # --db-uri URI The database URI to connect to
39
+ # --db-file PATH The sqlite3 database file to use
40
+ # --import Imports discovered vulnerabilities into the database
37
41
  # --first Only find the first vulnerability for each URL
38
42
  # -A, --all Find all vulnerabilities for each URL
43
+ # --print-curl Also prints an example curl command for each vulnerability
44
+ # --print-http Also prints an example HTTP request for each vulnerability
45
+ # -M COPY|DELETE|GET|HEAD|LOCK|MKCOL|MOVE|OPTIONS|PATCH|POST|PROPFIND|PROPPATCH|PUT|TRACE|UNLOCK,
46
+ # --request-method The HTTP request method to use
39
47
  # -H, --header "Name: value" Sets an additional header
48
+ # -U, --user-agent-string STRING Sets the User-Agent header
49
+ # -u chrome-linux|chrome-macos|chrome-windows|chrome-iphone|chrome-ipad|chrome-android|firefox-linux|firefox-macos|firefox-windows|firefox-iphone|firefox-ipad|firefox-android|safari-macos|safari-iphone|safari-ipad|edge,
50
+ # --user-agent Sets the User-Agent to use
40
51
  # -C, --cookie COOKIE Sets the raw Cookie header
41
52
  # -c, --cookie-param NAME=VALUE Sets an additional cookie param
42
53
  # -R, --referer URL Sets the Referer header
@@ -47,6 +58,7 @@ module Ronin
47
58
  # --test-cookie-param NAME Tests the HTTP Cookie name
48
59
  # --test-all-cookie-params Test all Cookie param names
49
60
  # --test-form-param NAME Tests the form param name
61
+ # --test-all-form-params Test all form param names
50
62
  # -i, --input FILE Reads URLs from the list file
51
63
  # -T, --test-url URL Optional test URL to try to redirect to
52
64
  # -h, --help Print help information
@@ -2,7 +2,7 @@
2
2
  #
3
3
  # ronin-vulns - A Ruby library for blind vulnerability testing.
4
4
  #
5
- # Copyright (c) 2022-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
5
+ # Copyright (c) 2022-2024 Hal Brodigan (postmodern.mod3 at gmail.com)
6
6
  #
7
7
  # ronin-vulns is free software: you can redistribute it and/or modify
8
8
  # it under the terms of the GNU Lesser General Public License as published
@@ -34,9 +34,20 @@ module Ronin
34
34
  #
35
35
  # ## Options
36
36
  #
37
+ # --db NAME The database to connect to (Default: default)
38
+ # --db-uri URI The database URI to connect to
39
+ # --db-file PATH The sqlite3 database file to use
40
+ # --import Imports discovered vulnerabilities into the database
37
41
  # --first Only find the first vulnerability for each URL
38
42
  # -A, --all Find all vulnerabilities for each URL
43
+ # --print-curl Also prints an example curl command for each vulnerability
44
+ # --print-http Also prints an example HTTP request for each vulnerability
45
+ # -M COPY|DELETE|GET|HEAD|LOCK|MKCOL|MOVE|OPTIONS|PATCH|POST|PROPFIND|PROPPATCH|PUT|TRACE|UNLOCK,
46
+ # --request-method The HTTP request method to use
39
47
  # -H, --header "Name: value" Sets an additional header
48
+ # -U, --user-agent-string STRING Sets the User-Agent header
49
+ # -u chrome-linux|chrome-macos|chrome-windows|chrome-iphone|chrome-ipad|chrome-android|firefox-linux|firefox-macos|firefox-windows|firefox-iphone|firefox-ipad|firefox-android|safari-macos|safari-iphone|safari-ipad|edge,
50
+ # --user-agent Sets the User-Agent to use
40
51
  # -C, --cookie COOKIE Sets the raw Cookie header
41
52
  # -c, --cookie-param NAME=VALUE Sets an additional cookie param
42
53
  # -R, --referer URL Sets the Referer header
@@ -47,6 +58,7 @@ module Ronin
47
58
  # --test-cookie-param NAME Tests the HTTP Cookie name
48
59
  # --test-all-cookie-params Test all Cookie param names
49
60
  # --test-form-param NAME Tests the form param name
61
+ # --test-all-form-params Test all form param names
50
62
  # -i, --input FILE Reads URLs from the list file
51
63
  # -h, --help Print help information
52
64
  #
@@ -2,7 +2,7 @@
2
2
  #
3
3
  # ronin-vulns - A Ruby library for blind vulnerability testing.
4
4
  #
5
- # Copyright (c) 2022-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
5
+ # Copyright (c) 2022-2024 Hal Brodigan (postmodern.mod3 at gmail.com)
6
6
  #
7
7
  # ronin-vulns is free software: you can redistribute it and/or modify
8
8
  # it under the terms of the GNU Lesser General Public License as published
@@ -34,9 +34,20 @@ module Ronin
34
34
  #
35
35
  # ## Options
36
36
  #
37
+ # --db NAME The database to connect to (Default: default)
38
+ # --db-uri URI The database URI to connect to
39
+ # --db-file PATH The sqlite3 database file to use
40
+ # --import Imports discovered vulnerabilities into the database
37
41
  # --first Only find the first vulnerability for each URL
38
42
  # -A, --all Find all vulnerabilities for each URL
43
+ # --print-curl Also prints an example curl command for each vulnerability
44
+ # --print-http Also prints an example HTTP request for each vulnerability
45
+ # -M COPY|DELETE|GET|HEAD|LOCK|MKCOL|MOVE|OPTIONS|PATCH|POST|PROPFIND|PROPPATCH|PUT|TRACE|UNLOCK,
46
+ # --request-method The HTTP request method to use
39
47
  # -H, --header "Name: value" Sets an additional header
48
+ # -U, --user-agent-string STRING Sets the User-Agent header
49
+ # -u chrome-linux|chrome-macos|chrome-windows|chrome-iphone|chrome-ipad|chrome-android|firefox-linux|firefox-macos|firefox-windows|firefox-iphone|firefox-ipad|firefox-android|safari-macos|safari-iphone|safari-ipad|edge,
50
+ # --user-agent Sets the User-Agent to use
40
51
  # -C, --cookie COOKIE Sets the raw Cookie header
41
52
  # -c, --cookie-param NAME=VALUE Sets an additional cookie param
42
53
  # -R, --referer URL Sets the Referer header
@@ -47,6 +58,7 @@ module Ronin
47
58
  # --test-cookie-param NAME Tests the HTTP Cookie name
48
59
  # --test-all-cookie-params Test all Cookie param names
49
60
  # --test-form-param NAME Tests the form param name
61
+ # --test-all-form-params Test all form param names
50
62
  # -i, --input FILE Reads URLs from the list file
51
63
  # -B double-encode|suffix-escape|null-byte,
52
64
  # --filter-bypass Optional filter-bypass strategy to use
@@ -2,7 +2,7 @@
2
2
  #
3
3
  # ronin-vulns - A Ruby library for blind vulnerability testing.
4
4
  #
5
- # Copyright (c) 2022-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
5
+ # Copyright (c) 2022-2024 Hal Brodigan (postmodern.mod3 at gmail.com)
6
6
  #
7
7
  # ronin-vulns is free software: you can redistribute it and/or modify
8
8
  # it under the terms of the GNU Lesser General Public License as published
@@ -34,9 +34,20 @@ module Ronin
34
34
  #
35
35
  # ## Options
36
36
  #
37
+ # --db NAME The database to connect to (Default: default)
38
+ # --db-uri URI The database URI to connect to
39
+ # --db-file PATH The sqlite3 database file to use
40
+ # --import Imports discovered vulnerabilities into the database
37
41
  # --first Only find the first vulnerability for each URL
38
42
  # -A, --all Find all vulnerabilities for each URL
43
+ # --print-curl Also prints an example curl command for each vulnerability
44
+ # --print-http Also prints an example HTTP request for each vulnerability
45
+ # -M COPY|DELETE|GET|HEAD|LOCK|MKCOL|MOVE|OPTIONS|PATCH|POST|PROPFIND|PROPPATCH|PUT|TRACE|UNLOCK,
46
+ # --request-method The HTTP request method to use
39
47
  # -H, --header "Name: value" Sets an additional header
48
+ # -U, --user-agent-string STRING Sets the User-Agent header
49
+ # -u chrome-linux|chrome-macos|chrome-windows|chrome-iphone|chrome-ipad|chrome-android|firefox-linux|firefox-macos|firefox-windows|firefox-iphone|firefox-ipad|firefox-android|safari-macos|safari-iphone|safari-ipad|edge,
50
+ # --user-agent Sets the User-Agent to use
40
51
  # -C, --cookie COOKIE Sets the raw Cookie header
41
52
  # -c, --cookie-param NAME=VALUE Sets an additional cookie param
42
53
  # -R, --referer URL Sets the Referer header
@@ -45,10 +56,11 @@ module Ronin
45
56
  # --test-header-names NAME Tests the HTTP Header name
46
57
  # --test-cookie-params NAME Tests the HTTP Cookie name
47
58
  # --test-form-params NAME Tests the form param name
59
+ # --test-all-form-params Test all form param names
48
60
  # -i, --input FILE Reads URLs from the list file
49
61
  # --lfi-os unix|windows Sets the OS to test for
50
62
  # --lfi-depth COUNT Sets the directory depth to escape up
51
- # --lfi-filter-bypass null_byte|double_escape|base64|rot13|zlib
63
+ # --lfi-filter-bypass null-byte|double-escape|base64|rot13|zlib
52
64
  # Sets the filter bypass strategy to use
53
65
  # --rfi-filter-bypass double-encode|suffix-escape|null-byte
54
66
  # Optional filter-bypass strategy to use
@@ -87,13 +99,13 @@ module Ronin
87
99
  end
88
100
 
89
101
  option :lfi_filter_bypass, value: {
90
- type: [
91
- :null_byte,
92
- :double_escape,
93
- :base64,
94
- :rot13,
95
- :zlib
96
- ]
102
+ type: {
103
+ 'null-byte' => :null_byte,
104
+ 'double-escape' => :double_escape,
105
+ 'base64' => :base64,
106
+ 'rot13' => :rot13,
107
+ 'zlib' => :zlib
108
+ }
97
109
  },
98
110
  desc: 'Sets the filter bypass strategy to use' do |filter_bypass|
99
111
  lfi_kwargs[:filter_bypass] = filter_bypass
@@ -2,7 +2,7 @@
2
2
  #
3
3
  # ronin-vulns - A Ruby library for blind vulnerability testing.
4
4
  #
5
- # Copyright (c) 2022-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
5
+ # Copyright (c) 2022-2024 Hal Brodigan (postmodern.mod3 at gmail.com)
6
6
  #
7
7
  # ronin-vulns is free software: you can redistribute it and/or modify
8
8
  # it under the terms of the GNU Lesser General Public License as published
@@ -34,9 +34,20 @@ module Ronin
34
34
  #
35
35
  # ## Options
36
36
  #
37
+ # --db NAME The database to connect to (Default: default)
38
+ # --db-uri URI The database URI to connect to
39
+ # --db-file PATH The sqlite3 database file to use
40
+ # --import Imports discovered vulnerabilities into the database
37
41
  # --first Only find the first vulnerability for each URL
38
42
  # -A, --all Find all vulnerabilities for each URL
43
+ # --print-curl Also prints an example curl command for each vulnerability
44
+ # --print-http Also prints an example HTTP request for each vulnerability
45
+ # -M COPY|DELETE|GET|HEAD|LOCK|MKCOL|MOVE|OPTIONS|PATCH|POST|PROPFIND|PROPPATCH|PUT|TRACE|UNLOCK,
46
+ # --request-method The HTTP request method to use
39
47
  # -H, --header "Name: value" Sets an additional header
48
+ # -U, --user-agent-string STRING Sets the User-Agent header
49
+ # -u chrome-linux|chrome-macos|chrome-windows|chrome-iphone|chrome-ipad|chrome-android|firefox-linux|firefox-macos|firefox-windows|firefox-iphone|firefox-ipad|firefox-android|safari-macos|safari-iphone|safari-ipad|edge,
50
+ # --user-agent Sets the User-Agent to use
40
51
  # -C, --cookie COOKIE Sets the raw Cookie header
41
52
  # -c, --cookie-param NAME=VALUE Sets an additional cookie param
42
53
  # -R, --referer URL Sets the Referer header
@@ -47,6 +58,7 @@ module Ronin
47
58
  # --test-cookie-param NAME Tests the HTTP Cookie name
48
59
  # --test-all-cookie-params Test all Cookie param names
49
60
  # --test-form-param NAME Tests the form param name
61
+ # --test-all-form-params Test all form param names
50
62
  # -i, --input FILE Reads URLs from the list file
51
63
  # -Q, --escape-quote Escapes quotation marks
52
64
  # -P, --escape-parens Escapes parenthesis
@@ -2,7 +2,7 @@
2
2
  #
3
3
  # ronin-vulns - A Ruby library for blind vulnerability testing.
4
4
  #
5
- # Copyright (c) 2022-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
5
+ # Copyright (c) 2022-2024 Hal Brodigan (postmodern.mod3 at gmail.com)
6
6
  #
7
7
  # ronin-vulns is free software: you can redistribute it and/or modify
8
8
  # it under the terms of the GNU Lesser General Public License as published
@@ -35,9 +35,20 @@ module Ronin
35
35
  #
36
36
  # ## Options
37
37
  #
38
+ # --db NAME The database to connect to (Default: default)
39
+ # --db-uri URI The database URI to connect to
40
+ # --db-file PATH The sqlite3 database file to use
41
+ # --import Imports discovered vulnerabilities into the database
38
42
  # --first Only find the first vulnerability for each URL
39
43
  # -A, --all Find all vulnerabilities for each URL
44
+ # --print-curl Also prints an example curl command for each vulnerability
45
+ # --print-http Also prints an example HTTP request for each vulnerability
46
+ # -M COPY|DELETE|GET|HEAD|LOCK|MKCOL|MOVE|OPTIONS|PATCH|POST|PROPFIND|PROPPATCH|PUT|TRACE|UNLOCK,
47
+ # --request-method The HTTP request method to use
40
48
  # -H, --header "Name: value" Sets an additional header
49
+ # -U, --user-agent-string STRING Sets the User-Agent header
50
+ # -u chrome-linux|chrome-macos|chrome-windows|chrome-iphone|chrome-ipad|chrome-android|firefox-linux|firefox-macos|firefox-windows|firefox-iphone|firefox-ipad|firefox-android|safari-macos|safari-iphone|safari-ipad|edge,
51
+ # --user-agent Sets the User-Agent to use
41
52
  # -C, --cookie COOKIE Sets the raw Cookie header
42
53
  # -c, --cookie-param NAME=VALUE Sets an additional cookie param
43
54
  # -R, --referer URL Sets the Referer header
@@ -48,6 +59,7 @@ module Ronin
48
59
  # --test-cookie-param NAME Tests the HTTP Cookie name
49
60
  # --test-all-cookie-params Test all Cookie param names
50
61
  # --test-form-param NAME Tests the form param name
62
+ # --test-all-form-params Test all form param names
51
63
  # -i, --input FILE Reads URLs from the list file
52
64
  # -T {X*Y | X/Z | X+Y | X-Y}, Optional numeric test to use
53
65
  # --test-expr
@@ -0,0 +1,76 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # ronin-vulns - A Ruby library for blind vulnerability testing.
4
+ #
5
+ # Copyright (c) 2022-2024 Hal Brodigan (postmodern.mod3 at gmail.com)
6
+ #
7
+ # ronin-vulns is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU Lesser General Public License as published
9
+ # by the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # ronin-vulns is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU Lesser General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU Lesser General Public License
18
+ # along with ronin-vulns. If not, see <https://www.gnu.org/licenses/>.
19
+ #
20
+
21
+ require 'ronin/vulns/importer'
22
+ require 'ronin/vulns/cli/printing'
23
+ require 'ronin/db/cli/database_options'
24
+ require 'ronin/db/cli/printing'
25
+
26
+ module Ronin
27
+ module Vulns
28
+ class CLI
29
+ #
30
+ # Mixin module which adds the ability to import web vulns into the
31
+ # [ronin-db] database.
32
+ #
33
+ # [ronin-db]: https://github.com/ronin-rb/ronin-db#readme
34
+ #
35
+ # @since 0.2.0
36
+ #
37
+ module Importable
38
+ include DB::CLI::Printing
39
+ include Printing
40
+
41
+ #
42
+ # Includes `Ronin::DB::CLI::DatabaseOptions` into the including command
43
+ # class.
44
+ #
45
+ # @param [Class<Command>] command
46
+ # The command class including {Importable}.
47
+ #
48
+ def self.included(command)
49
+ command.include DB::CLI::DatabaseOptions
50
+ end
51
+
52
+ #
53
+ # Imports a web vulnerability into the [ronin-db] database.
54
+ #
55
+ # [ronin-db]: https://github.com/ronin-rb/ronin-db#readme
56
+ #
57
+ # @param [WebVuln] vuln
58
+ # The web vulnerability to import.
59
+ #
60
+ def import_vuln(vuln)
61
+ Importer.import(vuln)
62
+
63
+ vuln_type = vuln_type(vuln)
64
+ param_type = vuln_param_type(vuln)
65
+ param_name = vuln_param_name(vuln)
66
+
67
+ if (param_type && param_name)
68
+ log_info "Imported #{vuln_type} vulnerability on URL #{vuln.url} and #{param_type} '#{param_name}'"
69
+ else
70
+ log_info "Imported #{vuln_type} vulnerability on URL #{vuln.url}"
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,184 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # ronin-vulns - A Ruby library for blind vulnerability testing.
4
+ #
5
+ # Copyright (c) 2022-2024 Hal Brodigan (postmodern.mod3 at gmail.com)
6
+ #
7
+ # ronin-vulns is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU Lesser General Public License as published
9
+ # by the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # ronin-vulns is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU Lesser General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU Lesser General Public License
18
+ # along with ronin-vulns. If not, see <https://www.gnu.org/licenses/>.
19
+ #
20
+
21
+ require 'ronin/core/cli/logging'
22
+
23
+ require 'command_kit/printing/indent'
24
+
25
+ module Ronin
26
+ module Vulns
27
+ class CLI
28
+ #
29
+ # Mixin that adds methods for logging and printing discovered web
30
+ # vulnerabilities.
31
+ #
32
+ # @since 0.2.0
33
+ #
34
+ module Printing
35
+ include Core::CLI::Logging
36
+ include CommandKit::Printing::Indent
37
+
38
+ # Known vulnerability types and their printable names.
39
+ VULN_TYPES = {
40
+ command_injection: 'Command Injection',
41
+ open_redirect: 'Open Redirect',
42
+ reflected_xss: 'reflected XSS',
43
+
44
+ lfi: 'LFI',
45
+ rfi: 'RFI',
46
+ sqli: 'SQLi',
47
+ ssti: 'SSTI'
48
+ }
49
+
50
+ #
51
+ # Returns the printable vulnerability type for the vulnerability object.
52
+ #
53
+ # @param [Vuln] vuln
54
+ #
55
+ # @return [String]
56
+ #
57
+ def vuln_type(vuln)
58
+ VULN_TYPES.fetch(vuln.class.vuln_type)
59
+ end
60
+
61
+ #
62
+ # Determines the param type that the web vulnerability occurs in.
63
+ #
64
+ # @param [WebVuln] vuln
65
+ #
66
+ # @return [String, nil]
67
+ #
68
+ def vuln_param_type(vuln)
69
+ if vuln.query_param then 'query param'
70
+ elsif vuln.header_name then 'Header'
71
+ elsif vuln.cookie_param then 'Cookie param'
72
+ elsif vuln.form_param then 'form param'
73
+ end
74
+ end
75
+
76
+ #
77
+ # Determines the param name that the web vulnerability occurs in.
78
+ #
79
+ # @param [WebVuln] vuln
80
+ #
81
+ # @return [String, nil]
82
+ #
83
+ def vuln_param_name(vuln)
84
+ if vuln.query_param then vuln.query_param
85
+ elsif vuln.header_name then vuln.header_name
86
+ elsif vuln.cookie_param then vuln.cookie_param
87
+ elsif vuln.form_param then vuln.form_param
88
+ end
89
+ end
90
+
91
+ #
92
+ # Prints a log message about a newly discovered web vulnerability.
93
+ #
94
+ # @param [WebVuln] vuln
95
+ # The web vulnerability to log.
96
+ #
97
+ def log_vuln(vuln)
98
+ vuln_type = vuln_type(vuln)
99
+ param_type = vuln_param_type(vuln)
100
+ param_name = vuln_param_name(vuln)
101
+
102
+ if (param_type && param_name)
103
+ log_warn "Found #{vuln_type} on #{vuln.url} via #{param_type} '#{param_name}'!"
104
+ else
105
+ log_warn "Found #{vuln_type} on #{vuln.url}!"
106
+ end
107
+ end
108
+
109
+ #
110
+ # Prints detailed information about a discovered web vulnerability.
111
+ #
112
+ # @param [WebVuln] vuln
113
+ # The web vulnerability to log.
114
+ #
115
+ # @param [Boolean] print_curl
116
+ # Prints an example `curl` command to trigger the web vulnerability.
117
+ #
118
+ # @param [Boolean] print_http
119
+ # Prints an example HTTP request to trigger the web vulnerability.
120
+ #
121
+ # @since 0.2.0
122
+ #
123
+ def print_vuln(vuln, print_curl: false, print_http: false)
124
+ vuln_type = vuln_type(vuln)
125
+ param_type = vuln_param_type(vuln)
126
+ param_name = vuln_param_name(vuln)
127
+
128
+ if (param_type && param_name)
129
+ puts "#{colors.bold(colors.bright_red(vuln_type))} on #{colors.bold(colors.bright_white(vuln.url))} via #{colors.bold(colors.bright_white(param_type))} '#{colors.bold(colors.bright_red(param_name))}'"
130
+ else
131
+ puts "#{colors.bold(colors.red(vuln_type))} on #{colors.bold(colors.bright_white(vuln.url))}"
132
+ end
133
+
134
+ if print_curl || print_http
135
+ puts
136
+
137
+ if print_curl
138
+ puts " #{vuln.to_curl}"
139
+ puts
140
+ end
141
+
142
+ if print_http
143
+ vuln.to_http.each_line(chomp: true) do |line|
144
+ puts " #{line}"
145
+ end
146
+ puts
147
+ end
148
+ end
149
+ end
150
+
151
+ #
152
+ # Print a summary of all web vulnerabilities found.
153
+ #
154
+ # @param [Array<WebVuln>] vulns
155
+ # The discovered web vulnerabilities.
156
+ #
157
+ # @param [Boolean] print_curl
158
+ # Prints an example `curl` command to trigger the web vulnerability.
159
+ #
160
+ # @param [Boolean] print_http
161
+ # Prints an example HTTP request to trigger the web vulnerability.
162
+ #
163
+ # @since 0.2.0
164
+ #
165
+ def print_vulns(vulns, print_curl: false, print_http: false)
166
+ if vulns.empty?
167
+ puts colors.green("No vulnerabilities found")
168
+ else
169
+ puts colors.bold(colors.bright_red('Vulnerabilities found!'))
170
+ puts
171
+
172
+ indent do
173
+ vulns.each do |vuln|
174
+ print_vuln(vuln, print_curl: print_curl,
175
+ print_http: print_http)
176
+ end
177
+ end
178
+ puts unless (print_curl || print_http)
179
+ end
180
+ end
181
+ end
182
+ end
183
+ end
184
+ end
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # ronin-vulns - A Ruby library for blind vulnerability testing.
4
+ #
5
+ # Copyright (c) 2022-2024 Hal Brodigan (postmodern.mod3 at gmail.com)
6
+ #
7
+ # ronin-vulns is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU Lesser General Public License as published
9
+ # by the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # ronin-vulns is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU Lesser General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU Lesser General Public License
18
+ # along with ronin-vulns. If not, see <https://www.gnu.org/licenses/>.
19
+ #
20
+
21
+ require 'ronin/core/cli/ruby_shell'
22
+
23
+ module Ronin
24
+ module Vulns
25
+ class CLI
26
+ #
27
+ # The interactive Ruby shell for {Ronin::Vulns}.
28
+ #
29
+ # @since 0.2.0
30
+ #
31
+ class RubyShell < Core::CLI::RubyShell
32
+
33
+ #
34
+ # Initializes the `ronin-vulns` Ruby shell.
35
+ #
36
+ # @param [String] name
37
+ # The name of the IRB shell.
38
+ #
39
+ # @param [Object] context
40
+ # Custom context to launch IRB from within.
41
+ #
42
+ # @param [Hash{Symbol => Object}] kwargs
43
+ # Additional keyword arguments for
44
+ # `Ronin::Core::CLI::RubyShell#initialize`.
45
+ #
46
+ def initialize(name: 'ronin-vulns', context: Vulns, **kwargs)
47
+ super(name: name, context: context, **kwargs)
48
+ end
49
+
50
+ end
51
+ end
52
+ end
53
+ end