Pages

15 March 2011

backdoor-listener.c

#include 
#include 
#include 
#include 
#include 

int main() {
int fd;
struct sockaddr_in sa;
int port = 9994;

    if ((fd = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
  perror("socket()");
  exit(1);
 }


 memset((char *) &sa, 0, sizeof(sa));
 sa.sin_family = AF_INET;
 sa.sin_addr.s_addr = htonl(INADDR_ANY);
 sa.sin_port = htons(port);

 if (bind(fd, (struct sockaddr *) &sa, sizeof(sa)) == -1) {
  perror("bind()");
  exit(1);
 }
 
 if (listen(fd, 1) == -1) {
  perror("listen()");
 }
 fprintf(stderr, "done binding\n");
 sleep(10000);
}

0 comments: