Skip to content

Commit

Permalink
Also test the ids of the built-in encoders.
Browse files Browse the repository at this point in the history
  • Loading branch information
postmodern committed Aug 15, 2024
1 parent 6b1f26e commit 72e72ca
Show file tree
Hide file tree
Showing 19 changed files with 152 additions and 0 deletions.
8 changes: 8 additions & 0 deletions spec/encoders/builtin/html/encode_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
expect(described_class).to be < Ronin::Payloads::Encoders::HTMLEncoder
end

describe ".id" do
subject { described_class }

it "must equal 'html/encode'" do
expect(subject.id).to eq('html/encode')
end
end

describe "#encode" do
let(:data) { "hello world" }
let(:encoded) { "&#104;&#101;&#108;&#108;&#111;&#32;&#119;&#111;&#114;&#108;&#100;" }
Expand Down
8 changes: 8 additions & 0 deletions spec/encoders/builtin/js/base64_encode_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
expect(described_class).to be < Ronin::Payloads::Encoders::JavaScriptEncoder
end

describe ".id" do
subject { described_class }

it "must equal 'js/base64_encode'" do
expect(subject.id).to eq('js/base64_encode')
end
end

describe "#encode" do
let(:javascript) { "alert(1)" }
let(:encoded) { %{eval(window.btoa("YWxlcnQoMSk="))} }
Expand Down
8 changes: 8 additions & 0 deletions spec/encoders/builtin/js/hex_encode_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
expect(described_class).to be < Ronin::Payloads::Encoders::JavaScriptEncoder
end

describe ".id" do
subject { described_class }

it "must equal 'js/hex_encode'" do
expect(subject.id).to eq('js/hex_encode')
end
end

describe "#encode" do
let(:command) { "alert(1)" }
let(:encoded) { %{eval("\\x61\\x6C\\x65\\x72\\x74\\x28\\x31\\x29")} }
Expand Down
8 changes: 8 additions & 0 deletions spec/encoders/builtin/perl/base64_encode_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
expect(described_class).to be < Ronin::Payloads::Encoders::PerlEncoder
end

describe ".id" do
subject { described_class }

it "must equal 'perl/base64_encode'" do
expect(subject.id).to eq('perl/base64_encode')
end
end

describe "#encode" do
let(:perl) { 'print "PWNED\n"' }
let(:encoded) { %{use MIME::Base64; eval(decode_base64("cHJpbnQgIlBXTkVEXG4i"))} }
Expand Down
8 changes: 8 additions & 0 deletions spec/encoders/builtin/perl/hex_encode_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
expect(described_class).to be < Ronin::Payloads::Encoders::PerlEncoder
end

describe ".id" do
subject { described_class }

it "must equal 'perl/hex_encode'" do
expect(subject.id).to eq('perl/hex_encode')
end
end

describe "#encode" do
let(:perl) { 'print "PWNED\n"' }
let(:encoded) { %{eval(pack("H*","7072696e74202250574e45445c6e22"))} }
Expand Down
8 changes: 8 additions & 0 deletions spec/encoders/builtin/php/base64_encode_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
expect(described_class).to be < Ronin::Payloads::Encoders::PHPEncoder
end

describe ".id" do
subject { described_class }

it "must equal 'php/base64_encode'" do
expect(subject.id).to eq('php/base64_encode')
end
end

describe "#encode" do
let(:php) { "echo 'PWNED';" }
let(:encoded) { %{eval(base64_decode("ZWNobyAnUFdORUQnOw=="));} }
Expand Down
8 changes: 8 additions & 0 deletions spec/encoders/builtin/php/hex_encode_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
expect(described_class).to be < Ronin::Payloads::Encoders::PHPEncoder
end

describe ".id" do
subject { described_class }

it "must equal 'php/hex_encode'" do
expect(subject.id).to eq('php/hex_encode')
end
end

describe "#encode" do
let(:php) { "echo 'PWNED';" }
let(:encoded) { %{eval(hex2bin("6563686f202750574e4544273b"));} }
Expand Down
8 changes: 8 additions & 0 deletions spec/encoders/builtin/powershell/base64_encode_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
expect(described_class).to be < Ronin::Payloads::Encoders::PowerShellEncoder
end

describe ".id" do
subject { described_class }

it "must equal 'powershell/base64_encode'" do
expect(subject.id).to eq('powershell/base64_encode')
end
end

describe "#encode" do
let(:powershell) { "Write-Output 'PWNED'" }
let(:encoded) { %{Invoke-Expression([System.Text.Encoding]::ASCII.GetString([System.Convert]::FromBase64String("V3JpdGUtT3V0cHV0ICdQV05FRCc=")))} }
Expand Down
8 changes: 8 additions & 0 deletions spec/encoders/builtin/powershell/hex_encode_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
expect(described_class).to be < Ronin::Payloads::Encoders::PowerShellEncoder
end

describe ".id" do
subject { described_class }

it "must equal 'powershell/hex_encode'" do
expect(subject.id).to eq('powershell/hex_encode')
end
end

describe "#encode" do
let(:data) { "dir" }
let(:encoded) do
Expand Down
8 changes: 8 additions & 0 deletions spec/encoders/builtin/python/base64_encode_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
expect(described_class).to be < Ronin::Payloads::Encoders::PythonEncoder
end

describe ".id" do
subject { described_class }

it "must equal 'python/base64_encode'" do
expect(subject.id).to eq('python/base64_encode')
end
end

describe "#encode" do
let(:python) { "print('PWNED')" }
let(:encoded) { %{import base64; eval(base64.b64decode("cHJpbnQoJ1BXTkVEJyk="))} }
Expand Down
8 changes: 8 additions & 0 deletions spec/encoders/builtin/python/hex_encode_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
expect(described_class).to be < Ronin::Payloads::Encoders::PythonEncoder
end

describe ".id" do
subject { described_class }

it "must equal 'python/hex_encode'" do
expect(subject.id).to eq('python/hex_encode')
end
end

describe "#encode" do
let(:python) { "print('PWNED')" }
let(:encoded) { %{import binascii; eval(binascii.unhexlify("7072696e74282750574e45442729"))} }
Expand Down
8 changes: 8 additions & 0 deletions spec/encoders/builtin/ruby/base64_encode_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
expect(described_class).to be < Ronin::Payloads::Encoders::RubyEncoder
end

describe ".id" do
subject { described_class }

it "must equal 'ruby/base64_encode'" do
expect(subject.id).to eq('ruby/base64_encode')
end
end

describe "#encode" do
let(:ruby) { "puts('PWNED')" }
let(:encoded) { %{require 'base64'; eval(Base64.decode64("cHV0cygnUFdORUQnKQ=="))} }
Expand Down
8 changes: 8 additions & 0 deletions spec/encoders/builtin/ruby/hex_encode_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
expect(described_class).to be < Ronin::Payloads::Encoders::RubyEncoder
end

describe ".id" do
subject { described_class }

it "must equal 'ruby/hex_encode'" do
expect(subject.id).to eq('ruby/hex_encode')
end
end

describe "#encode" do
let(:ruby) { "puts('PWNED')" }
let(:encoded) { %{eval("70757473282750574e45442729".scan(/../).map(&:hex).map(&:chr).join)} }
Expand Down
8 changes: 8 additions & 0 deletions spec/encoders/builtin/shell/base64_encode_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
expect(described_class).to be < Ronin::Payloads::Encoders::ShellCommandEncoder
end

describe ".id" do
subject { described_class }

it "must equal 'shell/base64_encode'" do
expect(subject.id).to eq('shell/base64_encode')
end
end

describe "#encode" do
let(:command) { "ls -la" }
let(:encoded) { "echo bHMgLWxh|base64 -d|bash" }
Expand Down
8 changes: 8 additions & 0 deletions spec/encoders/builtin/shell/hex_encode_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
expect(described_class).to be < Ronin::Payloads::Encoders::ShellCommandEncoder
end

describe ".id" do
subject { described_class }

it "must equal 'shell/hex_encode'" do
expect(subject.id).to eq('shell/hex_encode')
end
end

describe "#encode" do
let(:command) { "ls -la" }
let(:encoded) { "echo 6c73202d6c61|xxd -r -p|bash" }
Expand Down
8 changes: 8 additions & 0 deletions spec/encoders/builtin/shell/hex_escape_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
expect(described_class).to be < Ronin::Payloads::Encoders::ShellCommandEncoder
end

describe ".id" do
subject { described_class }

it "must equal 'shell/hex_escape'" do
expect(subject.id).to eq('shell/hex_escape')
end
end

describe "#encode" do
let(:command) { "ls -la" }
let(:encoded) { "$'\\x6c\\x73' $'\\x2d\\x6c\\x61'" }
Expand Down
8 changes: 8 additions & 0 deletions spec/encoders/builtin/shell/ifs_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
expect(described_class).to be < Ronin::Payloads::Encoders::ShellCommandEncoder
end

describe ".id" do
subject { described_class }

it "must equal 'shell/ifs'" do
expect(subject.id).to eq('shell/ifs')
end
end

describe "#encode" do
let(:command) { "ls -la" }
let(:encoded) { "ls${IFS}-la" }
Expand Down
8 changes: 8 additions & 0 deletions spec/encoders/builtin/sql/hex_encode_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
expect(described_class).to be < Ronin::Payloads::Encoders::SQLEncoder
end

describe ".id" do
subject { described_class }

it "must equal 'sql/hex_encode'" do
expect(subject.id).to eq('sql/hex_encode')
end
end

describe "#encode" do
let(:data) { "hello world" }
let(:encoded) { "0x68656c6c6f20776f726c64" }
Expand Down
8 changes: 8 additions & 0 deletions spec/encoders/builtin/xml/encode_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
expect(described_class).to be < Ronin::Payloads::Encoders::XMLEncoder
end

describe ".id" do
subject { described_class }

it "must equal 'xml/encode'" do
expect(subject.id).to eq('xml/encode')
end
end

describe "#encode" do
let(:data) { "hello world" }
let(:encoded) { "&#104;&#101;&#108;&#108;&#111;&#32;&#119;&#111;&#114;&#108;&#100;" }
Expand Down

0 comments on commit 72e72ca

Please sign in to comment.