ronin-support 1.0.0.beta3 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (134) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +14 -0
  3. data/.rubocop.yml +109 -0
  4. data/ChangeLog.md +12 -1
  5. data/Gemfile +8 -4
  6. data/README.md +1 -1
  7. data/Rakefile +2 -2
  8. data/examples/ssl_proxy.rb +2 -1
  9. data/examples/tcp_proxy.rb +6 -4
  10. data/lib/ronin/support/archive/tar/writer.rb +2 -2
  11. data/lib/ronin/support/archive/tar.rb +4 -4
  12. data/lib/ronin/support/archive/zip/reader.rb +2 -2
  13. data/lib/ronin/support/binary/array.rb +4 -7
  14. data/lib/ronin/support/binary/bit_flip.rb +7 -1
  15. data/lib/ronin/support/binary/buffer.rb +22 -22
  16. data/lib/ronin/support/binary/byte_slice.rb +17 -17
  17. data/lib/ronin/support/binary/cstring.rb +7 -4
  18. data/lib/ronin/support/binary/ctypes/arch/arm/big_endian.rb +4 -0
  19. data/lib/ronin/support/binary/ctypes/arch/arm.rb +3 -0
  20. data/lib/ronin/support/binary/ctypes/arch/arm64/big_endian.rb +4 -0
  21. data/lib/ronin/support/binary/ctypes/arch/arm64.rb +3 -0
  22. data/lib/ronin/support/binary/ctypes/arch/mips/little_endian.rb +4 -0
  23. data/lib/ronin/support/binary/ctypes/arch/mips.rb +3 -0
  24. data/lib/ronin/support/binary/ctypes/arch/mips64/little_endian.rb +4 -0
  25. data/lib/ronin/support/binary/ctypes/arch/mips64.rb +3 -0
  26. data/lib/ronin/support/binary/ctypes/arch/ppc.rb +3 -0
  27. data/lib/ronin/support/binary/ctypes/arch/ppc64.rb +3 -0
  28. data/lib/ronin/support/binary/ctypes/arch/x86.rb +3 -0
  29. data/lib/ronin/support/binary/ctypes/arch/x86_64.rb +3 -0
  30. data/lib/ronin/support/binary/ctypes/array_type.rb +1 -1
  31. data/lib/ronin/support/binary/ctypes/big_endian.rb +3 -0
  32. data/lib/ronin/support/binary/ctypes/enum_type.rb +2 -2
  33. data/lib/ronin/support/binary/ctypes/little_endian.rb +3 -0
  34. data/lib/ronin/support/binary/ctypes/native.rb +3 -0
  35. data/lib/ronin/support/binary/ctypes/scalar_type.rb +2 -2
  36. data/lib/ronin/support/binary/ctypes/struct_type.rb +3 -3
  37. data/lib/ronin/support/binary/ctypes/type_resolver.rb +7 -8
  38. data/lib/ronin/support/binary/ctypes/unbounded_array_type.rb +1 -1
  39. data/lib/ronin/support/binary/ctypes/union_type.rb +3 -3
  40. data/lib/ronin/support/binary/ctypes.rb +3 -3
  41. data/lib/ronin/support/binary/memory.rb +2 -2
  42. data/lib/ronin/support/binary/packet.rb +3 -0
  43. data/lib/ronin/support/binary/stack.rb +3 -4
  44. data/lib/ronin/support/binary/struct/member.rb +5 -3
  45. data/lib/ronin/support/binary/struct.rb +81 -79
  46. data/lib/ronin/support/binary/template.rb +1 -0
  47. data/lib/ronin/support/binary/unhexdump/parser.rb +11 -11
  48. data/lib/ronin/support/binary/union.rb +22 -22
  49. data/lib/ronin/support/cli/ansi.rb +0 -1
  50. data/lib/ronin/support/cli/io_shell/core_ext/io.rb +1 -1
  51. data/lib/ronin/support/cli/io_shell.rb +4 -4
  52. data/lib/ronin/support/cli/printing.rb +3 -3
  53. data/lib/ronin/support/compression/zlib.rb +1 -1
  54. data/lib/ronin/support/core_ext/enumerable.rb +0 -2
  55. data/lib/ronin/support/core_ext/file.rb +1 -1
  56. data/lib/ronin/support/core_ext/kernel.rb +6 -5
  57. data/lib/ronin/support/core_ext/string.rb +2 -2
  58. data/lib/ronin/support/crypto/cert.rb +11 -15
  59. data/lib/ronin/support/crypto/cert_chain.rb +1 -1
  60. data/lib/ronin/support/crypto/cipher/aes.rb +3 -0
  61. data/lib/ronin/support/crypto/cipher/aes128.rb +4 -1
  62. data/lib/ronin/support/crypto/cipher/aes256.rb +4 -1
  63. data/lib/ronin/support/crypto/cipher.rb +1 -1
  64. data/lib/ronin/support/crypto/core_ext/file.rb +1 -1
  65. data/lib/ronin/support/crypto/key/methods.rb +4 -1
  66. data/lib/ronin/support/crypto/key.rb +5 -2
  67. data/lib/ronin/support/crypto/openssl.rb +1 -1
  68. data/lib/ronin/support/crypto.rb +0 -1
  69. data/lib/ronin/support/encoding/base16.rb +1 -1
  70. data/lib/ronin/support/encoding/base32.rb +28 -17
  71. data/lib/ronin/support/encoding/c/core_ext/integer.rb +1 -1
  72. data/lib/ronin/support/encoding/c.rb +4 -4
  73. data/lib/ronin/support/encoding/hex.rb +2 -2
  74. data/lib/ronin/support/encoding/js/core_ext/integer.rb +1 -1
  75. data/lib/ronin/support/encoding/js.rb +4 -4
  76. data/lib/ronin/support/encoding/powershell/core_ext/integer.rb +2 -2
  77. data/lib/ronin/support/encoding/powershell.rb +4 -5
  78. data/lib/ronin/support/encoding/ruby.rb +4 -4
  79. data/lib/ronin/support/encoding/shell/core_ext/integer.rb +2 -2
  80. data/lib/ronin/support/encoding/shell.rb +3 -3
  81. data/lib/ronin/support/encoding/sql.rb +1 -1
  82. data/lib/ronin/support/encoding/xml.rb +2 -2
  83. data/lib/ronin/support/encoding.rb +95 -0
  84. data/lib/ronin/support/network/asn/list.rb +6 -1
  85. data/lib/ronin/support/network/asn/record.rb +3 -0
  86. data/lib/ronin/support/network/asn/record_set.rb +3 -0
  87. data/lib/ronin/support/network/asn.rb +167 -6
  88. data/lib/ronin/support/network/dns/resolver.rb +3 -0
  89. data/lib/ronin/support/network/domain.rb +21 -21
  90. data/lib/ronin/support/network/email_address.rb +1 -5
  91. data/lib/ronin/support/network/esmtp/mixin.rb +1 -0
  92. data/lib/ronin/support/network/ftp/mixin.rb +1 -1
  93. data/lib/ronin/support/network/host.rb +75 -47
  94. data/lib/ronin/support/network/http/core_ext.rb +1 -1
  95. data/lib/ronin/support/network/http.rb +317 -80
  96. data/lib/ronin/support/network/ip.rb +8 -10
  97. data/lib/ronin/support/network/ip_range/cidr.rb +1 -5
  98. data/lib/ronin/support/network/ip_range/glob.rb +1 -0
  99. data/lib/ronin/support/network/ip_range/range.rb +1 -1
  100. data/lib/ronin/support/network/ip_range.rb +1 -3
  101. data/lib/ronin/support/network/proxy.rb +4 -4
  102. data/lib/ronin/support/network/public_suffix/list.rb +10 -8
  103. data/lib/ronin/support/network/public_suffix/suffix_set.rb +3 -0
  104. data/lib/ronin/support/network/public_suffix.rb +9 -4
  105. data/lib/ronin/support/network/smtp/email.rb +0 -9
  106. data/lib/ronin/support/network/smtp/mixin.rb +2 -2
  107. data/lib/ronin/support/network/ssl/local_cert.rb +1 -3
  108. data/lib/ronin/support/network/ssl/mixin.rb +13 -13
  109. data/lib/ronin/support/network/ssl/openssl.rb +1 -1
  110. data/lib/ronin/support/network/ssl/proxy.rb +14 -16
  111. data/lib/ronin/support/network/ssl.rb +4 -2
  112. data/lib/ronin/support/network/tcp/proxy.rb +3 -3
  113. data/lib/ronin/support/network/tcp.rb +10 -12
  114. data/lib/ronin/support/network/telnet/mixin.rb +14 -14
  115. data/lib/ronin/support/network/tld/list.rb +2 -1
  116. data/lib/ronin/support/network/tld.rb +7 -4
  117. data/lib/ronin/support/network/tls/proxy.rb +1 -1
  118. data/lib/ronin/support/network/tls.rb +0 -2
  119. data/lib/ronin/support/network/udp/proxy.rb +5 -5
  120. data/lib/ronin/support/network/udp.rb +14 -16
  121. data/lib/ronin/support/path.rb +3 -3
  122. data/lib/ronin/support/text/erb/mixin.rb +3 -0
  123. data/lib/ronin/support/text/homoglyph/table.rb +3 -3
  124. data/lib/ronin/support/text/patterns/credentials.rb +2 -2
  125. data/lib/ronin/support/text/patterns/crypto.rb +1 -1
  126. data/lib/ronin/support/text/patterns/file_system.rb +3 -4
  127. data/lib/ronin/support/text/patterns/network.rb +10 -10
  128. data/lib/ronin/support/text/patterns/numeric.rb +1 -1
  129. data/lib/ronin/support/text/patterns/source_code.rb +2 -2
  130. data/lib/ronin/support/text/random.rb +2 -2
  131. data/lib/ronin/support/text/typo/generator.rb +2 -2
  132. data/lib/ronin/support/version.rb +1 -1
  133. data/ronin-support.gemspec +6 -5
  134. metadata +3 -2
@@ -37,10 +37,10 @@ module Ronin
37
37
  # ### Defining Members
38
38
  #
39
39
  # class Point < Ronin::Support::Binary::Struct
40
- #
40
+ #
41
41
  # member :x, :int32
42
42
  # member :y, :int32
43
- #
43
+ #
44
44
  # end
45
45
  #
46
46
  # ### Initializing Structs
@@ -69,10 +69,10 @@ module Ronin
69
69
  # ### Packing Structs
70
70
  #
71
71
  # class Point < Ronin::Support::Binary::Struct
72
- #
72
+ #
73
73
  # member :x, :int32
74
74
  # member :y, :int32
75
- #
75
+ #
76
76
  # end
77
77
  #
78
78
  # point = Point.new(x: 10, y: -1)
@@ -82,12 +82,12 @@ module Ronin
82
82
  # ### Unpacking Structs
83
83
  #
84
84
  # class Point < Ronin::Support::Binary::Struct
85
- #
85
+ #
86
86
  # member :x, :int32
87
87
  # member :y, :int32
88
- #
88
+ #
89
89
  # end
90
- #
90
+ #
91
91
  # point = Point.unpack("\x00\x00\x00\x01\xFF\xFF\xFF\xFF")
92
92
  # point.x
93
93
  # # => 1
@@ -95,30 +95,30 @@ module Ronin
95
95
  # # => -1
96
96
  #
97
97
  # ### Inheriting Structs
98
- #
98
+ #
99
99
  # class Point < Ronin::Support::Binary::Struct
100
- #
100
+ #
101
101
  # member :x, :int32
102
102
  # member :y, :int32
103
- #
103
+ #
104
104
  # end
105
- #
105
+ #
106
106
  # class Point3D < Point
107
- #
107
+ #
108
108
  # member :z, :int32
109
109
  #
110
110
  # end
111
- #
111
+ #
112
112
  # point = Point.new(x: 100, y: 42)
113
113
  # point3d = Point3D.new(x: 100, y: 42, z: -1)
114
114
  #
115
115
  # ### Array Fields
116
116
  #
117
117
  # class MyStruct < Ronin::Support::Binary::Struct
118
- #
118
+ #
119
119
  # member :x, :uint32
120
120
  # member :nums, [:uint8, 10]
121
- #
121
+ #
122
122
  # end
123
123
  #
124
124
  # struct = MyStruct.new
@@ -129,12 +129,12 @@ module Ronin
129
129
  # ### Unbounded Array Fields
130
130
  #
131
131
  # class MyStruct < Ronin::Support::Binary::Struct
132
- #
132
+ #
133
133
  # member :length, :uint32
134
134
  # member :payload, (:uint8..)
135
- #
135
+ #
136
136
  # end
137
- #
137
+ #
138
138
  # struct = MyStruct.new
139
139
  # struct.payload = [0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08]
140
140
  # struct.pack
@@ -143,14 +143,14 @@ module Ronin
143
143
  # ### Struct Endianness
144
144
  #
145
145
  # class MyStruct < Ronin::Support::Binary::Struct
146
- #
146
+ #
147
147
  # platform endian: :big
148
- #
148
+ #
149
149
  # member :x, :uint32
150
150
  # member :y, :uint32
151
- #
151
+ #
152
152
  # end
153
- #
153
+ #
154
154
  # struct = MyStruct.new
155
155
  # struct.x = 0xAABB
156
156
  # struct.y = 0xCCDD
@@ -160,13 +160,13 @@ module Ronin
160
160
  # ### Struct Architecture
161
161
  #
162
162
  # class MyStruct < Ronin::Support::Binary::Struct
163
- #
163
+ #
164
164
  # platform arch: :arm64_be
165
- #
165
+ #
166
166
  # member :x, :int
167
167
  # member :y, :int
168
168
  # member :f, :double
169
- #
169
+ #
170
170
  # end
171
171
  #
172
172
  # struct = MyStruct.new
@@ -177,16 +177,16 @@ module Ronin
177
177
  # # => "\x00\x00\x00d\xFF\xFF\xFF\x9C@<\xA5\xDC\x1Ac\xC1\xF8"
178
178
  #
179
179
  # ### Struct Operating System (OS)
180
- #
180
+ #
181
181
  # class MyStruct < Ronin::Support::Binary::Struct
182
- #
182
+ #
183
183
  # platform arch: :x86_64, os: :windows
184
- #
184
+ #
185
185
  # member :x, :long
186
186
  # member :y, :long
187
- #
187
+ #
188
188
  # end
189
- #
189
+ #
190
190
  # struct = MyStruct.new
191
191
  # struct.x = 255
192
192
  # struct.y = -1
@@ -196,20 +196,20 @@ module Ronin
196
196
  # ### Struct Alignment
197
197
  #
198
198
  # class Pixel < Ronin::Support::Binary::Struct
199
- #
199
+ #
200
200
  # align 4
201
- #
201
+ #
202
202
  # member :r, :uint8
203
203
  # member :g, :uint8
204
204
  # member :b, :uint8
205
- #
205
+ #
206
206
  # end
207
207
  #
208
208
  # class PixelBuf < Ronin::Support::Binary::Struct
209
- #
209
+ #
210
210
  # member :count, :uint8
211
211
  # member :pixels, [Pixel, 255]
212
- #
212
+ #
213
213
  # end
214
214
  #
215
215
  # pixelbuf = PixelBuf.new
@@ -226,12 +226,12 @@ module Ronin
226
226
  # ### Disable Struct Padding
227
227
  #
228
228
  # class MyStruct < Ronin::Support::Binary::Struct
229
- #
229
+ #
230
230
  # padding false
231
- #
231
+ #
232
232
  # member :c, :char
233
233
  # member :i, :int32
234
- #
234
+ #
235
235
  # end
236
236
  #
237
237
  # struct = MyStruct.new
@@ -259,13 +259,13 @@ module Ronin
259
259
  #
260
260
  # @example Initiializing a new struct from a buffer:
261
261
  # class MyStruct < Ronin::Support::Binary::Struct
262
- #
262
+ #
263
263
  # member :x, :uint32
264
264
  # member :f, :double
265
265
  # member :nums, [:uint8, 10]
266
- #
266
+ #
267
267
  # end
268
- #
268
+ #
269
269
  # struct = MyStruct.new("\x01\x00\x00\x00\x00\x00\x00\x00333333\xD3?\x01\x02\x03\x00\x00\x00\x00\x00\x00\x00")
270
270
  # struct.x
271
271
  # # => 1
@@ -328,12 +328,12 @@ module Ronin
328
328
  #
329
329
  # @example
330
330
  # class MyStruct < Ronin::Support::Binary::Struct
331
- #
331
+ #
332
332
  # member :x, :uint32
333
333
  # member :y, :uint32
334
- #
334
+ #
335
335
  # end
336
- #
336
+ #
337
337
  # MyStruct.size
338
338
  # # => 8
339
339
  #
@@ -412,13 +412,13 @@ module Ronin
412
412
  #
413
413
  # @example
414
414
  # class MyStruct < Ronin::Support::Binary::Struct
415
- #
415
+ #
416
416
  # member :x, :uint32
417
417
  # member :f, :double
418
418
  # member :nums, [:uint8, 10]
419
- #
419
+ #
420
420
  # end
421
- #
421
+ #
422
422
  # MyStruct.pack(x: 1, f: 0.3, nums: [1,2,3])
423
423
  # # => "\x01\x00\x00\x00\x00\x00\x00\x00333333\xD3?\x01\x02\x03\x00\x00\x00\x00\x00\x00\x00"
424
424
  #
@@ -439,13 +439,13 @@ module Ronin
439
439
  #
440
440
  # @example
441
441
  # class MyStruct < Ronin::Support::Binary::Struct
442
- #
442
+ #
443
443
  # member :x, :uint32
444
444
  # member :f, :double
445
445
  # member :nums, [:uint8, 10]
446
- #
446
+ #
447
447
  # end
448
- #
448
+ #
449
449
  # struct = MyStruct.unpack("\x01\x00\x00\x00\x00\x00\x00\x00333333\xD3?\x01\x02\x03\x00\x00\x00\x00\x00\x00\x00")
450
450
  #
451
451
  # @api public
@@ -465,13 +465,13 @@ module Ronin
465
465
  #
466
466
  # @example
467
467
  # class MyStruct < Ronin::Support::Binary::Struct
468
- #
468
+ #
469
469
  # member :x, :uint32
470
470
  # member :f, :double
471
471
  # member :nums, [:uint8, 10]
472
- #
472
+ #
473
473
  # end
474
- #
474
+ #
475
475
  # file = File.new('binary.dat','b')
476
476
  # struct = MyStruct.read_from(file)
477
477
  #
@@ -480,7 +480,7 @@ module Ronin
480
480
  # @api public
481
481
  #
482
482
  def self.read_from(io)
483
- new().read_from(io)
483
+ new.read_from(io)
484
484
  end
485
485
 
486
486
  #
@@ -497,13 +497,13 @@ module Ronin
497
497
  #
498
498
  # @example
499
499
  # class MyStruct < Ronin::Support::Binary::Struct
500
- #
500
+ #
501
501
  # member :x, :uint32
502
502
  # member :f, :double
503
503
  # member :nums, [:uint8, 10]
504
- #
504
+ #
505
505
  # end
506
- #
506
+ #
507
507
  # struct = MyStruct.new("\x01\x00\x00\x00\x00\x00\x00\x00333333\xD3?\x01\x02\x03\x00\x00\x00\x00\x00\x00\x00")
508
508
  # struct[:x]
509
509
  # # => 1
@@ -519,15 +519,21 @@ module Ronin
519
519
  case member.type
520
520
  when CTypes::UnboundedArrayType
521
521
  # XXX: but how do we handle an unbounded array of structs?
522
- @cache[name] ||= (
523
- slice = byteslice(member.offset,size - member.offset)
524
- Binary::Array.new(member.type.type,slice)
525
- )
522
+ @cache[name] ||= begin
523
+ offset = member.offset
524
+ length = size - member.offset
525
+ slice = byteslice(offset,length)
526
+
527
+ Binary::Array.new(member.type.type,slice)
528
+ end
526
529
  when CTypes::ObjectType
527
- @cache[name] ||= (
528
- slice = byteslice(member.offset,member.type.size)
529
- member.type.unpack(slice)
530
- )
530
+ @cache[name] ||= begin
531
+ offset = member.offset
532
+ length = member.type.size
533
+ slice = byteslice(offset,length)
534
+
535
+ member.type.unpack(slice)
536
+ end
531
537
  else
532
538
  data = super(member.offset,member.type.size)
533
539
  member.type.unpack(data)
@@ -554,13 +560,13 @@ module Ronin
554
560
  #
555
561
  # @example
556
562
  # class MyStruct < Ronin::Support::Binary::Struct
557
- #
563
+ #
558
564
  # member :x, :uint32
559
565
  # member :f, :double
560
566
  # member :nums, [:uint8, 10]
561
- #
567
+ #
562
568
  # end
563
- #
569
+ #
564
570
  # struct = MyStruct.new
565
571
  # struct[:x] = 1
566
572
  # struct[:x]
@@ -606,7 +612,7 @@ module Ronin
606
612
  def each(&block)
607
613
  return enum_for(__method__) unless block_given?
608
614
 
609
- @type.members.each_key do |name|
615
+ @type.members.each_key do |name|
610
616
  yield name, self[name]
611
617
  end
612
618
  end
@@ -620,9 +626,7 @@ module Ronin
620
626
  # @api public
621
627
  #
622
628
  def to_h
623
- Hash[@type.members.keys.map { |name|
624
- [name, self[name]]
625
- }]
629
+ each.to_h
626
630
  end
627
631
 
628
632
  #
@@ -634,9 +638,7 @@ module Ronin
634
638
  # @api public
635
639
  #
636
640
  def to_a
637
- @type.members.keys.map do |name|
638
- self[name]
639
- end
641
+ each.map { |name,value| value }
640
642
  end
641
643
 
642
644
  extend CTypes::Mixin
@@ -755,7 +757,7 @@ module Ronin
755
757
  # @api semipublic
756
758
  #
757
759
  def self.type_resolver
758
- @resolver ||= CTypes::TypeResolver.new(type_system)
760
+ @type_resolver ||= CTypes::TypeResolver.new(type_system)
759
761
  end
760
762
 
761
763
  #
@@ -771,7 +773,7 @@ module Ronin
771
773
  # class MyStruct < Ronin::Support::Binary::Struct
772
774
  # member :x, :uint32
773
775
  # end
774
- #
776
+ #
775
777
  # struct = MyStruct.new
776
778
  # struct.x = 0x11223344
777
779
  #
@@ -779,7 +781,7 @@ module Ronin
779
781
  # class MyStruct < Ronin::Support::Binary::Struct
780
782
  # member :nums, [:uint32, 10]
781
783
  # end
782
- #
784
+ #
783
785
  # struct = MyStruct.new
784
786
  # struct.x = [0x11111111, 0x22222222, 0x33333333, 0x44444444]
785
787
  #
@@ -787,7 +789,7 @@ module Ronin
787
789
  # class MyStruct < Ronin::Support::Binary::Struct
788
790
  # member :payload, :uint8..
789
791
  # end
790
- #
792
+ #
791
793
  # struct = MyStruct.new
792
794
  # struct.payloads = [0x1, 0x2, 0x3, 0x4]
793
795
  #
@@ -151,6 +151,7 @@ module Ronin
151
151
 
152
152
  @fields = []
153
153
  @types = []
154
+
154
155
  @pack_string = String.new
155
156
 
156
157
  fields.each do |field|
@@ -46,9 +46,7 @@ module Ronin
46
46
  )
47
47
 
48
48
  # Visible characters
49
- VISIBLE_CHARS = Hash[
50
- Chars::VISIBLE.chars.sort.zip(Chars::VISIBLE.bytes.sort)
51
- ]
49
+ VISIBLE_CHARS = Chars::VISIBLE.chars.sort.zip(Chars::VISIBLE.bytes.sort).to_h
52
50
 
53
51
  # Escaped characters
54
52
  CHARS = {
@@ -261,7 +259,7 @@ module Ronin
261
259
  case @type
262
260
  when CTypes::CharType
263
261
  @base = 8
264
- @chars = CHARS
262
+ @chars = CHARS
265
263
  end
266
264
  end
267
265
 
@@ -310,6 +308,8 @@ module Ronin
310
308
  starts_repeating_at = previous_address + previous_row_size
311
309
  else
312
310
  address, row = parse_line(line)
311
+
312
+ # remember the first address
313
313
  first_address ||= address
314
314
 
315
315
  if previous_row_repeats
@@ -317,8 +317,8 @@ module Ronin
317
317
  range = starts_repeating_at...address
318
318
  addresses = range.step(previous_row_size)
319
319
 
320
- addresses.each do |address|
321
- yield address, previous_row
320
+ addresses.each do |next_address|
321
+ yield next_address, previous_row
322
322
  end
323
323
 
324
324
  previous_row_repeats = false
@@ -368,7 +368,6 @@ module Ronin
368
368
  buffer = String.new(encoding: Encoding::ASCII_8BIT)
369
369
 
370
370
  length = parse(hexdump) do |address,row|
371
- first_address ||= address
372
371
  buffer << pack(row)
373
372
  end
374
373
 
@@ -385,7 +384,7 @@ module Ronin
385
384
  # The parsed address.
386
385
  #
387
386
  # @api private
388
- #
387
+ #
389
388
  def parse_address(address)
390
389
  address.to_i(@address_base)
391
390
  end
@@ -400,7 +399,7 @@ module Ronin
400
399
  # The parsed Integer.
401
400
  #
402
401
  # @api private
403
- #
402
+ #
404
403
  def parse_int(string)
405
404
  string.to_i(@base)
406
405
  end
@@ -415,7 +414,7 @@ module Ronin
415
414
  # The parsed integer or byte value of the character.
416
415
  #
417
416
  def parse_char_or_int(string)
418
- @chars.fetch(string) do |string|
417
+ @chars.fetch(string) do
419
418
  string.to_i(@base)
420
419
  end
421
420
  end
@@ -459,6 +458,7 @@ module Ronin
459
458
  end
460
459
  else
461
460
  address, *numbers = line.split
461
+
462
462
  address = parse_address(address)
463
463
  numbers.map!(&@parse_method)
464
464
 
@@ -480,7 +480,7 @@ module Ronin
480
480
  # The packed segment.
481
481
  #
482
482
  # @api private
483
- #
483
+ #
484
484
  def pack(values)
485
485
  values.pack(@type.pack_string * values.length)
486
486
  end
@@ -37,7 +37,7 @@ module Ronin
37
37
  # member :c, :char
38
38
  # member :i, :int16
39
39
  # member :u, :uint32
40
- #
40
+ #
41
41
  # end
42
42
  #
43
43
  # ### Initializing Fields
@@ -54,19 +54,19 @@ module Ronin
54
54
  # member :c, :char
55
55
  # member :i, :int16
56
56
  # member :u, :uint32
57
- #
57
+ #
58
58
  # end
59
- #
59
+ #
60
60
  # class MyUnion2 < MyUnion
61
- #
61
+ #
62
62
  # member :f, :float32
63
63
  # member :d, :float64
64
- #
64
+ #
65
65
  # end
66
- #
66
+ #
67
67
  # union = MyUnion.new
68
68
  # union.i = -1
69
- #
69
+ #
70
70
  # union2 = MyUnion.new
71
71
  # union2.i = -1
72
72
  # union2.d = 1.123
@@ -74,13 +74,13 @@ module Ronin
74
74
  # ### Packing Unions
75
75
  #
76
76
  # class MyUnion < Ronin::Support::Binary::Union
77
- #
77
+ #
78
78
  # member :c, :char
79
79
  # member :i, :int16
80
80
  # member :u, :uint32
81
- #
81
+ #
82
82
  # end
83
- #
83
+ #
84
84
  # union = MyUnion.new
85
85
  # union.u = 0x11111111
86
86
  # union.i = -1
@@ -90,13 +90,13 @@ module Ronin
90
90
  # ### Unpacking Unions
91
91
  #
92
92
  # class MyUnion < Ronin::Support::Binary::Union
93
- #
93
+ #
94
94
  # member :c, :char
95
95
  # member :i, :int32
96
96
  # member :u, :uint32
97
- #
97
+ #
98
98
  # end
99
- #
99
+ #
100
100
  # union = MyUnion.unpack("\xFF\xFF\x11\x11")
101
101
  # union.c
102
102
  # # => "\xFF"
@@ -108,12 +108,12 @@ module Ronin
108
108
  # ### Array Fields
109
109
  #
110
110
  # class MyUnion < Ronin::Support::Binary::Union
111
- #
111
+ #
112
112
  # member :c, :char
113
113
  # member :i, :int16
114
114
  # member :u, :uint32
115
115
  # member :nums, [:uint8, 10]
116
- #
116
+ #
117
117
  # end
118
118
  #
119
119
  # union = MyUnion.new
@@ -124,14 +124,14 @@ module Ronin
124
124
  # ### Unbounded Array Fields
125
125
  #
126
126
  # class MyUnion < Ronin::Support::Binary::Union
127
- #
127
+ #
128
128
  # member :c, :char
129
129
  # member :i, :int16
130
130
  # member :u, :uint32
131
131
  # member :payload, (:uint8..)
132
- #
132
+ #
133
133
  # end
134
- #
134
+ #
135
135
  # union = MyUnion.new
136
136
  # union.payload = [0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08]
137
137
  # union.pack
@@ -140,15 +140,15 @@ module Ronin
140
140
  # ### Default Endianness
141
141
  #
142
142
  # class MyUnion < Ronin::Support::Binary::Union
143
- #
143
+ #
144
144
  # endian :big
145
- #
145
+ #
146
146
  # member :c, :char
147
147
  # member :i, :int32
148
148
  # member :u, :uint32
149
- #
149
+ #
150
150
  # end
151
- #
151
+ #
152
152
  # union = MyUnion.new(u: 0xaabbccdd)
153
153
  # union.pack
154
154
  # # => "\xAA\xBB\xCC\xDD"
@@ -323,7 +323,6 @@ module Ronin
323
323
  end
324
324
  end
325
325
  end
326
-
327
326
  end
328
327
  end
329
328
  end
@@ -40,7 +40,7 @@ class IO
40
40
  # # NOTICE AUTH :*** Checking Ident
41
41
  # # NOTICE AUTH :*** Found your hostname
42
42
  # # NOTICE AUTH :*** No ident response
43
- # # USER test_ruby * * *
43
+ # # USER test_ruby * * *
44
44
  # # NICK test_ruby
45
45
  # # PING :3167790481
46
46
  # # PONG 3167790481
@@ -34,7 +34,7 @@ module Ronin
34
34
  # NOTICE AUTH :*** Checking Ident
35
35
  # NOTICE AUTH :*** Found your hostname
36
36
  # NOTICE AUTH :*** No ident response
37
- # USER test_ruby * * *
37
+ # USER test_ruby * * *
38
38
  # NICK test_ruby
39
39
  # PING :3167790481
40
40
  # PONG 3167790481
@@ -123,7 +123,7 @@ module Ronin
123
123
  io_array = [@io, @stdin]
124
124
 
125
125
  loop do
126
- readable, writable, errors = IO.select(io_array,nil,io_array)
126
+ readable, _writable, errors = IO.select(io_array,nil,io_array)
127
127
 
128
128
  if errors.include?(@io) || errors.include?(@stdin)
129
129
  return false
@@ -132,7 +132,7 @@ module Ronin
132
132
  if readable.include?(@io)
133
133
  data = begin
134
134
  @io.readpartial(4096)
135
- rescue EOFError => error
135
+ rescue EOFError
136
136
  return false
137
137
  end
138
138
 
@@ -142,7 +142,7 @@ module Ronin
142
142
  if readable.include?(@stdin)
143
143
  data = begin
144
144
  @stdin.readpartial(4096)
145
- rescue EOFError => error
145
+ rescue EOFError
146
146
  return true
147
147
  end
148
148