-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
Archive
and GitArchive
output formats
- Loading branch information
Showing
5 changed files
with
195 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# frozen_string_literal: true | ||
# | ||
# ronin-recon - A micro-framework and tool for performing reconnaissance. | ||
# | ||
# Copyright (c) 2023-2024 Hal Brodigan (postmodern.mod3@gmail.com) | ||
# | ||
# ronin-recon is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Lesser General Public License as published | ||
# by the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# ronin-recon is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Lesser General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Lesser General Public License | ||
# along with ronin-recon. If not, see <https://www.gnu.org/licenses/>. | ||
# | ||
|
||
require 'ronin/web/spider/archive' | ||
|
||
module Ronin | ||
module Recon | ||
module OutputFormats | ||
# | ||
# Represents a web archive directory. | ||
# | ||
class Archive < Ronin::Web::Spider::Archive | ||
|
||
# | ||
# Writes a new URL to it's specific file. | ||
# | ||
# @param [Value] value | ||
# The value to write. | ||
# | ||
def <<(value) | ||
if Values::URL === value | ||
write(value.uri, value.body) | ||
end | ||
end | ||
|
||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# frozen_string_literal: true | ||
# | ||
# ronin-recon - A micro-framework and tool for performing reconnaissance. | ||
# | ||
# Copyright (c) 2023-2024 Hal Brodigan (postmodern.mod3@gmail.com) | ||
# | ||
# ronin-recon is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Lesser General Public License as published | ||
# by the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# ronin-recon is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Lesser General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Lesser General Public License | ||
# along with ronin-recon. If not, see <https://www.gnu.org/licenses/>. | ||
# | ||
|
||
require 'ronin/recon/values/url' | ||
|
||
require 'ronin/web/spider/git_archive' | ||
|
||
module Ronin | ||
module Recon | ||
module OutputFormats | ||
# | ||
# Represents a web archive directory that is backed by Git. | ||
# | ||
class GitArchive < Ronin::Web::Spider::GitArchive | ||
|
||
# | ||
# Initializes new Git repository. | ||
# | ||
# @param [String] root | ||
# The path to the root directory. | ||
# | ||
def initialize(root) | ||
super(root) | ||
|
||
init unless git? | ||
end | ||
|
||
# | ||
# Writes a new URL to it's specific file in Git archive. | ||
# | ||
# @param [Value] value | ||
# The value to write. | ||
# | ||
def <<(value) | ||
if Values::URL === value | ||
write(value.uri, value.body) | ||
end | ||
end | ||
|
||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
require 'spec_helper' | ||
require 'ronin/recon/output_formats/archive' | ||
require 'ronin/recon/values/url' | ||
require 'ronin/recon/values/domain' | ||
require 'tmpdir' | ||
|
||
describe Ronin::Recon::OutputFormats::Archive do | ||
subject { described_class.new(path) } | ||
|
||
let(:path) { Dir.mktmpdir('ronin-recon-output-archive') } | ||
|
||
it "must inherit from Ronin::Web::Spider::Archive" do | ||
expect(described_class).to be < Ronin::Web::Spider::Archive | ||
end | ||
|
||
describe "#<<" do | ||
context "for Values::URL" do | ||
let(:value) { Ronin::Recon::Values::URL.new('https://www.example.com/foo.html') } | ||
let(:expected_path) { File.join(path,value.path) } | ||
|
||
it "must create a new file with webpage" do | ||
subject << value | ||
|
||
expect(File.exist?(expected_path)).to be(true) | ||
end | ||
end | ||
|
||
context "for other values" do | ||
let(:value) { Ronin::Recon::Values::Domain.new('example.com') } | ||
|
||
it "must not create any files" do | ||
subject << value | ||
|
||
expect(Dir.glob("#{path}/*")).to be_empty | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
require 'spec_helper' | ||
require 'ronin/recon/output_formats/git_archive' | ||
require 'ronin/recon/values/url' | ||
require 'ronin/recon/values/domain' | ||
require 'tmpdir' | ||
|
||
describe Ronin::Recon::OutputFormats::GitArchive do | ||
subject { described_class.new(path) } | ||
|
||
let(:path) { Dir.mktmpdir('ronin-recon-output-git-archive') } | ||
|
||
it "must inherit from Ronin::Web::Spider::GitArchive" do | ||
expect(described_class).to be < Ronin::Web::Spider::GitArchive | ||
end | ||
|
||
describe "#<<" do | ||
context "for Values::URL" do | ||
let(:value) { Ronin::Recon::Values::URL.new('https://www.example.com/foo.html') } | ||
let(:expected_path) { File.join(path,value.path) } | ||
|
||
it "must create a new file with webpage" do | ||
subject << value | ||
|
||
expect(File.exist?(expected_path)).to be(true) | ||
end | ||
end | ||
|
||
context "for other values" do | ||
let(:value) { Ronin::Recon::Values::Domain.new('example.com') } | ||
|
||
it "must not create any files" do | ||
subject << value | ||
|
||
expect(Dir.glob("#{path}/*")).to be_empty | ||
end | ||
end | ||
end | ||
end |