mirror of
				https://github.com/rofl0r/proxychains-ng.git
				synced 2025-11-04 00:56:03 +00:00 
			
		
		
		
	remove gnu autocrap
This commit is contained in:
		
							
								
								
									
										755
									
								
								src/core.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										755
									
								
								src/core.c
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,755 @@
 | 
			
		||||
/***************************************************************************
 | 
			
		||||
                          core.c  -  description
 | 
			
		||||
                             -------------------
 | 
			
		||||
    begin                : Tue May 14 2002
 | 
			
		||||
    copyright          :  netcreature (C) 2002
 | 
			
		||||
    email                 : netcreature@users.sourceforge.net
 | 
			
		||||
 ***************************************************************************/
 | 
			
		||||
/*     GPL */
 | 
			
		||||
/***************************************************************************
 | 
			
		||||
 *                                                                         *
 | 
			
		||||
 *   This program is free software; you can redistribute it and/or modify  *
 | 
			
		||||
 *   it under the terms of the GNU General Public License as published by  *
 | 
			
		||||
 *   the Free Software Foundation; either version 2 of the License, or     *
 | 
			
		||||
 *   (at your option) any later version.                                   *
 | 
			
		||||
 *                                                                         *
 | 
			
		||||
 ***************************************************************************/
 | 
			
		||||
#ifdef HAVE_CONFIG_H
 | 
			
		||||
#include <config.h>
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <unistd.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
#include <netdb.h>
 | 
			
		||||
 | 
			
		||||
#include <sys/utsname.h>
 | 
			
		||||
#include <netinet/in.h>
 | 
			
		||||
#include <arpa/inet.h>
 | 
			
		||||
#include <sys/types.h>
 | 
			
		||||
#include <sys/socket.h>
 | 
			
		||||
#include <sys/poll.h>
 | 
			
		||||
#include <sys/wait.h>
 | 
			
		||||
#include <fcntl.h>
 | 
			
		||||
#include <time.h>
 | 
			
		||||
#include <stdarg.h>
 | 
			
		||||
#include "core.h"
 | 
			
		||||
 | 
			
		||||
extern int tcp_read_time_out;
 | 
			
		||||
extern int tcp_connect_time_out;
 | 
			
		||||
extern int proxychains_quiet_mode;
 | 
			
		||||
 | 
			
		||||
static const char base64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
 | 
			
		||||
 | 
			
		||||
static int poll_retry(struct pollfd *fds, nfds_t nfsd, int timeout) 
 | 
			
		||||
{
 | 
			
		||||
  int ret;
 | 
			
		||||
  int time_remain = timeout;
 | 
			
		||||
  int time_elapsed = 0;
 | 
			
		||||
 | 
			
		||||
  struct timeval start_time;
 | 
			
		||||
  struct timeval tv;
 | 
			
		||||
 | 
			
		||||
  gettimeofday(&start_time, NULL);
 | 
			
		||||
 | 
			
		||||
  do 
 | 
			
		||||
  {
 | 
			
		||||
    //printf("Retry %d\n", time_remain);
 | 
			
		||||
    ret = poll(fds, nfsd, time_remain);
 | 
			
		||||
    gettimeofday(&tv, NULL);
 | 
			
		||||
    time_elapsed =  ((tv.tv_sec - start_time.tv_sec) * 1000 + (tv.tv_usec - start_time.tv_usec) / 1000);
 | 
			
		||||
    //printf("Time elapsed %d\n", time_elapsed);
 | 
			
		||||
    time_remain = timeout - time_elapsed;
 | 
			
		||||
  }
 | 
			
		||||
  while (ret == -1 && errno == EINTR && time_remain > 0);
 | 
			
		||||
  //if (ret == -1)
 | 
			
		||||
  //printf("Return %d %d %s\n", ret, errno, strerror(errno));
 | 
			
		||||
  return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static void encode_base_64(char* src,char* dest,int max_len)
 | 
			
		||||
{
 | 
			
		||||
	int n,l,i;
 | 
			
		||||
 	l=strlen(src);
 | 
			
		||||
	max_len=(max_len-1)/4;
 | 
			
		||||
	for ( i=0;i<max_len;i++,src+=3,l-=3)
 | 
			
		||||
	{
 | 
			
		||||
		switch (l) {
 | 
			
		||||
		case 0:
 | 
			
		||||
			break;
 | 
			
		||||
		case 1:
 | 
			
		||||
			n=src[0] << 16;
 | 
			
		||||
			*dest++=base64[(n >> 18) & 077];
 | 
			
		||||
			*dest++=base64[(n >> 12) & 077];
 | 
			
		||||
			*dest++='=';
 | 
			
		||||
			*dest++='=';
 | 
			
		||||
			break;
 | 
			
		||||
		case 2:
 | 
			
		||||
			n=src[0] << 16 | src[1] << 8;
 | 
			
		||||
			*dest++=base64[(n >> 18) & 077];
 | 
			
		||||
			*dest++=base64[(n >> 12) & 077];
 | 
			
		||||
			*dest++=base64[(n >> 6) & 077];
 | 
			
		||||
			*dest++='=';
 | 
			
		||||
			break;
 | 
			
		||||
		default:
 | 
			
		||||
			n=src[0] << 16 | src[1] << 8 | src[2];
 | 
			
		||||
			*dest++=base64[(n >> 18) & 077];
 | 
			
		||||
			*dest++=base64[(n >> 12) & 077];
 | 
			
		||||
			*dest++=base64[(n >> 6) & 077];
 | 
			
		||||
			*dest++=base64[n & 077];
 | 
			
		||||
		}
 | 
			
		||||
		if (l<3) break;
 | 
			
		||||
	}
 | 
			
		||||
	*dest++=0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#define LOG_BUFF 1024*20
 | 
			
		||||
 | 
			
		||||
int proxychains_write_log(char *str,...)
 | 
			
		||||
{
 | 
			
		||||
    char buff[LOG_BUFF];
 | 
			
		||||
    va_list arglist;
 | 
			
		||||
    FILE * log_file;
 | 
			
		||||
    log_file=stderr;
 | 
			
		||||
    if (!proxychains_quiet_mode)
 | 
			
		||||
    {
 | 
			
		||||
        va_start(arglist,str);
 | 
			
		||||
        vsprintf(buff,str,arglist);
 | 
			
		||||
        va_end(arglist);
 | 
			
		||||
        fprintf(log_file,"%s",buff);
 | 
			
		||||
        fflush(log_file);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
        return EXIT_SUCCESS;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int write_n_bytes(int fd,char *buff,size_t size)
 | 
			
		||||
{
 | 
			
		||||
  int i=0,wrote=0;
 | 
			
		||||
  for(;;)
 | 
			
		||||
  {
 | 
			
		||||
    i=write(fd,&buff[wrote],size-wrote);
 | 
			
		||||
    if(i<=0)
 | 
			
		||||
         return i;
 | 
			
		||||
    wrote+=i;
 | 
			
		||||
    if(wrote==size)
 | 
			
		||||
         return wrote;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int read_line(int fd, char *buff, size_t size)
 | 
			
		||||
{
 | 
			
		||||
  int i,ready;
 | 
			
		||||
  struct pollfd pfd[1];
 | 
			
		||||
 | 
			
		||||
  pfd[0].fd=fd;
 | 
			
		||||
  pfd[0].events=POLLIN;
 | 
			
		||||
  for(i=0;i<size-1;i++)
 | 
			
		||||
  {
 | 
			
		||||
    pfd[0].revents=0;
 | 
			
		||||
    ready=poll_retry(pfd,1,tcp_read_time_out);
 | 
			
		||||
    if(ready!=1 || !(pfd[0].revents&POLLIN) || 1!=read(fd,&buff[i],1))
 | 
			
		||||
      return -1;
 | 
			
		||||
    else if(buff[i]=='\n')
 | 
			
		||||
    {
 | 
			
		||||
        buff[i+1]=0;
 | 
			
		||||
        return (i+1);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  return -1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int read_n_bytes(int fd,char *buff, size_t size)
 | 
			
		||||
{
 | 
			
		||||
  int i,ready;
 | 
			
		||||
  struct pollfd pfd[1];
 | 
			
		||||
 | 
			
		||||
  pfd[0].fd=fd;
 | 
			
		||||
  pfd[0].events=POLLIN;
 | 
			
		||||
  for(i=0; i < size; i++) {  
 | 
			
		||||
    pfd[0].revents=0;
 | 
			
		||||
    ready=poll_retry(pfd,1,tcp_read_time_out);
 | 
			
		||||
    if(ready!=1 || !(pfd[0].revents&POLLIN) || 1!=read(fd,&buff[i],1))
 | 
			
		||||
      return -1;
 | 
			
		||||
  }
 | 
			
		||||
  return size;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int timed_connect(int sock, const struct sockaddr *addr, unsigned int len)
 | 
			
		||||
{
 | 
			
		||||
	int ret,value,value_len;
 | 
			
		||||
 	struct pollfd pfd[1];
 | 
			
		||||
 | 
			
		||||
	pfd[0].fd=sock;
 | 
			
		||||
	pfd[0].events=POLLOUT;	
 | 
			
		||||
	fcntl(sock, F_SETFL, O_NONBLOCK);
 | 
			
		||||
  	ret=true_connect(sock, addr,  len);
 | 
			
		||||
//	printf("\nconnect ret=%d\n",ret);fflush(stdout);
 | 
			
		||||
  	if(ret==-1 && errno==EINPROGRESS) {
 | 
			
		||||
		ret=poll_retry(pfd,1,tcp_connect_time_out);
 | 
			
		||||
		//printf("\npoll ret=%d\n",ret);fflush(stdout);
 | 
			
		||||
      	if(ret == 1) {
 | 
			
		||||
           		value_len=sizeof(int);
 | 
			
		||||
             		getsockopt(sock,SOL_SOCKET,SO_ERROR,&value,&value_len) ;
 | 
			
		||||
					//printf("\nvalue=%d\n",value);fflush(stdout);
 | 
			
		||||
               	if(!value)
 | 
			
		||||
						ret=0;
 | 
			
		||||
                 	else
 | 
			
		||||
                  		ret=-1;
 | 
			
		||||
		} else {
 | 
			
		||||
              	ret=-1;
 | 
			
		||||
		}
 | 
			
		||||
	} else {
 | 
			
		||||
		if (ret != 0)
 | 
			
		||||
	       	ret=-1;
 | 
			
		||||
	} 	
 | 
			
		||||
 | 
			
		||||
	fcntl(sock, F_SETFL, !O_NONBLOCK);
 | 
			
		||||
	return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int tunnel_to(int sock, unsigned int ip, unsigned short port, proxy_type pt,char *user,char *pass)
 | 
			
		||||
{
 | 
			
		||||
        int len;
 | 
			
		||||
        char buff[BUFF_SIZE];
 | 
			
		||||
        memset (buff, 0, sizeof(buff));
 | 
			
		||||
        switch(pt)
 | 
			
		||||
        {
 | 
			
		||||
        	case HTTP_TYPE:
 | 
			
		||||
         		{
 | 
			
		||||
             		sprintf(buff,"CONNECT %s:%d HTTP/1.0\r\n",
 | 
			
		||||
			        inet_ntoa( * (struct in_addr *) &ip),
 | 
			
		||||
			        ntohs(port));
 | 
			
		||||
           			if (user[0])
 | 
			
		||||
                		{
 | 
			
		||||
					char src[256];
 | 
			
		||||
     					char dst[512];
 | 
			
		||||
					strcpy(src,user);
 | 
			
		||||
					strcat(src,":");
 | 
			
		||||
					strcat(src,pass);
 | 
			
		||||
					encode_base_64(src,dst,512);
 | 
			
		||||
					strcat(buff,"Proxy-Authorization: Basic ");
 | 
			
		||||
					strcat(buff,dst);
 | 
			
		||||
					strcat(buff,"\r\n\r\n");
 | 
			
		||||
				}
 | 
			
		||||
    				else
 | 
			
		||||
					strcat(buff,"\r\n");
 | 
			
		||||
			
 | 
			
		||||
           			len=strlen(buff);
 | 
			
		||||
 | 
			
		||||
			        if(len!=send(sock,buff,len,0))
 | 
			
		||||
			                return SOCKET_ERROR;
 | 
			
		||||
			
 | 
			
		||||
           			memset(buff, 0, sizeof(buff));
 | 
			
		||||
                        len=0 ;
 | 
			
		||||
      			 // read header byte by byte.
 | 
			
		||||
			       while(len<BUFF_SIZE)
 | 
			
		||||
			       {
 | 
			
		||||
			                if(1==read_n_bytes(sock,buff+len,1))
 | 
			
		||||
			                        len++;
 | 
			
		||||
			                else
 | 
			
		||||
			                        return SOCKET_ERROR;
 | 
			
		||||
			                if (    len > 4     &&
 | 
			
		||||
		                        	buff[len-1]=='\n'  &&
 | 
			
		||||
			                        buff[len-2]=='\r'  &&
 | 
			
		||||
			                        buff[len-3]=='\n'  &&
 | 
			
		||||
			                        buff[len-4]=='\r'  )
 | 
			
		||||
		                        break;
 | 
			
		||||
			       }
 | 
			
		||||
 | 
			
		||||
			       // if not ok (200) or response greather than BUFF_SIZE return BLOCKED;
 | 
			
		||||
			       if (     (len==BUFF_SIZE)  ||
 | 
			
		||||
			                ! (     buff[9] =='2'         &&
 | 
			
		||||
			                        buff[10]=='0'        &&
 | 
			
		||||
			                        buff[11]=='0'         ))
 | 
			
		||||
                                  return BLOCKED;
 | 
			
		||||
			       return SUCCESS;
 | 
			
		||||
           		}
 | 
			
		||||
            	break;
 | 
			
		||||
            case SOCKS4_TYPE:
 | 
			
		||||
            	{
 | 
			
		||||
               		memset(buff,0,sizeof(buff));
 | 
			
		||||
                 		buff[0]=4; // socks version
 | 
			
		||||
  				buff[1]=1; // connect command
 | 
			
		||||
				memcpy(&buff[2],&port,2); // dest port
 | 
			
		||||
				memcpy(&buff[4],&ip,4); // dest host
 | 
			
		||||
				len=strlen(user)+1; // username
 | 
			
		||||
    				if(len>1)	
 | 
			
		||||
         				strcpy(&buff[8],user);
 | 
			
		||||
				if((len+8)!=write_n_bytes(sock,buff,(8+len)))
 | 
			
		||||
					return SOCKET_ERROR;
 | 
			
		||||
 | 
			
		||||
 				if(8!=read_n_bytes(sock,buff,8))
 | 
			
		||||
					return SOCKET_ERROR;
 | 
			
		||||
            	
 | 
			
		||||
				if (buff[0]!=0||buff[1]!=90)
 | 
			
		||||
					return BLOCKED;
 | 
			
		||||
     				
 | 
			
		||||
         			return SUCCESS;
 | 
			
		||||
               	}
 | 
			
		||||
                	break;
 | 
			
		||||
            case SOCKS5_TYPE:
 | 
			
		||||
            	{
 | 
			
		||||
               		if(user)
 | 
			
		||||
                 		{
 | 
			
		||||
                 			buff[0]=5;   //version
 | 
			
		||||
					buff[1]=2;	//nomber of methods
 | 
			
		||||
					buff[2]=0;   // no auth method
 | 
			
		||||
	    				buff[3]=2;  /// auth method -> username / password
 | 
			
		||||
                              if(4!=write_n_bytes(sock,buff,4))
 | 
			
		||||
					 	return SOCKET_ERROR;
 | 
			
		||||
       			}
 | 
			
		||||
            		else
 | 
			
		||||
                		{
 | 
			
		||||
            			buff[0]=5;   //version
 | 
			
		||||
					buff[1]=1;	//nomber of methods
 | 
			
		||||
					buff[2]=0;   // no auth method
 | 
			
		||||
                              if(3!=write_n_bytes(sock,buff,3))
 | 
			
		||||
					 	return SOCKET_ERROR;
 | 
			
		||||
       			}
 | 
			
		||||
 | 
			
		||||
				memset(buff,0,sizeof(buff));
 | 
			
		||||
 | 
			
		||||
				if(2!=read_n_bytes(sock,buff,2))
 | 
			
		||||
			 		return SOCKET_ERROR;
 | 
			
		||||
			
 | 
			
		||||
      			if (buff[0]!=5||(buff[1]!=0&&buff[1]!=2))
 | 
			
		||||
         			{
 | 
			
		||||
        				if((buff[0]==0x05)&&(buff[1]==(char)0xFF))
 | 
			
		||||
             						return BLOCKED;
 | 
			
		||||
						else
 | 
			
		||||
							return SOCKET_ERROR;
 | 
			
		||||
          			}
 | 
			
		||||
          			
 | 
			
		||||
          			if (buff[1]==2)
 | 
			
		||||
               		{
 | 
			
		||||
					// authentication
 | 
			
		||||
					char in[2];
 | 
			
		||||
     					char out[515]; char* cur=out;
 | 
			
		||||
					int c;
 | 
			
		||||
     					*cur++=1; // version
 | 
			
		||||
					c=strlen(user);
 | 
			
		||||
					*cur++=c;
 | 
			
		||||
					strncpy(cur,user,c);
 | 
			
		||||
					cur+=c;
 | 
			
		||||
					c=strlen(pass);
 | 
			
		||||
					*cur++=c;
 | 
			
		||||
					strncpy(cur,pass,c);
 | 
			
		||||
					cur+=c;
 | 
			
		||||
					
 | 
			
		||||
     					if((cur-out)!=write_n_bytes(sock,out,cur-out))
 | 
			
		||||
					 	return SOCKET_ERROR;
 | 
			
		||||
     					
 | 
			
		||||
          				
 | 
			
		||||
					if(2!=read_n_bytes(sock,in,2))
 | 
			
		||||
			 			return SOCKET_ERROR;
 | 
			
		||||
					if(in[0]!=1||in[1]!=0)
 | 
			
		||||
       				{
 | 
			
		||||
						if(in[0]!=1)
 | 
			
		||||
      						return SOCKET_ERROR;
 | 
			
		||||
						else
 | 
			
		||||
      						return BLOCKED;
 | 
			
		||||
					}
 | 
			
		||||
				}	
 | 
			
		||||
 | 
			
		||||
     				buff[0]=5;       // version
 | 
			
		||||
				buff[1]=1;       // connect
 | 
			
		||||
				buff[2]=0;       // reserved
 | 
			
		||||
				buff[3]=1;       // ip v4
 | 
			
		||||
 | 
			
		||||
			 	memcpy(&buff[4],&ip,4); // dest host
 | 
			
		||||
				memcpy(&buff[8],&port,2); // dest port
 | 
			
		||||
				
 | 
			
		||||
 | 
			
		||||
			      if(10!=write_n_bytes(sock,buff,10))
 | 
			
		||||
					return SOCKET_ERROR;
 | 
			
		||||
		
 | 
			
		||||
			      if(4!=read_n_bytes(sock,buff,4))
 | 
			
		||||
					return SOCKET_ERROR;
 | 
			
		||||
 | 
			
		||||
				if (buff[0]!=5||buff[1]!=0)
 | 
			
		||||
			      	return SOCKET_ERROR;
 | 
			
		||||
 | 
			
		||||
			  	switch (buff[3])
 | 
			
		||||
			      {
 | 
			
		||||
					case 1: len=4;  break;
 | 
			
		||||
					case 4: len=16; break;
 | 
			
		||||
					case 3: len=0;
 | 
			
		||||
			  			if(1!=read_n_bytes(sock,(char*)&len,1))
 | 
			
		||||
			 				return SOCKET_ERROR;
 | 
			
		||||
        					break;
 | 
			
		||||
					default:
 | 
			
		||||
						return SOCKET_ERROR;
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
     				if((len+2)!=read_n_bytes(sock,buff,(len+2)))
 | 
			
		||||
					return SOCKET_ERROR;
 | 
			
		||||
 | 
			
		||||
				return SUCCESS;
 | 
			
		||||
                	}
 | 
			
		||||
                	break;	
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
return SOCKET_ERROR;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int start_chain(int *fd, proxy_data *pd, char* begin_mark)
 | 
			
		||||
{
 | 
			
		||||
	struct sockaddr_in addr;
 | 
			
		||||
	
 | 
			
		||||
	*fd=socket(PF_INET,SOCK_STREAM,0);
 | 
			
		||||
	if(*fd==-1)
 | 
			
		||||
		goto error;
 | 
			
		||||
	
 | 
			
		||||
	proxychains_write_log("%s-<>-%s:%d-",
 | 
			
		||||
				begin_mark,
 | 
			
		||||
				inet_ntoa(*(struct in_addr*)&pd->ip),
 | 
			
		||||
				htons(pd->port));
 | 
			
		||||
	pd->ps=PLAY_STATE;
 | 
			
		||||
	memset(&addr, 0, sizeof(addr));
 | 
			
		||||
	addr.sin_family = AF_INET;
 | 
			
		||||
	addr.sin_addr.s_addr = pd->ip;
 | 
			
		||||
	addr.sin_port = pd->port;
 | 
			
		||||
	if (timed_connect (*fd ,(struct sockaddr*)&addr,sizeof(addr))) {
 | 
			
		||||
		pd->ps=DOWN_STATE;
 | 
			
		||||
		goto error1;
 | 
			
		||||
	}
 | 
			
		||||
	pd->ps=BUSY_STATE;
 | 
			
		||||
	return SUCCESS;
 | 
			
		||||
error1:
 | 
			
		||||
	proxychains_write_log("<--timeout\n");
 | 
			
		||||
error:
 | 
			
		||||
	if(*fd!=-1)
 | 
			
		||||
		close(*fd);
 | 
			
		||||
	return SOCKET_ERROR;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static proxy_data * select_proxy(select_type how, 
 | 
			
		||||
		proxy_data *pd, int proxy_count, int *offset)
 | 
			
		||||
{
 | 
			
		||||
	int i=0,k=0;
 | 
			
		||||
	if(*offset>=proxy_count)
 | 
			
		||||
		return NULL;
 | 
			
		||||
	switch(how) {
 | 
			
		||||
		case RANDOMLY:
 | 
			
		||||
			srand(time(NULL));
 | 
			
		||||
			do {
 | 
			
		||||
				k++;
 | 
			
		||||
				i = 0 + (int) (proxy_count*1.0*rand()/
 | 
			
		||||
						(RAND_MAX+1.0));
 | 
			
		||||
			} while (pd[i].ps!=PLAY_STATE && k<proxy_count*100 );
 | 
			
		||||
		break;
 | 
			
		||||
		case FIFOLY:
 | 
			
		||||
			for(i=*offset;i<proxy_count;i++) {
 | 
			
		||||
				if(pd[i].ps==PLAY_STATE) {
 | 
			
		||||
					*offset=i;
 | 
			
		||||
					break;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		default:
 | 
			
		||||
		break;
 | 
			
		||||
	}
 | 
			
		||||
	if (i>=proxy_count)
 | 
			
		||||
		i=0;
 | 
			
		||||
	return pd[i].ps==PLAY_STATE?&pd[i]:NULL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static void release_all(proxy_data *pd, int proxy_count)
 | 
			
		||||
{
 | 
			
		||||
	int i;
 | 
			
		||||
	for(i=0;i<proxy_count;i++)
 | 
			
		||||
		pd[i].ps=PLAY_STATE;
 | 
			
		||||
	return;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void release_busy(proxy_data *pd, int proxy_count)
 | 
			
		||||
{
 | 
			
		||||
	int i;
 | 
			
		||||
	for(i=0;i<proxy_count;i++)
 | 
			
		||||
		if(pd[i].ps==BUSY_STATE)
 | 
			
		||||
			pd[i].ps=PLAY_STATE;
 | 
			
		||||
	return;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int calc_alive(proxy_data *pd, int proxy_count)
 | 
			
		||||
{
 | 
			
		||||
	int i;
 | 
			
		||||
	int alive_count=0;
 | 
			
		||||
	release_busy(pd,proxy_count);
 | 
			
		||||
	for(i=0;i<proxy_count;i++)
 | 
			
		||||
		if(pd[i].ps==PLAY_STATE)
 | 
			
		||||
			alive_count++;
 | 
			
		||||
	return alive_count;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static int chain_step(int ns, proxy_data *pfrom, proxy_data *pto)
 | 
			
		||||
{
 | 
			
		||||
	int retcode=-1;
 | 
			
		||||
	
 | 
			
		||||
	proxychains_write_log("<>-%s:%d-", 
 | 
			
		||||
			inet_ntoa(*(struct in_addr*)&pto->ip),
 | 
			
		||||
			htons(pto->port));
 | 
			
		||||
	retcode = 
 | 
			
		||||
		tunnel_to(ns, pto->ip, pto->port, pfrom->pt, pfrom->user, 
 | 
			
		||||
				pfrom->pass);
 | 
			
		||||
	switch(retcode) {
 | 
			
		||||
		case SUCCESS:
 | 
			
		||||
			pto->ps=BUSY_STATE;
 | 
			
		||||
			break;
 | 
			
		||||
		case BLOCKED:
 | 
			
		||||
			pto->ps=BLOCKED_STATE;
 | 
			
		||||
			proxychains_write_log("<--denied\n");
 | 
			
		||||
			close(ns);
 | 
			
		||||
			break;
 | 
			
		||||
		case SOCKET_ERROR:
 | 
			
		||||
			pto->ps=DOWN_STATE;
 | 
			
		||||
			proxychains_write_log("<--timeout\n");
 | 
			
		||||
			close(ns);
 | 
			
		||||
			break;
 | 
			
		||||
	}
 | 
			
		||||
	return retcode;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int connect_proxy_chain( int sock, unsigned int target_ip, 
 | 
			
		||||
		unsigned short target_port, proxy_data *pd, 
 | 
			
		||||
		unsigned int proxy_count, chain_type ct, int max_chain )
 | 
			
		||||
{
 | 
			
		||||
	proxy_data p4;
 | 
			
		||||
	proxy_data *p1,*p2,*p3;
 | 
			
		||||
	int ns=-1;
 | 
			
		||||
	int offset=0;
 | 
			
		||||
	int alive_count=0;
 | 
			
		||||
	int curr_len=0;
 | 
			
		||||
 | 
			
		||||
#define TP "<>"
 | 
			
		||||
#define DT "|D-chain|"
 | 
			
		||||
#define ST "|S-chain|"
 | 
			
		||||
#define RT "|R-chain|"
 | 
			
		||||
	
 | 
			
		||||
	p3=&p4;
 | 
			
		||||
 | 
			
		||||
again:
 | 
			
		||||
	switch(ct)  {
 | 
			
		||||
		case DYNAMIC_TYPE:
 | 
			
		||||
		alive_count=calc_alive(pd,proxy_count);
 | 
			
		||||
		offset=0;
 | 
			
		||||
		do {
 | 
			
		||||
			if(!(p1=select_proxy(FIFOLY,pd,proxy_count,&offset)))
 | 
			
		||||
				goto error_more;
 | 
			
		||||
		} while(SUCCESS!=start_chain(&ns,p1,DT) && offset<proxy_count);
 | 
			
		||||
		for(;;) {
 | 
			
		||||
			p2=select_proxy(FIFOLY,pd,proxy_count,&offset);
 | 
			
		||||
			if(!p2)
 | 
			
		||||
				break;
 | 
			
		||||
			if(SUCCESS!=chain_step(ns,p1,p2))
 | 
			
		||||
				goto again;
 | 
			
		||||
			p1=p2;
 | 
			
		||||
		}
 | 
			
		||||
		proxychains_write_log(TP);
 | 
			
		||||
		p3->ip=target_ip;
 | 
			
		||||
		p3->port=target_port;
 | 
			
		||||
		if(SUCCESS!=chain_step(ns,p1,p3))
 | 
			
		||||
			goto error;
 | 
			
		||||
		break;
 | 
			
		||||
 | 
			
		||||
	case STRICT_TYPE:
 | 
			
		||||
		alive_count=calc_alive(pd,proxy_count);
 | 
			
		||||
		offset=0;
 | 
			
		||||
		if(!(p1=select_proxy(FIFOLY,pd,proxy_count,&offset)))
 | 
			
		||||
			goto error_strict;
 | 
			
		||||
		if(SUCCESS!=start_chain(&ns,p1,ST))
 | 
			
		||||
			goto error_strict;
 | 
			
		||||
		while(offset<proxy_count) {
 | 
			
		||||
			if(!(p2=select_proxy(FIFOLY,pd,proxy_count,&offset)))
 | 
			
		||||
				break;
 | 
			
		||||
			if(SUCCESS!=chain_step(ns,p1,p2))
 | 
			
		||||
				goto error_strict;
 | 
			
		||||
			p1=p2;
 | 
			
		||||
		}
 | 
			
		||||
		proxychains_write_log(TP);
 | 
			
		||||
		p3->ip=target_ip;
 | 
			
		||||
		p3->port=target_port;
 | 
			
		||||
		if(SUCCESS!=chain_step(ns,p1,p3))
 | 
			
		||||
			goto error;
 | 
			
		||||
		break;
 | 
			
		||||
		
 | 
			
		||||
	case RANDOM_TYPE:
 | 
			
		||||
		alive_count=calc_alive(pd,proxy_count);
 | 
			
		||||
		if(alive_count<max_chain)
 | 
			
		||||
			goto error_more;
 | 
			
		||||
		curr_len=offset=0;
 | 
			
		||||
		do {
 | 
			
		||||
			if(!(p1=select_proxy(RANDOMLY,pd,proxy_count,&offset)))
 | 
			
		||||
				goto error_more;
 | 
			
		||||
		} while(SUCCESS!=start_chain(&ns,p1,RT) && offset<max_chain);
 | 
			
		||||
		while(++curr_len<max_chain) {
 | 
			
		||||
			if(!(p2=select_proxy(RANDOMLY,pd,proxy_count,&offset)))
 | 
			
		||||
				goto error_more;
 | 
			
		||||
			if(SUCCESS!=chain_step(ns,p1,p2))
 | 
			
		||||
				goto again;
 | 
			
		||||
			p1=p2;
 | 
			
		||||
		}
 | 
			
		||||
		proxychains_write_log(TP);
 | 
			
		||||
		p3->ip=target_ip;
 | 
			
		||||
		p3->port=target_port;
 | 
			
		||||
		if(SUCCESS!=chain_step(ns,p1,p3))
 | 
			
		||||
			goto error;
 | 
			
		||||
			
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
done:
 | 
			
		||||
	proxychains_write_log("<><>-OK\n");
 | 
			
		||||
	dup2(ns,sock);
 | 
			
		||||
	close(ns);
 | 
			
		||||
	return 0;
 | 
			
		||||
error:
 | 
			
		||||
	if(ns!=-1)
 | 
			
		||||
		close(ns);
 | 
			
		||||
	errno = ECONNREFUSED;  // for nmap ;)
 | 
			
		||||
	return -1;
 | 
			
		||||
	
 | 
			
		||||
error_more:
 | 
			
		||||
	proxychains_write_log("\n!!!need more proxies!!!\n");
 | 
			
		||||
error_strict:
 | 
			
		||||
	release_all(pd,proxy_count);
 | 
			
		||||
	if(ns!=-1)
 | 
			
		||||
		close(ns);
 | 
			
		||||
	errno = ETIMEDOUT;
 | 
			
		||||
	return -1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static struct hostent hostent_space;
 | 
			
		||||
static in_addr_t resolved_addr;
 | 
			
		||||
static char* resolved_addr_p;
 | 
			
		||||
static char addr_name[1024*8];
 | 
			
		||||
struct hostent* proxy_gethostbyname(const char *name)
 | 
			
		||||
{
 | 
			
		||||
	int pipe_fd[2];
 | 
			
		||||
	char buff[256];
 | 
			
		||||
	in_addr_t addr;
 | 
			
		||||
	pid_t pid;
 | 
			
		||||
	int status;
 | 
			
		||||
	struct hostent* hp;
 | 
			
		||||
 | 
			
		||||
	hostent_space.h_addr_list = &resolved_addr_p;
 | 
			
		||||
	*hostent_space.h_addr_list = (char*)&resolved_addr;
 | 
			
		||||
	resolved_addr = 0;
 | 
			
		||||
	
 | 
			
		||||
	gethostname(buff,sizeof(buff));
 | 
			
		||||
	if(!strcmp(buff,name))
 | 
			
		||||
		goto got_buff;
 | 
			
		||||
 | 
			
		||||
	memset(buff, 0, sizeof(buff));
 | 
			
		||||
	
 | 
			
		||||
	// TODO: this works only once, so cache it  ...
 | 
			
		||||
	// 	 later
 | 
			
		||||
	while (hp=gethostent())
 | 
			
		||||
		if (!strcmp(hp->h_name,name)) 
 | 
			
		||||
			return hp; 
 | 
			
		||||
	
 | 
			
		||||
	if(pipe(pipe_fd))
 | 
			
		||||
		goto err;
 | 
			
		||||
	pid = fork();
 | 
			
		||||
	switch(pid) {
 | 
			
		||||
	
 | 
			
		||||
		case 0: // child
 | 
			
		||||
			proxychains_write_log("|DNS-request| %s \n", name);
 | 
			
		||||
			dup2(pipe_fd[1],1);
 | 
			
		||||
			//dup2(pipe_fd[1],2);
 | 
			
		||||
		//	putenv("LD_PRELOAD=");
 | 
			
		||||
			execlp("proxyresolv","proxyresolv",name,NULL);
 | 
			
		||||
			perror("can't exec proxyresolv");
 | 
			
		||||
			exit(2);
 | 
			
		||||
 | 
			
		||||
		case -1: //error
 | 
			
		||||
			close(pipe_fd[0]);
 | 
			
		||||
			close(pipe_fd[1]);
 | 
			
		||||
			perror("can't fork");
 | 
			
		||||
			goto err;
 | 
			
		||||
		
 | 
			
		||||
		default:
 | 
			
		||||
			close(pipe_fd[1]);
 | 
			
		||||
			waitpid(pid, &status, 0);
 | 
			
		||||
			read(pipe_fd[0],&buff,sizeof(buff));
 | 
			
		||||
			close(pipe_fd[0]);
 | 
			
		||||
got_buff:
 | 
			
		||||
			addr = inet_addr(buff);
 | 
			
		||||
			if (addr == -1)
 | 
			
		||||
				goto err_dns;
 | 
			
		||||
			memcpy(*(hostent_space.h_addr_list),
 | 
			
		||||
						&addr ,sizeof(struct in_addr));
 | 
			
		||||
			hostent_space.h_name = addr_name;
 | 
			
		||||
			hostent_space.h_length = sizeof (in_addr_t);
 | 
			
		||||
	}
 | 
			
		||||
	proxychains_write_log("|DNS-response| %s is %s\n",
 | 
			
		||||
			name, inet_ntoa(*(struct in_addr*)&addr));
 | 
			
		||||
	return &hostent_space;
 | 
			
		||||
err_dns:
 | 
			
		||||
	proxychains_write_log("|DNS-response|: %s is not exist\n", name);
 | 
			
		||||
err:
 | 
			
		||||
	return NULL;
 | 
			
		||||
}
 | 
			
		||||
int proxy_getaddrinfo(const char *node, const char *service,
 | 
			
		||||
		const struct addrinfo *hints,
 | 
			
		||||
		struct addrinfo **res)
 | 
			
		||||
{
 | 
			
		||||
	struct servent *se = NULL;
 | 
			
		||||
	struct hostent *hp = NULL;
 | 
			
		||||
	struct sockaddr* sockaddr_space = NULL;
 | 
			
		||||
	struct addrinfo*  addrinfo_space = NULL;
 | 
			
		||||
	
 | 
			
		||||
//	printf("proxy_getaddrinfo node %s service %s\n",node,service);
 | 
			
		||||
	addrinfo_space = malloc(sizeof(struct addrinfo));
 | 
			
		||||
	if(!addrinfo_space)
 | 
			
		||||
		goto err1;
 | 
			
		||||
	sockaddr_space = malloc(sizeof(struct sockaddr));
 | 
			
		||||
	if(!sockaddr_space)
 | 
			
		||||
		goto err2;
 | 
			
		||||
	memset(sockaddr_space, 0, sizeof(*sockaddr_space));
 | 
			
		||||
	memset(addrinfo_space, 0, sizeof(*addrinfo_space));
 | 
			
		||||
	if (node &&
 | 
			
		||||
	    !inet_aton(node,&((struct sockaddr_in*)sockaddr_space)->sin_addr)) {
 | 
			
		||||
		hp = proxy_gethostbyname(node);
 | 
			
		||||
		if (hp) 
 | 
			
		||||
			memcpy(&((struct sockaddr_in*)sockaddr_space)->sin_addr,
 | 
			
		||||
				*(hp->h_addr_list),
 | 
			
		||||
				sizeof(in_addr_t));
 | 
			
		||||
		else
 | 
			
		||||
			goto err3;
 | 
			
		||||
	}
 | 
			
		||||
	if (service)
 | 
			
		||||
		se = getservbyname(service, NULL);
 | 
			
		||||
	
 | 
			
		||||
	if (!se) {
 | 
			
		||||
		((struct sockaddr_in*)sockaddr_space)->sin_port = 
 | 
			
		||||
			htons(atoi(service?:"0"));
 | 
			
		||||
	} else 
 | 
			
		||||
		((struct sockaddr_in*)sockaddr_space)->sin_port = se->s_port;
 | 
			
		||||
 | 
			
		||||
	*res = addrinfo_space;
 | 
			
		||||
	(*res)->ai_addr = sockaddr_space;
 | 
			
		||||
	if (node)
 | 
			
		||||
		strcpy(addr_name, node);
 | 
			
		||||
	(*res)->ai_canonname = addr_name;
 | 
			
		||||
	(*res)->ai_next = NULL;
 | 
			
		||||
	(*res)->ai_family = sockaddr_space->sa_family = AF_INET;
 | 
			
		||||
	(*res)->ai_socktype = hints->ai_socktype;
 | 
			
		||||
	(*res)->ai_flags = hints->ai_flags;
 | 
			
		||||
	(*res)->ai_protocol = hints->ai_protocol;
 | 
			
		||||
	(*res)->ai_addrlen = sizeof(*sockaddr_space);
 | 
			
		||||
	goto out;
 | 
			
		||||
err3:
 | 
			
		||||
	free(sockaddr_space);
 | 
			
		||||
err2:
 | 
			
		||||
	free(addrinfo_space);
 | 
			
		||||
err1:
 | 
			
		||||
	return 1;
 | 
			
		||||
out:
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										112
									
								
								src/core.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										112
									
								
								src/core.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,112 @@
 | 
			
		||||
/***************************************************************************
 | 
			
		||||
                          core.h  -  description
 | 
			
		||||
                             -------------------
 | 
			
		||||
    begin                : Tue May 14 2002
 | 
			
		||||
    copyright          :  netcreature (C) 2002
 | 
			
		||||
    email                 : netcreature@users.sourceforge.net
 | 
			
		||||
 ***************************************************************************/
 | 
			
		||||
 /*     GPL */
 | 
			
		||||
/***************************************************************************
 | 
			
		||||
 *                                                                         *
 | 
			
		||||
 *   This program is free software; you can redistribute it and/or modify  *
 | 
			
		||||
 *   it under the terms of the GNU General Public License as published by  *
 | 
			
		||||
 *   the Free Software Foundation; either version 2 of the License, or     *
 | 
			
		||||
 *   (at your option) any later version.                                   *
 | 
			
		||||
 *                                                                         *
 | 
			
		||||
 ***************************************************************************/
 | 
			
		||||
#ifndef __CORE_HEADER
 | 
			
		||||
#define __CORE_HEADER
 | 
			
		||||
#define BUFF_SIZE 8*1024  // used to read responses from proxies.
 | 
			
		||||
#define     MAX_LOCALNET 1024
 | 
			
		||||
/*error codes*/
 | 
			
		||||
typedef enum
 | 
			
		||||
{
 | 
			
		||||
 SUCCESS=0,
 | 
			
		||||
 MEMORY_FAIL,        // malloc failed
 | 
			
		||||
 SOCKET_ERROR,  // look errno for more
 | 
			
		||||
 CHAIN_DOWN,    // no proxy in chain responds to tcp
 | 
			
		||||
 CHAIN_EMPTY,   //  if proxy_count = 0
 | 
			
		||||
 BLOCKED  //  target's port blocked on last proxy in the chain
 | 
			
		||||
} ERR_CODE;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
typedef enum {HTTP_TYPE,SOCKS4_TYPE,SOCKS5_TYPE} proxy_type;
 | 
			
		||||
typedef enum {DYNAMIC_TYPE,STRICT_TYPE,RANDOM_TYPE} chain_type;
 | 
			
		||||
typedef enum {PLAY_STATE,DOWN_STATE,BLOCKED_STATE,BUSY_STATE} proxy_state;
 | 
			
		||||
typedef enum {RANDOMLY,FIFOLY} select_type;
 | 
			
		||||
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
	struct in_addr in_addr, netmask;
 | 
			
		||||
	unsigned short port;
 | 
			
		||||
} localaddr_arg;
 | 
			
		||||
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
unsigned int ip;
 | 
			
		||||
unsigned short port;
 | 
			
		||||
proxy_type pt;
 | 
			
		||||
proxy_state ps;
 | 
			
		||||
char user[256];
 | 
			
		||||
char pass[256];
 | 
			
		||||
} proxy_data;
 | 
			
		||||
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
	proxy_data *pd;
 | 
			
		||||
 	chain_type ct;
 | 
			
		||||
  	unsigned int proxy_count;
 | 
			
		||||
   	int sock;
 | 
			
		||||
    	struct sockaddr addr;
 | 
			
		||||
      int flags;
 | 
			
		||||
} thread_arg;
 | 
			
		||||
 | 
			
		||||
int connect_proxy_chain (
 | 
			
		||||
		int sock,
 | 
			
		||||
		unsigned int target_ip,
 | 
			
		||||
		unsigned short target_port,
 | 
			
		||||
		proxy_data * pd,
 | 
			
		||||
		unsigned int proxy_count,
 | 
			
		||||
		chain_type ct,
 | 
			
		||||
		int max_chain );
 | 
			
		||||
 | 
			
		||||
int proxychains_write_log(char *str,...);
 | 
			
		||||
struct hostent* proxy_gethostbyname(const char *name);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
typedef int (*connect_t)(int, const struct sockaddr *, socklen_t);
 | 
			
		||||
connect_t true_connect;
 | 
			
		||||
 | 
			
		||||
typedef struct hostent* (*gethostbyname_t)(const char *);
 | 
			
		||||
gethostbyname_t true_gethostbyname;
 | 
			
		||||
 | 
			
		||||
typedef int (*getaddrinfo_t)(const char *, const char *,
 | 
			
		||||
		const struct addrinfo *,
 | 
			
		||||
		struct addrinfo **);
 | 
			
		||||
getaddrinfo_t true_getaddrinfo;
 | 
			
		||||
 | 
			
		||||
typedef int (*freeaddrinfo_t)(struct addrinfo *);
 | 
			
		||||
freeaddrinfo_t true_freeaddrinfo;
 | 
			
		||||
 | 
			
		||||
typedef int (*getnameinfo_t) (const struct sockaddr *,
 | 
			
		||||
		socklen_t, char *,
 | 
			
		||||
		socklen_t, char *,
 | 
			
		||||
		socklen_t, unsigned int);
 | 
			
		||||
getnameinfo_t true_getnameinfo;
 | 
			
		||||
 | 
			
		||||
typedef struct hostent *(*gethostbyaddr_t) (const void *, socklen_t, int);
 | 
			
		||||
gethostbyaddr_t true_gethostbyaddr;
 | 
			
		||||
 | 
			
		||||
int proxy_getaddrinfo(const char *node, const char *service,
 | 
			
		||||
		                const struct addrinfo *hints,
 | 
			
		||||
				                struct addrinfo **res);
 | 
			
		||||
 | 
			
		||||
struct hostent* proxy_gethostbyname(const char *name);
 | 
			
		||||
 | 
			
		||||
#if 0
 | 
			
		||||
#define PDEBUG(fmt, args...) fprintf(stderr,"DEBUG:"fmt, ## args)
 | 
			
		||||
#else
 | 
			
		||||
#define PDEBUG(fmt, args...)
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif 
 | 
			
		||||
							
								
								
									
										5
									
								
								src/docs/Makefile.am
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								src/docs/Makefile.am
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,5 @@
 | 
			
		||||
####### kdevelop will overwrite this part!!! (begin)##########
 | 
			
		||||
 | 
			
		||||
SUBDIRS = en 
 | 
			
		||||
 | 
			
		||||
####### kdevelop will overwrite this part!!! (end)############
 | 
			
		||||
							
								
								
									
										308
									
								
								src/docs/Makefile.in
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										308
									
								
								src/docs/Makefile.in
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,308 @@
 | 
			
		||||
# Makefile.in generated automatically by automake 1.4-p6 from Makefile.am
 | 
			
		||||
 | 
			
		||||
# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
 | 
			
		||||
# This Makefile.in is free software; the Free Software Foundation
 | 
			
		||||
# gives unlimited permission to copy and/or distribute it,
 | 
			
		||||
# with or without modifications, as long as this notice is preserved.
 | 
			
		||||
 | 
			
		||||
# This program is distributed in the hope that it will be useful,
 | 
			
		||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
 | 
			
		||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 | 
			
		||||
# PARTICULAR PURPOSE.
 | 
			
		||||
 | 
			
		||||
####### kdevelop will overwrite this part!!! (begin)##########
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
SHELL = @SHELL@
 | 
			
		||||
 | 
			
		||||
srcdir = @srcdir@
 | 
			
		||||
top_srcdir = @top_srcdir@
 | 
			
		||||
VPATH = @srcdir@
 | 
			
		||||
prefix = @prefix@
 | 
			
		||||
exec_prefix = @exec_prefix@
 | 
			
		||||
 | 
			
		||||
bindir = @bindir@
 | 
			
		||||
sbindir = @sbindir@
 | 
			
		||||
libexecdir = @libexecdir@
 | 
			
		||||
datadir = @datadir@
 | 
			
		||||
sysconfdir = @sysconfdir@
 | 
			
		||||
sharedstatedir = @sharedstatedir@
 | 
			
		||||
localstatedir = @localstatedir@
 | 
			
		||||
libdir = @libdir@
 | 
			
		||||
infodir = @infodir@
 | 
			
		||||
mandir = @mandir@
 | 
			
		||||
includedir = @includedir@
 | 
			
		||||
oldincludedir = /usr/include
 | 
			
		||||
 | 
			
		||||
DESTDIR =
 | 
			
		||||
 | 
			
		||||
pkgdatadir = $(datadir)/@PACKAGE@
 | 
			
		||||
pkglibdir = $(libdir)/@PACKAGE@
 | 
			
		||||
pkgincludedir = $(includedir)/@PACKAGE@
 | 
			
		||||
 | 
			
		||||
top_builddir = ../..
 | 
			
		||||
 | 
			
		||||
ACLOCAL = @ACLOCAL@
 | 
			
		||||
AUTOCONF = @AUTOCONF@
 | 
			
		||||
AUTOMAKE = @AUTOMAKE@
 | 
			
		||||
AUTOHEADER = @AUTOHEADER@
 | 
			
		||||
 | 
			
		||||
INSTALL = @INSTALL@
 | 
			
		||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
 | 
			
		||||
INSTALL_DATA = @INSTALL_DATA@
 | 
			
		||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
 | 
			
		||||
transform = @program_transform_name@
 | 
			
		||||
 | 
			
		||||
NORMAL_INSTALL = :
 | 
			
		||||
PRE_INSTALL = :
 | 
			
		||||
POST_INSTALL = :
 | 
			
		||||
NORMAL_UNINSTALL = :
 | 
			
		||||
PRE_UNINSTALL = :
 | 
			
		||||
POST_UNINSTALL = :
 | 
			
		||||
build_alias = @build_alias@
 | 
			
		||||
build_triplet = @build@
 | 
			
		||||
host_alias = @host_alias@
 | 
			
		||||
host_triplet = @host@
 | 
			
		||||
target_alias = @target_alias@
 | 
			
		||||
target_triplet = @target@
 | 
			
		||||
AR = @AR@
 | 
			
		||||
AS = @AS@
 | 
			
		||||
CC = @CC@
 | 
			
		||||
CXX = @CXX@
 | 
			
		||||
CXXCPP = @CXXCPP@
 | 
			
		||||
DLLTOOL = @DLLTOOL@
 | 
			
		||||
ECHO = @ECHO@
 | 
			
		||||
EGREP = @EGREP@
 | 
			
		||||
EXEEXT = @EXEEXT@
 | 
			
		||||
F77 = @F77@
 | 
			
		||||
GCJ = @GCJ@
 | 
			
		||||
GCJFLAGS = @GCJFLAGS@
 | 
			
		||||
HAVE_LIB = @HAVE_LIB@
 | 
			
		||||
LIB = @LIB@
 | 
			
		||||
LIBTOOL = @LIBTOOL@
 | 
			
		||||
LN_S = @LN_S@
 | 
			
		||||
LTLIB = @LTLIB@
 | 
			
		||||
MAKEINFO = @MAKEINFO@
 | 
			
		||||
OBJDUMP = @OBJDUMP@
 | 
			
		||||
OBJEXT = @OBJEXT@
 | 
			
		||||
PACKAGE = @PACKAGE@
 | 
			
		||||
RANLIB = @RANLIB@
 | 
			
		||||
RC = @RC@
 | 
			
		||||
STRIP = @STRIP@
 | 
			
		||||
VERSION = @VERSION@
 | 
			
		||||
 | 
			
		||||
SUBDIRS = en 
 | 
			
		||||
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
 | 
			
		||||
CONFIG_HEADER = ../../config.h
 | 
			
		||||
CONFIG_CLEAN_FILES = 
 | 
			
		||||
DIST_COMMON =  Makefile.am Makefile.in
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
 | 
			
		||||
 | 
			
		||||
TAR = tar
 | 
			
		||||
GZIP_ENV = --best
 | 
			
		||||
all: all-redirect
 | 
			
		||||
.SUFFIXES:
 | 
			
		||||
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) 
 | 
			
		||||
	cd $(top_srcdir) && $(AUTOMAKE) --gnu proxychains/docs/Makefile
 | 
			
		||||
 | 
			
		||||
Makefile: $(srcdir)/Makefile.in  $(top_builddir)/config.status $(BUILT_SOURCES)
 | 
			
		||||
	cd $(top_builddir) \
 | 
			
		||||
	  && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# This directory's subdirectories are mostly independent; you can cd
 | 
			
		||||
# into them and run `make' without going through this Makefile.
 | 
			
		||||
# To change the values of `make' variables: instead of editing Makefiles,
 | 
			
		||||
# (1) if the variable is set in `config.status', edit `config.status'
 | 
			
		||||
#     (which will cause the Makefiles to be regenerated when you run `make');
 | 
			
		||||
# (2) otherwise, pass the desired values on the `make' command line.
 | 
			
		||||
 | 
			
		||||
@SET_MAKE@
 | 
			
		||||
 | 
			
		||||
all-recursive install-data-recursive install-exec-recursive \
 | 
			
		||||
installdirs-recursive install-recursive uninstall-recursive  \
 | 
			
		||||
check-recursive installcheck-recursive info-recursive dvi-recursive:
 | 
			
		||||
	@set fnord $$MAKEFLAGS; amf=$$2; \
 | 
			
		||||
	dot_seen=no; \
 | 
			
		||||
	target=`echo $@ | sed s/-recursive//`; \
 | 
			
		||||
	list='$(SUBDIRS)'; for subdir in $$list; do \
 | 
			
		||||
	  echo "Making $$target in $$subdir"; \
 | 
			
		||||
	  if test "$$subdir" = "."; then \
 | 
			
		||||
	    dot_seen=yes; \
 | 
			
		||||
	    local_target="$$target-am"; \
 | 
			
		||||
	  else \
 | 
			
		||||
	    local_target="$$target"; \
 | 
			
		||||
	  fi; \
 | 
			
		||||
	  (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
 | 
			
		||||
	   || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
 | 
			
		||||
	done; \
 | 
			
		||||
	if test "$$dot_seen" = "no"; then \
 | 
			
		||||
	  $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
 | 
			
		||||
	fi; test -z "$$fail"
 | 
			
		||||
 | 
			
		||||
mostlyclean-recursive clean-recursive distclean-recursive \
 | 
			
		||||
maintainer-clean-recursive:
 | 
			
		||||
	@set fnord $$MAKEFLAGS; amf=$$2; \
 | 
			
		||||
	dot_seen=no; \
 | 
			
		||||
	rev=''; list='$(SUBDIRS)'; for subdir in $$list; do \
 | 
			
		||||
	  rev="$$subdir $$rev"; \
 | 
			
		||||
	  test "$$subdir" != "." || dot_seen=yes; \
 | 
			
		||||
	done; \
 | 
			
		||||
	test "$$dot_seen" = "no" && rev=". $$rev"; \
 | 
			
		||||
	target=`echo $@ | sed s/-recursive//`; \
 | 
			
		||||
	for subdir in $$rev; do \
 | 
			
		||||
	  echo "Making $$target in $$subdir"; \
 | 
			
		||||
	  if test "$$subdir" = "."; then \
 | 
			
		||||
	    local_target="$$target-am"; \
 | 
			
		||||
	  else \
 | 
			
		||||
	    local_target="$$target"; \
 | 
			
		||||
	  fi; \
 | 
			
		||||
	  (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
 | 
			
		||||
	   || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
 | 
			
		||||
	done && test -z "$$fail"
 | 
			
		||||
tags-recursive:
 | 
			
		||||
	list='$(SUBDIRS)'; for subdir in $$list; do \
 | 
			
		||||
	  test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
 | 
			
		||||
	done
 | 
			
		||||
 | 
			
		||||
tags: TAGS
 | 
			
		||||
 | 
			
		||||
ID: $(HEADERS) $(SOURCES) $(LISP)
 | 
			
		||||
	list='$(SOURCES) $(HEADERS)'; \
 | 
			
		||||
	unique=`for i in $$list; do echo $$i; done | \
 | 
			
		||||
	  awk '    { files[$$0] = 1; } \
 | 
			
		||||
	       END { for (i in files) print i; }'`; \
 | 
			
		||||
	here=`pwd` && cd $(srcdir) \
 | 
			
		||||
	  && mkid -f$$here/ID $$unique $(LISP)
 | 
			
		||||
 | 
			
		||||
TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) $(LISP)
 | 
			
		||||
	tags=; \
 | 
			
		||||
	here=`pwd`; \
 | 
			
		||||
	list='$(SUBDIRS)'; for subdir in $$list; do \
 | 
			
		||||
   if test "$$subdir" = .; then :; else \
 | 
			
		||||
	    test -f $$subdir/TAGS && tags="$$tags -i $$here/$$subdir/TAGS"; \
 | 
			
		||||
   fi; \
 | 
			
		||||
	done; \
 | 
			
		||||
	list='$(SOURCES) $(HEADERS)'; \
 | 
			
		||||
	unique=`for i in $$list; do echo $$i; done | \
 | 
			
		||||
	  awk '    { files[$$0] = 1; } \
 | 
			
		||||
	       END { for (i in files) print i; }'`; \
 | 
			
		||||
	test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
 | 
			
		||||
	  || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags  $$unique $(LISP) -o $$here/TAGS)
 | 
			
		||||
 | 
			
		||||
mostlyclean-tags:
 | 
			
		||||
 | 
			
		||||
clean-tags:
 | 
			
		||||
 | 
			
		||||
distclean-tags:
 | 
			
		||||
	-rm -f TAGS ID
 | 
			
		||||
 | 
			
		||||
maintainer-clean-tags:
 | 
			
		||||
 | 
			
		||||
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
 | 
			
		||||
 | 
			
		||||
subdir = proxychains/docs
 | 
			
		||||
 | 
			
		||||
distdir: $(DISTFILES)
 | 
			
		||||
	here=`cd $(top_builddir) && pwd`; \
 | 
			
		||||
	top_distdir=`cd $(top_distdir) && pwd`; \
 | 
			
		||||
	distdir=`cd $(distdir) && pwd`; \
 | 
			
		||||
	cd $(top_srcdir) \
 | 
			
		||||
	  && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu proxychains/docs/Makefile
 | 
			
		||||
	@for file in $(DISTFILES); do \
 | 
			
		||||
	  d=$(srcdir); \
 | 
			
		||||
	  if test -d $$d/$$file; then \
 | 
			
		||||
	    cp -pr $$d/$$file $(distdir)/$$file; \
 | 
			
		||||
	  else \
 | 
			
		||||
	    test -f $(distdir)/$$file \
 | 
			
		||||
	    || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
 | 
			
		||||
	    || cp -p $$d/$$file $(distdir)/$$file || :; \
 | 
			
		||||
	  fi; \
 | 
			
		||||
	done
 | 
			
		||||
	for subdir in $(SUBDIRS); do \
 | 
			
		||||
	  if test "$$subdir" = .; then :; else \
 | 
			
		||||
	    test -d $(distdir)/$$subdir \
 | 
			
		||||
	    || mkdir $(distdir)/$$subdir \
 | 
			
		||||
	    || exit 1; \
 | 
			
		||||
	    chmod 777 $(distdir)/$$subdir; \
 | 
			
		||||
	    (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir=../$(top_distdir) distdir=../$(distdir)/$$subdir distdir) \
 | 
			
		||||
	      || exit 1; \
 | 
			
		||||
	  fi; \
 | 
			
		||||
	done
 | 
			
		||||
info-am:
 | 
			
		||||
info: info-recursive
 | 
			
		||||
dvi-am:
 | 
			
		||||
dvi: dvi-recursive
 | 
			
		||||
check-am: all-am
 | 
			
		||||
check: check-recursive
 | 
			
		||||
installcheck-am:
 | 
			
		||||
installcheck: installcheck-recursive
 | 
			
		||||
install-exec-am:
 | 
			
		||||
install-exec: install-exec-recursive
 | 
			
		||||
 | 
			
		||||
install-data-am:
 | 
			
		||||
install-data: install-data-recursive
 | 
			
		||||
 | 
			
		||||
install-am: all-am
 | 
			
		||||
	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
 | 
			
		||||
install: install-recursive
 | 
			
		||||
uninstall-am:
 | 
			
		||||
uninstall: uninstall-recursive
 | 
			
		||||
all-am: Makefile
 | 
			
		||||
all-redirect: all-recursive
 | 
			
		||||
install-strip:
 | 
			
		||||
	$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
 | 
			
		||||
installdirs: installdirs-recursive
 | 
			
		||||
installdirs-am:
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
mostlyclean-generic:
 | 
			
		||||
 | 
			
		||||
clean-generic:
 | 
			
		||||
 | 
			
		||||
distclean-generic:
 | 
			
		||||
	-rm -f Makefile $(CONFIG_CLEAN_FILES)
 | 
			
		||||
	-rm -f config.cache config.log stamp-h stamp-h[0-9]*
 | 
			
		||||
 | 
			
		||||
maintainer-clean-generic:
 | 
			
		||||
mostlyclean-am:  mostlyclean-tags mostlyclean-generic
 | 
			
		||||
 | 
			
		||||
mostlyclean: mostlyclean-recursive
 | 
			
		||||
 | 
			
		||||
clean-am:  clean-tags clean-generic mostlyclean-am
 | 
			
		||||
 | 
			
		||||
clean: clean-recursive
 | 
			
		||||
 | 
			
		||||
distclean-am:  distclean-tags distclean-generic clean-am
 | 
			
		||||
	-rm -f libtool
 | 
			
		||||
 | 
			
		||||
distclean: distclean-recursive
 | 
			
		||||
 | 
			
		||||
maintainer-clean-am:  maintainer-clean-tags maintainer-clean-generic \
 | 
			
		||||
		distclean-am
 | 
			
		||||
	@echo "This command is intended for maintainers to use;"
 | 
			
		||||
	@echo "it deletes files that may require special tools to rebuild."
 | 
			
		||||
 | 
			
		||||
maintainer-clean: maintainer-clean-recursive
 | 
			
		||||
 | 
			
		||||
.PHONY: install-data-recursive uninstall-data-recursive \
 | 
			
		||||
install-exec-recursive uninstall-exec-recursive installdirs-recursive \
 | 
			
		||||
uninstalldirs-recursive all-recursive check-recursive \
 | 
			
		||||
installcheck-recursive info-recursive dvi-recursive \
 | 
			
		||||
mostlyclean-recursive distclean-recursive clean-recursive \
 | 
			
		||||
maintainer-clean-recursive tags tags-recursive mostlyclean-tags \
 | 
			
		||||
distclean-tags clean-tags maintainer-clean-tags distdir info-am info \
 | 
			
		||||
dvi-am dvi check check-am installcheck-am installcheck install-exec-am \
 | 
			
		||||
install-exec install-data-am install-data install-am install \
 | 
			
		||||
uninstall-am uninstall all-redirect all-am all installdirs-am \
 | 
			
		||||
installdirs mostlyclean-generic distclean-generic clean-generic \
 | 
			
		||||
maintainer-clean-generic clean mostlyclean distclean maintainer-clean
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
####### kdevelop will overwrite this part!!! (end)############
 | 
			
		||||
 | 
			
		||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
 | 
			
		||||
# Otherwise a system limit (for SysV at least) may be exceeded.
 | 
			
		||||
.NOEXPORT:
 | 
			
		||||
							
								
								
									
										4
									
								
								src/docs/en/Makefile.am
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								src/docs/en/Makefile.am
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,4 @@
 | 
			
		||||
####### kdevelop will overwrite this part!!! (begin)##########
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
####### kdevelop will overwrite this part!!! (end)############
 | 
			
		||||
							
								
								
									
										202
									
								
								src/docs/en/Makefile.in
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										202
									
								
								src/docs/en/Makefile.in
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,202 @@
 | 
			
		||||
# Makefile.in generated automatically by automake 1.4-p6 from Makefile.am
 | 
			
		||||
 | 
			
		||||
# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
 | 
			
		||||
# This Makefile.in is free software; the Free Software Foundation
 | 
			
		||||
# gives unlimited permission to copy and/or distribute it,
 | 
			
		||||
# with or without modifications, as long as this notice is preserved.
 | 
			
		||||
 | 
			
		||||
# This program is distributed in the hope that it will be useful,
 | 
			
		||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
 | 
			
		||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 | 
			
		||||
# PARTICULAR PURPOSE.
 | 
			
		||||
 | 
			
		||||
####### kdevelop will overwrite this part!!! (begin)##########
 | 
			
		||||
 | 
			
		||||
####### kdevelop will overwrite this part!!! (end)############
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
SHELL = @SHELL@
 | 
			
		||||
 | 
			
		||||
srcdir = @srcdir@
 | 
			
		||||
top_srcdir = @top_srcdir@
 | 
			
		||||
VPATH = @srcdir@
 | 
			
		||||
prefix = @prefix@
 | 
			
		||||
exec_prefix = @exec_prefix@
 | 
			
		||||
 | 
			
		||||
bindir = @bindir@
 | 
			
		||||
sbindir = @sbindir@
 | 
			
		||||
libexecdir = @libexecdir@
 | 
			
		||||
datadir = @datadir@
 | 
			
		||||
sysconfdir = @sysconfdir@
 | 
			
		||||
sharedstatedir = @sharedstatedir@
 | 
			
		||||
localstatedir = @localstatedir@
 | 
			
		||||
libdir = @libdir@
 | 
			
		||||
infodir = @infodir@
 | 
			
		||||
mandir = @mandir@
 | 
			
		||||
includedir = @includedir@
 | 
			
		||||
oldincludedir = /usr/include
 | 
			
		||||
 | 
			
		||||
DESTDIR =
 | 
			
		||||
 | 
			
		||||
pkgdatadir = $(datadir)/@PACKAGE@
 | 
			
		||||
pkglibdir = $(libdir)/@PACKAGE@
 | 
			
		||||
pkgincludedir = $(includedir)/@PACKAGE@
 | 
			
		||||
 | 
			
		||||
top_builddir = ../../..
 | 
			
		||||
 | 
			
		||||
ACLOCAL = @ACLOCAL@
 | 
			
		||||
AUTOCONF = @AUTOCONF@
 | 
			
		||||
AUTOMAKE = @AUTOMAKE@
 | 
			
		||||
AUTOHEADER = @AUTOHEADER@
 | 
			
		||||
 | 
			
		||||
INSTALL = @INSTALL@
 | 
			
		||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
 | 
			
		||||
INSTALL_DATA = @INSTALL_DATA@
 | 
			
		||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
 | 
			
		||||
transform = @program_transform_name@
 | 
			
		||||
 | 
			
		||||
NORMAL_INSTALL = :
 | 
			
		||||
PRE_INSTALL = :
 | 
			
		||||
POST_INSTALL = :
 | 
			
		||||
NORMAL_UNINSTALL = :
 | 
			
		||||
PRE_UNINSTALL = :
 | 
			
		||||
POST_UNINSTALL = :
 | 
			
		||||
build_alias = @build_alias@
 | 
			
		||||
build_triplet = @build@
 | 
			
		||||
host_alias = @host_alias@
 | 
			
		||||
host_triplet = @host@
 | 
			
		||||
target_alias = @target_alias@
 | 
			
		||||
target_triplet = @target@
 | 
			
		||||
AR = @AR@
 | 
			
		||||
AS = @AS@
 | 
			
		||||
CC = @CC@
 | 
			
		||||
CXX = @CXX@
 | 
			
		||||
CXXCPP = @CXXCPP@
 | 
			
		||||
DLLTOOL = @DLLTOOL@
 | 
			
		||||
ECHO = @ECHO@
 | 
			
		||||
EGREP = @EGREP@
 | 
			
		||||
EXEEXT = @EXEEXT@
 | 
			
		||||
F77 = @F77@
 | 
			
		||||
GCJ = @GCJ@
 | 
			
		||||
GCJFLAGS = @GCJFLAGS@
 | 
			
		||||
HAVE_LIB = @HAVE_LIB@
 | 
			
		||||
LIB = @LIB@
 | 
			
		||||
LIBTOOL = @LIBTOOL@
 | 
			
		||||
LN_S = @LN_S@
 | 
			
		||||
LTLIB = @LTLIB@
 | 
			
		||||
MAKEINFO = @MAKEINFO@
 | 
			
		||||
OBJDUMP = @OBJDUMP@
 | 
			
		||||
OBJEXT = @OBJEXT@
 | 
			
		||||
PACKAGE = @PACKAGE@
 | 
			
		||||
RANLIB = @RANLIB@
 | 
			
		||||
RC = @RC@
 | 
			
		||||
STRIP = @STRIP@
 | 
			
		||||
VERSION = @VERSION@
 | 
			
		||||
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
 | 
			
		||||
CONFIG_HEADER = ../../../config.h
 | 
			
		||||
CONFIG_CLEAN_FILES = 
 | 
			
		||||
DIST_COMMON =  Makefile.am Makefile.in
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
 | 
			
		||||
 | 
			
		||||
TAR = tar
 | 
			
		||||
GZIP_ENV = --best
 | 
			
		||||
all: all-redirect
 | 
			
		||||
.SUFFIXES:
 | 
			
		||||
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) 
 | 
			
		||||
	cd $(top_srcdir) && $(AUTOMAKE) --gnu proxychains/docs/en/Makefile
 | 
			
		||||
 | 
			
		||||
Makefile: $(srcdir)/Makefile.in  $(top_builddir)/config.status $(BUILT_SOURCES)
 | 
			
		||||
	cd $(top_builddir) \
 | 
			
		||||
	  && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
 | 
			
		||||
 | 
			
		||||
tags: TAGS
 | 
			
		||||
TAGS:
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
 | 
			
		||||
 | 
			
		||||
subdir = proxychains/docs/en
 | 
			
		||||
 | 
			
		||||
distdir: $(DISTFILES)
 | 
			
		||||
	here=`cd $(top_builddir) && pwd`; \
 | 
			
		||||
	top_distdir=`cd $(top_distdir) && pwd`; \
 | 
			
		||||
	distdir=`cd $(distdir) && pwd`; \
 | 
			
		||||
	cd $(top_srcdir) \
 | 
			
		||||
	  && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu proxychains/docs/en/Makefile
 | 
			
		||||
	@for file in $(DISTFILES); do \
 | 
			
		||||
	  d=$(srcdir); \
 | 
			
		||||
	  if test -d $$d/$$file; then \
 | 
			
		||||
	    cp -pr $$d/$$file $(distdir)/$$file; \
 | 
			
		||||
	  else \
 | 
			
		||||
	    test -f $(distdir)/$$file \
 | 
			
		||||
	    || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
 | 
			
		||||
	    || cp -p $$d/$$file $(distdir)/$$file || :; \
 | 
			
		||||
	  fi; \
 | 
			
		||||
	done
 | 
			
		||||
info-am:
 | 
			
		||||
info: info-am
 | 
			
		||||
dvi-am:
 | 
			
		||||
dvi: dvi-am
 | 
			
		||||
check-am: all-am
 | 
			
		||||
check: check-am
 | 
			
		||||
installcheck-am:
 | 
			
		||||
installcheck: installcheck-am
 | 
			
		||||
install-exec-am:
 | 
			
		||||
install-exec: install-exec-am
 | 
			
		||||
 | 
			
		||||
install-data-am:
 | 
			
		||||
install-data: install-data-am
 | 
			
		||||
 | 
			
		||||
install-am: all-am
 | 
			
		||||
	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
 | 
			
		||||
install: install-am
 | 
			
		||||
uninstall-am:
 | 
			
		||||
uninstall: uninstall-am
 | 
			
		||||
all-am: Makefile
 | 
			
		||||
all-redirect: all-am
 | 
			
		||||
install-strip:
 | 
			
		||||
	$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
 | 
			
		||||
installdirs:
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
mostlyclean-generic:
 | 
			
		||||
 | 
			
		||||
clean-generic:
 | 
			
		||||
 | 
			
		||||
distclean-generic:
 | 
			
		||||
	-rm -f Makefile $(CONFIG_CLEAN_FILES)
 | 
			
		||||
	-rm -f config.cache config.log stamp-h stamp-h[0-9]*
 | 
			
		||||
 | 
			
		||||
maintainer-clean-generic:
 | 
			
		||||
mostlyclean-am:  mostlyclean-generic
 | 
			
		||||
 | 
			
		||||
mostlyclean: mostlyclean-am
 | 
			
		||||
 | 
			
		||||
clean-am:  clean-generic mostlyclean-am
 | 
			
		||||
 | 
			
		||||
clean: clean-am
 | 
			
		||||
 | 
			
		||||
distclean-am:  distclean-generic clean-am
 | 
			
		||||
	-rm -f libtool
 | 
			
		||||
 | 
			
		||||
distclean: distclean-am
 | 
			
		||||
 | 
			
		||||
maintainer-clean-am:  maintainer-clean-generic distclean-am
 | 
			
		||||
	@echo "This command is intended for maintainers to use;"
 | 
			
		||||
	@echo "it deletes files that may require special tools to rebuild."
 | 
			
		||||
 | 
			
		||||
maintainer-clean: maintainer-clean-am
 | 
			
		||||
 | 
			
		||||
.PHONY: tags distdir info-am info dvi-am dvi check check-am \
 | 
			
		||||
installcheck-am installcheck install-exec-am install-exec \
 | 
			
		||||
install-data-am install-data install-am install uninstall-am uninstall \
 | 
			
		||||
all-redirect all-am all installdirs mostlyclean-generic \
 | 
			
		||||
distclean-generic clean-generic maintainer-clean-generic clean \
 | 
			
		||||
mostlyclean distclean maintainer-clean
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
 | 
			
		||||
# Otherwise a system limit (for SysV at least) may be exceeded.
 | 
			
		||||
.NOEXPORT:
 | 
			
		||||
							
								
								
									
										408
									
								
								src/libproxychains.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										408
									
								
								src/libproxychains.c
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,408 @@
 | 
			
		||||
/***************************************************************************
 | 
			
		||||
                          libproxychains.c  -  description
 | 
			
		||||
                             -------------------
 | 
			
		||||
    begin                : Tue May 14 2002
 | 
			
		||||
    copyright          :  netcreature (C) 2002
 | 
			
		||||
    email                 : netcreature@users.sourceforge.net
 | 
			
		||||
 ***************************************************************************/
 | 
			
		||||
 /*     GPL */
 | 
			
		||||
/***************************************************************************
 | 
			
		||||
 *                                                                         *
 | 
			
		||||
 *   This program is free software; you can redistribute it and/or modify  *
 | 
			
		||||
 *   it under the terms of the GNU General Public License as published by  *
 | 
			
		||||
 *   the Free Software Foundation; either version 2 of the License, or     *
 | 
			
		||||
 *   (at your option) any later version.                                   *
 | 
			
		||||
 *                                                                         *
 | 
			
		||||
 ***************************************************************************/
 | 
			
		||||
#define _GNU_SOURCE
 | 
			
		||||
#ifdef HAVE_CONFIG_H
 | 
			
		||||
#include <config.h>
 | 
			
		||||
#endif
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <unistd.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
#include <netdb.h>
 | 
			
		||||
 | 
			
		||||
#include <netinet/in.h>
 | 
			
		||||
#include <arpa/inet.h>
 | 
			
		||||
#include <sys/types.h>
 | 
			
		||||
#include <sys/socket.h>
 | 
			
		||||
#include <fcntl.h>
 | 
			
		||||
#include <dlfcn.h>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#include "core.h"
 | 
			
		||||
 | 
			
		||||
#define     satosin(x)      ((struct sockaddr_in *) &(x))
 | 
			
		||||
#define     SOCKADDR(x)     (satosin(x)->sin_addr.s_addr)
 | 
			
		||||
#define     SOCKADDR_2(x)     (satosin(x)->sin_addr)
 | 
			
		||||
#define     SOCKPORT(x)     (satosin(x)->sin_port)
 | 
			
		||||
#define     SOCKFAMILY(x)     (satosin(x)->sin_family)
 | 
			
		||||
#define     MAX_CHAIN 30*1024
 | 
			
		||||
 | 
			
		||||
int tcp_read_time_out;
 | 
			
		||||
int tcp_connect_time_out;
 | 
			
		||||
chain_type proxychains_ct;
 | 
			
		||||
proxy_data proxychains_pd[MAX_CHAIN];
 | 
			
		||||
int proxychains_proxy_count = 0;
 | 
			
		||||
int proxychains_got_chain_data = 0;
 | 
			
		||||
int proxychains_max_chain = 1;
 | 
			
		||||
int proxychains_quiet_mode = 0;
 | 
			
		||||
int proxychains_resolver = 0;
 | 
			
		||||
static int init_l = 0;
 | 
			
		||||
localaddr_arg localnet_addr[MAX_LOCALNET];
 | 
			
		||||
size_t num_localnet_addr = 0;
 | 
			
		||||
 | 
			
		||||
static inline void get_chain_data(proxy_data *pd, unsigned int *proxy_count,
 | 
			
		||||
	chain_type *ct);
 | 
			
		||||
static void init_lib(void);
 | 
			
		||||
 | 
			
		||||
static void init_lib(void)
 | 
			
		||||
{
 | 
			
		||||
//	proxychains_write_log("ProxyChains-"VERSION
 | 
			
		||||
//			" (http://proxychains.sf.net)\n");
 | 
			
		||||
	
 | 
			
		||||
	get_chain_data(proxychains_pd,&proxychains_proxy_count,&proxychains_ct);
 | 
			
		||||
	true_connect = (connect_t) dlsym(RTLD_NEXT, "connect");
 | 
			
		||||
 | 
			
		||||
	if (!true_connect) {
 | 
			
		||||
		fprintf(stderr, "Cannot load symbol 'connect' %s\n", dlerror());
 | 
			
		||||
		exit(1);
 | 
			
		||||
	} else {
 | 
			
		||||
//		PDEBUG( "loaded symbol 'connect'"
 | 
			
		||||
//		" real addr %p  wrapped addr %p\n",
 | 
			
		||||
//		true_connect, connect);
 | 
			
		||||
	}
 | 
			
		||||
	true_gethostbyname = (gethostbyname_t) 
 | 
			
		||||
		dlsym(RTLD_NEXT, "gethostbyname");
 | 
			
		||||
 | 
			
		||||
	if (!true_gethostbyname) {
 | 
			
		||||
		fprintf(stderr, "Cannot load symbol 'gethostbyname' %s\n", 
 | 
			
		||||
				dlerror());
 | 
			
		||||
		exit(1);
 | 
			
		||||
	} else {
 | 
			
		||||
//		PDEBUG( "loaded symbol 'gethostbyname'"
 | 
			
		||||
//		" real addr %p  wrapped addr %p\n",
 | 
			
		||||
//		true_gethostbyname, gethostbyname);
 | 
			
		||||
	}
 | 
			
		||||
	true_getaddrinfo = (getaddrinfo_t) 
 | 
			
		||||
		dlsym(RTLD_NEXT, "getaddrinfo");
 | 
			
		||||
 | 
			
		||||
	if (!true_getaddrinfo) {
 | 
			
		||||
		fprintf(stderr, "Cannot load symbol 'getaddrinfo' %s\n", 
 | 
			
		||||
				dlerror());
 | 
			
		||||
		exit(1);
 | 
			
		||||
	} else {
 | 
			
		||||
//		PDEBUG( "loaded symbol 'getaddrinfo'"
 | 
			
		||||
//			" real addr %p  wrapped addr %p\n",
 | 
			
		||||
//			true_getaddrinfo, getaddrinfo);
 | 
			
		||||
	}
 | 
			
		||||
	true_freeaddrinfo = (freeaddrinfo_t) 
 | 
			
		||||
		dlsym(RTLD_NEXT, "freeaddrinfo");
 | 
			
		||||
 | 
			
		||||
	if (!true_freeaddrinfo) {
 | 
			
		||||
		fprintf(stderr, "Cannot load symbol 'freeaddrinfo' %s\n", 
 | 
			
		||||
				dlerror());
 | 
			
		||||
		exit(1);
 | 
			
		||||
	} else {
 | 
			
		||||
//		PDEBUG( "loaded symbol 'freeaddrinfo'"
 | 
			
		||||
//			" real addr %p  wrapped addr %p\n",
 | 
			
		||||
//			true_freeaddrinfo, freeaddrinfo);
 | 
			
		||||
	}
 | 
			
		||||
	true_gethostbyaddr = (gethostbyaddr_t) 
 | 
			
		||||
		dlsym(RTLD_NEXT, "gethostbyaddr");
 | 
			
		||||
 | 
			
		||||
	if (!true_gethostbyaddr) {
 | 
			
		||||
		fprintf(stderr, "Cannot load symbol 'gethostbyaddr' %s\n", 
 | 
			
		||||
				dlerror());
 | 
			
		||||
		exit(1);
 | 
			
		||||
	} else {
 | 
			
		||||
//		PDEBUG( "loaded symbol 'gethostbyaddr'"
 | 
			
		||||
//			" real addr %p  wrapped addr %p\n",
 | 
			
		||||
//			true_gethostbyaddr, gethostbyaddr);
 | 
			
		||||
	}
 | 
			
		||||
	true_getnameinfo = (getnameinfo_t) 
 | 
			
		||||
		dlsym(RTLD_NEXT, "getnameinfo");
 | 
			
		||||
 | 
			
		||||
	if (!true_getnameinfo) {
 | 
			
		||||
		fprintf(stderr, "Cannot load symbol 'getnameinfo' %s\n", 
 | 
			
		||||
				dlerror());
 | 
			
		||||
		exit(1);
 | 
			
		||||
	} else {
 | 
			
		||||
//		PDEBUG( "loaded symbol 'getnameinfo'"
 | 
			
		||||
//			" real addr %p  wrapped addr %p\n",
 | 
			
		||||
//			true_getnameinfo, getnameinfo);
 | 
			
		||||
	}
 | 
			
		||||
	init_l = 1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * XXX. Same thing is defined in proxychains main.c it
 | 
			
		||||
 * needs to be changed, too.
 | 
			
		||||
 */
 | 
			
		||||
#define PROXYCHAINS_CONF_FILE "PROXYCHAINS_CONF_FILE"
 | 
			
		||||
 | 
			
		||||
static inline void get_chain_data(
 | 
			
		||||
			proxy_data *pd,
 | 
			
		||||
			unsigned int *proxy_count,
 | 
			
		||||
			chain_type *ct)
 | 
			
		||||
{
 | 
			
		||||
	int count=0,port_n=0,list=0;
 | 
			
		||||
	char buff[1024],type[1024],host[1024],user[1024];
 | 
			
		||||
	char *env;
 | 
			
		||||
	char local_in_addr_port[32];
 | 
			
		||||
	char local_in_addr[32], local_in_port[32], local_netmask[32];
 | 
			
		||||
	FILE* file;
 | 
			
		||||
 | 
			
		||||
	if(proxychains_got_chain_data)
 | 
			
		||||
	return;
 | 
			
		||||
 | 
			
		||||
	//Some defaults
 | 
			
		||||
	tcp_read_time_out=4*1000;
 | 
			
		||||
	tcp_connect_time_out=10*1000;
 | 
			
		||||
	*ct=DYNAMIC_TYPE;
 | 
			
		||||
 | 
			
		||||
	env = NULL;
 | 
			
		||||
 | 
			
		||||
	/*
 | 
			
		||||
	 * Get path to configuration file from env this file has priority
 | 
			
		||||
	 * if it's defined.
 | 
			
		||||
	 */
 | 
			
		||||
	env = getenv(PROXYCHAINS_CONF_FILE);
 | 
			
		||||
 | 
			
		||||
	snprintf(buff,256,"%s/.proxychains/proxychains.conf",getenv("HOME"));
 | 
			
		||||
 | 
			
		||||
	if(!(file=fopen(env,"r")))
 | 
			
		||||
	if(!(file=fopen("./proxychains.conf","r")))
 | 
			
		||||
	if(!(file=fopen(buff,"r")))
 | 
			
		||||
	if(!(file=fopen("/etc/proxychains.conf","r")))
 | 
			
		||||
	{
 | 
			
		||||
		perror("Can't locate proxychains.conf");
 | 
			
		||||
		exit(1);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	while(fgets(buff,sizeof(buff),file)) {
 | 
			
		||||
		if(buff[strspn(buff," ")]!='#') {
 | 
			
		||||
			if(list) {
 | 
			
		||||
				memset(&pd[count], 0, sizeof(proxy_data));
 | 
			
		||||
				pd[count].ps=PLAY_STATE;
 | 
			
		||||
				port_n=0;
 | 
			
		||||
				sscanf(buff,"%s %s %d %s %s", type,host,&port_n,
 | 
			
		||||
					pd[count].user,pd[count].pass);
 | 
			
		||||
				pd[count].ip=inet_addr(host);
 | 
			
		||||
				pd[count].port=htons((unsigned short)port_n);
 | 
			
		||||
				if(!strcmp(type,"http")) {
 | 
			
		||||
					pd[count].pt=HTTP_TYPE;
 | 
			
		||||
				}else if(!strcmp(type,"socks4")) {
 | 
			
		||||
					pd[count].pt=SOCKS4_TYPE;
 | 
			
		||||
				}else if(!strcmp(type,"socks5")) {
 | 
			
		||||
					pd[count].pt=SOCKS5_TYPE;
 | 
			
		||||
				}else continue;
 | 
			
		||||
				
 | 
			
		||||
				if( pd[count].ip && pd[count].ip!=-1 && port_n)
 | 
			
		||||
					if(++count==MAX_CHAIN)
 | 
			
		||||
						break;
 | 
			
		||||
			 } else {
 | 
			
		||||
				if(strstr(buff,"[ProxyList]")) {
 | 
			
		||||
					list=1;
 | 
			
		||||
				} else if(strstr(buff,"random_chain")) {
 | 
			
		||||
					*ct=RANDOM_TYPE;
 | 
			
		||||
				} else if(strstr(buff,"strict_chain")) {
 | 
			
		||||
					*ct=STRICT_TYPE;
 | 
			
		||||
				} else if(strstr(buff,"dynamic_chain")) {
 | 
			
		||||
					*ct=DYNAMIC_TYPE;
 | 
			
		||||
				}else if(strstr(buff,"tcp_read_time_out")){
 | 
			
		||||
					sscanf(buff,"%s %d",user,&tcp_read_time_out) ;
 | 
			
		||||
				}else if(strstr(buff,"tcp_connect_time_out")){
 | 
			
		||||
					sscanf(buff,"%s %d",user,&tcp_connect_time_out) ;
 | 
			
		||||
				}
 | 
			
		||||
				else if(strstr(buff,"localnet"))
 | 
			
		||||
				{
 | 
			
		||||
					if (sscanf(buff,"%s %21[^/]/%15s", user,
 | 
			
		||||
						local_in_addr_port, local_netmask) < 3) {
 | 
			
		||||
						fprintf(stderr, "localnet format error");
 | 
			
		||||
						exit(1);
 | 
			
		||||
					}
 | 
			
		||||
					/* clean previously used buffer */
 | 
			
		||||
					memset(local_in_port, 0,
 | 
			
		||||
						sizeof(local_in_port) / sizeof(local_in_port[0]));
 | 
			
		||||
 | 
			
		||||
					if (sscanf(local_in_addr_port, "%15[^:]:%5s",
 | 
			
		||||
						local_in_addr, local_in_port) < 2) {
 | 
			
		||||
					    PDEBUG("added localnet: netaddr=%s, port=%s\n",
 | 
			
		||||
							local_in_addr, local_netmask);
 | 
			
		||||
					} else {
 | 
			
		||||
					    PDEBUG("added localnet: netaddr=%s, port=%s, netmask=%s\n",
 | 
			
		||||
							local_in_addr, local_in_port, local_netmask);
 | 
			
		||||
					}
 | 
			
		||||
					if (num_localnet_addr < MAX_LOCALNET)
 | 
			
		||||
					{
 | 
			
		||||
						int error;
 | 
			
		||||
						error = inet_pton(AF_INET, local_in_addr, &localnet_addr[num_localnet_addr].in_addr);
 | 
			
		||||
						if (error <= 0)
 | 
			
		||||
						{
 | 
			
		||||
							fprintf(stderr, "localnet address error\n");
 | 
			
		||||
							exit(1);
 | 
			
		||||
						}
 | 
			
		||||
						error = inet_pton(AF_INET, local_netmask, &localnet_addr[num_localnet_addr].netmask);
 | 
			
		||||
						if (error <= 0)
 | 
			
		||||
						{
 | 
			
		||||
							fprintf(stderr, "localnet netmask error\n");
 | 
			
		||||
							exit(1);
 | 
			
		||||
						}
 | 
			
		||||
						if (local_in_port[0]) {
 | 
			
		||||
							localnet_addr[num_localnet_addr].port = (short)atoi(local_in_port);
 | 
			
		||||
						} else {
 | 
			
		||||
							localnet_addr[num_localnet_addr].port = 0;
 | 
			
		||||
						}
 | 
			
		||||
						++num_localnet_addr;
 | 
			
		||||
					}
 | 
			
		||||
					else
 | 
			
		||||
					{
 | 
			
		||||
						fprintf(stderr, "# of localnet exceed %d.\n", MAX_LOCALNET);
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
				else if(strstr(buff,"chain_len")){
 | 
			
		||||
					char *pc;int len;
 | 
			
		||||
					pc=strchr(buff,'=');
 | 
			
		||||
					len=atoi(++pc);
 | 
			
		||||
					proxychains_max_chain=(len?len:1);
 | 
			
		||||
				}else if(strstr(buff,"quiet_mode")){
 | 
			
		||||
					proxychains_quiet_mode=1;
 | 
			
		||||
				}else if(strstr(buff,"proxy_dns")){
 | 
			
		||||
					proxychains_resolver=1;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	fclose(file);
 | 
			
		||||
	*proxy_count=count;
 | 
			
		||||
	proxychains_got_chain_data=1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
int connect (int sock, const struct sockaddr *addr, unsigned int len)
 | 
			
		||||
{
 | 
			
		||||
	int socktype=0,optlen=0,flags=0,ret=0;
 | 
			
		||||
	char str[256];
 | 
			
		||||
	struct in_addr *p_addr_in;
 | 
			
		||||
	unsigned short port;
 | 
			
		||||
	size_t i;
 | 
			
		||||
 | 
			
		||||
	if(!init_l)
 | 
			
		||||
		init_lib();
 | 
			
		||||
	optlen=sizeof(socktype);
 | 
			
		||||
	getsockopt(sock,SOL_SOCKET,SO_TYPE,&socktype,&optlen);
 | 
			
		||||
	if (! (SOCKFAMILY(*addr)==AF_INET  && socktype==SOCK_STREAM))
 | 
			
		||||
		return true_connect(sock,addr,len);
 | 
			
		||||
 | 
			
		||||
	p_addr_in = &((struct sockaddr_in *)addr)->sin_addr;
 | 
			
		||||
	port = ntohs(((struct sockaddr_in *)addr)->sin_port);
 | 
			
		||||
 | 
			
		||||
	//PDEBUG("localnet: %s; ", inet_ntop(AF_INET,&in_addr_localnet, str, sizeof(str)));
 | 
			
		||||
	//PDEBUG("netmask: %s; " , inet_ntop(AF_INET, &in_addr_netmask, str, sizeof(str)));
 | 
			
		||||
	//PDEBUG("target: %s\n", inet_ntop(AF_INET, p_addr_in, str, sizeof(str)));
 | 
			
		||||
	//PDEBUG("port: %d\n", port);
 | 
			
		||||
	for (i = 0; i < num_localnet_addr; i++) {
 | 
			
		||||
		if ((localnet_addr[i].in_addr.s_addr & localnet_addr[i].netmask.s_addr)
 | 
			
		||||
			== (p_addr_in->s_addr & localnet_addr[i].netmask.s_addr))
 | 
			
		||||
		{
 | 
			
		||||
			if (localnet_addr[i].port && localnet_addr[i].port == port) {
 | 
			
		||||
				PDEBUG("accessing localnet using true_connect\n");
 | 
			
		||||
				return true_connect(sock,addr,len);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	flags=fcntl(sock, F_GETFL, 0);
 | 
			
		||||
	if(flags & O_NONBLOCK)
 | 
			
		||||
	fcntl(sock, F_SETFL, !O_NONBLOCK);
 | 
			
		||||
	ret=connect_proxy_chain(
 | 
			
		||||
		sock,
 | 
			
		||||
		SOCKADDR(*addr),
 | 
			
		||||
		SOCKPORT(*addr),
 | 
			
		||||
		proxychains_pd,
 | 
			
		||||
		proxychains_proxy_count,
 | 
			
		||||
		proxychains_ct,
 | 
			
		||||
		  proxychains_max_chain );
 | 
			
		||||
	fcntl(sock, F_SETFL, flags);
 | 
			
		||||
	if(ret!=SUCCESS)
 | 
			
		||||
	errno=ECONNREFUSED;
 | 
			
		||||
	return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
struct hostent *gethostbyname(const char *name)
 | 
			
		||||
{
 | 
			
		||||
	PDEBUG("gethostbyname: %s\n",name);
 | 
			
		||||
	if(!init_l)
 | 
			
		||||
		init_lib();
 | 
			
		||||
	if(proxychains_resolver)
 | 
			
		||||
		return proxy_gethostbyname(name);
 | 
			
		||||
	else
 | 
			
		||||
		return true_gethostbyname(name);
 | 
			
		||||
			
 | 
			
		||||
	return NULL;
 | 
			
		||||
}
 | 
			
		||||
int getaddrinfo(const char *node, const char *service,
 | 
			
		||||
		const struct addrinfo *hints,
 | 
			
		||||
		struct addrinfo **res)
 | 
			
		||||
{
 | 
			
		||||
	int ret = 0;
 | 
			
		||||
	PDEBUG("getaddrinfo: %s %s\n",node ,service);
 | 
			
		||||
	if(!init_l)
 | 
			
		||||
		init_lib();
 | 
			
		||||
	if(proxychains_resolver)
 | 
			
		||||
		ret = proxy_getaddrinfo(node, service, hints, res);
 | 
			
		||||
	else
 | 
			
		||||
		ret = true_getaddrinfo(node, service, hints, res);
 | 
			
		||||
			
 | 
			
		||||
	return ret;
 | 
			
		||||
}
 | 
			
		||||
void freeaddrinfo(struct addrinfo *res)
 | 
			
		||||
{
 | 
			
		||||
	PDEBUG("freeaddrinfo %p \n",res);
 | 
			
		||||
	if(!init_l)
 | 
			
		||||
		init_lib();
 | 
			
		||||
	if(!proxychains_resolver)
 | 
			
		||||
		true_freeaddrinfo(res);
 | 
			
		||||
	else {
 | 
			
		||||
		free(res->ai_addr);
 | 
			
		||||
		free(res);
 | 
			
		||||
	}
 | 
			
		||||
	return;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int getnameinfo (const struct sockaddr * sa,
 | 
			
		||||
			socklen_t salen, char * host,
 | 
			
		||||
			socklen_t hostlen, char * serv,
 | 
			
		||||
			socklen_t servlen, int flags)
 | 
			
		||||
{
 | 
			
		||||
	int ret = 0;
 | 
			
		||||
	if(!init_l)
 | 
			
		||||
		init_lib();
 | 
			
		||||
	if(!proxychains_resolver) {
 | 
			
		||||
		ret = true_getnameinfo(sa,salen,host,hostlen,
 | 
			
		||||
				serv,servlen,flags);
 | 
			
		||||
	} else {
 | 
			
		||||
		if(hostlen) 
 | 
			
		||||
			strncpy(host, inet_ntoa(SOCKADDR_2(*sa)),hostlen);
 | 
			
		||||
		if(servlen) 
 | 
			
		||||
			snprintf(serv, servlen,"%d",ntohs(SOCKPORT(*sa)));
 | 
			
		||||
	}
 | 
			
		||||
	PDEBUG("getnameinfo: %s %s\n", host, serv);
 | 
			
		||||
	return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
struct hostent *gethostbyaddr (const void *addr, socklen_t len, int type)
 | 
			
		||||
{
 | 
			
		||||
	PDEBUG("TODO: gethostbyaddr hook\n"); 
 | 
			
		||||
	if(!init_l)
 | 
			
		||||
		init_lib();
 | 
			
		||||
	if(!proxychains_resolver)
 | 
			
		||||
		return true_gethostbyaddr(addr,len,type);
 | 
			
		||||
	return NULL;
 | 
			
		||||
}
 | 
			
		||||
	
 | 
			
		||||
							
								
								
									
										85
									
								
								src/main.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										85
									
								
								src/main.c
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,85 @@
 | 
			
		||||
/***************************************************************************
 | 
			
		||||
                          main.c  -  description
 | 
			
		||||
   q							 -------------------
 | 
			
		||||
    begin                : Tue May 14 2002
 | 
			
		||||
    copyright          :  netcreature (C) 2002
 | 
			
		||||
    email                 : netcreature@users.sourceforge.net
 | 
			
		||||
 ***************************************************************************/
 | 
			
		||||
 /*     GPL */
 | 
			
		||||
/***************************************************************************
 | 
			
		||||
 *                                                                         *
 | 
			
		||||
 *   This program is free software; you can redistribute it and/or modify  *
 | 
			
		||||
 *   it under the terms of the GNU General Public License as published by  *
 | 
			
		||||
 *   the Free Software Foundation; either version 2 of the License, or     *
 | 
			
		||||
 *   (at your option) any later version.                                   *
 | 
			
		||||
 *                                                                         *
 | 
			
		||||
 ***************************************************************************/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
* 	 well ... actually this file could be a shell script ... but C rulez :).
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
#ifdef HAVE_CONFIG_H
 | 
			
		||||
#include <config.h>
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <unistd.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <memory.h>
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
#include <sys/types.h>
 | 
			
		||||
#include <sys/wait.h>
 | 
			
		||||
 | 
			
		||||
extern char *optarg;
 | 
			
		||||
extern int optind, opterr, optopt
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * XXX. Same thing is defined in proxychains main.c it
 | 
			
		||||
 * needs to be changed, too.
 | 
			
		||||
 */
 | 
			
		||||
#define PROXYCHAINS_CONF_FILE "PROXYCHAINS_CONF_FILE"
 | 
			
		||||
 | 
			
		||||
static usage(void)
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
		printf("\nUsage:	 %s [h] [f] config_file program_name [arguments]\n"
 | 
			
		||||
       	   "\t for example : proxychains telnet somehost.com\n"
 | 
			
		||||
										"More help in README file\n", argv[0], );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int main(int argc, char *argv[])
 | 
			
		||||
{
 | 
			
		||||
		char *path;
 | 
			
		||||
 | 
			
		||||
		path = NULL;
 | 
			
		||||
 | 
			
		||||
		while ((opt = getopt(argc, argv, "fh:")) != -1) {
 | 
			
		||||
				switch (opt) {
 | 
			
		||||
						case 'h':
 | 
			
		||||
								usage();
 | 
			
		||||
								break;
 | 
			
		||||
						case 'f':
 | 
			
		||||
								path = (char *)optarg;
 | 
			
		||||
								break;
 | 
			
		||||
						default: /* '?' */
 | 
			
		||||
								usage();
 | 
			
		||||
								exit(EXIT_FAILURE);
 | 
			
		||||
				}
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
		printf("Proxychains are going to use %s as config file.\n", path);
 | 
			
		||||
		printf("argv = %s\n", argv[1]);
 | 
			
		||||
 | 
			
		||||
		/* Set PROXYCHAINS_CONF_FILE to get proxychains lib to
 | 
			
		||||
			 use new config file. */
 | 
			
		||||
		setenv(PROXYCHAINS_CONF_FILE, path, 1);
 | 
			
		||||
 | 
			
		||||
		/*XXX. proxychains might be installed in some different location */
 | 
			
		||||
  putenv("LD_PRELOAD=/usr/lib/libproxychains.so");
 | 
			
		||||
  execvp(argv[1],&argv[1]);
 | 
			
		||||
  perror("proxychains can't load process....");
 | 
			
		||||
 | 
			
		||||
  return EXIT_SUCCESS;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										26
									
								
								src/proxychains
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										26
									
								
								src/proxychains
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,26 @@
 | 
			
		||||
#!/bin/sh
 | 
			
		||||
echo "ProxyChains-3.1 (http://proxychains.sf.net)"
 | 
			
		||||
 | 
			
		||||
usage() {
 | 
			
		||||
 | 
			
		||||
	echo "	usage:"
 | 
			
		||||
	echo "		$0 [h] [f config-file] <prog> [args]"
 | 
			
		||||
	exit
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
if [ $# = 0 ] ; then
 | 
			
		||||
	usage
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
if [ $1 = "-h" ]; then
 | 
			
		||||
	usage
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
if [ "$1" = "-f" ]; then
 | 
			
		||||
	export PROXYCHAINS_CONF_FILE=$2;
 | 
			
		||||
	shift;
 | 
			
		||||
	shift;
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
export LD_PRELOAD=libproxychains.so.3
 | 
			
		||||
exec "$@"
 | 
			
		||||
							
								
								
									
										75
									
								
								src/proxychains.conf
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										75
									
								
								src/proxychains.conf
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,75 @@
 | 
			
		||||
# proxychains.conf  VER 3.1
 | 
			
		||||
#
 | 
			
		||||
#        HTTP, SOCKS4, SOCKS5 tunneling proxifier with DNS.
 | 
			
		||||
#	
 | 
			
		||||
 | 
			
		||||
# The option below identifies how the ProxyList is treated.
 | 
			
		||||
# only one option should be uncommented at time,
 | 
			
		||||
# otherwise the last appearing option will be accepted
 | 
			
		||||
#
 | 
			
		||||
#dynamic_chain
 | 
			
		||||
#
 | 
			
		||||
# Dynamic - Each connection will be done via chained proxies
 | 
			
		||||
# all proxies chained in the order as they appear in the list
 | 
			
		||||
# at least one proxy must be online to play in chain
 | 
			
		||||
# (dead proxies are skipped)
 | 
			
		||||
# otherwise EINTR is returned to the app
 | 
			
		||||
#
 | 
			
		||||
strict_chain
 | 
			
		||||
#
 | 
			
		||||
# Strict - Each connection will be done via chained proxies
 | 
			
		||||
# all proxies chained in the order as they appear in the list
 | 
			
		||||
# all proxies must be online to play in chain
 | 
			
		||||
# otherwise EINTR is returned to the app
 | 
			
		||||
#
 | 
			
		||||
#random_chain
 | 
			
		||||
#
 | 
			
		||||
# Random - Each connection will be done via random proxy
 | 
			
		||||
# (or proxy chain, see  chain_len) from the list.
 | 
			
		||||
# this option is good to test your IDS :)
 | 
			
		||||
 | 
			
		||||
# Make sense only if random_chain
 | 
			
		||||
#chain_len = 2
 | 
			
		||||
 | 
			
		||||
# Quiet mode (no output from library)
 | 
			
		||||
#quiet_mode
 | 
			
		||||
 | 
			
		||||
# Proxy DNS requests - no leak for DNS data
 | 
			
		||||
proxy_dns 
 | 
			
		||||
 | 
			
		||||
# Some timeouts in milliseconds
 | 
			
		||||
tcp_read_time_out 15000
 | 
			
		||||
tcp_connect_time_out 8000
 | 
			
		||||
 | 
			
		||||
# Example for localnet exclusion
 | 
			
		||||
## Exclude connections to 192.168.1.0/24 with port 80
 | 
			
		||||
# localnet 192.168.1.0:80/255.255.255.0
 | 
			
		||||
 | 
			
		||||
## Exclude connections to 192.168.100.0/24
 | 
			
		||||
# localnet 192.168.100.0/255.255.255.0
 | 
			
		||||
 | 
			
		||||
## Exclude connections to ANYwhere with port 80
 | 
			
		||||
# localnet 0.0.0.0:80/0.0.0.0
 | 
			
		||||
 | 
			
		||||
# ProxyList format
 | 
			
		||||
#       type  host  port [user pass]
 | 
			
		||||
#       (values separated by 'tab' or 'blank')
 | 
			
		||||
#
 | 
			
		||||
#
 | 
			
		||||
#        Examples:
 | 
			
		||||
#
 | 
			
		||||
#            	socks5	192.168.67.78	1080	lamer	secret
 | 
			
		||||
#		http	192.168.89.3	8080	justu	hidden
 | 
			
		||||
#	 	socks4	192.168.1.49	1080
 | 
			
		||||
#	        http	192.168.39.93	8080	
 | 
			
		||||
#		
 | 
			
		||||
#
 | 
			
		||||
#       proxy types: http, socks4, socks5
 | 
			
		||||
#        ( auth types supported: "basic"-http  "user/pass"-socks )
 | 
			
		||||
#
 | 
			
		||||
[ProxyList]
 | 
			
		||||
# add proxy here ...
 | 
			
		||||
# meanwile
 | 
			
		||||
# defaults set to "tor"
 | 
			
		||||
socks4 	127.0.0.1 9050
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										16
									
								
								src/proxyresolv
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										16
									
								
								src/proxyresolv
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,16 @@
 | 
			
		||||
#!/bin/sh
 | 
			
		||||
# This script is called by proxychains to resolve DNS names
 | 
			
		||||
 | 
			
		||||
# DNS server used to resolve names
 | 
			
		||||
DNS_SERVER=4.2.2.2
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
if [ $# = 0 ] ; then
 | 
			
		||||
	echo "	usage:"
 | 
			
		||||
	echo "		proxyresolv <hostname> "
 | 
			
		||||
	exit
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
export LD_PRELOAD=libproxychains.so
 | 
			
		||||
dig $1 @$DNS_SERVER +tcp | awk '/A.+[0-9]+\.[0-9]+\.[0-9]/{print $5;}'
 | 
			
		||||
		Reference in New Issue
	
	Block a user