Skip to content

Commit

Permalink
Use hyphenated option values for --lfi-filter-bypass and `--filter-…
Browse files Browse the repository at this point in the history
…bypass`.
  • Loading branch information
postmodern committed May 14, 2024
1 parent b5c0117 commit a50383a
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 26 deletions.
16 changes: 8 additions & 8 deletions lib/ronin/vulns/cli/commands/lfi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ module Commands
# -i, --input FILE Reads URLs from the list file
# -O, --os unix|windows Sets the OS to test for
# -D, --depth COUNT Sets the directory depth to escape up
# -B null_byte|double_escape|base64|rot13|zlib,
# -B null-byte|double-escape|base64|rot13|zlib,
# --filter-bypass Sets the filter bypass strategy to use
# -h, --help Print help information
#
Expand Down Expand Up @@ -92,13 +92,13 @@ class Lfi < WebVulnCommand

option :filter_bypass, short: '-B',
value: {
type: [
:null_byte,
:double_escape,
:base64,
:rot13,
:zlib
]
type: {
'null-byte' => :null_byte,
'double-escape' => :double_escape,
'base64' => :base64,
'rot13' => :rot13,
'zlib' => :zlib
}
},
desc: 'Sets the filter bypass strategy to use' do |filter_bypass|
scan_kwargs[:filter_bypass] = filter_bypass
Expand Down
16 changes: 8 additions & 8 deletions lib/ronin/vulns/cli/commands/scan.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ module Commands
# -i, --input FILE Reads URLs from the list file
# --lfi-os unix|windows Sets the OS to test for
# --lfi-depth COUNT Sets the directory depth to escape up
# --lfi-filter-bypass null_byte|double_escape|base64|rot13|zlib
# --lfi-filter-bypass null-byte|double-escape|base64|rot13|zlib
# Sets the filter bypass strategy to use
# --rfi-filter-bypass double-encode|suffix-escape|null-byte
# Optional filter-bypass strategy to use
Expand Down Expand Up @@ -98,13 +98,13 @@ class Scan < WebVulnCommand
end

option :lfi_filter_bypass, value: {
type: [
:null_byte,
:double_escape,
:base64,
:rot13,
:zlib
]
type: {
'null-byte' => :null_byte,
'double-escape' => :double_escape,
'base64' => :base64,
'rot13' => :rot13,
'zlib' => :zlib
}
},
desc: 'Sets the filter bypass strategy to use' do |filter_bypass|
lfi_kwargs[:filter_bypass] = filter_bypass
Expand Down
4 changes: 2 additions & 2 deletions man/ronin-vulns-scan.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ additional arguments or read from a file using the `--input` option.
`--lfi-depth` *NUM*
: Sets the directory depth to escape up.

`--lfi-filter-bypass` `null_byte`\|`double_escape`\|`base64`\|`rot13`\|`zlib`
`--lfi-filter-bypass` `null-byte`\|`double-escape`\|`base64`\|`rot13`\|`zlib`
: Sets the filter bypass strategy to use.

`--rfi-filter-bypass` `double-encode`\|`suffix-escape`\|`null-byte`
Expand Down Expand Up @@ -132,4 +132,4 @@ Postmodern <[email protected]>

## SEE ALSO

[ronin-vulns-lfi](ronin-vulns-lfi.1.md) [ronin-vulns-rfi](ronin-vulns-rfi.1.md) [ronin-vulns-sqli](ronin-vulns-sqli.1.md) [ronin-vulns-ssti](ronin-vulns-ssti.1.md) [ronin-vulns-open-redirect](ronin-vulns-open-redirect.1.md) [ronin-vulns-reflected-xss](ronin-vulns-reflected-xss.1.md)
[ronin-vulns-lfi](ronin-vulns-lfi.1.md) [ronin-vulns-rfi](ronin-vulns-rfi.1.md) [ronin-vulns-sqli](ronin-vulns-sqli.1.md) [ronin-vulns-ssti](ronin-vulns-ssti.1.md) [ronin-vulns-open-redirect](ronin-vulns-open-redirect.1.md) [ronin-vulns-reflected-xss](ronin-vulns-reflected-xss.1.md)
48 changes: 44 additions & 4 deletions spec/cli/commands/lfi_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,53 @@
end

context "when the '--filter-bypass' option is parsed" do
let(:filter_bypass) { :base64 }
let(:argv) { ['--filter-bypass', filter_bypass.to_s] }
let(:argv) { ['--filter-bypass', option_value] }

before { subject.option_parser.parse(argv) }

it "must set the :filter_bypass key in the Hash" do
expect(subject.scan_kwargs[:filter_bypass]).to eq(filter_bypass)
context "and it's value is 'null-byte'" do
let(:option_value) { 'null-byte' }
let(:filter_bypass) { :null_byte }

it "must set the :filter_bypass key in the Hash to :null_byte" do
expect(subject.scan_kwargs[:filter_bypass]).to eq(filter_bypass)
end
end

context "and it's value is 'double-escape'" do
let(:option_value) { 'double-escape' }
let(:filter_bypass) { :double_escape }

it "must set the :filter_bypass key in the Hash to :double_escape" do
expect(subject.scan_kwargs[:filter_bypass]).to eq(filter_bypass)
end
end

context "and it's value is 'base64'" do
let(:option_value) { 'base64' }
let(:filter_bypass) { :base64 }

it "must set the :filter_bypass key in the Hash to :base64" do
expect(subject.scan_kwargs[:filter_bypass]).to eq(filter_bypass)
end
end

context "and it's value is 'rot13'" do
let(:option_value) { 'rot13' }
let(:filter_bypass) { :rot13 }

it "must set the :filter_bypass key in the Hash to :rot13" do
expect(subject.scan_kwargs[:filter_bypass]).to eq(filter_bypass)
end
end

context "and it's value is 'zlib'" do
let(:option_value) { 'zlib' }
let(:filter_bypass) { :zlib }

it "must set the :filter_bypass key in the Hash to :zlib" do
expect(subject.scan_kwargs[:filter_bypass]).to eq(filter_bypass)
end
end
end
end
Expand Down
48 changes: 44 additions & 4 deletions spec/cli/commands/scan_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,53 @@
end

context "when the '--lfi-filter-bypass' option is parsed" do
let(:filter_bypass) { :base64 }
let(:argv) { ['--lfi-filter-bypass', filter_bypass.to_s] }
let(:argv) { ['--lfi-filter-bypass', option_value] }

before { subject.option_parser.parse(argv) }

it "must set the :filter_bypass key in the Hash" do
expect(subject.lfi_kwargs[:filter_bypass]).to eq(filter_bypass)
context "and it's value is 'null-byte'" do
let(:option_value) { 'null-byte' }
let(:filter_bypass) { :null_byte }

it "must set the :filter_bypass key in #lfi_kwargs to :null_byte" do
expect(subject.lfi_kwargs[:filter_bypass]).to eq(filter_bypass)
end
end

context "and it's value is 'double-escape'" do
let(:option_value) { 'double-escape' }
let(:filter_bypass) { :double_escape }

it "must set the :filter_bypass key in #lfi_kwargs to :double_escape" do
expect(subject.lfi_kwargs[:filter_bypass]).to eq(filter_bypass)
end
end

context "and it's value is 'base64'" do
let(:option_value) { 'base64' }
let(:filter_bypass) { :base64 }

it "must set the :filter_bypass key in #lfi_kwargs to :base64" do
expect(subject.lfi_kwargs[:filter_bypass]).to eq(filter_bypass)
end
end

context "and it's value is 'rot13'" do
let(:option_value) { 'rot13' }
let(:filter_bypass) { :rot13 }

it "must set the :filter_bypass key in #lfi_kwargs to :rot13" do
expect(subject.lfi_kwargs[:filter_bypass]).to eq(filter_bypass)
end
end

context "and it's value is 'zlib'" do
let(:option_value) { 'zlib' }
let(:filter_bypass) { :zlib }

it "must set the :filter_bypass key in #lfi_kwargs to :zlib" do
expect(subject.lfi_kwargs[:filter_bypass]).to eq(filter_bypass)
end
end
end

Expand Down

0 comments on commit a50383a

Please sign in to comment.