Module: Ronin::Payloads::Mixins::ReverseShell

Overview

Common params and methods for reverse shell payloads.

Instance Attribute Summary

Attributes included from PostEx

#session

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(payload) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Adds the host and port required options to the payload.

Parameters:



44
45
46
47
48
49
50
51
52
# File 'lib/ronin/payloads/mixins/reverse_shell.rb', line 44

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

Instance Method Details

#hostString

The host param value.

Returns:

  • (String)


59
60
61
# File 'lib/ronin/payloads/mixins/reverse_shell.rb', line 59

def host
  params[:host]
end

#perform_cleanupObject

Performs additional cleanup steps, then closes any connections and the server socket.



99
100
101
102
103
104
105
106
# File 'lib/ronin/payloads/mixins/reverse_shell.rb', line 99

def perform_cleanup
  super

  if @server
    @server.close
    @server = nil
  end
end

#perform_postlaunchObject

Waits for an incoming connect on #host and #port, then performs additional post-launch steps.



87
88
89
90
91
92
93
# File 'lib/ronin/payloads/mixins/reverse_shell.rb', line 87

def perform_postlaunch
  print_info "Waiting for connection on #{host}:#{port} ..."
  @session = Ronin::PostEx::Sessions::ReverseShell.new(@server.accept)
  print_info "Accepted connection from #{@session.name}!"

  super
end

#perform_prelaunchObject

Opens a server socket using #host and #port, then performs additional pre-launch steps.



76
77
78
79
80
81
# File 'lib/ronin/payloads/mixins/reverse_shell.rb', line 76

def perform_prelaunch
  @server = TCPServer.new(host,port)
  @server.listen(1)

  super
end

#portInteger

The port param value.

Returns:

  • (Integer)


68
69
70
# File 'lib/ronin/payloads/mixins/reverse_shell.rb', line 68

def port
  params[:port]
end