PHP einfache Passwortabfrage umgehbar?
-
Hallo!
Kann man eigentlich eine einfache Passwortabfrage wie zB...
if($this->password != ADMIN_PASSWORD) throw new Exception($this->WARNING_ACCESS_DENIED, 1);
...clientseitig umgehen? Ich dachte da an das Prinzip wie bei SQL Injections, aber bei einem Vergleich wird doch Bitweise verglichen, also dürfte das "unhackbar" sein (Außer man meiert den Server irgendwie), oder?
MfG
-
Unhackbar, aber Missbrauch von Exceptions
-
hackbar schrieb:
..., aber Missbrauch von Exceptions
Ist doch so aber am einfachsten. Wie denn sonst? Mit return-Werten? Da komm ich mir dumm dabei vor.
Kleiner Aussschnitt meines Gästebuch-Skripts:
Insertion:
function Process() { ... if($this->action == "insert") { try { $this->ValidateInsertion(); $statement = $this->databaseHandle->prepare("INSERT INTO blackboard (ip, timestamp, name, text) VALUES (:remoteAddress, :timestamp, :name, :text)"); $statement->bindParam(":ip", $_SERVER[REMOTE_ADDR], PDO::PARAM_STR); $statement->bindParam(":timestamp", time(), PDO::PARAM_INT); $statement->bindParam(":name", $this->name, PDO::PARAM_STR); $statement->bindParam(":text", $this->text, PDO::PARAM_STR); $statement->execute(); $this->name = ""; $this->text = ""; throw new Exception($this->NOTICE_MESSAGE_SENT, 0); } catch(Exception $e) { throw $e; } } ... }
Verwendung:
try { $blackboard = new Blackboard(/* parameter halt */); $blackboard->Process(); } catch(Exception $e) { if(!$e->getCode()) echo "<div id = 'noticeArea'>"; else { echo "<div id = 'errorArea'>"; if($e->getCode() == 2) $abortPrinting = true; } echo $e->getMessage() . "</div>"; } if(!$abortPrinting) { $blackboard->Update(); $blackboard->PrintForm(); ... }
Ich verwende also sogar Exceptions für eine Bestätigung, dass eine Nachricht erfolgreich eingetragen wurde.
Mir wurst, wie soll man es denn sonst unkompliziert lösen? Ist doch superelegant so...MfG
-
Ich verwende also sogar Exceptions für eine Bestätigung, dass eine Nachricht erfolgreich eingetragen wurde.
lololo bissu dumm
-
Why, wenns so komfortabler ist? Nachteil? Genau, keiner.
-
Ich benutz mein Auto auch nicht zum Plattrollen meiner Pizza. Auch, wenns geht
Die Klobürste auch nicht zum spülen (sogar wenn die Klobürste neu und unbenutzt is mach ichs nicht)
Und den Autoschlüssel nicht zum Austern auslösen.*SCNR*
-
ceplusplus@loggedoff schrieb:
Why, wenns so komfortabler ist? Nachteil? Genau, keiner.
Wenn in deinem Programm eins von deinen PDO Objekten eine Exception wirft die
du eigentlich nicht erwartest ...try { $this->ValidateInsertion(); $statement = $this->databaseHandle->prepare("INSERT INTO blackboard (ip, timestamp, name, text) VALUES (:remoteAddress, :timestamp, :name, :text)"); $statement->bindParam(":ip", $_SERVER[REMOTE_ADDR], PDO::PARAM_STR); $statement->bindParam(":timestamp", time(), PDO::PARAM_INT); $statement->bindParam(":name", $this->name, PDO::PARAM_STR); $statement->bindParam(":text", $this->text, PDO::PARAM_STR); $statement->execute(); $this->name = ""; $this->text = ""; throw new Exception($this->NOTICE_MESSAGE_SENT, 0); } catch(Exception $e) { throw $e; }
... Wird sie von deinem Catch in jedem fall gefangen und kann nicht punktgenau
behandelt werden. Du nimmst dir also selbst die möglichkeit einer
Reibungslosen Fehlerbehandlung, da du nicht mit spezifischem Code darauf
eingehen kannst sondern dann unelegant irgendwo rumbasteln musst um
verschiedene Fehlertypen zu behandeln.
-
wieso machen es immer alle so umständlich? Du musst doch nur eine SQLabfrage schreiben mit where bedingungen und wenn du mehr als 1 row zurück bekommst ist der user eingeloggt und das speicherst du in die session
edit: ach .. sorry glaub ging am topic vorbei
-
PRIEST schrieb:
edit: ach .. sorry glaub ging am topic vorbei
das, und sechs Monate gingen auch vorbei
-
afafafffafa2325222
-
hackbar schrieb:
Unhackbar, aber Missbrauch von Exceptions
ich finde die exception hier sehr schön.