proxychains-ng
proxychains-ng copied to clipboard
The quiet mode (-q) does not work in some case
The quiet mode (-q
) does not work in some case on my computer (OS X 10.11 with csrutil enable --without debug
).
For example, when i running proxychains -q emacs
, the message [proxychains] DLL init: proxychains-ng 4.11
appears in the content which retrieved from system clipboard every time.
Where the [proxychains] DLL init: proxychains-ng 4.11
from? I did a little bit changes to print proxychains_quiet_mode
value in console, then i got these:
$ proxychains4 -q npm install
[proxychains] [quiet=0] DLL init: proxychains-ng
[proxychains] [quiet=0] DLL init: proxychains-ng
[proxychains] [quiet=0] DLL init: proxychains-ng
[proxychains] [quiet=0] DLL init: proxychains-ng
[proxychains] [quiet=0] DLL init: proxychains-ng
[proxychains] [quiet=0] DLL init: proxychains-ng
[proxychains] [quiet=0] DLL init: proxychains-ng
[proxychains] [quiet=0] DLL init: proxychains-ng
[proxychains] [quiet=0] DLL init: proxychains-ng
[proxychains] [quiet=0] DLL init: proxychains-ng
Following are the installation procedures and scripts:
$ brew install ~/scratch/proxychains-ng.rb --HEAD
$ cat ~/scratch/proxychains-ng.rb
class ProxychainsNg < Formula
desc "Hook preloader"
homepage "https://sourceforge.net/projects/proxychains-ng/"
url "https://downloads.sourceforge.net/project/proxychains-ng/proxychains-ng-4.11.tar.bz2"
sha256 "dcc4149808cd1fb5d9663cc09791f478805816b1f017381f424414c47f6376b6"
head "https://github.com/rofl0r/proxychains-ng.git"
bottle do
sha256 "3a54f2ae04b107b97db3a0522f06cc77c0420bf7a562a07d4938c209e34d53ca" => :el_capitan
sha256 "336d042fcdef471d60bca6233c834db94b85c911425efba8bf442b6affc0db00" => :yosemite
sha256 "2707450f3238082aeef0884770eabae0167d17c1029840a5ab48db0af320b254" => :mavericks
end
option :universal
def install
args = ["--prefix=#{prefix}", "--sysconfdir=#{prefix}/etc"]
if build.universal?
ENV.universal_binary
args << "--fat-binary"
end
system "./configure", *args
system "make"
system "make", "install"
system "make", "install-config"
end
test do
assert_match "config file found", shell_output("#{bin}/proxychains4 test 2>&1", 1)
end
patch :DATA
end
__END__
diff --git a/src/libproxychains.c b/src/libproxychains.c
index 1240448..882eb23 100644
--- a/src/libproxychains.c
+++ b/src/libproxychains.c
@@ -122,7 +122,7 @@ static void do_init(void) {
get_chain_data(proxychains_pd, &proxychains_proxy_count, &proxychains_ct);
DUMP_PROXY_CHAIN(proxychains_pd, proxychains_proxy_count);
- proxychains_write_log(LOG_PREFIX "DLL init: proxychains-ng %s\n", proxychains_get_version());
+ proxychains_write_log(LOG_PREFIX "[quiet=%d] DLL init: proxychains-ng %s\n", proxychains_quiet_mode, proxychains_get_version());
setup_hooks();
does this happen only with the target application npm
?
a possible cause could be that npm does unset all environment variables it doesnt know.
in our case we need PROXYCHAINS_QUIET_MODE
to be set to 1
.
@rofl0r
- npm (without -q option)
proxychains4 npm install
[proxychains] config file found: ~/.proxychains4shadowsocks.conf
[proxychains] preloading /usr/local/Cellar/proxychains-ng/HEAD-e527b9e/lib/libproxychains4.dylib
[proxychains] DLL init: proxychains-ng
[proxychains] DLL init: proxychains-ng
[proxychains] DLL init: proxychains-ng
[proxychains] DLL init: proxychains-ng
[proxychains] DLL init: proxychains-ng
...
[proxychains] DLL init: proxychains-ng
[proxychains] DLL init: proxychains-ng
[proxychains] DLL init: proxychains-ng
[proxychains] DLL init: proxychains-ng
[proxychains] DLL init: proxychains-ng
...
^C
# aborted by manual
- curl
$ proxychains4 -q curl -s https://google.com
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="https://www.google.com/">here</A>.
</BODY></HTML>
seems well
- vi
$ proxychains4 -q vi
:!
[proxychains] DLL init: proxychains-ng 4.11
Press ENTER or type command to continue
- vi (without -q option)
$ proxychains4 vi
:!
[proxychains] config file found: ~/.proxychains4shadowsocks.conf
[proxychains] preloading /usr/local/Cellar/proxychains-ng/4.11/lib/libproxychains4.dylib
[proxychains] DLL init: proxychains-ng 4.11
[proxychains] DLL init: proxychains-ng 4.11
Press ENTER or type command to continue
i'm a bit irritated about the number of
[proxychains] DLL init: proxychains-ng 4.11
lines you get. this code should only be executed once (the whole init stuff).
can you attach a debugger and see why its called more than once ?
or add -DDEBUG to your CFLAGS when building so we can see from where it's called.
very interesting/confusing.
- the gcc_init() code is called multiple times, even from the same PID
- that means pthread_once() in OSX doesn't work, or at least not in the case of preloading or when called from ldso constructor.
- any variables set during the constructor call are "lost". this looks like the dynlinker would spawn a lot of forks before running the constructor code, so every process has its own view of the memory. however that cannot be the case since the first couple calls to the init function seem to come from the same pid.
since the gcc constructor code seems broken for OSX, you could try to change this line in libproxychains.c from
#if __GNUC__ > 2
to
#if 0
After change #if __GNUC__ > 2
to #if 0
$ proxychains4 -q curl -so /dev/null -w "%{http_code}" https://google.com
301
$ proxychains4 curl -so /dev/null -w "%{http_code}" https://google.com
[proxychains] config file found: ~/.proxychains4shadowsocks.conf
[proxychains] preloading /usr/local/Cellar/proxychains-ng/HEAD-e527b9e/lib/libproxychains4.dylib
[proxychains] DLL init: proxychains-ng
[proxychains] Strict chain ... 127.0.0.1:1080 ... google.com:443 ... OK
301
$ proxychains4 npm install
[proxychains] config file found: ~/.proxychains4shadowsocks.conf
[proxychains] preloading /usr/local/Cellar/proxychains-ng/HEAD-e527b9e/lib/libproxychains4.dylib
# hangs
would be more interesting with debug output...
note that i mistakenly closed this issue (but reopened it at once); i didn't intend to discourage you from further investigation.
I'm from linux and find something interesting:
makepkg -s
(too long)
read(0, [proxychains] DLL init: proxychains-ng 4.12
"", 1) = 0
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=1288, si_uid=1000, si_status=1, si_utime=0, si_stime=0} ---
wait4(-1, [{WIFEXITED(s) && WEXITSTATUS(s) == 1}], WNOHANG, NULL) = 1288
wait4(-1, 0x7ffcdeb167d0, WNOHANG, NULL) = -1 ECHILD (No child processes)
rt_sigreturn({mask=[]}) = 0
dup2(10, 0) = 0
fcntl(10, F_GETFD) = 0x1 (flags FD_CLOEXEC)
close(10) = 0
close(63) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
pipe([7, 8]) = 0
fcntl(63, F_GETFD) = -1 EBADF (Bad file descriptor)
dup2(7, 63) = 63
close(7) = 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigprocmask(SIG_BLOCK, [INT CHLD], [], 8) = 0
clone(child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f0322b1a810) = 1292
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigaction(SIGCHLD, {sa_handler=0x443a00, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7f0321f0c6f0}, {sa_handler=0x443a00, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7f0321f0c6f0}, 8) = 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
close(8) = 0
open("/dev/fd/63", O_RDONLY) = 7
fcntl(0, F_GETFD) = 0
fcntl(0, F_DUPFD, 10) = 10
fcntl(0, F_GETFD) = 0
fcntl(10, F_SETFD, FD_CLOEXEC) = 0
dup2(7, 0) = 0
close(7) = 0
ioctl(0, TCGETS, 0x7ffcdeb16e90) = -1 ENOTTY (Inappropriate ioctl for device)
lseek(0, 0, SEEK_CUR) = -1 ESPIPE (Illegal seek)
read(0, [proxychains] DLL init: proxychains-ng 4.12
"", 1) = 0
dup2(10, 0) = 0
fcntl(10, F_GETFD) = 0x1 (flags FD_CLOEXEC)
close(10) = 0
close(63) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0, it repeats
pipe([7, 8]) = 0
fcntl(63, F_GETFD) = -1 EBADF (Bad file descriptor)
dup2(7, 63) = 63
close(7) = 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigprocmask(SIG_BLOCK, [INT CHLD], [], 8) = 0
clone(child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f0322b1a810) = 1296
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigaction(SIGCHLD, {sa_handler=0x443a00, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7f0321f0c6f0}, {sa_handler=0x443a00, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7f0321f0c6f0}, 8) = 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
close(8) = 0
open("/dev/fd/63", O_RDONLY) = 7
fcntl(0, F_GETFD) = 0
fcntl(0, F_DUPFD, 10) = 10
fcntl(0, F_GETFD) = 0
fcntl(10, F_SETFD, FD_CLOEXEC) = 0
dup2(7, 0) = 0
close(7) = 0
ioctl(0, TCGETS, 0x7ffcdeb16e90) = -1 ENOTTY (Inappropriate ioctl for device)
lseek(0, 0, SEEK_CUR) = -1 ESPIPE (Illegal seek)
read(0, [proxychains] DLL init: proxychains-ng 4.12
"", 1) = 0
dup2(10, 0) = 0
fcntl(10, F_GETFD) = 0x1 (flags FD_CLOEXEC)
close(10) = 0
close(63) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
pipe([7, 8]) = 0
fcntl(63, F_GETFD) = -1 EBADF (Bad file descriptor)
dup2(7, 63) = 63
close(7) = 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigprocmask(SIG_BLOCK, [INT CHLD], [], 8) = 0
clone(child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f0322b1a810) = 1300
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigaction(SIGCHLD, {sa_handler=0x443a00, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7f0321f0c6f0}, {sa_handler=0x443a00, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7f0321f0c6f0}, 8) = 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
close(8) = 0
open("/dev/fd/63", O_RDONLY) = 7
fcntl(0, F_GETFD) = 0
fcntl(0, F_DUPFD, 10) = 10
fcntl(0, F_GETFD) = 0
fcntl(10, F_SETFD, FD_CLOEXEC) = 0
dup2(7, 0) = 0
close(7) = 0
ioctl(0, TCGETS, 0x7ffcdeb16e90) = -1 ENOTTY (Inappropriate ioctl for device)
lseek(0, 0, SEEK_CUR) = -1 ESPIPE (Illegal seek)
read(0, [proxychains] DLL init: proxychains-ng 4.12
npm update
:
prlimit64(0, RLIMIT_STACK, NULL, {rlim_cur=8192*1024, rlim_max=RLIM64_INFINITY}) = 0
brk(NULL) = 0x32e9000
brk(0x331b000) = 0x331b000
pipe([7, 8]) = 0
pipe([9, 10]) = 0
mmap(NULL, 16384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = 0x7f1c992bc000
mprotect(0x7f1c992bc000, 4096, PROT_NONE) = 0
clone(child_stack=0x7f1c992befb0, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, parent_tidptr=0x7f1c992bf9d0, tls=0x7f1c992bf700, child_tidptr=0x7f1c992bf9d0) = 1535
access("/etc/proxychains.conf", R_OK) = 0
open("/etc/proxychains.conf", O_RDONLY) = 11
fstat(11, {st_mode=S_IFREG|0644, st_size=3690, ...}) = 0
read(11, "# proxychains.conf VER 4.x\n#\n# "..., 4096) = 3690
read(11, "", 4096) = 0
close(11) = 0
write(2, "[proxychains] DLL init: proxycha"..., 44[proxychains] DLL init: proxychains-ng 4.12
) = 44
futex(0x7f1c976e5048, FUTEX_WAKE_PRIVATE, 2147483647) = 0
futex(0x7f1c99059380, FUTEX_WAKE_PRIVATE, 2147483647) = 0
rt_sigprocmask(SIG_SETMASK, [USR1], NULL, 8) = 0
fstat(0, {st_mode=S_IFCHR|0600, st_rdev=makedev(136, 3), ...}) = 0
fstat(1, {st_mode=S_IFCHR|0600, st_rdev=makedev(136, 3), ...}) = 0
fstat(2, {st_mode=S_IFCHR|0600, st_rdev=makedev(136, 3), ...}) = 0
It would init DLL again after clone
(maybe)
sorry, but i don't get your point. could you elaborate on what you think is interesting ?