是否可以使用 DBD::Oracle 在单个查询中执行多个语句?

发布于 2024-07-22 20:40:50 字数 1357 浏览 12 评论 0原文

我想知道是否可以在单个 中执行多个 SQL 语句执行()do() 使用 DBD::Oracle 进行调用Perl DBI。 示例:

# Multiple SQL statements in a single query, separated by a ";"
$sql = 'UPDATE foo SET bar = 123; DELETE FROM foo WHERE baz = 456';

$sth = $dbh->prepare($sql);
$sth->execute;

# ...or...

$dbh->do($sql);

我问这个问题并不是因为我想实际做这样的事情,而是因为我想衡量成功的 SQL 注入攻击可能造成的损害。 是的,我知道,无论这个问题的答案如何,仍然必须使用绑定值和可信输入等从根本上消除 SQL 注入的可能性。但问题仍然存在:是否有可能使 DBD::Oracle 执行多个语句?

作为相关示例, DBD::mysqlmysql_multi_statements 明确启用此“功能”的连接选项。 我无法摆脱这样的感觉,即存在一些类似的、可能未记录的、晦涩难懂的 Oracle OCI 选项,可以通过 DBD::Oracle 以某种方式访问​​它,从而实现相同的功能。

如果重要的话,这是:

  • perl 5.8.8
  • DBD::Oracle 1.22
  • Oracle 11g (11.01.0700)

I'd like to know if it's possible to execute more than one SQL statement within a single execute() or do() call using DBD::Oracle via Perl DBI. Example:

# Multiple SQL statements in a single query, separated by a ";"
$sql = 'UPDATE foo SET bar = 123; DELETE FROM foo WHERE baz = 456';

$sth = $dbh->prepare($sql);
$sth->execute;

# ...or...

$dbh->do($sql);

I ask this not because I want to actually do such a thing, but rather because I want to gauge the damage possible through a successful SQL injection attack. And yes, I know that, regardless of the answer to this question, the possibility of SQL injection must still be eliminated at its root using bind values and trusted input only, etc. But the question still stands: is it possible to make DBD::Oracle execute multiple statements?

As a related example, DBD::mysql has a mysql_multi_statements connection option that explicitly enables this "feature." I can't shake the feeling that there's some similar, perhaps undocumented and obscure Oracle OCI option that's accessible somehow via DBD::Oracle that will enable the same thing.

In case it matters, this is:

  • perl 5.8.8
  • DBD::Oracle 1.22
  • Oracle 11g (11.01.0700)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

゛清羽墨安 2024-07-29 20:40:50

如果 SQL 注入攻击成功,攻击者难道不能简单地重复它并以这种方式运行多个语句吗?

Oracle 支持可以包含多个语句的匿名 PL/SQL 块。

“开始执行立即‘删除表客户’;执行立即‘删除表销售’;结束”

Oracle 在这里提供了关于避免 SQL 注入攻击的免费教程:
http://st-curriculum.oracle.com/tutorial/SQLInjection/index.htm

If there is a successful SQL injection attack, couldn't the attacker simply repeat it and run multiple statements that way as well?

Oracle supports anonymous PL/SQL blocks which can contain multiple statements.

"begin execute immediate 'drop table customers'; execute immediate 'drop table sales'; end"

Oracle provides a free tutorial on avoiding SQL injection attacks here:
http://st-curriculum.oracle.com/tutorial/SQLInjection/index.htm

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文