Class: Ronin::Payloads::Bin::UNIX::ReverseShell

Inherits:
CPayload show all
Includes:
Metadata::OS, Mixins::ReverseShell, Mixins::Tempfile
Defined in:
lib/ronin/payloads/builtin/bin/unix/reverse_shell.rb

Overview

UNIX C reverse shell that executes "cmd".

Constant Summary collapse

SOURCE_FILE =

The path to the reverse_shell.c file.

File.join(__dir__,'reverse_shell.c')

Instance Attribute Summary

Attributes included from Mixins::PostEx

#session

Attributes inherited from Payload

#encoders, #payload

Instance Method Summary collapse

Methods included from Mixins::Tempfile

#tempfile

Methods included from Mixins::ReverseShell

#host, included, #perform_cleanup, #perform_postlaunch, #perform_prelaunch, #port

Methods included from Mixins::PostEx

#perform_cleanup

Methods included from Metadata::OS

included, #os, #os_version

Methods inherited from CPayload

payload_type

Methods included from Mixins::CCompiler

cc, #cc, #compile_c, included, #target_arch, #target_os, #target_platform, #target_vendor

Methods inherited from Ronin::Payloads::BinaryPayload

payload_type

Methods inherited from Payload

#built?, #built_payload, #bytesize, #cleanup, #encode_payload, #encoded_payload, encoder_class, #initialize, #length, payload_type, #perform_build, #perform_cleanup, #perform_postlaunch, #perform_prelaunch, #perform_validate, #postlaunch, #prelaunch, #rebuild_payload, #reencode_payload, register, #to_s, #validate

Constructor Details

This class inherits a constructor from Ronin::Payloads::Payload

Instance Method Details

#buildObject

Builds the shellcode.



68
69
70
71
72
73
74
75
76
77
78
# File 'lib/ronin/payloads/builtin/bin/unix/reverse_shell.rb', line 68

def build
  tempfile('reverse_shell', ext: '.c') do |tempfile|
    compile(SOURCE_FILE, defs: {
                           'CLIENT_IP'   => "\"#{params[:host]}\"",
                           'CLIENT_PORT' => params[:port]
                         },
                         output: tempfile.path)

    @payload = File.binread(tempfile.path)
  end
end