ronin-support 1.0.0 → 1.0.2
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 +4 -4
- data/.github/workflows/ruby.yml +14 -0
- data/.rubocop.yml +109 -0
- data/ChangeLog.md +33 -1
- data/Gemfile +8 -4
- data/README.md +1 -1
- data/Rakefile +2 -2
- data/examples/ssl_proxy.rb +2 -1
- data/examples/tcp_proxy.rb +6 -4
- data/lib/ronin/support/archive/core_ext/file.rb +43 -0
- data/lib/ronin/support/archive/core_ext.rb +1 -1
- data/lib/ronin/support/archive/tar/writer.rb +2 -2
- data/lib/ronin/support/archive/tar.rb +4 -4
- data/lib/ronin/support/archive/zip/reader.rb +2 -2
- data/lib/ronin/support/binary/array.rb +5 -8
- data/lib/ronin/support/binary/bit_flip.rb +7 -1
- data/lib/ronin/support/binary/buffer.rb +25 -25
- data/lib/ronin/support/binary/byte_slice.rb +17 -17
- data/lib/ronin/support/binary/core_ext.rb +2 -0
- data/lib/ronin/support/binary/cstring.rb +50 -4
- data/lib/ronin/support/binary/ctypes/arch/arm/big_endian.rb +4 -0
- data/lib/ronin/support/binary/ctypes/arch/arm.rb +3 -0
- data/lib/ronin/support/binary/ctypes/arch/arm64/big_endian.rb +4 -0
- data/lib/ronin/support/binary/ctypes/arch/arm64.rb +3 -0
- data/lib/ronin/support/binary/ctypes/arch/mips/little_endian.rb +4 -0
- data/lib/ronin/support/binary/ctypes/arch/mips.rb +3 -0
- data/lib/ronin/support/binary/ctypes/arch/mips64/little_endian.rb +4 -0
- data/lib/ronin/support/binary/ctypes/arch/mips64.rb +3 -0
- data/lib/ronin/support/binary/ctypes/arch/ppc.rb +3 -0
- data/lib/ronin/support/binary/ctypes/arch/ppc64.rb +3 -0
- data/lib/ronin/support/binary/ctypes/arch/x86.rb +3 -0
- data/lib/ronin/support/binary/ctypes/arch/x86_64.rb +3 -0
- data/lib/ronin/support/binary/ctypes/array_type.rb +2 -2
- data/lib/ronin/support/binary/ctypes/big_endian.rb +3 -0
- data/lib/ronin/support/binary/ctypes/enum_type.rb +2 -2
- data/lib/ronin/support/binary/ctypes/little_endian.rb +3 -0
- data/lib/ronin/support/binary/ctypes/native.rb +3 -0
- data/lib/ronin/support/binary/ctypes/os/bsd.rb +1 -1
- data/lib/ronin/support/binary/ctypes/scalar_type.rb +2 -2
- data/lib/ronin/support/binary/ctypes/struct_type.rb +3 -3
- data/lib/ronin/support/binary/ctypes/type_resolver.rb +7 -8
- data/lib/ronin/support/binary/ctypes/unbounded_array_type.rb +2 -2
- data/lib/ronin/support/binary/ctypes/union_type.rb +3 -3
- data/lib/ronin/support/binary/ctypes.rb +3 -3
- data/lib/ronin/support/binary/memory.rb +2 -2
- data/lib/ronin/support/binary/packet.rb +80 -0
- data/lib/ronin/support/binary/stack.rb +6 -7
- data/lib/ronin/support/binary/struct/member.rb +5 -3
- data/lib/ronin/support/binary/struct.rb +81 -79
- data/lib/ronin/support/binary/template.rb +2 -5
- data/lib/ronin/support/binary/unhexdump/parser.rb +11 -11
- data/lib/ronin/support/binary/union.rb +22 -22
- data/lib/ronin/support/binary.rb +1 -0
- data/lib/ronin/support/cli/ansi.rb +0 -1
- data/lib/ronin/support/cli/io_shell/core_ext/io.rb +1 -1
- data/lib/ronin/support/cli/io_shell.rb +4 -4
- data/lib/ronin/support/cli/printing.rb +3 -3
- data/lib/ronin/support/compression/core_ext/file.rb +16 -0
- data/lib/ronin/support/compression/zlib.rb +1 -1
- data/lib/ronin/support/core_ext/enumerable.rb +0 -2
- data/lib/ronin/support/core_ext/file.rb +1 -1
- data/lib/ronin/support/core_ext/kernel.rb +6 -9
- data/lib/ronin/support/core_ext/string.rb +2 -2
- data/lib/ronin/support/crypto/cert.rb +11 -15
- data/lib/ronin/support/crypto/cert_chain.rb +1 -1
- data/lib/ronin/support/crypto/cipher/aes.rb +3 -0
- data/lib/ronin/support/crypto/cipher/aes128.rb +4 -1
- data/lib/ronin/support/crypto/cipher/aes256.rb +4 -1
- data/lib/ronin/support/crypto/cipher.rb +1 -1
- data/lib/ronin/support/crypto/core_ext/file.rb +33 -1
- data/lib/ronin/support/crypto/core_ext/string.rb +34 -2
- data/lib/ronin/support/crypto/key/methods.rb +4 -1
- data/lib/ronin/support/crypto/key.rb +5 -2
- data/lib/ronin/support/crypto/openssl.rb +1 -1
- data/lib/ronin/support/crypto.rb +0 -1
- data/lib/ronin/support/encoding/base16.rb +2 -2
- data/lib/ronin/support/encoding/base32.rb +29 -18
- data/lib/ronin/support/encoding/c/core_ext/integer.rb +1 -1
- data/lib/ronin/support/encoding/c/core_ext/string.rb +1 -1
- data/lib/ronin/support/encoding/c.rb +6 -6
- data/lib/ronin/support/encoding/core_ext/string.rb +2 -2
- data/lib/ronin/support/encoding/hex/core_ext/string.rb +1 -1
- data/lib/ronin/support/encoding/hex.rb +4 -4
- data/lib/ronin/support/encoding/js/core_ext/integer.rb +1 -1
- data/lib/ronin/support/encoding/js.rb +5 -5
- data/lib/ronin/support/encoding/powershell/core_ext/integer.rb +2 -2
- data/lib/ronin/support/encoding/powershell.rb +5 -6
- data/lib/ronin/support/encoding/quoted_printable.rb +3 -1
- data/lib/ronin/support/encoding/ruby.rb +5 -5
- data/lib/ronin/support/encoding/shell/core_ext/integer.rb +2 -2
- data/lib/ronin/support/encoding/shell.rb +3 -3
- data/lib/ronin/support/encoding/sql.rb +1 -1
- data/lib/ronin/support/encoding/uuencoding.rb +3 -1
- data/lib/ronin/support/encoding/xml.rb +3 -3
- data/lib/ronin/support/encoding.rb +95 -0
- data/lib/ronin/support/network/asn/list.rb +6 -1
- data/lib/ronin/support/network/asn/record.rb +3 -0
- data/lib/ronin/support/network/asn/record_set.rb +3 -0
- data/lib/ronin/support/network/asn.rb +167 -6
- data/lib/ronin/support/network/dns/mixin.rb +2 -10
- data/lib/ronin/support/network/dns/resolver.rb +3 -0
- data/lib/ronin/support/network/domain.rb +21 -21
- data/lib/ronin/support/network/email_address.rb +1 -5
- data/lib/ronin/support/network/esmtp/mixin.rb +1 -0
- data/lib/ronin/support/network/ftp/mixin.rb +1 -1
- data/lib/ronin/support/network/host.rb +75 -47
- data/lib/ronin/support/network/http/core_ext/uri/http.rb +8 -0
- data/lib/ronin/support/network/http/core_ext.rb +1 -1
- data/lib/ronin/support/network/http.rb +317 -80
- data/lib/ronin/support/network/ip.rb +49 -23
- data/lib/ronin/support/network/ip_range/cidr.rb +1 -5
- data/lib/ronin/support/network/ip_range/glob.rb +1 -0
- data/lib/ronin/support/network/ip_range/range.rb +1 -1
- data/lib/ronin/support/network/ip_range.rb +5 -7
- data/lib/ronin/support/network/proxy.rb +4 -4
- data/lib/ronin/support/network/public_suffix/list.rb +10 -8
- data/lib/ronin/support/network/public_suffix/suffix_set.rb +3 -0
- data/lib/ronin/support/network/public_suffix.rb +9 -4
- data/lib/ronin/support/network/smtp/email.rb +0 -9
- data/lib/ronin/support/network/smtp/mixin.rb +2 -2
- data/lib/ronin/support/network/ssl/local_cert.rb +1 -3
- data/lib/ronin/support/network/ssl/mixin.rb +13 -13
- data/lib/ronin/support/network/ssl/openssl.rb +1 -1
- data/lib/ronin/support/network/ssl/proxy.rb +14 -16
- data/lib/ronin/support/network/ssl.rb +4 -2
- data/lib/ronin/support/network/tcp/proxy.rb +3 -3
- data/lib/ronin/support/network/tcp.rb +10 -12
- data/lib/ronin/support/network/telnet/mixin.rb +14 -14
- data/lib/ronin/support/network/tld/list.rb +2 -1
- data/lib/ronin/support/network/tld.rb +7 -4
- data/lib/ronin/support/network/tls/proxy.rb +1 -1
- data/lib/ronin/support/network/tls.rb +0 -2
- data/lib/ronin/support/network/udp/proxy.rb +5 -5
- data/lib/ronin/support/network/udp.rb +14 -16
- data/lib/ronin/support/path.rb +4 -4
- data/lib/ronin/support/text/erb/mixin.rb +3 -0
- data/lib/ronin/support/text/homoglyph/core_ext/string.rb +33 -0
- data/lib/ronin/support/text/homoglyph/table.rb +3 -3
- data/lib/ronin/support/text/patterns/credentials.rb +2 -2
- data/lib/ronin/support/text/patterns/crypto.rb +1 -1
- data/lib/ronin/support/text/patterns/file_system.rb +3 -4
- data/lib/ronin/support/text/patterns/network.rb +21 -21
- data/lib/ronin/support/text/patterns/numeric.rb +1 -1
- data/lib/ronin/support/text/patterns/source_code.rb +2 -2
- data/lib/ronin/support/text/random/mixin.rb +17 -17
- data/lib/ronin/support/text/random.rb +25 -25
- data/lib/ronin/support/text/typo/core_ext/string.rb +24 -0
- data/lib/ronin/support/text/typo/generator.rb +2 -2
- data/lib/ronin/support/version.rb +1 -1
- data/ronin-support.gemspec +6 -5
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e7362a5af595979050611362ff0d48ace6148032006e9f05e9d90976b44487c
|
4
|
+
data.tar.gz: a6c6277a8af8169bf8fb374782b65169ae460c8cd6f4cac28a0c82d7ce7648b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f927d978f7af471f00bac7b97cc2bc9244df4b04683af3f6ce89ae6988d8f09cf7b28c16422673414a55b2711c9db05695afa0ffae35b1889b0c35117b7597fa
|
7
|
+
data.tar.gz: 519478e67e3fd01efa02d800d4badb66ce21a867165f300d4310e5a2a4411614ecacd7292c8095b8cef3ae444306b4402cf96e54fb5054f9d4eeb3d19350a335
|
data/.github/workflows/ruby.yml
CHANGED
@@ -26,3 +26,17 @@ jobs:
|
|
26
26
|
run: bundle install --jobs 4 --retry 3
|
27
27
|
- name: Run tests
|
28
28
|
run: bundle exec rake test
|
29
|
+
|
30
|
+
# rubocop linting
|
31
|
+
rubocop:
|
32
|
+
runs-on: ubuntu-latest
|
33
|
+
steps:
|
34
|
+
- uses: actions/checkout@v2
|
35
|
+
- name: Set up Ruby
|
36
|
+
uses: ruby/setup-ruby@v1
|
37
|
+
with:
|
38
|
+
ruby-version: 3.0
|
39
|
+
- name: Install dependencies
|
40
|
+
run: bundle install --jobs 4 --retry 3
|
41
|
+
- name: Run rubocop
|
42
|
+
run: bundle exec rubocop --parallel
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
AllCops:
|
2
|
+
NewCops: enable
|
3
|
+
SuggestExtensions: false
|
4
|
+
TargetRubyVersion: 3.1
|
5
|
+
|
6
|
+
inherit_gem:
|
7
|
+
rubocop-ronin: rubocop.yml
|
8
|
+
|
9
|
+
Style/CommentedKeyword: { Enabled: false }
|
10
|
+
Style/ArgumentsForwarding: { Enabled: false }
|
11
|
+
Style/WhileUntilModifier: { Enabled: false }
|
12
|
+
|
13
|
+
#
|
14
|
+
# ronin-support specific exceptions
|
15
|
+
#
|
16
|
+
|
17
|
+
# it makes sense to use octal numbers when testing the file's mode
|
18
|
+
Style/NumericLiteralPrefix:
|
19
|
+
Exclude:
|
20
|
+
- 'lib/ronin/support/archive/tar/writer.rb'
|
21
|
+
- 'lib/ronin/support/network/ssl/local_key.rb'
|
22
|
+
- 'lib/ronin/support/network/ssl/local_cert.rb'
|
23
|
+
- 'spec/archive/tar/writer_spec.rb'
|
24
|
+
- 'spec/network/ssl/local_cert_spec.rb'
|
25
|
+
- 'spec/network/ssl/local_key_spec.rb'
|
26
|
+
|
27
|
+
# in certain specs we need to use an empty block
|
28
|
+
Lint/EmptyBlock:
|
29
|
+
Exclude:
|
30
|
+
- 'spec/archive/zip/reader_spec.rb'
|
31
|
+
- 'spec/network/proxy_spec.rb'
|
32
|
+
|
33
|
+
Lint/RaiseException:
|
34
|
+
Exclude:
|
35
|
+
- 'spec/core_ext/kernel_spec.rb'
|
36
|
+
|
37
|
+
# the arrays of Floats need to be organized into rows of columns
|
38
|
+
Layout/ArrayAlignment:
|
39
|
+
Exclude:
|
40
|
+
- 'spec/binary/unhexdump/parser_spec.rb'
|
41
|
+
|
42
|
+
# the arrays of Floats need to be organized into rows of columns
|
43
|
+
Layout/ExtraSpacing:
|
44
|
+
Exclude:
|
45
|
+
- 'spec/binary/unhexdump/parser_spec.rb'
|
46
|
+
|
47
|
+
# make an exception for required block keyword arguments.
|
48
|
+
Layout/SpaceAroundBlockParameters:
|
49
|
+
Exclude:
|
50
|
+
- 'spec/binary/unhexdump/parser_spec.rb'
|
51
|
+
|
52
|
+
# robucop mistakes :x86_64 for a "symbol number"
|
53
|
+
Naming/VariableNumber:
|
54
|
+
AllowedIdentifiers:
|
55
|
+
- x86_64
|
56
|
+
# OpenSSL TLS version symbols
|
57
|
+
- TLSv1
|
58
|
+
- TLSv1_1
|
59
|
+
- TLSv1_2
|
60
|
+
|
61
|
+
# rubocop does not support constants that contain multiple numbers
|
62
|
+
Naming/ClassAndModuleCamelCase:
|
63
|
+
AllowedNames:
|
64
|
+
- X86_64
|
65
|
+
|
66
|
+
# we need to test Ronin::Support::Binary::CString#+ does not modify itself
|
67
|
+
Lint/Void:
|
68
|
+
Exclude:
|
69
|
+
- 'spec/binary/cstring_spec.rb'
|
70
|
+
|
71
|
+
Style/Documentation:
|
72
|
+
Exclude:
|
73
|
+
# ignore top-level documentation for core-ext classes
|
74
|
+
- 'lib/ronin/support/**/core_ext/**/*.rb'
|
75
|
+
# BUG: Ronin::Support::Crypto is already documented in lib/ronin/support/crypto.rb
|
76
|
+
- 'lib/ronin/support/crypto/cert.rb'
|
77
|
+
# BUG: Ronin::Support::Binary is already documented in lib/ronin/support/binary.rb
|
78
|
+
- 'lib/ronin/support/binary/struct.rb'
|
79
|
+
|
80
|
+
Naming/MethodParameterName:
|
81
|
+
AllowedNames:
|
82
|
+
- n
|
83
|
+
- id
|
84
|
+
- ip
|
85
|
+
- io
|
86
|
+
- iv
|
87
|
+
- os
|
88
|
+
- to
|
89
|
+
|
90
|
+
# prefer to keep `self.user_agent` a method
|
91
|
+
Style/TrivialAccessors:
|
92
|
+
Exclude:
|
93
|
+
- 'lib/ronin/support/network/http.rb'
|
94
|
+
|
95
|
+
# we need to redefine the public-key component methods as public
|
96
|
+
Lint/UselessMethodDefinition:
|
97
|
+
Exclude:
|
98
|
+
- 'lib/ronin/support/crypto/key/dh.rb'
|
99
|
+
- 'lib/ronin/support/crypto/key/dsa.rb'
|
100
|
+
- 'lib/ronin/support/crypto/key/rsa.rb'
|
101
|
+
|
102
|
+
Naming/BinaryOperatorParameterName:
|
103
|
+
Exclude:
|
104
|
+
- 'lib/ronin/support/binary/memory.rb'
|
105
|
+
|
106
|
+
# Kernel#try explicitly rescues all exceptions
|
107
|
+
Lint/RescueException:
|
108
|
+
Exclude:
|
109
|
+
- 'lib/ronin/support/core_ext/kernel.rb'
|
data/ChangeLog.md
CHANGED
@@ -1,4 +1,36 @@
|
|
1
|
-
### 1.0.
|
1
|
+
### 1.0.2 / 2023-06-09
|
2
|
+
|
3
|
+
* Fixed a bug in {Ronin::Support::Encoding::Base32.decode},
|
4
|
+
{Ronin::Support::Encoding::Hex.unescape},
|
5
|
+
{Ronin::Support::Encoding::C.unescape},
|
6
|
+
{Ronin::Support::Encoding::JS.unescape},
|
7
|
+
{Ronin::Support::Encoding::PowerShell.unescape},
|
8
|
+
{Ronin::Support::Encoding::Ruby.unescape},
|
9
|
+
{Ronin::Support::Encoding::XML.unescape},
|
10
|
+
{Ronin::Support::Path#join}, {String#encode_bytes}, and {String#encode_chars}
|
11
|
+
where ASCII-bit Strings were always being returned instead of UTF-8 Strings.
|
12
|
+
* Fixed a bug where {Ronin::Support::Network::IP#address} was being improperly
|
13
|
+
cached.
|
14
|
+
* Added missing `require` for {File.tar}, {File.untar}, {File.zip}, and
|
15
|
+
{File.unzip} core-ext methods.
|
16
|
+
* Added missing `require` for {Integer#pack} and {Float#pack} core-ext methods.
|
17
|
+
* No longer include {Ronin::Support::Mixin} into {Kernel} which caused Mixin
|
18
|
+
methods to be included into *every* Class and object.
|
19
|
+
* Added more example code to documentation.
|
20
|
+
* Documentation fixes.
|
21
|
+
|
22
|
+
### 1.0.1 / 2023-03-01
|
23
|
+
|
24
|
+
* {Ronin::Support::Network::HTTP.connect_uri} can now infer when to enable
|
25
|
+
SSL/TLS from the given URI.
|
26
|
+
* {Ronin::Support::Network::HTTP.connect_uri} can now use the `user` and
|
27
|
+
`password` information from the given URI.
|
28
|
+
* All {Ronin::Support::Network::HTTP} class methods which accept URI objects
|
29
|
+
can now accept URLs with International Domain Names (IDN).
|
30
|
+
* Changed {Kernel#try} to not silently ignore `SyntaxError` exceptions.
|
31
|
+
* Documentation improvements.
|
32
|
+
|
33
|
+
### 1.0.0 / 2023-02-01
|
2
34
|
|
3
35
|
* Added {File.aes_encrypt}.
|
4
36
|
* Added {File.aes_decrypt}.
|
data/Gemfile
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
source 'https://rubygems.org'
|
2
4
|
|
3
5
|
gemspec
|
@@ -6,10 +8,10 @@ gem 'jruby-openssl', '~> 0.7', platforms: :jruby
|
|
6
8
|
|
7
9
|
gem 'net-telnet', '~> 0.1', group: :net
|
8
10
|
if RUBY_VERSION >= '3.1.0'
|
9
|
-
gem 'net-ftp', '~> 0.1', group: :net
|
10
|
-
gem 'net-smtp', '~> 0.1', group: :net
|
11
|
-
gem 'net-pop', '~> 0.1', group: :net
|
12
|
-
gem 'net-imap', '~> 0.1', group: :net
|
11
|
+
gem 'net-ftp', '~> 0.1', group: :net
|
12
|
+
gem 'net-smtp', '~> 0.1', group: :net
|
13
|
+
gem 'net-pop', '~> 0.1', group: :net
|
14
|
+
gem 'net-imap', '~> 0.1', group: :net
|
13
15
|
end
|
14
16
|
|
15
17
|
group :development do
|
@@ -27,4 +29,6 @@ group :development do
|
|
27
29
|
gem 'dead_end', require: false
|
28
30
|
gem 'sord', require: false, platform: :mri
|
29
31
|
gem 'stackprof', require: false, platform: :mri
|
32
|
+
gem 'rubocop', require: false, platform: :mri
|
33
|
+
gem 'rubocop-ronin', require: false, platform: :mri
|
30
34
|
end
|
data/README.md
CHANGED
@@ -95,7 +95,7 @@ research and development.
|
|
95
95
|
* [Regexs for matching/extracting common types of data][docs-text-patterns].
|
96
96
|
* Adds additional methods to many of [Ruby's core classes][docs-core-exts].
|
97
97
|
* Small memory footprint (~46Kb).
|
98
|
-
* Has
|
98
|
+
* Has 96% documentation coverage.
|
99
99
|
* Has 93% test coverage.
|
100
100
|
|
101
101
|
## Synopsis
|
data/Rakefile
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
begin
|
4
4
|
require 'bundler'
|
@@ -53,7 +53,7 @@ namespace :public_suffix do
|
|
53
53
|
list = Ronin::Support::Network::PublicSuffix::List.load_file(
|
54
54
|
'public_suffix_list.dat'
|
55
55
|
)
|
56
|
-
|
56
|
+
|
57
57
|
regex = list.to_regexp
|
58
58
|
|
59
59
|
template = 'data/text/patterns/network/public_suffix.rb.erb'
|
data/examples/ssl_proxy.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
require 'bundler/setup'
|
4
5
|
require 'ronin/support/network/ssl/proxy'
|
5
6
|
|
6
7
|
Ronin::Support::Network::SSL::Proxy.start(port: 1337, server: ['example.com', 443]) do |proxy|
|
7
|
-
address =
|
8
|
+
address = ->(socket) {
|
8
9
|
addrinfo = socket.peeraddr
|
9
10
|
|
10
11
|
"#{addrinfo[3]}:#{addrinfo[1]}"
|
data/examples/tcp_proxy.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
require 'bundler/setup'
|
4
5
|
|
@@ -6,16 +7,17 @@ require 'ronin/support/network/tcp/proxy'
|
|
6
7
|
require 'hexdump'
|
7
8
|
|
8
9
|
Ronin::Support::Network::TCP::Proxy.start(port: 1337, server: ['www.wired.com', 80]) do |proxy|
|
9
|
-
address =
|
10
|
+
address = ->(socket) {
|
10
11
|
addrinfo = socket.peeraddr
|
11
12
|
|
12
13
|
"#{addrinfo[3]}:#{addrinfo[1]}"
|
13
14
|
}
|
14
|
-
|
15
|
+
|
16
|
+
hexdump = Hexdump::Dumper.new
|
15
17
|
|
16
18
|
proxy.on_client_data do |client,server,data|
|
17
19
|
puts "#{address[client]} -> #{proxy}"
|
18
|
-
|
20
|
+
hexdump.dump(data)
|
19
21
|
end
|
20
22
|
|
21
23
|
proxy.on_client_connect do |client|
|
@@ -28,7 +30,7 @@ Ronin::Support::Network::TCP::Proxy.start(port: 1337, server: ['www.wired.com',
|
|
28
30
|
|
29
31
|
proxy.on_server_data do |client,server,data|
|
30
32
|
puts "#{address[client]} <- #{proxy}"
|
31
|
-
|
33
|
+
hexdump.dump(data)
|
32
34
|
end
|
33
35
|
|
34
36
|
proxy.on_server_connect do |client,server|
|
@@ -38,6 +38,22 @@ class File
|
|
38
38
|
# @return [Ronin::Support::Archive::Tar::Reader]
|
39
39
|
# The tar reader object.
|
40
40
|
#
|
41
|
+
# @example Enumerating over each entry in the tar archive:
|
42
|
+
# File.untar('file.tar') do |tar|
|
43
|
+
# tar.each do |entry|
|
44
|
+
# puts entry.full_name
|
45
|
+
# puts '-' * 80
|
46
|
+
# puts entry.read
|
47
|
+
# puts '-' * 80
|
48
|
+
# end
|
49
|
+
# end
|
50
|
+
#
|
51
|
+
# @example Reads a specific file from the tar archive:
|
52
|
+
# File.untar('file.tar') do |tar|
|
53
|
+
# data = tar.read('foo.txt')
|
54
|
+
# # ...
|
55
|
+
# end
|
56
|
+
#
|
41
57
|
# @api public
|
42
58
|
#
|
43
59
|
# @since 1.0.0
|
@@ -61,6 +77,12 @@ class File
|
|
61
77
|
# @return [Ronin::Support::Archive::Tar::Writer]
|
62
78
|
# The tar writer object.
|
63
79
|
#
|
80
|
+
# @example
|
81
|
+
# File.tar('output.tar') do |tar|
|
82
|
+
# tar.mkdir('foo')
|
83
|
+
# tar.add_file('foo/bar.txt','Hello World!')
|
84
|
+
# end
|
85
|
+
#
|
64
86
|
# @api public
|
65
87
|
#
|
66
88
|
# @since 1.0.0
|
@@ -84,6 +106,22 @@ class File
|
|
84
106
|
# @return [Ronin::Support::Archive::Zip::Reader]
|
85
107
|
# The zip reader object.
|
86
108
|
#
|
109
|
+
# @example Enumerating over each file in a zip archive:
|
110
|
+
# File.unzip('file.zip') do |zip|
|
111
|
+
# zip.each do |entry|
|
112
|
+
# puts entry.name
|
113
|
+
# puts '-' * 80
|
114
|
+
# puts entry.read
|
115
|
+
# puts '-' * 80
|
116
|
+
# end
|
117
|
+
# end
|
118
|
+
#
|
119
|
+
# @example Reads a specific file from a zip archive:
|
120
|
+
# File.unzip('file.zip') do |zip|
|
121
|
+
# data = zip.read('foo.txt')
|
122
|
+
# # ...
|
123
|
+
# end
|
124
|
+
#
|
87
125
|
# @api public
|
88
126
|
#
|
89
127
|
# @since 1.0.0
|
@@ -107,6 +145,11 @@ class File
|
|
107
145
|
# @return [Ronin::Support::Archive::Zip::Writer]
|
108
146
|
# The zip writer object.
|
109
147
|
#
|
148
|
+
# @example
|
149
|
+
# File.zip('output.zip') do |zip|
|
150
|
+
# zip.add_file('foo/bar.txt','Hello World!')
|
151
|
+
# end
|
152
|
+
#
|
110
153
|
# @api public
|
111
154
|
#
|
112
155
|
# @since 1.0.0
|
@@ -122,7 +122,7 @@ module Ronin
|
|
122
122
|
# @return [self]
|
123
123
|
#
|
124
124
|
# @see https://rubydoc.info/stdlib/rubygems/Gem/Package/TarWriter/RestrictedStream
|
125
|
-
#
|
125
|
+
#
|
126
126
|
def add_file(name,contents=nil, mode: 0644, &block)
|
127
127
|
if contents
|
128
128
|
super(name,mode) do |io|
|
@@ -154,7 +154,7 @@ module Ronin
|
|
154
154
|
# @return [self]
|
155
155
|
#
|
156
156
|
# @see https://rubydoc.info/stdlib/rubygems/Gem/Package/TarWriter/BoundedStream
|
157
|
-
#
|
157
|
+
#
|
158
158
|
def allocate_file(name,size, mode: 0644, &block)
|
159
159
|
add_file_simple(name,mode,size,&block)
|
160
160
|
end
|
@@ -40,20 +40,20 @@ module Ronin
|
|
40
40
|
# Tar.new(io, mode: 'w') do |tar|
|
41
41
|
# # add a file
|
42
42
|
# tar.add_file('file1.txt', "...")
|
43
|
-
#
|
43
|
+
#
|
44
44
|
# # add a file and open an output stream
|
45
45
|
# tar.add_file('file2.txt') do |io|
|
46
46
|
# io.write("...")
|
47
47
|
# end
|
48
|
-
#
|
48
|
+
#
|
49
49
|
# # add a symlink 'link' pointing to 'file1.txt'
|
50
50
|
# tar.add_symlink('link','file1.txt')
|
51
|
-
#
|
51
|
+
#
|
52
52
|
# # add a directory
|
53
53
|
# tar.mkdir('foo')
|
54
54
|
# end
|
55
55
|
#
|
56
|
-
# Opening
|
56
|
+
# Opening
|
57
57
|
#
|
58
58
|
# @api public
|
59
59
|
#
|
@@ -183,7 +183,7 @@ module Ronin
|
|
183
183
|
end
|
184
184
|
|
185
185
|
private
|
186
|
-
|
186
|
+
|
187
187
|
#
|
188
188
|
# Creates an `unzip` command with the additional arguments.
|
189
189
|
#
|
@@ -256,7 +256,7 @@ module Ronin
|
|
256
256
|
# The parsed statistics.
|
257
257
|
#
|
258
258
|
def parse_statistics_line(line)
|
259
|
-
length, size, compression, files,
|
259
|
+
length, size, compression, files, _rest = line.lstrip.split(/\s+/,5)
|
260
260
|
|
261
261
|
return Statistics.new(
|
262
262
|
length: length.to_i,
|
@@ -35,7 +35,7 @@ module Ronin
|
|
35
35
|
#
|
36
36
|
# Creating an array of `int32`s:
|
37
37
|
#
|
38
|
-
# array = Binary::Array.new(:int32, 4)
|
38
|
+
# array = Binary::Binary::Array.new(:int32, 4)
|
39
39
|
# # => #<Ronin::Support::Binary::Binary::Array: "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00">
|
40
40
|
# array[0] = 0x11111111
|
41
41
|
# array[1] = 0x22222222
|
@@ -172,16 +172,13 @@ module Ronin
|
|
172
172
|
def [](index)
|
173
173
|
offset = index * @type.size
|
174
174
|
|
175
|
-
if (index < 0 || offset
|
175
|
+
if (index < 0) || ((offset + @type.size) > size)
|
176
176
|
raise(IndexError,"index #{index} is out of bounds: 0...#{@length}")
|
177
177
|
end
|
178
178
|
|
179
179
|
case @type
|
180
180
|
when CTypes::ObjectType
|
181
|
-
@cache[index] ||= (
|
182
|
-
slice = byteslice(offset,@type.size)
|
183
|
-
@type.unpack(slice)
|
184
|
-
)
|
181
|
+
@cache[index] ||= @type.unpack(byteslice(offset,@type.size))
|
185
182
|
else
|
186
183
|
data = super(offset,@type.size)
|
187
184
|
@type.unpack(data)
|
@@ -207,11 +204,11 @@ module Ronin
|
|
207
204
|
# array[0] = 0x11111111
|
208
205
|
# array[0]
|
209
206
|
# # => 286331153
|
210
|
-
#
|
207
|
+
#
|
211
208
|
def []=(index,value)
|
212
209
|
offset = index * @type.size
|
213
210
|
|
214
|
-
if (index < 0 || offset
|
211
|
+
if (index < 0) || ((offset + @type.size) > size)
|
215
212
|
raise(IndexError,"index #{index} is out of bounds: 0...#{@length}")
|
216
213
|
end
|
217
214
|
|
@@ -32,6 +32,9 @@ module Ronin
|
|
32
32
|
# @api semipublic
|
33
33
|
#
|
34
34
|
module BitFlip
|
35
|
+
#
|
36
|
+
# Methods for bit-flipping Integers.
|
37
|
+
#
|
35
38
|
module Integer
|
36
39
|
#
|
37
40
|
# Enumerates over every bit flip in the integer.
|
@@ -101,6 +104,9 @@ module Ronin
|
|
101
104
|
end
|
102
105
|
end
|
103
106
|
|
107
|
+
#
|
108
|
+
# Methods for bit-flipping Strings.
|
109
|
+
#
|
104
110
|
module String
|
105
111
|
#
|
106
112
|
# Enumerates over every bit flip of every byte in the string.
|
@@ -127,7 +133,7 @@ module Ronin
|
|
127
133
|
|
128
134
|
bits = (0...8)
|
129
135
|
|
130
|
-
string.each_byte.
|
136
|
+
string.each_byte.with_index do |byte,index|
|
131
137
|
Integer.each_bit_flip(byte,bits) do |flipped_byte|
|
132
138
|
new_string = string.dup
|
133
139
|
new_string.force_encoding(Encoding::ASCII_8BIT)
|
@@ -30,7 +30,7 @@ module Ronin
|
|
30
30
|
#
|
31
31
|
# Writing bytes into an empty buffer:
|
32
32
|
#
|
33
|
-
# buffer = Buffer.new(10)
|
33
|
+
# buffer = Binary::Buffer.new(10)
|
34
34
|
# # => #<Ronin::Support::Binary::Buffer: "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00">
|
35
35
|
# buffer[0] = 0x41
|
36
36
|
# buffer[1] = 0x42
|
@@ -40,7 +40,7 @@ module Ronin
|
|
40
40
|
#
|
41
41
|
# Writing different types of data to a buffer:
|
42
42
|
#
|
43
|
-
# buffer = Buffer.new(16)
|
43
|
+
# buffer = Binary::Buffer.new(16)
|
44
44
|
# # => #<Ronin::Support::Binary::Buffer: "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00">
|
45
45
|
# buffer.put_uint32(0,0x11223344)
|
46
46
|
# buffer.put_int32(4,-1)
|
@@ -51,7 +51,7 @@ module Ronin
|
|
51
51
|
#
|
52
52
|
# Creating a buffer from an existing String:
|
53
53
|
#
|
54
|
-
# buffer = Buffer.new("\x41\x00\x00\x00\x42\x00\x00\x00")
|
54
|
+
# buffer = Binary::Buffer.new("\x41\x00\x00\x00\x42\x00\x00\x00")
|
55
55
|
# # => #<Ronin::Support::Binary::Buffer: "A\u0000\u0000\u0000B\u0000\u0000\u0000">
|
56
56
|
# buffer.get_uint32(0)
|
57
57
|
# # => 65
|
@@ -203,8 +203,8 @@ module Ronin
|
|
203
203
|
def get(type,offset)
|
204
204
|
type = @type_system[type]
|
205
205
|
|
206
|
-
if (offset < 0 || offset+type.size > size)
|
207
|
-
raise(IndexError,"offset #{offset} is out of bounds: 0...#{size-type.size}")
|
206
|
+
if (offset < 0) || ((offset + type.size) > size)
|
207
|
+
raise(IndexError,"offset #{offset} is out of bounds: 0...#{size - type.size}")
|
208
208
|
end
|
209
209
|
|
210
210
|
data = @string[offset,type.size]
|
@@ -270,27 +270,27 @@ module Ronin
|
|
270
270
|
# The read C string, without the null-byte.
|
271
271
|
#
|
272
272
|
def get_string(offset,length=nil)
|
273
|
-
if (offset < 0 || offset >= size)
|
274
|
-
raise(IndexError,"offset #{offset} is out of bounds: 0...#{size-1}")
|
275
|
-
elsif (length && offset+length > size)
|
276
|
-
raise(IndexError,"offset #{offset} or length #{length} is out of bounds: 0...#{size-1}")
|
273
|
+
if (offset < 0) || (offset >= size)
|
274
|
+
raise(IndexError,"offset #{offset} is out of bounds: 0...#{size - 1}")
|
275
|
+
elsif (length && (offset + length) > size)
|
276
|
+
raise(IndexError,"offset #{offset} or length #{length} is out of bounds: 0...#{size - 1}")
|
277
277
|
end
|
278
278
|
|
279
279
|
if length
|
280
280
|
substring = @string[offset,length]
|
281
281
|
|
282
|
-
if (
|
283
|
-
substring[0...
|
282
|
+
if (null_byte_index = substring.index("\0"))
|
283
|
+
substring[0...null_byte_index]
|
284
|
+
else
|
285
|
+
substring
|
284
286
|
end
|
285
287
|
else
|
286
|
-
if (
|
287
|
-
|
288
|
+
if (null_byte_index = @string.index("\0",offset))
|
289
|
+
@string[offset...null_byte_index]
|
288
290
|
else
|
289
|
-
|
291
|
+
@string[offset..]
|
290
292
|
end
|
291
293
|
end
|
292
|
-
|
293
|
-
return substring
|
294
294
|
end
|
295
295
|
|
296
296
|
#
|
@@ -707,8 +707,8 @@ module Ronin
|
|
707
707
|
type = @type_system[type]
|
708
708
|
array_type = type[count]
|
709
709
|
|
710
|
-
if (offset < 0 || offset+array_type.size > size)
|
711
|
-
raise(IndexError,"offset #{offset} or size #{array_type.size} is out of bounds: 0...#{size-type.size}")
|
710
|
+
if (offset < 0) || ((offset + array_type.size) > size)
|
711
|
+
raise(IndexError,"offset #{offset} or size #{array_type.size} is out of bounds: 0...#{size - type.size}")
|
712
712
|
end
|
713
713
|
|
714
714
|
slice = @string[offset,array_type.size]
|
@@ -1162,8 +1162,8 @@ module Ronin
|
|
1162
1162
|
def put(type,offset,value)
|
1163
1163
|
type = @type_system[type]
|
1164
1164
|
|
1165
|
-
if (offset < 0 || offset+type.size > size)
|
1166
|
-
raise(IndexError,"offset #{offset} is out of bounds: 0...#{size-type.size}")
|
1165
|
+
if (offset < 0) || ((offset + type.size) > size)
|
1166
|
+
raise(IndexError,"offset #{offset} is out of bounds: 0...#{size - type.size}")
|
1167
1167
|
end
|
1168
1168
|
|
1169
1169
|
data = type.pack(value)
|
@@ -1222,8 +1222,8 @@ module Ronin
|
|
1222
1222
|
ascii_string = string.encode(Encoding::ASCII_8BIT)
|
1223
1223
|
cstring = "#{ascii_string}\0"
|
1224
1224
|
|
1225
|
-
if (offset < 0 || offset+cstring.bytesize >= size)
|
1226
|
-
raise(IndexError,"offset #{offset} or C string size #{cstring.bytesize} is out of bounds: 0...#{size-1}")
|
1225
|
+
if (offset < 0) || ((offset + cstring.bytesize) >= size)
|
1226
|
+
raise(IndexError,"offset #{offset} or C string size #{cstring.bytesize} is out of bounds: 0...#{size - 1}")
|
1227
1227
|
end
|
1228
1228
|
|
1229
1229
|
@string[offset,cstring.bytesize] = cstring
|
@@ -1605,9 +1605,9 @@ module Ronin
|
|
1605
1605
|
def put_array_of(type,offset,array)
|
1606
1606
|
type = @type_system[type]
|
1607
1607
|
array_type = type[array.length]
|
1608
|
-
|
1609
|
-
if (offset < 0 || offset+array_type.size > size)
|
1610
|
-
raise(IndexError,"offset #{offset} or size #{array_type.size} is out of bounds: 0...#{size-type.size}")
|
1608
|
+
|
1609
|
+
if (offset < 0) || ((offset + array_type.size) > size)
|
1610
|
+
raise(IndexError,"offset #{offset} or size #{array_type.size} is out of bounds: 0...#{size - type.size}")
|
1611
1611
|
end
|
1612
1612
|
|
1613
1613
|
data = array_type.pack(array)
|