SQL注入攻击的最小可能字符序列是多少?

发布于 2024-10-03 12:39:00 字数 135 浏览 1 评论 0原文

很简单,用尽可能少的字符进行 SQL 注入攻击。请注意,我并不是试图通过将输入限制在一定大小来防止 SQL 注入攻击,而是真正好奇执行最简单的攻击需要多少个字符。

为了方便起见,假设最小的表名是 4 个字符,例如“user”。请考虑这一点。

Simple, a SQL injection attack in as few characters as possible. Note, I'm not trying to prevent SQL injection attacks by limiting inputs to a certain size, but rather am genuinely curious how many characters is needed to execute even the simplest attack.

For posterity sake, let's say the smallest table name is 4 characters, e.g., "user". Please factor that in.

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

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

发布评论

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

评论(5

猫卆 2024-10-10 12:39:00

1 个角色是你可以控制的最小单位。这个问题很大程度上取决于你在做什么。例如,如果您正在处理从网站删除您的个人资料的界面,并且您发送“%”而不是您的姓名:

"Delete from Users where name like '"+username+"'"

那么将您的用户名设置为 % 将删除所有用户。

1 Character is the smallest unit that you have control over. The question depends heavily on what you're doing. For instance, if you're dealing with an interface to delete your profile from a site, and you send '%' instead of your name:

"Delete from Users where name like '"+username+"'"

then setting your username to % will delete all the users.

怪我太投入 2024-10-10 12:39:00

当注入字符串文字时:

';drop database;--

When injecting into a string literal:

';drop database;--
情域 2024-10-10 12:39:00

这个怎么样:

' OR 1=1 --

how about this one:

' OR 1=1 --
肤浅与狂妄 2024-10-10 12:39:00

假设查询是这样生成的

"Select * from user where userid = " + myVar 

1; delete from user;

Suppose the query was generated like this

"Select * from user where userid = " + myVar 

1; delete from user;
≈。彩虹 2024-10-10 12:39:00

总而言之,如果我将内联变量修剪为最多 13 个字符,则不可能出现危险的 SQL 注入。在我的 sql 中,13 个字符足以将我的任何结果与 charindex 相匹配。我无法使用参数化存储过程,因为我的 sql 是在 C# 中动态生成的,具有复杂的 if else 逻辑。

To summarize, if I trim my inline variable to have 13 chars max no dangerous sql injection is possible. In my sql 13 chars is enough to match any of my results with charindex. I cannot use parameterized stored procedure since my sql is dynamically generated in C# with complicated if else logic.

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