ronin-listener-http 0.1.0.rc1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/ChangeLog.md +1 -1
- data/lib/ronin/listener/http/request.rb +72 -17
- data/lib/ronin/listener/http/server.rb +12 -6
- data/lib/ronin/listener/http/version.rb +1 -1
- data/lib/ronin/listener/http.rb +1 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c30560b1a128571b6624cc2d466dc1508395df6f2630cdc09b6012cee5e79fa4
|
4
|
+
data.tar.gz: fec1870e02c243c885c72a7eea34207ee9478a96931838a01d22811533993de1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '09095fbcd472e192d14b1828db9b7c5e66a4a2a9f13ea0d55303eda62219dba71105094fcc16dba99c7cee7930b3584ecb558f354376a40333dd1bd4b6bb0bbc'
|
7
|
+
data.tar.gz: 3713e12f0a6b5ed8e2a50b927f7ae2e01b89275e5c1439e0e5c1cff83c9441fb8cb8ccc3e4d34040181f74dfc7d738c10897e89b749385a32a1f57e5ca6c1774
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby-3.
|
1
|
+
ruby-3.3
|
data/ChangeLog.md
CHANGED
@@ -29,6 +29,11 @@ module Ronin
|
|
29
29
|
#
|
30
30
|
class Request
|
31
31
|
|
32
|
+
# The remote address that sent the request.
|
33
|
+
#
|
34
|
+
# @return [Addrinfo]
|
35
|
+
attr_reader :remote_addr
|
36
|
+
|
32
37
|
# The HTTP request method.
|
33
38
|
#
|
34
39
|
# @return [String]
|
@@ -39,6 +44,11 @@ module Ronin
|
|
39
44
|
# @return [String]
|
40
45
|
attr_reader :path
|
41
46
|
|
47
|
+
# The request query string.
|
48
|
+
#
|
49
|
+
# @return [String, nil]
|
50
|
+
attr_reader :query
|
51
|
+
|
42
52
|
# The HTTP version.
|
43
53
|
#
|
44
54
|
# @return [String]
|
@@ -57,12 +67,18 @@ module Ronin
|
|
57
67
|
#
|
58
68
|
# Initializes the request.
|
59
69
|
#
|
70
|
+
# @param [Addrinfo] remote_addr
|
71
|
+
# The remote address that sent the request.
|
72
|
+
#
|
60
73
|
# @param [String] method
|
61
74
|
# The HTTP request method.
|
62
75
|
#
|
63
76
|
# @param [String] path
|
64
77
|
# The request path.
|
65
78
|
#
|
79
|
+
# @param [String, nil] query
|
80
|
+
# The request query string.
|
81
|
+
#
|
66
82
|
# @param [String] version
|
67
83
|
# The HTTP version.
|
68
84
|
#
|
@@ -72,12 +88,38 @@ module Ronin
|
|
72
88
|
# @param [String, nil] body
|
73
89
|
# The optional body sent with the request.
|
74
90
|
#
|
75
|
-
def initialize(
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
91
|
+
def initialize(remote_addr: ,
|
92
|
+
method: ,
|
93
|
+
path: ,
|
94
|
+
query: nil,
|
95
|
+
version: ,
|
96
|
+
headers:,
|
97
|
+
body: nil)
|
98
|
+
@remote_addr = remote_addr
|
99
|
+
@method = method
|
100
|
+
@path = path
|
101
|
+
@query = query
|
102
|
+
@version = version
|
103
|
+
@headers = headers
|
104
|
+
@body = body
|
105
|
+
end
|
106
|
+
|
107
|
+
#
|
108
|
+
# The remote IP address that sent the request.
|
109
|
+
#
|
110
|
+
# @return [String]
|
111
|
+
#
|
112
|
+
def remote_ip
|
113
|
+
@remote_addr.ip_address
|
114
|
+
end
|
115
|
+
|
116
|
+
#
|
117
|
+
# The remote port that sent the request.
|
118
|
+
#
|
119
|
+
# @return [String]
|
120
|
+
#
|
121
|
+
def remote_port
|
122
|
+
@remote_addr.ip_port
|
81
123
|
end
|
82
124
|
|
83
125
|
#
|
@@ -91,11 +133,14 @@ module Ronin
|
|
91
133
|
#
|
92
134
|
def ==(other)
|
93
135
|
self.class == other.class &&
|
94
|
-
|
95
|
-
|
96
|
-
@
|
97
|
-
@
|
98
|
-
@
|
136
|
+
remote_ip == other.remote_ip &&
|
137
|
+
remote_port == other.remote_port &&
|
138
|
+
@method == other.method &&
|
139
|
+
@path == other.path &&
|
140
|
+
@query == other.query &&
|
141
|
+
@version == other.version &&
|
142
|
+
@headers == other.headers &&
|
143
|
+
@body == other.body
|
99
144
|
end
|
100
145
|
|
101
146
|
#
|
@@ -105,7 +150,11 @@ module Ronin
|
|
105
150
|
# The raw HTTP request.
|
106
151
|
#
|
107
152
|
def to_s
|
108
|
-
|
153
|
+
request_uri = if @query then "#{@path}?#{@query}"
|
154
|
+
else @path
|
155
|
+
end
|
156
|
+
|
157
|
+
string = "#{@method} #{request_uri} HTTP/#{@version}\r\n"
|
109
158
|
|
110
159
|
@headers.each do |name,value|
|
111
160
|
string << "#{name}: #{value}\r\n"
|
@@ -122,11 +171,14 @@ module Ronin
|
|
122
171
|
#
|
123
172
|
def to_h
|
124
173
|
{
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
174
|
+
remote_ip: remote_ip,
|
175
|
+
remote_port: remote_port,
|
176
|
+
method: @method,
|
177
|
+
path: @path,
|
178
|
+
query: @query,
|
179
|
+
version: @version,
|
180
|
+
headers: @headers,
|
181
|
+
body: @body
|
130
182
|
}
|
131
183
|
end
|
132
184
|
|
@@ -139,8 +191,11 @@ module Ronin
|
|
139
191
|
def to_csv
|
140
192
|
CSV.generate_line(
|
141
193
|
[
|
194
|
+
remote_ip,
|
195
|
+
remote_port,
|
142
196
|
@method,
|
143
197
|
@path,
|
198
|
+
@query,
|
144
199
|
@version,
|
145
200
|
CSV.generate { |csv|
|
146
201
|
@headers.each_pair do |name_value|
|
@@ -24,6 +24,7 @@ require 'async'
|
|
24
24
|
require 'async/http/server'
|
25
25
|
require 'async/http/endpoint'
|
26
26
|
require 'async/http/protocol/response'
|
27
|
+
require 'protocol/http/reference'
|
27
28
|
|
28
29
|
module Ronin
|
29
30
|
module Listener
|
@@ -128,14 +129,19 @@ module Ronin
|
|
128
129
|
#
|
129
130
|
def process(request)
|
130
131
|
if (@vhost.nil? || @vhost === request.authority)
|
131
|
-
|
132
|
+
reference = Protocol::HTTP::Reference.parse(request.path)
|
133
|
+
path = reference.path
|
134
|
+
|
135
|
+
if path == @root || path.start_with?(@root)
|
132
136
|
@callback.call(
|
133
137
|
Request.new(
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
138
|
+
remote_addr: request.remote_address,
|
139
|
+
method: request.method,
|
140
|
+
path: path,
|
141
|
+
query: reference.query,
|
142
|
+
version: request.version,
|
143
|
+
headers: request.headers,
|
144
|
+
body: request.body
|
139
145
|
)
|
140
146
|
)
|
141
147
|
end
|
data/lib/ronin/listener/http.rb
CHANGED
@@ -47,8 +47,7 @@ module Ronin
|
|
47
47
|
# @yield [request]
|
48
48
|
# The given block will be passed each received HTTP request.
|
49
49
|
#
|
50
|
-
# @yieldparam [
|
51
|
-
# Async::HTTP::Protocol::HTTP2::Request] request
|
50
|
+
# @yieldparam [Request] request
|
52
51
|
# The received HTTP request object.
|
53
52
|
#
|
54
53
|
# @raise [ArgumentError]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ronin-listener-http
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Postmodern
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: async-http
|
@@ -93,7 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
93
93
|
- !ruby/object:Gem::Version
|
94
94
|
version: '0'
|
95
95
|
requirements: []
|
96
|
-
rubygems_version: 3.
|
96
|
+
rubygems_version: 3.5.11
|
97
97
|
signing_key:
|
98
98
|
specification_version: 4
|
99
99
|
summary: A HTTP server for receiving exfiled data.
|