Skip to content

Instantly share code, notes, and snippets.

@th4s1s
Created January 6, 2025 08:52
Show Gist options
  • Save th4s1s/21abb650b4b70fe8392d8449445703f7 to your computer and use it in GitHub Desktop.
Save th4s1s/21abb650b4b70fe8392d8449445703f7 to your computer and use it in GitHub Desktop.

Online Book Shop Using PHP has SQL Injection vulnerability via $cat paremeter in /subcat.php.

Project

https://code-projects.org/online-book-shop-using-php-source-code/

Vulnerability

/subcat.php - $cat paremeter.

Description

The SQL Injection vulnerability exists in diretory /subcat.php where this function query the cat parameter into the SQL statement without any restriction, validation or sanitization. An attacker could exploit this vulnerability to get unauthorized access to the server database, or even perform Remote Code Execution (RCE).

  require('includes/config.php');
  session_start();
  
  $cat=$_GET['cat_nm'];

  $q = "select * from subcat where parent_id = ".$_GET['cat'];
  $res = mysqli_query($conn,$q) or die("Can't Execute Query..");

  $row1 = mysqli_fetch_assoc($res);

  if($_GET['catnm']==$row1['subcat_nm'])
  {
    header("location:booklist.php?subcatid=".$row1['subcat_id']."&subcatnm=".$row1["subcat_nm"]);
	}
?>

PoC

Enumerate all databases with sqlmap: image

Get OS-shell and execute command: image image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment