Remote Command execution :
Find out ip address of system using
>start>run>type cmd>type ipconfig
// SERVER SIDE
#include <arpa/inet.h> /* for sockaddr_in and inet_ntoa() */
#include <stdlib.h> /* for atoi() and exit() */
#include <string.h> /* for memset() */
ServAddr.sin_addr.s_addr = htonl(INADDR_ANY); ; /*this means that server will serve to the specific port which is mentioned regardless of what its ip address is*/
you need to change IP Address in client side only
CLIENT SIDE ADD:
struct sockaddr_in ServAddr; /* server address */
char *servIP; /* Server IP address (dotted quad) */
char *echoString;
print("enter ip");
scanf("%s",servIP); // use argv[1]
memset(&echoServAddr, 0, sizeof(ServAddr)); /* Zero out structure */
echoServAddr.sin_family = AF_INET; /* Internet address family */
echoServAddr.sin_addr.s_addr = inet_addr(servIP); /* Server IP address */
echoServAddr.sin_port = htons(ServPort); /* Server port */
if(connfd!=0)
printf("Server accepted client \n");
else
printf("Server not accepted client\n");
recv(connfd,buff,1024,0);
printf("Serever received msg from client %s",buff);
system( buff );
close(sd);
// CLIENT SIDE PROGRAM
#include<sys/types.h>
#include<sys/socket.h>
#include<netinet/in.h>
#include<string.h>
#include<stddef.h>
char ip_adr[15]="10.121.9.240"; // Here type ur server ipaddress
struct sockaddr_in serv_addr;
/* gets(ip_adr);*/
serv_addr.sin_addr.s_addr =inet_addr(ip_adr); /* the obtained ip address which is a dotted string is converted to unsigned long.*/
serv_addr.sin_family = AF_INET; /* this information we specify that it belongs to tcp or udp*/
serv_addr.sin_port = htons(port_no); /*htons is used because we may need to change it to network byte order which is always big endian*/