[ Curiosity,Experimentation ]

Random stuff from the parallel universe of Ones and Zeroes

Archive for the ‘Worm’ Category

Developing an Anti-Worm tool [VB 6]

Posted by appusajeev on March 1, 2010

I am pretty sure that you must have certainly come across this malware which copies itself in each directory with the name same as the directory name and icon same as the default win xp folder icon to trick the user into executing the malware which he apparently thinks as a folder(see the post below for an implementation of the same).So even if you somehow kill it,the chances of it bouncing back to action are pretty high.

Anyway this post is about creating a anti-worm tool in VB – a behaviour based detection tool that  searches for and removes such malware .

First, you gotta give it a sample of the malware to search for. The directory structure of each drive is traversed and each directory is searched for the presence of an exe with the name same as the directory name, if such an exe is found, its size is compared with the size of the exe given as sample. If there is match,it is reported(MD5 signature based comparison would have been an anytime better alternative but i dunno if theres is an md5 implementation for vb yet). This second level of checking is needed cuz an exe with name same as the directory name need not always be a malware.

Download Source

Download Tool

Heres the tool in action

Ant-worm tool in action

Ant-worm tool in action

Given below is the souce, download source

Anti-worm source in VB6

Anti-worm source in VB6

Advertisements

Posted in Visual Basic, Worm | Tagged: , | 4 Comments »

Malware Spreading [A Worm with source]

Posted by appusajeev on August 6, 2009

This post deals with a mechanism to spread your malware through removable media like pen drives or memory cards or portable hdds or whatever. The method described here is a potential mechanism that could be used for the said purpose. With this mechanism, a malware deployed on a single machine could spread itself in quite a small time (sort of a a chain reaction). This is a method commonly used by malware developers as part of their spreading policy.

Basically,this mechanism relies upon the AUTORUN feature provided by Windows. AUTORUN is a feature by which certain actions can be perfomed when a media device(like hdd,pen drives) is accessed. With Autorun,you can set to execute a file when the device is accessed. You could also alter the right click context menu actions on the device.Basically Microsoft introduced this concept with a view to enhance the user friendliness ,buts its been used more often for the sinister purpose .The actions are stored in an Autorun.inf file is the root path of the device.
A sample autorun.inf file for executing malware.exe upon access of a media device is shown below.

Sample autorun.inf

Sample autorun.inf

The Worm

Presented here is an ActiveX control which i developed in VB6(source can be downloaded here[VB6]) which well,could be embedded in your Visual Basic/Visual C++ application(or malware,he he) to copy the required malware executable to the removable media with the corresponding autorun.inf also being created to execute the malware upon the device access with the commands to alter the right click context menu actions like open,explore,autoplay.

Download Active X Control

Download Worm ActiveX Source

The Source of the ActiveX  control is given below:

VB6 Source Code:Worm

VB6 Source Code:Worm

The control starts its action when the start() method is called. This method takes 2 arguments-the path of the executable which is to be copied and the name of the executable under which it will be copied to the removable media(the name will hence be used in the autorun.inf file)

Once the method has been called,the control checks for the presence of any plugged in removable media(by the GetDriveType API) every 10 seconds and if found,copies the given file and creates the autorun.inf files and sets the attributes of both as hidden + system so that those will not be visible normally to the user.

When that removable media is plugged to another computer and is accessed normally,the executable specified in the autorun.inf file is executed(autorun feature is enabled by default on all machines running XP and higher). Thus,with a malware installation file(the below post deals with malware installation),you could install the malware on a machine as well as start spreading the malware from that machine.

Posted in Worm | Tagged: | 5 Comments »

Malware Deployment [EXE Binding]

Posted by appusajeev on July 22, 2009

All right fellas,so you did your malware and now what? The final step is to create some mechanism to install the stuff on the target machine and get it running when the machine boots up. Initially ,the method i used was to archive the binaries to a cab archive and code an executable to unpack  the contents into a target folder and create the necessary registry entries(there are plenty of  them) to run the code at startup.But this method had the obvious disadvantage that not all files could be included in a singe executable archive ,which,upon execution shall proceed with the installation silently.

The tool of the trade which could serve this purpose is NSIS or NULLSOFT SCRIPTABLE INSTALL SYSTEM. NSIS is an open source tool for creating multipurpose installers. The most powerful feature of NSIS is that it comes with a flexible scripting system with a multitude of features.
With NSIS ,you could create an  installer(silent if required) which would install the binaries,register the DLLs and OCXs,register startup and so on.

For example,suppose you want to deploy your malware,say Malw.exe onto the target machine. The NSIS script for that would be ( I have set the install directory as System32\5016)

nsis src eg

nsis src eg

I think the code itself is self explanatory. The compliled single exe archive,upon execution would install the exe to the path specified by installdir property. It then sets the registry key for startup(via the key specified in WriteRegStr property which is nothing but WriteRegistryString). Finally it executes Malw.exe after installation. Simple,isnt it?Now to the core part.

EXE Binding (Trojan Horse Mechanism)

Now comes the promising part. With exe binding you could bind your malware setup created above with any other regular software installer/exe so that the user can be tricked into installing the malware along with the software without his knowledge: The exact Trojan Horse Mechanism.

What i do is that i create an installer for the malware as described above and i create a second installer(the Trojan Horse) whose contents are the malware installer created above and the intended software installer execuatable(the bait ,he he). I script this container installer in such a way that upon execution,the malware installer and software installer both are unpacked into a temporary folder and the malware setup(which is silent) is executed prior to executing the software installer so that the malware is installed on the machine before the software installer window pop us. This strategy would install the malware on the target machine without user knowledge.

The NSIS source code to effect such a trojan horse mechanism is given below(faking the iTunes Installer):

NSIS Source eg.

NSIS Source eg.

I guess the code is again self explanatory and if not,the comments in the code will help

The icon and VIAddVersionKey properties have been set to fake the original itunes installer better.

Suggestions are welcome.

Posted in Exe Binding, Visual Basic, Worm | Tagged: , | 1 Comment »