ronin-listener-http 0.1.0.rc1 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5adf81fa9ced6ab4fd65074de117b81415c1404928f92454232c2062ff758548
4
- data.tar.gz: 07e253fe463c655429521a42e2e79aeafe8a69389d58c606ea01d11a230271d7
3
+ metadata.gz: c30560b1a128571b6624cc2d466dc1508395df6f2630cdc09b6012cee5e79fa4
4
+ data.tar.gz: fec1870e02c243c885c72a7eea34207ee9478a96931838a01d22811533993de1
5
5
  SHA512:
6
- metadata.gz: e1fdba946028f0696559f874f2264b3116c073398bd3dbc704b19d67a26cc73e02524177f2280c9fcb9ad42d51082b99ca809fd9da73258c794cafc26a9ab592
7
- data.tar.gz: 950be8ff0f2f62488e39d32d4d4d70d775ba72f926e0470ba4907e60168646e148b357f98472ccb120a66eaa1e37d3106e6259377d1af8519bf9478bc4857aac
6
+ metadata.gz: '09095fbcd472e192d14b1828db9b7c5e66a4a2a9f13ea0d55303eda62219dba71105094fcc16dba99c7cee7930b3584ecb558f354376a40333dd1bd4b6bb0bbc'
7
+ data.tar.gz: 3713e12f0a6b5ed8e2a50b927f7ae2e01b89275e5c1439e0e5c1cff83c9441fb8cb8ccc3e4d34040181f74dfc7d738c10897e89b749385a32a1f57e5ca6c1774
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-3.1
1
+ ruby-3.3
data/ChangeLog.md CHANGED
@@ -1,4 +1,4 @@
1
- ### 0.1.0 / 2024-XX-XX
1
+ ### 0.1.0 / 2024-07-22
2
2
 
3
3
  * Initial release:
4
4
  * Supports receiving HTTP requests.
@@ -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(method: , path: , version: , headers:, body: nil)
76
- @method = method
77
- @path = path
78
- @version = version
79
- @headers = headers
80
- @body = body
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
- @method == other.method &&
95
- @path == other.path &&
96
- @version == other.version &&
97
- @headers == other.headers &&
98
- @body == other.body
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
- string = "#{@method} #{@path} HTTP/#{@version}\r\n"
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
- method: @method,
126
- path: @path,
127
- version: @version,
128
- headers: @headers,
129
- body: @body
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
- if request.path == @root || request.path.start_with?(@root)
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
- method: request.method,
135
- path: request.path,
136
- version: request.version,
137
- headers: request.headers,
138
- body: request.body
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
@@ -22,7 +22,7 @@ module Ronin
22
22
  module Listener
23
23
  module HTTP
24
24
  # ronin-listener-http version
25
- VERSION = '0.1.0.rc1'
25
+ VERSION = '0.1.0'
26
26
  end
27
27
  end
28
28
  end
@@ -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 [Async::HTTP::Protocol::HTTP1::Request,
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.rc1
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-06-23 00:00:00.000000000 Z
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.3.27
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.