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
# File 'lib/ronin/payloads/mixins/reverse_shell.rb', line 44

def self.included(payload)
  payload.param :host, String, required: true,
                               desc:     'The host to connect back to'

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

Instance Method Details

#hostString

The host param value.

Returns:

  • (String)


57
58
59
# File 'lib/ronin/payloads/mixins/reverse_shell.rb', line 57

def host
  params[:host]
end

#perform_cleanupObject

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



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

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.



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

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.



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

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

  super
end

#portInteger

The port param value.

Returns:

  • (Integer)


66
67
68
# File 'lib/ronin/payloads/mixins/reverse_shell.rb', line 66

def port
  params[:port]
end