PHP

SQL Injection

Uses string concatenations

 $query = 'SELECT id,username FROM users WHERE id=' . $injection . ' LIMIT 1';

Should use prepared statements

$sql = "INSERT INTO MyGuests (firstname, lastname, email) VALUES (?, ?, ?)";

// Prepare the SQL query template
if($stmt = $conn->prepare($sql)) {
  // Bind parameters
  $stmt->bind_param("sss", $firstname, $lastname, $email);

  // Set parameters and execute
  $firstname = "John";
  $lastname = "Doe";
  $email = "john@example.com";
  $stmt->execute();

Serialization

Able to bypass by using by passing it as an object as they only check if it is an array

Strcmp and Strcasecmp

Able to be bypass by sending it as an array

parse_url

parse_url will return as null if we use a URL like this: https://test.com///level1/index.php?page=flag

It will interprets as ///level25/index.php?page=flag

TOUTOC

There is a brief window where the attacker is able to access the php file after uploading, mainly is at file_put_contents($filename, $flagfilecontent) and unlink($filename)

preg_match

In this code, they only check for the blacklisted words once and process the query

So, I can do something like this

and it will filter and become this when being parsed into the query

Last updated