Skip to content

Commit

Permalink
sample/exeencode: fix inline sample source
Browse files Browse the repository at this point in the history
  • Loading branch information
jj committed May 13, 2009
1 parent 7591f15 commit 7263390
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 35 deletions.
33 changes: 8 additions & 25 deletions samples/elfencode.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,15 @@
load File.join(File.dirname(__FILE__), 'exeencode.rb')

__END__
.interp '/lib/ld-linux.so.2'
.pt_gnu_stack rw

.data
toto db "world", 0
fmt db "Hello, %s !\n", 0

.text
.entrypoint
call metasm_intern_geteip
mov esi, eax
lea eax, [esi-metasm_intern_geteip+toto]
push eax
lea eax, [esi-metasm_intern_geteip+fmt]
push eax
call printf
add esp, 8
push bla
push fmt
call printf
push 0
call exit

push 28h
call _exit
add esp, 4
ret

metasm_intern_geteip:
call 1f
1:
pop eax
add eax, metasm_intern_geteip - 1b
ret
.data
bla db "world", 0
fmt db "Hello, %s !\n", 0
27 changes: 17 additions & 10 deletions samples/exeencode.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,21 @@
end

__END__
.text
.entrypoint
push bla
push fmt
call printf
push 0
call exit
#include <asm/unistd_32.h>
jmp getip
gotip:
mov eax, __NR_write
mov ebx, 1
pop ecx
mov edx, strend-str
int 80h

.data
bla db "world", 0
fmt db "Hello, %s !\n", 0
mov eax, __NR_exit
mov ebx, 1
int 80h

getip:
call gotip

str db "Hello, world!", 0xa
strend:

0 comments on commit 7263390

Please sign in to comment.