Open aitsc opened 2 years ago
the problem seems to be pip and apt, which both require root permissions. some security feature might intervene. you can try whether proxydns_daemon mode fixes it.
@rofl0r I used proxychains4-daemon, but apt and pip still have the same output. The problem doesn't seem to be a dns proxy issue, as direct access to the ip doesn't work either.
(base) root@test# proxychains4 python -c "import os;os.system('curl 1.1.1.1')"
[proxychains] config file found: /usr/local/etc/proxychains.conf
[proxychains] preloading /usr/local/lib/libproxychains4.so
curl: (28) Failed to connect to 1.1.1.1 port 80: Connection timed out
(base) root@test# python -c "import os;os.system('proxychains4 curl 1.1.1.1')"
[proxychains] config file found: /usr/local/etc/proxychains.conf
[proxychains] preloading /usr/local/lib/libproxychains4.so
[proxychains] DLL init: proxychains-ng 4.16-git-9-g060801d
[proxychains] Strict chain ... 127.0.0.1:34567 ... 1.1.1.1:80 ... OK
<html>
<head><title>301 Moved Permanently</title></head>
<body>
<center><h1>301 Moved Permanently</h1></center>
<hr><center>cloudflare</center>
</body>
</html>
the output of the second command seems to suggest that python's system
deletes environment variables, such as the LD_PRELOAD one set by proxychains4 binary. so i'd just use the second method, namely running system("proxychains4 ...")
.
@rofl0r It is true that environment variables are deleted. But what is confusing is that this phenomenon only happens with the LD_PRELOAD variable, which is strange.
The first command proves that adding LD_PRELOAD manually in the subshell is valid. The second command proves that manually adding LD_PRELOAD outside is not valid. The third command proves that manually adding LD_PRELOAD1 outside is valid.
(base) root@test# proxychains4 bash -c "python -c 'import os;os.system(\"export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libproxychains.so.4 && export && curl baidu.com\")'"
[proxychains] config file found: /etc/proxychains4.conf
[proxychains] preloading /usr/lib/x86_64-linux-gnu/libproxychains.so.4
[proxychains] DLL init: proxychains-ng 4.14
......
export LD_PRELOAD='/usr/lib/x86_64-linux-gnu/libproxychains.so.4'
......
[proxychains] DLL init: proxychains-ng 4.14
[proxychains] Strict chain ... 127.0.0.1:34567 ... baidu.com:80 ... OK
<html>
<meta http-equiv="refresh" content="0;url=http://www.baidu.com/">
</html>
(base) root@test# proxychains4 bash -c "export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libproxychains.so.4 && python -c 'import os;os.system(\"export && curl baidu.com\")'"
[proxychains] config file found: /etc/proxychains4.conf
[proxychains] preloading /usr/lib/x86_64-linux-gnu/libproxychains.so.4
[proxychains] DLL init: proxychains-ng 4.14
......
curl: (6) Could not resolve host: baidu.com
(base) root@test# proxychains4 bash -c "export LD_PRELOAD1=/usr/lib/x86_64-linux-gnu/libproxychains.so.4 && python -c 'import os;os.system(\"export && curl baidu.com\")'"
[proxychains] config file found: /etc/proxychains4.conf
[proxychains] preloading /usr/lib/x86_64-linux-gnu/libproxychains.so.4
[proxychains] DLL init: proxychains-ng 4.14
......
export LD_PRELOAD1='/usr/lib/x86_64-linux-gnu/libproxychains.so.4'
......
curl: (6) Could not resolve host: baidu.com
might be a security "feature" of python. maybe you can grep the sources of your python version for "LD_PRELOAD" and find out why.
I configured proxychains4, but these lines of code doesn't work:
However, the results of running the first 6 commands prove that the configuration of proxychains4 should be fine:
vim /etc/proxychains4.conf
I don't have this problem on other ubuntu. How should I look for the cause of this problem?