Welcome to mirror list, hosted at ThFree Co, Russian Federation.

proxychains « src - github.com/haad/proxychains.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 29efcc88953834b893fa43247cd49a5d8cdf07b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/bin/sh
echo "ProxyChains-4.0 (https://github.com/haad/proxychains)"

usage() {

	echo "	usage:"
	echo "	$0 [hq] [-f config-file] <prog> [args]"
	echo "		-q make proxychains quiet"
	exit
}

find_proxy_conf() {

	show_proxy_env
	if [ -f "/usr/local/etc/proxychains.conf" ]; then
		export PROXYCHAINS_CONF_FILE="/usr/local/etc/proxychains.conf"
	else 
		if [ -f "/etc/proxychains.conf" ];then
			PROXYCHAINS_CONF_FILE="/etc/proxychains.conf"
		fi
	fi
}

#
# XXX We should not overide possible user settings here. Just add libproxychains to it.
# 
setup_proxy_env() {

	if [ -z "$PROXYCHAINS_CONF_FILE" ]; then
		find_proxy_conf
	fi

	if [ $(uname -s) = "Darwin" ]; then
		export DYLD_FORCE_FLAT_NAMESPACE=
		export DYLD_INSERT_LIBRARIES=libproxychains4.dylib
	else
		export LD_PRELOAD=libproxychains.so.4
	fi
}

disable_proxy_env() {

	if [ $(uname -s) = "Darwin" ]; then
		unset DYLD_FORCE_FLAT_NAMESPACE
		export DYLD_INSERT_LIBRARIES=$(echo $DYLD_INSERT_LIBRARIES | sed -e 's/libproxychains4.dylib//g')
		if [ -z $DYLD_INSERT_LIBRARIES ]; then
			unset DYLD_INSERT_LIBRARIES
		fi
	else
		export LD_PRELOAD=$(echo $DYLD_INSERT_LIBRARIES | sed -e 's/libproxychains.so.4//g')
		if [ -z $LD_PRELOAD ]; then
			unset LD_PRELOAD
		fi
	fi
}

show_proxy_env() {

	echo "Proxified environment setup"
	echo "PROXYCHAINS_CONF_FILE = $PROXYCHAINS_CONF_FILE"
	
	if [ $(uname -s) = "Darwin" ]; then
		echo "DYLD_FORCE_FLAT_NAMESPACE = $DYLD_FORCE_FLAT_NAMESPACE"
		echo "DYLD_INSERT_LIBRARIES = $DYLD_INSERT_LIBRARIES"
	else
		echo "LD_PRELOAD = $LD_PRELOAD"
	fi
}

if [ $# = 0 ] ; then
	usage
fi

case "$1" in
	-h)
		usage
		;;
	-f)
		export PROXYCHAINS_CONF_FILE=$2;
		shift;
		shift;
		;;
	-q)
		export PROXYCHAINS_QUIET_MODE=1;
		shift;
		;;
	show)
		show_proxy_env
		return
		;;
esac

case "$1" in
	on)
		setup_proxy_env
		show_proxy_env
		;;
	off)
		disable_proxy_env
		show_proxy_env
		;;
	*)
		setup_proxy_env
		exec "$@"
		;;
esac