mirror of
https://github.com/rofl0r/proxychains-ng.git
synced 2024-12-22 20:38:49 +00:00
care about HOME also in proxychains loader. put common symbols in common.h
This commit is contained in:
parent
4d517cdfb0
commit
b8bdfc2d5e
2
src/common.h
Normal file
2
src/common.h
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
#define PROXYCHAINS_CONF_FILE_ENV_VAR "PROXYCHAINS_CONF_FILE"
|
||||||
|
#define PROXYCHAINS_CONF_FILE "proxychains.conf"
|
@ -18,6 +18,7 @@
|
|||||||
#define __CORE_HEADER
|
#define __CORE_HEADER
|
||||||
#define BUFF_SIZE 8*1024 // used to read responses from proxies.
|
#define BUFF_SIZE 8*1024 // used to read responses from proxies.
|
||||||
#define MAX_LOCALNET 1024
|
#define MAX_LOCALNET 1024
|
||||||
|
|
||||||
/*error codes*/
|
/*error codes*/
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "core.h"
|
#include "core.h"
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
#define satosin(x) ((struct sockaddr_in *) &(x))
|
#define satosin(x) ((struct sockaddr_in *) &(x))
|
||||||
#define SOCKADDR(x) (satosin(x)->sin_addr.s_addr)
|
#define SOCKADDR(x) (satosin(x)->sin_addr.s_addr)
|
||||||
@ -61,7 +62,7 @@ static void init_lib(void);
|
|||||||
|
|
||||||
static void init_lib(void)
|
static void init_lib(void)
|
||||||
{
|
{
|
||||||
proxychains_write_log("ProxyChains-3.2 (http://github.com/rofl0r/proxychains)\n");
|
proxychains_write_log("[proxychains v3.2] DLL init\n");
|
||||||
|
|
||||||
get_chain_data(proxychains_pd, &proxychains_proxy_count, &proxychains_ct);
|
get_chain_data(proxychains_pd, &proxychains_proxy_count, &proxychains_ct);
|
||||||
true_connect = (connect_t) dlsym(RTLD_NEXT, "connect");
|
true_connect = (connect_t) dlsym(RTLD_NEXT, "connect");
|
||||||
@ -156,12 +157,6 @@ static void init_lib(void)
|
|||||||
init_l = 1;
|
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(
|
static inline void get_chain_data(
|
||||||
proxy_data *pd,
|
proxy_data *pd,
|
||||||
unsigned int *proxy_count,
|
unsigned int *proxy_count,
|
||||||
@ -188,7 +183,7 @@ static inline void get_chain_data(
|
|||||||
* Get path to configuration file from env this file has priority
|
* Get path to configuration file from env this file has priority
|
||||||
* if it's defined.
|
* if it's defined.
|
||||||
*/
|
*/
|
||||||
env = getenv(PROXYCHAINS_CONF_FILE);
|
env = getenv(PROXYCHAINS_CONF_FILE_ENV_VAR);
|
||||||
|
|
||||||
snprintf(buff,256,"%s/.proxychains/proxychains.conf",getenv("HOME"));
|
snprintf(buff,256,"%s/.proxychains/proxychains.conf",getenv("HOME"));
|
||||||
|
|
||||||
|
47
src/main.c
47
src/main.c
@ -26,7 +26,7 @@
|
|||||||
extern char *optarg;
|
extern char *optarg;
|
||||||
extern int optind, opterr, optopt;
|
extern int optind, opterr, optopt;
|
||||||
|
|
||||||
#define PROXYCHAINS_CONF_FILE "proxychains.conf"
|
#include "common.h"
|
||||||
|
|
||||||
static void usage(char** argv) {
|
static void usage(char** argv) {
|
||||||
printf("\nUsage: %s [h] [f] config_file program_name [arguments]\n"
|
printf("\nUsage: %s [h] [f] config_file program_name [arguments]\n"
|
||||||
@ -34,6 +34,11 @@ static void usage(char** argv) {
|
|||||||
"More help in README file\n", argv[0]);
|
"More help in README file\n", argv[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int check_path(char* path) {
|
||||||
|
if(!path) return 0;
|
||||||
|
return access(path, R_OK) != -1;
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
char *path = NULL;
|
char *path = NULL;
|
||||||
char buf[256];
|
char buf[256];
|
||||||
@ -54,34 +59,42 @@ int main(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* check if path of config file has not been passed via command line */
|
||||||
if(!path) {
|
if(!path) {
|
||||||
if(!(path = getenv("PROXYCHAINS_CONF_FILE")))
|
// priority 1: env var PROXYCHAINS_CONF_FILE
|
||||||
path = getcwd(buf, sizeof(buf));
|
path = getenv(PROXYCHAINS_CONF_FILE_ENV_VAR);
|
||||||
else if(access(path, R_OK) != -1) goto have;
|
if(check_path(path)) goto have;
|
||||||
if(!path ||
|
|
||||||
!snprintf(pbuf, sizeof(pbuf), "%s/%s", path, PROXYCHAINS_CONF_FILE) ||
|
// priority 2; proxychains conf in actual dir
|
||||||
access(pbuf, R_OK) == -1
|
path = getcwd(buf, sizeof(buf));
|
||||||
)
|
snprintf(pbuf, sizeof(pbuf), "%s/%s", path, PROXYCHAINS_CONF_FILE);
|
||||||
path = "/etc/proxychains.conf";
|
path = pbuf;
|
||||||
else
|
if(check_path(path)) goto have;
|
||||||
path = pbuf;
|
|
||||||
}
|
// priority 3; $HOME/.proxychains/proxychains.conf
|
||||||
if(access(path, R_OK) == -1) {
|
path = getenv("HOME");
|
||||||
|
snprintf(pbuf, sizeof(pbuf), "%s/.proxychains/%s", path, PROXYCHAINS_CONF_FILE);
|
||||||
|
path = pbuf;
|
||||||
|
if(check_path(path)) goto have;
|
||||||
|
|
||||||
|
// priority 4: /etc/proxychains.conf
|
||||||
|
path = "/etc/proxychains.conf";
|
||||||
|
if(check_path(path)) goto have;
|
||||||
perror("couldnt find configuration file");
|
perror("couldnt find configuration file");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
have:
|
have:
|
||||||
|
|
||||||
printf("using config file: %s\n", path);
|
printf("[proxychains config] %s\n", path);
|
||||||
//printf("argv = %s\n", argv[1]);
|
|
||||||
|
|
||||||
/* Set PROXYCHAINS_CONF_FILE to get proxychains lib to use new config file. */
|
/* Set PROXYCHAINS_CONF_FILE to get proxychains lib to use new config file. */
|
||||||
setenv("PROXYCHAINS_CONF_FILE", path, 1);
|
setenv(PROXYCHAINS_CONF_FILE_ENV_VAR, path, 1);
|
||||||
|
|
||||||
snprintf(buf, sizeof(buf), "LD_PRELOAD=%s/libproxychains.so", LIB_DIR);
|
snprintf(buf, sizeof(buf), "LD_PRELOAD=%s/libproxychains.so", LIB_DIR);
|
||||||
putenv(buf);
|
putenv(buf);
|
||||||
execvp(argv[1], &argv[1]);
|
execvp(argv[1], &argv[1]);
|
||||||
perror("proxychains can't load process....");
|
perror("proxychains can't load process....");
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user