以'(引号)开头的字符串,在PostgreSQL中以$ txt $结尾

问题描述 投票:0回答:1

我有一个带有某些安全性模式的PHP应用程序,以防止使用PHP pg_scape_string进行SQL注入。我是一名安全分析师,我的工作被这种模式所破坏。我需要找到一种传递报价的方法。

例如:在sql命令中:select * from table where field = $par and two=$par2;

SQL注入:select * from owner.table where field = '0' or 1=1;--' and two=value;

使用sql命令中的pg_scape_string:select * from owner.table where varcharfield = '0'' or 1=1;--' and two=value;

如何关闭不带引号的where field = '0

php sql database postgresql sql-injection
1个回答
1
投票

要构造字符串文字'test$txt$,您可以使用以下选项:

  • 将单引号加倍:

    SELECT '''test$txt$'
    
  • 使用美元报价,其字符串不同于txt

    SELECT $new$'test$txt$$new$
    
© www.soinside.com 2019 - 2024. All rights reserved.