Este es el código de una shell remota que he creado hace un tiempito:
#include <windows.h>
#include <stdlib.h>
#include <stdio.h>
int main()
{
SECURITY_ATTRIBUTES sa;
STARTUPINFO si;
PROCESS_INFORMATION pi;
void * leer;
void * escribir;
ZeroMemory(&sa,sizeof(&sa));
sa.nLength = sizeof(SECURITY_ATTRIBUTES);
sa.bInheritHandle = TRUE;
sa.lpSecurityDescriptor = NULL;
CreatePipe(&leer,&escribir,&sa,0);
GetStartupInfoA(&si);
si.dwFlags = STARTF_USESTDHANDLES|STARTF_USESHOWWINDOW;
si.wShowWindow = SW_HIDE;
si.hStdOutput = escribir;
si.hStdError = escribir;
si.hStdInput = leer;
CreateProcessA(0,"c:\\windows\\system32\\cmd.exe /c dir",0,0,TRUE,0,0,0,&si,&pi);
Sleep(200);
CloseHandle(escribir);
char buffer[1024];
DWORD bleidos;
ReadFile(leer,buffer,1024,&bleidos,0);
MessageBoxA(0,buffer,0,0);
system("PAUSE");
return 0;
}
salu2!
Esta bien, podrias usar popen y asi no tirar tanto de API sino de funciones de C.
Sa1uDoS