Thisislegal.com

:[ Login ]:

welcome, please log-in:




 Remember Me  ?
About: Remember Me
Ticking this box will make the site remember you for 24 hours. However, each time you visit the site this time is renewed, so if you are a regular visitor you will stay logged in.


Register An Account
Forgot Password?

:[ Forums ]:
Latest post in: Challenge Help
topic:
real 4
by: Karlito
:[ Welcome ]:

The NULL Byte


Do not mix up the NULL byte with 0 (zero)!
The NULL byte is the byte with the hex representation "%00".
It also might be written as "\\0". For PHP, the NULL Byte is a NULL character. The problem is PHP is coded in C and the NULL Byte in C is a string terminator. This means that the string stops when there is a NULL Byte!

Also system calls passed to the operation system should be filtered carefully. UNIX is written in C too, and so the string termination character NULL might lead to problems.

The best example is to fool web application into thinking a different file type has been requested. Take a look at the code below:

<?php
$file = $HTTP_GET_VARS['file'];
$file = $file .'.txt';
fopen($file, 'r');
?>


The script doesn't look so bad. It takes the filename that it gets and puts a ".txt" on the end. So the programmer tries to make sure that only text files can be opened. But what about a filename like this:
phppage.php%00


It will try to get:

phppage.php%00.txt


So fopen opens phppage.php%00.txt? No! And that is the point. The fopen functions stops after ".php" before the NULL Byte and opens only "phppage.php". So every type of file can be opened.

Scripts that allow uploads (but only for a certain file type) are also a potential target for this type of attack.

For another usefull example of the NULL byte have a look at /*ereg()*/.



Was this tutorial helpful? please rate:

You Must Login To Vote




Previous Tutorial  |  Next Tutorial


Tutorial By Raduce

Comments:

xyberz09Reply 
0


I guess we've got a 'Guest' spammer in here tongue.png
xyberz09Reply 
0


Please post the link to the other tutorial
RaducEReply 
0


No prob.I was running out of ideas and I wrote this.
t0mmy9Reply 
0


short but helpful, thanks smile.gif


Submit Comment:


Human test. Enter "QJH"



Who's online: flipp

Click here to Vote!    Firefox 3  Opera Web Browser  Valid XHTML 1.0 Transitional

Home | Challenges | Forums | Contact | About (Disclaimer)
Copyright © 2007-11 Thisislegal.com, All Rights Reserved

 
:[ ShoutBox ]:
Guest - Login to post comments


Karlito:
crack it
niken:
how get wpa password
sidolo:
maybe you have the wrong kind of network card?
12345:
why doesnt my airodump detect wireless networks?
Andrew3726:
IDA Pro, i think smile.gif
ksydfius:
app challenge 4? whats the best 16-bit debugger?
dot_Cipher:
The internet says hi smile.gif
Pages: 1, 2...195
Goto: