Skip to content

Commit

Permalink
Added the --python option to ronin unescape (closes #224).
Browse files Browse the repository at this point in the history
  • Loading branch information
postmodern committed Nov 23, 2024
1 parent 72ebc4b commit 81e7ed7
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/ronin/cli/commands/unescape.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ module Commands
# -S, --shell Unescapes the data as a Shell String
# -P, --powershell Unescapes the data as a PowerShell String
# -p, --php Unescapes the data as a PHP String
# --python Unescapes the data as a Python String
# -R, --ruby Unescapes the data as a Ruby String
# -Q, --quoted-printable Unescapes the data as Quoted Printable
# -x, --xml XML unescapes the data
Expand Down Expand Up @@ -120,6 +121,11 @@ class Unescape < StringMethodsCommand
@method_calls << :php_unescape
end

option :python, desc: 'Unescapes the data as a Python String' do
require 'ronin/support/encoding/python'
@method_calls << :python_unescape
end

option :ruby, short: '-R',
desc: 'Unescapes the data as a Ruby String' do
require 'ronin/support/encoding/ruby'
Expand Down
3 changes: 3 additions & 0 deletions man/ronin-unescape.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ Unescapes each escaped character from a variety of encodings.
`-p`, `--php`
: Unescapes the data as a PHP String.

`--python`
: Unescapes the data as a Python String.

`-R`, `--ruby`
: Unescapes the data as a Ruby String.

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

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

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

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

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

Expand Down

0 comments on commit 81e7ed7

Please sign in to comment.