ronin-web-server 0.1.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: b03a351e55978cace7f0c7685913b2eb69f76043d959f25fa221ac5e30fc7737
4
+ data.tar.gz: f1de79f2bb53bd318ad517fc44eb36352b73532de58c32653d4da70c01832d4a
5
+ SHA512:
6
+ metadata.gz: 310070fa76735edb7f01daf99185a8a384aff900e05bd92d9290a35285e7379e18e70ad86130090e383bae21d18888b47ecdd4a6296b976f62c59288dffb8fd1
7
+ data.tar.gz: 07dd136fa10a1fa6971b4fae96c3cf56f19e0a65a8cbc13f2a246d358e7f3642f0cdf0271251b0252e4e28147c3ac4e6c982c1c3d9a46be57778fbee291241c2
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ -
3
+ ChangeLog.md
4
+ COPYING.txt
5
+ man/*.md
@@ -0,0 +1,41 @@
1
+ name: CI
2
+
3
+ on: [ push, pull_request ]
4
+
5
+ jobs:
6
+ tests:
7
+ runs-on: ubuntu-latest
8
+ strategy:
9
+ fail-fast: false
10
+ matrix:
11
+ ruby:
12
+ - '3.0'
13
+ - '3.1'
14
+ - '3.2'
15
+ - jruby
16
+ - truffleruby
17
+ name: Ruby ${{ matrix.ruby }}
18
+ steps:
19
+ - uses: actions/checkout@v2
20
+ - name: Set up Ruby
21
+ uses: ruby/setup-ruby@v1
22
+ with:
23
+ ruby-version: ${{ matrix.ruby }}
24
+ - name: Install dependencies
25
+ run: bundle install --jobs 4 --retry 3
26
+ - name: Run tests
27
+ run: bundle exec rake test
28
+
29
+ # rubocop linting
30
+ rubocop:
31
+ runs-on: ubuntu-latest
32
+ steps:
33
+ - uses: actions/checkout@v2
34
+ - name: Set up Ruby
35
+ uses: ruby/setup-ruby@v1
36
+ with:
37
+ ruby-version: 3.0
38
+ - name: Install dependencies
39
+ run: bundle install --jobs 4 --retry 3
40
+ - name: Run rubocop
41
+ run: bundle exec rubocop --parallel
data/.gitignore ADDED
@@ -0,0 +1,13 @@
1
+ /coverage
2
+ /doc
3
+ /pkg
4
+ /man/*.[1-9]
5
+ /vendor/bundle
6
+ /Gemfile.lock
7
+ /.bundle
8
+ /.yardoc
9
+ .DS_Store
10
+ *.db
11
+ *.log
12
+ *.swp
13
+ *~
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --colour --format documentation
data/.rubocop.yml ADDED
@@ -0,0 +1,154 @@
1
+ AllCops:
2
+ NewCops: enable
3
+ SuggestExtensions: false
4
+ TargetRubyVersion: 3.1
5
+
6
+ #
7
+ # our rules
8
+ #
9
+
10
+ Layout/FirstArrayElementIndentation: { Exclude: ['spec/**/*'] }
11
+ Layout/LineLength: { Enabled: false }
12
+ Layout/SpaceAroundEqualsInParameterDefault: { EnforcedStyle: no_space }
13
+ Lint/ConstantDefinitionInBlock: { Exclude: ['spec/**/*'] }
14
+ Metrics: { Enabled: false }
15
+ Style/SymbolArray: { EnforcedStyle: brackets }
16
+ Style/IfInsideElse: { Enabled: false } # Offense count: 1
17
+ Style/PercentLiteralDelimiters:
18
+ Enabled: true
19
+ PreferredDelimiters:
20
+ default: '{}'
21
+ '%i': '[]'
22
+ '%I': '[]'
23
+ '%w': '[]'
24
+ '%W': '[]'
25
+ Style/UnlessElse: { Enabled: false }
26
+ Bundler/OrderedGems: { Enabled: false }
27
+ Style/CaseEquality: { Exclude: ['lib/ronin/web/server/conditions.rb'] }
28
+ Style/Next: { Enabled: false }
29
+ Style/HashSyntax: { Enabled: false }
30
+ Naming/BlockForwarding: { Enabled: false }
31
+ Lint/ReturnInVoidContext: { Enabled: false }
32
+ Gemspec/DeprecatedAttributeAssignment: { Enabled: false }
33
+ Layout/EmptyLineAfterMagicComment: { Enabled: false }
34
+
35
+ #
36
+ # rules that are in flux
37
+ #
38
+
39
+ # consider enabling these and autocorrecting?
40
+ # Layout/SpaceAfterComma
41
+ # Layout/SpaceAroundKeyword
42
+ # Layout/SpaceBeforeComma
43
+ # Layout/SpaceInsideHashLiteralBraces
44
+ # Layout/SpaceInsideParens
45
+ # Layout/TrailingWhitespace
46
+ # Lint/UnreachableLoop
47
+ # Lint/UnusedBlockArgument
48
+ # Style/ClassCheck
49
+ # Style/Documentation
50
+ # Style/ExpandPathArguments
51
+ # Style/GlobalStdStream
52
+ # Style/HashSyntax
53
+ # Style/KeywordParametersOrder
54
+ # Style/MethodCallWithoutArgsParentheses
55
+ # Style/MutableConstant
56
+ # Style/QuotedSymbols: { EnforcedStyle: double_quotes }
57
+ # Style/RedundantReturn
58
+ # Style/SafeNavigation
59
+ # Style/SpecialGlobalVars
60
+ # Style/StringLiterals: { EnforcedStyle: double_quotes }
61
+ # Style/WordArray
62
+
63
+ # these have been fixed
64
+ # Gemspec/DuplicatedAssignment: { Enabled: false } # Offense count: 1
65
+ # Layout/ElseAlignment: { Enabled: false } # Offense count: 1
66
+ # Layout/EndAlignment: { Enabled: false } # Offense count: 1
67
+ # Lint/DuplicateMethods: { Enabled: false } # Offense count: 1
68
+ # Lint/UselessAssignment: { Enabled: false } # Offense count: 1
69
+ # Style/Encoding: { Enabled: false } # Offense count: 2
70
+ # Style/RedundantBegin: { Enabled: false } # Offense count: 2
71
+ # Style/RedundantInterpolation: { Enabled: false } # Offense count: 1
72
+ # Style/TrailingCommaInArrayLiteral: { Enabled: false } # Offense count: 1
73
+
74
+ #
75
+ # This list was generated with:
76
+ # bundle exec rubocop --auto-gen-config --exclude-limit 1
77
+ #
78
+
79
+ # > 10 violations
80
+ Layout/AssignmentIndentation: { Enabled: false } # Offense count: 11
81
+ Layout/EmptyLinesAroundClassBody: { Enabled: false } # Offense count: 76
82
+ Layout/HashAlignment: { Enabled: false } # Offense count: 28
83
+ Layout/SpaceAfterComma: { Enabled: false } # Offense count: 141
84
+ Layout/SpaceInsideHashLiteralBraces: { Enabled: false } # Offense count: 57
85
+ Layout/TrailingWhitespace: { Enabled: false } # Offense count: 50
86
+ Naming/RescuedExceptionsVariableName: { Enabled: false } # Offense count: 11
87
+ Style/BlockDelimiters: { Enabled: false } # Offense count: 17
88
+ Style/ClassCheck: { Enabled: false } # Offense count: 10
89
+ Style/ClassEqualityComparison: { Enabled: false } # Offense count: 16
90
+ Style/FrozenStringLiteralComment: { Enabled: false } # Offense count: 77
91
+ Style/GlobalStdStream: { Enabled: false } # Offense count: 13
92
+ Style/GuardClause: { Enabled: false } # Offense count: 10
93
+ Style/IfUnlessModifier: { Enabled: false } # Offense count: 13
94
+ Style/MethodCallWithoutArgsParentheses: { Enabled: false } # Offense count: 10
95
+ Style/SpecialGlobalVars: { Enabled: false } # Offense count: 28
96
+ Style/StringLiterals: { Enabled: false } # Offense count: 774
97
+ Lint/ElseLayout: { Enabled: false } # Offense count: 22
98
+
99
+ # < 10 violations
100
+ Layout/EmptyLinesAroundModuleBody: { Enabled: false } # Offense count: 5
101
+ Layout/ExtraSpacing: { Enabled: false } # Offense count: 6
102
+ Layout/FirstHashElementIndentation: { Enabled: false } # Offense count: 4
103
+ Layout/ParameterAlignment: { Enabled: false } # Offense count: 9
104
+ Layout/SpaceAroundKeyword: { Enabled: false } # Offense count: 7
105
+ Layout/SpaceBeforeComma: { Enabled: false } # Offense count: 4
106
+ Layout/SpaceInsideParens: { Enabled: false } # Offense count: 4
107
+ Lint/EmptyClass: { Enabled: false } # Offense count: 3
108
+ Lint/SuppressedException: { Enabled: false } # Offense count: 4
109
+ Lint/UnusedMethodArgument: { Enabled: false } # Offense count: 5
110
+ Style/AccessorGrouping: { Enabled: false } # Offense count: 7
111
+ Style/Documentation: { Enabled: false } # Offense count: 3
112
+ Style/ExpandPathArguments: { Enabled: false } # Offense count: 8
113
+ Style/KeywordParametersOrder: { Enabled: false } # Offense count: 8
114
+ Style/Lambda: { Enabled: false } # Offense count: 3
115
+ Style/MutableConstant: { Enabled: false } # Offense count: 4
116
+ Style/RaiseArgs: { Enabled: false } # Offense count: 4
117
+ Style/RedundantReturn: { Enabled: false } # Offense count: 7
118
+ Style/SafeNavigation: { Enabled: false } # Offense count: 5
119
+ Style/StringConcatenation: { Enabled: false } # Offense count: 8
120
+ Style/WordArray: { Enabled: false } # Offense count: 4
121
+
122
+ # 1 or 2 violations
123
+ Layout/ArgumentAlignment: { Enabled: false } # Offense count: 1
124
+ Layout/BlockAlignment: { Enabled: false } # Offense count: 1
125
+ Layout/IndentationWidth: { Enabled: false } # Offense count: 2
126
+ Layout/SpaceAroundOperators: { Enabled: false } # Offense count: 1
127
+ Layout/SpaceBeforeBlockBraces: { Enabled: false } # Offense count: 1
128
+ Lint/MissingSuper: { Enabled: false } # Offense count: 2
129
+ Lint/RescueException: { Enabled: false } # Offense count: 1
130
+ Lint/UnreachableLoop: { Enabled: false } # Offense count: 1
131
+ Lint/UnusedBlockArgument: { Enabled: false } # Offense count: 1
132
+ Naming/MethodParameterName: { Enabled: false } # Offense count: 1
133
+ Style/EmptyMethod: { Enabled: false } # Offense count: 2
134
+ Style/HashConversion: { Enabled: false } # Offense count: 1
135
+ Style/MultilineMemoization: { Enabled: false } # Offense count: 1
136
+ Style/NumericPredicate: { Enabled: false } # Offense count: 1
137
+ Style/OptionalArguments: { Enabled: false } # Offense count: 1
138
+ Style/ParenthesesAroundCondition: { Enabled: false } # Offense count: 1
139
+ Style/PreferredHashMethods: { Enabled: false } # Offense count: 1
140
+ Style/QuotedSymbols: { Enabled: false } # Offense count: 1
141
+ Style/RedundantException: { Enabled: false } # Offense count: 1
142
+ Style/RedundantRegexpEscape: { Enabled: false } # Offense count: 1
143
+ Style/RegexpLiteral: { Enabled: false } # Offense count: 1
144
+ Style/RescueStandardError: { Enabled: false } # Offense count: 1
145
+ Style/SoleNestedConditional: { Enabled: false } # Offense count: 1
146
+ Style/TrailingCommaInHashLiteral: { Enabled: false } # Offense count: 2
147
+
148
+ # rubocop cannot tell that rubygems_mfa_required is enabled in gemspec.yml
149
+ Gemspec/RequireMFA: { Enabled: false }
150
+
151
+ # make an exception for our gemspec code
152
+ Gemspec/DuplicatedAssignment:
153
+ Exclude:
154
+ - 'ronin-web-server.gemspec'
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ ruby-3.1
data/.yardopts ADDED
@@ -0,0 +1 @@
1
+ --markup markdown --title 'ronin-web-server Documentation' --protected
data/COPYING.txt ADDED
@@ -0,0 +1,165 @@
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+
9
+ This version of the GNU Lesser General Public License incorporates
10
+ the terms and conditions of version 3 of the GNU General Public
11
+ License, supplemented by the additional permissions listed below.
12
+
13
+ 0. Additional Definitions.
14
+
15
+ As used herein, "this License" refers to version 3 of the GNU Lesser
16
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
+ General Public License.
18
+
19
+ "The Library" refers to a covered work governed by this License,
20
+ other than an Application or a Combined Work as defined below.
21
+
22
+ An "Application" is any work that makes use of an interface provided
23
+ by the Library, but which is not otherwise based on the Library.
24
+ Defining a subclass of a class defined by the Library is deemed a mode
25
+ of using an interface provided by the Library.
26
+
27
+ A "Combined Work" is a work produced by combining or linking an
28
+ Application with the Library. The particular version of the Library
29
+ with which the Combined Work was made is also called the "Linked
30
+ Version".
31
+
32
+ The "Minimal Corresponding Source" for a Combined Work means the
33
+ Corresponding Source for the Combined Work, excluding any source code
34
+ for portions of the Combined Work that, considered in isolation, are
35
+ based on the Application, and not on the Linked Version.
36
+
37
+ The "Corresponding Application Code" for a Combined Work means the
38
+ object code and/or source code for the Application, including any data
39
+ and utility programs needed for reproducing the Combined Work from the
40
+ Application, but excluding the System Libraries of the Combined Work.
41
+
42
+ 1. Exception to Section 3 of the GNU GPL.
43
+
44
+ You may convey a covered work under sections 3 and 4 of this License
45
+ without being bound by section 3 of the GNU GPL.
46
+
47
+ 2. Conveying Modified Versions.
48
+
49
+ If you modify a copy of the Library, and, in your modifications, a
50
+ facility refers to a function or data to be supplied by an Application
51
+ that uses the facility (other than as an argument passed when the
52
+ facility is invoked), then you may convey a copy of the modified
53
+ version:
54
+
55
+ a) under this License, provided that you make a good faith effort to
56
+ ensure that, in the event an Application does not supply the
57
+ function or data, the facility still operates, and performs
58
+ whatever part of its purpose remains meaningful, or
59
+
60
+ b) under the GNU GPL, with none of the additional permissions of
61
+ this License applicable to that copy.
62
+
63
+ 3. Object Code Incorporating Material from Library Header Files.
64
+
65
+ The object code form of an Application may incorporate material from
66
+ a header file that is part of the Library. You may convey such object
67
+ code under terms of your choice, provided that, if the incorporated
68
+ material is not limited to numerical parameters, data structure
69
+ layouts and accessors, or small macros, inline functions and templates
70
+ (ten or fewer lines in length), you do both of the following:
71
+
72
+ a) Give prominent notice with each copy of the object code that the
73
+ Library is used in it and that the Library and its use are
74
+ covered by this License.
75
+
76
+ b) Accompany the object code with a copy of the GNU GPL and this license
77
+ document.
78
+
79
+ 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that,
82
+ taken together, effectively do not restrict modification of the
83
+ portions of the Library contained in the Combined Work and reverse
84
+ engineering for debugging such modifications, if you also do each of
85
+ the following:
86
+
87
+ a) Give prominent notice with each copy of the Combined Work that
88
+ the Library is used in it and that the Library and its use are
89
+ covered by this License.
90
+
91
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
+ document.
93
+
94
+ c) For a Combined Work that displays copyright notices during
95
+ execution, include the copyright notice for the Library among
96
+ these notices, as well as a reference directing the user to the
97
+ copies of the GNU GPL and this license document.
98
+
99
+ d) Do one of the following:
100
+
101
+ 0) Convey the Minimal Corresponding Source under the terms of this
102
+ License, and the Corresponding Application Code in a form
103
+ suitable for, and under terms that permit, the user to
104
+ recombine or relink the Application with a modified version of
105
+ the Linked Version to produce a modified Combined Work, in the
106
+ manner specified by section 6 of the GNU GPL for conveying
107
+ Corresponding Source.
108
+
109
+ 1) Use a suitable shared library mechanism for linking with the
110
+ Library. A suitable mechanism is one that (a) uses at run time
111
+ a copy of the Library already present on the user's computer
112
+ system, and (b) will operate properly with a modified version
113
+ of the Library that is interface-compatible with the Linked
114
+ Version.
115
+
116
+ e) Provide Installation Information, but only if you would otherwise
117
+ be required to provide such information under section 6 of the
118
+ GNU GPL, and only to the extent that such information is
119
+ necessary to install and execute a modified version of the
120
+ Combined Work produced by recombining or relinking the
121
+ Application with a modified version of the Linked Version. (If
122
+ you use option 4d0, the Installation Information must accompany
123
+ the Minimal Corresponding Source and Corresponding Application
124
+ Code. If you use option 4d1, you must provide the Installation
125
+ Information in the manner specified by section 6 of the GNU GPL
126
+ for conveying Corresponding Source.)
127
+
128
+ 5. Combined Libraries.
129
+
130
+ You may place library facilities that are a work based on the
131
+ Library side by side in a single library together with other library
132
+ facilities that are not Applications and are not covered by this
133
+ License, and convey such a combined library under terms of your
134
+ choice, if you do both of the following:
135
+
136
+ a) Accompany the combined library with a copy of the same work based
137
+ on the Library, uncombined with any other library facilities,
138
+ conveyed under the terms of this License.
139
+
140
+ b) Give prominent notice with the combined library that part of it
141
+ is a work based on the Library, and explaining where to find the
142
+ accompanying uncombined form of the same work.
143
+
144
+ 6. Revised Versions of the GNU Lesser General Public License.
145
+
146
+ The Free Software Foundation may publish revised and/or new versions
147
+ of the GNU Lesser General Public License from time to time. Such new
148
+ versions will be similar in spirit to the present version, but may
149
+ differ in detail to address new problems or concerns.
150
+
151
+ Each version is given a distinguishing version number. If the
152
+ Library as you received it specifies that a certain numbered version
153
+ of the GNU Lesser General Public License "or any later version"
154
+ applies to it, you have the option of following the terms and
155
+ conditions either of that published version or of any later version
156
+ published by the Free Software Foundation. If the Library as you
157
+ received it does not specify a version number of the GNU Lesser
158
+ General Public License, you may choose any version of the GNU Lesser
159
+ General Public License ever published by the Free Software Foundation.
160
+
161
+ If the Library as you received it specifies that a proxy can decide
162
+ whether future versions of the GNU Lesser General Public License shall
163
+ apply, that proxy's public statement of acceptance of any version is
164
+ permanent authorization for you to choose that version for the
165
+ Library.
data/ChangeLog.md ADDED
@@ -0,0 +1,38 @@
1
+ ### 0.1.0 / 2023-XX-XX
2
+
3
+ * Initial release:
4
+ * Provides a [Sinatra][sinatra] based
5
+ {Ronin::Web::Server::Base web server base class}.
6
+ * Supports additional routing helper methods:
7
+ * `any` - matches any HTTP request method.
8
+ * `default` - default response for the app.
9
+ * `basic_auth` - enables Basic-Auth for the app.
10
+ * `redirect` - adds a redirect to a given URL for the given path.
11
+ * `file` - mounts a local file to the given path.
12
+ * `directory` - mounts a local directory of files at the given path.
13
+ * `public_dir` - mounts the files/directories within the directory to the
14
+ root of the app.
15
+ * `vhost` - routes all requests for the given host to another app.
16
+ * `mount` - routes all requests for a given directory to another app.
17
+ * Supports additional routing conditions:
18
+ * `client_ip` - matches the client IP Address that sent the request.
19
+ * `asn` - matches the AS number of the client's IP address.
20
+ * `country_code` - matches the country code of the ASN information for the
21
+ client's IP address.
22
+ * `asn_name` - matches the company/ISP name of the ASN information for the
23
+ client's IP address.
24
+ * `host` - matches the `Host` header.
25
+ * `referer` - matches the `Referer` header of the request.
26
+ * `user_agent` - matches the `User-Agent` header of the request.
27
+ * `browser` - matches the browser name from the `User-Agent` header of the
28
+ request.
29
+ * `browser_vendor` - matches the browser vendor from the `User-Agent` header
30
+ of the request.
31
+ * `browser_version` - matches the browser version from the `User-Agent`
32
+ header of the request.
33
+ * `device_type` - matches the device type of the `User-Agent` header of the
34
+ request.
35
+ * `os` - matches the OS from the `User-Agent` header of the request.
36
+ * `os_version` - matches the OS version from the `User-Agent` header of the
37
+ request.
38
+
data/Gemfile ADDED
@@ -0,0 +1,35 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ platform :jruby do
6
+ gem 'jruby-openssl', '~> 0.7'
7
+ end
8
+
9
+ # Ronin dependencies
10
+ # gem 'ronin-support', '~> 1.0', github: "ronin-rb/ronin-support",
11
+ # branch: 'main'
12
+ # gem 'ronin-core', '~> 0.1', github: "ronin-rb/ronin-core",
13
+ # branch: 'main'
14
+
15
+ group :development do
16
+ gem 'rake'
17
+ gem 'rubygems-tasks', '~> 0.2'
18
+
19
+ gem 'rspec', '~> 3.0'
20
+ gem 'simplecov', '~> 0.20'
21
+ gem 'rack-test', '~> 0.6'
22
+ gem 'webmock', '~> 3.0'
23
+
24
+ gem 'kramdown', '~> 2.0'
25
+ gem 'kramdown-man', '~> 0.1'
26
+
27
+ gem 'redcarpet', platform: :mri
28
+ gem 'yard', '~> 0.9'
29
+ gem 'yard-spellcheck', require: false
30
+
31
+ gem 'dead_end', require: false
32
+ gem 'sord', require: false, platform: :mri
33
+ gem 'stackprof', require: false, platform: :mri
34
+ gem 'rubocop', require: false
35
+ end
data/README.md ADDED
@@ -0,0 +1,177 @@
1
+ # ronin-web-server
2
+
3
+ [![CI](https://github.com/ronin-rb/ronin-web-server/actions/workflows/ruby.yml/badge.svg)](https://github.com/ronin-rb/ronin-web-server/actions/workflows/ruby.yml)
4
+ [![Code Climate](https://codeclimate.com/github/ronin-rb/ronin-web-server.svg)](https://codeclimate.com/github/ronin-rb/ronin-web-server)
5
+
6
+ * [Website](https://ronin-rb.dev/)
7
+ * [Source](https://github.com/ronin-rb/ronin-web-server)
8
+ * [Issues](https://github.com/ronin-rb/ronin-web-server/issues)
9
+ * [Documentation](https://ronin-rb.dev/docs/ronin-web-server/frames)
10
+ * [Discord](https://discord.gg/6WAb3PsVX9) |
11
+ [Twitter](https://twitter.com/ronin_rb) |
12
+ [Mastodon](https://infosec.exchange/@ronin_rb)
13
+
14
+ ## Description
15
+
16
+ ronin-web-server is a custom Ruby web server based on Sinatra tailored for
17
+ security research and development.
18
+
19
+ ## Features
20
+
21
+ * Provides a [Sinatra][sinatra] based
22
+ {Ronin::Web::Server::Base web server base class}.
23
+ * Supports additional routing helper methods:
24
+ * `any` - matches any HTTP request method.
25
+ * `default` - default response for the app.
26
+ * `basic_auth` - enables Basic-Auth for the app.
27
+ * `redirect` - adds a redirect to a given URL for the given path.
28
+ * `file` - mounts a local file to the given path.
29
+ * `directory` - mounts a local directory of files at the given path.
30
+ * `public_dir` - mounts the files/directories within the directory to the root
31
+ of the app.
32
+ * `vhost` - routes all requests for the given host to another app.
33
+ * `mount` - routes all requests for a given directory to another app.
34
+ * Supports additional routing conditions:
35
+ * `client_ip` - matches the client IP Address that sent the request.
36
+ * `asn` - matches the AS number of the client's IP address.
37
+ * `country_code` - matches the country code of the ASN information for the
38
+ client's IP address.
39
+ * `asn_name` - matches the company/ISP name of the ASN information for the
40
+ client's IP address.
41
+ * `host` - matches the `Host` header.
42
+ * `referer` - matches the `Referer` header of the request.
43
+ * `user_agent` - matches the `User-Agent` header of the request.
44
+ * `browser` - matches the browser name from the `User-Agent` header of the
45
+ request.
46
+ * `browser_vendor` - matches the browser vendor from the `User-Agent` header
47
+ of the request.
48
+ * `browser_version` - matches the browser version from the `User-Agent` header
49
+ of the request.
50
+ * `device_type` - matches the device type of the `User-Agent` header of the
51
+ request.
52
+ * `os` - matches the OS from the `User-Agent` header of the request.
53
+ * `os_version` - matches the OS version from the `User-Agent` header of the
54
+ request.
55
+ * Has 97% documentation coverage.
56
+ * Has 85% test coverage.
57
+
58
+ ## Examples
59
+
60
+ Create and run a simple web app:
61
+
62
+ ```ruby
63
+ require 'ronin/web/server'
64
+
65
+ class App < Ronin::Web::Server::Base
66
+
67
+ # mount a file
68
+ file '/sitemap.xml', './files/sitemap.xml'
69
+
70
+ # mount a directory
71
+ directory '/downloads/', '/tmp/downloads/'
72
+
73
+ get '/' do
74
+ # renders views/index.erb
75
+ erb :index
76
+ end
77
+
78
+ get '/test' do
79
+ "raw string here"
80
+ end
81
+
82
+ get '/exploit', asn: 13335 do
83
+ # route that only matches the AS13335 netblock
84
+ end
85
+
86
+ get '/exploit', asn_name: 'GOOGLE' do
87
+ # route that only matches GOOGLE netblocks
88
+ end
89
+
90
+ get '/exploit', country_code: 'US' do
91
+ # route that only matches US netblocks
92
+ end
93
+
94
+ get '/exploit', browser: :firefox do
95
+ # route that only matches firefox web browsers
96
+ end
97
+
98
+ get '/exploit', browser: :chrome, browser_version: /^99\./ do
99
+ # route that only matches chrome 99.X.Y.Z web browsers
100
+ end
101
+
102
+ get '/exploit', os: :ios, os_version: '15.6' do
103
+ # route that only matches iOS 15.6 devices
104
+ end
105
+
106
+ # catchall route
107
+ get '/exploit' do
108
+ "nothing to see here"
109
+ end
110
+
111
+ end
112
+
113
+ App.run!
114
+ ```
115
+
116
+ **Note**: See {Ronin::Web::Server::Base} and [Sinatra's Intro][1] for additional
117
+ documentation.
118
+
119
+ [1]: http://sinatrarb.com/intro.html
120
+
121
+ ## Requirements
122
+
123
+ * [Ruby] >= 3.0.0
124
+ * [webrick] ~> 1.0
125
+ * [rack] ~> 2.2
126
+ * [rack-user_agent] ~> 0.5
127
+ * [sinatra] ~> 3.0
128
+ * [ronin-support] ~> 1.0
129
+
130
+ ## Install
131
+
132
+ ```shell
133
+ $ gem install ronin-web-server
134
+ ```
135
+
136
+ ### Gemfile
137
+
138
+ ```shell
139
+ gem 'ronin-web-server', '~> 0.1'
140
+ ```
141
+
142
+ ## Development
143
+
144
+ 1. [Fork It!](https://github.com/ronin-rb/ronin-web-server/fork)
145
+ 2. Clone It!
146
+ 3. `cd ronin-web-server/`
147
+ 4. `bundle install`
148
+ 5. `git checkout -b my_feature`
149
+ 6. Code It!
150
+ 7. `bundle exec rake spec`
151
+ 8. `git push origin my_feature`
152
+
153
+ ## License
154
+
155
+ ronin-web-server - A custom Ruby web server based on Sinatra.
156
+
157
+ Copyright (c) 2006-2022 Hal Brodigan (postmodern.mod3 at gmail.com)
158
+
159
+ ronin-web-server is free software: you can redistribute it and/or modify
160
+ it under the terms of the GNU Lesser General Public License as published
161
+ by the Free Software Foundation, either version 3 of the License, or
162
+ (at your option) any later version.
163
+
164
+ ronin-web-server is distributed in the hope that it will be useful,
165
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
166
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
167
+ GNU Lesser General Public License for more details.
168
+
169
+ You should have received a copy of the GNU Lesser General Public License
170
+ along with ronin-web-server. If not, see <https://www.gnu.org/licenses/>.
171
+
172
+ [Ruby]: https://www.ruby-lang.org
173
+ [webrick]: https://github.com/ruby/webrick#readme
174
+ [rack]: https://github.com/rack/rack#readme
175
+ [rack-user_agent]: https://github.com/k0kubun/rack-user_agent#readme
176
+ [sinatra]: https://github.com/sinatra/sinatra#readme
177
+ [ronin-support]: https://github.com/ronin-rb/ronin-support#readme
data/Rakefile ADDED
@@ -0,0 +1,34 @@
1
+ require 'rubygems'
2
+
3
+ begin
4
+ require 'bundler'
5
+ rescue LoadError => e
6
+ warn e.message
7
+ warn "Run `gem install bundler` to install Bundler"
8
+ exit(-1)
9
+ end
10
+
11
+ begin
12
+ Bundler.setup(:development)
13
+ rescue Bundler::BundlerError => e
14
+ warn e.message
15
+ warn "Run `bundle install` to install missing gems"
16
+ exit e.status_code
17
+ end
18
+
19
+ require 'rake'
20
+
21
+ require 'rubygems/tasks'
22
+ Gem::Tasks.new(sign: {checksum: true, pgp: true})
23
+
24
+ require 'rspec/core/rake_task'
25
+ RSpec::Core::RakeTask.new
26
+ task :test => :spec
27
+ task :default => :spec
28
+
29
+ require 'yard'
30
+ YARD::Rake::YardocTask.new
31
+ task :docs => :yard
32
+
33
+ require 'kramdown/man/task'
34
+ Kramdown::Man::Task.new