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: [Format String vulnerabilities]

RE: [Format String vulnerabilities]

From: Chris Eagle <cseagle_at_redshift.com>
Date: Sat, 29 May 2004 04:00:21 -0700

Gerardo Richarte wrote:
> > Surely however the format string *itself* isn't passed on the stack
> > but a pointer to the format string. therefore the %x modifer would
> > return a hex representation of the address pointing to the string, *not*
> > a hex representation of the string contents?
>
> Everything you said is correct, except for 2 things:
>
> . the fact that the format string itself is not in the
> stack. This is actually why there is a buf[1024] and a
> strncpy(buf,argv[1],sizeof(buf)): to copy the format string to the stack.
>
...
> the code is:
>
> > fmt1.c ----------------------------------------------------
> >
> > int main(int argc, char *argv[]) {
> > char buf[1024];
> >
> > strncpy(buf, argv[1], sizeof(buf));
> > printf(argv[1]);
> > printf("\n");
> > }
> > ------------------------------------------------------------

argv[1] is already on the stack, there is no need for the strncpy call to
copy the format string to the stack. In fact, in this case, the call places
a second copy of argv[1] on the stack.

Chris
Received on May 29 2004

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