gpt4 book ai didi

java - SQL注入(inject): want to show a demo of sql injection

转载 作者:行者123 更新时间:2023-12-01 15:29:05 25 4
gpt4 key购买 nike

我想展示一种 sql 注入(inject)攻击,其中当用户填写用户登录表单并提交给 java servlet 时。在登录名和密码字段中,我们如何键入更新任何其他记录的查询。我知道所有列和表的名称。例如我在 servlet 中编写此查询:

从 accountinfo 中选择用户 ID、用户名,其中 userid='testid' 且 pass='1234';
更新 accountinfo set emailid='aar@r.com' where userid='testid2';

但是它给出了Sql Exception如何解决这个问题。

最佳答案

首先尝试单个查询:

select userid, username
from accountinfo
where userid='-' and pass='-'
union
select userid, pass
from accountinfo
where userid like 'adm%'

如果没有异常(exception),首先呈现系统表的查询,然后是上面的查询。为更新 accountinfo 选择 SQL 更新注入(inject)。

关于java - SQL注入(inject): want to show a demo of sql injection,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9782988/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com