Skip to content

Commit

Permalink
Added the --java option to ronin unquote (closes #244).
Browse files Browse the repository at this point in the history
  • Loading branch information
postmodern committed Nov 23, 2024
1 parent 209f2ac commit 6060003
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/ronin/cli/commands/unquote.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ module Commands
# -n, --keep-newlines Preserves newlines at the end of each line
# -X, --hex Unquotes the Hex string
# -c, --c Unquotes the C string
# -J, --java Unquotes the Java String
# -j, --js Unquotes the JavaScript String
# -S, --shell Unquotes the Shell String
# -P, --powershell Unquotes the PowerShell String
Expand All @@ -62,6 +63,12 @@ class Unquote < StringMethodsCommand
@method_calls << :c_unquote
end

option :java, short: '-J',
desc: 'Unquotes the Java String' do
require 'ronin/support/encoding/java'
@method_calls << :java_unquote
end

option :js, short: '-j',
desc: 'Unquotes the JavaScript String' do
require 'ronin/support/encoding/js'
Expand Down
3 changes: 3 additions & 0 deletions man/ronin-unquote.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ Unquotes a double/single quoted string.
`-c`, `--c`
: Unquotes the C string.

`-J`, `--java`
: Unquotes the Java String.

`-j`, `--js`
: Unquotes the JavaScript String.

Expand Down
12 changes: 12 additions & 0 deletions spec/cli/commands/unquote_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,18 @@
end
end

describe "--java" do
let(:argv) { %w[--java] }

it "must require 'ronin/support/encoding/java'" do
expect(require('ronin/support/encoding/java')).to be(false)
end

it "must add :java_unquote to #method_calls" do
expect(subject.method_calls.last).to eq(:java_unquote)
end
end

describe "--js" do
let(:argv) { %w[--js] }

Expand Down

0 comments on commit 6060003

Please sign in to comment.