Skip to content

Commit

Permalink
Added the --python option to ronin encode (closes #221).
Browse files Browse the repository at this point in the history
  • Loading branch information
postmodern committed Nov 23, 2024
1 parent 2f4491b commit ccc35c9
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/encode.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ module Commands
# --punycode Encodes the data as Punycode
# -Q, --quoted-printable Encodes the data as Quoted Printable
# -p, --php Encodes the data as a PHP String
# --python Encodes the data as a Python String
# -R, --ruby Encodes the data as a Ruby String
# --uuencode uuencodes the data
# -x, --xml XML encodes the data
Expand Down Expand Up @@ -169,6 +170,11 @@ class Encode < StringMethodsCommand
@method_calls << :php_encode
end

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

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

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

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

Expand Down
12 changes: 12 additions & 0 deletions spec/cli/commands/encode_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,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 :ruby_encode to #method_calls" do
expect(subject.method_calls.last).to eq(:python_encode)
end
end

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

Expand Down

0 comments on commit ccc35c9

Please sign in to comment.