One of the most widely used SQL Injection vulnerability protection functions is the addslashes () function. This function takes an input and if it sees characters like ” \ ‘and … in the input sentence, it puts a \ before these characters.
One way to bypass this function is to use the GBK encoding character, this encoding character is made for Chinese characters and we can use this bypass when the ability to support this encoding is defined in the database.
The urlencoded value of some characters in the GBK encoding character ends with 5c%, such as
% ef% 5c
Now when the hacker sends the following upload
% ef% 27% 20OR% 201 = 1 -% 20
The addslashes () function sets the value to 27%, which is equivalent to ‘, and then sets a \ that has a urlencode equivalent of 5c%.
% ef% 5c% 27% 20OR% 201 = 1 -% 20
Now when this input is processed by the database the characters
% ef% 5c
Is considered a Chinese character and ‘or the same 27% that we injected in the sentence can cause SQLI to occur.
#SQL_Injection #GBK Character Encoding
یکی از پرکاربرد ترین تابع های ایمن سازی در برابر آسیب پذیری SQL Injection تابع ()addslashes می باشد. این تابع یک ورودی می گیرد و در صورتی که کاراکتر هایی مانند ‘ ” \ و … را در جمله ورودی مشاهده کند قبل این کاراکتر ها یک \ قرار می دهد.
یکی از راه های دور زدن این تابع استفاده از کاراکتر انکودینگ GBK است, این کاراکتر انکودینگ برای حروف چینی ساخته شده و زمانی می توانیم از این بایپس استفاده کنیم که در دیتابیس قابلیت پشتیبانی از این انکودینگ تعریف شده باشد.
مقدار urlencode شده بعضی کاراکتر ها در کاراکتر انکودینگ GBK با 5c% تمام می شود مانند
%ef%5c
حال هنگامی که هکر پیلود زیر را ارسال میکند
%ef%27%20OR%201=1–%20
تابع ()addslashes مقدار 27% که معادل ‘ را تشخیص داده و قبل آن یک \ که معادل urlencode شده آن برابر 5c% است قرار می دهد
%ef%5c%27%20OR%201=1–%20
حال هنگامی که این ورودی توسط دیتابیس پردازش می شود کاراکتر های
%ef%5c
را یک کاراکتر چینی در نظر گرفته و ‘ یا همان 27% که در جمله تزریق داده ایم می تواند باعث رخ داده SQLI شود.
You must be logged in to post a comment.