ronin 1.5.0 → 1.5.1
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 +7 -0
- data/.editorconfig +11 -0
- data/.github/workflows/ruby.yml +32 -0
- data/.gitignore +7 -7
- data/.ruby-version +1 -0
- data/COPYING.txt +3 -3
- data/ChangeLog.md +25 -11
- data/Gemfile +21 -20
- data/README.md +102 -81
- data/Rakefile +4 -5
- data/bin/ronin +7 -12
- data/bin/ronin-campaigns +7 -12
- data/bin/ronin-console +7 -12
- data/bin/ronin-creds +7 -12
- data/bin/ronin-database +7 -12
- data/bin/ronin-emails +7 -12
- data/bin/ronin-exec +7 -12
- data/bin/ronin-fuzzer +7 -12
- data/bin/ronin-help +7 -12
- data/bin/ronin-hosts +7 -12
- data/bin/ronin-install +7 -12
- data/bin/ronin-ips +7 -12
- data/bin/ronin-net-proxy +7 -12
- data/bin/ronin-repos +7 -12
- data/bin/ronin-uninstall +7 -12
- data/bin/ronin-update +7 -12
- data/bin/ronin-urls +7 -12
- data/bin/ronin-wordlist +7 -12
- data/gemspec.yml +8 -8
- data/lib/bond/completions/ronin.rb +23 -23
- data/lib/ronin.rb +3 -3
- data/lib/ronin/address.rb +6 -7
- data/lib/ronin/arch.rb +3 -3
- data/lib/ronin/author.rb +5 -7
- data/lib/ronin/auto_load.rb +5 -5
- data/lib/ronin/bootstrap.rb +3 -3
- data/lib/ronin/campaign.rb +3 -3
- data/lib/ronin/config.rb +5 -7
- data/lib/ronin/credential.rb +3 -3
- data/lib/ronin/database.rb +3 -3
- data/lib/ronin/database/database.rb +8 -12
- data/lib/ronin/database/exceptions.rb +3 -3
- data/lib/ronin/database/exceptions/invalid_config.rb +3 -3
- data/lib/ronin/database/exceptions/unknown_repository.rb +3 -3
- data/lib/ronin/database/migrations.rb +3 -3
- data/lib/ronin/database/migrations/1.0.0.rb +3 -3
- data/lib/ronin/database/migrations/1.1.0.rb +3 -3
- data/lib/ronin/database/migrations/exceptions.rb +3 -3
- data/lib/ronin/database/migrations/exceptions/duplicate_migration.rb +3 -3
- data/lib/ronin/database/migrations/exceptions/unknown_migration.rb +3 -3
- data/lib/ronin/database/migrations/graph.rb +3 -3
- data/lib/ronin/database/migrations/migration.rb +3 -3
- data/lib/ronin/database/migrations/migrations.rb +3 -3
- data/lib/ronin/email_address.rb +5 -7
- data/lib/ronin/environment.rb +3 -3
- data/lib/ronin/exceptions.rb +3 -3
- data/lib/ronin/exceptions/duplicate_repository.rb +3 -3
- data/lib/ronin/exceptions/repository_not_found.rb +3 -3
- data/lib/ronin/host_name.rb +3 -3
- data/lib/ronin/host_name_ip_address.rb +3 -3
- data/lib/ronin/installation.rb +5 -7
- data/lib/ronin/ip_address.rb +6 -8
- data/lib/ronin/ip_address_mac_address.rb +3 -3
- data/lib/ronin/license.rb +6 -6
- data/lib/ronin/mac_address.rb +3 -3
- data/lib/ronin/model.rb +3 -3
- data/lib/ronin/model/has_authors.rb +3 -3
- data/lib/ronin/model/has_description.rb +3 -3
- data/lib/ronin/model/has_license.rb +3 -3
- data/lib/ronin/model/has_name.rb +3 -3
- data/lib/ronin/model/has_title.rb +3 -3
- data/lib/ronin/model/has_unique_name.rb +5 -7
- data/lib/ronin/model/has_version.rb +3 -3
- data/lib/ronin/model/importable.rb +3 -3
- data/lib/ronin/model/model.rb +7 -8
- data/lib/ronin/model/types.rb +3 -3
- data/lib/ronin/model/types/description.rb +9 -12
- data/lib/ronin/open_port.rb +5 -7
- data/lib/ronin/organization.rb +3 -3
- data/lib/ronin/os.rb +5 -7
- data/lib/ronin/os_guess.rb +3 -3
- data/lib/ronin/password.rb +3 -3
- data/lib/ronin/port.rb +3 -3
- data/lib/ronin/repositories.rb +3 -3
- data/lib/ronin/repository.rb +3 -3
- data/lib/ronin/ronin.rb +3 -3
- data/lib/ronin/script.rb +3 -3
- data/lib/ronin/script/buildable.rb +3 -3
- data/lib/ronin/script/deployable.rb +3 -3
- data/lib/ronin/script/exceptions.rb +3 -3
- data/lib/ronin/script/exceptions/build_failed.rb +3 -3
- data/lib/ronin/script/exceptions/deploy_failed.rb +3 -3
- data/lib/ronin/script/exceptions/exception.rb +3 -3
- data/lib/ronin/script/exceptions/not_built.rb +3 -3
- data/lib/ronin/script/exceptions/test_failed.rb +3 -3
- data/lib/ronin/script/path.rb +3 -3
- data/lib/ronin/script/script.rb +3 -3
- data/lib/ronin/script/testable.rb +3 -3
- data/lib/ronin/service.rb +3 -3
- data/lib/ronin/service_credential.rb +3 -3
- data/lib/ronin/software.rb +3 -3
- data/lib/ronin/spec/database.rb +27 -21
- data/lib/ronin/target.rb +3 -3
- data/lib/ronin/tcp_port.rb +3 -3
- data/lib/ronin/udp_port.rb +3 -3
- data/lib/ronin/ui.rb +3 -3
- data/lib/ronin/ui/cli.rb +3 -3
- data/lib/ronin/ui/cli/class_command.rb +14 -7
- data/lib/ronin/ui/cli/cli.rb +5 -5
- data/lib/ronin/ui/cli/command.rb +5 -7
- data/lib/ronin/ui/cli/commands.rb +3 -3
- data/lib/ronin/ui/cli/commands/campaigns.rb +5 -7
- data/lib/ronin/ui/cli/commands/console.rb +3 -3
- data/lib/ronin/ui/cli/commands/creds.rb +3 -3
- data/lib/ronin/ui/cli/commands/database.rb +3 -3
- data/lib/ronin/ui/cli/commands/emails.rb +3 -3
- data/lib/ronin/ui/cli/commands/exec.rb +3 -3
- data/lib/ronin/ui/cli/commands/fuzzer.rb +16 -16
- data/lib/ronin/ui/cli/commands/help.rb +3 -3
- data/lib/ronin/ui/cli/commands/hosts.rb +5 -7
- data/lib/ronin/ui/cli/commands/install.rb +7 -11
- data/lib/ronin/ui/cli/commands/ips.rb +5 -7
- data/lib/ronin/ui/cli/commands/net/proxy.rb +19 -12
- data/lib/ronin/ui/cli/commands/repos.rb +3 -3
- data/lib/ronin/ui/cli/commands/uninstall.rb +3 -3
- data/lib/ronin/ui/cli/commands/update.rb +3 -3
- data/lib/ronin/ui/cli/commands/urls.rb +3 -3
- data/lib/ronin/ui/cli/commands/wordlist.rb +3 -3
- data/lib/ronin/ui/cli/exceptions.rb +3 -3
- data/lib/ronin/ui/cli/exceptions/unknown_command.rb +3 -3
- data/lib/ronin/ui/cli/model_command.rb +6 -9
- data/lib/ronin/ui/cli/printing.rb +3 -3
- data/lib/ronin/ui/cli/resources_command.rb +7 -11
- data/lib/ronin/ui/cli/script_command.rb +5 -10
- data/lib/ronin/ui/console.rb +3 -3
- data/lib/ronin/ui/console/commands.rb +3 -3
- data/lib/ronin/ui/console/console.rb +3 -3
- data/lib/ronin/ui/console/context.rb +3 -3
- data/lib/ronin/ui/console/shell.rb +3 -3
- data/lib/ronin/url.rb +5 -7
- data/lib/ronin/url_query_param.rb +3 -3
- data/lib/ronin/url_query_param_name.rb +6 -6
- data/lib/ronin/url_scheme.rb +4 -4
- data/lib/ronin/user_name.rb +3 -3
- data/lib/ronin/vendor.rb +3 -3
- data/lib/ronin/version.rb +5 -5
- data/lib/ronin/web_credential.rb +5 -7
- data/man/ronin-campaigns.1.md +20 -20
- data/man/ronin-console.1.md +17 -17
- data/man/ronin-creds.1.md +16 -16
- data/man/ronin-database.1.md +23 -23
- data/man/ronin-emails.1.md +18 -18
- data/man/ronin-exec.1.md +11 -11
- data/man/ronin-fuzzer.1.md +23 -23
- data/man/ronin-help.1.md +5 -5
- data/man/ronin-hosts.1.md +20 -20
- data/man/ronin-install.1.md +18 -18
- data/man/ronin-ips.1.md +21 -21
- data/man/ronin-net-proxy.1.md +24 -24
- data/man/ronin-repos.1.md +18 -18
- data/man/ronin-uninstall.1.md +14 -14
- data/man/ronin-update.1.md +14 -14
- data/man/ronin-urls.1.md +22 -22
- data/man/ronin-wordlist.1.md +14 -13
- data/man/ronin.1.md +1 -1
- data/spec/arch_spec.rb +59 -46
- data/spec/author_spec.rb +14 -14
- data/spec/campaign_spec.rb +8 -0
- data/spec/credential_spec.rb +11 -8
- data/spec/database_spec.rb +6 -6
- data/spec/email_address_spec.rb +23 -20
- data/spec/host_name_spec.rb +24 -22
- data/spec/installation_spec.rb +6 -6
- data/spec/ip_address_spec.rb +31 -26
- data/spec/license_spec.rb +15 -9
- data/spec/mac_address_spec.rb +17 -8
- data/spec/model/has_authors_spec.rb +56 -37
- data/spec/model/has_description_spec.rb +36 -23
- data/spec/model/has_license_spec.rb +38 -28
- data/spec/model/has_name_spec.rb +36 -19
- data/spec/model/has_title_spec.rb +27 -14
- data/spec/model/has_version_spec.rb +64 -35
- data/spec/model/model_spec.rb +57 -33
- data/spec/model/models/{basic_model.rb → base_model.rb} +1 -1
- data/spec/model/models/{custom_model.rb → inherited_model.rb} +2 -3
- data/spec/os_spec.rb +24 -20
- data/spec/password_spec.rb +17 -9
- data/spec/port_spec.rb +30 -22
- data/spec/repository_spec.rb +59 -60
- data/spec/ronin_spec.rb +4 -4
- data/spec/script/buildable_spec.rb +8 -8
- data/spec/script/deployable_spec.rb +7 -7
- data/spec/script/path_spec.rb +42 -40
- data/spec/script/script_spec.rb +23 -23
- data/spec/script/testable_spec.rb +20 -20
- data/spec/service_spec.rb +14 -8
- data/spec/software_spec.rb +30 -17
- data/spec/spec_helper.rb +4 -4
- data/spec/ui/cli/classes/test_command.rb +2 -4
- data/spec/ui/cli/cli_spec.rb +5 -5
- data/spec/ui/cli/command_spec.rb +34 -30
- data/spec/url_query_param_spec.rb +23 -14
- data/spec/url_scheme_spec.rb +12 -9
- data/spec/url_spec.rb +64 -61
- data/spec/vendor_spec.rb +15 -8
- metadata +122 -150
- data/.gemtest +0 -0
data/spec/campaign_spec.rb
CHANGED
data/spec/credential_spec.rb
CHANGED
@@ -1,26 +1,29 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
|
2
3
|
require 'ronin/credential'
|
3
4
|
|
4
5
|
describe Credential do
|
5
|
-
let(:name)
|
6
|
-
let(:
|
6
|
+
let(:name) { 'alice' }
|
7
|
+
let(:password) { 'secret' }
|
7
8
|
|
8
9
|
subject do
|
9
|
-
|
10
|
+
described_class.new(
|
10
11
|
:user_name => {:name => name},
|
11
|
-
:password
|
12
|
+
:password => {:clear_text => password}
|
12
13
|
)
|
13
14
|
end
|
14
15
|
|
15
16
|
it "should provide the user-name" do
|
16
|
-
subject.user.
|
17
|
+
expect(subject.user).to eq(name)
|
17
18
|
end
|
18
19
|
|
19
20
|
it "should provide the clear-text password" do
|
20
|
-
subject.clear_text.
|
21
|
+
expect(subject.clear_text).to eq(password)
|
21
22
|
end
|
22
23
|
|
23
|
-
|
24
|
-
|
24
|
+
describe "#to_s" do
|
25
|
+
it "should include the user name and password" do
|
26
|
+
expect(subject.to_s).to eq("#{name}:#{password}")
|
27
|
+
end
|
25
28
|
end
|
26
29
|
end
|
data/spec/database_spec.rb
CHANGED
@@ -4,25 +4,25 @@ require 'ronin/database'
|
|
4
4
|
describe Database do
|
5
5
|
describe "repositories" do
|
6
6
|
it "should not be empty" do
|
7
|
-
subject.repositories.
|
7
|
+
expect(subject.repositories).not_to be_empty
|
8
8
|
end
|
9
9
|
|
10
10
|
it "should have a ':default' repository" do
|
11
|
-
subject.repositories[:default].
|
11
|
+
expect(subject.repositories[:default]).not_to be_nil
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
15
|
it "shold determine if a repository is defined" do
|
16
|
-
subject.repository?(:default).
|
16
|
+
expect(subject.repository?(:default)).to be(true)
|
17
17
|
end
|
18
18
|
|
19
19
|
it "should determine when a repository is setup" do
|
20
|
-
subject.setup?(:default).
|
20
|
+
expect(subject.setup?(:default)).to be(true)
|
21
21
|
end
|
22
22
|
|
23
23
|
it "should not allow switching to unknown repositories" do
|
24
|
-
|
24
|
+
expect {
|
25
25
|
subject.repository(:foo) { }
|
26
|
-
}.
|
26
|
+
}.to raise_error(Database::UnknownRepository)
|
27
27
|
end
|
28
28
|
end
|
data/spec/email_address_spec.rb
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
|
2
3
|
require 'ronin/email_address'
|
3
4
|
|
4
5
|
describe EmailAddress do
|
5
|
-
let(:user)
|
6
|
-
let(:host)
|
6
|
+
let(:user) { 'joe' }
|
7
|
+
let(:host) { 'example.com' }
|
7
8
|
let(:email) { "#{user}@#{host}" }
|
8
9
|
|
9
10
|
subject {
|
10
|
-
|
11
|
+
described_class.new(
|
11
12
|
:user_name => {:name => user},
|
12
13
|
:host_name => {:address => host}
|
13
14
|
)
|
@@ -18,10 +19,10 @@ describe EmailAddress do
|
|
18
19
|
|
19
20
|
let(:email1) { subject.parse('foo@bar.com') }
|
20
21
|
let(:email2) { subject.parse('foo!bar@baz.com') }
|
21
|
-
let(:text)
|
22
|
+
let(:text) { "To: #{email1}, #{email2}." }
|
22
23
|
|
23
24
|
it "should extract multiple email addresses from text" do
|
24
|
-
subject.extract(text).
|
25
|
+
expect(subject.extract(text)).to eq([email1, email2])
|
25
26
|
end
|
26
27
|
|
27
28
|
it "should yield the extracted email addresses if a block is given" do
|
@@ -29,23 +30,23 @@ describe EmailAddress do
|
|
29
30
|
|
30
31
|
subject.extract(text) { |email| emails << email }
|
31
32
|
|
32
|
-
emails.
|
33
|
+
expect(emails).to eq([email1, email2])
|
33
34
|
end
|
34
35
|
end
|
35
36
|
|
36
37
|
describe "parse" do
|
37
38
|
it "should parse email addresses" do
|
38
|
-
email_address =
|
39
|
+
email_address = described_class.parse(email)
|
39
40
|
|
40
|
-
email_address.user_name.name.
|
41
|
-
email_address.host_name.address.
|
41
|
+
expect(email_address.user_name.name).to eq(user)
|
42
|
+
expect(email_address.host_name.address).to eq(host)
|
42
43
|
end
|
43
44
|
|
44
45
|
it "should strip whitespace from emails" do
|
45
|
-
email_address =
|
46
|
+
email_address = described_class.parse(" #{email} ")
|
46
47
|
|
47
|
-
email_address.user_name.name.
|
48
|
-
email_address.host_name.address.
|
48
|
+
expect(email_address.user_name.name).to eq(user)
|
49
|
+
expect(email_address.host_name.address).to eq(host)
|
49
50
|
end
|
50
51
|
end
|
51
52
|
|
@@ -53,28 +54,30 @@ describe EmailAddress do
|
|
53
54
|
it "should accept Strings" do
|
54
55
|
email_address = described_class.from(email)
|
55
56
|
|
56
|
-
email_address.user_name.name.
|
57
|
-
email_address.host_name.address.
|
57
|
+
expect(email_address.user_name.name).to eq(user)
|
58
|
+
expect(email_address.host_name.address).to eq(host)
|
58
59
|
end
|
59
60
|
|
60
61
|
it "should accept URI::MailTo objects" do
|
61
62
|
uri = URI("mailto:#{email}")
|
62
63
|
email_address = described_class.from(uri)
|
63
64
|
|
64
|
-
email_address.user_name.name.
|
65
|
-
email_address.host_name.address.
|
65
|
+
expect(email_address.user_name.name).to eq(user)
|
66
|
+
expect(email_address.host_name.address).to eq(host)
|
66
67
|
end
|
67
68
|
end
|
68
69
|
|
69
70
|
it "should provide the user-name" do
|
70
|
-
subject.user.
|
71
|
+
expect(subject.user).to eq(user)
|
71
72
|
end
|
72
73
|
|
73
74
|
it "should provide the host-name" do
|
74
|
-
subject.host.
|
75
|
+
expect(subject.host).to eq(host)
|
75
76
|
end
|
76
77
|
|
77
|
-
|
78
|
-
|
78
|
+
describe "#to_s" do
|
79
|
+
it "should include the email address" do
|
80
|
+
expect(subject.to_s).to eq(email)
|
81
|
+
end
|
79
82
|
end
|
80
83
|
end
|
data/spec/host_name_spec.rb
CHANGED
@@ -1,20 +1,23 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
|
2
3
|
require 'ronin/host_name'
|
3
4
|
|
4
5
|
describe HostName do
|
5
6
|
let(:domain) { 'localhost' }
|
6
|
-
let(:ip)
|
7
|
+
let(:ip) { '127.0.0.1' }
|
7
8
|
|
8
|
-
subject {
|
9
|
+
subject { described_class.new(:address => domain) }
|
9
10
|
|
10
|
-
|
11
|
-
|
11
|
+
describe "validations" do
|
12
|
+
it "should require an address" do
|
13
|
+
host_name = described_class.new
|
12
14
|
|
13
|
-
|
15
|
+
expect(host_name).not_to be_valid
|
16
|
+
end
|
14
17
|
end
|
15
18
|
|
16
19
|
it "should alias #name to #address" do
|
17
|
-
subject.name.
|
20
|
+
expect(subject.name).to eq(subject.address)
|
18
21
|
end
|
19
22
|
|
20
23
|
describe "extract" do
|
@@ -25,7 +28,7 @@ describe HostName do
|
|
25
28
|
let(:text) { "Hosts: #{host1}, #{host2}." }
|
26
29
|
|
27
30
|
it "should extract multiple host-names from text" do
|
28
|
-
subject.extract(text).
|
31
|
+
expect(subject.extract(text)).to eq([host1, host2])
|
29
32
|
end
|
30
33
|
|
31
34
|
it "should yield the extracted host-names if a block is given" do
|
@@ -33,58 +36,57 @@ describe HostName do
|
|
33
36
|
|
34
37
|
subject.extract(text) { |host| hosts << host }
|
35
38
|
|
36
|
-
hosts.
|
39
|
+
expect(hosts).to eq([host1, host2])
|
37
40
|
end
|
38
41
|
end
|
39
42
|
|
40
43
|
describe "lookup" do
|
41
|
-
subject {
|
42
|
-
|
43
|
-
let(:bad_ip) { '0.0.0.0' }
|
44
|
+
subject { described_class }
|
44
45
|
|
45
46
|
it "should look up the host names for an IP Address" do
|
46
47
|
host_names = subject.lookup(ip).map { |name| name.address }
|
47
48
|
|
48
|
-
host_names.
|
49
|
+
expect(host_names).to include(domain)
|
49
50
|
end
|
50
51
|
|
51
52
|
it "should associate the host names with the original IP address" do
|
52
53
|
host_names = subject.lookup(ip)
|
53
54
|
|
54
55
|
host_names.each do |host|
|
55
|
-
host.ip_addresses[0].address.
|
56
|
+
expect(host.ip_addresses[0].address).to eq(ip)
|
56
57
|
end
|
57
58
|
end
|
58
59
|
|
60
|
+
let(:bad_ip) { '0.0.0.0' }
|
61
|
+
|
59
62
|
it "should return an empty Array for unknown host names" do
|
60
63
|
host_names = subject.lookup(bad_ip)
|
61
64
|
|
62
|
-
host_names.
|
65
|
+
expect(host_names).to be_empty
|
63
66
|
end
|
64
67
|
end
|
65
68
|
|
66
69
|
describe "#lookup!" do
|
67
|
-
let(:bad_domain) { '.bad.domain.com.' }
|
68
|
-
|
69
70
|
it "should look up the IP Addresses for the host name" do
|
70
71
|
ips = subject.lookup!
|
71
72
|
|
72
|
-
ips.
|
73
|
-
ips[0].address.should == ip
|
73
|
+
expect(ips.any? { |ip_address| ip_address.address == ip }).to be(true)
|
74
74
|
end
|
75
75
|
|
76
76
|
it "should associate the IP addresses with the original host name" do
|
77
77
|
ips = subject.lookup!
|
78
78
|
|
79
|
-
ips.each do |
|
80
|
-
|
79
|
+
ips.each do |ip_address|
|
80
|
+
expect(ip_address.host_names[0].address).to eq(domain)
|
81
81
|
end
|
82
82
|
end
|
83
83
|
|
84
|
+
let(:bad_domain) { 'foo' }
|
85
|
+
|
84
86
|
it "should return an empty Array for unknown host names" do
|
85
|
-
ips =
|
87
|
+
ips = described_class.new(:address => bad_domain).lookup!
|
86
88
|
|
87
|
-
ips.
|
89
|
+
expect(ips).to be_empty
|
88
90
|
end
|
89
91
|
end
|
90
92
|
end
|
data/spec/installation_spec.rb
CHANGED
@@ -3,11 +3,11 @@ require 'ronin/installation'
|
|
3
3
|
|
4
4
|
describe Installation do
|
5
5
|
it "should load the gemspec for the 'ronin' library" do
|
6
|
-
subject.gems['ronin'].
|
6
|
+
expect(subject.gems['ronin']).not_to be_nil
|
7
7
|
end
|
8
8
|
|
9
9
|
it "should provide the names of the installed Ronin libraries" do
|
10
|
-
subject.libraries.
|
10
|
+
expect(subject.libraries).to include('ronin')
|
11
11
|
end
|
12
12
|
|
13
13
|
let(:directory) { 'lib/ronin/ui/cli/commands/' }
|
@@ -17,11 +17,11 @@ describe Installation do
|
|
17
17
|
|
18
18
|
describe "each_file" do
|
19
19
|
it "should enumerate over the files which match a glob pattern" do
|
20
|
-
subject.each_file(pattern).to_a.
|
20
|
+
expect(subject.each_file(pattern).to_a).to match_array(paths)
|
21
21
|
end
|
22
22
|
|
23
23
|
it "should return an Enumerator when no block is given" do
|
24
|
-
subject.each_file(pattern).
|
24
|
+
expect(subject.each_file(pattern)).to respond_to(:each)
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -30,11 +30,11 @@ describe Installation do
|
|
30
30
|
let(:expected) { files }
|
31
31
|
|
32
32
|
it "should enumerate over the files which match a glob pattern" do
|
33
|
-
subject.each_file_in(directory,ext).to_a.
|
33
|
+
expect(subject.each_file_in(directory,ext).to_a).to match_array(expected)
|
34
34
|
end
|
35
35
|
|
36
36
|
it "should return an Enumerator when no block is given" do
|
37
|
-
subject.each_file_in(directory,ext).
|
37
|
+
expect(subject.each_file_in(directory,ext)).to respond_to(:each)
|
38
38
|
end
|
39
39
|
end
|
40
40
|
end
|
data/spec/ip_address_spec.rb
CHANGED
@@ -1,27 +1,28 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
|
2
3
|
require 'ronin/ip_address'
|
3
4
|
|
4
5
|
describe IPAddress do
|
5
6
|
let(:example_domain) { 'localhost' }
|
6
7
|
let(:example_ip) { '127.0.0.1' }
|
7
8
|
|
8
|
-
subject {
|
9
|
+
subject { described_class.new(:address => example_ip) }
|
9
10
|
|
10
11
|
it "should require an address" do
|
11
|
-
ip_address =
|
12
|
+
ip_address = described_class.new
|
12
13
|
|
13
|
-
ip_address.
|
14
|
+
expect(ip_address).not_to be_valid
|
14
15
|
end
|
15
16
|
|
16
17
|
describe "extract" do
|
17
|
-
subject {
|
18
|
+
subject { described_class }
|
18
19
|
|
19
20
|
let(:ip1) { subject.parse('127.0.0.1') }
|
20
21
|
let(:ip2) { subject.parse('10.1.1.1') }
|
21
22
|
let(:text) { "Hosts: #{ip1}, #{ip2}" }
|
22
23
|
|
23
24
|
it "should extract multiple IP Addresses from text" do
|
24
|
-
subject.extract(text).
|
25
|
+
expect(subject.extract(text)).to eq([ip1, ip2])
|
25
26
|
end
|
26
27
|
|
27
28
|
it "should yield the extracted IPs if a block is given" do
|
@@ -29,44 +30,42 @@ describe IPAddress do
|
|
29
30
|
|
30
31
|
subject.extract(text) { |ip| ip_addresses << ip }
|
31
32
|
|
32
|
-
ip_addresses.
|
33
|
+
expect(ip_addresses).to eq([ip1, ip2])
|
33
34
|
end
|
34
35
|
end
|
35
36
|
|
36
37
|
describe "lookup" do
|
37
|
-
subject {
|
38
|
-
|
39
|
-
let(:bad_domain) { '.bad.domain.com.' }
|
38
|
+
subject { described_class }
|
40
39
|
|
41
40
|
it "should lookup host-names to IP Addresses" do
|
42
41
|
ip_addresses = subject.lookup(example_domain)
|
43
42
|
addresses = ip_addresses.map { |ip| ip.address }
|
44
43
|
|
45
|
-
addresses.
|
44
|
+
expect(addresses).to include(example_ip)
|
46
45
|
end
|
47
46
|
|
48
47
|
it "should associate the IP addresses with the original host name" do
|
49
48
|
ip_addresses = subject.lookup(example_domain)
|
50
49
|
host_names = ip_addresses.map { |ip| ip.host_names[0].address }
|
51
50
|
|
52
|
-
host_names.
|
51
|
+
expect(host_names).to include(example_domain)
|
53
52
|
end
|
54
53
|
|
54
|
+
let(:bad_domain) { 'foo' }
|
55
|
+
|
55
56
|
it "should return an empty Array for unknown domain names" do
|
56
57
|
ip_addresses = subject.lookup(bad_domain)
|
57
58
|
|
58
|
-
ip_addresses.
|
59
|
+
expect(ip_addresses).to be_empty
|
59
60
|
end
|
60
61
|
end
|
61
62
|
|
62
63
|
describe "#lookup!" do
|
63
|
-
let(:bad_ip) { '0.0.0.0' }
|
64
|
-
|
65
64
|
it "should reverse lookup the host-name for an IP Address" do
|
66
65
|
host_names = subject.lookup!
|
67
66
|
addresses = host_names.map { |host_name| host_name.address }
|
68
67
|
|
69
|
-
addresses.
|
68
|
+
expect(addresses).to include(example_domain)
|
70
69
|
end
|
71
70
|
|
72
71
|
it "should associate the host names with the original IP address" do
|
@@ -75,30 +74,36 @@ describe IPAddress do
|
|
75
74
|
host_name.ip_addresses[0].address
|
76
75
|
end
|
77
76
|
|
78
|
-
ip_addresses.
|
77
|
+
expect(ip_addresses).to include(subject)
|
79
78
|
end
|
80
79
|
|
80
|
+
let(:bad_ip) { '0.0.0.0' }
|
81
|
+
|
81
82
|
it "should return an empty Array for unknown domain names" do
|
82
|
-
ip_address =
|
83
|
+
ip_address = described_class.new(:address => bad_ip)
|
83
84
|
host_names = ip_address.lookup!
|
84
85
|
|
85
|
-
host_names.
|
86
|
+
expect(host_names).to be_empty
|
86
87
|
end
|
87
88
|
end
|
88
89
|
|
89
90
|
describe "#version" do
|
90
|
-
let(:ipv4) { IPAddress.new(:address => '127.0.0.1') }
|
91
|
-
let(:ipv6) { IPAddress.new(:address => '::1') }
|
92
|
-
|
93
91
|
it "should only accept 4 or 6" do
|
94
|
-
ip_address =
|
92
|
+
ip_address = described_class.new(:address => '1.1.1.1', :version => 7)
|
93
|
+
|
94
|
+
expect(ip_address).not_to be_valid
|
95
|
+
end
|
96
|
+
|
97
|
+
context "with IPv4 address" do
|
98
|
+
subject { described_class.new(:address => '127.0.0.1') }
|
95
99
|
|
96
|
-
|
100
|
+
it { expect(subject.version).to be == 4 }
|
97
101
|
end
|
98
102
|
|
99
|
-
|
100
|
-
|
101
|
-
|
103
|
+
context "with IPv6 address" do
|
104
|
+
subject { described_class.new(:address => '::1') }
|
105
|
+
|
106
|
+
it { expect(subject.version).to be == 6 }
|
102
107
|
end
|
103
108
|
end
|
104
109
|
end
|