From: Stephan Walter <stephan.walter@gmx.ch>
To: linux-assembly@vger.kernel.org
Subject: Re: shellcode
Date: Tue, 25 Jun 2002 22:28:25 +0200 [thread overview]
Message-ID: <20020625222825.428828b3.stephan.walter@gmx.ch> (raw)
In-Reply-To: <20020625144651.A430@nietzsche>
On Tue, 25 Jun 2002 14:46:51 -0500, xlp <xlp@emtel.net.co> wrote:
> Stephan, it's so complicated, i dont get it, what's objdump for?
> if a buffer is char [10], how is the sfp, ret and shellcode length?
objdump? Why would you want to use that? See "man objdump".
Let's have a look at your code:
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";
int main() {
void (*s)()=(void *)bsdshell;
s();
}
"bsdshell" is an array of char which contains the assembly code. It is
25 bytes long, but you could make it smaller by optimizing the code.
If you disassemble these bytes, it looks like this:
xor eax,eax
push eax
push dword 0x68732f2f
push dword 0x6e69622f
mov ebx,esp
push eax
push ebx
push eax
push esp
push ebx
mov al,0x3b
push eax
int 0x80
The important thing is that it uses "int 0x80" (last line). This
interrupt is used to tell the kernel to do something. In this case, it
is the system call named "execve", which means that the kernel should
execute a program.
The function "s" is a pointer of type void to bsdshell. On the next line
you execute this "s". It is not a C function, just some lonely bytes in
the memory. But your CPU jumps to this code just as it was a C function,
and now the code listed above gets executed.
What do you mean with sfp and ret? If you mean the ret (return) command,
the answer's short: there is no return. If you type "exit" in the shell,
your program will crash.
I don't know if this answers your questions. Just write to the mailing
list if you have trouble understanding this
Regards,
Stephan
next prev parent reply other threads:[~2002-06-25 20:28 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 ` Stephan Walter [this message]
[not found] ` <20020625161401.B27404@nietzsche>
2002-06-26 17:08 ` shellcode Stephan Walter
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=20020625222825.428828b3.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox