Zacznijmy kurs

Error Reporting

Rozdział 28. Error Reporting

With PHP security, there are two sides to error reporting. One is beneficial to increasing security, the other is detrimental.

A standard attack tactic involves profiling a system by feeding it improper data, and checking for the kinds, and contexts, of the errors which are returned. This allows the system cracker to probe for information about the server, to determine possible weaknesses. For example, if an attacker had gleaned information about a page based on a prior form submission, they may attempt to override variables, or modify them:

Przykład 28-1. Attacking Variables with a custom HTML page

<form method="post" action="attacktarget?username=badfoo&amp;password=badfoo">
<input type="hidden" name="username" value="badfoo" />
<input type="hidden" name="password" value="badfoo" />
</form>

The PHP errors which are normally returned can be quite helpful to a developer who is trying to debug a script, indicating such things as the function or file that failed, the PHP file it failed in, and the line number which the failure occurred in. This is all information that can be exploited. It is not uncommon for a php developer to use show_source(), highlight_string(), or highlight_file() as a debugging measure, but in a live site, this can expose hidden variables, unchecked syntax, and other dangerous information. Especially dangerous is running code from known sources with built-in debugging handlers, or using common debugging techniques. If the attacker can determine what general technique you are using, they may try to brute-force a page, by sending various common debugging strings:

Przykład 28-2. Exploiting common debugging variables

<form method="post" action="attacktarget?errors=Y&amp;showerrors=1&amp;debug=1">
<input type="hidden" name="errors" value="Y" />
<input type="hidden" name="showerrors" value="1" />
<input type="hidden" name="debug" value="1" />
</form>

Regardless of the method of error handling, the ability to probe a system for errors leads to providing an attacker with more information.

For example, the very style of a generic PHP error indicates a system is running PHP. If the attacker was looking at an .html page, and wanted to probe for the back-end (to look for known weaknesses in the system), by feeding it the wrong data they may be able to determine that a system was built with PHP.

A function error can indicate whether a system may be running a specific database engine, or give clues as to how a web page or programmed or designed. This allows for deeper investigation into open database ports, or to look for specific bugs or weaknesses in a web page. By feeding different pieces of bad data, for example, an attacker can determine the order of authentication in a script, (from the line number errors) as well as probe for exploits that may be exploited in different locations in the script.

A filesystem or general PHP error can indicate what permissions the web server has, as well as the structure and organization of files on the web server. Developer written error code can aggravate this problem, leading to easy exploitation of formerly "hidden" information.

There are three major solutions to this issue. The first is to scrutinize all functions, and attempt to compensate for the bulk of the errors. The second is to disable error reporting entirely on the running code. The third is to use PHP's custom error handling functions to create your own error handler. Depending on your security policy, you may find all three to be applicable to your situation.

One way of catching this issue ahead of time is to make use of PHP's own error_reporting(), to help you secure your code and find variable usage that may be dangerous. By testing your code, prior to deployment, with E_ALL, you can quickly find areas where your variables may be open to poisoning or modification in other ways. Once you are ready for deployment, you should either disable error reporting completely by setting error_reporting() to 0, or turn off the error display using the php.ini option display_errors, to insulate your code from probing. If you choose to do the latter, you should also define the path to your log file using the error_log ini directive, and turn log_errors on.

Przykład 28-3. Finding dangerous variables with E_ALL

<?php
if ($username) {  // Not initialized or checked before usage
    
$good_login = 1;
}
if (
$good_login == 1) { // If above test fails, not initialized or checked before usage
    
readfile ("/highly/sensitive/data/index.html");
}
?>



WÄ…tki z forum o php

Najnowsze posty naszych userów

nie w³±cza sie ca³kowicie instalator systemu win xp.
witam, chcê mojej dziewczynie sformatowaæ komputer, po ustawieniu kolejno¶ci bootowania, resetuje komputer, wk³adam plyte z windowsem, i pojawia sie czarny ekran z informacja, ze wlacza sie instalator windows, potem pojawia sie niebeiski ekran z napisem instalator rozpakowywuje pliki i wtym momencie komputer staje, dysk przestaje sie krecic i naped tez, cos jakby zawieszka, dzieje sie to zarowno w przypadku winxp 1 wer. jak i ta z sp2. prosze o pomoc,

plyta glowna ECS, proc. Athlon 1GHz.
dual layer czy Double layer
Witam


Patrzê w everest jakie p³yty obs³uguje moja nagrywarka dvd.I przy jednej opcji pisze DVD+R9 Dual Layer czym¶ siê rózni od duble layer?I czy mogê kupiæ p³ytki duble layer aby je nagraæ? czy musz± byæ dual layer



Kaszanka dobra do wszystkiego [+18]
Drogie Bravo, drodzy koledzy i kole¿anki.Mam na imiê Dagmara i mam 19 lat. Moja sytuacja jest bardzo krepuj±ca i nie wiem co teraz mam zrobiæ. Jestem ju¿ doros³± dziewczyn± i mam wspania³ego ch³opaka o imieniu Marcin, którego kocham ponad ¿ycie i my¶lê ze on odwzajemnia moje uczucie. Jeste¶my ju¿ razem 6 miesiêcy i postanowili¶my dokonaæ Aktu Mi³osnego, aby umocniæ nasz zwi±zek. Nie fart polega na tym ¿e ja jestem dziewic±, a z tego co wiem On jest ju¿ do¶wiadczonym mê¿czyzn±. Bardzo obawia³am siê ¿e nie spe³niê jego oczekiwa , po prostu zawiodê! Na dodatek wszystkie moje kole¿anki potraci³y ju¿ dziewictwo i ¿eby mieæ o czym rozmawiaæ z nimi, powiedzia³am ¿e ja równie¿ nie jestem jak to siê mówi potocznie "cnotk±". O tym fakcie dowiedzia³ siê Marcin od mojej kole¿anki, Moniki, która jest jego dobr± znajom±. Gdy Marcin zapyta³ czy to prawda nie zaprzeczy³am. Ustalili¶my nasz Pierwszy Raz na najbli¿szy weekend, poniewa¿ Marcina rodzice jad± na wesele. Bardzo siê obawia³am bólu, oraz tego ¿e Marcin pos±dzi mnie o k³amstwo, wiêc postanowi³am jako¶ sobie poradziæ. Nie chcia³am przespaæ siê z "pierwszym lepszym" gdy¿ kocham Marcina i chcê aby to on by³ moim Pierwszym Mê¿czyzn±!! Akurat zdarzy³o siê tak ¿e by³am sama w domu i postanowi³am uporaæ siê z moja b³ona dziewicz±. Nie chcia³am robiæ tego palcami ani jakim¶ twardym przedmiotem a na wibrator niestety nie by³o by mnie staæ. Posz³am wiêc do lodówki i zobaczy³am nadaj±c± siê do mojego czynu kaszankê. Odpowiada³a mi rozmiarem i grubo¶ci±, by³a trochê za zimna i za twarda wiêc postanowi³am ja podgotowaæ. Kiedy nareszcie ostyg³a, nasmarowa³am ja wazelin±, i zaczê³am wk³adaæ j± do pochwy. Podda³am siê chyba za bardzo chwili i za bardzo j± ¶cisnê³am. Wtedy sta³o siê najgorsze co mog³o siê staæ!! KASZANKA SIÊ Z£AMA£A!!!!!!!!!!Rozpaczliwie próbowa³am j± wyj±æ palcami ale chyba trochê za bardzo j± rozgotowa³am i niektóre kawa³ki kaszanki zosta³y mi w pochwie i nie mogê ich wyj±æ! Wstydzê siê i¶æ do ginekologa a za kilka dni wyczekiwany przez nasz± dwójkê upojny weekend!! Nie wiem co mam zrobiæ i do kogo siê zwróciæ. Co teraz pomy¶li o mnie Marcin!! B£AGAM POMÓ¯CIE!!!!!
Zrozpaczona

Odpowied¼ Bravo:
Na wstêpie pragniemy podziêkowaæ Ci za podzielenie siê z nami swoim problemem. W twojej nader ciekawej sytuacji proponujemy Ci dwa rozwi±zania:
1. Ekstrawaganckie w stylu new art.
2. Si³owe

Pierwsze wydaje nam siê ciekawe lecz mo¿e nie przynie¶æ spodziewanych efektów. Musisz pokroiæ cebulê w kostkê, a nastêpnie podsma¿yæ j± na z³ocisty kolor na patelni (koniecznie na oleju z pierwszego tloczenia). Nastêpnie musisz dopchaæ j± do pochwy i zrobiæ 3-4 przysiadów tak aby zmiesza³a siê z kaszank±. Potem zapro¶ swojego ukochanego na romantyczne spotkanie inicjuj±ce. Przed pierwszym stosunkiem zaproponujesz mu wiêc kaszankê po staropolsku w wersji francuskiej. W ten sposób osi±gniesz dwa cele: udowodnisz mu, ¿e bardzo go kochasz i jednocze¶nie poka¿esz, ¿e ¶wietnie gotujesz. Przypominamy Ci powiedzenie "PRZEZ ¯O£¡DEK DO SERCA".

Rozwi±zanie drugie jest jednak o wiele bardziej skuteczne. Przygotuj patelniê na której mia³a¶ zarumieniæ cebulkê. Nastêpnie we¼ j± w praw± rêkê (je¶li jeste¶ leworêczna to w lew±) i [beeep]nij siê ni± z ca³ej si³y w g³owê - bo tobie to ju¿ chyba nic nie pomo¿e!
Z powa¿aniem Redakcja


Problemem bylo to, ze autor nie pozostawil mozliwosci zmian, wiec za pomoca programu PHP WebPage Editor zmienilem pewne potrzebne mi wartosci (ilosci wojsk - to akurat bylo latwe do znalezienia...), ale nie wiem, ktore wartosci odpowiadaja za czas wysylania tych jednostek wojska - chce zmienic z tych kilkunastu sekud na ok 1,5 godz... (to dziwne, bo nie jest to regularne - niektore ataki wychodza co 10 sek, niektore co 15 albo 20.