CuDemVN.Wap.Sh



![]() | ![]() ![]() ![]() |
Các dạng lỗi SQL Injection thường gặp
- Không kiểm tra ký tự thoát truy vấn
- Xử lý không đúng kiểu
- Lỗi bảo mật bên trong máy chủ cơ sở dữ liệu
- Blind SQL injection
- Thay đổi giá trị điều kiện truy vấn
- Điều kiện lỗi
- Thời gian trễ
Một số dạng tấn công thường gặp với các ứng dụng web
- Dạng tấn công vượt qua kiểm tra lúc đăng nhập
- Dạng tấn công sử dụng câu lệnh SELECT
- Dạng tấn công sử dụng câu lệnh INSERT
- Dạng tấn công sử dụng stored-procedures
Share function fix SQLi Injection sử dụng cho chống SQL Injection trong trường hợp các bác IT tò mò.
<?php
function anti_sql($sql) {
$sql = preg_replace(sql_regcase("/(from|select|insert|delete|where|drop table|show tables|#|*|--|\)/"),"",$sql);
return trim(strip_tags(addslashes($sql)));
}
Chống sql inject 2. Các bạn có thể lựa chọn phương pháp khác nhau và function cho phù hợp
<?php
function id_replace($id) {
$id = str_replace("+","",$id);
$id = str_replace("'","''",$id);
$id = str_replace("UNI0N","",$id);
$id = str_replace("select","",$id);
$id = str_replace("*","",$id);
$id = str_replace("%","",$id);
$id = str_replace("%","",$id);
$id = str_replace("2b","",$id);
if (strlen($id) > 10) {
$id="";
}
return $id;
}
function string_replace($string) {
$string = str_replace(""",""",$string);
$string = str_replace("+","",$string);
$string = str_replace("'","''",$string);
$string = str_replace("<","[",$string);
$string = str_replace(">","]",$string);
$string = str_replace(">","]",$string);
$string = str_replace("<","[",$string);
$string = str_replace("UNI0N","",$string);
$string = str_replace("select","",$string);
$string = str_replace("*","",$string);
$string = str_replace("%","",$string);
$string = str_replace("%","",$string);
$string = str_replace("2b","",$string);
if (strlen($string) > 15) {
$string="";
}
return $string;
}
Các bạn hãy dùng thử và phân tích khả năng ứng dụng. Chúc các bạn thành công!

Nguồn: TuoiTreIT

Đánh giá: 4.5/ 5, 622 bình chọn
