ronin-support 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3f47bb5e6e9e8b720f2b2e66cfd1eb49bcb4562e5ed0025a3ed491ee7e39f106
4
- data.tar.gz: a68c5f263d3d7caf40f789354e51a977ada25c52cb7a93f58c4c10208c40da67
3
+ metadata.gz: d6f75dd96200bd01190ad5ae040cc28dfc658c3f6bcf6c7f299bcdb01d1ee974
4
+ data.tar.gz: 2a9b6e98f9959efacbbc81fccecbaa68b1620a8f52e38efdc941dcdba74ba38d
5
5
  SHA512:
6
- metadata.gz: 302af7c9324ba08daff8107236734c211b10f969723f55cac2843ec52a5e367357c1b3c06d4138215553960a994ae4c3338e3a4302105979fedb1dac51b2cc20
7
- data.tar.gz: 542b8b0d1caab51fce5fedf516b3b849c2a673492995916db6a43b3522090cd8bb1acc1b3200741832153e874522fcd60eae76f74e2aa90bb76d57dafb6daa1e
6
+ metadata.gz: 604e499c76bfd98e82dd2711a203edb85263742df23f128179d52b283c1f6e468334a34b456119b76c1a0d84b2d06969100d4b75e880a5b4ab963e6ccf244742
7
+ data.tar.gz: 843289f09e088afc611ee793f645cdb978bb51613d69176591599c26fdc4e8bfcc8b255e76fc01a7b8c40b1024aa94b69976754de3d9ef84b9ae5eecc62d4223
@@ -16,7 +16,7 @@ jobs:
16
16
  # - truffleruby
17
17
  name: Ruby ${{ matrix.ruby }}
18
18
  steps:
19
- - uses: actions/checkout@v2
19
+ - uses: actions/checkout@v4
20
20
  - name: Set up Ruby
21
21
  uses: ruby/setup-ruby@v1
22
22
  with:
@@ -31,7 +31,7 @@ jobs:
31
31
  rubocop:
32
32
  runs-on: ubuntu-latest
33
33
  steps:
34
- - uses: actions/checkout@v2
34
+ - uses: actions/checkout@v4
35
35
  - name: Set up Ruby
36
36
  uses: ruby/setup-ruby@v1
37
37
  with:
data/ChangeLog.md CHANGED
@@ -1,3 +1,13 @@
1
+ ### 1.0.4 / 2023-12-15
2
+
3
+ * Fixed a bug in {Array#pack} where complex types (ex: `[[:uint32, 4], 10]`)
4
+ were not being packed correctly.
5
+ * Fixed a bug in {String#unpack} where complex types (ex: `[[:uint32, 4], 10]`)
6
+ were not being unpacked correctly.
7
+ * Fixed a bug in {Ronin::Support::Binary::CTypes::ObjectType#initialize} when
8
+ the object's type has an infinite size, such as an unbounded Array type.
9
+ * Allow using non-RSA keys in all SSL/TLS methods.
10
+
1
11
  ### 1.0.3 / 2023-09-19
2
12
 
3
13
  * {Ronin::Support::Crypto::Cert::Name#entries} now returns UTF-8 encoded
@@ -41,6 +41,11 @@ class Array
41
41
  # :mips, :mips_le, :mips64, :mips64_le, nil] :arch
42
42
  # The desired architecture to pack the data for.
43
43
  #
44
+ # @option kwargs [:linux, :macos, :windows,
45
+ # :android, :apple_ios, :bsd,
46
+ # :freebsd, :openbsd, :netbsd] :os
47
+ # The Operating System (OS) to use.
48
+ #
44
49
  # @return [String]
45
50
  # The packed Array.
46
51
  #
@@ -67,8 +72,8 @@ class Array
67
72
  if (arguments.length == 1 && arguments.first.kind_of?(String))
68
73
  pack_original(arguments.first)
69
74
  else
70
- format = Ronin::Support::Binary::Template.new(arguments,**kwargs)
71
- pack_original(format.pack_string)
75
+ template = Ronin::Support::Binary::Template.new(arguments,**kwargs)
76
+ template.pack(*self)
72
77
  end
73
78
  end
74
79
 
@@ -43,6 +43,11 @@ class String
43
43
  # :mips, :mips_le, :mips64, :mips64_le, nil] :arch
44
44
  # The desired architecture that the data was packed for.
45
45
  #
46
+ # @option kwargs [:linux, :macos, :windows,
47
+ # :android, :apple_ios, :bsd,
48
+ # :freebsd, :openbsd, :netbsd] :os
49
+ # The Operating System (OS) to use.
50
+ #
46
51
  # @return [Array]
47
52
  # The values unpacked from the String.
48
53
  #
@@ -69,8 +74,8 @@ class String
69
74
  if (arguments.length == 1 && arguments.first.kind_of?(String))
70
75
  unpack_original(arguments.first)
71
76
  else
72
- format = Ronin::Support::Binary::Template.new(arguments,**kwargs)
73
- unpack_original(format.pack_string)
77
+ template = Ronin::Support::Binary::Template.new(arguments,**kwargs)
78
+ template.unpack(self)
74
79
  end
75
80
  end
76
81
 
@@ -45,7 +45,13 @@ module Ronin
45
45
  def initialize(size)
46
46
  @size = size
47
47
 
48
- super(pack_string: "a#{@size}")
48
+ super(
49
+ pack_string: if size.finite?
50
+ "a#{@size}"
51
+ else
52
+ 'a*'
53
+ end
54
+ )
49
55
  end
50
56
 
51
57
  end
@@ -44,7 +44,7 @@ module Ronin
44
44
  typedef :long, :__blkcnt_t
45
45
  typedef :long, :__blksize_t
46
46
  typedef :long, :blksize_t
47
- typedef types::POINTER, :__caddr_t
47
+ typedef :pointer, :__caddr_t
48
48
  typedef :int, :__clockid_t
49
49
  typedef :int, :clockid_t
50
50
  typedef :long, :__clock_t
@@ -170,7 +170,7 @@ module Ronin
170
170
  typedef :uint, :nlink_t
171
171
  typedef :long_long, :__off64_t
172
172
  typedef :long_long, :off_t
173
- typedef types::POINTER, :__qaddr_t
173
+ typedef :pointer, :__qaddr_t
174
174
  typedef :long_long, :__quad_t
175
175
  typedef :long_long, :quad_t
176
176
  typedef :ulong_long, :__rlim64_t
@@ -132,11 +132,16 @@ module Ronin
132
132
  # :arm64, :arm64_le, :arm64_be] :arch
133
133
  # The desired architecture for the values within the template.
134
134
  #
135
+ # @option kwargs [:linux, :macos, :windows,
136
+ # :android, :apple_ios, :bsd,
137
+ # :freebsd, :openbsd, :netbsd] :os
138
+ # The Operating System (OS) to use.
139
+ #
135
140
  # @raise [ArgumentError]
136
141
  # A given type is not known.
137
142
  #
138
143
  # @example
139
- # template = Template.new([:uint32, [:char, 100]])
144
+ # template = Template.new([:uint32, [:char, 10]])
140
145
  # template.pack(0x123456, ['A', 'B', 'C'])
141
146
  # # => "CBA\x00XYZ\x00\x00\x00\x00\x00\x00\x00"
142
147
  # template.unpack("CBA\x00XYZ\x00\x00\x00\x00\x00\x00\x00")
@@ -164,9 +169,39 @@ module Ronin
164
169
  end
165
170
  end
166
171
 
172
+ #
173
+ # Alias for `Template.new`.
174
+ #
175
+ # @param [::Array<Symbol, (Symbol, Integer)>] fields
176
+ # The C-types which the packer will use.
177
+ #
178
+ # @param [Hash{Symbol => Object}] kwargs
179
+ # Additional keyword arguments.
180
+ #
181
+ # @option kwargs [:little, :big, :net, nil] :endian
182
+ # The desired endianness of the values within the template.
183
+ #
184
+ # @option kwargs [:x86, :x86_64,
185
+ # :ppc, :ppc64,
186
+ # :mips, :mips_le, :mips_be,
187
+ # :mips64, :mips64_le, :mips64_be,
188
+ # :arm, :arm_le, :arm_be,
189
+ # :arm64, :arm64_le, :arm64_be] :arch
190
+ # The desired architecture for the values within the template.
191
+ #
192
+ # @option kwargs [:linux, :macos, :windows,
193
+ # :android, :apple_ios, :bsd,
194
+ # :freebsd, :openbsd, :netbsd] :os
195
+ # The Operating System (OS) to use.
196
+ #
197
+ # @return [Template]
198
+ # The new template object.
199
+ #
200
+ # @raise [ArgumentError]
201
+ # A given type is not known.
167
202
  #
168
203
  # @example
169
- # template = Template.new[:uint32, [:char, 10]]
204
+ # template = Template[:uint32, [:char, 10]]
170
205
  # template.pack(0x123456, ['A', 'B', 'C'])
171
206
  # # => "CBA\x00XYZ\x00\x00\x00\x00\x00\x00\x00"
172
207
  # template.unpack("CBA\x00XYZ\x00\x00\x00\x00\x00\x00\x00")
@@ -78,7 +78,7 @@ class Integer
78
78
  # The `format:` or `case:` keyword argument is invalid.
79
79
  #
80
80
  # @example
81
- # 0x41.html_enocde
81
+ # 0x41.html_encode
82
82
  # # => "&#65;"
83
83
  #
84
84
  # @example Zero-padding:
@@ -182,7 +182,7 @@ module Ronin
182
182
  # The HTTP method to use for the request.
183
183
  #
184
184
  # @param [URI::HTTP, Addressable::URI, String] url
185
- # Optional URL to create the HTTP request for.
185
+ # The URL to create the HTTP request for.
186
186
  #
187
187
  # @!macro request_kwargs
188
188
  # @!macro connect_kwargs
@@ -215,7 +215,7 @@ module Ronin
215
215
  # The HTTP method to use for the request.
216
216
  #
217
217
  # @param [URI::HTTP, Addressable::URI, String] url
218
- # Optional URL to create the HTTP request for.
218
+ # The URL to create the HTTP request for.
219
219
  #
220
220
  # @!macro request_kwargs
221
221
  # @!macro connect_kwargs
@@ -240,7 +240,7 @@ module Ronin
240
240
  # The HTTP method to use for the request.
241
241
  #
242
242
  # @param [URI::HTTP, Addressable::URI, String] url
243
- # Optional URL to create the HTTP request for.
243
+ # The URL to create the HTTP request for.
244
244
  #
245
245
  # @!macro request_kwargs
246
246
  # @!macro connect_kwargs
@@ -263,7 +263,7 @@ module Ronin
263
263
  # The HTTP method to use for the request.
264
264
  #
265
265
  # @param [URI::HTTP, Addressable::URI, String] url
266
- # Optional URL to create the HTTP request for.
266
+ # The URL to create the HTTP request for.
267
267
  #
268
268
  # @!macro request_kwargs
269
269
  # @!macro connect_kwargs
@@ -285,7 +285,7 @@ module Ronin
285
285
  # Sends an HTTP request and returns the `Server` header.
286
286
  #
287
287
  # @param [URI::HTTP, Addressable::URI, String] url
288
- # Optional URL to create the HTTP request for.
288
+ # The URL to create the HTTP request for.
289
289
  #
290
290
  # @!macro connect_kwargs
291
291
  # @!macro request_kwargs
@@ -307,7 +307,7 @@ module Ronin
307
307
  # Sends an HTTP request and returns the `X-Powered-By` header.
308
308
  #
309
309
  # @param [URI::HTTP, Addressable::URI, String] url
310
- # Optional URL to create the HTTP request for.
310
+ # The URL to create the HTTP request for.
311
311
  #
312
312
  # @!macro request_kwargs
313
313
  # @!macro connect_kwargs
@@ -332,7 +332,7 @@ module Ronin
332
332
  # The HTTP method to use for the request.
333
333
  #
334
334
  # @param [URI::HTTP, Addressable::URI, String] url
335
- # Optional URL to create the HTTP request for.
335
+ # The URL to create the HTTP request for.
336
336
  #
337
337
  # @!macro request_kwargs
338
338
  # @!macro connect_kwargs
@@ -354,7 +354,7 @@ module Ronin
354
354
  # Performs a `COPY` request for the given URI.
355
355
  #
356
356
  # @param [URI::HTTP, Addressable::URI, String] url
357
- # Optional URL to create the HTTP request for.
357
+ # The URL to create the HTTP request for.
358
358
  #
359
359
  # @!macro request_kwargs
360
360
  # @!macro connect_kwargs
@@ -372,15 +372,15 @@ module Ronin
372
372
  #
373
373
  # @api public
374
374
  #
375
- def http_copy(url, ssl: nil, **kwargs)
376
- Network::HTTP.copy(url, ssl: ssl, **kwargs)
375
+ def http_copy(url, ssl: nil, **kwargs,&block)
376
+ Network::HTTP.copy(url, ssl: ssl, **kwargs,&block)
377
377
  end
378
378
 
379
379
  #
380
380
  # Performs a `DELETE` request for the given URI.
381
381
  #
382
382
  # @param [URI::HTTP, Addressable::URI, String] url
383
- # Optional URL to create the HTTP request for.
383
+ # The URL to create the HTTP request for.
384
384
  #
385
385
  # @!macro request_kwargs
386
386
  # @!macro connect_kwargs
@@ -406,7 +406,7 @@ module Ronin
406
406
  # Performs a `GET` request for the given URI.
407
407
  #
408
408
  # @param [URI::HTTP, Addressable::URI, String] url
409
- # Optional URL to create the HTTP request for.
409
+ # The URL to create the HTTP request for.
410
410
  #
411
411
  # @!macro request_kwargs
412
412
  # @!macro connect_kwargs
@@ -433,7 +433,7 @@ module Ronin
433
433
  # headers.
434
434
  #
435
435
  # @param [URI::HTTP, Addressable::URI, String] url
436
- # Optional URL to create the HTTP request for.
436
+ # The URL to create the HTTP request for.
437
437
  #
438
438
  # @!macro request_kwargs
439
439
  # @!macro connect_kwargs
@@ -456,7 +456,7 @@ module Ronin
456
456
  # header(s).
457
457
  #
458
458
  # @param [URI::HTTP, Addressable::URI, String] url
459
- # Optional URL to create the HTTP request for.
459
+ # The URL to create the HTTP request for.
460
460
  #
461
461
  # @!macro request_kwargs
462
462
  # @!macro connect_kwargs
@@ -477,7 +477,7 @@ module Ronin
477
477
  # body.
478
478
  #
479
479
  # @param [URI::HTTP, Addressable::URI, String] url
480
- # Optional URL to create the HTTP request for.
480
+ # The URL to create the HTTP request for.
481
481
  #
482
482
  # @!macro request_kwargs
483
483
  # @!macro connect_kwargs
@@ -497,7 +497,7 @@ module Ronin
497
497
  # Performs a `HEAD` request for the given URI.
498
498
  #
499
499
  # @param [URI::HTTP, Addressable::URI, String] url
500
- # Optional URL to create the HTTP request for.
500
+ # The URL to create the HTTP request for.
501
501
  #
502
502
  # @!macro request_kwargs
503
503
  # @!macro connect_kwargs
@@ -523,7 +523,7 @@ module Ronin
523
523
  # Performs a `LOCK` request for the given URI.
524
524
  #
525
525
  # @param [URI::HTTP, Addressable::URI, String] url
526
- # Optional URL to create the HTTP request for.
526
+ # The URL to create the HTTP request for.
527
527
  #
528
528
  # @!macro request_kwargs
529
529
  # @!macro connect_kwargs
@@ -549,7 +549,7 @@ module Ronin
549
549
  # Performs a `MKCOL` request for the given URI.
550
550
  #
551
551
  # @param [URI::HTTP, Addressable::URI, String] url
552
- # Optional URL to create the HTTP request for.
552
+ # The URL to create the HTTP request for.
553
553
  #
554
554
  # @!macro request_kwargs
555
555
  # @!macro connect_kwargs
@@ -575,7 +575,7 @@ module Ronin
575
575
  # Performs a `MOVE` request for the given URI.
576
576
  #
577
577
  # @param [URI::HTTP, Addressable::URI, String] url
578
- # Optional URL to create the HTTP request for.
578
+ # The URL to create the HTTP request for.
579
579
  #
580
580
  # @!macro request_kwargs
581
581
  # @!macro connect_kwargs
@@ -601,7 +601,7 @@ module Ronin
601
601
  # Performs a `OPTIONS` request for the given URI.
602
602
  #
603
603
  # @param [URI::HTTP, Addressable::URI, String] url
604
- # Optional URL to create the HTTP request for.
604
+ # The URL to create the HTTP request for.
605
605
  #
606
606
  # @!macro request_kwargs
607
607
  # @!macro connect_kwargs
@@ -628,17 +628,11 @@ module Ronin
628
628
  # `Allow` response header.
629
629
  #
630
630
  # @param [URI::HTTP, Addressable::URI, String] url
631
- # Optional URL to create the HTTP request for.
631
+ # The URL to create the HTTP request for.
632
632
  #
633
633
  # @!macro request_kwargs
634
634
  # @!macro connect_kwargs
635
635
  #
636
- # @yield [response]
637
- # If a block is given it will be passed the received HTTP response.
638
- #
639
- # @yieldparam [Net::HTTPRresponse] response
640
- # The received HTTP response object.
641
- #
642
636
  # @return [Array<Symbol>]
643
637
  # The allowed HTTP request methods for the given URL.
644
638
  #
@@ -646,15 +640,15 @@ module Ronin
646
640
  #
647
641
  # @api public
648
642
  #
649
- def http_allowed_methods(url, ssl: nil, **kwargs,&block)
650
- Network::HTTP.allowed_methods(url, ssl: ssl, **kwargs,&block)
643
+ def http_allowed_methods(url, ssl: nil, **kwargs)
644
+ Network::HTTP.allowed_methods(url, ssl: ssl, **kwargs)
651
645
  end
652
646
 
653
647
  #
654
648
  # Performs a `PATCH` request for the given URI.
655
649
  #
656
650
  # @param [URI::HTTP, Addressable::URI, String] url
657
- # Optional URL to create the HTTP request for.
651
+ # The URL to create the HTTP request for.
658
652
  #
659
653
  # @!macro request_kwargs
660
654
  # @!macro connect_kwargs
@@ -682,7 +676,7 @@ module Ronin
682
676
  # Performs a `POST` request for the given URI.
683
677
  #
684
678
  # @param [URI::HTTP, Addressable::URI, String] url
685
- # Optional URL to create the HTTP request for.
679
+ # The URL to create the HTTP request for.
686
680
  #
687
681
  # @!macro request_kwargs
688
682
  # @!macro connect_kwargs
@@ -709,7 +703,7 @@ module Ronin
709
703
  # headers.
710
704
  #
711
705
  # @param [URI::HTTP, Addressable::URI, String] url
712
- # Optional URL to create the HTTP request for.
706
+ # The URL to create the HTTP request for.
713
707
  #
714
708
  # @!macro request_kwargs
715
709
  # @!macro connect_kwargs
@@ -732,7 +726,7 @@ module Ronin
732
726
  # response body.
733
727
  #
734
728
  # @param [URI::HTTP, Addressable::URI, String] url
735
- # Optional URL to create the HTTP request for.
729
+ # The URL to create the HTTP request for.
736
730
  #
737
731
  # @!macro request_kwargs
738
732
  # @!macro connect_kwargs
@@ -752,7 +746,7 @@ module Ronin
752
746
  # Performs a `PROPFIND` request for the given URI.
753
747
  #
754
748
  # @param [URI::HTTP, Addressable::URI, String] url
755
- # Optional URL to create the HTTP request for.
749
+ # The URL to create the HTTP request for.
756
750
  #
757
751
  # @!macro request_kwargs
758
752
  # @!macro connect_kwargs
@@ -780,7 +774,7 @@ module Ronin
780
774
  # Performs a `PROPPATCH` request for the given URI.
781
775
  #
782
776
  # @param [URI::HTTP, Addressable::URI, String] url
783
- # Optional URL to create the HTTP request for.
777
+ # The URL to create the HTTP request for.
784
778
  #
785
779
  # @!macro request_kwargs
786
780
  # @!macro connect_kwargs
@@ -808,7 +802,7 @@ module Ronin
808
802
  # Performs a `PUT` request for the given URI.
809
803
  #
810
804
  # @param [URI::HTTP, Addressable::URI, String] url
811
- # Optional URL to create the HTTP request for.
805
+ # The URL to create the HTTP request for.
812
806
  #
813
807
  # @!macro request_kwargs
814
808
  # @!macro connect_kwargs
@@ -836,7 +830,7 @@ module Ronin
836
830
  # Performs a `TRACE` request for the given URI.
837
831
  #
838
832
  # @param [URI::HTTP, Addressable::URI, String] url
839
- # Optional URL to create the HTTP request for.
833
+ # The URL to create the HTTP request for.
840
834
  #
841
835
  # @!macro request_kwargs
842
836
  # @!macro connect_kwargs
@@ -862,7 +856,7 @@ module Ronin
862
856
  # Performs a `UNLOCK` request for the given URI.
863
857
  #
864
858
  # @param [URI::HTTP, Addressable::URI, String] url
865
- # Optional URL to create the HTTP request for.
859
+ # The URL to create the HTTP request for.
866
860
  #
867
861
  # @!macro request_kwargs
868
862
  # @!macro connect_kwargs
@@ -16,7 +16,8 @@
16
16
  # along with ronin-support. If not, see <https://www.gnu.org/licenses/>.
17
17
  #
18
18
 
19
- require 'ronin/support/network/ssl/openssl'
19
+ require 'ronin/support/crypto/openssl'
20
+ require 'ronin/support/crypto/key'
20
21
  require 'ronin/support/network/ssl/local_key'
21
22
  require 'ronin/support/network/ssl/local_cert'
22
23
  require 'ronin/support/network/ssl/proxy'
@@ -148,7 +149,7 @@ module Ronin
148
149
  context.verify_mode = VERIFY[verify]
149
150
 
150
151
  if (key_file || key) && (cert_file || cert)
151
- context.key = if key_file then Crypto::Key::RSA.load_file(key_file)
152
+ context.key = if key_file then Crypto::Key.load_file(key_file)
152
153
  else key
153
154
  end
154
155
 
@@ -51,7 +51,7 @@ module Ronin
51
51
  length = string.length.to_f
52
52
  entropy = 0.0
53
53
 
54
- char_counts.each do |char,count|
54
+ char_counts.each_value do |count|
55
55
  freq = count / length
56
56
  entropy -= freq * Math.log(freq,base)
57
57
  end
@@ -19,6 +19,6 @@
19
19
  module Ronin
20
20
  module Support
21
21
  # ronin-support version
22
- VERSION = '1.0.3'
22
+ VERSION = '1.0.4'
23
23
  end
24
24
  end
data/lib/ronin/support.rb CHANGED
@@ -28,6 +28,20 @@ require 'ronin/support/text'
28
28
  require 'ronin/support/version'
29
29
 
30
30
  module Ronin
31
+ #
32
+ # Top-level namespace for `ronin-support`.
33
+ #
34
+ # ## Example
35
+ #
36
+ # require 'ronin/support'
37
+ # include Ronin::Support
38
+ #
39
+ # "hello world".base64_encode
40
+ # # => "aGVsbG8gd29ybGQ=\n"
41
+ #
42
+ # http_get 'https://example.com/'
43
+ # # => #<Net::HTTPOK 200 OK readbody=true>
44
+ #
31
45
  module Support
32
46
  include Mixin
33
47
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ronin-support
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Postmodern
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-19 00:00:00.000000000 Z
11
+ date: 2023-12-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chars