Izvestnyj rassadnik dyryavyh skriptov www.freecode.com izobiluet primerami nebezopasnyh skriptov. Ne berite ottuda nichego. Rassmotrim neskol'ko primerov:
Skript-menedzher reklamnyh ob®yavlenij
|to pervyj skript s www.freecode.com.
# First version 1.1
# Dan Bloomquist dan@lakeweb.net
Avtor pereda£t vse parametry, s kotorymi byl vyzvan skript v %DATA. On ne ochishchaet '..', ne ochishaet i nulevye bajty. Itak, poglyadim kod...
#This sets the real paths to the html and lock files.
#It is done here, after the POST data is read.
#of the classified page.
$pageurl= $realpath . $DATA{ 'adPath' } . ".html";
$lockfile= $realpath . $DATA{ 'adPath' } . ".lock";
Ispol'zuya 'adPath=/../../../../../etc/passwd%00' - my mozhem ukazat' $pageurl na fajl s parolyami. Posmotrim na $lockfile. My ne mozhem ispol'zovat' pajp dlya nashih nuzhd - tak kak rasshirenie (.html) dobavlyaetsya v poslednyuyu ochered'.
#Read in the classified page
open( FILE,"$pageurl" ) || die "can't open to read
$pageurl: $!\n";
@lines= ;
close( FILE );
Tut v $pageurl zanositsya imya fajla, kooryj zatem otkryvaetsya. K schast'yu dlya avtora, on nemedlenno okryvaet $pageurl na zapis'. Itak, my dolzhny imet' prava na zapis' v to, chto, voobshche-to pytaemsya otkryt' na chtenie. |to ogranichivaet nashi vozmozhnosti ispol'zovaniya dannoj uyazvimosti, no eto est' zhivoj primer togo, kak sam togo ne znaya, avtor sil'no svyazal nam ruki v raskalyvanii serverov cherez ego skript.
Ves'ma interesno otkryvaetsya i mejler.
#Send your mail out.
#
open( MAIL, "|$mailprog $DATA{ 'adEmail' }" )
|| die "can't open sendmail: $adEmail: $!\n";
Oh.. eto my videli uzhe sto raz. Ne proveryayutsya ni simvoly perenapravleniya potoka dannyh, ni pajpy.. my mozhem vypolnit' lyubuyu komandu cherez eto.
Tak zhe ya nash£l prosten'kij logger dannyh, kotorye pol'zovatel' vvodit v veb-formu.
# flexform.cgi
# Written by Leif M. Wright
# leif@conservatives.net
Itak, vhodnye dannye peredayutsya v %CONTENTS, i opyat' nikakoj poverki na podozritel'nye simvoly. Zatem
$output = $basedir . $contents{'file'};
open(RESULTS, ">>$output");
Ispol'zuya standartnyj vyhod za predely papki, kuda nas posadili (/../../) , nam dazhe ne prid£tsya ispol'zovat' nefil'traciyu 0x00. No chto by my ne otkryli - fajl otkryvaetsya dlya dopisyvaniya, i poetomu my dolzhny imet' prava na zapis' v tot fajl, kotoryj pytaemsya otkryt'. Po etoj zhe prichine ne srabotaet i pipe (|) bug.
Itak, na segodnya obzor nedokumentirovannyh vozmozhnostej razlichnyh skriptov, i rasskazy o tom, kak ih sdelat' bolee bezopasnymi, okochneny. Spasibo vsem za vnimanie!
.rain.worest.puppy. [ADM/Wiretrip] rfp@wiretrip.net
Last-modified: Thu, 27 Jan 2000 16:40:27 GMT