Username / Password :   

    $  .  /  0  1  2  3  4  6  8  9  A  B  C  D  E  F  G  H  I  J  K  L  M  N  O  P  Q  R  S  T  U  V  W  X  Y  Z  [  ~
The LinuxDig.Com Linux Dictionary is currently in Beta.
You can help, email Comments or Suggestions here.
I.E. users please click.
Number of Terms : 8142 Number of Definitions : 9135

format-string attacks (printf())

1. A common vulnerability created by programmers who use tainted input as the format string for printf() (a common C function). Normally, printf() uses a "format string" to specify how following data will be formatted when printed. For example, when printing the time, you could use the following command: printf("%02d:%02d:%02d", hours, minutes, seconds); This will print the time in a format that looks like "09:15:00" (i.e. quarter after nine). The format string "%02d" means print a decimal number that is 2 digits long, and if the number isn't long enough, put a 0 at the front. Character strings can be printed in a similar manner: printf("greetings=%s", "hello"); This prints the output: greetings=Hello However, if you wanted to be lazy, you could simply program the system: printf("greetings=Hello"); Up to this point, everything is fine. The problem comes about when the string is read from input: g = read_input(); printf(g); The programmer is expecting the user to enter normal input such as "Hi". However, the user could enter something like "die %s". This makes the above statement equivalent to: printf("die %s"); Since there is no following string, this may cause the program to crash. The correct way that this should have been handled is: g = read_input(); printf("%s", g); Printf will treat the first parameter as the format string, but will know not to interpret any formatting characters in subsequent strings. Key point: A popular technique to see if a system is possibly vulnerable to format string bugs is to send the input "%x %x %x". If the hacker sees hex output, then they know the system was vulnerable to format string bugs. From Hacking-Lexicon
Source:
Linux Dictionary (version 0.12)
author: Binh Nguyen
linuxfilesystem(at)yahoo(dot)com(dot)au

This Linux Dictionary is distributed under the GNU
Free Documentation License. Online version is at
http://www.tldp.org/LDP/Linux-Dictionary/html/index.htm




Site Hosted By Digital Environments, Inc. This Website was Created with DE-Web Version 1.9.7.4,
The Fast, Web Based - Website Design Tool, Groupware and Web Hosting System by Digital Environments, Inc.
Groupware:Project Management, Sales Tracking, Web Site Design and News / Blogger all in one package.