163 Commits

Author SHA1 Message Date
Adam Hamsik 9aff5523a4 Update mac os build. 2021-01-29 11:00:07 +01:00
Adam Hamsik ea89ca551a Merge pull request #109 from aviau/patch-1
proxychains.conf: mention `raw` type
2020-12-11 15:41:37 +01:00
Alexandre Viau d27fcbff9b proxychains.conf: mention raw type 2020-12-10 11:42:49 -05:00
Adam Hamsik 4c31f32dc9 Update version string 2020-12-10 14:05:01 +01:00
Adam Hamsik 5320c1bc22 Bump version string to 4.3.0 2020-12-10 14:04:16 +01:00
Adam Hamsik 2d2ba1c921 Merge pull request #108 from aviau/aviau/raw-proxy
support 'raw' proxy type
2020-12-10 14:02:52 +01:00
Adam Hamsik ed75dfa6e2 Merge pull request #104 from ChuanfengZhang/master
docs: fix link of pkgsrc
2020-12-10 14:00:53 +01:00
aviau 7b24b954c8 support 'raw' proxy type 2020-10-27 15:23:40 -04:00
zhangcf e8247feeda docs: fix link of pkgsrc 2020-09-14 15:30:42 +08:00
Adam Hamsik 99af45703e Update libproxychains.c
Fix redundant parenthesis.
2020-07-28 16:15:00 +02:00
Adam Hamsik 5dd8450452 Merge pull request #99 from tomgilon/dnat
Add dnat feature
2020-07-21 22:41:19 +02:00
Adam Hamsik 8dea4f9297 Merge pull request #98 from AdamVanScyoc/fix_conf_file_typo
Fix type on proxychains.conf fix_conf_file_type
2020-07-21 22:39:39 +02:00
Adam Hamsik 48c7a005e6 Merge pull request #100 from 0xflotus/patch-1
(docs): fixed possible typo error
2020-07-21 22:38:47 +02:00
0xflotus 7efa291d90 (docs): fixed possible typo error
in www.insecure.org/nmap
2020-05-24 14:22:02 +02:00
tom gilon d7096b4f98 Add option to change tcp destination port and ip before sending to proxy server 2020-05-07 00:10:59 +03:00
Adam Van Scyoc 6d1e0e8af6 Fix type on proxychains.conf fix_conf_file_type 2020-04-14 22:28:44 -04:00
Adam Hamsik e7a2b9d79a Merge pull request #88 from Mister-Meeseeks/master
Allow user to override default DNS server
2020-01-10 13:39:06 +01:00
Adam Hamsik f1ffbd4b94 Merge pull request #75 from tinyzimmer/master
optional set host on easy socks5 env var
2020-01-10 13:38:20 +01:00
Adam Hamsik 87ec01c762 Merge pull request #95 from theosotr/fix
Add missing Make dependencies
2020-01-10 13:36:38 +01:00
Thodoris Sotiropoulos 8df5b3f11d Add missing Make dependencies 2020-01-02 21:52:50 +02:00
Douglas R Colkitt 0416c2b7ea Fix issue with POSIX portability in proxyresolv script 2019-04-13 15:48:24 +00:00
Douglas R Colkitt 98e9326534 Allow user to override default DNS server
Implements support for an environmnet variable (PROXY_DNS_SERVER) whereby
the user can specify a DNS server. If not set defaults to the hardcoded
OpenDNS default.
2019-04-13 15:41:07 +00:00
Adam Hamsik 14e15aa2c1 Merge pull request #85 from Intika-Linux-Network/master
Fix security issue CVE-2015-3887
2019-01-22 18:45:29 +01:00
intika 9f99278525 Fix security issue CVE-2015-3887 2019-01-22 13:25:35 +00:00
tinyzimmer f3b07370fb require cdefs 2018-04-22 21:42:33 -07:00
tinyzimmer dbe328efdd dont require cdefs 2018-04-22 21:36:52 -07:00
tinyzimmer f88610077c allow dynamic host for simple socks env var 2018-04-22 20:40:26 -07:00
Alex Flores fbfdd995db Merge pull request #73 from audibleblink/master
patch for random proxy selection
2018-04-12 21:55:02 -04:00
Alex Flores bd207014a2 patch for better random proxy selection 2018-04-12 21:35:23 -04:00
Adam Hamsik 2bdf74d5a6 Merge pull request #66 from julian-klode/pu/fix-pbuf-null
Fix compilation error in get_config_path()
2018-04-04 12:36:16 +02:00
Julian Andres Klode e8e0b93b37 Fix compilation error in get_config_path()
When inlining check_path(), gcc sees after the first snprintf()
call that pbuf might be null, and subsequently generates a warning
for the next snprintf() call. Since the code (erroneously) builds
with -Werror, this causes it to fail.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83139
2017-11-24 11:10:28 +01:00
Adam Hamsik c38374ab5b Merge pull request #59 from leggiero/patch-1
Minor typo
2017-09-03 12:40:06 +02:00
Eduardo Leggiero 67aa8eae24 Minor typo 2017-07-25 13:47:39 +01:00
Adam Hamsik 0f61bd0713 Remove superfluos ] 2016-02-14 21:58:19 +01:00
Adam Hamsik 581f0ff31a Some updates 2016-02-14 21:57:34 +01:00
Adam Hamsik 7d160b9015 Rewrite README as proper asciidoc 2016-02-14 21:55:59 +01:00
Adam Hamsik 138481b410 Test build on osx too 2016-02-14 21:09:33 +01:00
Adam Hamsik bf833e216b Add travis.yml 2016-02-14 21:06:34 +01:00
Adam Hamsik 60bcee08c9 Merge branch 'hutchinson-linux_fix'
* hutchinson-linux_fix:
  Fix Linux compile issue
2016-02-14 21:00:47 +01:00
Adam Hamsik 8623b26a72 Merge branch 'linux_fix' of https://github.com/hutchinson/proxychains into hutchinson-linux_fix
* 'linux_fix' of https://github.com/hutchinson/proxychains:
  Fix Linux compile issue
2016-02-14 21:00:35 +01:00
Adam Hamsik 3b52a10c54 Merge pull request #37 from douglasanpa/master
Fix to compile on Ubuntu 13:04
2015-12-29 13:32:12 +01:00
Adam Hamsik ec404a9e61 Merge pull request #45 from netroby/feature/drill-opendns
Using OpenDNS and Drill (ldns-utils)
2014-12-08 15:41:49 +01:00
ZhiFeng Hu fdbce6cf24 Using OpenDNS and Drill (ldns-utils) 2014-11-28 13:45:02 +08:00
Adam Hamsik 0c39bb25a6 Merge pull request #44 from hmgle/fix_usage
fix #43
2014-06-30 16:13:36 +02:00
mingang.he a1ff3e0426 fix #43
"-t" should be "-f"
2014-06-30 20:18:14 +08:00
Dan Hutchinson 86dfc828f1 Fix Linux compile issue 2014-04-21 20:42:14 +01:00
douglasanpa 33805b3375 Fix to compile on Ubuntu 13:04
With this modification the proxychains compiles successfully on Ubuntu 13:04
2013-04-17 04:09:02 -03:00
Adam Hamsik dcbafb0279 Make linux and mac options similar. 2012-10-15 14:16:38 +02:00
Adam Hamsik 93bbad6ccb Use same LD parameters where is it possible. 2012-10-15 11:41:33 +02:00
Adam Hamsik f52a3001e1 Merge tomsawyer changes while, Makefile changes were fixed in my previous commit.
Merge branch 'main_fixes' of git://github.com/tomsawyer/proxychains into tomsawyer-main_fixes

Conflicts:
	Makefile
2012-10-15 11:27:51 +02:00
Adam Hamsik 92ab117a9e Merge branch 'master' of github.com:haad/proxychains 2012-10-15 11:05:17 +02:00
Adam Hamsik fb30a834a7 Add OS specific LD, C flags this enables use to use -pthread and -lpthread for different platforms. 2012-10-15 11:03:59 +02:00
Adam Hamsik caa76df519 Merge pull request #30 from benizi/add-socks5-mode
Add simple SOCKS5 mode
2012-10-15 01:02:17 -07:00
Benjamin R. Haskell 2ac7066abd Add README changes for simple SOCKS5 mode 2012-10-12 15:39:13 -04:00
Benjamin R. Haskell d3516a1c28 Add simple SOCKS5 proxy mode
If the environment variable PROXYCHAINS_SOCKS5 is set to a port number,
the configuration will be a single chain with a SOCKS5 proxy on
localhost:{that port}.

Additionally, setting the PROXYCHAINS_DNS environment variable (to any
value at all) will cause DNS queries to be proxied.
2012-10-12 15:39:03 -04:00
Semion Laptev 7aa95f9304 gethostbyname() and Makefile fixes 2012-10-10 19:19:12 +04:00
Adam Hamsik c4decf6da2 Mention homebrew formula in README. 2012-10-10 13:26:57 +02:00
Adam Hamsik 2eb641758b Fix library settings. 2012-10-10 03:27:57 -07:00
Adam Hamsik 4678bae604 Fix wrong glibc prototype. 2012-10-10 03:27:25 -07:00
Adam Hamsik 6fe50f2b29 Merge pull request #25 from xiezhenye/patch-1
Update src/proxyresolv
2012-09-22 07:23:22 -07:00
Xie Zhenye d69f46afc5 Update src/proxyresolv
resolve hostname by local /etc/hosts file first
2012-09-22 22:17:53 +08:00
Adam Hamsik f9a2ac0456 Add more documentation updates about BSD support and using pkgsrc to install proxychains. 2012-08-10 02:19:54 +02:00
Adam Hamsik 1c020ced1e Port Proxychains to NetBSD. 2012-08-09 22:36:29 +00:00
Adam Hamsik 361889a2d2 Add option to do a development build with --devel configure flag. Rename proxy_getserverbyname to proxy_getservbyname. 2012-08-05 15:07:37 +02:00
Adam Hamsik 025840930b Add more files to ignore. 2012-07-29 12:09:53 +02:00
Adam Hamsik cca0cea44a Fix couple of problems introduced/detected by clang checker and new -fno-common compiler flag. 2012-07-29 12:09:11 +02:00
Adam Hamsik 462e34f447 Add more strict warnings, make proxychains build with -Wconversion 2012-07-25 02:39:30 +02:00
Adam Hamsik e5ad6e53c3 Add more info, about last work, versions. 2012-07-25 02:34:52 +02:00
Adam Hamsik 5b7270d75b Add new thread-safe getsrvbyname for MacOS X 2012-07-24 14:37:20 +02:00
Adam Hamsik e6b5f245f7 Merge branch 'rofl0r-master'
Conflicts:
	Makefile
	proxychains.lsm
	src/core.h
	src/libproxychains.c
	src/main.c
2012-07-24 14:02:18 +02:00
Adam Hamsik 17dbc76577 Add more binary stuff 2012-07-24 11:51:41 +02:00
Adam Hamsik efa5738a6a Delete binary file. 2012-07-24 11:50:45 +02:00
Adam Hamsik 8547764a82 Merge branch 'master' of https://github.com/rofl0r/proxychains into rofl0r-master
Conflicts:
	Makefile
	src/core.c
	src/core.h
	src/libproxychains.c
	src/main.c
2012-07-24 11:49:22 +02:00
rofl0r 40bb78b53f fix omission in common.c 2012-07-16 02:42:09 +02:00
rofl0r a4f3dd0538 Makefile: put config into new install-config target 2012-07-16 02:36:35 +02:00
rofl0r 80e58726e2 correct copyright of main.c 2012-07-16 02:36:35 +02:00
rofl0r 3c7fcc7507 update AUTHORS 2012-07-16 02:36:35 +02:00
rofl0r ab3ca31871 getaddrinfo: cosmetics 2012-07-16 01:34:00 +02:00
rofl0r 6f56956715 add test for getaddrinfo 2012-07-16 01:21:22 +02:00
rofl0r 037edbcb8e proxy_getaddrinfo: fix segfault when hints is NULL 2012-07-16 01:19:30 +02:00
rofl0r 40edf758ee make getaddrinfo threadsafe 2012-07-16 01:05:28 +02:00
rofl0r 4b999cdae7 use threadsafe getservbyname_r 2012-07-14 17:59:56 +02:00
rofl0r 71e15e2edd simplify log func 2012-07-14 17:59:06 +02:00
rofl0r e5e87c8f22 put abort functionality into get_config_path to further reduce code duplication 2012-07-08 23:47:56 +02:00
rofl0r fafeaf5936 remove unused file 2012-07-08 23:34:34 +02:00
rofl0r fba5f5694c use config file lookup routine from a common place 2012-07-08 23:32:50 +02:00
rofl0r 1a02b9f82f update README 2012-07-08 21:44:02 +02:00
rofl0r 3004240462 slightly better error message 2012-07-08 21:23:39 +02:00
rofl0r 364c785970 print everything to stderr, and fflush on PDEBUG 2012-07-08 04:18:42 +02:00
rofl0r 1fc7e38ee0 fixup for d95ef42d48 2012-07-08 04:09:50 +02:00
rofl0r eb0db7221a configure: add --help text 2012-07-08 00:35:59 +02:00
rofl0r 2c9c4d9da7 simplify load_sym code and remove potential aliasing violation. 2012-07-08 00:27:46 +02:00
rofl0r d95ef42d48 externalize some variables, which are used from both C files 2012-07-08 00:16:00 +02:00
Adam Hamsik 7599bdfdfe Update this file to last version. 2012-06-22 21:59:21 +02:00
Adam Hamsik c1f0c68abd Extract configuration file opening to separate routine. 2012-06-22 21:58:57 +02:00
Adam Hamsik 877e1844ea Remove trailing white space. 2012-06-22 21:57:50 +02:00
Adam Hamsik 69ab0415ac Merge branch 'testing' 2012-06-22 21:35:41 +02:00
Adam Hamsik c14bf58cd7 Add support for both i386 and amd64 in mac os x binary. 2012-06-18 15:46:41 +02:00
Adam Hamsik 5294214150 Fix merge error. 2012-06-18 15:46:22 +02:00
Adam Hamsik 385b349a8e Add support for both i386 and amd64 in mac os x binary. 2012-06-18 15:45:45 +02:00
Adam Hamsik 2320f6608a Merge rofl0r changes to main stream. 2012-06-16 12:10:41 +02:00
Michel Oosterhof 251fd7cd4a Only enable loopback localnet by default, not private address range. 2012-06-16 12:04:28 +02:00
Michel Oosterhof b0d9d1da41 Enable localnet by default for loopback and private address ranges. 2012-06-16 12:04:23 +02:00
Michel Oosterhof a7831a8f53 Typo fix. 2012-06-16 12:02:51 +02:00
Jahrome 229eb7cc5a bugfix: localnet never used if no port specified. Fix typo. 2012-05-22 23:11:03 +02:00
Adam Hamsik c9b8ce35b2 Merge pull request #16 from jahrome/master
Hi ! Nice job with localnet, just what I was needing, here is just a small fix. Hope this helps.
2012-05-22 06:07:35 -07:00
Jahrome 63c3a4b0d2 bugfix: localnet never used if no port specified. Fix typo. 2012-05-22 14:25:53 +02:00
rofl0r 45f50ac754 cosmetic fix 2012-04-24 02:04:02 +02:00
rofl0r d72e668767 use sane defaults 2012-04-24 01:48:17 +02:00
rofl0r 561679fbcd remove dead code 2012-04-24 01:46:57 +02:00
rofl0r bc23ef8f46 fix debug message 2012-04-23 22:56:44 +02:00
rofl0r 88a54e872a use dynloader to call init() func when gcc is available, and lock it properly 2012-04-23 22:21:40 +02:00
rofl0r caed782652 macros 2012-04-23 22:21:40 +02:00
rofl0r f55c6bc4d5 fix PDEBUG macro 2012-04-23 22:21:40 +02:00
rofl0r 49293b180d some cleanup in core.h 2012-04-23 20:26:13 +02:00
rofl0r 3260ee812a debloat init_lib() 2012-04-23 19:51:14 +02:00
rofl0r 1000366f88 Makefile: create destination dirs in case they do not exist 2012-03-07 18:05:04 +01:00
rofl0r 598a41a671 Makefile: add support for DESTDIR 2012-03-07 18:02:37 +01:00
Jianing Yang 65471b750c bugfix: localnet conflicts with proxydns 2012-03-07 17:58:37 +01:00
Adam Hamsik 4d40a4790f Merge pull request #15 from jianingy/master
bugfix: localnet conflicts with proxydns
2012-03-04 23:21:43 -08:00
Jianing Yang 50820ce80d new: added DESTDIR option to Makefile so that packaging will be easier 2012-03-03 14:57:49 +08:00
Jianing Yang b6746997d2 bugfix: localnet conflicts with proxydns (fixed bytes-order) 2012-03-03 14:30:14 +08:00
Jianing Yang 6dda28a2c8 bugfix: localnet conflicts with proxydns 2012-03-03 14:24:05 +08:00
Adam Hamsik fb3d8e04a1 Change example config version to 4. 2012-03-02 12:57:05 +01:00
rofl0r 03b49f529e fix bogus use of ! in configure 2012-01-30 18:35:03 +01:00
rofl0r e99dd76941 complete sysconfdir support 2012-01-30 18:29:35 +01:00
rofl0r 0ee539f31c added support for --sysconfdir 2012-01-30 18:26:38 +01:00
rofl0r f4e4c8c2b1 remove unnecessary sprintf call 2012-01-29 02:34:04 +01:00
Adam Hamsik 0938a940c5 Create install destionation directories first with install -d. 2012-01-28 23:10:40 +01:00
Adam Hamsik 788ffd9d26 Use standard PROXYCHAINS_CONF_FILE instead of hardcoded config name. 2012-01-28 19:51:23 +01:00
Adam Hamsik 99dcfe085e Change proxychains script to add different ways of usage.
To run a command from shell use
proxychains -f {config_file} {command}

To turn proxychains on for all processes inside your shell use
. proxychains on
. proxychains off
2012-01-28 19:47:56 +01:00
rofl0r dbb172b510 use PROXYCHAINS_CONF_FILE consistently 2012-01-28 18:34:40 +01:00
rofl0r 48373ab7a5 fix forgotten etc 2012-01-28 18:33:40 +01:00
Adam Hamsik 89e8bfddf4 Add etc/ to path where we search for config file. 2012-01-28 18:18:58 +01:00
Adam Hamsik adb13c7e79 Check for default config file in 2 locations /etc/ and {install_prefix}/etc. 2012-01-28 16:56:47 +01:00
Adam Hamsik 2250ef66a8 Make proxychains working on Mac OS X, build universal binaries to make older
versions of Mac OS X working. Make both proxychains shell script and proxychains program working.

Tested on my 10.7.3
2012-01-28 14:01:28 +01:00
Adam Hamsik e991cabb94 Merge rofl0r updates to bring both forks of proxychains to same base and to not diverge them more then they are now.
Merge branch 'master' of https://github.com/rofl0r/proxychains into rofl0r-master

Conflicts:
	Makefile
	src/core.c
	src/core.h
	src/libproxychains.c
	src/main.c
2012-01-28 00:16:53 +01:00
rofl0r 070051bb73 use macros for mutex stuff 2012-01-27 21:30:42 +01:00
rofl0r c36db11ebc complete mac support 2012-01-27 20:48:24 +01:00
rofl0r 6d25f5d89e allow dll suffix to be passed from ./configure 2012-01-27 20:30:44 +01:00
rofl0r 9c83402d37 detect MAC in configure 2012-01-27 20:21:06 +01:00
rofl0r 5b5cc604a6 remove dangerous uses of inet_ntoa 2012-01-27 20:00:22 +01:00
rofl0r 526fb8b410 pass dll_name to proxychains app, makes it easier to port to MAC 2012-01-27 19:31:01 +01:00
rofl0r 2acdcd9707 pass install prefix to proxychains app, to find /etc 2012-01-27 19:28:00 +01:00
rofl0r 3bb03892fa remove superfluous DEBUG checks 2012-01-27 19:14:17 +01:00
rofl0r e32ef26fec ran indent tool on the source code
now everythings finally correctly indented and future patches
will not be overshadowed by whitespace noise.
used the following settings
--braces-on-func-def-line
--braces-on-struct-decl-line
--braces-on-if-line
--dont-break-procedure-type
--leave-preprocessor-space
--continue-at-parentheses
-linux
-i8
-brace-indent1
--case-indentation8
--space-after-cast
--line-length120
--no-space-after-for
--no-space-after-if
--no-space-after-while
--leave-optional-blank-lines
--ignore-profile
--space-special-semicolon
--indent-label8
2012-01-27 19:03:21 +01:00
rofl0r 80817dbf6f fix *all* trailing whitespace at once 2012-01-27 17:55:37 +01:00
rofl0r 73c4195ce3 remove magic number 2012-01-27 17:50:04 +01:00
rofl0r cce902b301 eliminate dead code 2012-01-27 17:48:41 +01:00
Adam Hamsik d28cf03c61 Replace inet_ntoa which is not thread safe by re-entrant threadsafe inet_ntop. 2012-01-27 16:26:51 +01:00
Adam Hamsik 952a039801 Pull some fixes from proxychains sf forum. 2012-01-27 15:41:40 +01:00
Adam Hamsik 8d9bb5545c Check variable install/etc directory for proxychains config. Fix for #12 on github reported by sheepdestroyer. 2012-01-27 15:28:25 +01:00
Adam Hamsik f512779539 Replace homegrown pc_stringfromipv4 standard libc inet_ntoa, this should be available on all libcs (musl checked). Reenable accidentaly disabled THREAD_SAFE. 2012-01-27 14:35:00 +01:00
Adam Hamsik f53119773a remove cdefs.h from include, fix non THREAD_SAFE build, do some more PDEBUG cleanup. 2012-01-27 14:02:36 +01:00
Adam Hamsik 2f9a9cf0b0 Remove -Wextra which is unsupported on old gcc. 2012-01-26 16:41:48 +01:00
Adam Hamsik cdec339f11 Remove THREAD_SAFE ifdefs and use macros for it. Is there any reason to not require threads by default ? 2012-01-26 15:41:48 +01:00
Adam Hamsik fe8672eab6 Merge branch 'master' of github.com:haad/proxychains 2012-01-26 15:17:28 +01:00
Adam Hamsik d9341a8c74 Add some more code checking to CCFLAGS, remove unnecessary ifdef's 2012-01-26 15:17:12 +01:00
Adam Hamsik af5163bccf Merge pull request #9 from rofl0r/master
this fixes the getopt issue and makes the subnet for remote dns lookup a config option
2012-01-26 05:57:49 -08:00
rofl0r b618a4ece3 updated TODO 2012-01-26 13:25:48 +01:00
rofl0r 4da71e1b44 make remote_dns_subnet a config option 2012-01-26 12:44:42 +01:00
rofl0r 75d41dea3d use the right tool for the job. getopt clearly isnt 2012-01-26 05:11:52 +01:00
Adam Hamsik 75bd465038 Fix localnet issue with fix suggested in #issue 4 on github. 2012-01-24 08:42:04 +01:00
21 changed files with 1719 additions and 1211 deletions
+4 -1
View File
@@ -4,8 +4,11 @@
*.lo
.deps/
.libs/
.*
src/*.d
# Autoconf stuff
libtool
config.*
stamp-h
proxychains4
*.dylib
+16
View File
@@ -0,0 +1,16 @@
# Enable C support
language: c
# OS selection
os:
- linux
- osx
# Compiler selection
compiler:
- clang
- gcc
# Build steps
script:
- ./configure
- make
+13 -2
View File
@@ -1,5 +1,16 @@
original code
N3E7CR34TUR3.
http://proxychains.sourceforge.net
netcreature@users.sourceforge.net
web site: proxychains.sourceforge.net
email: netcreature@users.sourceforge.net
main.c, remote-dns, thread safety, bugfixes, build system, cleanups
rofl0r.
https://github.com/rofl0r/proxychains
localnet, bugfixes, macos x support, bsd support, packaging
adam hamsik.
https://github.com/haad/proxychains
localnet-port, bugfixes
jianing yang.
https://github.com/jianingy/proxychains
+21
View File
@@ -1,6 +1,27 @@
ProxyChains version history (public releases)
====================
ver 4.2
* Introduce BSD support make proxychains available on (NetBSD, FreeBSD ,OpenBSD and DragonFlyBSD)
* Update pkgsrc-wip proxychains package to 4.2.0 release and make easy to install and use
proxychains
-------------------------------------------------------------------------
ver 4.1
* Mac OS X support, create install script.
* thread-safe fixes by @rofl0r
-------------------------------------------------------------------------
ver 4.0
changed:
* Add a lot of fixes
* localnet-patch
* remote-dns
* thread-safe
-------------------------------------------------------------------------
ver 3.1
changed:
-13
View File
@@ -1,13 +0,0 @@
ProxyChains ver 3.1 Installation
=======================
If you have installed other ver of proxychains "make uninstall" before installing this distribution
unpack the .tar.gz , 'cd' to distribution directory and
run following commands (as root)
-------------------------------------
./configure
make
make install
-------------------------------------
that's all
+31 -18
View File
@@ -8,55 +8,68 @@
prefix = /usr/local
includedir = $(prefix)/include
libdir = $(prefix)/lib
confdir = $(prefix)/etc
exec_prefix = $(prefix)
bindir = $(exec_prefix)/bin
SRCS = $(sort $(wildcard src/*.c))
OBJS = $(SRCS:.c=.o)
LOBJS = src/core.o src/libproxychains.o
LOBJS = src/core.o src/common.o src/libproxychains.o
DEPS = $(OBJS:.o=.d)
CFLAGS += -Wall -O0 -g -std=c99 -D_GNU_SOURCE -pipe -DTHREAD_SAFE
LDFLAGS = -shared -fPIC -ldl -lpthread
INC =
CCFLAGS = -MD -Wall -O2 -g -std=c99 -D_GNU_SOURCE -pipe -DTHREAD_SAFE -Werror
LDFLAGS = -shared -fPIC
INC =
PIC = -fPIC
AR = $(CROSS_COMPILE)ar
RANLIB = $(CROSS_COMPILE)ranlib
LDSO_PATHNAME = libproxychains4.so
LDSO_SUFFIX = so
LD_SET_SONAME = -Wl
INSTALL_FLAGS = -D -m
-include config.mak
LDSO_PATHNAME = libproxychains4.$(LDSO_SUFFIX)
SHARED_LIBS = $(LDSO_PATHNAME)
ALL_LIBS = $(SHARED_LIBS)
PXCHAINS = proxychains4
ALL_TOOLS = $(PXCHAINS)
-include config.mak
CFLAGS+=$(USER_CFLAGS)
CFLAGS_MAIN=-DLIB_DIR=\"$(libdir)\"
CCFLAGS+=$(USER_CFLAGS) $(OS_CFLAGS)
LDFLAGS+=$(USER_LDFLAGS) $(OS_LDFLAGS)
CXXFLAGS+=$(CCFLAGS) $(USER_CFLAGS) $(OS_CFLAGS)
CFLAGS_MAIN=-DLIB_DIR=\"$(libdir)\" -DINSTALL_PREFIX=\"$(prefix)\" -DDLL_NAME=\"$(LDSO_PATHNAME)\" -DSYSCONFDIR=\"$(confdir)\"
all: $(ALL_LIBS) $(ALL_TOOLS)
#install: $(ALL_LIBS:lib/%=$(DESTDIR)$(libdir)/%) $(DESTDIR)$(LDSO_PATHNAME)
install:
install -D -m 755 $(ALL_TOOLS) $(bindir)/
install -D -m 644 $(ALL_LIBS) $(libdir)/
install -D -m 644 src/proxychains.conf $(prefix)/etc/
install:
install -d $(DESTDIR)/$(bindir) $(DESTDIR)/$(libdir) $(DESTDIR)/$(confdir) $(DESTDIR)/$(includedir)
install $(INSTALL_FLAGS) 755 $(ALL_TOOLS) $(DESTDIR)/$(bindir)/
install $(INSTALL_FLAGS) 644 $(ALL_LIBS) $(DESTDIR)/$(libdir)/
install-config:
install -d $(DESTDIR)/$(confdir)
install $(INSTALL_FLAGS) 644 src/proxychains.conf $(DESTDIR)/$(confdir)/
clean:
rm -f $(ALL_LIBS)
rm -f $(ALL_TOOLS)
rm -f $(OBJS)
rm -f $(DEPS)
%.o: %.c
$(CC) $(CFLAGS) $(CFLAGS_MAIN) $(INC) $(PIC) -c -o $@ $<
$(CC) $(CCFLAGS) $(CFLAGS_MAIN) $(INC) $(PIC) -c -o $@ $<
$(LDSO_PATHNAME): $(LOBJS)
$(CC) $(LDFLAGS) -Wl,-soname=$(LDSO_PATHNAME) -o $@ $(LOBJS)
$(CC) $(LDFLAGS) $(LD_SET_SONAME)$(LDSO_PATHNAME) -o $@ $(LOBJS)
$(ALL_TOOLS): $(OBJS)
$(CC) src/main.o -o $(PXCHAINS)
$(CC) src/main.o src/common.o -o $(PXCHAINS)
.PHONY: all clean install install-config
.PHONY: all clean install
-include $(DEPS)
-95
View File
@@ -1,95 +0,0 @@
ProxyChains ver 4.0 README
==========================
*********** ATTENTION ***********
this program works only on dynamically linked programs.
also both proxychains and the program to call must use
the same dynamic linker (i.e. same libc)
*********************************
This is Unix version only.
How to mess with sources - How to Install : read INSTALL !!!!!!
This program forces any tcp connection made by any given tcp client
to follow through proxy (or proxy chain). It is a kind of proxifier.
It acts like sockscap / permeo / eborder driver ( intercepts TCP calls )
It is FREE.
Changelog:
----------
Version (4.x) removes the dnsresolver script which required a dynamically
linked "dig" binary to be present with remote DNS lookup.
this speeds up any operation involving DNS, as the old script had to use TCP.
additionally it allows to use .onion urls when used with TOR.
also it removed the broken autoconf build system with a simple Makefile.
there's a ./configure script though for convenience.
it also adds support for a config file passed via command line switches/
environment variables.
Version (3.x) introduces support for DNS resolving through proxy
it supports SOCKS4, SOCKS5 and HTTP CONNECT proxy servers.
Auth-types: socks - "user/pass" , http - "basic".
When to use it ?
1) When the only way to get "outside" from your LAN is through proxy server.
2) To get out from behind restrictive firewall which filters outgoing ports.
3) To use two (or more) proxies in chain:
like: your_host <--> proxy1 <--> proxy2 <--> target_host
4) To "proxify" some program with no proxy support built-in (like telnet)
5) Access intranet from outside via proxy.
5) To use DNS behind proxy.
Some cool features:
* This program can mix different proxy types in the same chain
like: your_host <-->socks5 <--> http <--> socks4 <--> target_host
* Different chaining options supported
random order from the list ( user defined length of chain ).
exact order (as they appear in the list )
dynamic order (smart exclude dead proxies from chain)
* You can use it with any TCP client application, even network scanners
yes, yes - you can make portscan via proxy (or chained proxies)
for example with Nmap scanner by fyodor (www.insecire.org/nmap).
proxychains nmap -sT -PO -p 80 -iR (find some webservers through proxy)
* You can use it with servers, like squid, sendmail, or whatever.
* DNS resolving through proxy.
Configuration:
--------------
proxychains looks for config file in following order:
1) file listed in environment variable ${PROXYCHAINS_CONF_FILE} or
provided as a -f argument to proxychains script or binary.
2) ./proxychains.conf
3) $(HOME)/.proxychains/proxychains.conf
4) /etc/proxychains.conf **
**see more in /etc/proxychains.conf
Usage Example:
bash$ proxychains telnet targethost.com
in this example it will run telnet through proxy(or chained proxies)
specified by proxychains.conf
Usage Example:
bash$ proxychains -f /etc/proxychains-other.conf targethost2.com
in this example it will use different configuration file then proxychains.conf
to connect to targethost2.com host.
Usage Example:
bash$ proxyresolv targethost.com
in this example it will resolve targethost.com through proxy(or chained proxies)
specified by proxychains.conf
+172
View File
@@ -0,0 +1,172 @@
= ProxyChains ver. 4.3.0 README
image:https://travis-ci.org/haad/proxychains.svg?branch=master["Build Status", link="https://travis-ci.org/haad/proxychains"]
ProxyChains is a UNIX program, that hooks network-related libc functions
in dynamically linked programs via a preloaded DLL and redirects the
connections through SOCKS4a/5 or HTTP proxies.
WARNING: this program works only on dynamically linked programs.
also both proxychains and the program to call must use
the same dynamic linker (i.e. same libc)
== Known limitations of the current version
when a process forks, does a DNS lookup in the child, and then uses
the ip in the parent, the corresponding ip mapping will not be found,
this is because the fork can't write back into the parents mapping table.
IRSSI shows this behaviour, so you have to pass the resolved ip address
to it. (you can use the proxyresolv script (requires "dig") to do so)
this means that you can't currently use tor onion urls for irssi.
to solve this issue, an external data store (file, pipe, ...) has to
manage the dns <-> ip mapping. of course there has to be proper locking.
shm_open, mkstemp, are possible candidates for a file based approach,
the other option is to spawn some kind of server process that manages the
map lookups. since connect() etc are hooked, this must not be a TCP server.
I am reluctant on doing this change, because the described behaviour
seems pretty idiotic (doing a fork only for a DNS lookup), and irssi
is currently the only known affected program.
== Installation
=== Using release version
*Proxychains-4.3.0* are available with pkgsrc to everyone using it on _Linux_,
_NetBSD_, _FreeBSD_, _OpenBSD_, _DragonFlyBSD_ or _Mac OS X_. You just need to install
pkgsrc-wip repository and run
make install
in a wip/proxychains directory.
You can find out more about pkgsrc on link:http://www.pkgsrc.org[pkgsrc] and about pkgsrc-wip on
link:http://pkgsrc-wip.sourceforge.net[Pkgsrc-wip homepage]
=== Installing on Mac OS X with homebrew
You can install current proxychains on Mac OS X with an homebrew. You have to
download unofficial link:https://gist.github.com/3792521[homebrew formula] from
to your BREW_HOME by default /usr/local/Library/Formula/ and run
----
$ brew install proxychains
----
=== Running Current Source code version
----
# needs a working C compiler, preferably gcc
./configure
make
sudo make install
----
== Changelog
*Version (4.x)* removes the dnsresolver script which required a dynamically
linked "dig" binary to be present with remote DNS lookup.
this speeds up any operation involving DNS, as the old script had to use TCP.
additionally it allows to use .onion urls when used with TOR.
also it removed the broken autoconf build system with a simple Makefile.
there's a ./configure script though for convenience.
it also adds support for a config file passed via command line switches/
environment variables.
*Version (3.x)* introduces support for DNS resolving through proxy
it supports SOCKS4, SOCKS5 and HTTP CONNECT proxy servers.
* Auth-types
** socks - "user/pass",
** http - "basic"
== When to use it
* When the only way to get "outside" from your LAN is through proxy server.
* To get out from behind restrictive firewall which filters outgoing ports.
* To use two (or more) proxies in chain:
----
like: your_host <--> proxy1 <--> proxy2 <--> target_host
----
* To "proxify" some program with no proxy support built-in (like telnet)
* Access intranet from outside via proxy.
* To use DNS behind proxy.
=== Some cool features
* This program can mix different proxy types in the same chain
----
like: your_host <-->socks5 <--> http <--> socks4 <--> target_host
----
* Different chaining options supported
random order from the list ( user defined length of chain ).
exact order (as they appear in the list )
dynamic order (smart exclude dead proxies from chain)
* You can use it with any TCP client application, even network scanners
yes, yes - you can make portscan via proxy (or chained proxies)
for example with Nmap scanner by fyodor (www.insecure.org/nmap).
----
proxychains nmap -sT -PO -p 80 -iR (find some webservers through proxy)
----
* You can use it with servers, like squid, sendmail, or whatever.
* DNS resolving through proxy.
== Configuration
proxychains looks for configuration in the following order:
* SOCKS5 proxy port in environment variable ${PROXYCHAINS_SOCKS5}
(if set, no further configuration will be searched)
* file listed in environment variable ${PROXYCHAINS_CONF_FILE} or
provided as a -f argument to proxychains script or binary.
* ./proxychains.conf
* $(HOME)/.proxychains/proxychains.conf
* /etc/proxychains.conf
see more in */etc/proxychains.conf*
=== Usage Example
----
$ proxychains telnet targethost.com
----
in this example it will run telnet through proxy(or chained proxies)
specified by *proxychains.conf*
=== Usage Example
----
$ proxychains -f /etc/proxychains-other.conf targethost2.com
----
in this example it will use different configuration file then *proxychains.conf*
to connect to targethost2.com host.
=== Usage Example
----
$ proxyresolv targethost.com
----
in this example it will resolve targethost.com through proxy(or chained proxies)
specified by *proxychains.conf*
=== Usage Example:
----
$ ssh -fN -D 4321 some.example.com
$ PROXYCHAINS_SOCKS5=4321 proxychains zsh
----
in this example, it will run a shell with all traffic proxied through
OpenSSH's "dynamic proxy" (SOCKS5 proxy) on localhost port 4321.
=== Usage Example:
----
$ export PROXY_DNS_SERVER=8.8.8.8
$ proxychains telnet targethost.com
----
in this example, it will telnet to targethost.com using the 8.8.8.8
nameserver supplied by the user through the PROXY_DNS_SERVER
+1 -3
View File
@@ -1,8 +1,6 @@
ProxyChains ver 3.1 TODO
ProxyChains ver 4.0 TODO
===================
stable DNS resolver .... currently gnu dig is used, which is an ugly hack
also it is required to link it with the same libc as proxychains
hooks for reentrant dns functions, i.e. gethostbyaddr_r
Vendored
+68 -6
View File
@@ -1,6 +1,20 @@
#!/bin/sh
prefix=/usr/local
develflg=0
usage() {
echo "supported arguments"
echo "--prefix=/path default: $prefix"
echo "--exec_prefix=/path default: $prefix/bin"
echo "--bindir=/path default: $prefix/bin"
echo "--libdir=/path default: $prefix/lib"
echo "--includedir=/path default: $prefix/include"
echo "--sysconfdir=/path default: $prefix/etc"
echo "--devel default:no (set development mode)"
echo "--help : show this text"
exit 1
}
spliteq() {
arg=$1
@@ -11,14 +25,29 @@ spliteq() {
parsearg() {
case "$1" in
--prefix=*) prefix=$(spliteq "$1");;
--prefix=*) prefix=`spliteq $1`;;
--exec_prefix=*) exec_prefix=`spliteq $1`;;
--bindir=*) bindir=`spliteq $1`;;
--libdir=*) libdir=`spliteq $1`;;
--includedir=*) includedir=`spliteq $1`;;
--sysconfdir=*) sysconfdir=`spliteq $1`;;
--devel) develflg=1;;
--help) usage;;
esac
}
ismac() {
uname -s | grep Darwin
}
isbsd() {
uname -s | grep BSD
}
islinux() {
uname -s | grep Linux
}
while true ; do
case $1 in
-*) parsearg "$1"; shift;;
@@ -26,34 +55,67 @@ while true ; do
esac
done
if [ ! $exec_prefix ] ; then
if [ -z "$exec_prefix" ] ; then
exec_prefix=$prefix
fi
if [ ! $libdir ] ; then
if [ -z "$libdir" ] ; then
libdir=$prefix/lib
fi
if [ ! $includedir ] ; then
if [ -z "$includedir" ] ; then
includedir=$prefix/include
fi
if [ ! $bindir ] ; then
if [ -z "$sysconfdir" ] ; then
sysconfdir=$prefix/etc
fi
if [ -z "$bindir" ] ; then
bindir=$exec_prefix/bin
fi
if [ ! $CC ] ; then
if [ -z "$CC" ] ; then
CC=cc
fi
if [ $develflg -eq 1 ]; then
CFLAGS="-Wextra -Wunused -Wuninitialized -Wconversion -fno-common -g -O0"
fi
echo CC?=$CC>config.mak
[ -z "$CPPFLAGS" ] || echo CPPFLAGS?=$CPPFLAGS>>config.mak
[ -z "$CFLAGS" ] || echo USER_CFLAGS?=$CFLAGS>>config.mak
[ -z "$LDFLAGS" ] || echo USER_LDFLAGS?=$LDFLAGS>>config.mak
echo prefix=$prefix>>config.mak
echo exec_prefix=$exec_prefix>>config.mak
echo bindir=$bindir>>config.mak
echo libdir=$libdir>>config.mak
echo includedir=$includedir>>config.mak
echo sysconfdir=$sysconfdir>>config.mak
if ismac ; then
echo LDSO_SUFFIX=dylib>>config.mak
echo OS_CFLAGS+=-DIS_MAC=1 -arch x86_64 >>config.mak
echo OS_LDFLAGS+=-arch x86_64 -lpthread -ldl -Wl,>>config.mak
echo LD_SET_SONAME=-Wl,-install_name,>>config.mak
echo LDSO_SUFFIX=dylib>>config.mak
echo INSTALL_FLAGS=-m>>config.mak
fi
if islinux ; then
echo OS_LDFLAGS=-pthread -ldl -Wl,--no-as-needed>>config.mak
echo LD_SET_SONAME=-Wl,-soname= >>config.mak
fi
if isbsd ; then
#echo OS_LDFLAGS=
#echo OS_CFLAGS
echo INSTALL_FLAGS=-m>>config.mak
echo LD_SET_SONAME=-Wl,-rpath,$libdir -install_name,>>config.mak
fi
echo done, now run make \&\& make install
+8 -8
View File
@@ -1,14 +1,14 @@
Begin3
Title: ProxyChains
Version: 3.0
Entered-date:
Description:
Keywords:
Title: ProxyChains
Version: 4.0
Entered-date:
Description:
Keywords:
Author: <N37CR347UR3>
Maintained-by: <NetCreature>
Primary-site:
Maintained-by: <haad@netbsd.org>
Primary-site:
Home-page: http://proxychains.sourceforge.net
Original-site:
Original-site:
Platforms: Linux and other Unices
Copying-policy: GNU Public License
End
+53
View File
@@ -0,0 +1,53 @@
#include "common.h"
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
static int check_path(char *path) {
if(!path)
return 0;
return access(path, R_OK) != -1;
}
char *get_config_path(char* default_path, char* pbuf, size_t bufsize) {
char buf[512];
// top priority: user defined path
char *path = default_path;
if(check_path(path))
return path;
if (!pbuf)
goto err;
// priority 1: env var PROXYCHAINS_CONF_FILE
path = getenv(PROXYCHAINS_CONF_FILE_ENV_VAR);
if(check_path(path))
return path;
// priority 2; proxychains conf in actual dir
path = getcwd(buf, sizeof(buf));
snprintf(pbuf, bufsize, "%s/%s", path, PROXYCHAINS_CONF_FILE);
path = pbuf;
if(check_path(path))
return path;
// priority 3; $HOME/.proxychains/proxychains.conf
path = getenv("HOME");
snprintf(pbuf, bufsize, "%s/.proxychains/%s", path, PROXYCHAINS_CONF_FILE);
path = pbuf;
if(check_path(path))
return path;
// priority 4: $SYSCONFDIR/proxychains.conf
path = SYSCONFDIR "/" PROXYCHAINS_CONF_FILE;
if(check_path(path))
return path;
// priority 5: /etc/proxychains.conf
path = "/etc/" PROXYCHAINS_CONF_FILE;
if(check_path(path))
return path;
err:
perror("couldnt find configuration file");
exit(1);
}
+11
View File
@@ -1,4 +1,15 @@
#define PROXYCHAINS_CONF_FILE_ENV_VAR "PROXYCHAINS_CONF_FILE"
#define PROXYCHAINS_QUIET_MODE_ENV_VAR "PROXYCHAINS_QUIET_MODE"
#define PROXYCHAINS_CONF_FILE "proxychains.conf"
#define PROXYCHAINS_SOCKS5_PORT_ENV_VAR "PROXYCHAINS_SOCKS5_PORT"
#define PROXYCHAINS_SOCKS5_HOST_ENV_VAR "PROXYCHAINS_SOCKS5_HOST"
#define PROXYCHAINS_DNS_ENV_VAR "PROXYCHAINS_DNS"
#define LOG_PREFIX "[proxychains] "
#define PROXYCHAINS_VERSION_MAJOR 4
#define PROXYCHAINS_VERSION_MINOR 3
#define PROXYCHAINS_VERSION_BUGFIX 0
#include <stddef.h>
char *get_config_path(char* default_path, char* pbuf, size_t bufsize);
+614 -590
View File
File diff suppressed because it is too large Load Diff
+61 -54
View File
@@ -4,10 +4,8 @@
begin : Tue May 14 2002
copyright : netcreature (C) 2002
email : netcreature@users.sourceforge.net
***************************************************************************/
#include <stdint.h>
/* 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 *
@@ -15,10 +13,14 @@
* (at your option) any later version. *
* *
***************************************************************************/
#include <stdint.h>
#ifndef __CORE_HEADER
#define __CORE_HEADER
#define BUFF_SIZE 8*1024 // used to read responses from proxies.
#define MAX_LOCALNET 1024
#define MAX_LOCALNET 64
#define MAX_DNAT 64
typedef union {
unsigned char octet[4];
@@ -37,9 +39,20 @@ typedef struct {
} internal_ip_lookup_table;
extern internal_ip_lookup_table internal_ips;
#ifdef THREAD_SAFE
#include <pthread.h>
extern pthread_mutex_t internal_ips_lock;
extern pthread_mutex_t internal_getsrvbyname_lock;
# define MUTEX_LOCK(x) pthread_mutex_lock(x)
# define MUTEX_UNLOCK(x) pthread_mutex_unlock(x)
# define MUTEX_INIT(x,y) pthread_mutex_init(x, y)
#else
# define MUTEX_LOCK(x)
# define MUTEX_UNLOCK(x)
# define MUTEX_INIT(x,y)
#endif
/*error codes*/
@@ -52,9 +65,9 @@ typedef enum {
BLOCKED // target's port blocked on last proxy in the chain
} ERR_CODE;
typedef enum {
HTTP_TYPE,
RAW_TYPE,
SOCKS4_TYPE,
SOCKS5_TYPE
} proxy_type;
@@ -82,6 +95,11 @@ typedef struct {
unsigned short port;
} localaddr_arg;
typedef struct {
struct in_addr orig_dst, new_dst;
unsigned short orig_port, new_port;
} dnat_arg;
typedef struct {
ip_type ip;
unsigned short port;
@@ -91,61 +109,50 @@ typedef struct {
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,
ip_type target_ip,
unsigned short target_port,
proxy_data * pd,
unsigned int proxy_count,
chain_type ct,
unsigned int max_chain );
int proxychains_write_log(char *str,...);
struct hostent* proxy_gethostbyname(const char *name);
int connect_proxy_chain (int, ip_type, unsigned short, proxy_data *, unsigned int,
chain_type, unsigned int);
void proxychains_write_log(char *, ...);
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;
#if (defined __linux__) || (defined __APPLE__)
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);
#ifdef DEBUG
# define PDEBUG(fmt, args...) fprintf(stderr,"DEBUG:"fmt, ## args)
#else
# define PDEBUG(fmt, args...)
typedef struct hostent *(*gethostbyaddr_t) (const char *, socklen_t, int);
#endif
#endif
typedef int (*getaddrinfo_t)(const char *, const char *, const struct addrinfo *,
struct addrinfo **);
typedef int (*getnameinfo_t) (const struct sockaddr *, socklen_t, char *,
socklen_t, char *, socklen_t, int);
extern connect_t true_connect;
extern gethostbyname_t true_gethostbyname;
extern getaddrinfo_t true_getaddrinfo;
extern freeaddrinfo_t true_freeaddrinfo;
extern getnameinfo_t true_getnameinfo;
extern gethostbyaddr_t true_gethostbyaddr;
struct gethostbyname_data {
struct hostent hostent_space;
in_addr_t resolved_addr;
char *resolved_addr_p[2];
char addr_name[1024 * 8];
};
struct hostent* proxy_gethostbyname(const char *, struct gethostbyname_data *);
void proxy_getservbyname(const char *, struct servent *, char *, size_t, struct servent **);
int proxy_getaddrinfo(const char *, const char *, const struct addrinfo *, struct addrinfo **);
void proxy_freeaddrinfo(struct addrinfo *);
#ifdef DEBUG
# define PDEBUG(fmt, args...) do { fprintf(stderr,"DEBUG:"fmt, ## args); fflush(stderr); } while(0)
#else
# define PDEBUG(fmt, args...) do {} while (0)
#endif
#endif
+398 -315
View File
@@ -18,20 +18,21 @@
#undef _GNU_SOURCE
#define _GNU_SOURCE
#include <sys/types.h>
#include <sys/param.h>
#include <dlfcn.h>
#include <errno.h>
#include <fcntl.h>
#include <netdb.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <netdb.h>
#include <unistd.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"
#include "common.h"
@@ -41,260 +42,316 @@
#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
#define MAX_CHAIN 512
connect_t true_connect;
gethostbyname_t true_gethostbyname;
getaddrinfo_t true_getaddrinfo;
freeaddrinfo_t true_freeaddrinfo;
getnameinfo_t true_getnameinfo;
gethostbyaddr_t true_gethostbyaddr;
int tcp_read_time_out;
int tcp_connect_time_out;
chain_type proxychains_ct;
proxy_data proxychains_pd[MAX_CHAIN];
unsigned int proxychains_proxy_count = 0;
int proxychains_got_chain_data = 0;
unsigned int proxychains_max_chain = 1;
int proxychains_quiet_mode = 0;
int proxychains_resolver = 0;
static int init_l = 0;
unsigned int proxychains_proxy_count = 0;
unsigned int proxychains_max_chain = 1;
unsigned int remote_dns_subnet = 224;
localaddr_arg localnet_addr[MAX_LOCALNET];
chain_type proxychains_ct;
proxy_data proxychains_pd[MAX_CHAIN];
size_t num_localnet_addr = 0;
dnat_arg dnats[MAX_DNAT];
size_t num_dnats = 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)
{
#ifdef THREAD_SAFE
pthread_mutex_init(&internal_ips_lock, NULL);
pthread_once_t init_once = PTHREAD_ONCE_INIT;
#endif
/* read the config file */
get_chain_data(proxychains_pd, &proxychains_proxy_count, &proxychains_ct);
proxychains_write_log(LOG_PREFIX "DLL init\n");
true_connect = (connect_t) dlsym(RTLD_NEXT, "connect");
static int init_l = 0;
if (!true_connect) {
fprintf(stderr, "Cannot load symbol 'connect' %s\n", dlerror());
static void load_default_settings(chain_type *ct);
static inline void get_chain_data(proxy_data * pd, unsigned int *proxy_count, chain_type * ct);
static void simple_socks5_env(proxy_data * pd, unsigned int *proxy_count, chain_type * ct);
static void* load_sym(char* symname, void* proxyfunc) {
void *funcptr = dlsym(RTLD_NEXT, symname);
if(!funcptr) {
fprintf(stderr, "Cannot load symbol '%s' %s\n", symname, dlerror());
exit(1);
} else {
#ifdef DEBUG
PDEBUG( "loaded symbol 'connect'"
" real addr %p wrapped addr %p\n",
true_connect, connect);
#endif
PDEBUG("loaded symbol '%s'" " real addr %p wrapped addr %p\n", symname, funcptr, proxyfunc);
}
if(connect==true_connect) {
#ifdef DEBUG
if(funcptr == proxyfunc) {
PDEBUG("circular reference detected, aborting!\n");
#endif
abort();
}
true_gethostbyname = (gethostbyname_t)
dlsym(RTLD_NEXT, "gethostbyname");
return funcptr;
}
if (!true_gethostbyname) {
fprintf(stderr, "Cannot load symbol 'gethostbyname' %s\n",
dlerror());
exit(1);
} else {
#ifdef DEBUG
PDEBUG( "loaded symbol 'gethostbyname'"
" real addr %p wrapped addr %p\n",
true_gethostbyname, gethostbyname);
#endif
}
true_getaddrinfo = (getaddrinfo_t)
dlsym(RTLD_NEXT, "getaddrinfo");
#define INIT() init_lib_wrapper(__FUNCTION__)
if (!true_getaddrinfo) {
fprintf(stderr, "Cannot load symbol 'getaddrinfo' %s\n",
dlerror());
exit(1);
} else {
#ifdef DEBUG
PDEBUG( "loaded symbol 'getaddrinfo'"
" real addr %p wrapped addr %p\n",
true_getaddrinfo, getaddrinfo);
#endif
}
true_freeaddrinfo = (freeaddrinfo_t)
dlsym(RTLD_NEXT, "freeaddrinfo");
#define SETUP_SYM(X) do { true_ ## X = load_sym( # X, X ); } while(0)
if (!true_freeaddrinfo) {
fprintf(stderr, "Cannot load symbol 'freeaddrinfo' %s\n",
dlerror());
exit(1);
} else {
#ifdef DEBUG
PDEBUG( "loaded symbol 'freeaddrinfo'"
" real addr %p wrapped addr %p\n",
true_freeaddrinfo, freeaddrinfo);
#endif
}
true_gethostbyaddr = (gethostbyaddr_t)
dlsym(RTLD_NEXT, "gethostbyaddr");
static void do_init(void) {
MUTEX_INIT(&internal_ips_lock, NULL);
if (!true_gethostbyaddr) {
fprintf(stderr, "Cannot load symbol 'gethostbyaddr' %s\n",
dlerror());
exit(1);
} else {
#ifdef DEBUG
PDEBUG( "loaded symbol 'gethostbyaddr'"
" real addr %p wrapped addr %p\n",
true_gethostbyaddr, gethostbyaddr);
#endif
}
true_getnameinfo = (getnameinfo_t)
dlsym(RTLD_NEXT, "getnameinfo");
#ifdef __APPLE__
MUTEX_INIT(&internal_getsrvbyname_lock, NULL);
#endif
if (!true_getnameinfo) {
fprintf(stderr, "Cannot load symbol 'getnameinfo' %s\n",
dlerror());
exit(1);
} else {
#ifdef DEBUG
PDEBUG( "loaded symbol 'getnameinfo'"
" real addr %p wrapped addr %p\n",
true_getnameinfo, getnameinfo);
#endif
}
/* check for simple SOCKS5 proxy setup */
simple_socks5_env(proxychains_pd, &proxychains_proxy_count, &proxychains_ct);
/* read the config file */
get_chain_data(proxychains_pd, &proxychains_proxy_count, &proxychains_ct);
proxychains_write_log(LOG_PREFIX "DLL init\n");
SETUP_SYM(connect);
SETUP_SYM(gethostbyname);
SETUP_SYM(getaddrinfo);
SETUP_SYM(freeaddrinfo);
SETUP_SYM(gethostbyaddr);
SETUP_SYM(getnameinfo);
init_l = 1;
}
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];
static void init_lib_wrapper(const char* caller) {
#ifndef DEBUG
(void) caller;
#endif
#ifndef THREAD_SAFE
if(init_l) return;
PDEBUG("%s called from %s\n", __FUNCTION__, caller);
do_init();
#else
if(!init_l) PDEBUG("%s called from %s\n", __FUNCTION__, caller);
pthread_once(&init_once, do_init);
#endif
}
/* if we use gcc >= 3, we can instruct the dynamic loader
* to call init_lib at link time. otherwise it gets loaded
* lazily, which has the disadvantage that there's a potential
* race condition if 2 threads call it before init_l is set
* and PTHREAD support was disabled */
#if __GNUC__ > 2
__attribute__((constructor))
static void gcc_init(void) {
INIT();
}
#endif
FILE *
open_config_file() {
char home_conf[MAXPATHLEN], prefix_conf[MAXPATHLEN];
FILE *file;
snprintf(home_conf, 256, "%s/.proxychains/proxychains.conf", getenv("HOME"));
snprintf(prefix_conf, 256, "%s/etc/proxychains.conf", INSTALL_PREFIX);
if(!(file = fopen("./proxychains.conf", "r"))) {
if(!(file = fopen(home_conf, "r"))) {
if(!(file = fopen(prefix_conf, "r"))) {
if(!(file = fopen("/etc/proxychains.conf", "r"))) {
perror("Can't locate proxychains.conf");
exit(1);
}
}
}
}
return file;
}
/* default settings common to get_chain_data and simple_socks5_env */
static void load_default_settings(chain_type *ct) {
char *env;
tcp_read_time_out = 4 * 1000;
tcp_connect_time_out = 10 * 1000;
*ct = DYNAMIC_TYPE;
env = getenv(PROXYCHAINS_QUIET_MODE_ENV_VAR);
if(env && *env == '1')
proxychains_quiet_mode = 1;
}
/* get configuration from config file */
static void get_chain_data(proxy_data * pd, unsigned int *proxy_count, chain_type * ct) {
unsigned int count = 0;
int 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;
char dnat_orig_addr_port[32], dnat_new_addr_port[32];
char dnat_orig_addr[32], dnat_orig_port[32], dnat_new_addr[32], dnat_new_port[32];
FILE *file = NULL;
if(proxychains_got_chain_data)
return;
return;
//Some defaults
tcp_read_time_out = 4*1000;
tcp_connect_time_out = 10*1000;
*ct = DYNAMIC_TYPE;
load_default_settings(ct);
/*
* Get path to configuration file from env this file has priority
* if it's defined.
*/
env = getenv(PROXYCHAINS_CONF_FILE_ENV_VAR);
env = get_config_path(getenv(PROXYCHAINS_CONF_FILE_ENV_VAR), buff, sizeof(buff));
file = fopen(env, "r");
snprintf(buff,256,"%s/.proxychains/proxychains.conf",getenv("HOME"));
if(!env || (!(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);
}
env = getenv(PROXYCHAINS_QUIET_MODE_ENV_VAR);
if(env && *env == '1') proxychains_quiet_mode = 1;
while(fgets(buff,sizeof(buff),file)) {
if(buff[0] != '\n' && buff[strspn(buff," ")]!='#') {
while(fgets(buff, sizeof(buff), file)) {
if(buff[0] != '\n' && buff[strspn(buff, " ")] != '#') {
/* proxylist has to come last */
if(list) {
if(count >= MAX_CHAIN)
break;
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);
sscanf(buff, "%s %s %d %s %s", type, host, &port_n, pd[count].user, pd[count].pass);
pd[count].ip.as_int = (uint32_t) inet_addr(host);
pd[count].port = htons((unsigned short)port_n);
if(!strcmp(type,"http")) {
pd[count].port = htons((unsigned short) port_n);
if(!strcmp(type, "http")) {
pd[count].pt = HTTP_TYPE;
} else if(!strcmp(type,"socks4")) {
} else if(!strcmp(type, "raw")) {
pd[count].pt = RAW_TYPE;
} else if(!strcmp(type, "socks4")) {
pd[count].pt = SOCKS4_TYPE;
} else if(!strcmp(type,"socks5")) {
} else if(!strcmp(type, "socks5")) {
pd[count].pt = SOCKS5_TYPE;
} else
} else
continue;
if(pd[count].ip.as_int && port_n &&
pd[count].ip.as_int != (uint32_t) -1)
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) {
if(pd[count].ip.as_int && port_n && pd[count].ip.as_int != (uint32_t) - 1)
count++;
} 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, "remote_dns_subnet")) {
sscanf(buff, "%s %d", user, &remote_dns_subnet);
if(remote_dns_subnet >= 256) {
fprintf(stderr,
"remote_dns_subnet: invalid value. requires a number between 0 and 255.\n");
exit(1);
}
} 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]));
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);
if(sscanf(local_in_addr_port, "%15[^:]:%5s", local_in_addr, local_in_port) < 2) {
PDEBUG("added localnet: netaddr=%s, netmask=%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);
PDEBUG("added localnet: netaddr=%s, port=%s, netmask=%s\n",
local_in_addr, local_in_port, local_netmask);
}
if (num_localnet_addr < MAX_LOCALNET)
{
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)
{
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)
{
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);
if(local_in_port[0]) {
localnet_addr[num_localnet_addr].port =
(unsigned short) atoi(local_in_port);
} else {
localnet_addr[num_localnet_addr].port = 0;
}
++num_localnet_addr;
}
else
{
} 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;
} else if(strstr(buff, "chain_len")) {
char *pc;
int len;
pc = strchr(buff, '=');
len = atoi(++pc);
proxychains_max_chain = (unsigned int) (len ? len : 1);
} else if(strstr(buff, "quiet_mode")) {
proxychains_quiet_mode = 1;
} else if(strstr(buff, "proxy_dns")) {
proxychains_resolver = 1;
} else if(strstr(buff, "dnat")) {
if(sscanf(buff, "%s %21[^ ] %21s\n", user, dnat_orig_addr_port, dnat_new_addr_port) < 3) {
fprintf(stderr, "dnat format error");
exit(1);
}
/* clean previously used buffer */
memset(dnat_orig_port, 0, sizeof(dnat_orig_port) / sizeof(dnat_orig_port[0]));
memset(dnat_new_port, 0, sizeof(dnat_new_port) / sizeof(dnat_new_port[0]));
(void)sscanf(dnat_orig_addr_port, "%15[^:]:%5s", dnat_orig_addr, dnat_orig_port);
(void)sscanf(dnat_new_addr_port, "%15[^:]:%5s", dnat_new_addr, dnat_new_port);
if(num_dnats < MAX_DNAT) {
int error;
error =
inet_pton(AF_INET, dnat_orig_addr,
&dnats[num_dnats].orig_dst);
if(error <= 0) {
fprintf(stderr, "dnat original destination address error\n");
exit(1);
}
error =
inet_pton(AF_INET, dnat_new_addr,
&dnats[num_dnats].new_dst);
if(error <= 0) {
fprintf(stderr, "dnat effective destination address error\n");
exit(1);
}
if(dnat_orig_port[0]) {
dnats[num_dnats].orig_port =
(short) atoi(dnat_orig_port);
} else {
dnats[num_dnats].orig_port = 0;
}
if(dnat_new_port[0]) {
dnats[num_dnats].new_port =
(short) atoi(dnat_new_port);
} else {
dnats[num_dnats].new_port = 0;
}
PDEBUG("added dnat: orig-dst=%s orig-port=%d new-dst=%s new-port=%d\n", dnat_orig_addr, dnats[num_dnats].orig_port, dnat_new_addr, dnats[num_dnats].new_port);
++num_dnats;
} else {
fprintf(stderr, "# of dnat exceed %d.\n", MAX_DNAT);
}
}
}
}
@@ -304,190 +361,217 @@ static inline void get_chain_data(
proxychains_got_chain_data = 1;
}
static void simple_socks5_env(proxy_data *pd, unsigned int *proxy_count, chain_type *ct) {
char *port_string;
char *host_string;
if(proxychains_got_chain_data)
return;
int connect (int sock, const struct sockaddr *addr, unsigned int len)
{
int socktype=0, flags=0, ret=0;
load_default_settings(ct);
port_string = getenv(PROXYCHAINS_SOCKS5_PORT_ENV_VAR);
if(!port_string)
return;
host_string = getenv(PROXYCHAINS_SOCKS5_HOST_ENV_VAR);
if(!host_string)
host_string = "127.0.0.1";
memset(pd, 0, sizeof(proxy_data));
pd[0].ps = PLAY_STATE;
pd[0].ip.as_int = (uint32_t) inet_addr(host_string);
pd[0].port = htons((unsigned short) strtol(port_string, NULL, 0));
pd[0].pt = SOCKS5_TYPE;
proxychains_max_chain = 1;
if(getenv(PROXYCHAINS_DNS_ENV_VAR))
proxychains_resolver = 1;
*proxy_count = 1;
proxychains_got_chain_data = 1;
}
/******* HOOK FUNCTIONS *******/
int connect(int sock, const struct sockaddr *addr, socklen_t len) {
int socktype = 0, flags = 0, ret = 0;
socklen_t optlen = 0;
ip_type dest_ip;
#ifdef DEBUG
char str[256];
#endif
struct in_addr *p_addr_in;
struct sockaddr_in new_addr;
dnat_arg *dnat = NULL;
unsigned short port;
size_t i;
int remote_dns_connect = 0;
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);
INIT();
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);
p_addr_in = &((struct sockaddr_in *) addr)->sin_addr;
port = ntohs(((struct sockaddr_in *) addr)->sin_port);
#ifdef DEBUG
// 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("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);
#endif
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) {
// check if connect called from proxydns
remote_dns_connect = (ntohl(p_addr_in->s_addr) >> 24 == remote_dns_subnet);
// more specific first
for(i = 0; i < num_dnats && !remote_dns_connect && !dnat; i++)
if(dnats[i].orig_dst.s_addr == p_addr_in->s_addr)
if(dnats[i].orig_port && (dnats[i].orig_port == port))
dnat = &dnats[i];
for(i = 0; i < num_dnats && !remote_dns_connect && !dnat; i++)
if(dnats[i].orig_dst.s_addr == p_addr_in->s_addr)
if(!dnats[i].orig_port)
dnat = &dnats[i];
if (dnat) {
if (dnat->new_port)
new_addr.sin_port = htons(dnat->new_port);
else
new_addr.sin_port = htons(port);
new_addr.sin_addr = dnat->new_dst;
addr = (struct sockaddr *)&new_addr;
p_addr_in = &((struct sockaddr_in *) addr)->sin_addr;
port = ntohs(((struct sockaddr_in *) addr)->sin_port);
}
for(i = 0; i < num_localnet_addr && !remote_dns_connect; 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);
return true_connect(sock, addr, len);
}
}
}
flags = fcntl(sock, F_GETFL, 0);
if(flags & O_NONBLOCK)
fcntl(sock, F_SETFL, !O_NONBLOCK);
fcntl(sock, F_SETFL, !O_NONBLOCK);
dest_ip.as_int = SOCKADDR(*addr);
ret = connect_proxy_chain(
sock,
dest_ip,
SOCKPORT(*addr),
proxychains_pd,
proxychains_proxy_count,
proxychains_ct,
proxychains_max_chain );
ret = connect_proxy_chain(sock,
dest_ip,
SOCKPORT(*addr),
proxychains_pd, proxychains_proxy_count, proxychains_ct, proxychains_max_chain);
fcntl(sock, F_SETFL, flags);
if(ret != SUCCESS)
errno = ECONNREFUSED;
errno = ECONNREFUSED;
return ret;
}
struct hostent *gethostbyname(const char *name)
{
if(!init_l)
init_lib();
PDEBUG("gethostbyname: %s\n",name);
static struct gethostbyname_data ghbndata;
struct hostent *gethostbyname(const char *name) {
INIT();
PDEBUG("gethostbyname: %s\n", name);
if(proxychains_resolver)
return proxy_gethostbyname(name);
return proxy_gethostbyname(name, &ghbndata);
else
return true_gethostbyname(name);
return NULL;
}
int getaddrinfo(const char *node, const char *service,
const struct addrinfo *hints,
struct addrinfo **res)
{
int getaddrinfo(const char *node, const char *service, const struct addrinfo *hints, struct addrinfo **res) {
int ret = 0;
if(!init_l)
init_lib();
PDEBUG("getaddrinfo: %s %s\n",node ,service);
INIT();
PDEBUG("getaddrinfo: %s %s\n", node, service);
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)
{
if(!init_l)
init_lib();
PDEBUG("freeaddrinfo %p \n",res);
void freeaddrinfo(struct addrinfo *res) {
INIT();
PDEBUG("freeaddrinfo %p \n", res);
if(!proxychains_resolver)
true_freeaddrinfo(res);
else {
free(res->ai_addr);
free(res);
}
else
proxy_freeaddrinfo(res);
return;
}
// work around a buggy prototype in GLIBC. according to the bugtracker it has been fixed in git at 02 May 2011.
// 2.14 came out in June 2011 so that should be the first fixed version
#if defined(__GLIBC__) && (__GLIBC__ < 3) && (__GLIBC_MINOR__ < 14)
int getnameinfo (const struct sockaddr * sa,
socklen_t salen, char * host,
socklen_t hostlen, char * serv,
socklen_t servlen, unsigned int flags)
int getnameinfo(const struct sockaddr *sa,
socklen_t salen, char *host, socklen_t hostlen, char *serv, socklen_t servlen, unsigned int flags)
#else
int getnameinfo (const struct sockaddr * sa,
socklen_t salen, char * host,
socklen_t hostlen, char * serv,
socklen_t servlen, int flags)
int getnameinfo(const struct sockaddr *sa,
socklen_t salen, char *host, socklen_t hostlen, char *serv, socklen_t servlen, int flags)
#endif
{
char ip_buf[16];
int ret = 0;
if(!init_l)
init_lib();
INIT();
PDEBUG("getnameinfo: %s %s\n", host, serv);
if(!proxychains_resolver) {
ret = true_getnameinfo(sa,salen,host,hostlen,
serv,servlen,flags);
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)));
if(hostlen) {
inet_ntop(AF_INET, (unsigned char*) &(SOCKADDR_2(*sa)), ip_buf, sizeof(ip_buf));
strncpy(host, ip_buf, hostlen);
}
if(servlen)
snprintf(serv, servlen, "%d", ntohs(SOCKPORT(*sa)));
}
return ret;
}
// stolen from libulz (C) rofl0r
static void pc_stringfromipv4(unsigned char* ip_buf_4_bytes, char* outbuf_16_bytes) {
unsigned char* p;
char *o = outbuf_16_bytes;
unsigned char n;
for(p = ip_buf_4_bytes; p < ip_buf_4_bytes + 4; p++) {
n = *p;
if(*p >= 100) {
if(*p >= 200) *(o++) = '2';
else *(o++) = '1';
n %= 100;
}
if(*p >= 10) {
*(o++) = (n / 10) + '0';
n %= 10;
}
*(o++) = n + '0';
*(o++) = '.';
}
o[-1] = 0;
}
struct hostent *gethostbyaddr (const void *addr, socklen_t len, int type)
{
#if (defined __linux__) || (defined __APPLE__)
struct hostent *gethostbyaddr(const void *addr, socklen_t len, int type) {
#else
struct hostent *gethostbyaddr(const char *addr, socklen_t len, int type) {
#endif
static char buf[16];
static char ipv4[4];
static char* list[2];
static char *list[2];
static struct hostent he;
if(!init_l)
init_lib();
INIT();
PDEBUG("TODO: proper gethostbyaddr hook\n");
if(!proxychains_resolver)
return true_gethostbyaddr(addr,len,type);
return true_gethostbyaddr(addr, len, type);
else {
PDEBUG("len %u\n", len);
if(len != 4) return NULL;
if(len != 4)
return NULL;
he.h_name = buf;
memcpy(ipv4, addr, 4);
list[0] = ipv4;
@@ -496,9 +580,8 @@ struct hostent *gethostbyaddr (const void *addr, socklen_t len, int type)
he.h_addrtype = AF_INET;
he.h_aliases = NULL;
he.h_length = 4;
pc_stringfromipv4((unsigned char*)addr, buf);
inet_ntop(AF_INET, addr, buf, sizeof(buf));
return &he;
}
return NULL;
}
+60 -88
View File
@@ -1,12 +1,4 @@
/***************************************************************************
main.c - description
begin : Tue May 14 2002
copyright : netcreature (C) 2002
email : netcreature@users.sourceforge.net
***************************************************************************/
/* GPL */
/***************************************************************************
/* (C) 2011, 2012 rofl0r
* *
* 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 *
@@ -14,42 +6,38 @@
* (at your option) any later version. *
* *
***************************************************************************/
#undef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 200809L
#undef _XOPEN_SOURCE
#define _XOPEN_SOURCE 700
#include <sys/types.h>
#include <sys/param.h>
#include <errno.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
extern char *optarg;
extern int optind, opterr, optopt;
#include <sys/wait.h>
#include "common.h"
static int usage(char** argv) {
printf( "\nUsage:\t%s -q -f config_file program_name [arguments]\n"
"\t-q makes proxychains quiet - this overrides the config setting\n"
"\t-t allows to manually specify a configfile to use\n"
"\tfor example : proxychains telnet somehost.com\n"
"More help in README file\n\n", argv[0]);
static int usage(char **argv) {
printf("\nUsage:\t%s -q -f config_file program_name [arguments]\n"
"\t-q makes proxychains quiet - this overrides the config setting\n"
"\t-f allows to manually specify a configfile to use\n"
"\tfor example : proxychains telnet somehost.com\n" "More help in README file\n\n", argv[0]);
return EXIT_FAILURE;
}
int check_path(char* path) {
if(!path) return 0;
return access(path, R_OK) != -1;
}
static const char* dll_name = "libproxychains4.so";
static const char *dll_name = DLL_NAME;
static char own_dir[256];
static const char* dll_dirs[] = {
".",
static const char *dll_dirs[] = {
//".",
own_dir,
LIB_DIR,
"/lib",
@@ -59,87 +47,64 @@ static const char* dll_dirs[] = {
NULL
};
static void set_own_dir(const char* argv0) {
static void set_own_dir(const char *argv0) {
size_t l = strlen(argv0);
while(l && argv0[l - 1] != '/') l--;
while(l && argv0[l - 1] != '/')
l--;
if(l == 0)
memcpy(own_dir, ".", 2);
//memcpy(own_dir, ".", 2);
memcpy(own_dir, "/dev/null/", 2);
else {
memcpy(own_dir, argv0, l - 1);
own_dir[l] = 0;
}
}
#define MAX_COMMANDLINE_FLAGS 2
int main(int argc, char *argv[]) {
char *path = NULL;
char buf[256];
char pbuf[256];
int opt;
char buf[PATH_MAX];
char pbuf[PATH_MAX];
int start_argv = 1;
int quiet = 0;
if(argc == 1) return usage(argv);
size_t i;
while ((opt = getopt(argc, argv, "qf:")) != -1) {
switch (opt) {
case 'q':
const char *prefix = NULL;
for(i = 0; i < MAX_COMMANDLINE_FLAGS; i++) {
if(start_argv < argc && argv[start_argv][0] == '-') {
if(argv[start_argv][1] == 'q') {
quiet = 1;
start_argv++;
break;
case 'f':
path = (char *)optarg;
if(!path) {
fprintf(stderr, "error: no path supplied.\n");
return EXIT_FAILURE;
}
} else if(argv[start_argv][1] == 'f') {
if(start_argv + 1 < argc)
path = argv[start_argv + 1];
else
return usage(argv);
start_argv += 2;
break;
default: /* '?' */
return usage(argv);
}
} else
break;
}
if(start_argv >= argc) return usage(argv);
if(start_argv >= argc)
return usage(argv);
/* check if path of config file has not been passed via command line */
if(!path) {
// priority 1: env var PROXYCHAINS_CONF_FILE
path = getenv(PROXYCHAINS_CONF_FILE_ENV_VAR);
if(check_path(path)) goto have;
// priority 2; proxychains conf in actual dir
path = getcwd(buf, sizeof(buf));
snprintf(pbuf, sizeof(pbuf), "%s/%s", path, PROXYCHAINS_CONF_FILE);
path = pbuf;
if(check_path(path)) goto have;
// priority 3; $HOME/.proxychains/proxychains.conf
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");
return 1;
}
have:
if(!quiet) fprintf(stderr, LOG_PREFIX "config file found: %s\n", path);
path = get_config_path(path, pbuf, sizeof(pbuf));
if(!quiet)
fprintf(stderr, LOG_PREFIX "config file found: %s\n", path);
/* Set PROXYCHAINS_CONF_FILE to get proxychains lib to use new config file. */
setenv(PROXYCHAINS_CONF_FILE_ENV_VAR, path, 1);
if(quiet) setenv(PROXYCHAINS_QUIET_MODE_ENV_VAR, "1", 1);
if(quiet)
setenv(PROXYCHAINS_QUIET_MODE_ENV_VAR, "1", 1);
// search DLL
size_t i = 0;
const char* prefix = NULL;
set_own_dir(argv[0]);
while(dll_dirs[i]) {
@@ -155,11 +120,18 @@ int main(int argc, char *argv[]) {
fprintf(stderr, "couldnt locate %s\n", dll_name);
return EXIT_FAILURE;
}
if(!quiet) fprintf(stderr, LOG_PREFIX "preloading %s/%s\n", prefix, dll_name);
snprintf(buf, sizeof(buf), "LD_PRELOAD=%s/%s", prefix, dll_name);
putenv(buf);
if(!quiet)
fprintf(stderr, LOG_PREFIX "preloading %s/%s\n", prefix, dll_name);
#ifndef IS_MAC
snprintf(buf, sizeof(buf), "%s/%s", prefix, dll_name);
setenv("LD_PRELOAD", buf, 1);
#else
snprintf(buf, sizeof(buf), "%s/%s", prefix, dll_name);
setenv("DYLD_INSERT_LIBRARIES", buf, 1);
setenv("DYLD_FORCE_FLAT_NAMESPACE", "1", 1);
#endif
execvp(argv[start_argv], &argv[start_argv]);
perror("proxychains can't load process....");
+93 -13
View File
@@ -1,26 +1,106 @@
#!/bin/sh
echo "ProxyChains-3.1 (http://proxychains.sf.net)"
echo "ProxyChains-4.0 (https://github.com/haad/proxychains)"
usage() {
echo " usage:"
echo " $0 [h] [f config-file] <prog> [args]"
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
if [ $1 = "-h" ]; 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
if [ "$1" = "-f" ]; then
export PROXYCHAINS_CONF_FILE=$2;
shift;
shift;
fi
export LD_PRELOAD=libproxychains.so.3
exec "$@"
case "$1" in
on)
setup_proxy_env
show_proxy_env
;;
off)
disable_proxy_env
show_proxy_env
;;
*)
setup_proxy_env
exec "$@"
;;
esac
+44 -3
View File
@@ -1,4 +1,4 @@
# proxychains.conf VER 3.1
# proxychains.conf VER 4
#
# HTTP, SOCKS4, SOCKS5 tunneling proxifier with DNS.
#
@@ -37,10 +37,32 @@ strict_chain
# Proxy DNS requests - no leak for DNS data
proxy_dns
# set the class A subnet number to usefor use of the internal remote DNS mapping
# we use the reserved 224.x.x.x range by default,
# if the proxified app does a DNS request, we will return an IP from that range.
# on further accesses to this ip we will send the saved DNS name to the proxy.
# in case some control-freak app checks the returned ip, and denies to
# connect, you can use another subnet, e.g. 10.x.x.x or 127.x.x.x.
# of course you should make sure that the proxified app does not need
# *real* access to this subnet.
# i.e. dont use the same subnet then in the localnet section
#remote_dns_subnet 127
#remote_dns_subnet 10
remote_dns_subnet 224
# Some timeouts in milliseconds
tcp_read_time_out 15000
tcp_connect_time_out 8000
# By default enable localnet for loopback address ranges
# RFC5735 Loopback address range
localnet 127.0.0.0/255.0.0.0
# RFC1918 Private Address Ranges
# localnet 10.0.0.0/255.0.0.0
# localnet 172.16.0.0/255.240.0.0
# localnet 192.168.0.0/255.255.0.0
# 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
@@ -51,6 +73,24 @@ tcp_connect_time_out 8000
## Exclude connections to ANYwhere with port 80
# localnet 0.0.0.0:80/0.0.0.0
### Examples for dnat
## Trying to proxy connections to destinations which are dnatted,
## will result in proxying connections to the new given destinations.
## Whenever I connect to 1.1.1.1 on port 1234 actually connect to 1.1.1.2 on port 443
# dnat 1.1.1.1:1234 1.1.1.2:443
## Whenever I connect to 1.1.1.1 on port 443 actually connect to 1.1.1.2 on port 443
## (no need to write :443 again)
# dnat 1.1.1.2:443 1.1.1.2
## No matter what port I connect to on 1.1.1.1 port actually connect to 1.1.1.2 on port 443
# dnat 1.1.1.1 1.1.1.2:443
## Always, instead of connecting to 1.1.1.1, connect to 1.1.1.2
# dnat 1.1.1.1 1.1.1.2
# ProxyList format
# type host port [user pass]
# (values separated by 'tab' or 'blank')
@@ -64,12 +104,13 @@ tcp_connect_time_out 8000
# http 192.168.39.93 8080
#
#
# proxy types: http, socks4, socks5
# proxy types: http, socks4, socks5, raw
# * raw: The traffic is simply forwarded to the proxy without modification.
# ( auth types supported: "basic"-http "user/pass"-socks )
#
[ProxyList]
# add proxy here ...
# meanwile
# meanwhile
# defaults set to "tor"
socks4 127.0.0.1 9050
+10 -2
View File
@@ -2,8 +2,12 @@
# This script is called by proxychains to resolve DNS names
# DNS server used to resolve names
DNS_SERVER=4.2.2.2
if [ -z "$PROXY_DNS_SERVER" ] ; then
DNS_SERVER=208.67.222.222 # OpenDNS
else
DNS_SERVER=$PROXY_DNS_SERVER
fi
if [ $# = 0 ] ; then
echo " usage:"
@@ -11,6 +15,10 @@ if [ $# = 0 ] ; then
exit
fi
awk 'BEGIN{ARGC=0} {for(i=2;i<=NF;i++){if($i==ARGV[1] && $1!~":"){print $1;found=1}} } END{exit found?0:1}' "$1" </etc/hosts
if [ "$?" -eq "0" ]; then
exit
fi
export LD_PRELOAD=libproxychains.so
dig $1 @$DNS_SERVER +tcp | awk '/A.+[0-9]+\.[0-9]+\.[0-9]/{print $5;}'
drill $1 @$DNS_SERVER -t | awk '/A.+[0-9]+\.[0-9]+\.[0-9]/{print $5;}'
+41
View File
@@ -0,0 +1,41 @@
#include <stdio.h>
#include <stdlib.h>
#include <netdb.h>
#include <netinet/in.h>
#include <sys/socket.h>
#ifndef NI_MAXHOST
#define NI_MAXHOST 1025
#endif
int main(void) {
struct addrinfo *result;
struct addrinfo *res;
int error;
/* resolve the domain name into a list of addresses */
error = getaddrinfo("www.example.com", NULL, NULL, &result);
if (error != 0)
{
fprintf(stderr, "error in getaddrinfo: %s\n", gai_strerror(error));
return EXIT_FAILURE;
}
/* loop over all returned results and do inverse lookup */
for (res = result; res != NULL; res = res->ai_next)
{
char hostname[NI_MAXHOST] = "";
error = getnameinfo(res->ai_addr, res->ai_addrlen, hostname, NI_MAXHOST, NULL, 0, 0);
if (error != 0)
{
fprintf(stderr, "error in getnameinfo: %s\n", gai_strerror(error));
continue;
}
if (*hostname != '\0')
printf("hostname: %s\n", hostname);
}
freeaddrinfo(result);
return EXIT_SUCCESS;
}