Skip to content

Commit

Permalink
Add default param values to Mixins::ReverseShell (closes #114).
Browse files Browse the repository at this point in the history
* Default `host` to `0.0.0.0`.
* Default `port` to `4444`.
  • Loading branch information
postmodern committed Apr 27, 2024
1 parent 1af0328 commit 99ed053
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/ronin/payloads/mixins/reverse_shell.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@ module ReverseShell
#
def self.included(payload)
payload.param :host, String, required: true,
default: '0.0.0.0',
desc: 'The host to connect back to'

payload.param :port, Integer, required: true,
default: 4444,
desc: 'The port to connect back to'
end

Expand Down
18 changes: 18 additions & 0 deletions spec/mixins/reverse_shell_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ class TestPayload < Ronin::Payloads::Payload
expect(subject.params[:host]).to_not be_nil
expect(subject.params[:host].type).to be_kind_of(Ronin::Core::Params::Types::String)
expect(subject.params[:host].required?).to be(true)
expect(subject.params[:host].default).to eq('0.0.0.0')
expect(subject.params[:host].desc).to eq('The host to connect back to')
end

it "must add a required 'port' param" do
expect(subject.params[:port]).to_not be_nil
expect(subject.params[:port].type).to be_kind_of(Ronin::Core::Params::Types::Integer)
expect(subject.params[:port].required?).to be(true)
expect(subject.params[:port].default).to eq(4444)
expect(subject.params[:port].desc).to eq('The port to connect back to')
end
end
Expand All @@ -40,12 +42,28 @@ class TestPayload < Ronin::Payloads::Payload
it "must return the 'host' param value" do
expect(subject.host).to eq(host)
end

context "when no 'host' param value is given" do
subject { payload_class.new }

it "must default to '0.0.0.0'" do
expect(subject.host).to eq('0.0.0.0')
end
end
end

describe "#port" do
it "must return the 'port' param value" do
expect(subject.port).to eq(port)
end

context "when no 'port' param value is given" do
subject { payload_class.new }

it "must default to 4444" do
expect(subject.port).to eq(4444)
end
end
end

describe "#perform_prelaunch" do
Expand Down

0 comments on commit 99ed053

Please sign in to comment.