mirror of
https://github.com/rofl0r/proxychains-ng
synced 2026-05-14 01:12:34 +08:00
Compare commits
357 Commits
+20
@@ -0,0 +1,20 @@
|
||||
proxychains4
|
||||
proxychains4-daemon
|
||||
*.bz2
|
||||
*.xz
|
||||
*.o
|
||||
*.so
|
||||
*.la
|
||||
*.lo
|
||||
.deps/
|
||||
.libs/
|
||||
*.rcb
|
||||
*.out
|
||||
*~
|
||||
*.patch
|
||||
version.h
|
||||
|
||||
# Autoconf stuff
|
||||
libtool
|
||||
config.*
|
||||
stamp-h
|
||||
@@ -1,5 +1,27 @@
|
||||
original code up to version 3.1
|
||||
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, mac support
|
||||
rofl0r.
|
||||
https://github.com/rofl0r/proxychains-ng
|
||||
|
||||
localnet, bugfixes
|
||||
jianing yang.
|
||||
https://github.com/jianingy/proxychains
|
||||
https://sourceforge.net/projects/proxychains/forums/forum/644747/topic/3498696
|
||||
|
||||
round-robin
|
||||
crass.
|
||||
https://github.com/crass/proxychains-ng
|
||||
|
||||
poll_retry (fixes for signal handling)
|
||||
colin cross.
|
||||
https://sourceforge.net/projects/proxychains/forums/forum/644747/topic/2367923
|
||||
|
||||
collecting patches from px forum and putting it into a repo
|
||||
adam hamsik.
|
||||
https://github.com/haad/proxychains
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
675 Mass Ave, Cambridge, MA 02139, USA
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
ProxyChains version history (public releases)
|
||||
====================
|
||||
|
||||
ver 3.1
|
||||
|
||||
changed:
|
||||
* dns resolver script fix
|
||||
* prototypes in core.h
|
||||
|
||||
-------------------------------------------------------------------------
|
||||
ver 3.0
|
||||
|
||||
added:
|
||||
* new feature - DNS from behind proxy
|
||||
* proxyresolv - stand alone command
|
||||
* proxychains.conf - new option to enable/disable DNS support
|
||||
|
||||
changed:
|
||||
* bugfixes in core lib
|
||||
* fixed strict chain
|
||||
* fixed random chain
|
||||
* output text
|
||||
* autotools fix
|
||||
|
||||
-------------------------------------------------------------------------
|
||||
ver 2.1
|
||||
* bugfuxes
|
||||
|
||||
-------------------------------------------------------------------------
|
||||
ver 2.0
|
||||
* major core rewrite
|
||||
* new config options
|
||||
|
||||
-------------------------------------------------------------------------
|
||||
|
||||
ver 1.8.2
|
||||
* minor bugfixes
|
||||
* improved compilation on FreeBSD & OpenBSD sysems.
|
||||
* improved compilation on Sun Solaris systems .
|
||||
* cross platform (UNIX) issues
|
||||
|
||||
-------------------------------------------------------------------------
|
||||
|
||||
ver 1.8.0
|
||||
|
||||
added:
|
||||
* Socks5 protocol
|
||||
* Socks4 protocol
|
||||
* HTTP proxy auth basic
|
||||
* Socks4 user auth
|
||||
* Socks5 user/pass auth
|
||||
* more chain options (random, strict, dynamic )
|
||||
* configurable timeout for TCP connect.
|
||||
* configurable timeout for TCP read.
|
||||
* INSTALL file (explains how to install properly)
|
||||
|
||||
changed:
|
||||
* configuration file entries (proxychains.conf)
|
||||
* configuration file lookup
|
||||
|
||||
-------------------------------------------------------------------------
|
||||
|
||||
ver 0.0.1
|
||||
* TCP calls interception
|
||||
* HTTP CONNECT proxy protocol.
|
||||
@@ -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
|
||||
@@ -0,0 +1,106 @@
|
||||
#
|
||||
# Makefile for proxychains (requires GNU make), stolen from musl
|
||||
#
|
||||
# Use config.mak to override any of the following variables.
|
||||
# Do not make changes here.
|
||||
#
|
||||
|
||||
exec_prefix = /usr/local
|
||||
bindir = $(exec_prefix)/bin
|
||||
|
||||
prefix = /usr/local/
|
||||
includedir = $(prefix)/include
|
||||
libdir = $(prefix)/lib
|
||||
sysconfdir = $(prefix)/etc
|
||||
zshcompletiondir = $(prefix)/share/zsh/site-functions
|
||||
|
||||
OBJS = src/common.o src/main.o
|
||||
|
||||
DOBJS = src/daemon/hsearch.o \
|
||||
src/daemon/sblist.o src/daemon/sblist_delete.o \
|
||||
src/daemon/daemon.o src/daemon/udpserver.o
|
||||
|
||||
LOBJS = src/version.o \
|
||||
src/core.o src/common.o src/libproxychains.o \
|
||||
src/allocator_thread.o src/rdns.o \
|
||||
src/hostsreader.o src/hash.o src/debug.o
|
||||
|
||||
|
||||
GENH = src/version.h
|
||||
|
||||
CFLAGS += -Wall -O0 -g -std=c99 -D_GNU_SOURCE -pipe
|
||||
NO_AS_NEEDED = -Wl,--no-as-needed
|
||||
LDFLAGS = -fPIC $(NO_AS_NEEDED) $(LIBDL) $(PTHREAD)
|
||||
INC =
|
||||
PIC = -fPIC
|
||||
AR = $(CROSS_COMPILE)ar
|
||||
RANLIB = $(CROSS_COMPILE)ranlib
|
||||
SOCKET_LIBS =
|
||||
|
||||
LDSO_SUFFIX = so
|
||||
LD_SET_SONAME = -Wl,-soname=
|
||||
INSTALL = ./tools/install.sh
|
||||
|
||||
LDSO_PATHNAME = libproxychains4.$(LDSO_SUFFIX)
|
||||
|
||||
SHARED_LIBS = $(LDSO_PATHNAME)
|
||||
ALL_LIBS = $(SHARED_LIBS)
|
||||
PXCHAINS = proxychains4
|
||||
PXCHAINS_D = proxychains4-daemon
|
||||
ALL_TOOLS = $(PXCHAINS) $(PXCHAINS_D)
|
||||
ALL_CONFIGS = src/proxychains.conf
|
||||
ZSH_COMPLETION = completions/zsh/_proxychains4
|
||||
|
||||
-include config.mak
|
||||
|
||||
CFLAGS+=$(USER_CFLAGS) $(MAC_CFLAGS)
|
||||
CFLAGS_MAIN=-DLIB_DIR=\"$(libdir)\" -DSYSCONFDIR=\"$(sysconfdir)\" -DDLL_NAME=\"$(LDSO_PATHNAME)\"
|
||||
|
||||
|
||||
all: $(ALL_LIBS) $(ALL_TOOLS)
|
||||
|
||||
install: install-libs install-tools
|
||||
|
||||
$(DESTDIR)$(bindir)/%: %
|
||||
$(INSTALL) -D -m 755 $< $@
|
||||
|
||||
$(DESTDIR)$(libdir)/%: %
|
||||
$(INSTALL) -D -m 644 $< $@
|
||||
|
||||
$(DESTDIR)$(sysconfdir)/%: src/%
|
||||
$(INSTALL) -D -m 644 $< $@
|
||||
|
||||
$(DESTDIR)$(zshcompletiondir)/%: completions/zsh/%
|
||||
$(INSTALL) -D -m 644 $< $@
|
||||
|
||||
install-libs: $(ALL_LIBS:%=$(DESTDIR)$(libdir)/%)
|
||||
install-tools: $(ALL_TOOLS:%=$(DESTDIR)$(bindir)/%)
|
||||
install-config: $(ALL_CONFIGS:src/%=$(DESTDIR)$(sysconfdir)/%)
|
||||
install-zsh-completion: $(ZSH_COMPLETION:completions/zsh/%=$(DESTDIR)$(zshcompletiondir)/%)
|
||||
|
||||
clean:
|
||||
rm -f $(ALL_LIBS)
|
||||
rm -f $(ALL_TOOLS)
|
||||
rm -f $(OBJS) $(LOBJS) $(DOBJS)
|
||||
rm -f $(GENH)
|
||||
|
||||
src/version.h: $(wildcard VERSION .git)
|
||||
printf '#define VERSION "%s"\n' "$$(sh tools/version.sh)" > $@
|
||||
|
||||
src/version.o: src/version.h
|
||||
|
||||
%.o: %.c
|
||||
$(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS_MAIN) $(INC) $(PIC) -c -o $@ $<
|
||||
|
||||
$(LDSO_PATHNAME): $(LOBJS)
|
||||
$(CC) $(LDFLAGS) $(FAT_LDFLAGS) $(LD_SET_SONAME)$(LDSO_PATHNAME) \
|
||||
$(USER_LDFLAGS) -shared -o $@ $^ $(SOCKET_LIBS)
|
||||
|
||||
$(PXCHAINS): $(OBJS)
|
||||
$(CC) $^ $(FAT_BIN_LDFLAGS) $(USER_LDFLAGS) $(LIBDL) -o $@
|
||||
|
||||
$(PXCHAINS_D): $(DOBJS)
|
||||
$(CC) $^ $(FAT_BIN_LDFLAGS) $(USER_LDFLAGS) -o $@
|
||||
|
||||
|
||||
.PHONY: all clean install install-config install-libs install-tools install-zsh-completion
|
||||
@@ -1,8 +0,0 @@
|
||||
|
||||
SUBDIRS = proxychains
|
||||
|
||||
EXTRA_DIST = AUTHORS COPYING ChangeLog INSTALL README TODO proxychains.lsm
|
||||
|
||||
AUTOMAKE_OPTIONS = foreign 1.4
|
||||
|
||||
|
||||
-385
@@ -1,385 +0,0 @@
|
||||
# Makefile.in generated automatically by automake 1.4-p6 from Makefile.am
|
||||
|
||||
# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
|
||||
SHELL = @SHELL@
|
||||
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
VPATH = @srcdir@
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
|
||||
bindir = @bindir@
|
||||
sbindir = @sbindir@
|
||||
libexecdir = @libexecdir@
|
||||
datadir = @datadir@
|
||||
sysconfdir = @sysconfdir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
localstatedir = @localstatedir@
|
||||
libdir = @libdir@
|
||||
infodir = @infodir@
|
||||
mandir = @mandir@
|
||||
includedir = @includedir@
|
||||
oldincludedir = /usr/include
|
||||
|
||||
DESTDIR =
|
||||
|
||||
pkgdatadir = $(datadir)/@PACKAGE@
|
||||
pkglibdir = $(libdir)/@PACKAGE@
|
||||
pkgincludedir = $(includedir)/@PACKAGE@
|
||||
|
||||
top_builddir = .
|
||||
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
AUTOMAKE = @AUTOMAKE@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
transform = @program_transform_name@
|
||||
|
||||
NORMAL_INSTALL = :
|
||||
PRE_INSTALL = :
|
||||
POST_INSTALL = :
|
||||
NORMAL_UNINSTALL = :
|
||||
PRE_UNINSTALL = :
|
||||
POST_UNINSTALL = :
|
||||
build_alias = @build_alias@
|
||||
build_triplet = @build@
|
||||
host_alias = @host_alias@
|
||||
host_triplet = @host@
|
||||
target_alias = @target_alias@
|
||||
target_triplet = @target@
|
||||
AR = @AR@
|
||||
AS = @AS@
|
||||
CC = @CC@
|
||||
CXX = @CXX@
|
||||
CXXCPP = @CXXCPP@
|
||||
DLLTOOL = @DLLTOOL@
|
||||
ECHO = @ECHO@
|
||||
EGREP = @EGREP@
|
||||
EXEEXT = @EXEEXT@
|
||||
F77 = @F77@
|
||||
GCJ = @GCJ@
|
||||
GCJFLAGS = @GCJFLAGS@
|
||||
HAVE_LIB = @HAVE_LIB@
|
||||
LIB = @LIB@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
LN_S = @LN_S@
|
||||
LTLIB = @LTLIB@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
OBJDUMP = @OBJDUMP@
|
||||
OBJEXT = @OBJEXT@
|
||||
PACKAGE = @PACKAGE@
|
||||
RANLIB = @RANLIB@
|
||||
RC = @RC@
|
||||
STRIP = @STRIP@
|
||||
VERSION = @VERSION@
|
||||
|
||||
SUBDIRS = proxychains
|
||||
|
||||
EXTRA_DIST = AUTHORS COPYING ChangeLog INSTALL README TODO proxychains.lsm
|
||||
|
||||
AUTOMAKE_OPTIONS = foreign 1.4
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
||||
CONFIG_HEADER = config.h
|
||||
CONFIG_CLEAN_FILES =
|
||||
DIST_COMMON = README ./stamp-h.in AUTHORS COPYING ChangeLog INSTALL \
|
||||
Makefile.am Makefile.in TODO aclocal.m4 config.guess config.h.in \
|
||||
config.sub configure configure.in install-sh ltconfig ltmain.sh missing \
|
||||
mkinstalldirs
|
||||
|
||||
|
||||
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
|
||||
|
||||
TAR = tar
|
||||
GZIP_ENV = --best
|
||||
all: all-redirect
|
||||
.SUFFIXES:
|
||||
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
|
||||
cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile
|
||||
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES)
|
||||
cd $(top_builddir) \
|
||||
&& CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status
|
||||
|
||||
$(ACLOCAL_M4): configure.in
|
||||
cd $(srcdir) && $(ACLOCAL)
|
||||
|
||||
config.status: $(srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
|
||||
$(SHELL) ./config.status --recheck
|
||||
$(srcdir)/configure: $(srcdir)/configure.in $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES)
|
||||
cd $(srcdir) && $(AUTOCONF)
|
||||
|
||||
config.h: stamp-h
|
||||
@if test ! -f $@; then \
|
||||
rm -f stamp-h; \
|
||||
$(MAKE) stamp-h; \
|
||||
else :; fi
|
||||
stamp-h: $(srcdir)/config.h.in $(top_builddir)/config.status
|
||||
cd $(top_builddir) \
|
||||
&& CONFIG_FILES= CONFIG_HEADERS=config.h \
|
||||
$(SHELL) ./config.status
|
||||
@echo timestamp > stamp-h 2> /dev/null
|
||||
$(srcdir)/config.h.in: $(srcdir)/stamp-h.in
|
||||
@if test ! -f $@; then \
|
||||
rm -f $(srcdir)/stamp-h.in; \
|
||||
$(MAKE) $(srcdir)/stamp-h.in; \
|
||||
else :; fi
|
||||
$(srcdir)/stamp-h.in: $(top_srcdir)/configure.in $(ACLOCAL_M4)
|
||||
cd $(top_srcdir) && $(AUTOHEADER)
|
||||
@echo timestamp > $(srcdir)/stamp-h.in 2> /dev/null
|
||||
|
||||
mostlyclean-hdr:
|
||||
|
||||
clean-hdr:
|
||||
|
||||
distclean-hdr:
|
||||
-rm -f config.h
|
||||
|
||||
maintainer-clean-hdr:
|
||||
|
||||
# This directory's subdirectories are mostly independent; you can cd
|
||||
# into them and run `make' without going through this Makefile.
|
||||
# To change the values of `make' variables: instead of editing Makefiles,
|
||||
# (1) if the variable is set in `config.status', edit `config.status'
|
||||
# (which will cause the Makefiles to be regenerated when you run `make');
|
||||
# (2) otherwise, pass the desired values on the `make' command line.
|
||||
|
||||
@SET_MAKE@
|
||||
|
||||
all-recursive install-data-recursive install-exec-recursive \
|
||||
installdirs-recursive install-recursive uninstall-recursive \
|
||||
check-recursive installcheck-recursive info-recursive dvi-recursive:
|
||||
@set fnord $$MAKEFLAGS; amf=$$2; \
|
||||
dot_seen=no; \
|
||||
target=`echo $@ | sed s/-recursive//`; \
|
||||
list='$(SUBDIRS)'; for subdir in $$list; do \
|
||||
echo "Making $$target in $$subdir"; \
|
||||
if test "$$subdir" = "."; then \
|
||||
dot_seen=yes; \
|
||||
local_target="$$target-am"; \
|
||||
else \
|
||||
local_target="$$target"; \
|
||||
fi; \
|
||||
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|
||||
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
|
||||
done; \
|
||||
if test "$$dot_seen" = "no"; then \
|
||||
$(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
|
||||
fi; test -z "$$fail"
|
||||
|
||||
mostlyclean-recursive clean-recursive distclean-recursive \
|
||||
maintainer-clean-recursive:
|
||||
@set fnord $$MAKEFLAGS; amf=$$2; \
|
||||
dot_seen=no; \
|
||||
rev=''; list='$(SUBDIRS)'; for subdir in $$list; do \
|
||||
rev="$$subdir $$rev"; \
|
||||
test "$$subdir" != "." || dot_seen=yes; \
|
||||
done; \
|
||||
test "$$dot_seen" = "no" && rev=". $$rev"; \
|
||||
target=`echo $@ | sed s/-recursive//`; \
|
||||
for subdir in $$rev; do \
|
||||
echo "Making $$target in $$subdir"; \
|
||||
if test "$$subdir" = "."; then \
|
||||
local_target="$$target-am"; \
|
||||
else \
|
||||
local_target="$$target"; \
|
||||
fi; \
|
||||
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|
||||
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
|
||||
done && test -z "$$fail"
|
||||
tags-recursive:
|
||||
list='$(SUBDIRS)'; for subdir in $$list; do \
|
||||
test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
|
||||
done
|
||||
|
||||
tags: TAGS
|
||||
|
||||
ID: $(HEADERS) $(SOURCES) $(LISP)
|
||||
list='$(SOURCES) $(HEADERS)'; \
|
||||
unique=`for i in $$list; do echo $$i; done | \
|
||||
awk ' { files[$$0] = 1; } \
|
||||
END { for (i in files) print i; }'`; \
|
||||
here=`pwd` && cd $(srcdir) \
|
||||
&& mkid -f$$here/ID $$unique $(LISP)
|
||||
|
||||
TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) $(LISP)
|
||||
tags=; \
|
||||
here=`pwd`; \
|
||||
list='$(SUBDIRS)'; for subdir in $$list; do \
|
||||
if test "$$subdir" = .; then :; else \
|
||||
test -f $$subdir/TAGS && tags="$$tags -i $$here/$$subdir/TAGS"; \
|
||||
fi; \
|
||||
done; \
|
||||
list='$(SOURCES) $(HEADERS)'; \
|
||||
unique=`for i in $$list; do echo $$i; done | \
|
||||
awk ' { files[$$0] = 1; } \
|
||||
END { for (i in files) print i; }'`; \
|
||||
test -z "$(ETAGS_ARGS)config.h.in$$unique$(LISP)$$tags" \
|
||||
|| (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags config.h.in $$unique $(LISP) -o $$here/TAGS)
|
||||
|
||||
mostlyclean-tags:
|
||||
|
||||
clean-tags:
|
||||
|
||||
distclean-tags:
|
||||
-rm -f TAGS ID
|
||||
|
||||
maintainer-clean-tags:
|
||||
|
||||
distdir = $(PACKAGE)-$(VERSION)
|
||||
top_distdir = $(distdir)
|
||||
|
||||
# This target untars the dist file and tries a VPATH configuration. Then
|
||||
# it guarantees that the distribution is self-contained by making another
|
||||
# tarfile.
|
||||
distcheck: dist
|
||||
-rm -rf $(distdir)
|
||||
GZIP=$(GZIP_ENV) $(TAR) zxf $(distdir).tar.gz
|
||||
mkdir $(distdir)/=build
|
||||
mkdir $(distdir)/=inst
|
||||
dc_install_base=`cd $(distdir)/=inst && pwd`; \
|
||||
cd $(distdir)/=build \
|
||||
&& ../configure --srcdir=.. --prefix=$$dc_install_base \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) dvi \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) check \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) install \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) installcheck \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) dist
|
||||
-rm -rf $(distdir)
|
||||
@banner="$(distdir).tar.gz is ready for distribution"; \
|
||||
dashes=`echo "$$banner" | sed s/./=/g`; \
|
||||
echo "$$dashes"; \
|
||||
echo "$$banner"; \
|
||||
echo "$$dashes"
|
||||
dist: distdir
|
||||
-chmod -R a+r $(distdir)
|
||||
GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir)
|
||||
-rm -rf $(distdir)
|
||||
dist-all: distdir
|
||||
-chmod -R a+r $(distdir)
|
||||
GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir)
|
||||
-rm -rf $(distdir)
|
||||
distdir: $(DISTFILES)
|
||||
-rm -rf $(distdir)
|
||||
mkdir $(distdir)
|
||||
-chmod 777 $(distdir)
|
||||
here=`cd $(top_builddir) && pwd`; \
|
||||
top_distdir=`cd $(distdir) && pwd`; \
|
||||
distdir=`cd $(distdir) && pwd`; \
|
||||
cd $(top_srcdir) \
|
||||
&& $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --foreign Makefile
|
||||
@for file in $(DISTFILES); do \
|
||||
d=$(srcdir); \
|
||||
if test -d $$d/$$file; then \
|
||||
cp -pr $$d/$$file $(distdir)/$$file; \
|
||||
else \
|
||||
test -f $(distdir)/$$file \
|
||||
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|
||||
|| cp -p $$d/$$file $(distdir)/$$file || :; \
|
||||
fi; \
|
||||
done
|
||||
for subdir in $(SUBDIRS); do \
|
||||
if test "$$subdir" = .; then :; else \
|
||||
test -d $(distdir)/$$subdir \
|
||||
|| mkdir $(distdir)/$$subdir \
|
||||
|| exit 1; \
|
||||
chmod 777 $(distdir)/$$subdir; \
|
||||
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir=../$(distdir) distdir=../$(distdir)/$$subdir distdir) \
|
||||
|| exit 1; \
|
||||
fi; \
|
||||
done
|
||||
info-am:
|
||||
info: info-recursive
|
||||
dvi-am:
|
||||
dvi: dvi-recursive
|
||||
check-am: all-am
|
||||
check: check-recursive
|
||||
installcheck-am:
|
||||
installcheck: installcheck-recursive
|
||||
all-recursive-am: config.h
|
||||
$(MAKE) $(AM_MAKEFLAGS) all-recursive
|
||||
|
||||
install-exec-am:
|
||||
install-exec: install-exec-recursive
|
||||
|
||||
install-data-am:
|
||||
install-data: install-data-recursive
|
||||
|
||||
install-am: all-am
|
||||
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
|
||||
install: install-recursive
|
||||
uninstall-am:
|
||||
uninstall: uninstall-recursive
|
||||
all-am: Makefile config.h
|
||||
all-redirect: all-recursive-am
|
||||
install-strip:
|
||||
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
|
||||
installdirs: installdirs-recursive
|
||||
installdirs-am:
|
||||
|
||||
|
||||
mostlyclean-generic:
|
||||
|
||||
clean-generic:
|
||||
|
||||
distclean-generic:
|
||||
-rm -f Makefile $(CONFIG_CLEAN_FILES)
|
||||
-rm -f config.cache config.log stamp-h stamp-h[0-9]*
|
||||
|
||||
maintainer-clean-generic:
|
||||
mostlyclean-am: mostlyclean-hdr mostlyclean-tags mostlyclean-generic
|
||||
|
||||
mostlyclean: mostlyclean-recursive
|
||||
|
||||
clean-am: clean-hdr clean-tags clean-generic mostlyclean-am
|
||||
|
||||
clean: clean-recursive
|
||||
|
||||
distclean-am: distclean-hdr distclean-tags distclean-generic clean-am
|
||||
-rm -f libtool
|
||||
|
||||
distclean: distclean-recursive
|
||||
-rm -f config.status
|
||||
|
||||
maintainer-clean-am: maintainer-clean-hdr maintainer-clean-tags \
|
||||
maintainer-clean-generic distclean-am
|
||||
@echo "This command is intended for maintainers to use;"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
|
||||
maintainer-clean: maintainer-clean-recursive
|
||||
-rm -f config.status
|
||||
|
||||
.PHONY: mostlyclean-hdr distclean-hdr clean-hdr maintainer-clean-hdr \
|
||||
install-data-recursive uninstall-data-recursive install-exec-recursive \
|
||||
uninstall-exec-recursive installdirs-recursive uninstalldirs-recursive \
|
||||
all-recursive check-recursive installcheck-recursive info-recursive \
|
||||
dvi-recursive mostlyclean-recursive distclean-recursive clean-recursive \
|
||||
maintainer-clean-recursive tags tags-recursive mostlyclean-tags \
|
||||
distclean-tags clean-tags maintainer-clean-tags distdir info-am info \
|
||||
dvi-am dvi check check-am installcheck-am installcheck all-recursive-am \
|
||||
install-exec-am install-exec install-data-am install-data install-am \
|
||||
install uninstall-am uninstall all-redirect all-am all installdirs-am \
|
||||
installdirs mostlyclean-generic distclean-generic clean-generic \
|
||||
maintainer-clean-generic clean mostlyclean distclean maintainer-clean
|
||||
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
||||
@@ -1,18 +1,186 @@
|
||||
ProxyChains ver 3.1 README
|
||||
======================
|
||||
ProxyChains-NG ver 4.17 README
|
||||
=============================
|
||||
|
||||
This is Unix version only.
|
||||
ProxyChains is a UNIX program, that hooks network-related libc functions
|
||||
in DYNAMICALLY LINKED programs via a preloaded DLL (dlsym(), LD_PRELOAD)
|
||||
and redirects the connections through SOCKS4a/5 or HTTP proxies.
|
||||
It supports TCP only (no UDP/ICMP etc).
|
||||
|
||||
How to mess with sources - How to Install : read INSTALL !!!!!!
|
||||
The way it works is basically a HACK; so it is possible that it doesn't
|
||||
work with your program, especially when it's a script, or starts
|
||||
numerous processes like background daemons or uses dlopen() to load
|
||||
"modules" (bug in glibc dynlinker).
|
||||
It should work with simple compiled (C/C++) dynamically linked programs
|
||||
though.
|
||||
|
||||
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.
|
||||
If your program doesn't work with proxychains, consider using an
|
||||
iptables based solution instead; this is much more robust.
|
||||
|
||||
This 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".
|
||||
Supported Platforms: Linux, BSD, Mac, Haiku.
|
||||
|
||||
|
||||
*********** ATTENTION ***********
|
||||
|
||||
this program can be used to circumvent censorship.
|
||||
doing so can be VERY DANGEROUS in certain countries.
|
||||
|
||||
ALWAYS MAKE SURE THAT PROXYCHAINS WORKS AS EXPECTED
|
||||
BEFORE USING IT FOR ANYTHING SERIOUS.
|
||||
|
||||
this involves both the program and the proxy that you're going to
|
||||
use.
|
||||
|
||||
for example, you can connect to some "what is my ip" service
|
||||
like ifconfig.me to make sure that it's not using your real ip.
|
||||
|
||||
ONLY USE PROXYCHAINS IF YOU KNOW WHAT YOU'RE DOING.
|
||||
|
||||
THE AUTHORS AND MAINTAINERS OF PROXYCHAINS DO NOT TAKE ANY
|
||||
RESPONSIBILITY FOR ANY ABUSE OR MISUSE OF THIS SOFTWARE AND
|
||||
THE RESULTING CONSEQUENCES.
|
||||
|
||||
*** Installation ***
|
||||
|
||||
# needs a working C compiler, preferably gcc
|
||||
./configure --prefix=/usr --sysconfdir=/etc
|
||||
make
|
||||
[optional] sudo make install
|
||||
[optional] sudo make install-config (installs proxychains.conf)
|
||||
|
||||
if you dont install, you can use proxychains from the build directory
|
||||
like this: ./proxychains4 -f src/proxychains.conf telnet google.com 80
|
||||
|
||||
Changelog:
|
||||
----------
|
||||
Version 4.17
|
||||
- add hook for close_range function, fixing newer versions of openssh
|
||||
- fat-binary-m1 option for mac
|
||||
- fix DNS error handling in proxy_dns_old
|
||||
- simplify init code
|
||||
- fix openbsd preloading
|
||||
- fix double-close in multithreaded apps
|
||||
- various improvements to configure script
|
||||
|
||||
Version 4.16
|
||||
- fix regression in configure script linker flag detection
|
||||
- remove 10 year old workaround for wrong glibc getnameinfo signature
|
||||
- support for new DYLD hooking method for OSX Monterey
|
||||
- netbsd compilation fix
|
||||
- support IPv6 localnets
|
||||
- more user-friendly error message when execvp fails
|
||||
- proxy_getaddrinfo(): fill in ai_socktype if requested
|
||||
|
||||
Version 4.15
|
||||
- fix configure script for buggy binutils version
|
||||
- initialize rand_seed with nano-second granularity
|
||||
- add support for numeric ipv6 in getaddrinfo
|
||||
- fix bug in getaddrinfo when node is null and !passive
|
||||
- add dnat feature
|
||||
- add raw proxy type
|
||||
- add haiku support
|
||||
- add proxy_dns_old to emulate proxychains 3.1 behaviour
|
||||
- add new proxy_dns_daemon feature (experimental)
|
||||
- various other fixes
|
||||
|
||||
Version 4.14
|
||||
- allow alternative proto://user:pass@ip:port syntax for proxylist
|
||||
- fix endless loop in round robin mode when all proxies are down (#147)
|
||||
- fix compilation on android (#265)
|
||||
- fix fd leak in forked processes (#273)
|
||||
- skip connection attempt to nullrouted ips
|
||||
- allow hostnames for proxylist under specific circumstances
|
||||
|
||||
Version 4.13
|
||||
- fix robustness of DNS lookup thread and a segfault
|
||||
- fix socks5 user/pass auth on non-conforming servers
|
||||
- fix memory leak
|
||||
- add support for Solaris
|
||||
|
||||
Version 4.12
|
||||
- fix several build issues
|
||||
- for MAC
|
||||
- with -pie
|
||||
- with custom CC
|
||||
- compatibility fix for some GUI apps (8870140)
|
||||
- compatibility fix for some HTTP proxies (cf9a16d)
|
||||
- fix several warnings for cleaner build on debian
|
||||
- fix random_chain on OSX (0f6b226)
|
||||
|
||||
Version 4.11
|
||||
- preliminary IPv6 support
|
||||
- fixed bug in hostsreader
|
||||
- preliminary support for usage on OpenBSD (caveat emptor)
|
||||
|
||||
Version 4.10
|
||||
- fix regression in linking order with custom LDFLAGS
|
||||
- fix segfault in DNS mapping code in programs with > ~400 different lookups
|
||||
|
||||
Version 4.9
|
||||
- fix a security issue CVE-2015-3887
|
||||
- add sendto hook to handle MSG_FASTOPEN flag
|
||||
- replace problematic hostentdb with hostsreader
|
||||
- fix compilation on OpenBSD (although doesn't work there)
|
||||
|
||||
Version 4.8.1:
|
||||
- fix regression in 4.8 install-config Makefile target
|
||||
|
||||
Version 4.8:
|
||||
- fix for odd cornercase where getaddrinfo was used with AI_NUMERICHOST
|
||||
to test for a numeric ip instead of resolving it (fixes nmap).
|
||||
- allow usage with programs that rely on LD_PRELOAD themselves
|
||||
- reject wrong entries in config file
|
||||
- print version number on startup
|
||||
|
||||
Version 4.7:
|
||||
- new round_robin chaintype by crass.
|
||||
- fix bug with lazy allocation when GCC constructor was not used.
|
||||
- new configure flag --fat-binary to create a "fat" binary/library on OS X
|
||||
- return EBADF rather than EINTR in close hook.
|
||||
it's legal for a program to retry close() calls when they receive
|
||||
EINTR, which could cause an infinite loop, as seen in chromium.
|
||||
|
||||
Version 4.6:
|
||||
- some cosmetic fixes to Makefile, fix a bug when non-numeric ip was
|
||||
used as proxy server address.
|
||||
|
||||
Version 4.5:
|
||||
- hook close() to prevent OpenSSH from messing with internal infrastructure.
|
||||
this caused ssh client to segfault when proxified.
|
||||
|
||||
Version 4.4:
|
||||
- FreeBSD port
|
||||
- fixes some installation issues on Debian and Mac.
|
||||
|
||||
Version 4.3:
|
||||
- fixes programs that do dns-lookups in child processes (fork()ed),
|
||||
like irssi. to achieve this, support for compilation without pthreads
|
||||
was sacrified.
|
||||
- fixes thread safety for gethostent() calls.
|
||||
- improved DNS handling speed, since hostent db is cached.
|
||||
|
||||
Version 4.2:
|
||||
- fixes compilation issues with ubuntu 12.04 toolchain
|
||||
- fixes segfault in rare codepath
|
||||
|
||||
Version 4.1
|
||||
- support for mac os x (all archs)
|
||||
- all internal functions are threadsafe when compiled with -DTHREAD_SAFE
|
||||
(default).
|
||||
|
||||
Version 4.0
|
||||
- replaced 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.
|
||||
- removed 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.0
|
||||
- support for DNS resolving through proxy
|
||||
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.
|
||||
@@ -21,7 +189,8 @@ When to use it ?
|
||||
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.
|
||||
6) To use DNS behind proxy.
|
||||
7) To access hidden tor onion services.
|
||||
|
||||
Some cool features:
|
||||
|
||||
@@ -31,34 +200,76 @@ Some cool features:
|
||||
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 most TCP client applications, possibly even network
|
||||
scanners, as long as they use standard libc functionality.
|
||||
pcap based scanning does not work.
|
||||
* 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) ./proxychains.conf
|
||||
2) $(HOME)/.proxychains/proxychains.conf
|
||||
3) /etc/proxychains.conf **
|
||||
|
||||
**see more in /etc/proxychains.conf
|
||||
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) $(sysconfdir)/proxychains.conf **
|
||||
|
||||
** usually /etc/proxychains.conf
|
||||
|
||||
Usage Example:
|
||||
|
||||
bash$ proxychains telnet targethost.com
|
||||
$ proxychains telnet targethost.com
|
||||
|
||||
in this example it will run telnet through proxy(or chained proxies)
|
||||
specified by proxychains.conf
|
||||
|
||||
Usage Example:
|
||||
|
||||
bash$ proxyresolv targethost.com
|
||||
$ proxychains -f /etc/proxychains-other.conf telnet 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
|
||||
|
||||
NOTE:
|
||||
to run suid/sgid programs(like ssh) through proxychains you have to be root
|
||||
Known Problems:
|
||||
---------------
|
||||
- newer versions of nmap try to determine the network interface to use
|
||||
even if it's not needed (like when doing simple syn scans which use the
|
||||
standard POSIX socket API. this results in errors when proxychains hands
|
||||
out an ip address to a reserved address space.
|
||||
possible workarounds: disable proxy_dns, use a numeric ip, or use nmap's
|
||||
native support for SOCKS proxies.
|
||||
|
||||
- Mac OS X 10.11 (El Capitan) ships with a new security feature called SIP
|
||||
that prevents hooking of system apps.
|
||||
workarounds are to partially disable SIP by issuing
|
||||
csrutil enable --without debug in recovery mode,
|
||||
or to copy the system binary into the home directory and run it from there.
|
||||
see github issue #78 for details.
|
||||
|
||||
- the glibc dynlinker has a bug or security feature that inhibits dlopen()ed
|
||||
modules from being subject to the same dlsym hooks as installed for the main
|
||||
program. this mainly affects scripting languages such as perl or python
|
||||
that heavily rely on dlopen() for modules written in C to work.
|
||||
there are unconfirmed reports that it works as root though.
|
||||
musl libc is unaffected from the bug.
|
||||
|
||||
|
||||
Community:
|
||||
----------
|
||||
#proxychains on irc.libera.chat
|
||||
|
||||
Donations:
|
||||
----------
|
||||
bitcoins donations are welcome - please send to this address:
|
||||
1C9LBpuy56veBqw5N33sZMoZW8mwCw3tPh
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
ProxyChains ver 3.1 TODO
|
||||
ProxyChains ver 4.0 TODO
|
||||
===================
|
||||
|
||||
stable DNS resolver ....
|
||||
|
||||
|
||||
hooks for reentrant dns functions, i.e. gethostbyaddr_r
|
||||
|
||||
|
||||
|
||||
Vendored
-7433
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,8 @@
|
||||
#compdef proxychains4
|
||||
|
||||
_arguments \
|
||||
'(- : *)--help[More help in README file]' \
|
||||
'-q[makes proxychains quiet - this overrides the config setting]' \
|
||||
'-f[allows one to manually specify a configfile to use]: :_files' \
|
||||
'(-)1: :{_command_names -e}' \
|
||||
'*:: :_normal'
|
||||
Vendored
-1495
File diff suppressed because it is too large
Load Diff
-55
@@ -1,55 +0,0 @@
|
||||
/* config.h.in. Generated from configure.in by autoheader. */
|
||||
|
||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||
#undef HAVE_DLFCN_H
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#undef HAVE_INTTYPES_H
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#undef HAVE_MEMORY_H
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#undef HAVE_STDINT_H
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#undef HAVE_STDLIB_H
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#undef HAVE_STRINGS_H
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#undef HAVE_STRING_H
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#undef HAVE_SYS_STAT_H
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#undef HAVE_SYS_TYPES_H
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#undef HAVE_UNISTD_H
|
||||
|
||||
/* Name of package */
|
||||
#undef PACKAGE
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#undef PACKAGE_BUGREPORT
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#undef PACKAGE_NAME
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#undef PACKAGE_STRING
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#undef PACKAGE_TARNAME
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#undef PACKAGE_VERSION
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#undef STDC_HEADERS
|
||||
|
||||
/* Version number of package */
|
||||
#undef VERSION
|
||||
Vendored
-1627
File diff suppressed because it is too large
Load Diff
@@ -1,32 +0,0 @@
|
||||
dnl without this order in this file, autoconf will not work!
|
||||
dnl the argument is a source file out of your sources. But
|
||||
dnl acinclude.m4 makes the job for all programs ;-)
|
||||
AC_INIT(proxychains,3.1)
|
||||
|
||||
dnl enable the following if you want to use autoconf/automake
|
||||
dnl framework from a certain directory (like kde-common)
|
||||
dnl AC_CONFIG_AUX_DIR(admin)
|
||||
|
||||
AC_CANONICAL_SYSTEM
|
||||
|
||||
AM_INIT_AUTOMAKE
|
||||
|
||||
AC_PREFIX_DEFAULT(/)
|
||||
|
||||
dnl without this order in this file, automake will be confused!
|
||||
dnl
|
||||
AM_CONFIG_HEADER(config.h)
|
||||
|
||||
AC_PROG_CC
|
||||
AC_PROG_LIBTOOL
|
||||
|
||||
dnl create only shared libtool-libraries
|
||||
AC_ENABLE_SHARED(yes)
|
||||
|
||||
dnl set the following to yes, if you want to create static
|
||||
dnl libtool-libraries
|
||||
AC_ENABLE_STATIC(no)
|
||||
|
||||
|
||||
dnl add here all your Makefiles. These will be created by configure
|
||||
AC_OUTPUT(Makefile proxychains/Makefile proxychains/docs/Makefile proxychains/docs/en/Makefile )
|
||||
-250
@@ -1,250 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# install - install a program, script, or datafile
|
||||
# This comes from X11R5 (mit/util/scripts/install.sh).
|
||||
#
|
||||
# Copyright 1991 by the Massachusetts Institute of Technology
|
||||
#
|
||||
# Permission to use, copy, modify, distribute, and sell this software and its
|
||||
# documentation for any purpose is hereby granted without fee, provided that
|
||||
# the above copyright notice appear in all copies and that both that
|
||||
# copyright notice and this permission notice appear in supporting
|
||||
# documentation, and that the name of M.I.T. not be used in advertising or
|
||||
# publicity pertaining to distribution of the software without specific,
|
||||
# written prior permission. M.I.T. makes no representations about the
|
||||
# suitability of this software for any purpose. It is provided "as is"
|
||||
# without express or implied warranty.
|
||||
#
|
||||
# Calling this script install-sh is preferred over install.sh, to prevent
|
||||
# `make' implicit rules from creating a file called install from it
|
||||
# when there is no Makefile.
|
||||
#
|
||||
# This script is compatible with the BSD install script, but was written
|
||||
# from scratch. It can only install one file at a time, a restriction
|
||||
# shared with many OS's install programs.
|
||||
|
||||
|
||||
# set DOITPROG to echo to test this script
|
||||
|
||||
# Don't use :- since 4.3BSD and earlier shells don't like it.
|
||||
doit="${DOITPROG-}"
|
||||
|
||||
|
||||
# put in absolute paths if you don't have them in your path; or use env. vars.
|
||||
|
||||
mvprog="${MVPROG-mv}"
|
||||
cpprog="${CPPROG-cp}"
|
||||
chmodprog="${CHMODPROG-chmod}"
|
||||
chownprog="${CHOWNPROG-chown}"
|
||||
chgrpprog="${CHGRPPROG-chgrp}"
|
||||
stripprog="${STRIPPROG-strip}"
|
||||
rmprog="${RMPROG-rm}"
|
||||
mkdirprog="${MKDIRPROG-mkdir}"
|
||||
|
||||
transformbasename=""
|
||||
transform_arg=""
|
||||
instcmd="$mvprog"
|
||||
chmodcmd="$chmodprog 0755"
|
||||
chowncmd=""
|
||||
chgrpcmd=""
|
||||
stripcmd=""
|
||||
rmcmd="$rmprog -f"
|
||||
mvcmd="$mvprog"
|
||||
src=""
|
||||
dst=""
|
||||
dir_arg=""
|
||||
|
||||
while [ x"$1" != x ]; do
|
||||
case $1 in
|
||||
-c) instcmd="$cpprog"
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-d) dir_arg=true
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-m) chmodcmd="$chmodprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-o) chowncmd="$chownprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-g) chgrpcmd="$chgrpprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-s) stripcmd="$stripprog"
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-t=*) transformarg=`echo $1 | sed 's/-t=//'`
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
|
||||
shift
|
||||
continue;;
|
||||
|
||||
*) if [ x"$src" = x ]
|
||||
then
|
||||
src=$1
|
||||
else
|
||||
# this colon is to work around a 386BSD /bin/sh bug
|
||||
:
|
||||
dst=$1
|
||||
fi
|
||||
shift
|
||||
continue;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ x"$src" = x ]
|
||||
then
|
||||
echo "install: no input file specified"
|
||||
exit 1
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
if [ x"$dir_arg" != x ]; then
|
||||
dst=$src
|
||||
src=""
|
||||
|
||||
if [ -d $dst ]; then
|
||||
instcmd=:
|
||||
else
|
||||
instcmd=mkdir
|
||||
fi
|
||||
else
|
||||
|
||||
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
|
||||
# might cause directories to be created, which would be especially bad
|
||||
# if $src (and thus $dsttmp) contains '*'.
|
||||
|
||||
if [ -f $src -o -d $src ]
|
||||
then
|
||||
true
|
||||
else
|
||||
echo "install: $src does not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ x"$dst" = x ]
|
||||
then
|
||||
echo "install: no destination specified"
|
||||
exit 1
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
# If destination is a directory, append the input filename; if your system
|
||||
# does not like double slashes in filenames, you may need to add some logic
|
||||
|
||||
if [ -d $dst ]
|
||||
then
|
||||
dst="$dst"/`basename $src`
|
||||
else
|
||||
true
|
||||
fi
|
||||
fi
|
||||
|
||||
## this sed command emulates the dirname command
|
||||
dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
|
||||
|
||||
# Make sure that the destination directory exists.
|
||||
# this part is taken from Noah Friedman's mkinstalldirs script
|
||||
|
||||
# Skip lots of stat calls in the usual case.
|
||||
if [ ! -d "$dstdir" ]; then
|
||||
defaultIFS='
|
||||
'
|
||||
IFS="${IFS-${defaultIFS}}"
|
||||
|
||||
oIFS="${IFS}"
|
||||
# Some sh's can't handle IFS=/ for some reason.
|
||||
IFS='%'
|
||||
set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
|
||||
IFS="${oIFS}"
|
||||
|
||||
pathcomp=''
|
||||
|
||||
while [ $# -ne 0 ] ; do
|
||||
pathcomp="${pathcomp}${1}"
|
||||
shift
|
||||
|
||||
if [ ! -d "${pathcomp}" ] ;
|
||||
then
|
||||
$mkdirprog "${pathcomp}"
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
pathcomp="${pathcomp}/"
|
||||
done
|
||||
fi
|
||||
|
||||
if [ x"$dir_arg" != x ]
|
||||
then
|
||||
$doit $instcmd $dst &&
|
||||
|
||||
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
|
||||
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
|
||||
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
|
||||
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
|
||||
else
|
||||
|
||||
# If we're going to rename the final executable, determine the name now.
|
||||
|
||||
if [ x"$transformarg" = x ]
|
||||
then
|
||||
dstfile=`basename $dst`
|
||||
else
|
||||
dstfile=`basename $dst $transformbasename |
|
||||
sed $transformarg`$transformbasename
|
||||
fi
|
||||
|
||||
# don't allow the sed command to completely eliminate the filename
|
||||
|
||||
if [ x"$dstfile" = x ]
|
||||
then
|
||||
dstfile=`basename $dst`
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
# Make a temp file name in the proper directory.
|
||||
|
||||
dsttmp=$dstdir/#inst.$$#
|
||||
|
||||
# Move or copy the file name to the temp name
|
||||
|
||||
$doit $instcmd $src $dsttmp &&
|
||||
|
||||
trap "rm -f ${dsttmp}" 0 &&
|
||||
|
||||
# and set any options; do chmod last to preserve setuid bits
|
||||
|
||||
# If any of these fail, we abort the whole thing. If we want to
|
||||
# ignore errors from any of these, just make sure not to ignore
|
||||
# errors from the above "$doit $instcmd $src $dsttmp" command.
|
||||
|
||||
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
|
||||
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
|
||||
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
|
||||
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
|
||||
|
||||
# Now rename the file to the real destination.
|
||||
|
||||
$doit $rmcmd -f $dstdir/$dstfile &&
|
||||
$doit $mvcmd $dsttmp $dstdir/$dstfile
|
||||
|
||||
fi &&
|
||||
|
||||
|
||||
exit 0
|
||||
@@ -1,238 +0,0 @@
|
||||
#! /bin/sh
|
||||
# Common stub for a few missing GNU programs while installing.
|
||||
# Copyright (C) 1996, 1997, 1999 Free Software Foundation, Inc.
|
||||
# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
|
||||
|
||||
# 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
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
# 02111-1307, USA.
|
||||
|
||||
if test $# -eq 0; then
|
||||
echo 1>&2 "Try \`$0 --help' for more information"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
run=:
|
||||
|
||||
case "$1" in
|
||||
--run)
|
||||
# Try to run requested program, and just exit if it succeeds.
|
||||
run=
|
||||
shift
|
||||
"$@" && exit 0
|
||||
;;
|
||||
esac
|
||||
|
||||
# If it does not exist, or fails to run (possibly an outdated version),
|
||||
# try to emulate it.
|
||||
case "$1" in
|
||||
|
||||
-h|--h|--he|--hel|--help)
|
||||
echo "\
|
||||
$0 [OPTION]... PROGRAM [ARGUMENT]...
|
||||
|
||||
Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
|
||||
error status if there is no known handling for PROGRAM.
|
||||
|
||||
Options:
|
||||
-h, --help display this help and exit
|
||||
-v, --version output version information and exit
|
||||
--run try to run the given command, and emulate it if it fails
|
||||
|
||||
Supported PROGRAM values:
|
||||
aclocal touch file \`aclocal.m4'
|
||||
autoconf touch file \`configure'
|
||||
autoheader touch file \`config.h.in'
|
||||
automake touch all \`Makefile.in' files
|
||||
bison create \`y.tab.[ch]', if possible, from existing .[ch]
|
||||
flex create \`lex.yy.c', if possible, from existing .c
|
||||
lex create \`lex.yy.c', if possible, from existing .c
|
||||
makeinfo touch the output file
|
||||
tar try tar, gnutar, gtar, then tar without non-portable flags
|
||||
yacc create \`y.tab.[ch]', if possible, from existing .[ch]"
|
||||
;;
|
||||
|
||||
-v|--v|--ve|--ver|--vers|--versi|--versio|--version)
|
||||
echo "missing 0.2 - GNU automake"
|
||||
;;
|
||||
|
||||
-*)
|
||||
echo 1>&2 "$0: Unknown \`$1' option"
|
||||
echo 1>&2 "Try \`$0 --help' for more information"
|
||||
exit 1
|
||||
;;
|
||||
|
||||
aclocal)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is missing on your system. You should only need it if
|
||||
you modified \`acinclude.m4' or \`configure.in'. You might want
|
||||
to install the \`Automake' and \`Perl' packages. Grab them from
|
||||
any GNU archive site."
|
||||
touch aclocal.m4
|
||||
;;
|
||||
|
||||
autoconf)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is missing on your system. You should only need it if
|
||||
you modified \`configure.in'. You might want to install the
|
||||
\`Autoconf' and \`GNU m4' packages. Grab them from any GNU
|
||||
archive site."
|
||||
touch configure
|
||||
;;
|
||||
|
||||
autoheader)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is missing on your system. You should only need it if
|
||||
you modified \`acconfig.h' or \`configure.in'. You might want
|
||||
to install the \`Autoconf' and \`GNU m4' packages. Grab them
|
||||
from any GNU archive site."
|
||||
files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' configure.in`
|
||||
test -z "$files" && files="config.h"
|
||||
touch_files=
|
||||
for f in $files; do
|
||||
case "$f" in
|
||||
*:*) touch_files="$touch_files "`echo "$f" |
|
||||
sed -e 's/^[^:]*://' -e 's/:.*//'`;;
|
||||
*) touch_files="$touch_files $f.in";;
|
||||
esac
|
||||
done
|
||||
touch $touch_files
|
||||
;;
|
||||
|
||||
automake)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is missing on your system. You should only need it if
|
||||
you modified \`Makefile.am', \`acinclude.m4' or \`configure.in'.
|
||||
You might want to install the \`Automake' and \`Perl' packages.
|
||||
Grab them from any GNU archive site."
|
||||
find . -type f -name Makefile.am -print |
|
||||
sed 's/\.am$/.in/' |
|
||||
while read f; do touch "$f"; done
|
||||
;;
|
||||
|
||||
bison|yacc)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is missing on your system. You should only need it if
|
||||
you modified a \`.y' file. You may need the \`Bison' package
|
||||
in order for those modifications to take effect. You can get
|
||||
\`Bison' from any GNU archive site."
|
||||
rm -f y.tab.c y.tab.h
|
||||
if [ $# -ne 1 ]; then
|
||||
eval LASTARG="\${$#}"
|
||||
case "$LASTARG" in
|
||||
*.y)
|
||||
SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
|
||||
if [ -f "$SRCFILE" ]; then
|
||||
cp "$SRCFILE" y.tab.c
|
||||
fi
|
||||
SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
|
||||
if [ -f "$SRCFILE" ]; then
|
||||
cp "$SRCFILE" y.tab.h
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
if [ ! -f y.tab.h ]; then
|
||||
echo >y.tab.h
|
||||
fi
|
||||
if [ ! -f y.tab.c ]; then
|
||||
echo 'main() { return 0; }' >y.tab.c
|
||||
fi
|
||||
;;
|
||||
|
||||
lex|flex)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is missing on your system. You should only need it if
|
||||
you modified a \`.l' file. You may need the \`Flex' package
|
||||
in order for those modifications to take effect. You can get
|
||||
\`Flex' from any GNU archive site."
|
||||
rm -f lex.yy.c
|
||||
if [ $# -ne 1 ]; then
|
||||
eval LASTARG="\${$#}"
|
||||
case "$LASTARG" in
|
||||
*.l)
|
||||
SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
|
||||
if [ -f "$SRCFILE" ]; then
|
||||
cp "$SRCFILE" lex.yy.c
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
if [ ! -f lex.yy.c ]; then
|
||||
echo 'main() { return 0; }' >lex.yy.c
|
||||
fi
|
||||
;;
|
||||
|
||||
makeinfo)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is missing on your system. You should only need it if
|
||||
you modified a \`.texi' or \`.texinfo' file, or any other file
|
||||
indirectly affecting the aspect of the manual. The spurious
|
||||
call might also be the consequence of using a buggy \`make' (AIX,
|
||||
DU, IRIX). You might want to install the \`Texinfo' package or
|
||||
the \`GNU make' package. Grab either from any GNU archive site."
|
||||
file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
|
||||
if test -z "$file"; then
|
||||
file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
|
||||
file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file`
|
||||
fi
|
||||
touch $file
|
||||
;;
|
||||
|
||||
tar)
|
||||
shift
|
||||
if test -n "$run"; then
|
||||
echo 1>&2 "ERROR: \`tar' requires --run"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# we have already tried tar in the generic part
|
||||
gnutar ${1+"$@"} && exit 0
|
||||
gtar ${1+"$@"} && exit 0
|
||||
firstarg="$1"
|
||||
if shift; then
|
||||
case "$firstarg" in
|
||||
*o*)
|
||||
firstarg=`echo "$firstarg" | sed s/o//`
|
||||
tar "$firstarg" ${1+"$@"} && exit 0
|
||||
;;
|
||||
esac
|
||||
case "$firstarg" in
|
||||
*h*)
|
||||
firstarg=`echo "$firstarg" | sed s/h//`
|
||||
tar "$firstarg" ${1+"$@"} && exit 0
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
echo 1>&2 "\
|
||||
WARNING: I can't seem to be able to run \`tar' with the given arguments.
|
||||
You may want to install GNU tar or Free paxutils, or check the
|
||||
command line arguments."
|
||||
exit 1
|
||||
;;
|
||||
|
||||
*)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is needed, and you do not seem to have it handy on your
|
||||
system. You might have modified some files without having the
|
||||
proper tools for further handling them. Check the \`README' file,
|
||||
it often tells you about the needed prerequirements for installing
|
||||
this package. You may also peek at any GNU archive site, in case
|
||||
some other package would contain this missing \`$1' program."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
@@ -1,40 +0,0 @@
|
||||
#! /bin/sh
|
||||
# mkinstalldirs --- make directory hierarchy
|
||||
# Author: Noah Friedman <friedman@prep.ai.mit.edu>
|
||||
# Created: 1993-05-16
|
||||
# Public domain
|
||||
|
||||
# $Id: mkinstalldirs,v 1.2 2004/03/22 00:29:19 netcreature Exp $
|
||||
|
||||
errstatus=0
|
||||
|
||||
for file
|
||||
do
|
||||
set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
|
||||
shift
|
||||
|
||||
pathcomp=
|
||||
for d
|
||||
do
|
||||
pathcomp="$pathcomp$d"
|
||||
case "$pathcomp" in
|
||||
-* ) pathcomp=./$pathcomp ;;
|
||||
esac
|
||||
|
||||
if test ! -d "$pathcomp"; then
|
||||
echo "mkdir $pathcomp"
|
||||
|
||||
mkdir "$pathcomp" || lasterr=$?
|
||||
|
||||
if test ! -d "$pathcomp"; then
|
||||
errstatus=$lasterr
|
||||
fi
|
||||
fi
|
||||
|
||||
pathcomp="$pathcomp/"
|
||||
done
|
||||
done
|
||||
|
||||
exit $errstatus
|
||||
|
||||
# mkinstalldirs ends here
|
||||
@@ -1,14 +0,0 @@
|
||||
Begin3
|
||||
Title: ProxyChains
|
||||
Version: 3.0
|
||||
Entered-date:
|
||||
Description:
|
||||
Keywords:
|
||||
Author: <N37CR347UR3>
|
||||
Maintained-by: <NetCreature>
|
||||
Primary-site:
|
||||
Home-page: http://proxychains.sourceforge.net
|
||||
Original-site:
|
||||
Platforms: Linux and other Unices
|
||||
Copying-policy: GNU Public License
|
||||
End
|
||||
@@ -1,38 +0,0 @@
|
||||
SUBDIRS = docs
|
||||
|
||||
EXTRA_DIST = proxychains.conf core.c core.h libproxychains.c
|
||||
|
||||
sysconf_DATA=$(srcdir)/proxychains.conf
|
||||
|
||||
install-data-local:
|
||||
$(mkinstalldirs) ${DESTDIR}${bindir}
|
||||
${INSTALL} $(srcdir)/proxychains ${DESTDIR}${bindir}/proxychains
|
||||
${INSTALL} $(srcdir)/proxyresolv ${DESTDIR}${bindir}/proxyresolv
|
||||
|
||||
uninstall-local:
|
||||
-rm -f ${DESTDIR}${bindir}/proxychains
|
||||
-rm -f ${DESTDIR}${bindir}/proxyresolv
|
||||
|
||||
#bin_PROGRAMS = proxychains
|
||||
|
||||
#proxychains_SOURCES = main.c
|
||||
|
||||
# set the include path found by configure
|
||||
INCLUDES= $(all_includes)
|
||||
|
||||
#proxychains_LDFLAGS = $(all_libraries)
|
||||
lib_LTLIBRARIES = libproxychains.la
|
||||
libproxychains_la_LDFLAGS = -version-info 3:0:0 $(all_libraries)
|
||||
libproxychains_la_LIBADD= -ldl
|
||||
noinst_HEADERS = core.h
|
||||
libproxychains_la_SOURCES= libproxychains.c core.c
|
||||
libproxychains_la_METASOURCES = USE_AUTOMOC
|
||||
|
||||
|
||||
|
||||
#install-private: install
|
||||
# $(mkinstalldirs) $(HOME)/bin
|
||||
# $(INSTALL_DATA) $(srcdir)/proxychains $(HOME)/bin/proxychains
|
||||
#
|
||||
#uninstall-private: uninstall
|
||||
# -rm -f $(HOME)/bin/proxychains
|
||||
@@ -1,496 +0,0 @@
|
||||
# Makefile.in generated automatically by automake 1.4-p6 from Makefile.am
|
||||
|
||||
# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
|
||||
SHELL = @SHELL@
|
||||
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
VPATH = @srcdir@
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
|
||||
bindir = @bindir@
|
||||
sbindir = @sbindir@
|
||||
libexecdir = @libexecdir@
|
||||
datadir = @datadir@
|
||||
sysconfdir = @sysconfdir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
localstatedir = @localstatedir@
|
||||
libdir = @libdir@
|
||||
infodir = @infodir@
|
||||
mandir = @mandir@
|
||||
includedir = @includedir@
|
||||
oldincludedir = /usr/include
|
||||
|
||||
DESTDIR =
|
||||
|
||||
pkgdatadir = $(datadir)/@PACKAGE@
|
||||
pkglibdir = $(libdir)/@PACKAGE@
|
||||
pkgincludedir = $(includedir)/@PACKAGE@
|
||||
|
||||
top_builddir = ..
|
||||
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
AUTOMAKE = @AUTOMAKE@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
transform = @program_transform_name@
|
||||
|
||||
NORMAL_INSTALL = :
|
||||
PRE_INSTALL = :
|
||||
POST_INSTALL = :
|
||||
NORMAL_UNINSTALL = :
|
||||
PRE_UNINSTALL = :
|
||||
POST_UNINSTALL = :
|
||||
build_alias = @build_alias@
|
||||
build_triplet = @build@
|
||||
host_alias = @host_alias@
|
||||
host_triplet = @host@
|
||||
target_alias = @target_alias@
|
||||
target_triplet = @target@
|
||||
AR = @AR@
|
||||
AS = @AS@
|
||||
CC = @CC@
|
||||
CXX = @CXX@
|
||||
CXXCPP = @CXXCPP@
|
||||
DLLTOOL = @DLLTOOL@
|
||||
ECHO = @ECHO@
|
||||
EGREP = @EGREP@
|
||||
EXEEXT = @EXEEXT@
|
||||
F77 = @F77@
|
||||
GCJ = @GCJ@
|
||||
GCJFLAGS = @GCJFLAGS@
|
||||
HAVE_LIB = @HAVE_LIB@
|
||||
LIB = @LIB@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
LN_S = @LN_S@
|
||||
LTLIB = @LTLIB@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
OBJDUMP = @OBJDUMP@
|
||||
OBJEXT = @OBJEXT@
|
||||
PACKAGE = @PACKAGE@
|
||||
RANLIB = @RANLIB@
|
||||
RC = @RC@
|
||||
STRIP = @STRIP@
|
||||
VERSION = @VERSION@
|
||||
|
||||
SUBDIRS = docs
|
||||
|
||||
EXTRA_DIST = proxychains.conf core.c core.h libproxychains.c
|
||||
|
||||
sysconf_DATA = $(srcdir)/proxychains.conf
|
||||
|
||||
#bin_PROGRAMS = proxychains
|
||||
|
||||
#proxychains_SOURCES = main.c
|
||||
|
||||
# set the include path found by configure
|
||||
INCLUDES = $(all_includes)
|
||||
|
||||
#proxychains_LDFLAGS = $(all_libraries)
|
||||
lib_LTLIBRARIES = libproxychains.la
|
||||
libproxychains_la_LDFLAGS = -version-info 3:0:0 $(all_libraries)
|
||||
libproxychains_la_LIBADD = -ldl
|
||||
noinst_HEADERS = core.h
|
||||
libproxychains_la_SOURCES = libproxychains.c core.c
|
||||
libproxychains_la_METASOURCES = USE_AUTOMOC
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
||||
CONFIG_HEADER = ../config.h
|
||||
CONFIG_CLEAN_FILES =
|
||||
LTLIBRARIES = $(lib_LTLIBRARIES)
|
||||
|
||||
|
||||
DEFS = @DEFS@ -I. -I$(srcdir) -I..
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBS = @LIBS@
|
||||
libproxychains_la_DEPENDENCIES =
|
||||
libproxychains_la_OBJECTS = libproxychains.lo core.lo
|
||||
CFLAGS = @CFLAGS@
|
||||
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||
CCLD = $(CC)
|
||||
LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
|
||||
DATA = $(sysconf_DATA)
|
||||
|
||||
HEADERS = $(noinst_HEADERS)
|
||||
|
||||
DIST_COMMON = Makefile.am Makefile.in
|
||||
|
||||
|
||||
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
|
||||
|
||||
TAR = tar
|
||||
GZIP_ENV = --best
|
||||
DEP_FILES = .deps/core.P .deps/libproxychains.P
|
||||
SOURCES = $(libproxychains_la_SOURCES)
|
||||
OBJECTS = $(libproxychains_la_OBJECTS)
|
||||
|
||||
all: all-redirect
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .S .c .lo .o .obj .s
|
||||
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
|
||||
cd $(top_srcdir) && $(AUTOMAKE) --gnu proxychains/Makefile
|
||||
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES)
|
||||
cd $(top_builddir) \
|
||||
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
|
||||
|
||||
|
||||
mostlyclean-libLTLIBRARIES:
|
||||
|
||||
clean-libLTLIBRARIES:
|
||||
-test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
|
||||
|
||||
distclean-libLTLIBRARIES:
|
||||
|
||||
maintainer-clean-libLTLIBRARIES:
|
||||
|
||||
install-libLTLIBRARIES: $(lib_LTLIBRARIES)
|
||||
@$(NORMAL_INSTALL)
|
||||
$(mkinstalldirs) $(DESTDIR)$(libdir)
|
||||
@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
|
||||
if test -f $$p; then \
|
||||
echo "$(LIBTOOL) --mode=install $(INSTALL) $$p $(DESTDIR)$(libdir)/$$p"; \
|
||||
$(LIBTOOL) --mode=install $(INSTALL) $$p $(DESTDIR)$(libdir)/$$p; \
|
||||
else :; fi; \
|
||||
done
|
||||
|
||||
uninstall-libLTLIBRARIES:
|
||||
@$(NORMAL_UNINSTALL)
|
||||
list='$(lib_LTLIBRARIES)'; for p in $$list; do \
|
||||
$(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$$p; \
|
||||
done
|
||||
|
||||
# FIXME: We should only use cygpath when building on Windows,
|
||||
# and only if it is available.
|
||||
.c.obj:
|
||||
$(COMPILE) -c `cygpath -w $<`
|
||||
|
||||
.s.o:
|
||||
$(COMPILE) -c $<
|
||||
|
||||
.S.o:
|
||||
$(COMPILE) -c $<
|
||||
|
||||
mostlyclean-compile:
|
||||
-rm -f *.o core *.core
|
||||
-rm -f *.$(OBJEXT)
|
||||
|
||||
clean-compile:
|
||||
|
||||
distclean-compile:
|
||||
-rm -f *.tab.c
|
||||
|
||||
maintainer-clean-compile:
|
||||
|
||||
.s.lo:
|
||||
$(LIBTOOL) --mode=compile $(COMPILE) -c $<
|
||||
|
||||
.S.lo:
|
||||
$(LIBTOOL) --mode=compile $(COMPILE) -c $<
|
||||
|
||||
mostlyclean-libtool:
|
||||
-rm -f *.lo
|
||||
|
||||
clean-libtool:
|
||||
-rm -rf .libs _libs
|
||||
|
||||
distclean-libtool:
|
||||
|
||||
maintainer-clean-libtool:
|
||||
|
||||
libproxychains.la: $(libproxychains_la_OBJECTS) $(libproxychains_la_DEPENDENCIES)
|
||||
$(LINK) -rpath $(libdir) $(libproxychains_la_LDFLAGS) $(libproxychains_la_OBJECTS) $(libproxychains_la_LIBADD) $(LIBS)
|
||||
|
||||
install-sysconfDATA: $(sysconf_DATA)
|
||||
@$(NORMAL_INSTALL)
|
||||
$(mkinstalldirs) $(DESTDIR)$(sysconfdir)
|
||||
@list='$(sysconf_DATA)'; for p in $$list; do \
|
||||
if test -f $(srcdir)/$$p; then \
|
||||
echo " $(INSTALL_DATA) $(srcdir)/$$p $(DESTDIR)$(sysconfdir)/$$p"; \
|
||||
$(INSTALL_DATA) $(srcdir)/$$p $(DESTDIR)$(sysconfdir)/$$p; \
|
||||
else if test -f $$p; then \
|
||||
echo " $(INSTALL_DATA) $$p $(DESTDIR)$(sysconfdir)/$$p"; \
|
||||
$(INSTALL_DATA) $$p $(DESTDIR)$(sysconfdir)/$$p; \
|
||||
fi; fi; \
|
||||
done
|
||||
|
||||
uninstall-sysconfDATA:
|
||||
@$(NORMAL_UNINSTALL)
|
||||
list='$(sysconf_DATA)'; for p in $$list; do \
|
||||
rm -f $(DESTDIR)$(sysconfdir)/$$p; \
|
||||
done
|
||||
|
||||
# This directory's subdirectories are mostly independent; you can cd
|
||||
# into them and run `make' without going through this Makefile.
|
||||
# To change the values of `make' variables: instead of editing Makefiles,
|
||||
# (1) if the variable is set in `config.status', edit `config.status'
|
||||
# (which will cause the Makefiles to be regenerated when you run `make');
|
||||
# (2) otherwise, pass the desired values on the `make' command line.
|
||||
|
||||
@SET_MAKE@
|
||||
|
||||
all-recursive install-data-recursive install-exec-recursive \
|
||||
installdirs-recursive install-recursive uninstall-recursive \
|
||||
check-recursive installcheck-recursive info-recursive dvi-recursive:
|
||||
@set fnord $$MAKEFLAGS; amf=$$2; \
|
||||
dot_seen=no; \
|
||||
target=`echo $@ | sed s/-recursive//`; \
|
||||
list='$(SUBDIRS)'; for subdir in $$list; do \
|
||||
echo "Making $$target in $$subdir"; \
|
||||
if test "$$subdir" = "."; then \
|
||||
dot_seen=yes; \
|
||||
local_target="$$target-am"; \
|
||||
else \
|
||||
local_target="$$target"; \
|
||||
fi; \
|
||||
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|
||||
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
|
||||
done; \
|
||||
if test "$$dot_seen" = "no"; then \
|
||||
$(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
|
||||
fi; test -z "$$fail"
|
||||
|
||||
mostlyclean-recursive clean-recursive distclean-recursive \
|
||||
maintainer-clean-recursive:
|
||||
@set fnord $$MAKEFLAGS; amf=$$2; \
|
||||
dot_seen=no; \
|
||||
rev=''; list='$(SUBDIRS)'; for subdir in $$list; do \
|
||||
rev="$$subdir $$rev"; \
|
||||
test "$$subdir" != "." || dot_seen=yes; \
|
||||
done; \
|
||||
test "$$dot_seen" = "no" && rev=". $$rev"; \
|
||||
target=`echo $@ | sed s/-recursive//`; \
|
||||
for subdir in $$rev; do \
|
||||
echo "Making $$target in $$subdir"; \
|
||||
if test "$$subdir" = "."; then \
|
||||
local_target="$$target-am"; \
|
||||
else \
|
||||
local_target="$$target"; \
|
||||
fi; \
|
||||
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|
||||
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
|
||||
done && test -z "$$fail"
|
||||
tags-recursive:
|
||||
list='$(SUBDIRS)'; for subdir in $$list; do \
|
||||
test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
|
||||
done
|
||||
|
||||
tags: TAGS
|
||||
|
||||
ID: $(HEADERS) $(SOURCES) $(LISP)
|
||||
list='$(SOURCES) $(HEADERS)'; \
|
||||
unique=`for i in $$list; do echo $$i; done | \
|
||||
awk ' { files[$$0] = 1; } \
|
||||
END { for (i in files) print i; }'`; \
|
||||
here=`pwd` && cd $(srcdir) \
|
||||
&& mkid -f$$here/ID $$unique $(LISP)
|
||||
|
||||
TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP)
|
||||
tags=; \
|
||||
here=`pwd`; \
|
||||
list='$(SUBDIRS)'; for subdir in $$list; do \
|
||||
if test "$$subdir" = .; then :; else \
|
||||
test -f $$subdir/TAGS && tags="$$tags -i $$here/$$subdir/TAGS"; \
|
||||
fi; \
|
||||
done; \
|
||||
list='$(SOURCES) $(HEADERS)'; \
|
||||
unique=`for i in $$list; do echo $$i; done | \
|
||||
awk ' { files[$$0] = 1; } \
|
||||
END { for (i in files) print i; }'`; \
|
||||
test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
|
||||
|| (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS)
|
||||
|
||||
mostlyclean-tags:
|
||||
|
||||
clean-tags:
|
||||
|
||||
distclean-tags:
|
||||
-rm -f TAGS ID
|
||||
|
||||
maintainer-clean-tags:
|
||||
|
||||
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
|
||||
|
||||
subdir = proxychains
|
||||
|
||||
distdir: $(DISTFILES)
|
||||
here=`cd $(top_builddir) && pwd`; \
|
||||
top_distdir=`cd $(top_distdir) && pwd`; \
|
||||
distdir=`cd $(distdir) && pwd`; \
|
||||
cd $(top_srcdir) \
|
||||
&& $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu proxychains/Makefile
|
||||
@for file in $(DISTFILES); do \
|
||||
d=$(srcdir); \
|
||||
if test -d $$d/$$file; then \
|
||||
cp -pr $$d/$$file $(distdir)/$$file; \
|
||||
else \
|
||||
test -f $(distdir)/$$file \
|
||||
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|
||||
|| cp -p $$d/$$file $(distdir)/$$file || :; \
|
||||
fi; \
|
||||
done
|
||||
for subdir in $(SUBDIRS); do \
|
||||
if test "$$subdir" = .; then :; else \
|
||||
test -d $(distdir)/$$subdir \
|
||||
|| mkdir $(distdir)/$$subdir \
|
||||
|| exit 1; \
|
||||
chmod 777 $(distdir)/$$subdir; \
|
||||
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir=../$(top_distdir) distdir=../$(distdir)/$$subdir distdir) \
|
||||
|| exit 1; \
|
||||
fi; \
|
||||
done
|
||||
|
||||
DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :)
|
||||
|
||||
-include $(DEP_FILES)
|
||||
|
||||
mostlyclean-depend:
|
||||
|
||||
clean-depend:
|
||||
|
||||
distclean-depend:
|
||||
-rm -rf .deps
|
||||
|
||||
maintainer-clean-depend:
|
||||
|
||||
%.o: %.c
|
||||
@echo '$(COMPILE) -c $<'; \
|
||||
$(COMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
|
||||
@-cp .deps/$(*F).pp .deps/$(*F).P; \
|
||||
tr ' ' '\012' < .deps/$(*F).pp \
|
||||
| sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
|
||||
>> .deps/$(*F).P; \
|
||||
rm .deps/$(*F).pp
|
||||
|
||||
%.lo: %.c
|
||||
@echo '$(LTCOMPILE) -c $<'; \
|
||||
$(LTCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
|
||||
@-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \
|
||||
< .deps/$(*F).pp > .deps/$(*F).P; \
|
||||
tr ' ' '\012' < .deps/$(*F).pp \
|
||||
| sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
|
||||
>> .deps/$(*F).P; \
|
||||
rm -f .deps/$(*F).pp
|
||||
info-am:
|
||||
info: info-recursive
|
||||
dvi-am:
|
||||
dvi: dvi-recursive
|
||||
check-am: all-am
|
||||
check: check-recursive
|
||||
installcheck-am:
|
||||
installcheck: installcheck-recursive
|
||||
install-exec-am: install-libLTLIBRARIES install-sysconfDATA
|
||||
install-exec: install-exec-recursive
|
||||
|
||||
install-data-am: install-data-local
|
||||
install-data: install-data-recursive
|
||||
|
||||
install-am: all-am
|
||||
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
|
||||
install: install-recursive
|
||||
uninstall-am: uninstall-libLTLIBRARIES uninstall-sysconfDATA \
|
||||
uninstall-local
|
||||
uninstall: uninstall-recursive
|
||||
all-am: Makefile $(LTLIBRARIES) $(DATA) $(HEADERS)
|
||||
all-redirect: all-recursive
|
||||
install-strip:
|
||||
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
|
||||
installdirs: installdirs-recursive
|
||||
installdirs-am:
|
||||
$(mkinstalldirs) $(DESTDIR)$(libdir) $(DESTDIR)$(sysconfdir)
|
||||
|
||||
|
||||
mostlyclean-generic:
|
||||
|
||||
clean-generic:
|
||||
|
||||
distclean-generic:
|
||||
-rm -f Makefile $(CONFIG_CLEAN_FILES)
|
||||
-rm -f config.cache config.log stamp-h stamp-h[0-9]*
|
||||
|
||||
maintainer-clean-generic:
|
||||
mostlyclean-am: mostlyclean-libLTLIBRARIES mostlyclean-compile \
|
||||
mostlyclean-libtool mostlyclean-tags mostlyclean-depend \
|
||||
mostlyclean-generic
|
||||
|
||||
mostlyclean: mostlyclean-recursive
|
||||
|
||||
clean-am: clean-libLTLIBRARIES clean-compile clean-libtool clean-tags \
|
||||
clean-depend clean-generic mostlyclean-am
|
||||
|
||||
clean: clean-recursive
|
||||
|
||||
distclean-am: distclean-libLTLIBRARIES distclean-compile \
|
||||
distclean-libtool distclean-tags distclean-depend \
|
||||
distclean-generic clean-am
|
||||
-rm -f libtool
|
||||
|
||||
distclean: distclean-recursive
|
||||
|
||||
maintainer-clean-am: maintainer-clean-libLTLIBRARIES \
|
||||
maintainer-clean-compile maintainer-clean-libtool \
|
||||
maintainer-clean-tags maintainer-clean-depend \
|
||||
maintainer-clean-generic distclean-am
|
||||
@echo "This command is intended for maintainers to use;"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
|
||||
maintainer-clean: maintainer-clean-recursive
|
||||
|
||||
.PHONY: mostlyclean-libLTLIBRARIES distclean-libLTLIBRARIES \
|
||||
clean-libLTLIBRARIES maintainer-clean-libLTLIBRARIES \
|
||||
uninstall-libLTLIBRARIES install-libLTLIBRARIES mostlyclean-compile \
|
||||
distclean-compile clean-compile maintainer-clean-compile \
|
||||
mostlyclean-libtool distclean-libtool clean-libtool \
|
||||
maintainer-clean-libtool uninstall-sysconfDATA install-sysconfDATA \
|
||||
install-data-recursive uninstall-data-recursive install-exec-recursive \
|
||||
uninstall-exec-recursive installdirs-recursive uninstalldirs-recursive \
|
||||
all-recursive check-recursive installcheck-recursive info-recursive \
|
||||
dvi-recursive mostlyclean-recursive distclean-recursive clean-recursive \
|
||||
maintainer-clean-recursive tags tags-recursive mostlyclean-tags \
|
||||
distclean-tags clean-tags maintainer-clean-tags distdir \
|
||||
mostlyclean-depend distclean-depend clean-depend \
|
||||
maintainer-clean-depend info-am info dvi-am dvi check check-am \
|
||||
installcheck-am installcheck install-exec-am install-exec \
|
||||
install-data-local install-data-am install-data install-am install \
|
||||
uninstall-local uninstall-am uninstall all-redirect all-am all \
|
||||
installdirs-am installdirs mostlyclean-generic distclean-generic \
|
||||
clean-generic maintainer-clean-generic clean mostlyclean distclean \
|
||||
maintainer-clean
|
||||
|
||||
|
||||
install-data-local:
|
||||
$(mkinstalldirs) ${DESTDIR}${bindir}
|
||||
${INSTALL} $(srcdir)/proxychains ${DESTDIR}${bindir}/proxychains
|
||||
${INSTALL} $(srcdir)/proxyresolv ${DESTDIR}${bindir}/proxyresolv
|
||||
|
||||
uninstall-local:
|
||||
-rm -f ${DESTDIR}${bindir}/proxychains
|
||||
-rm -f ${DESTDIR}${bindir}/proxyresolv
|
||||
|
||||
#install-private: install
|
||||
# $(mkinstalldirs) $(HOME)/bin
|
||||
# $(INSTALL_DATA) $(srcdir)/proxychains $(HOME)/bin/proxychains
|
||||
#
|
||||
#uninstall-private: uninstall
|
||||
# -rm -f $(HOME)/bin/proxychains
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
||||
@@ -1,733 +0,0 @@
|
||||
/***************************************************************************
|
||||
core.c - description
|
||||
-------------------
|
||||
begin : Tue May 14 2002
|
||||
copyright : netcreature (C) 2002
|
||||
email : netcreature@users.sourceforge.net
|
||||
***************************************************************************/
|
||||
/* 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 *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <memory.h>
|
||||
#include <errno.h>
|
||||
#include <netdb.h>
|
||||
|
||||
#include <sys/utsname.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/poll.h>
|
||||
#include <sys/wait.h>
|
||||
#include <fcntl.h>
|
||||
#include <time.h>
|
||||
#include <stdarg.h>
|
||||
#include "core.h"
|
||||
|
||||
extern int tcp_read_time_out;
|
||||
extern int tcp_connect_time_out;
|
||||
extern int proxychains_quiet_mode;
|
||||
|
||||
static const char base64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
|
||||
static void encode_base_64(char* src,char* dest,int max_len)
|
||||
{
|
||||
int n,l,i;
|
||||
l=strlen(src);
|
||||
max_len=(max_len-1)/4;
|
||||
for ( i=0;i<max_len;i++,src+=3,l-=3)
|
||||
{
|
||||
switch (l) {
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
n=src[0] << 16;
|
||||
*dest++=base64[(n >> 18) & 077];
|
||||
*dest++=base64[(n >> 12) & 077];
|
||||
*dest++='=';
|
||||
*dest++='=';
|
||||
break;
|
||||
case 2:
|
||||
n=src[0] << 16 | src[1] << 8;
|
||||
*dest++=base64[(n >> 18) & 077];
|
||||
*dest++=base64[(n >> 12) & 077];
|
||||
*dest++=base64[(n >> 6) & 077];
|
||||
*dest++='=';
|
||||
break;
|
||||
default:
|
||||
n=src[0] << 16 | src[1] << 8 | src[2];
|
||||
*dest++=base64[(n >> 18) & 077];
|
||||
*dest++=base64[(n >> 12) & 077];
|
||||
*dest++=base64[(n >> 6) & 077];
|
||||
*dest++=base64[n & 077];
|
||||
}
|
||||
if (l<3) break;
|
||||
}
|
||||
*dest++=0;
|
||||
}
|
||||
|
||||
#define LOG_BUFF 1024*20
|
||||
|
||||
int proxychains_write_log(char *str,...)
|
||||
{
|
||||
char buff[LOG_BUFF];
|
||||
va_list arglist;
|
||||
FILE * log_file;
|
||||
log_file=stderr;
|
||||
if (!proxychains_quiet_mode)
|
||||
{
|
||||
va_start(arglist,str);
|
||||
vsprintf(buff,str,arglist);
|
||||
va_end(arglist);
|
||||
fprintf(log_file,"%s",buff);
|
||||
fflush(log_file);
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
static int write_n_bytes(int fd,char *buff,size_t size)
|
||||
{
|
||||
int i=0,wrote=0;
|
||||
for(;;)
|
||||
{
|
||||
i=write(fd,&buff[wrote],size-wrote);
|
||||
if(i<=0)
|
||||
return i;
|
||||
wrote+=i;
|
||||
if(wrote==size)
|
||||
return wrote;
|
||||
}
|
||||
}
|
||||
|
||||
static int read_line(int fd, char *buff, size_t size)
|
||||
{
|
||||
int i,ready;
|
||||
struct pollfd pfd[1];
|
||||
|
||||
pfd[0].fd=fd;
|
||||
pfd[0].events=POLLIN;
|
||||
for(i=0;i<size-1;i++)
|
||||
{
|
||||
pfd[0].revents=0;
|
||||
ready=poll(pfd,1,tcp_read_time_out);
|
||||
if(ready!=1 || !(pfd[0].revents&POLLIN) || 1!=read(fd,&buff[i],1))
|
||||
return -1;
|
||||
else if(buff[i]=='\n')
|
||||
{
|
||||
buff[i+1]=0;
|
||||
return (i+1);
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int read_n_bytes(int fd,char *buff, size_t size)
|
||||
{
|
||||
int i,ready;
|
||||
struct pollfd pfd[1];
|
||||
|
||||
pfd[0].fd=fd;
|
||||
pfd[0].events=POLLIN;
|
||||
for(i=0;i<size;i++)
|
||||
{
|
||||
pfd[0].revents=0;
|
||||
ready=poll(pfd,1,tcp_read_time_out);
|
||||
if(ready!=1 || !(pfd[0].revents&POLLIN) || 1!=read(fd,&buff[i],1))
|
||||
return -1;
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
static int timed_connect(int sock, const struct sockaddr *addr, unsigned int len)
|
||||
{
|
||||
int ret,value,value_len;
|
||||
struct pollfd pfd[1];
|
||||
|
||||
pfd[0].fd=sock;
|
||||
pfd[0].events=POLLOUT;
|
||||
fcntl(sock, F_SETFL, O_NONBLOCK);
|
||||
ret=true_connect(sock, addr, len);
|
||||
// printf("\nconnect ret=%d\n",ret);fflush(stdout);
|
||||
if(ret==-1 && errno==EINPROGRESS)
|
||||
{
|
||||
ret=poll(pfd,1,tcp_connect_time_out);
|
||||
// printf("\npoll ret=%d\n",ret);fflush(stdout);
|
||||
if(ret==1)
|
||||
{
|
||||
value_len=sizeof(int);
|
||||
getsockopt(sock,SOL_SOCKET,SO_ERROR,&value,&value_len) ;
|
||||
// printf("\nvalue=%d\n",value);fflush(stdout);
|
||||
if(!value)
|
||||
ret=0;
|
||||
else
|
||||
ret=-1;
|
||||
}
|
||||
else
|
||||
ret=-1;
|
||||
}
|
||||
else if (ret==0)
|
||||
;
|
||||
else
|
||||
ret=-1;
|
||||
|
||||
|
||||
fcntl(sock, F_SETFL, !O_NONBLOCK);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int tunnel_to(int sock, unsigned int ip, unsigned short port, proxy_type pt,char *user,char *pass)
|
||||
{
|
||||
int len;
|
||||
char buff[BUFF_SIZE];
|
||||
bzero (buff,sizeof(buff));
|
||||
switch(pt)
|
||||
{
|
||||
case HTTP_TYPE:
|
||||
{
|
||||
sprintf(buff,"CONNECT %s:%d HTTP/1.0\r\n",
|
||||
inet_ntoa( * (struct in_addr *) &ip),
|
||||
ntohs(port));
|
||||
if (user[0])
|
||||
{
|
||||
char src[256];
|
||||
char dst[512];
|
||||
strcpy(src,user);
|
||||
strcat(src,":");
|
||||
strcat(src,pass);
|
||||
encode_base_64(src,dst,512);
|
||||
strcat(buff,"Proxy-Authorization: Basic ");
|
||||
strcat(buff,dst);
|
||||
strcat(buff,"\r\n\r\n");
|
||||
}
|
||||
else
|
||||
strcat(buff,"\r\n");
|
||||
|
||||
len=strlen(buff);
|
||||
|
||||
if(len!=send(sock,buff,len,0))
|
||||
return SOCKET_ERROR;
|
||||
|
||||
bzero(buff,sizeof(buff));
|
||||
len=0 ;
|
||||
// read header byte by byte.
|
||||
while(len<BUFF_SIZE)
|
||||
{
|
||||
if(1==read_n_bytes(sock,buff+len,1))
|
||||
len++;
|
||||
else
|
||||
return SOCKET_ERROR;
|
||||
if ( len > 4 &&
|
||||
buff[len-1]=='\n' &&
|
||||
buff[len-2]=='\r' &&
|
||||
buff[len-3]=='\n' &&
|
||||
buff[len-4]=='\r' )
|
||||
break;
|
||||
}
|
||||
|
||||
// if not ok (200) or response greather than BUFF_SIZE return BLOCKED;
|
||||
if ( (len==BUFF_SIZE) ||
|
||||
! ( buff[9] =='2' &&
|
||||
buff[10]=='0' &&
|
||||
buff[11]=='0' ))
|
||||
return BLOCKED;
|
||||
return SUCCESS;
|
||||
}
|
||||
break;
|
||||
case SOCKS4_TYPE:
|
||||
{
|
||||
memset(buff,0,sizeof(buff));
|
||||
buff[0]=4; // socks version
|
||||
buff[1]=1; // connect command
|
||||
memcpy(&buff[2],&port,2); // dest port
|
||||
memcpy(&buff[4],&ip,4); // dest host
|
||||
len=strlen(user)+1; // username
|
||||
if(len>1)
|
||||
strcpy(&buff[8],user);
|
||||
if((len+8)!=write_n_bytes(sock,buff,(8+len)))
|
||||
return SOCKET_ERROR;
|
||||
|
||||
if(8!=read_n_bytes(sock,buff,8))
|
||||
return SOCKET_ERROR;
|
||||
|
||||
if (buff[0]!=0||buff[1]!=90)
|
||||
return BLOCKED;
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
break;
|
||||
case SOCKS5_TYPE:
|
||||
{
|
||||
if(user)
|
||||
{
|
||||
buff[0]=5; //version
|
||||
buff[1]=2; //nomber of methods
|
||||
buff[2]=0; // no auth method
|
||||
buff[3]=2; /// auth method -> username / password
|
||||
if(4!=write_n_bytes(sock,buff,4))
|
||||
return SOCKET_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
buff[0]=5; //version
|
||||
buff[1]=1; //nomber of methods
|
||||
buff[2]=0; // no auth method
|
||||
if(3!=write_n_bytes(sock,buff,3))
|
||||
return SOCKET_ERROR;
|
||||
}
|
||||
|
||||
memset(buff,0,sizeof(buff));
|
||||
|
||||
if(2!=read_n_bytes(sock,buff,2))
|
||||
return SOCKET_ERROR;
|
||||
|
||||
if (buff[0]!=5||(buff[1]!=0&&buff[1]!=2))
|
||||
{
|
||||
if((buff[0]==0x05)&&(buff[1]==(char)0xFF))
|
||||
return BLOCKED;
|
||||
else
|
||||
return SOCKET_ERROR;
|
||||
}
|
||||
|
||||
if (buff[1]==2)
|
||||
{
|
||||
// authentication
|
||||
char in[2];
|
||||
char out[515]; char* cur=out;
|
||||
int c;
|
||||
*cur++=1; // version
|
||||
c=strlen(user);
|
||||
*cur++=c;
|
||||
strncpy(cur,user,c);
|
||||
cur+=c;
|
||||
c=strlen(pass);
|
||||
*cur++=c;
|
||||
strncpy(cur,pass,c);
|
||||
cur+=c;
|
||||
|
||||
if((cur-out)!=write_n_bytes(sock,out,cur-out))
|
||||
return SOCKET_ERROR;
|
||||
|
||||
|
||||
if(2!=read_n_bytes(sock,in,2))
|
||||
return SOCKET_ERROR;
|
||||
if(in[0]!=1||in[1]!=0)
|
||||
{
|
||||
if(in[0]!=1)
|
||||
return SOCKET_ERROR;
|
||||
else
|
||||
return BLOCKED;
|
||||
}
|
||||
}
|
||||
|
||||
buff[0]=5; // version
|
||||
buff[1]=1; // connect
|
||||
buff[2]=0; // reserved
|
||||
buff[3]=1; // ip v4
|
||||
|
||||
memcpy(&buff[4],&ip,4); // dest host
|
||||
memcpy(&buff[8],&port,2); // dest port
|
||||
|
||||
|
||||
if(10!=write_n_bytes(sock,buff,10))
|
||||
return SOCKET_ERROR;
|
||||
|
||||
if(4!=read_n_bytes(sock,buff,4))
|
||||
return SOCKET_ERROR;
|
||||
|
||||
if (buff[0]!=5||buff[1]!=0)
|
||||
return SOCKET_ERROR;
|
||||
|
||||
switch (buff[3])
|
||||
{
|
||||
case 1: len=4; break;
|
||||
case 4: len=16; break;
|
||||
case 3: len=0;
|
||||
if(1!=read_n_bytes(sock,(char*)&len,1))
|
||||
return SOCKET_ERROR;
|
||||
break;
|
||||
default:
|
||||
return SOCKET_ERROR;
|
||||
}
|
||||
|
||||
if((len+2)!=read_n_bytes(sock,buff,(len+2)))
|
||||
return SOCKET_ERROR;
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
return SOCKET_ERROR;
|
||||
}
|
||||
|
||||
static int start_chain(int *fd, proxy_data *pd, char* begin_mark)
|
||||
{
|
||||
struct sockaddr_in addr;
|
||||
|
||||
*fd=socket(PF_INET,SOCK_STREAM,0);
|
||||
if(*fd==-1)
|
||||
goto error;
|
||||
|
||||
proxychains_write_log("%s-<>-%s:%d-",
|
||||
begin_mark,
|
||||
inet_ntoa(*(struct in_addr*)&pd->ip),
|
||||
htons(pd->port));
|
||||
pd->ps=PLAY_STATE;
|
||||
bzero(&addr,sizeof(addr));
|
||||
addr.sin_family = AF_INET;
|
||||
addr.sin_addr.s_addr = pd->ip;
|
||||
addr.sin_port = pd->port;
|
||||
if (timed_connect (*fd ,(struct sockaddr*)&addr,sizeof(addr))) {
|
||||
pd->ps=DOWN_STATE;
|
||||
goto error1;
|
||||
}
|
||||
pd->ps=BUSY_STATE;
|
||||
return SUCCESS;
|
||||
error1:
|
||||
proxychains_write_log("<--timeout\n");
|
||||
error:
|
||||
if(*fd!=-1)
|
||||
close(*fd);
|
||||
return SOCKET_ERROR;
|
||||
}
|
||||
|
||||
static proxy_data * select_proxy(select_type how,
|
||||
proxy_data *pd, int proxy_count, int *offset)
|
||||
{
|
||||
int i=0,k=0;
|
||||
if(*offset>=proxy_count)
|
||||
return NULL;
|
||||
switch(how) {
|
||||
case RANDOMLY:
|
||||
srand(time(NULL));
|
||||
do {
|
||||
k++;
|
||||
i = 0 + (int) (proxy_count*1.0*rand()/
|
||||
(RAND_MAX+1.0));
|
||||
} while (pd[i].ps!=PLAY_STATE && k<proxy_count*100 );
|
||||
break;
|
||||
case FIFOLY:
|
||||
for(i=*offset;i<proxy_count;i++) {
|
||||
if(pd[i].ps==PLAY_STATE) {
|
||||
*offset=i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (i>=proxy_count)
|
||||
i=0;
|
||||
return pd[i].ps==PLAY_STATE?&pd[i]:NULL;
|
||||
}
|
||||
|
||||
|
||||
static void release_all(proxy_data *pd, int proxy_count)
|
||||
{
|
||||
int i;
|
||||
for(i=0;i<proxy_count;i++)
|
||||
pd[i].ps=PLAY_STATE;
|
||||
return;
|
||||
}
|
||||
|
||||
static void release_busy(proxy_data *pd, int proxy_count)
|
||||
{
|
||||
int i;
|
||||
for(i=0;i<proxy_count;i++)
|
||||
if(pd[i].ps==BUSY_STATE)
|
||||
pd[i].ps=PLAY_STATE;
|
||||
return;
|
||||
}
|
||||
|
||||
static int calc_alive(proxy_data *pd, int proxy_count)
|
||||
{
|
||||
int i;
|
||||
int alive_count=0;
|
||||
release_busy(pd,proxy_count);
|
||||
for(i=0;i<proxy_count;i++)
|
||||
if(pd[i].ps==PLAY_STATE)
|
||||
alive_count++;
|
||||
return alive_count;
|
||||
}
|
||||
|
||||
|
||||
static int chain_step(int ns, proxy_data *pfrom, proxy_data *pto)
|
||||
{
|
||||
int retcode=-1;
|
||||
|
||||
proxychains_write_log("<>-%s:%d-",
|
||||
inet_ntoa(*(struct in_addr*)&pto->ip),
|
||||
htons(pto->port));
|
||||
retcode =
|
||||
tunnel_to(ns, pto->ip, pto->port, pfrom->pt, pfrom->user,
|
||||
pfrom->pass);
|
||||
switch(retcode) {
|
||||
case SUCCESS:
|
||||
pto->ps=BUSY_STATE;
|
||||
break;
|
||||
case BLOCKED:
|
||||
pto->ps=BLOCKED_STATE;
|
||||
proxychains_write_log("<--denied\n");
|
||||
close(ns);
|
||||
break;
|
||||
case SOCKET_ERROR:
|
||||
pto->ps=DOWN_STATE;
|
||||
proxychains_write_log("<--timeout\n");
|
||||
close(ns);
|
||||
break;
|
||||
}
|
||||
return retcode;
|
||||
}
|
||||
|
||||
int connect_proxy_chain( int sock, unsigned int target_ip,
|
||||
unsigned short target_port, proxy_data *pd,
|
||||
unsigned int proxy_count, chain_type ct, int max_chain )
|
||||
{
|
||||
proxy_data p4;
|
||||
proxy_data *p1,*p2,*p3;
|
||||
int ns=-1;
|
||||
int offset=0;
|
||||
int alive_count=0;
|
||||
int curr_len=0;
|
||||
|
||||
#define TP "<>"
|
||||
#define DT "|D-chain|"
|
||||
#define ST "|S-chain|"
|
||||
#define RT "|R-chain|"
|
||||
|
||||
p3=&p4;
|
||||
|
||||
again:
|
||||
switch(ct) {
|
||||
case DYNAMIC_TYPE:
|
||||
alive_count=calc_alive(pd,proxy_count);
|
||||
offset=0;
|
||||
do {
|
||||
if(!(p1=select_proxy(FIFOLY,pd,proxy_count,&offset)))
|
||||
goto error_more;
|
||||
} while(SUCCESS!=start_chain(&ns,p1,DT) && offset<proxy_count);
|
||||
for(;;) {
|
||||
p2=select_proxy(FIFOLY,pd,proxy_count,&offset);
|
||||
if(!p2)
|
||||
break;
|
||||
if(SUCCESS!=chain_step(ns,p1,p2))
|
||||
goto again;
|
||||
p1=p2;
|
||||
}
|
||||
proxychains_write_log(TP);
|
||||
p3->ip=target_ip;
|
||||
p3->port=target_port;
|
||||
if(SUCCESS!=chain_step(ns,p1,p3))
|
||||
goto error;
|
||||
break;
|
||||
|
||||
case STRICT_TYPE:
|
||||
alive_count=calc_alive(pd,proxy_count);
|
||||
offset=0;
|
||||
if(!(p1=select_proxy(FIFOLY,pd,proxy_count,&offset)))
|
||||
goto error_strict;
|
||||
if(SUCCESS!=start_chain(&ns,p1,ST))
|
||||
goto error_strict;
|
||||
while(offset<proxy_count) {
|
||||
if(!(p2=select_proxy(FIFOLY,pd,proxy_count,&offset)))
|
||||
break;
|
||||
if(SUCCESS!=chain_step(ns,p1,p2))
|
||||
goto error_strict;
|
||||
p1=p2;
|
||||
}
|
||||
proxychains_write_log(TP);
|
||||
p3->ip=target_ip;
|
||||
p3->port=target_port;
|
||||
if(SUCCESS!=chain_step(ns,p1,p3))
|
||||
goto error;
|
||||
break;
|
||||
|
||||
case RANDOM_TYPE:
|
||||
alive_count=calc_alive(pd,proxy_count);
|
||||
if(alive_count<max_chain)
|
||||
goto error_more;
|
||||
curr_len=offset=0;
|
||||
do {
|
||||
if(!(p1=select_proxy(RANDOMLY,pd,proxy_count,&offset)))
|
||||
goto error_more;
|
||||
} while(SUCCESS!=start_chain(&ns,p1,RT) && offset<max_chain);
|
||||
while(++curr_len<max_chain) {
|
||||
if(!(p2=select_proxy(RANDOMLY,pd,proxy_count,&offset)))
|
||||
goto error_more;
|
||||
if(SUCCESS!=chain_step(ns,p1,p2))
|
||||
goto again;
|
||||
p1=p2;
|
||||
}
|
||||
proxychains_write_log(TP);
|
||||
p3->ip=target_ip;
|
||||
p3->port=target_port;
|
||||
if(SUCCESS!=chain_step(ns,p1,p3))
|
||||
goto error;
|
||||
|
||||
}
|
||||
|
||||
done:
|
||||
proxychains_write_log("<><>-OK\n");
|
||||
dup2(ns,sock);
|
||||
close(ns);
|
||||
return 0;
|
||||
error:
|
||||
if(ns!=-1)
|
||||
close(ns);
|
||||
errno = ECONNREFUSED; // for nmap ;)
|
||||
return -1;
|
||||
|
||||
error_more:
|
||||
proxychains_write_log("\n!!!need more proxies!!!\n");
|
||||
error_strict:
|
||||
release_all(pd,proxy_count);
|
||||
if(ns!=-1)
|
||||
close(ns);
|
||||
errno = ETIMEDOUT;
|
||||
return -1;
|
||||
}
|
||||
|
||||
static struct hostent hostent_space;
|
||||
static in_addr_t resolved_addr;
|
||||
static char* resolved_addr_p;
|
||||
static char addr_name[1024*8];
|
||||
struct hostent* proxy_gethostbyname(const char *name)
|
||||
{
|
||||
int pipe_fd[2];
|
||||
char buff[256];
|
||||
in_addr_t addr;
|
||||
pid_t pid;
|
||||
int status;
|
||||
struct hostent* hp;
|
||||
|
||||
hostent_space.h_addr_list = &resolved_addr_p;
|
||||
*hostent_space.h_addr_list = (char*)&resolved_addr;
|
||||
resolved_addr = 0;
|
||||
|
||||
gethostname(buff,sizeof(buff));
|
||||
if(!strcmp(buff,name))
|
||||
goto got_buff;
|
||||
|
||||
bzero(buff,sizeof(buff));
|
||||
|
||||
// TODO: this works only once, so cache it ...
|
||||
// later
|
||||
while (hp=gethostent())
|
||||
if (!strcmp(hp->h_name,name))
|
||||
return hp;
|
||||
|
||||
if(pipe(pipe_fd))
|
||||
goto err;
|
||||
pid = fork();
|
||||
switch(pid) {
|
||||
|
||||
case 0: // child
|
||||
proxychains_write_log("|DNS-request| %s \n", name);
|
||||
dup2(pipe_fd[1],1);
|
||||
//dup2(pipe_fd[1],2);
|
||||
// putenv("LD_PRELOAD=");
|
||||
execlp("proxyresolv","proxyresolv",name,NULL);
|
||||
perror("can't exec proxyresolv");
|
||||
exit(2);
|
||||
|
||||
case -1: //error
|
||||
close(pipe_fd[0]);
|
||||
close(pipe_fd[1]);
|
||||
perror("can't fork");
|
||||
goto err;
|
||||
|
||||
default:
|
||||
close(pipe_fd[1]);
|
||||
waitpid(pid, &status, 0);
|
||||
read(pipe_fd[0],&buff,sizeof(buff));
|
||||
close(pipe_fd[0]);
|
||||
got_buff:
|
||||
addr = inet_addr(buff);
|
||||
if (addr == -1)
|
||||
goto err_dns;
|
||||
memcpy(*(hostent_space.h_addr_list),
|
||||
&addr ,sizeof(struct in_addr));
|
||||
hostent_space.h_name = addr_name;
|
||||
hostent_space.h_length = sizeof (in_addr_t);
|
||||
}
|
||||
proxychains_write_log("|DNS-response| %s is %s\n",
|
||||
name, inet_ntoa(*(struct in_addr*)&addr));
|
||||
return &hostent_space;
|
||||
err_dns:
|
||||
proxychains_write_log("|DNS-response|: %s is not exist\n", name);
|
||||
err:
|
||||
return NULL;
|
||||
}
|
||||
int proxy_getaddrinfo(const char *node, const char *service,
|
||||
const struct addrinfo *hints,
|
||||
struct addrinfo **res)
|
||||
{
|
||||
struct servent *se = NULL;
|
||||
struct hostent *hp = NULL;
|
||||
struct sockaddr* sockaddr_space = NULL;
|
||||
struct addrinfo* addrinfo_space = NULL;
|
||||
|
||||
// printf("proxy_getaddrinfo node %s service %s\n",node,service);
|
||||
addrinfo_space = malloc(sizeof(struct addrinfo));
|
||||
if(!addrinfo_space)
|
||||
goto err1;
|
||||
sockaddr_space = malloc(sizeof(struct sockaddr));
|
||||
if(!sockaddr_space)
|
||||
goto err2;
|
||||
bzero(sockaddr_space, sizeof(*sockaddr_space));
|
||||
bzero(addrinfo_space, sizeof(*addrinfo_space));
|
||||
if (node &&
|
||||
!inet_aton(node,&((struct sockaddr_in*)sockaddr_space)->sin_addr)) {
|
||||
hp = proxy_gethostbyname(node);
|
||||
if (hp)
|
||||
memcpy(&((struct sockaddr_in*)sockaddr_space)->sin_addr,
|
||||
*(hp->h_addr_list),
|
||||
sizeof(in_addr_t));
|
||||
else
|
||||
goto err3;
|
||||
}
|
||||
if (service)
|
||||
se = getservbyname(service, NULL);
|
||||
|
||||
if (!se) {
|
||||
((struct sockaddr_in*)sockaddr_space)->sin_port =
|
||||
htons(atoi(service?:"0"));
|
||||
} else
|
||||
((struct sockaddr_in*)sockaddr_space)->sin_port = se->s_port;
|
||||
|
||||
*res = addrinfo_space;
|
||||
(*res)->ai_addr = sockaddr_space;
|
||||
if (node)
|
||||
strcpy(addr_name, node);
|
||||
(*res)->ai_canonname = addr_name;
|
||||
(*res)->ai_next = NULL;
|
||||
(*res)->ai_family = sockaddr_space->sa_family = AF_INET;
|
||||
(*res)->ai_socktype = hints->ai_socktype;
|
||||
(*res)->ai_flags = hints->ai_flags;
|
||||
(*res)->ai_protocol = hints->ai_protocol;
|
||||
(*res)->ai_addrlen = sizeof(*sockaddr_space);
|
||||
goto out;
|
||||
err3:
|
||||
free(sockaddr_space);
|
||||
err2:
|
||||
free(addrinfo_space);
|
||||
err1:
|
||||
return 1;
|
||||
out:
|
||||
return 0;
|
||||
}
|
||||
@@ -1,112 +0,0 @@
|
||||
/***************************************************************************
|
||||
core.h - description
|
||||
-------------------
|
||||
begin : Tue May 14 2002
|
||||
copyright : netcreature (C) 2002
|
||||
email : netcreature@users.sourceforge.net
|
||||
***************************************************************************/
|
||||
/* 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 *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
#ifndef __CORE_HEADER
|
||||
#define __CORE_HEADER
|
||||
#define BUFF_SIZE 8*1024 // used to read responses from proxies.
|
||||
#define MAX_LOCALNET 1024
|
||||
/*error codes*/
|
||||
typedef enum
|
||||
{
|
||||
SUCCESS=0,
|
||||
MEMORY_FAIL, // malloc failed
|
||||
SOCKET_ERROR, // look errno for more
|
||||
CHAIN_DOWN, // no proxy in chain responds to tcp
|
||||
CHAIN_EMPTY, // if proxy_count = 0
|
||||
BLOCKED // target's port blocked on last proxy in the chain
|
||||
} ERR_CODE;
|
||||
|
||||
|
||||
typedef enum {HTTP_TYPE,SOCKS4_TYPE,SOCKS5_TYPE} proxy_type;
|
||||
typedef enum {DYNAMIC_TYPE,STRICT_TYPE,RANDOM_TYPE} chain_type;
|
||||
typedef enum {PLAY_STATE,DOWN_STATE,BLOCKED_STATE,BUSY_STATE} proxy_state;
|
||||
typedef enum {RANDOMLY,FIFOLY} select_type;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
struct in_addr in_addr, netmask;
|
||||
unsigned short port;
|
||||
} localaddr_arg;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned int ip;
|
||||
unsigned short port;
|
||||
proxy_type pt;
|
||||
proxy_state ps;
|
||||
char user[256];
|
||||
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,
|
||||
unsigned int target_ip,
|
||||
unsigned short target_port,
|
||||
proxy_data * pd,
|
||||
unsigned int proxy_count,
|
||||
chain_type ct,
|
||||
int max_chain );
|
||||
|
||||
int proxychains_write_log(char *str,...);
|
||||
struct hostent* proxy_gethostbyname(const char *name);
|
||||
|
||||
|
||||
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;
|
||||
|
||||
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);
|
||||
|
||||
#if 0
|
||||
#define PDEBUG(fmt, args...) fprintf(stderr,"DEBUG:"fmt, ## args)
|
||||
#else
|
||||
#define PDEBUG(fmt, args...)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,5 +0,0 @@
|
||||
####### kdevelop will overwrite this part!!! (begin)##########
|
||||
|
||||
SUBDIRS = en
|
||||
|
||||
####### kdevelop will overwrite this part!!! (end)############
|
||||
@@ -1,308 +0,0 @@
|
||||
# Makefile.in generated automatically by automake 1.4-p6 from Makefile.am
|
||||
|
||||
# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
####### kdevelop will overwrite this part!!! (begin)##########
|
||||
|
||||
|
||||
SHELL = @SHELL@
|
||||
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
VPATH = @srcdir@
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
|
||||
bindir = @bindir@
|
||||
sbindir = @sbindir@
|
||||
libexecdir = @libexecdir@
|
||||
datadir = @datadir@
|
||||
sysconfdir = @sysconfdir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
localstatedir = @localstatedir@
|
||||
libdir = @libdir@
|
||||
infodir = @infodir@
|
||||
mandir = @mandir@
|
||||
includedir = @includedir@
|
||||
oldincludedir = /usr/include
|
||||
|
||||
DESTDIR =
|
||||
|
||||
pkgdatadir = $(datadir)/@PACKAGE@
|
||||
pkglibdir = $(libdir)/@PACKAGE@
|
||||
pkgincludedir = $(includedir)/@PACKAGE@
|
||||
|
||||
top_builddir = ../..
|
||||
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
AUTOMAKE = @AUTOMAKE@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
transform = @program_transform_name@
|
||||
|
||||
NORMAL_INSTALL = :
|
||||
PRE_INSTALL = :
|
||||
POST_INSTALL = :
|
||||
NORMAL_UNINSTALL = :
|
||||
PRE_UNINSTALL = :
|
||||
POST_UNINSTALL = :
|
||||
build_alias = @build_alias@
|
||||
build_triplet = @build@
|
||||
host_alias = @host_alias@
|
||||
host_triplet = @host@
|
||||
target_alias = @target_alias@
|
||||
target_triplet = @target@
|
||||
AR = @AR@
|
||||
AS = @AS@
|
||||
CC = @CC@
|
||||
CXX = @CXX@
|
||||
CXXCPP = @CXXCPP@
|
||||
DLLTOOL = @DLLTOOL@
|
||||
ECHO = @ECHO@
|
||||
EGREP = @EGREP@
|
||||
EXEEXT = @EXEEXT@
|
||||
F77 = @F77@
|
||||
GCJ = @GCJ@
|
||||
GCJFLAGS = @GCJFLAGS@
|
||||
HAVE_LIB = @HAVE_LIB@
|
||||
LIB = @LIB@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
LN_S = @LN_S@
|
||||
LTLIB = @LTLIB@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
OBJDUMP = @OBJDUMP@
|
||||
OBJEXT = @OBJEXT@
|
||||
PACKAGE = @PACKAGE@
|
||||
RANLIB = @RANLIB@
|
||||
RC = @RC@
|
||||
STRIP = @STRIP@
|
||||
VERSION = @VERSION@
|
||||
|
||||
SUBDIRS = en
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
||||
CONFIG_HEADER = ../../config.h
|
||||
CONFIG_CLEAN_FILES =
|
||||
DIST_COMMON = Makefile.am Makefile.in
|
||||
|
||||
|
||||
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
|
||||
|
||||
TAR = tar
|
||||
GZIP_ENV = --best
|
||||
all: all-redirect
|
||||
.SUFFIXES:
|
||||
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
|
||||
cd $(top_srcdir) && $(AUTOMAKE) --gnu proxychains/docs/Makefile
|
||||
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES)
|
||||
cd $(top_builddir) \
|
||||
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
|
||||
|
||||
|
||||
# This directory's subdirectories are mostly independent; you can cd
|
||||
# into them and run `make' without going through this Makefile.
|
||||
# To change the values of `make' variables: instead of editing Makefiles,
|
||||
# (1) if the variable is set in `config.status', edit `config.status'
|
||||
# (which will cause the Makefiles to be regenerated when you run `make');
|
||||
# (2) otherwise, pass the desired values on the `make' command line.
|
||||
|
||||
@SET_MAKE@
|
||||
|
||||
all-recursive install-data-recursive install-exec-recursive \
|
||||
installdirs-recursive install-recursive uninstall-recursive \
|
||||
check-recursive installcheck-recursive info-recursive dvi-recursive:
|
||||
@set fnord $$MAKEFLAGS; amf=$$2; \
|
||||
dot_seen=no; \
|
||||
target=`echo $@ | sed s/-recursive//`; \
|
||||
list='$(SUBDIRS)'; for subdir in $$list; do \
|
||||
echo "Making $$target in $$subdir"; \
|
||||
if test "$$subdir" = "."; then \
|
||||
dot_seen=yes; \
|
||||
local_target="$$target-am"; \
|
||||
else \
|
||||
local_target="$$target"; \
|
||||
fi; \
|
||||
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|
||||
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
|
||||
done; \
|
||||
if test "$$dot_seen" = "no"; then \
|
||||
$(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
|
||||
fi; test -z "$$fail"
|
||||
|
||||
mostlyclean-recursive clean-recursive distclean-recursive \
|
||||
maintainer-clean-recursive:
|
||||
@set fnord $$MAKEFLAGS; amf=$$2; \
|
||||
dot_seen=no; \
|
||||
rev=''; list='$(SUBDIRS)'; for subdir in $$list; do \
|
||||
rev="$$subdir $$rev"; \
|
||||
test "$$subdir" != "." || dot_seen=yes; \
|
||||
done; \
|
||||
test "$$dot_seen" = "no" && rev=". $$rev"; \
|
||||
target=`echo $@ | sed s/-recursive//`; \
|
||||
for subdir in $$rev; do \
|
||||
echo "Making $$target in $$subdir"; \
|
||||
if test "$$subdir" = "."; then \
|
||||
local_target="$$target-am"; \
|
||||
else \
|
||||
local_target="$$target"; \
|
||||
fi; \
|
||||
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|
||||
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
|
||||
done && test -z "$$fail"
|
||||
tags-recursive:
|
||||
list='$(SUBDIRS)'; for subdir in $$list; do \
|
||||
test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
|
||||
done
|
||||
|
||||
tags: TAGS
|
||||
|
||||
ID: $(HEADERS) $(SOURCES) $(LISP)
|
||||
list='$(SOURCES) $(HEADERS)'; \
|
||||
unique=`for i in $$list; do echo $$i; done | \
|
||||
awk ' { files[$$0] = 1; } \
|
||||
END { for (i in files) print i; }'`; \
|
||||
here=`pwd` && cd $(srcdir) \
|
||||
&& mkid -f$$here/ID $$unique $(LISP)
|
||||
|
||||
TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP)
|
||||
tags=; \
|
||||
here=`pwd`; \
|
||||
list='$(SUBDIRS)'; for subdir in $$list; do \
|
||||
if test "$$subdir" = .; then :; else \
|
||||
test -f $$subdir/TAGS && tags="$$tags -i $$here/$$subdir/TAGS"; \
|
||||
fi; \
|
||||
done; \
|
||||
list='$(SOURCES) $(HEADERS)'; \
|
||||
unique=`for i in $$list; do echo $$i; done | \
|
||||
awk ' { files[$$0] = 1; } \
|
||||
END { for (i in files) print i; }'`; \
|
||||
test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
|
||||
|| (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS)
|
||||
|
||||
mostlyclean-tags:
|
||||
|
||||
clean-tags:
|
||||
|
||||
distclean-tags:
|
||||
-rm -f TAGS ID
|
||||
|
||||
maintainer-clean-tags:
|
||||
|
||||
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
|
||||
|
||||
subdir = proxychains/docs
|
||||
|
||||
distdir: $(DISTFILES)
|
||||
here=`cd $(top_builddir) && pwd`; \
|
||||
top_distdir=`cd $(top_distdir) && pwd`; \
|
||||
distdir=`cd $(distdir) && pwd`; \
|
||||
cd $(top_srcdir) \
|
||||
&& $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu proxychains/docs/Makefile
|
||||
@for file in $(DISTFILES); do \
|
||||
d=$(srcdir); \
|
||||
if test -d $$d/$$file; then \
|
||||
cp -pr $$d/$$file $(distdir)/$$file; \
|
||||
else \
|
||||
test -f $(distdir)/$$file \
|
||||
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|
||||
|| cp -p $$d/$$file $(distdir)/$$file || :; \
|
||||
fi; \
|
||||
done
|
||||
for subdir in $(SUBDIRS); do \
|
||||
if test "$$subdir" = .; then :; else \
|
||||
test -d $(distdir)/$$subdir \
|
||||
|| mkdir $(distdir)/$$subdir \
|
||||
|| exit 1; \
|
||||
chmod 777 $(distdir)/$$subdir; \
|
||||
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir=../$(top_distdir) distdir=../$(distdir)/$$subdir distdir) \
|
||||
|| exit 1; \
|
||||
fi; \
|
||||
done
|
||||
info-am:
|
||||
info: info-recursive
|
||||
dvi-am:
|
||||
dvi: dvi-recursive
|
||||
check-am: all-am
|
||||
check: check-recursive
|
||||
installcheck-am:
|
||||
installcheck: installcheck-recursive
|
||||
install-exec-am:
|
||||
install-exec: install-exec-recursive
|
||||
|
||||
install-data-am:
|
||||
install-data: install-data-recursive
|
||||
|
||||
install-am: all-am
|
||||
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
|
||||
install: install-recursive
|
||||
uninstall-am:
|
||||
uninstall: uninstall-recursive
|
||||
all-am: Makefile
|
||||
all-redirect: all-recursive
|
||||
install-strip:
|
||||
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
|
||||
installdirs: installdirs-recursive
|
||||
installdirs-am:
|
||||
|
||||
|
||||
mostlyclean-generic:
|
||||
|
||||
clean-generic:
|
||||
|
||||
distclean-generic:
|
||||
-rm -f Makefile $(CONFIG_CLEAN_FILES)
|
||||
-rm -f config.cache config.log stamp-h stamp-h[0-9]*
|
||||
|
||||
maintainer-clean-generic:
|
||||
mostlyclean-am: mostlyclean-tags mostlyclean-generic
|
||||
|
||||
mostlyclean: mostlyclean-recursive
|
||||
|
||||
clean-am: clean-tags clean-generic mostlyclean-am
|
||||
|
||||
clean: clean-recursive
|
||||
|
||||
distclean-am: distclean-tags distclean-generic clean-am
|
||||
-rm -f libtool
|
||||
|
||||
distclean: distclean-recursive
|
||||
|
||||
maintainer-clean-am: maintainer-clean-tags maintainer-clean-generic \
|
||||
distclean-am
|
||||
@echo "This command is intended for maintainers to use;"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
|
||||
maintainer-clean: maintainer-clean-recursive
|
||||
|
||||
.PHONY: install-data-recursive uninstall-data-recursive \
|
||||
install-exec-recursive uninstall-exec-recursive installdirs-recursive \
|
||||
uninstalldirs-recursive all-recursive check-recursive \
|
||||
installcheck-recursive info-recursive dvi-recursive \
|
||||
mostlyclean-recursive distclean-recursive clean-recursive \
|
||||
maintainer-clean-recursive tags tags-recursive mostlyclean-tags \
|
||||
distclean-tags clean-tags maintainer-clean-tags distdir info-am info \
|
||||
dvi-am dvi check check-am installcheck-am installcheck install-exec-am \
|
||||
install-exec install-data-am install-data install-am install \
|
||||
uninstall-am uninstall all-redirect all-am all installdirs-am \
|
||||
installdirs mostlyclean-generic distclean-generic clean-generic \
|
||||
maintainer-clean-generic clean mostlyclean distclean maintainer-clean
|
||||
|
||||
|
||||
####### kdevelop will overwrite this part!!! (end)############
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
||||
@@ -1,4 +0,0 @@
|
||||
####### kdevelop will overwrite this part!!! (begin)##########
|
||||
|
||||
|
||||
####### kdevelop will overwrite this part!!! (end)############
|
||||
@@ -1,202 +0,0 @@
|
||||
# Makefile.in generated automatically by automake 1.4-p6 from Makefile.am
|
||||
|
||||
# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
####### kdevelop will overwrite this part!!! (begin)##########
|
||||
|
||||
####### kdevelop will overwrite this part!!! (end)############
|
||||
|
||||
|
||||
SHELL = @SHELL@
|
||||
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
VPATH = @srcdir@
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
|
||||
bindir = @bindir@
|
||||
sbindir = @sbindir@
|
||||
libexecdir = @libexecdir@
|
||||
datadir = @datadir@
|
||||
sysconfdir = @sysconfdir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
localstatedir = @localstatedir@
|
||||
libdir = @libdir@
|
||||
infodir = @infodir@
|
||||
mandir = @mandir@
|
||||
includedir = @includedir@
|
||||
oldincludedir = /usr/include
|
||||
|
||||
DESTDIR =
|
||||
|
||||
pkgdatadir = $(datadir)/@PACKAGE@
|
||||
pkglibdir = $(libdir)/@PACKAGE@
|
||||
pkgincludedir = $(includedir)/@PACKAGE@
|
||||
|
||||
top_builddir = ../../..
|
||||
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
AUTOMAKE = @AUTOMAKE@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
transform = @program_transform_name@
|
||||
|
||||
NORMAL_INSTALL = :
|
||||
PRE_INSTALL = :
|
||||
POST_INSTALL = :
|
||||
NORMAL_UNINSTALL = :
|
||||
PRE_UNINSTALL = :
|
||||
POST_UNINSTALL = :
|
||||
build_alias = @build_alias@
|
||||
build_triplet = @build@
|
||||
host_alias = @host_alias@
|
||||
host_triplet = @host@
|
||||
target_alias = @target_alias@
|
||||
target_triplet = @target@
|
||||
AR = @AR@
|
||||
AS = @AS@
|
||||
CC = @CC@
|
||||
CXX = @CXX@
|
||||
CXXCPP = @CXXCPP@
|
||||
DLLTOOL = @DLLTOOL@
|
||||
ECHO = @ECHO@
|
||||
EGREP = @EGREP@
|
||||
EXEEXT = @EXEEXT@
|
||||
F77 = @F77@
|
||||
GCJ = @GCJ@
|
||||
GCJFLAGS = @GCJFLAGS@
|
||||
HAVE_LIB = @HAVE_LIB@
|
||||
LIB = @LIB@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
LN_S = @LN_S@
|
||||
LTLIB = @LTLIB@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
OBJDUMP = @OBJDUMP@
|
||||
OBJEXT = @OBJEXT@
|
||||
PACKAGE = @PACKAGE@
|
||||
RANLIB = @RANLIB@
|
||||
RC = @RC@
|
||||
STRIP = @STRIP@
|
||||
VERSION = @VERSION@
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
||||
CONFIG_HEADER = ../../../config.h
|
||||
CONFIG_CLEAN_FILES =
|
||||
DIST_COMMON = Makefile.am Makefile.in
|
||||
|
||||
|
||||
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
|
||||
|
||||
TAR = tar
|
||||
GZIP_ENV = --best
|
||||
all: all-redirect
|
||||
.SUFFIXES:
|
||||
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
|
||||
cd $(top_srcdir) && $(AUTOMAKE) --gnu proxychains/docs/en/Makefile
|
||||
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES)
|
||||
cd $(top_builddir) \
|
||||
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
|
||||
|
||||
tags: TAGS
|
||||
TAGS:
|
||||
|
||||
|
||||
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
|
||||
|
||||
subdir = proxychains/docs/en
|
||||
|
||||
distdir: $(DISTFILES)
|
||||
here=`cd $(top_builddir) && pwd`; \
|
||||
top_distdir=`cd $(top_distdir) && pwd`; \
|
||||
distdir=`cd $(distdir) && pwd`; \
|
||||
cd $(top_srcdir) \
|
||||
&& $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu proxychains/docs/en/Makefile
|
||||
@for file in $(DISTFILES); do \
|
||||
d=$(srcdir); \
|
||||
if test -d $$d/$$file; then \
|
||||
cp -pr $$d/$$file $(distdir)/$$file; \
|
||||
else \
|
||||
test -f $(distdir)/$$file \
|
||||
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|
||||
|| cp -p $$d/$$file $(distdir)/$$file || :; \
|
||||
fi; \
|
||||
done
|
||||
info-am:
|
||||
info: info-am
|
||||
dvi-am:
|
||||
dvi: dvi-am
|
||||
check-am: all-am
|
||||
check: check-am
|
||||
installcheck-am:
|
||||
installcheck: installcheck-am
|
||||
install-exec-am:
|
||||
install-exec: install-exec-am
|
||||
|
||||
install-data-am:
|
||||
install-data: install-data-am
|
||||
|
||||
install-am: all-am
|
||||
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
|
||||
install: install-am
|
||||
uninstall-am:
|
||||
uninstall: uninstall-am
|
||||
all-am: Makefile
|
||||
all-redirect: all-am
|
||||
install-strip:
|
||||
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
|
||||
installdirs:
|
||||
|
||||
|
||||
mostlyclean-generic:
|
||||
|
||||
clean-generic:
|
||||
|
||||
distclean-generic:
|
||||
-rm -f Makefile $(CONFIG_CLEAN_FILES)
|
||||
-rm -f config.cache config.log stamp-h stamp-h[0-9]*
|
||||
|
||||
maintainer-clean-generic:
|
||||
mostlyclean-am: mostlyclean-generic
|
||||
|
||||
mostlyclean: mostlyclean-am
|
||||
|
||||
clean-am: clean-generic mostlyclean-am
|
||||
|
||||
clean: clean-am
|
||||
|
||||
distclean-am: distclean-generic clean-am
|
||||
-rm -f libtool
|
||||
|
||||
distclean: distclean-am
|
||||
|
||||
maintainer-clean-am: maintainer-clean-generic distclean-am
|
||||
@echo "This command is intended for maintainers to use;"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
|
||||
maintainer-clean: maintainer-clean-am
|
||||
|
||||
.PHONY: tags distdir info-am info dvi-am dvi check check-am \
|
||||
installcheck-am installcheck install-exec-am install-exec \
|
||||
install-data-am install-data install-am install uninstall-am uninstall \
|
||||
all-redirect all-am all installdirs mostlyclean-generic \
|
||||
distclean-generic clean-generic maintainer-clean-generic clean \
|
||||
mostlyclean distclean maintainer-clean
|
||||
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
||||
@@ -1,395 +0,0 @@
|
||||
/***************************************************************************
|
||||
libproxychains.c - description
|
||||
-------------------
|
||||
begin : Tue May 14 2002
|
||||
copyright : netcreature (C) 2002
|
||||
email : netcreature@users.sourceforge.net
|
||||
***************************************************************************/
|
||||
/* 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 *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
#define _GNU_SOURCE
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <memory.h>
|
||||
#include <errno.h>
|
||||
#include <netdb.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <dlfcn.h>
|
||||
|
||||
|
||||
#include "core.h"
|
||||
|
||||
#define satosin(x) ((struct sockaddr_in *) &(x))
|
||||
#define SOCKADDR(x) (satosin(x)->sin_addr.s_addr)
|
||||
#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
|
||||
|
||||
int tcp_read_time_out;
|
||||
int tcp_connect_time_out;
|
||||
chain_type proxychains_ct;
|
||||
proxy_data proxychains_pd[MAX_CHAIN];
|
||||
int proxychains_proxy_count = 0;
|
||||
int proxychains_got_chain_data = 0;
|
||||
int proxychains_max_chain = 1;
|
||||
int proxychains_quiet_mode = 0;
|
||||
int proxychains_resolver = 0;
|
||||
static int init_l = 0;
|
||||
localaddr_arg localnet_addr[MAX_LOCALNET];
|
||||
size_t num_localnet_addr = 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)
|
||||
{
|
||||
// proxychains_write_log("ProxyChains-"VERSION
|
||||
// " (http://proxychains.sf.net)\n");
|
||||
|
||||
get_chain_data(proxychains_pd,&proxychains_proxy_count,&proxychains_ct);
|
||||
true_connect = (connect_t) dlsym(RTLD_NEXT, "connect");
|
||||
|
||||
if (!true_connect) {
|
||||
fprintf(stderr, "Cannot load symbol 'connect' %s\n", dlerror());
|
||||
exit(1);
|
||||
} else {
|
||||
// PDEBUG( "loaded symbol 'connect'"
|
||||
// " real addr %p wrapped addr %p\n",
|
||||
// true_connect, connect);
|
||||
}
|
||||
true_gethostbyname = (gethostbyname_t)
|
||||
dlsym(RTLD_NEXT, "gethostbyname");
|
||||
|
||||
if (!true_gethostbyname) {
|
||||
fprintf(stderr, "Cannot load symbol 'gethostbyname' %s\n",
|
||||
dlerror());
|
||||
exit(1);
|
||||
} else {
|
||||
// PDEBUG( "loaded symbol 'gethostbyname'"
|
||||
// " real addr %p wrapped addr %p\n",
|
||||
// true_gethostbyname, gethostbyname);
|
||||
}
|
||||
true_getaddrinfo = (getaddrinfo_t)
|
||||
dlsym(RTLD_NEXT, "getaddrinfo");
|
||||
|
||||
if (!true_getaddrinfo) {
|
||||
fprintf(stderr, "Cannot load symbol 'getaddrinfo' %s\n",
|
||||
dlerror());
|
||||
exit(1);
|
||||
} else {
|
||||
// PDEBUG( "loaded symbol 'getaddrinfo'"
|
||||
// " real addr %p wrapped addr %p\n",
|
||||
// true_getaddrinfo, getaddrinfo);
|
||||
}
|
||||
true_freeaddrinfo = (freeaddrinfo_t)
|
||||
dlsym(RTLD_NEXT, "freeaddrinfo");
|
||||
|
||||
if (!true_freeaddrinfo) {
|
||||
fprintf(stderr, "Cannot load symbol 'freeaddrinfo' %s\n",
|
||||
dlerror());
|
||||
exit(1);
|
||||
} else {
|
||||
// PDEBUG( "loaded symbol 'freeaddrinfo'"
|
||||
// " real addr %p wrapped addr %p\n",
|
||||
// true_freeaddrinfo, freeaddrinfo);
|
||||
}
|
||||
true_gethostbyaddr = (gethostbyaddr_t)
|
||||
dlsym(RTLD_NEXT, "gethostbyaddr");
|
||||
|
||||
if (!true_gethostbyaddr) {
|
||||
fprintf(stderr, "Cannot load symbol 'gethostbyaddr' %s\n",
|
||||
dlerror());
|
||||
exit(1);
|
||||
} else {
|
||||
// PDEBUG( "loaded symbol 'gethostbyaddr'"
|
||||
// " real addr %p wrapped addr %p\n",
|
||||
// true_gethostbyaddr, gethostbyaddr);
|
||||
}
|
||||
true_getnameinfo = (getnameinfo_t)
|
||||
dlsym(RTLD_NEXT, "getnameinfo");
|
||||
|
||||
if (!true_getnameinfo) {
|
||||
fprintf(stderr, "Cannot load symbol 'getnameinfo' %s\n",
|
||||
dlerror());
|
||||
exit(1);
|
||||
} else {
|
||||
// PDEBUG( "loaded symbol 'getnameinfo'"
|
||||
// " real addr %p wrapped addr %p\n",
|
||||
// true_getnameinfo, 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];
|
||||
char local_in_addr_port[32];
|
||||
char local_in_addr[32], local_in_port[32], local_netmask[32];
|
||||
FILE* file;
|
||||
|
||||
if(proxychains_got_chain_data)
|
||||
return;
|
||||
|
||||
//Some defaults
|
||||
tcp_read_time_out=4*1000;
|
||||
tcp_connect_time_out=10*1000;
|
||||
*ct=DYNAMIC_TYPE;
|
||||
|
||||
snprintf(buff,256,"%s/.proxychains/proxychains.conf",getenv("HOME"));
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
while(fgets(buff,sizeof(buff),file)) {
|
||||
if(buff[strspn(buff," ")]!='#') {
|
||||
if(list) {
|
||||
bzero(&pd[count], 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);
|
||||
pd[count].ip=inet_addr(host);
|
||||
pd[count].port=htons((unsigned short)port_n);
|
||||
if(!strcmp(type,"http")) {
|
||||
pd[count].pt=HTTP_TYPE;
|
||||
}else if(!strcmp(type,"socks4")) {
|
||||
pd[count].pt=SOCKS4_TYPE;
|
||||
}else if(!strcmp(type,"socks5")) {
|
||||
pd[count].pt=SOCKS5_TYPE;
|
||||
}else continue;
|
||||
|
||||
if( pd[count].ip && pd[count].ip!=-1 && port_n)
|
||||
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) {
|
||||
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]));
|
||||
|
||||
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);
|
||||
} else {
|
||||
PDEBUG("added localnet: netaddr=%s, port=%s, netmask=%s\n",
|
||||
local_in_addr, local_in_port, local_netmask);
|
||||
}
|
||||
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)
|
||||
{
|
||||
fprintf(stderr, "localnet address error\n");
|
||||
exit(1);
|
||||
}
|
||||
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);
|
||||
} else {
|
||||
localnet_addr[num_localnet_addr].port = 0;
|
||||
}
|
||||
++num_localnet_addr;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose(file);
|
||||
*proxy_count=count;
|
||||
proxychains_got_chain_data=1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int connect (int sock, const struct sockaddr *addr, unsigned int len)
|
||||
{
|
||||
int socktype=0,optlen=0,flags=0,ret=0;
|
||||
char str[256];
|
||||
struct in_addr *p_addr_in;
|
||||
unsigned short port;
|
||||
size_t i;
|
||||
|
||||
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);
|
||||
|
||||
p_addr_in = &((struct sockaddr_in *)addr)->sin_addr;
|
||||
port = ntohs(((struct sockaddr_in *)addr)->sin_port);
|
||||
|
||||
//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);
|
||||
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) {
|
||||
PDEBUG("accessing localnet using true_connect\n");
|
||||
return true_connect(sock,addr,len);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
flags=fcntl(sock, F_GETFL, 0);
|
||||
if(flags & O_NONBLOCK)
|
||||
fcntl(sock, F_SETFL, !O_NONBLOCK);
|
||||
ret=connect_proxy_chain(
|
||||
sock,
|
||||
SOCKADDR(*addr),
|
||||
SOCKPORT(*addr),
|
||||
proxychains_pd,
|
||||
proxychains_proxy_count,
|
||||
proxychains_ct,
|
||||
proxychains_max_chain );
|
||||
fcntl(sock, F_SETFL, flags);
|
||||
if(ret!=SUCCESS)
|
||||
errno=ECONNREFUSED;
|
||||
return ret;
|
||||
}
|
||||
|
||||
struct hostent *gethostbyname(const char *name)
|
||||
{
|
||||
PDEBUG("gethostbyname: %s\n",name);
|
||||
if(!init_l)
|
||||
init_lib();
|
||||
if(proxychains_resolver)
|
||||
return proxy_gethostbyname(name);
|
||||
else
|
||||
return true_gethostbyname(name);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
int getaddrinfo(const char *node, const char *service,
|
||||
const struct addrinfo *hints,
|
||||
struct addrinfo **res)
|
||||
{
|
||||
int ret = 0;
|
||||
PDEBUG("getaddrinfo: %s %s\n",node ,service);
|
||||
if(!init_l)
|
||||
init_lib();
|
||||
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)
|
||||
{
|
||||
PDEBUG("freeaddrinfo %p \n",res);
|
||||
if(!init_l)
|
||||
init_lib();
|
||||
if(!proxychains_resolver)
|
||||
true_freeaddrinfo(res);
|
||||
else {
|
||||
free(res->ai_addr);
|
||||
free(res);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
int getnameinfo (const struct sockaddr * sa,
|
||||
socklen_t salen, char * host,
|
||||
socklen_t hostlen, char * serv,
|
||||
socklen_t servlen, unsigned int flags)
|
||||
{
|
||||
int ret = 0;
|
||||
if(!init_l)
|
||||
init_lib();
|
||||
if(!proxychains_resolver) {
|
||||
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)));
|
||||
}
|
||||
PDEBUG("getnameinfo: %s %s\n", host, serv);
|
||||
return ret;
|
||||
}
|
||||
|
||||
struct hostent *gethostbyaddr (const void *addr, socklen_t len, int type)
|
||||
{
|
||||
PDEBUG("TODO: gethostbyaddr hook\n");
|
||||
if(!init_l)
|
||||
init_lib();
|
||||
if(!proxychains_resolver)
|
||||
return true_gethostbyaddr(addr,len,type);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
/***************************************************************************
|
||||
main.c - description
|
||||
-------------------
|
||||
begin : Tue May 14 2002
|
||||
copyright : netcreature (C) 2002
|
||||
email : netcreature@users.sourceforge.net
|
||||
***************************************************************************/
|
||||
/* 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 *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
/*
|
||||
* well ... actually this file could be a shell script ... but C rulez :).
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <memory.h>
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if(argc<2)
|
||||
{
|
||||
printf("\nUsage: proxychains program_name [arguments]\n"
|
||||
"\t for example : proxychains telnet somehost.com\n"
|
||||
"More help in README file\n");
|
||||
return 0 ;
|
||||
}
|
||||
putenv("LD_PRELOAD=/usr/lib/libproxychains.so");
|
||||
execvp(argv[1],&argv[1]);
|
||||
perror("proxychains can't load process....");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
#!/bin/sh
|
||||
echo "ProxyChains-3.1 (http://proxychains.sf.net)"
|
||||
if [ $# = 0 ] ; then
|
||||
echo " usage:"
|
||||
echo " proxychains <prog> [args]"
|
||||
exit
|
||||
fi
|
||||
export LD_PRELOAD=libproxychains.so
|
||||
exec "$@"
|
||||
@@ -1,75 +0,0 @@
|
||||
# proxychains.conf VER 3.1
|
||||
#
|
||||
# HTTP, SOCKS4, SOCKS5 tunneling proxifier with DNS.
|
||||
#
|
||||
|
||||
# The option below identifies how the ProxyList is treated.
|
||||
# only one option should be uncommented at time,
|
||||
# otherwise the last appearing option will be accepted
|
||||
#
|
||||
#dynamic_chain
|
||||
#
|
||||
# Dynamic - Each connection will be done via chained proxies
|
||||
# all proxies chained in the order as they appear in the list
|
||||
# at least one proxy must be online to play in chain
|
||||
# (dead proxies are skipped)
|
||||
# otherwise EINTR is returned to the app
|
||||
#
|
||||
strict_chain
|
||||
#
|
||||
# Strict - Each connection will be done via chained proxies
|
||||
# all proxies chained in the order as they appear in the list
|
||||
# all proxies must be online to play in chain
|
||||
# otherwise EINTR is returned to the app
|
||||
#
|
||||
#random_chain
|
||||
#
|
||||
# Random - Each connection will be done via random proxy
|
||||
# (or proxy chain, see chain_len) from the list.
|
||||
# this option is good to test your IDS :)
|
||||
|
||||
# Make sense only if random_chain
|
||||
#chain_len = 2
|
||||
|
||||
# Quiet mode (no output from library)
|
||||
#quiet_mode
|
||||
|
||||
# Proxy DNS requests - no leak for DNS data
|
||||
proxy_dns
|
||||
|
||||
# Some timeouts in milliseconds
|
||||
tcp_read_time_out 15000
|
||||
tcp_connect_time_out 8000
|
||||
|
||||
# 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
|
||||
|
||||
## Exclude connections to 192.168.100.0/24
|
||||
# localnet 192.168.100.0/255.255.255.0
|
||||
|
||||
## Exclude connections to ANYwhere with port 80
|
||||
# localnet 0.0.0.0:80/0.0.0.0
|
||||
|
||||
# ProxyList format
|
||||
# type host port [user pass]
|
||||
# (values separated by 'tab' or 'blank')
|
||||
#
|
||||
#
|
||||
# Examples:
|
||||
#
|
||||
# socks5 192.168.67.78 1080 lamer secret
|
||||
# http 192.168.89.3 8080 justu hidden
|
||||
# socks4 192.168.1.49 1080
|
||||
# http 192.168.39.93 8080
|
||||
#
|
||||
#
|
||||
# proxy types: http, socks4, socks5
|
||||
# ( auth types supported: "basic"-http "user/pass"-socks )
|
||||
#
|
||||
[ProxyList]
|
||||
# add proxy here ...
|
||||
# meanwile
|
||||
# defaults set to "tor"
|
||||
socks4 127.0.0.1 9050
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
#!/bin/sh
|
||||
# This script is called by proxychains to resolve DNS names
|
||||
|
||||
# DNS server used to resolve names
|
||||
DNS_SERVER=4.2.2.2
|
||||
|
||||
|
||||
if [ $# = 0 ] ; then
|
||||
echo " usage:"
|
||||
echo " proxyresolv <hostname> "
|
||||
exit
|
||||
fi
|
||||
|
||||
|
||||
export LD_PRELOAD=libproxychains.so
|
||||
dig $1 @$DNS_SERVER +tcp | awk '/A.+[0-9]+\.[0-9]+\.[0-9]/{print $5;}'
|
||||
@@ -0,0 +1,360 @@
|
||||
#undef _GNU_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
#undef _POSIX_C_SOURCE
|
||||
#define _DARWIN_C_SOURCE
|
||||
#include <limits.h>
|
||||
#include <pthread.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/select.h>
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <errno.h>
|
||||
#include <sys/mman.h>
|
||||
#include "allocator_thread.h"
|
||||
#include "debug.h"
|
||||
#include "ip_type.h"
|
||||
#include "mutex.h"
|
||||
#include "hash.h"
|
||||
#include "remotedns.h"
|
||||
|
||||
/* stuff for our internal translation table */
|
||||
|
||||
typedef struct {
|
||||
uint32_t hash;
|
||||
char* string;
|
||||
} string_hash_tuple;
|
||||
|
||||
typedef struct {
|
||||
uint32_t counter;
|
||||
uint32_t capa;
|
||||
string_hash_tuple** list;
|
||||
} internal_ip_lookup_table;
|
||||
|
||||
static void *dumpstring(char* s, size_t len) {
|
||||
char* p = malloc(len);
|
||||
if(p) memcpy(p, s, len);
|
||||
return p;
|
||||
}
|
||||
|
||||
static pthread_mutex_t *internal_ips_lock;
|
||||
static internal_ip_lookup_table *internal_ips;
|
||||
|
||||
uint32_t index_from_internal_ip(ip_type4 internalip) {
|
||||
PFUNC();
|
||||
ip_type4 tmp = internalip;
|
||||
uint32_t ret;
|
||||
ret = tmp.octet[3] + (tmp.octet[2] << 8) + (tmp.octet[1] << 16);
|
||||
ret -= 1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
char *string_from_internal_ip(ip_type4 internalip) {
|
||||
PFUNC();
|
||||
char *res = NULL;
|
||||
uint32_t index = index_from_internal_ip(internalip);
|
||||
if(index < internal_ips->counter)
|
||||
res = internal_ips->list[index]->string;
|
||||
return res;
|
||||
}
|
||||
|
||||
extern unsigned int remote_dns_subnet;
|
||||
ip_type4 make_internal_ip(uint32_t index) {
|
||||
ip_type4 ret;
|
||||
index++; // so we can start at .0.0.1
|
||||
if(index > 0xFFFFFF)
|
||||
return IPT4_INVALID;
|
||||
ret.octet[0] = remote_dns_subnet & 0xFF;
|
||||
ret.octet[1] = (index & 0xFF0000) >> 16;
|
||||
ret.octet[2] = (index & 0xFF00) >> 8;
|
||||
ret.octet[3] = index & 0xFF;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static ip_type4 ip_from_internal_list(char* name, size_t len) {
|
||||
uint32_t hash = dalias_hash((char *) name);
|
||||
size_t i;
|
||||
ip_type4 res;
|
||||
void* new_mem;
|
||||
// see if we already have this dns entry saved.
|
||||
if(internal_ips->counter) {
|
||||
for(i = 0; i < internal_ips->counter; i++) {
|
||||
if(internal_ips->list[i]->hash == hash && !strcmp(name, internal_ips->list[i]->string)) {
|
||||
res = make_internal_ip(i);
|
||||
PDEBUG("got cached ip for %s\n", name);
|
||||
goto have_ip;
|
||||
}
|
||||
}
|
||||
}
|
||||
// grow list if needed.
|
||||
if(internal_ips->capa < internal_ips->counter + 1) {
|
||||
PDEBUG("realloc\n");
|
||||
new_mem = realloc(internal_ips->list, (internal_ips->capa + 16) * sizeof(void *));
|
||||
if(new_mem) {
|
||||
internal_ips->capa += 16;
|
||||
internal_ips->list = new_mem;
|
||||
} else {
|
||||
oom:
|
||||
PDEBUG("out of mem\n");
|
||||
goto err_plus_unlock;
|
||||
}
|
||||
}
|
||||
|
||||
res = make_internal_ip(internal_ips->counter);
|
||||
if(res.as_int == IPT4_INVALID.as_int)
|
||||
goto err_plus_unlock;
|
||||
|
||||
string_hash_tuple tmp = { 0 };
|
||||
new_mem = dumpstring((char*) &tmp, sizeof(string_hash_tuple));
|
||||
if(!new_mem)
|
||||
goto oom;
|
||||
|
||||
PDEBUG("creating new entry %d for ip of %s\n", (int) internal_ips->counter, name);
|
||||
|
||||
internal_ips->list[internal_ips->counter] = new_mem;
|
||||
internal_ips->list[internal_ips->counter]->hash = hash;
|
||||
|
||||
new_mem = dumpstring((char*) name, len);
|
||||
|
||||
if(!new_mem) {
|
||||
internal_ips->list[internal_ips->counter] = 0;
|
||||
goto oom;
|
||||
}
|
||||
internal_ips->list[internal_ips->counter]->string = new_mem;
|
||||
|
||||
internal_ips->counter += 1;
|
||||
|
||||
have_ip:
|
||||
|
||||
return res;
|
||||
err_plus_unlock:
|
||||
|
||||
PDEBUG("return err\n");
|
||||
return IPT4_INVALID;
|
||||
}
|
||||
|
||||
/* stuff for communication with the allocator thread */
|
||||
|
||||
enum at_direction {
|
||||
ATD_SERVER = 0,
|
||||
ATD_CLIENT,
|
||||
ATD_MAX,
|
||||
};
|
||||
|
||||
static pthread_t allocator_thread;
|
||||
int req_pipefd[2];
|
||||
int resp_pipefd[2];
|
||||
|
||||
static int wait_data(int readfd) {
|
||||
PFUNC();
|
||||
fd_set fds;
|
||||
FD_ZERO(&fds);
|
||||
FD_SET(readfd, &fds);
|
||||
int ret;
|
||||
while((ret = select(readfd+1, &fds, NULL, NULL, NULL)) <= 0) {
|
||||
if(ret < 0) {
|
||||
int e = errno;
|
||||
if(e == EINTR) continue;
|
||||
#ifdef __GLIBC__
|
||||
char emsg[1024];
|
||||
char* x = strerror_r(errno, emsg, sizeof emsg);
|
||||
dprintf(2, "select2: %s\n", x);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int trywrite(int fd, void* buf, size_t bytes) {
|
||||
ssize_t ret;
|
||||
unsigned char *out = buf;
|
||||
again:
|
||||
ret = write(fd, out, bytes);
|
||||
switch(ret) {
|
||||
case -1:
|
||||
if(errno == EINTR) goto again;
|
||||
case 0:
|
||||
return 0;
|
||||
default:
|
||||
if(ret == bytes || !bytes) return 1;
|
||||
out += ret;
|
||||
bytes -= ret;
|
||||
goto again;
|
||||
}
|
||||
}
|
||||
|
||||
static int sendmessage(enum at_direction dir, struct at_msg *msg) {
|
||||
static int* destfd[ATD_MAX] = { [ATD_SERVER] = &req_pipefd[1], [ATD_CLIENT] = &resp_pipefd[1] };
|
||||
assert(msg->h.datalen <= MSG_LEN_MAX);
|
||||
int ret = trywrite(*destfd[dir], msg, sizeof (msg->h)+msg->h.datalen);
|
||||
assert(msg->h.datalen <= MSG_LEN_MAX);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int tryread(int fd, void* buf, size_t bytes) {
|
||||
ssize_t ret;
|
||||
unsigned char *out = buf;
|
||||
again:
|
||||
ret = read(fd, out, bytes);
|
||||
switch(ret) {
|
||||
case -1:
|
||||
if(errno == EINTR) goto again;
|
||||
case 0:
|
||||
return 0;
|
||||
default:
|
||||
if(ret == bytes || !bytes) return 1;
|
||||
out += ret;
|
||||
bytes -= ret;
|
||||
goto again;
|
||||
}
|
||||
}
|
||||
static int readmsg(int fd, struct at_msg *msg) {
|
||||
int ret = tryread(fd, msg, sizeof(msg->h));
|
||||
if(ret != 1) return ret;
|
||||
return tryread(fd, &msg->m, msg->h.datalen);
|
||||
}
|
||||
|
||||
static int getmessage(enum at_direction dir, struct at_msg *msg) {
|
||||
static int* readfd[ATD_MAX] = { [ATD_SERVER] = &req_pipefd[0], [ATD_CLIENT] = &resp_pipefd[0] };
|
||||
ssize_t ret;
|
||||
if((ret = wait_data(*readfd[dir]))) {
|
||||
if(!readmsg(*readfd[dir], msg))
|
||||
return 0;
|
||||
assert(msg->h.datalen <= MSG_LEN_MAX);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void* threadfunc(void* x) {
|
||||
(void) x;
|
||||
int ret;
|
||||
struct at_msg msg;
|
||||
while((ret = getmessage(ATD_SERVER, &msg))) {
|
||||
switch(msg.h.msgtype) {
|
||||
case ATM_GETIP:
|
||||
/* client wants an ip for a DNS name. iterate our list and check if we have an existing entry.
|
||||
* if not, create a new one. */
|
||||
msg.m.ip = ip_from_internal_list(msg.m.host, msg.h.datalen);
|
||||
msg.h.datalen = sizeof(ip_type4);
|
||||
break;
|
||||
case ATM_GETNAME: {
|
||||
char *host = string_from_internal_ip(msg.m.ip);
|
||||
if(host) {
|
||||
size_t l = strlen(host);
|
||||
assert(l+1 < MSG_LEN_MAX);
|
||||
memcpy(msg.m.host, host, l + 1);
|
||||
msg.h.datalen = l + 1;
|
||||
} else {
|
||||
msg.h.datalen = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ATM_EXIT:
|
||||
return 0;
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
ret = sendmessage(ATD_CLIENT, &msg);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* API to access the internal ip mapping */
|
||||
|
||||
ip_type4 at_get_ip_for_host(char* host, size_t len) {
|
||||
ip_type4 readbuf;
|
||||
MUTEX_LOCK(internal_ips_lock);
|
||||
if(len > MSG_LEN_MAX) goto inv;
|
||||
struct at_msg msg = {.h.msgtype = ATM_GETIP, .h.datalen = len + 1 };
|
||||
memcpy(msg.m.host, host, len+1);
|
||||
if(sendmessage(ATD_SERVER, &msg) &&
|
||||
getmessage(ATD_CLIENT, &msg)) readbuf = msg.m.ip;
|
||||
else {
|
||||
inv:
|
||||
readbuf = IPT4_INVALID;
|
||||
}
|
||||
assert(msg.h.msgtype == ATM_GETIP);
|
||||
MUTEX_UNLOCK(internal_ips_lock);
|
||||
return readbuf;
|
||||
}
|
||||
|
||||
size_t at_get_host_for_ip(ip_type4 ip, char* readbuf) {
|
||||
struct at_msg msg = {.h.msgtype = ATM_GETNAME, .h.datalen = sizeof(ip_type4), .m.ip = ip };
|
||||
size_t res = 0;
|
||||
MUTEX_LOCK(internal_ips_lock);
|
||||
if(sendmessage(ATD_SERVER, &msg) && getmessage(ATD_CLIENT, &msg)) {
|
||||
if((int16_t) msg.h.datalen <= 0) res = 0;
|
||||
else {
|
||||
memcpy(readbuf, msg.m.host, msg.h.datalen);
|
||||
res = msg.h.datalen - 1;
|
||||
}
|
||||
}
|
||||
assert(msg.h.msgtype == ATM_GETNAME);
|
||||
MUTEX_UNLOCK(internal_ips_lock);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
static void initpipe(int* fds) {
|
||||
int retval;
|
||||
|
||||
#ifdef HAVE_PIPE2
|
||||
retval = pipe2(fds, O_CLOEXEC);
|
||||
#else
|
||||
retval = pipe(fds);
|
||||
if(retval == 0) {
|
||||
fcntl(fds[0], F_SETFD, FD_CLOEXEC);
|
||||
fcntl(fds[1], F_SETFD, FD_CLOEXEC);
|
||||
}
|
||||
#endif
|
||||
if(retval == -1) {
|
||||
perror("pipe");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef MAX
|
||||
#define MAX(x, y) ((x) > (y) ? (x) : (y))
|
||||
#endif
|
||||
|
||||
#if !defined(PTHREAD_STACK_MIN) || defined(__APPLE__)
|
||||
/* MAC says its min is 8KB, but then crashes in our face. thx hunkOLard */
|
||||
#define PTHREAD_STACK_MIN 64*1024
|
||||
#endif
|
||||
|
||||
/* initialize with pointers to shared memory. these will
|
||||
* be used to place responses and arguments */
|
||||
void at_init(void) {
|
||||
PFUNC();
|
||||
void *shm = mmap(0, 4096, PROT_WRITE|PROT_READ, MAP_ANON|MAP_SHARED, -1, 0);
|
||||
assert(shm);
|
||||
internal_ips_lock = shm;
|
||||
internal_ips = (void*)((char*)shm + 2048);
|
||||
|
||||
MUTEX_INIT(internal_ips_lock);
|
||||
memset(internal_ips, 0, sizeof *internal_ips);
|
||||
initpipe(req_pipefd);
|
||||
initpipe(resp_pipefd);
|
||||
pthread_attr_t allocator_thread_attr;
|
||||
pthread_attr_init(&allocator_thread_attr);
|
||||
pthread_attr_setstacksize(&allocator_thread_attr, MAX(16 * 1024, PTHREAD_STACK_MIN));
|
||||
pthread_create(&allocator_thread, &allocator_thread_attr, threadfunc, 0);
|
||||
pthread_attr_destroy(&allocator_thread_attr);
|
||||
}
|
||||
|
||||
void at_close(void) {
|
||||
PFUNC();
|
||||
const int msg = ATM_EXIT;
|
||||
write(req_pipefd[1], &msg, sizeof(int));
|
||||
pthread_join(allocator_thread, NULL);
|
||||
close(req_pipefd[0]);
|
||||
close(req_pipefd[1]);
|
||||
close(resp_pipefd[0]);
|
||||
close(resp_pipefd[1]);
|
||||
MUTEX_DESTROY(internal_ips_lock);
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
#ifndef ALLOCATOR_THREAD_H
|
||||
#define ALLOCATOR_THREAD_H
|
||||
|
||||
#include <unistd.h>
|
||||
#include "ip_type.h"
|
||||
|
||||
extern int req_pipefd[2];
|
||||
extern int resp_pipefd[2];
|
||||
|
||||
void at_init(void);
|
||||
void at_close(void);
|
||||
size_t at_get_host_for_ip(ip_type4 ip, char* readbuf);
|
||||
ip_type4 at_get_ip_for_host(char* host, size_t len);
|
||||
|
||||
//RcB: DEP "allocator_thread.c"
|
||||
#endif
|
||||
|
||||
+132
@@ -0,0 +1,132 @@
|
||||
#include "common.h"
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
|
||||
const char *proxy_type_strmap[] = {
|
||||
"http",
|
||||
"socks4",
|
||||
"socks5",
|
||||
};
|
||||
|
||||
const char *chain_type_strmap[] = {
|
||||
"dynamic_chain",
|
||||
"strict_chain",
|
||||
"random_chain",
|
||||
"round_robin_chain",
|
||||
};
|
||||
|
||||
const char *proxy_state_strmap[] = {
|
||||
"play",
|
||||
"down",
|
||||
"blocked",
|
||||
"busy",
|
||||
};
|
||||
|
||||
/* isnumericipv4() taken from libulz */
|
||||
int pc_isnumericipv4(const char* ipstring) {
|
||||
size_t x = 0, n = 0, d = 0;
|
||||
int wasdot = 0;
|
||||
while(1) {
|
||||
switch(ipstring[x]) {
|
||||
case 0: goto done;
|
||||
case '.':
|
||||
if(!n || wasdot) return 0;
|
||||
d++;
|
||||
wasdot = 1;
|
||||
break;
|
||||
case '0': case '1': case '2': case '3': case '4':
|
||||
case '5': case '6': case '7': case '8': case '9':
|
||||
n++;
|
||||
wasdot = 0;
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
x++;
|
||||
}
|
||||
done:
|
||||
if(d == 3 && n >= 4 && n <= 12) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// stolen from libulz (C) rofl0r
|
||||
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;
|
||||
}
|
||||
|
||||
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))
|
||||
goto have;
|
||||
|
||||
// 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, bufsize, "%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, bufsize, "%s/.proxychains/%s", path, PROXYCHAINS_CONF_FILE);
|
||||
path = pbuf;
|
||||
if(check_path(path))
|
||||
goto have;
|
||||
|
||||
// priority 3b: ~/config/settings/proxychains.conf (for haiku)
|
||||
path = getenv("HOME");
|
||||
snprintf(pbuf, bufsize, "%s/config/settings/%s", path, PROXYCHAINS_CONF_FILE);
|
||||
path = pbuf;
|
||||
if(check_path(path))
|
||||
goto have;
|
||||
|
||||
// priority 4: $SYSCONFDIR/proxychains.conf
|
||||
path = SYSCONFDIR "/" PROXYCHAINS_CONF_FILE;
|
||||
if(check_path(path))
|
||||
goto have;
|
||||
|
||||
// priority 5: /etc/proxychains.conf
|
||||
path = "/etc/" PROXYCHAINS_CONF_FILE;
|
||||
if(check_path(path))
|
||||
goto have;
|
||||
|
||||
perror("couldnt find configuration file");
|
||||
exit(1);
|
||||
|
||||
return NULL;
|
||||
have:
|
||||
return path;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
#ifndef COMMON_H
|
||||
#define COMMON_H
|
||||
|
||||
#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 LOG_PREFIX "[proxychains] "
|
||||
#ifndef SYSCONFDIR
|
||||
#define SYSCONFDIR "/etc"
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
extern const char *proxy_type_strmap[];
|
||||
extern const char *chain_type_strmap[];
|
||||
extern const char *proxy_state_strmap[];
|
||||
|
||||
char *get_config_path(char* default_path, char* pbuf, size_t bufsize);
|
||||
void pc_stringfromipv4(unsigned char *ip_buf_4_bytes, char *outbuf_16_bytes);
|
||||
int pc_isnumericipv4(const char* ipstring);
|
||||
|
||||
//RcB: DEP "common.c"
|
||||
#endif
|
||||
+1036
File diff suppressed because it is too large
Load Diff
+151
@@ -0,0 +1,151 @@
|
||||
/***************************************************************************
|
||||
core.h - description
|
||||
-------------------
|
||||
begin : Tue May 14 2002
|
||||
copyright : netcreature (C) 2002
|
||||
email : netcreature@users.sourceforge.net
|
||||
***************************************************************************
|
||||
***************************************************************************
|
||||
* *
|
||||
* 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 *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdint.h>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netdb.h>
|
||||
|
||||
#ifndef __CORE_HEADER
|
||||
#define __CORE_HEADER
|
||||
#define MAX_LOCALNET 64
|
||||
#define MAX_DNAT 64
|
||||
|
||||
#include "ip_type.h"
|
||||
|
||||
/*error codes*/
|
||||
typedef enum {
|
||||
SUCCESS=0,
|
||||
MEMORY_FAIL, // malloc failed
|
||||
SOCKET_ERROR, // look errno for more
|
||||
CHAIN_DOWN, // no proxy in chain responds to tcp
|
||||
CHAIN_EMPTY, // if proxy_count = 0
|
||||
BLOCKED // target's port blocked on last proxy in the chain
|
||||
} ERR_CODE;
|
||||
|
||||
typedef enum {
|
||||
HTTP_TYPE,
|
||||
SOCKS4_TYPE,
|
||||
SOCKS5_TYPE,
|
||||
RAW_TYPE
|
||||
} proxy_type;
|
||||
|
||||
typedef enum {
|
||||
DYNAMIC_TYPE,
|
||||
STRICT_TYPE,
|
||||
RANDOM_TYPE,
|
||||
ROUND_ROBIN_TYPE
|
||||
} chain_type;
|
||||
|
||||
typedef enum {
|
||||
PLAY_STATE,
|
||||
DOWN_STATE,
|
||||
BLOCKED_STATE,
|
||||
BUSY_STATE
|
||||
} proxy_state;
|
||||
|
||||
typedef enum {
|
||||
RANDOMLY,
|
||||
FIFOLY
|
||||
} select_type;
|
||||
|
||||
typedef struct {
|
||||
sa_family_t family;
|
||||
unsigned short port;
|
||||
union {
|
||||
struct {
|
||||
struct in_addr in_addr;
|
||||
struct in_addr in_mask;
|
||||
};
|
||||
struct {
|
||||
struct in6_addr in6_addr;
|
||||
unsigned char in6_prefix;
|
||||
};
|
||||
};
|
||||
} 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;
|
||||
proxy_type pt;
|
||||
proxy_state ps;
|
||||
char user[256];
|
||||
char pass[256];
|
||||
} proxy_data;
|
||||
|
||||
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 );
|
||||
|
||||
void proxychains_write_log(char *str, ...);
|
||||
|
||||
typedef int (*close_t)(int);
|
||||
typedef int (*close_range_t)(unsigned, unsigned, int);
|
||||
typedef int (*connect_t)(int, const struct sockaddr *, socklen_t);
|
||||
typedef struct hostent* (*gethostbyname_t)(const char *);
|
||||
typedef int (*freeaddrinfo_t)(struct addrinfo *);
|
||||
typedef struct hostent *(*gethostbyaddr_t) (const void *, socklen_t, int);
|
||||
|
||||
typedef int (*getaddrinfo_t)(const char *, const char *, const struct addrinfo *,
|
||||
struct addrinfo **);
|
||||
|
||||
typedef int (*getnameinfo_t) (const struct sockaddr *, socklen_t, char *,
|
||||
GN_NODELEN_T, char *, GN_SERVLEN_T, GN_FLAGS_T);
|
||||
|
||||
typedef ssize_t (*sendto_t) (int sockfd, const void *buf, size_t len, int flags,
|
||||
const struct sockaddr *dest_addr, socklen_t addrlen);
|
||||
|
||||
|
||||
|
||||
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[256];
|
||||
};
|
||||
|
||||
struct hostent* proxy_gethostbyname(const char *name, struct gethostbyname_data *data);
|
||||
struct hostent* proxy_gethostbyname_old(const char *name);
|
||||
|
||||
int proxy_getaddrinfo(const char *node, const char *service,
|
||||
const struct addrinfo *hints, struct addrinfo **res);
|
||||
void proxy_freeaddrinfo(struct addrinfo *res);
|
||||
|
||||
void core_initialize(void);
|
||||
void core_unload(void);
|
||||
|
||||
#include "debug.h"
|
||||
|
||||
#endif
|
||||
|
||||
//RcB: DEP "core.c"
|
||||
//RcB: DEP "libproxychains.c"
|
||||
//RcB: LINK "-Wl,--no-as-needed -ldl -lpthread"
|
||||
|
||||
@@ -0,0 +1,231 @@
|
||||
/*
|
||||
proxychains-ng DNS daemon
|
||||
|
||||
Copyright (C) 2020 rofl0r.
|
||||
|
||||
*/
|
||||
|
||||
#define _GNU_SOURCE
|
||||
#include <unistd.h>
|
||||
#define _POSIX_C_SOURCE 200809L
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <pthread.h>
|
||||
#include <signal.h>
|
||||
#include <sys/select.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
#include "udpserver.h"
|
||||
#include "sblist.h"
|
||||
#include "hsearch.h"
|
||||
#include "../remotedns.h"
|
||||
#include "../ip_type.h"
|
||||
|
||||
#ifndef MAX
|
||||
#define MAX(x, y) ((x) > (y) ? (x) : (y))
|
||||
#endif
|
||||
|
||||
static struct htab *ip_lookup_table;
|
||||
static sblist *hostnames;
|
||||
static unsigned remote_subnet;
|
||||
static const struct server* server;
|
||||
|
||||
#ifndef CONFIG_LOG
|
||||
#define CONFIG_LOG 1
|
||||
#endif
|
||||
#if CONFIG_LOG
|
||||
/* we log to stderr because it's not using line buffering, i.e. malloc which would need
|
||||
locking when called from different threads. for the same reason we use dprintf,
|
||||
which writes directly to an fd. */
|
||||
#define dolog(...) dprintf(2, __VA_ARGS__)
|
||||
#else
|
||||
static void dolog(const char* fmt, ...) { }
|
||||
#endif
|
||||
|
||||
static char* my_inet_ntoa(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;
|
||||
return outbuf_16_bytes;
|
||||
}
|
||||
|
||||
|
||||
/* buf needs to be long enough for an ipv6 addr, i.e. INET6_ADDRSTRLEN + 1 */
|
||||
static char* ipstr(union sockaddr_union *su, char* buf) {
|
||||
int af = SOCKADDR_UNION_AF(su);
|
||||
void *ipdata = SOCKADDR_UNION_ADDRESS(su);
|
||||
inet_ntop(af, ipdata, buf, INET6_ADDRSTRLEN+1);
|
||||
char portbuf[7];
|
||||
snprintf(portbuf, sizeof portbuf, ":%u", (unsigned) ntohs(SOCKADDR_UNION_PORT(su)));
|
||||
strcat(buf, portbuf);
|
||||
return buf;
|
||||
}
|
||||
|
||||
static int usage(char *a0) {
|
||||
dprintf(2,
|
||||
"Proxychains-NG remote dns daemon\n"
|
||||
"--------------------------------\n"
|
||||
"usage: %s -i listenip -p port -r remotesubnet\n"
|
||||
"all arguments are optional.\n"
|
||||
"by default listenip is 127.0.0.1, port 1053 and remotesubnet 224.\n\n", a0
|
||||
);
|
||||
return 1;
|
||||
}
|
||||
|
||||
unsigned index_from_ip(ip_type4 internalip) {
|
||||
ip_type4 tmp = internalip;
|
||||
uint32_t ret;
|
||||
ret = tmp.octet[3] + (tmp.octet[2] << 8) + (tmp.octet[1] << 16);
|
||||
ret -= 1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
char *host_from_ip(ip_type4 internalip) {
|
||||
char *res = NULL;
|
||||
unsigned index = index_from_ip(internalip);
|
||||
if(index < sblist_getsize(hostnames)) {
|
||||
char **tmp = sblist_get(hostnames, index);
|
||||
if(tmp && *tmp) res = *tmp;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
ip_type4 get_ip_from_index(unsigned index) {
|
||||
ip_type4 ret;
|
||||
index++; // so we can start at .0.0.1
|
||||
if(index > 0xFFFFFF)
|
||||
return IPT4_INVALID;
|
||||
ret.octet[0] = remote_subnet & 0xFF;
|
||||
ret.octet[1] = (index & 0xFF0000) >> 16;
|
||||
ret.octet[2] = (index & 0xFF00) >> 8;
|
||||
ret.octet[3] = index & 0xFF;
|
||||
return ret;
|
||||
}
|
||||
|
||||
ip_type4 get_ip(char* hn) {
|
||||
htab_value *v = htab_find(ip_lookup_table, hn);
|
||||
if(v) return get_ip_from_index(v->n);
|
||||
char *n = strdup(hn);
|
||||
if(!n) return IPT4_INVALID;
|
||||
if(!sblist_add(hostnames, &n)) {
|
||||
o_out:;
|
||||
free(n);
|
||||
return IPT4_INVALID;
|
||||
}
|
||||
if(!htab_insert(ip_lookup_table, n, HTV_N(sblist_getsize(hostnames)-1))) {
|
||||
sblist_delete(hostnames, sblist_getsize(hostnames)-1);
|
||||
goto o_out;
|
||||
}
|
||||
return get_ip_from_index(sblist_getsize(hostnames)-1);
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
int ch;
|
||||
const char *listenip = "127.0.0.1";
|
||||
unsigned port = 1053;
|
||||
remote_subnet = 224;
|
||||
while((ch = getopt(argc, argv, ":r:i:p:")) != -1) {
|
||||
switch(ch) {
|
||||
case 'r':
|
||||
remote_subnet = atoi(optarg);
|
||||
break;
|
||||
case 'i':
|
||||
listenip = optarg;
|
||||
break;
|
||||
case 'p':
|
||||
port = atoi(optarg);
|
||||
break;
|
||||
case ':':
|
||||
dprintf(2, "error: option -%c requires an operand\n", optopt);
|
||||
/* fall through */
|
||||
case '?':
|
||||
return usage(argv[0]);
|
||||
}
|
||||
}
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
struct server s;
|
||||
if(server_setup(&s, listenip, port)) {
|
||||
perror("server_setup");
|
||||
return 1;
|
||||
}
|
||||
server = &s;
|
||||
|
||||
ip_lookup_table = htab_create(64);
|
||||
hostnames = sblist_new(sizeof(char*), 64);
|
||||
|
||||
while(1) {
|
||||
struct client c;
|
||||
char ipstr_buf[INET6_ADDRSTRLEN+6+1];
|
||||
char ip4str_buf[16];
|
||||
struct at_msg msg, out;
|
||||
size_t msgl = sizeof(msg);
|
||||
int failed = 0;
|
||||
|
||||
#define FAIL() do { failed=1; goto sendresp; } while(0)
|
||||
|
||||
if(server_waitclient(&s, &c, &msg, &msgl)) continue;
|
||||
msg.h.datalen = ntohs(msg.h.datalen);
|
||||
if(msgl != sizeof(msg.h)+msg.h.datalen) {
|
||||
dolog("%s: invalid datalen\n", ipstr(&c.addr, ipstr_buf));
|
||||
FAIL();
|
||||
}
|
||||
|
||||
out.h.msgtype = msg.h.msgtype;
|
||||
if(msg.h.msgtype == ATM_GETIP) {
|
||||
if(!memchr(msg.m.host, 0, msg.h.datalen)) {
|
||||
dolog("%s: nul terminator missing\n", ipstr(&c.addr, ipstr_buf));
|
||||
FAIL();
|
||||
}
|
||||
out.h.datalen = sizeof(ip_type4);
|
||||
out.m.ip = get_ip(msg.m.host);
|
||||
failed = !memcmp(&out.m.ip, &IPT4_INVALID, 4);
|
||||
dolog("%s requested ip for %s (%s)\n", ipstr(&c.addr, ipstr_buf),
|
||||
msg.m.host, failed?"FAIL":my_inet_ntoa((void*)&out.m.ip, ip4str_buf));
|
||||
if(failed) FAIL();
|
||||
} else if (msg.h.msgtype == ATM_GETNAME) {
|
||||
if(msg.h.datalen != 4) {
|
||||
dolog("%s: invalid len for getname request\n", ipstr(&c.addr, ipstr_buf));
|
||||
FAIL();
|
||||
}
|
||||
char *hn = host_from_ip(msg.m.ip);
|
||||
if(hn) {
|
||||
size_t l = strlen(hn);
|
||||
memcpy(out.m.host, hn, l+1);
|
||||
out.h.datalen = l+1;
|
||||
}
|
||||
dolog("%s requested name for %s (%s)\n", ipstr(&c.addr, ipstr_buf),
|
||||
my_inet_ntoa((void*) &msg.m.ip, ip4str_buf), hn?hn:"FAIL");
|
||||
if(!hn) FAIL();
|
||||
} else {
|
||||
dolog("%s: unknown request %u\n", ipstr(&c.addr, ipstr_buf),
|
||||
(unsigned) msg.h.msgtype);
|
||||
}
|
||||
sendresp:;
|
||||
if(failed) {
|
||||
out.h.msgtype = ATM_FAIL;
|
||||
out.h.datalen = 0;
|
||||
}
|
||||
unsigned short dlen = out.h.datalen;
|
||||
out.h.datalen = htons(dlen);
|
||||
sendto(server->fd, &out, sizeof(out.h)+dlen, 0, (void*) &c.addr, SOCKADDR_UNION_LENGTH(&c.addr));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,188 @@
|
||||
/*
|
||||
musl license, hsearch.c originally written by Szabolcs Nagy
|
||||
|
||||
Copyright © 2005-2020 Rich Felker, et al.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "hsearch.h"
|
||||
|
||||
/*
|
||||
open addressing hash table with 2^n table size
|
||||
quadratic probing is used in case of hash collision
|
||||
tab indices and hash are size_t
|
||||
after resize fails with ENOMEM the state of tab is still usable
|
||||
*/
|
||||
|
||||
typedef struct htab_entry {
|
||||
char *key;
|
||||
htab_value data;
|
||||
} htab_entry;
|
||||
|
||||
struct elem {
|
||||
htab_entry item;
|
||||
size_t hash;
|
||||
};
|
||||
|
||||
struct htab {
|
||||
struct elem *elems;
|
||||
size_t mask;
|
||||
size_t used;
|
||||
};
|
||||
|
||||
#define MINSIZE 8
|
||||
#define MAXSIZE ((size_t)-1/2 + 1)
|
||||
|
||||
static size_t keyhash(char *k)
|
||||
{
|
||||
unsigned char *p = (void *)k;
|
||||
size_t h = 0;
|
||||
|
||||
while (*p)
|
||||
h = 31*h + *p++;
|
||||
return h;
|
||||
}
|
||||
|
||||
static int resize(struct htab *htab, size_t nel)
|
||||
{
|
||||
size_t newsize;
|
||||
size_t i, j;
|
||||
struct elem *e, *newe;
|
||||
struct elem *oldtab = htab->elems;
|
||||
struct elem *oldend = htab->elems + htab->mask + 1;
|
||||
|
||||
if (nel > MAXSIZE)
|
||||
nel = MAXSIZE;
|
||||
for (newsize = MINSIZE; newsize < nel; newsize *= 2);
|
||||
htab->elems = calloc(newsize, sizeof *htab->elems);
|
||||
if (!htab->elems) {
|
||||
htab->elems = oldtab;
|
||||
return 0;
|
||||
}
|
||||
htab->mask = newsize - 1;
|
||||
if (!oldtab)
|
||||
return 1;
|
||||
for (e = oldtab; e < oldend; e++)
|
||||
if (e->item.key) {
|
||||
for (i=e->hash,j=1; ; i+=j++) {
|
||||
newe = htab->elems + (i & htab->mask);
|
||||
if (!newe->item.key)
|
||||
break;
|
||||
}
|
||||
*newe = *e;
|
||||
}
|
||||
free(oldtab);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static struct elem *lookup(struct htab *htab, char *key, size_t hash)
|
||||
{
|
||||
size_t i, j;
|
||||
struct elem *e;
|
||||
|
||||
for (i=hash,j=1; ; i+=j++) {
|
||||
e = htab->elems + (i & htab->mask);
|
||||
if (!e->item.key ||
|
||||
(e->hash==hash && strcmp(e->item.key, key)==0))
|
||||
break;
|
||||
}
|
||||
return e;
|
||||
}
|
||||
|
||||
struct htab *htab_create(size_t nel)
|
||||
{
|
||||
struct htab *r = calloc(1, sizeof *r);
|
||||
if(r && !resize(r, nel)) {
|
||||
free(r);
|
||||
r = 0;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
void htab_destroy(struct htab *htab)
|
||||
{
|
||||
free(htab->elems);
|
||||
free(htab);
|
||||
}
|
||||
|
||||
static htab_entry *htab_find_item(struct htab *htab, char* key)
|
||||
{
|
||||
size_t hash = keyhash(key);
|
||||
struct elem *e = lookup(htab, key, hash);
|
||||
|
||||
if (e->item.key) {
|
||||
return &e->item;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
htab_value* htab_find(struct htab *htab, char* key)
|
||||
{
|
||||
htab_entry *i = htab_find_item(htab, key);
|
||||
if(i) return &i->data;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int htab_delete(struct htab *htab, char* key)
|
||||
{
|
||||
htab_entry *i = htab_find_item(htab, key);
|
||||
if(!i) return 0;
|
||||
i->key = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int htab_insert(struct htab *htab, char* key, htab_value value)
|
||||
{
|
||||
size_t hash = keyhash(key);
|
||||
struct elem *e = lookup(htab, key, hash);
|
||||
if(e->item.key) {
|
||||
/* it's not allowed to overwrite existing data */
|
||||
return 0;
|
||||
}
|
||||
|
||||
e->item.key = key;
|
||||
e->item.data = value;
|
||||
e->hash = hash;
|
||||
if (++htab->used > htab->mask - htab->mask/4) {
|
||||
if (!resize(htab, 2*htab->used)) {
|
||||
htab->used--;
|
||||
e->item.key = 0;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
size_t htab_next(struct htab *htab, size_t iterator, char** key, htab_value **v)
|
||||
{
|
||||
size_t i;
|
||||
for(i=iterator;i<htab->mask+1;++i) {
|
||||
struct elem *e = htab->elems + i;
|
||||
if(e->item.key) {
|
||||
*key = e->item.key;
|
||||
*v = &e->item.data;
|
||||
return i+1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
#ifndef HSEARCH_H
|
||||
#define HSEARCH_H
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
typedef union htab_value {
|
||||
void *p;
|
||||
size_t n;
|
||||
} htab_value;
|
||||
|
||||
#define HTV_N(N) (htab_value) {.n = N}
|
||||
#define HTV_P(P) (htab_value) {.p = P}
|
||||
|
||||
struct htab * htab_create(size_t);
|
||||
void htab_destroy(struct htab *);
|
||||
htab_value* htab_find(struct htab *, char* key);
|
||||
int htab_insert(struct htab *, char*, htab_value);
|
||||
int htab_delete(struct htab *htab, char* key);
|
||||
size_t htab_next(struct htab *, size_t iterator, char** key, htab_value **v);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,73 @@
|
||||
#undef _POSIX_C_SOURCE
|
||||
#define _POSIX_C_SOURCE 200809L
|
||||
#include "sblist.h"
|
||||
#include <limits.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#define MY_PAGE_SIZE 4096
|
||||
|
||||
sblist* sblist_new(size_t itemsize, size_t blockitems) {
|
||||
sblist* ret = (sblist*) malloc(sizeof(sblist));
|
||||
sblist_init(ret, itemsize, blockitems);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void sblist_clear(sblist* l) {
|
||||
l->items = NULL;
|
||||
l->capa = 0;
|
||||
l->count = 0;
|
||||
}
|
||||
|
||||
void sblist_init(sblist* l, size_t itemsize, size_t blockitems) {
|
||||
if(l) {
|
||||
l->blockitems = blockitems ? blockitems : MY_PAGE_SIZE / itemsize;
|
||||
l->itemsize = itemsize;
|
||||
sblist_clear(l);
|
||||
}
|
||||
}
|
||||
|
||||
void sblist_free_items(sblist* l) {
|
||||
if(l) {
|
||||
if(l->items) free(l->items);
|
||||
sblist_clear(l);
|
||||
}
|
||||
}
|
||||
|
||||
void sblist_free(sblist* l) {
|
||||
if(l) {
|
||||
sblist_free_items(l);
|
||||
free(l);
|
||||
}
|
||||
}
|
||||
|
||||
char* sblist_item_from_index(sblist* l, size_t idx) {
|
||||
return l->items + (idx * l->itemsize);
|
||||
}
|
||||
|
||||
void* sblist_get(sblist* l, size_t item) {
|
||||
if(item < l->count) return (void*) sblist_item_from_index(l, item);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int sblist_set(sblist* l, void* item, size_t pos) {
|
||||
if(pos >= l->count) return 0;
|
||||
memcpy(sblist_item_from_index(l, pos), item, l->itemsize);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int sblist_grow_if_needed(sblist* l) {
|
||||
char* temp;
|
||||
if(l->count == l->capa) {
|
||||
temp = realloc(l->items, (l->capa + l->blockitems) * l->itemsize);
|
||||
if(!temp) return 0;
|
||||
l->capa += l->blockitems;
|
||||
l->items = temp;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int sblist_add(sblist* l, void* item) {
|
||||
if(!sblist_grow_if_needed(l)) return 0;
|
||||
l->count++;
|
||||
return sblist_set(l, item, l->count - 1);
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
#ifndef SBLIST_H
|
||||
#define SBLIST_H
|
||||
|
||||
/* this file is part of libulz, as of commit 8ab361a27743aaf025323ee43b8b8876dc054fdd
|
||||
modified for direct inclusion in microsocks. */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
/*
|
||||
* simple buffer list.
|
||||
*
|
||||
* this thing here is basically a generic dynamic array
|
||||
* will realloc after every blockitems inserts
|
||||
* can store items of any size.
|
||||
*
|
||||
* so think of it as a by-value list, as opposed to a typical by-ref list.
|
||||
* you typically use it by having some struct on the stack, and pass a pointer
|
||||
* to sblist_add, which will copy the contents into its internal memory.
|
||||
*
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
size_t itemsize;
|
||||
size_t blockitems;
|
||||
size_t count;
|
||||
size_t capa;
|
||||
char* items;
|
||||
} sblist;
|
||||
|
||||
#define sblist_getsize(X) ((X)->count)
|
||||
#define sblist_get_count(X) ((X)->count)
|
||||
#define sblist_empty(X) ((X)->count == 0)
|
||||
|
||||
// for dynamic style
|
||||
sblist* sblist_new(size_t itemsize, size_t blockitems);
|
||||
void sblist_free(sblist* l);
|
||||
|
||||
//for static style
|
||||
void sblist_init(sblist* l, size_t itemsize, size_t blockitems);
|
||||
void sblist_free_items(sblist* l);
|
||||
|
||||
// accessors
|
||||
void* sblist_get(sblist* l, size_t item);
|
||||
// returns 1 on success, 0 on OOM
|
||||
int sblist_add(sblist* l, void* item);
|
||||
int sblist_set(sblist* l, void* item, size_t pos);
|
||||
void sblist_delete(sblist* l, size_t item);
|
||||
char* sblist_item_from_index(sblist* l, size_t idx);
|
||||
int sblist_grow_if_needed(sblist* l);
|
||||
int sblist_insert(sblist* l, void* item, size_t pos);
|
||||
/* same as sblist_add, but returns list index of new item, or -1 */
|
||||
size_t sblist_addi(sblist* l, void* item);
|
||||
void sblist_sort(sblist *l, int (*compar)(const void *, const void *));
|
||||
/* insert element into presorted list, returns listindex of new entry or -1*/
|
||||
size_t sblist_insert_sorted(sblist* l, void* o, int (*compar)(const void *, const void *));
|
||||
|
||||
#ifndef __COUNTER__
|
||||
#define __COUNTER__ __LINE__
|
||||
#endif
|
||||
|
||||
#define __sblist_concat_impl( x, y ) x##y
|
||||
#define __sblist_macro_concat( x, y ) __sblist_concat_impl( x, y )
|
||||
#define __sblist_iterator_name __sblist_macro_concat(sblist_iterator, __COUNTER__)
|
||||
|
||||
// use with custom iterator variable
|
||||
#define sblist_iter_counter(LIST, ITER, PTR) \
|
||||
for(size_t ITER = 0; (PTR = sblist_get(LIST, ITER)), ITER < sblist_getsize(LIST); ITER++)
|
||||
|
||||
// use with custom iterator variable, which is predeclared
|
||||
#define sblist_iter_counter2(LIST, ITER, PTR) \
|
||||
for(ITER = 0; (PTR = sblist_get(LIST, ITER)), ITER < sblist_getsize(LIST); ITER++)
|
||||
|
||||
// use with custom iterator variable, which is predeclared and signed
|
||||
// useful for a loop which can delete items from the list, and then decrease the iterator var.
|
||||
#define sblist_iter_counter2s(LIST, ITER, PTR) \
|
||||
for(ITER = 0; (PTR = sblist_get(LIST, ITER)), ITER < (ssize_t) sblist_getsize(LIST); ITER++)
|
||||
|
||||
|
||||
// uses "magic" iterator variable
|
||||
#define sblist_iter(LIST, PTR) sblist_iter_counter(LIST, __sblist_iterator_name, PTR)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#pragma RcB2 DEP "sblist.c" "sblist_delete.c"
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,9 @@
|
||||
#include "sblist.h"
|
||||
#include <string.h>
|
||||
|
||||
void sblist_delete(sblist* l, size_t item) {
|
||||
if (l->count && item < l->count) {
|
||||
memmove(sblist_item_from_index(l, item), sblist_item_from_index(l, item + 1), (sblist_getsize(l) - (item + 1)) * l->itemsize);
|
||||
l->count--;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include "../remotedns.h"
|
||||
#include "../ip_type.h"
|
||||
|
||||
int main() {
|
||||
int fd;
|
||||
int port = 1053;
|
||||
char srvn[] = "127.0.0.1";
|
||||
struct sockaddr_in srva = {.sin_family = AF_INET, .sin_port = htons(port)};
|
||||
inet_pton(AF_INET, srvn, &srva.sin_addr);
|
||||
fd = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
char namebuf[260];
|
||||
while(fgets(namebuf, sizeof namebuf, stdin)) {
|
||||
size_t l = strlen(namebuf);
|
||||
if(namebuf[l-1] == '\n') {
|
||||
l--;
|
||||
namebuf[l] = 0;
|
||||
}
|
||||
struct at_msg msg = {0};
|
||||
unsigned msglen;
|
||||
if(isdigit(namebuf[0])) {
|
||||
msglen = 4;
|
||||
msg.h.msgtype = ATM_GETNAME;
|
||||
inet_aton(namebuf, (void*) &msg.m.ip);
|
||||
} else {
|
||||
msglen = l+1;
|
||||
msg.h.msgtype = ATM_GETIP;
|
||||
memcpy(msg.m.host, namebuf, msglen);
|
||||
}
|
||||
msg.h.datalen = htons(msglen);
|
||||
sendto(fd, &msg, sizeof(msg.h)+msglen, 0, (void*)&srva, sizeof(srva));
|
||||
char rcvbuf[512];
|
||||
recvfrom(fd, rcvbuf, sizeof rcvbuf, 0, (void*)0, (void*)0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
#include "udpserver.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int resolve(const char *host, unsigned short port, struct addrinfo** addr) {
|
||||
struct addrinfo hints = {
|
||||
.ai_family = AF_UNSPEC,
|
||||
.ai_socktype = SOCK_STREAM,
|
||||
.ai_flags = AI_PASSIVE,
|
||||
};
|
||||
char port_buf[8];
|
||||
snprintf(port_buf, sizeof port_buf, "%u", port);
|
||||
return getaddrinfo(host, port_buf, &hints, addr);
|
||||
}
|
||||
|
||||
int resolve_sa(const char *host, unsigned short port, union sockaddr_union *res) {
|
||||
struct addrinfo *ainfo = 0;
|
||||
int ret;
|
||||
SOCKADDR_UNION_AF(res) = AF_UNSPEC;
|
||||
if((ret = resolve(host, port, &ainfo))) return ret;
|
||||
memcpy(res, ainfo->ai_addr, ainfo->ai_addrlen);
|
||||
freeaddrinfo(ainfo);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bindtoip(int fd, union sockaddr_union *bindaddr) {
|
||||
socklen_t sz = SOCKADDR_UNION_LENGTH(bindaddr);
|
||||
if(sz)
|
||||
return bind(fd, (struct sockaddr*) bindaddr, sz);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int server_waitclient(struct server *server, struct client* client, void* buf, size_t *buflen) {
|
||||
socklen_t clen = sizeof client->addr;
|
||||
ssize_t ret = recvfrom(server->fd, buf, *buflen, 0, (void*)&client->addr, &clen);
|
||||
if(ret >= 0) {
|
||||
*buflen = ret;
|
||||
return 0;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int server_setup(struct server *server, const char* listenip, unsigned short port) {
|
||||
struct addrinfo *ainfo = 0;
|
||||
if(resolve(listenip, port, &ainfo)) return -1;
|
||||
struct addrinfo* p;
|
||||
int listenfd = -1;
|
||||
for(p = ainfo; p; p = p->ai_next) {
|
||||
if((listenfd = socket(p->ai_family, SOCK_DGRAM, 0)) < 0)
|
||||
continue;
|
||||
int yes = 1;
|
||||
setsockopt(listenfd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int));
|
||||
if(bind(listenfd, p->ai_addr, p->ai_addrlen) < 0) {
|
||||
close(listenfd);
|
||||
listenfd = -1;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
freeaddrinfo(ainfo);
|
||||
if(listenfd < 0) return -2;
|
||||
server->fd = listenfd;
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
#ifndef SERVER_H
|
||||
#define SERVER_H
|
||||
|
||||
#undef _POSIX_C_SOURCE
|
||||
#define _POSIX_C_SOURCE 200809L
|
||||
|
||||
#include <sys/socket.h>
|
||||
#include <netdb.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
#pragma RcB2 DEP "udpserver.c"
|
||||
|
||||
union sockaddr_union {
|
||||
struct sockaddr_in v4;
|
||||
struct sockaddr_in6 v6;
|
||||
};
|
||||
|
||||
#define SOCKADDR_UNION_AF(PTR) (PTR)->v4.sin_family
|
||||
|
||||
#define SOCKADDR_UNION_LENGTH(PTR) ( \
|
||||
( SOCKADDR_UNION_AF(PTR) == AF_INET ) ? sizeof((PTR)->v4) : ( \
|
||||
( SOCKADDR_UNION_AF(PTR) == AF_INET6 ) ? sizeof((PTR)->v6) : 0 ) )
|
||||
|
||||
#define SOCKADDR_UNION_ADDRESS(PTR) ( \
|
||||
( SOCKADDR_UNION_AF(PTR) == AF_INET ) ? (void*) &(PTR)->v4.sin_addr : ( \
|
||||
( SOCKADDR_UNION_AF(PTR) == AF_INET6 ) ? (void*) &(PTR)->v6.sin6_addr : (void*) 0 ) )
|
||||
|
||||
#define SOCKADDR_UNION_PORT(PTR) ( \
|
||||
( SOCKADDR_UNION_AF(PTR) == AF_INET ) ? (PTR)->v4.sin_port : ( \
|
||||
( SOCKADDR_UNION_AF(PTR) == AF_INET6 ) ? (PTR)->v6.sin6_port : 0 ) )
|
||||
|
||||
struct client {
|
||||
union sockaddr_union addr;
|
||||
};
|
||||
|
||||
struct server {
|
||||
int fd;
|
||||
};
|
||||
|
||||
int resolve(const char *host, unsigned short port, struct addrinfo** addr);
|
||||
int resolve_sa(const char *host, unsigned short port, union sockaddr_union *res);
|
||||
int bindtoip(int fd, union sockaddr_union *bindaddr);
|
||||
|
||||
int server_waitclient(struct server *server, struct client* client, void* buf, size_t *buflen);
|
||||
int server_setup(struct server *server, const char* listenip, unsigned short port);
|
||||
|
||||
#endif
|
||||
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
|
||||
#ifdef DEBUG
|
||||
# include "core.h"
|
||||
# include "common.h"
|
||||
# include "debug.h"
|
||||
#include <arpa/inet.h>
|
||||
|
||||
void dump_proxy_chain(proxy_data *pchain, unsigned int count) {
|
||||
char ip_buf[INET6_ADDRSTRLEN];
|
||||
for (; count; pchain++, count--) {
|
||||
if(!inet_ntop(pchain->ip.is_v6?AF_INET6:AF_INET,pchain->ip.addr.v6,ip_buf,sizeof ip_buf)) {
|
||||
proxychains_write_log(LOG_PREFIX "error: ip address conversion failed\n");
|
||||
continue;
|
||||
}
|
||||
PDEBUG("[%s] %s %s:%d", proxy_state_strmap[pchain->ps],
|
||||
proxy_type_strmap[pchain->pt],
|
||||
ip_buf, htons(pchain->port));
|
||||
if (*pchain->user || *pchain->pass) {
|
||||
PSTDERR(" [u=%s,p=%s]", pchain->user, pchain->pass);
|
||||
}
|
||||
PSTDERR("\n");
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
// Do not allow this translation unit to end up empty
|
||||
// for non-DEBUG builds, to satisfy ISO C standards.
|
||||
typedef int __appease_iso_compilers__;
|
||||
|
||||
#endif
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
#ifndef DEBUG_H
|
||||
#define DEBUG_H
|
||||
|
||||
# include <stdio.h>
|
||||
|
||||
#ifdef DEBUG
|
||||
# define PSTDERR(fmt, args...) do { dprintf(2,fmt, ## args); } while(0)
|
||||
# define PDEBUG(fmt, args...) PSTDERR("DEBUG:pid[%d]:" fmt, getpid(), ## args)
|
||||
# define DEBUGDECL(args...) args
|
||||
# define DUMP_PROXY_CHAIN(A, B) dump_proxy_chain(A, B)
|
||||
#else
|
||||
# define PDEBUG(fmt, args...) do {} while (0)
|
||||
# define DEBUGDECL(args...)
|
||||
# define DUMP_PROXY_CHAIN(args...) do {} while (0)
|
||||
#endif
|
||||
|
||||
# define PFUNC() do { PDEBUG("%s()\n", __FUNCTION__); } while(0)
|
||||
|
||||
#include "core.h"
|
||||
void dump_proxy_chain(proxy_data *pchain, unsigned int count);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
#include "hash.h"
|
||||
|
||||
/* dalias' version of the elf hash */
|
||||
uint32_t dalias_hash(char *s0) {
|
||||
unsigned char *s = (void *) s0;
|
||||
uint_fast32_t h = 0;
|
||||
while(*s) {
|
||||
h = 16 * h + *s++;
|
||||
h ^= h >> 24 & 0xf0;
|
||||
}
|
||||
return h & 0xfffffff;
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
#ifndef HASH_H
|
||||
#define HASH_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
uint32_t dalias_hash(char *s0);
|
||||
|
||||
//RcB: DEP "hash.c"
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,96 @@
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include "common.h"
|
||||
|
||||
/*
|
||||
simple reader for /etc/hosts
|
||||
it only supports comments, blank lines and lines consisting of an ipv4 hostname pair.
|
||||
this is required so we can return entries from the host db without messing up the
|
||||
non-thread-safe state of libc's gethostent().
|
||||
|
||||
*/
|
||||
|
||||
struct hostsreader {
|
||||
FILE *f;
|
||||
char* ip, *name;
|
||||
};
|
||||
|
||||
int hostsreader_open(struct hostsreader *ctx) {
|
||||
if(!(ctx->f = fopen("/etc/hosts", "r"))) return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void hostsreader_close(struct hostsreader *ctx) {
|
||||
fclose(ctx->f);
|
||||
}
|
||||
|
||||
int hostsreader_get(struct hostsreader *ctx, char* buf, size_t bufsize) {
|
||||
while(1) {
|
||||
if(!fgets(buf, bufsize, ctx->f)) return 0;
|
||||
if(*buf == '#') continue;
|
||||
char *p = buf;
|
||||
size_t l = bufsize;
|
||||
ctx->ip = p;
|
||||
while(*p && !isspace(*p) && l) {
|
||||
p++;
|
||||
l--;
|
||||
}
|
||||
if(!l || !*p || p == ctx->ip) continue;
|
||||
*p = 0;
|
||||
p++;
|
||||
while(*p && isspace(*p) && l) {
|
||||
p++;
|
||||
l--;
|
||||
}
|
||||
if(!l || !*p) continue;
|
||||
ctx->name = p;
|
||||
while(*p && !isspace(*p) && l) {
|
||||
p++;
|
||||
l--;
|
||||
}
|
||||
if(!l || !*p) continue;
|
||||
*p = 0;
|
||||
if(pc_isnumericipv4(ctx->ip)) return 1;
|
||||
}
|
||||
}
|
||||
|
||||
char* hostsreader_get_ip_for_name(const char* name, char* buf, size_t bufsize) {
|
||||
struct hostsreader ctx;
|
||||
char *res = 0;
|
||||
if(!hostsreader_open(&ctx)) return 0;
|
||||
while(hostsreader_get(&ctx, buf, bufsize)) {
|
||||
if(!strcmp(ctx.name, name)) {
|
||||
res = ctx.ip;
|
||||
break;
|
||||
}
|
||||
}
|
||||
hostsreader_close(&ctx);
|
||||
return res;
|
||||
}
|
||||
|
||||
#include "ip_type.h"
|
||||
#include <netinet/in.h>
|
||||
#include <sys/socket.h>
|
||||
#include <arpa/inet.h>
|
||||
ip_type4 hostsreader_get_numeric_ip_for_name(const char* name) {
|
||||
char *hres;
|
||||
char buf[320];
|
||||
if((hres = hostsreader_get_ip_for_name(name, buf, sizeof buf))) {
|
||||
struct in_addr c;
|
||||
inet_aton(hres, &c);
|
||||
ip_type4 res;
|
||||
memcpy(res.octet, &c.s_addr, 4);
|
||||
return res;
|
||||
} else return IPT4_INVALID;
|
||||
}
|
||||
|
||||
#ifdef HOSTSREADER_TEST
|
||||
#include "ip_type.c"
|
||||
int main(int a, char**b) {
|
||||
char buf[256];
|
||||
if(a != 2) return 1;
|
||||
char * ret = hostsreader_get_ip_for_name(b[1], buf, sizeof buf);
|
||||
printf("%s\n", ret ? ret : "null");
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,25 @@
|
||||
#ifndef IP_TYPE_H
|
||||
#define IP_TYPE_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef union {
|
||||
unsigned char octet[4];
|
||||
uint32_t as_int;
|
||||
} ip_type4;
|
||||
|
||||
typedef struct {
|
||||
union {
|
||||
ip_type4 v4;
|
||||
unsigned char v6[16];
|
||||
} addr;
|
||||
char is_v6;
|
||||
} ip_type;
|
||||
|
||||
#define IPT4_INT(X) (ip_type4){.as_int = (X)}
|
||||
#define IPT4_INVALID IPT4_INT(-1)
|
||||
|
||||
#define IPT4_BYTES(A,B,C,D) (ip_type4){.octet = {(A), (B), (C), (D)} }
|
||||
#define IPT4_LOCALHOST IPT4_BYTES(127,0,0,1)
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,945 @@
|
||||
/***************************************************************************
|
||||
libproxychains.c - description
|
||||
-------------------
|
||||
begin : Tue May 14 2002
|
||||
copyright : netcreature (C) 2002
|
||||
email : netcreature@users.sourceforge.net
|
||||
***************************************************************************/
|
||||
/* 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 *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#undef _GNU_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
#include <netdb.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <fcntl.h>
|
||||
#include <dlfcn.h>
|
||||
#include <pthread.h>
|
||||
|
||||
|
||||
#include "core.h"
|
||||
#include "common.h"
|
||||
#include "rdns.h"
|
||||
|
||||
#undef satosin
|
||||
#define satosin(x) ((struct sockaddr_in *) &(x))
|
||||
#define SOCKADDR(x) (satosin(x)->sin_addr.s_addr)
|
||||
#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 512
|
||||
|
||||
#ifdef IS_SOLARIS
|
||||
#undef connect
|
||||
int __xnet_connect(int sock, const struct sockaddr *addr, unsigned int len);
|
||||
connect_t true___xnet_connect;
|
||||
#endif
|
||||
|
||||
close_t true_close;
|
||||
close_range_t true_close_range;
|
||||
connect_t true_connect;
|
||||
gethostbyname_t true_gethostbyname;
|
||||
getaddrinfo_t true_getaddrinfo;
|
||||
freeaddrinfo_t true_freeaddrinfo;
|
||||
getnameinfo_t true_getnameinfo;
|
||||
gethostbyaddr_t true_gethostbyaddr;
|
||||
sendto_t true_sendto;
|
||||
|
||||
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;
|
||||
unsigned int proxychains_proxy_offset = 0;
|
||||
int proxychains_got_chain_data = 0;
|
||||
unsigned int proxychains_max_chain = 1;
|
||||
int proxychains_quiet_mode = 0;
|
||||
enum dns_lookup_flavor proxychains_resolver = DNSLF_LIBC;
|
||||
localaddr_arg localnet_addr[MAX_LOCALNET];
|
||||
size_t num_localnet_addr = 0;
|
||||
dnat_arg dnats[MAX_DNAT];
|
||||
size_t num_dnats = 0;
|
||||
unsigned int remote_dns_subnet = 224;
|
||||
|
||||
pthread_once_t init_once = PTHREAD_ONCE_INIT;
|
||||
|
||||
static int init_l = 0;
|
||||
|
||||
static void get_chain_data(proxy_data * pd, unsigned int *proxy_count, chain_type * ct);
|
||||
|
||||
static void* load_sym(char* symname, void* proxyfunc, int is_mandatory) {
|
||||
void *funcptr = dlsym(RTLD_NEXT, symname);
|
||||
|
||||
if(is_mandatory && !funcptr) {
|
||||
fprintf(stderr, "Cannot load symbol '%s' %s\n", symname, dlerror());
|
||||
exit(1);
|
||||
} else if (!funcptr) {
|
||||
return funcptr;
|
||||
} else {
|
||||
PDEBUG("loaded symbol '%s'" " real addr %p wrapped addr %p\n", symname, funcptr, proxyfunc);
|
||||
}
|
||||
if(funcptr == proxyfunc) {
|
||||
PDEBUG("circular reference detected, aborting!\n");
|
||||
abort();
|
||||
}
|
||||
return funcptr;
|
||||
}
|
||||
|
||||
#include "allocator_thread.h"
|
||||
|
||||
const char *proxychains_get_version(void);
|
||||
|
||||
static void setup_hooks(void);
|
||||
|
||||
typedef struct {
|
||||
unsigned int first, last, flags;
|
||||
} close_range_args_t;
|
||||
|
||||
/* If there is some `close` or `close_range` system call before do_init,
|
||||
we buffer it, and actually execute them in do_init. */
|
||||
static int close_fds[16];
|
||||
static int close_fds_cnt = 0;
|
||||
static close_range_args_t close_range_buffer[16];
|
||||
static int close_range_buffer_cnt = 0;
|
||||
|
||||
static unsigned get_rand_seed(void) {
|
||||
#ifdef HAVE_CLOCK_GETTIME
|
||||
struct timespec now;
|
||||
clock_gettime(CLOCK_REALTIME, &now);
|
||||
return now.tv_sec ^ now.tv_nsec;
|
||||
#else
|
||||
return time(NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void do_init(void) {
|
||||
char *env;
|
||||
|
||||
srand(get_rand_seed());
|
||||
core_initialize();
|
||||
|
||||
env = getenv(PROXYCHAINS_QUIET_MODE_ENV_VAR);
|
||||
if(env && *env == '1')
|
||||
proxychains_quiet_mode = 1;
|
||||
|
||||
proxychains_write_log(LOG_PREFIX "DLL init: proxychains-ng %s\n", proxychains_get_version());
|
||||
|
||||
setup_hooks();
|
||||
|
||||
/* read the config file */
|
||||
get_chain_data(proxychains_pd, &proxychains_proxy_count, &proxychains_ct);
|
||||
DUMP_PROXY_CHAIN(proxychains_pd, proxychains_proxy_count);
|
||||
|
||||
while(close_fds_cnt) true_close(close_fds[--close_fds_cnt]);
|
||||
while(close_range_buffer_cnt) {
|
||||
int i = --close_range_buffer_cnt;
|
||||
true_close_range(close_range_buffer[i].first, close_range_buffer[i].last, close_range_buffer[i].flags);
|
||||
}
|
||||
init_l = 1;
|
||||
|
||||
rdns_init(proxychains_resolver);
|
||||
}
|
||||
|
||||
static void init_lib_wrapper(const char* caller) {
|
||||
#ifndef DEBUG
|
||||
(void) caller;
|
||||
#endif
|
||||
if(!init_l) PDEBUG("%s called from %s\n", __FUNCTION__, caller);
|
||||
pthread_once(&init_once, do_init);
|
||||
}
|
||||
|
||||
/* 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__+0 > 2
|
||||
__attribute__((constructor))
|
||||
static void gcc_init(void) {
|
||||
init_lib_wrapper(__FUNCTION__);
|
||||
}
|
||||
#define INIT() do {} while(0)
|
||||
#else
|
||||
#define INIT() init_lib_wrapper(__FUNCTION__)
|
||||
#endif
|
||||
|
||||
|
||||
typedef enum {
|
||||
RS_PT_NONE = 0,
|
||||
RS_PT_SOCKS4,
|
||||
RS_PT_SOCKS5,
|
||||
RS_PT_HTTP
|
||||
} rs_proxyType;
|
||||
|
||||
/*
|
||||
proxy_from_string() taken from rocksock network I/O library (C) rofl0r
|
||||
valid inputs:
|
||||
socks5://user:password@proxy.domain.com:port
|
||||
socks5://proxy.domain.com:port
|
||||
socks4://proxy.domain.com:port
|
||||
http://user:password@proxy.domain.com:port
|
||||
http://proxy.domain.com:port
|
||||
|
||||
supplying port number is obligatory.
|
||||
user:pass@ part is optional for http and socks5.
|
||||
however, user:pass authentication is currently not implemented for http proxies.
|
||||
return 1 on success, 0 on error.
|
||||
*/
|
||||
static int proxy_from_string(const char *proxystring,
|
||||
char *type_buf,
|
||||
char* host_buf,
|
||||
int *port_n,
|
||||
char *user_buf,
|
||||
char* pass_buf)
|
||||
{
|
||||
const char* p;
|
||||
rs_proxyType proxytype;
|
||||
|
||||
size_t next_token = 6, ul = 0, pl = 0, hl;
|
||||
if(!proxystring[0] || !proxystring[1] || !proxystring[2] || !proxystring[3] || !proxystring[4] || !proxystring[5]) goto inv_string;
|
||||
if(*proxystring == 's') {
|
||||
switch(proxystring[5]) {
|
||||
case '5': proxytype = RS_PT_SOCKS5; break;
|
||||
case '4': proxytype = RS_PT_SOCKS4; break;
|
||||
default: goto inv_string;
|
||||
}
|
||||
} else if(*proxystring == 'h') {
|
||||
proxytype = RS_PT_HTTP;
|
||||
next_token = 4;
|
||||
} else goto inv_string;
|
||||
if(
|
||||
proxystring[next_token++] != ':' ||
|
||||
proxystring[next_token++] != '/' ||
|
||||
proxystring[next_token++] != '/') goto inv_string;
|
||||
const char *at = strrchr(proxystring+next_token, '@');
|
||||
if(at) {
|
||||
if(proxytype == RS_PT_SOCKS4)
|
||||
return 0;
|
||||
p = strchr(proxystring+next_token, ':');
|
||||
if(!p || p >= at) goto inv_string;
|
||||
const char *u = proxystring+next_token;
|
||||
ul = p-u;
|
||||
p++;
|
||||
pl = at-p;
|
||||
if(proxytype == RS_PT_SOCKS5 && (ul > 255 || pl > 255))
|
||||
return 0;
|
||||
memcpy(user_buf, u, ul);
|
||||
user_buf[ul]=0;
|
||||
memcpy(pass_buf, p, pl);
|
||||
pass_buf[pl]=0;
|
||||
next_token += 2+ul+pl;
|
||||
} else {
|
||||
user_buf[0]=0;
|
||||
pass_buf[0]=0;
|
||||
}
|
||||
const char* h = proxystring+next_token;
|
||||
p = strchr(h, ':');
|
||||
if(!p) goto inv_string;
|
||||
hl = p-h;
|
||||
if(hl > 255)
|
||||
return 0;
|
||||
memcpy(host_buf, h, hl);
|
||||
host_buf[hl]=0;
|
||||
*port_n = atoi(p+1);
|
||||
switch(proxytype) {
|
||||
case RS_PT_SOCKS4:
|
||||
strcpy(type_buf, "socks4");
|
||||
break;
|
||||
case RS_PT_SOCKS5:
|
||||
strcpy(type_buf, "socks5");
|
||||
break;
|
||||
case RS_PT_HTTP:
|
||||
strcpy(type_buf, "http");
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
inv_string:
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const char* bool_str(int bool_val) {
|
||||
if(bool_val) return "true";
|
||||
return "false";
|
||||
}
|
||||
|
||||
#define STR_STARTSWITH(P, LIT) (!strncmp(P, LIT, sizeof(LIT)-1))
|
||||
/* get configuration from config file */
|
||||
static void get_chain_data(proxy_data * pd, unsigned int *proxy_count, chain_type * ct) {
|
||||
int count = 0, port_n = 0, list = 0;
|
||||
char buf[1024], type[1024], host[1024], user[1024];
|
||||
char *buff, *env, *p;
|
||||
char local_addr_port[64], local_addr[64], local_netmask[32];
|
||||
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];
|
||||
char rdnsd_addr[32], rdnsd_port[8];
|
||||
FILE *file = NULL;
|
||||
|
||||
if(proxychains_got_chain_data)
|
||||
return;
|
||||
|
||||
PFUNC();
|
||||
|
||||
//Some defaults
|
||||
tcp_read_time_out = 4 * 1000;
|
||||
tcp_connect_time_out = 10 * 1000;
|
||||
*ct = DYNAMIC_TYPE;
|
||||
|
||||
env = get_config_path(getenv(PROXYCHAINS_CONF_FILE_ENV_VAR), buf, sizeof(buf));
|
||||
if( ( file = fopen(env, "r") ) == NULL )
|
||||
{
|
||||
perror("couldnt read configuration file");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
while(fgets(buf, sizeof(buf), file)) {
|
||||
buff = buf;
|
||||
/* remove leading whitespace */
|
||||
while(isspace(*buff)) buff++;
|
||||
/* remove trailing '\n' */
|
||||
if((p = strrchr(buff, '\n'))) *p = 0;
|
||||
p = buff + strlen(buff)-1;
|
||||
/* remove trailing whitespace */
|
||||
while(p >= buff && isspace(*p)) *(p--) = 0;
|
||||
if(!*buff || *buff == '#') continue; /* skip empty lines and comments */
|
||||
if(1) {
|
||||
/* 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;
|
||||
|
||||
int ret = sscanf(buff, "%s %s %d %s %s", type, host, &port_n, pd[count].user, pd[count].pass);
|
||||
if(ret < 3 || ret == EOF) {
|
||||
if(!proxy_from_string(buff, type, host, &port_n, pd[count].user, pd[count].pass)) {
|
||||
inv:
|
||||
fprintf(stderr, "error: invalid item in proxylist section: %s", buff);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
memset(&pd[count].ip, 0, sizeof(pd[count].ip));
|
||||
pd[count].ip.is_v6 = !!strchr(host, ':');
|
||||
pd[count].port = htons((unsigned short) port_n);
|
||||
ip_type* host_ip = &pd[count].ip;
|
||||
if(1 != inet_pton(host_ip->is_v6 ? AF_INET6 : AF_INET, host, host_ip->addr.v6)) {
|
||||
if(*ct == STRICT_TYPE && proxychains_resolver >= DNSLF_RDNS_START && count > 0) {
|
||||
/* we can allow dns hostnames for all but the first proxy in the list if chaintype is strict, as remote lookup can be done */
|
||||
rdns_init(proxychains_resolver);
|
||||
ip_type4 internal_ip = rdns_get_ip_for_host(host, strlen(host));
|
||||
pd[count].ip.is_v6 = 0;
|
||||
host_ip->addr.v4 = internal_ip;
|
||||
if(internal_ip.as_int == IPT4_INVALID.as_int)
|
||||
goto inv_host;
|
||||
} else {
|
||||
inv_host:
|
||||
fprintf(stderr, "proxy %s has invalid value or is not numeric\n", host);
|
||||
fprintf(stderr, "non-numeric ips are only allowed under the following circumstances:\n");
|
||||
fprintf(stderr, "chaintype == strict (%s), proxy is not first in list (%s), proxy_dns active (%s)\n\n", bool_str(*ct == STRICT_TYPE), bool_str(count > 0), rdns_resolver_string(proxychains_resolver));
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if(!strcmp(type, "http")) {
|
||||
pd[count].pt = HTTP_TYPE;
|
||||
} 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")) {
|
||||
pd[count].pt = SOCKS5_TYPE;
|
||||
} else
|
||||
goto inv;
|
||||
|
||||
if(port_n)
|
||||
count++;
|
||||
} else {
|
||||
if(!strcmp(buff, "[ProxyList]")) {
|
||||
list = 1;
|
||||
} else if(!strcmp(buff, "random_chain")) {
|
||||
*ct = RANDOM_TYPE;
|
||||
} else if(!strcmp(buff, "strict_chain")) {
|
||||
*ct = STRICT_TYPE;
|
||||
} else if(!strcmp(buff, "dynamic_chain")) {
|
||||
*ct = DYNAMIC_TYPE;
|
||||
} else if(!strcmp(buff, "round_robin_chain")) {
|
||||
*ct = ROUND_ROBIN_TYPE;
|
||||
} else if(STR_STARTSWITH(buff, "tcp_read_time_out")) {
|
||||
sscanf(buff, "%s %d", user, &tcp_read_time_out);
|
||||
} else if(STR_STARTSWITH(buff, "tcp_connect_time_out")) {
|
||||
sscanf(buff, "%s %d", user, &tcp_connect_time_out);
|
||||
} else if(STR_STARTSWITH(buff, "remote_dns_subnet")) {
|
||||
sscanf(buff, "%s %u", 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(STR_STARTSWITH(buff, "localnet")) {
|
||||
char colon, extra, right_bracket[2];
|
||||
unsigned short local_port = 0, local_prefix;
|
||||
int local_family, n, valid;
|
||||
if(sscanf(buff, "%s %53[^/]/%15s%c", user, local_addr_port, local_netmask, &extra) != 3) {
|
||||
fprintf(stderr, "localnet format error");
|
||||
exit(1);
|
||||
}
|
||||
p = strchr(local_addr_port, ':');
|
||||
if(!p || p == strrchr(local_addr_port, ':')) {
|
||||
local_family = AF_INET;
|
||||
n = sscanf(local_addr_port, "%15[^:]%c%5hu%c", local_addr, &colon, &local_port, &extra);
|
||||
valid = n == 1 || (n == 3 && colon == ':');
|
||||
} else if(local_addr_port[0] == '[') {
|
||||
local_family = AF_INET6;
|
||||
n = sscanf(local_addr_port, "[%45[^][]%1[]]%c%5hu%c", local_addr, right_bracket, &colon, &local_port, &extra);
|
||||
valid = n == 2 || (n == 4 && colon == ':');
|
||||
} else {
|
||||
local_family = AF_INET6;
|
||||
valid = sscanf(local_addr_port, "%45[^][]%c", local_addr, &extra) == 1;
|
||||
}
|
||||
if(!valid) {
|
||||
fprintf(stderr, "localnet address or port error\n");
|
||||
exit(1);
|
||||
}
|
||||
if(local_port) {
|
||||
PDEBUG("added localnet: netaddr=%s, port=%u, netmask=%s\n",
|
||||
local_addr, local_port, local_netmask);
|
||||
} else {
|
||||
PDEBUG("added localnet: netaddr=%s, netmask=%s\n",
|
||||
local_addr, local_netmask);
|
||||
}
|
||||
if(num_localnet_addr < MAX_LOCALNET) {
|
||||
localnet_addr[num_localnet_addr].family = local_family;
|
||||
localnet_addr[num_localnet_addr].port = local_port;
|
||||
valid = 0;
|
||||
if (local_family == AF_INET) {
|
||||
valid =
|
||||
inet_pton(local_family, local_addr,
|
||||
&localnet_addr[num_localnet_addr].in_addr) > 0;
|
||||
} else if(local_family == AF_INET6) {
|
||||
valid =
|
||||
inet_pton(local_family, local_addr,
|
||||
&localnet_addr[num_localnet_addr].in6_addr) > 0;
|
||||
}
|
||||
if(!valid) {
|
||||
fprintf(stderr, "localnet address error\n");
|
||||
exit(1);
|
||||
}
|
||||
if(local_family == AF_INET && strchr(local_netmask, '.')) {
|
||||
valid =
|
||||
inet_pton(local_family, local_netmask,
|
||||
&localnet_addr[num_localnet_addr].in_mask) > 0;
|
||||
} else {
|
||||
valid = sscanf(local_netmask, "%hu%c", &local_prefix, &extra) == 1;
|
||||
if (valid) {
|
||||
if(local_family == AF_INET && local_prefix <= 32) {
|
||||
localnet_addr[num_localnet_addr].in_mask.s_addr =
|
||||
htonl(0xFFFFFFFFu << (32u - local_prefix));
|
||||
} else if(local_family == AF_INET6 && local_prefix <= 128) {
|
||||
localnet_addr[num_localnet_addr].in6_prefix =
|
||||
local_prefix;
|
||||
} else {
|
||||
valid = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!valid) {
|
||||
fprintf(stderr, "localnet netmask error\n");
|
||||
exit(1);
|
||||
}
|
||||
++num_localnet_addr;
|
||||
} else {
|
||||
fprintf(stderr, "# of localnet exceed %d.\n", MAX_LOCALNET);
|
||||
}
|
||||
} else if(STR_STARTSWITH(buff, "chain_len")) {
|
||||
char *pc;
|
||||
int len;
|
||||
pc = strchr(buff, '=');
|
||||
if(!pc) {
|
||||
fprintf(stderr, "error: missing equals sign '=' in chain_len directive.\n");
|
||||
exit(1);
|
||||
}
|
||||
len = atoi(++pc);
|
||||
proxychains_max_chain = (len ? len : 1);
|
||||
} else if(!strcmp(buff, "quiet_mode")) {
|
||||
proxychains_quiet_mode = 1;
|
||||
} else if(!strcmp(buff, "proxy_dns_old")) {
|
||||
proxychains_resolver = DNSLF_FORKEXEC;
|
||||
} else if(!strcmp(buff, "proxy_dns")) {
|
||||
proxychains_resolver = DNSLF_RDNS_THREAD;
|
||||
} else if(STR_STARTSWITH(buff, "proxy_dns_daemon")) {
|
||||
struct sockaddr_in rdns_server_buffer;
|
||||
|
||||
if(sscanf(buff, "%s %15[^:]:%5s", user, rdnsd_addr, rdnsd_port) < 3) {
|
||||
fprintf(stderr, "proxy_dns_daemon format error\n");
|
||||
exit(1);
|
||||
}
|
||||
rdns_server_buffer.sin_family = AF_INET;
|
||||
int error = inet_pton(AF_INET, rdnsd_addr, &rdns_server_buffer.sin_addr);
|
||||
if(error <= 0) {
|
||||
fprintf(stderr, "bogus proxy_dns_daemon address\n");
|
||||
exit(1);
|
||||
}
|
||||
rdns_server_buffer.sin_port = htons(atoi(rdnsd_port));
|
||||
proxychains_resolver = DNSLF_RDNS_DAEMON;
|
||||
rdns_set_daemon(&rdns_server_buffer);
|
||||
} else if(STR_STARTSWITH(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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifndef BROKEN_FCLOSE
|
||||
fclose(file);
|
||||
#endif
|
||||
if(!count) {
|
||||
fprintf(stderr, "error: no valid proxy found in config\n");
|
||||
exit(1);
|
||||
}
|
||||
*proxy_count = count;
|
||||
proxychains_got_chain_data = 1;
|
||||
PDEBUG("proxy_dns: %s\n", rdns_resolver_string(proxychains_resolver));
|
||||
}
|
||||
|
||||
/******* HOOK FUNCTIONS *******/
|
||||
|
||||
#define EXPAND( args...) args
|
||||
#ifdef MONTEREY_HOOKING
|
||||
#define HOOKFUNC(R, N, args...) R pxcng_ ## N ( EXPAND(args) )
|
||||
#else
|
||||
#define HOOKFUNC(R, N, args...) R N ( EXPAND(args) )
|
||||
#endif
|
||||
|
||||
HOOKFUNC(int, close, int fd) {
|
||||
if(!init_l) {
|
||||
if(close_fds_cnt>=(sizeof close_fds/sizeof close_fds[0])) goto err;
|
||||
close_fds[close_fds_cnt++] = fd;
|
||||
errno = 0;
|
||||
return 0;
|
||||
}
|
||||
if(proxychains_resolver != DNSLF_RDNS_THREAD) return true_close(fd);
|
||||
|
||||
/* prevent rude programs (like ssh) from closing our pipes */
|
||||
if(fd != req_pipefd[0] && fd != req_pipefd[1] &&
|
||||
fd != resp_pipefd[0] && fd != resp_pipefd[1]) {
|
||||
return true_close(fd);
|
||||
}
|
||||
err:
|
||||
errno = EBADF;
|
||||
return -1;
|
||||
}
|
||||
static int is_v4inv6(const struct in6_addr *a) {
|
||||
return !memcmp(a->s6_addr, "\0\0\0\0\0\0\0\0\0\0\xff\xff", 12);
|
||||
}
|
||||
|
||||
static void intsort(int *a, int n) {
|
||||
int i, j, s;
|
||||
for(i=0; i<n; ++i)
|
||||
for(j=i+1; j<n; ++j)
|
||||
if(a[j] < a[i]) {
|
||||
s = a[i];
|
||||
a[i] = a[j];
|
||||
a[j] = s;
|
||||
}
|
||||
}
|
||||
|
||||
/* Warning: Linux manual says the third arg is `unsigned int`, but unistd.h says `int`. */
|
||||
HOOKFUNC(int, close_range, unsigned first, unsigned last, int flags) {
|
||||
if(true_close_range == NULL) {
|
||||
fprintf(stderr, "Calling close_range, but this platform does not provide this system call. ");
|
||||
return -1;
|
||||
}
|
||||
if(!init_l) {
|
||||
/* push back to cache, and delay the execution. */
|
||||
if(close_range_buffer_cnt >= (sizeof close_range_buffer / sizeof close_range_buffer[0])) {
|
||||
errno = ENOMEM;
|
||||
return -1;
|
||||
}
|
||||
int i = close_range_buffer_cnt++;
|
||||
close_range_buffer[i].first = first;
|
||||
close_range_buffer[i].last = last;
|
||||
close_range_buffer[i].flags = flags;
|
||||
return errno = 0;
|
||||
}
|
||||
if(proxychains_resolver != DNSLF_RDNS_THREAD) return true_close_range(first, last, flags);
|
||||
|
||||
/* prevent rude programs (like ssh) from closing our pipes */
|
||||
int res = 0, uerrno = 0, i;
|
||||
int protected_fds[] = {req_pipefd[0], req_pipefd[1], resp_pipefd[0], resp_pipefd[1]};
|
||||
intsort(protected_fds, 4);
|
||||
/* We are skipping protected_fds while calling true_close_range()
|
||||
* If protected_fds cut the range into some sub-ranges, we close sub-ranges BEFORE cut point in the loop.
|
||||
* [first, cut1-1] , [cut1+1, cut2-1] , [cut2+1, cut3-1]
|
||||
* Finally, we delete the remaining sub-range, outside the loop. [cut3+1, tail]
|
||||
*/
|
||||
int next_fd_to_close = first;
|
||||
for(i = 0; i < 4; ++i) {
|
||||
if(protected_fds[i] < first || protected_fds[i] > last)
|
||||
continue;
|
||||
int prev = (i == 0 || protected_fds[i-1] < first) ? first : protected_fds[i-1]+1;
|
||||
if(prev != protected_fds[i]) {
|
||||
if(-1 == true_close_range(prev, protected_fds[i]-1, flags)) {
|
||||
res = -1;
|
||||
uerrno = errno;
|
||||
}
|
||||
}
|
||||
next_fd_to_close = protected_fds[i]+1;
|
||||
}
|
||||
if(next_fd_to_close <= last) {
|
||||
if(-1 == true_close_range(next_fd_to_close, last, flags)) {
|
||||
res = -1;
|
||||
uerrno = errno;
|
||||
}
|
||||
}
|
||||
errno = uerrno;
|
||||
return res;
|
||||
}
|
||||
|
||||
HOOKFUNC(int, connect, int sock, const struct sockaddr *addr, unsigned int len) {
|
||||
INIT();
|
||||
PFUNC();
|
||||
|
||||
int socktype = 0, flags = 0, ret = 0;
|
||||
socklen_t optlen = 0;
|
||||
ip_type dest_ip;
|
||||
DEBUGDECL(char str[256]);
|
||||
|
||||
struct in_addr *p_addr_in;
|
||||
struct in6_addr *p_addr_in6;
|
||||
dnat_arg *dnat = NULL;
|
||||
unsigned short port;
|
||||
size_t i;
|
||||
int remote_dns_connect = 0;
|
||||
optlen = sizeof(socktype);
|
||||
sa_family_t fam = SOCKFAMILY(*addr);
|
||||
getsockopt(sock, SOL_SOCKET, SO_TYPE, &socktype, &optlen);
|
||||
if(!((fam == AF_INET || fam == AF_INET6) && socktype == SOCK_STREAM))
|
||||
return true_connect(sock, addr, len);
|
||||
|
||||
int v6 = dest_ip.is_v6 = fam == AF_INET6;
|
||||
|
||||
p_addr_in = &((struct sockaddr_in *) addr)->sin_addr;
|
||||
p_addr_in6 = &((struct sockaddr_in6 *) addr)->sin6_addr;
|
||||
port = !v6 ? ntohs(((struct sockaddr_in *) addr)->sin_port)
|
||||
: ntohs(((struct sockaddr_in6 *) addr)->sin6_port);
|
||||
struct in_addr v4inv6;
|
||||
if(v6 && is_v4inv6(p_addr_in6)) {
|
||||
memcpy(&v4inv6.s_addr, &p_addr_in6->s6_addr[12], 4);
|
||||
v6 = dest_ip.is_v6 = 0;
|
||||
p_addr_in = &v4inv6;
|
||||
}
|
||||
if(!v6 && !memcmp(p_addr_in, "\0\0\0\0", 4)) {
|
||||
errno = ECONNREFUSED;
|
||||
return -1;
|
||||
}
|
||||
|
||||
// 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(v6 ? AF_INET6 : AF_INET, v6 ? (void*)p_addr_in6 : (void*)p_addr_in, str, sizeof(str)));
|
||||
PDEBUG("port: %d\n", port);
|
||||
|
||||
// check if connect called from proxydns
|
||||
remote_dns_connect = !v6 && (ntohl(p_addr_in->s_addr) >> 24 == remote_dns_subnet);
|
||||
|
||||
// more specific first
|
||||
if (!v6) 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];
|
||||
|
||||
if (!v6) 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) {
|
||||
p_addr_in = &dnat->new_dst;
|
||||
if (dnat->new_port)
|
||||
port = dnat->new_port;
|
||||
}
|
||||
|
||||
for(i = 0; i < num_localnet_addr && !remote_dns_connect; i++) {
|
||||
if (localnet_addr[i].port && localnet_addr[i].port != port)
|
||||
continue;
|
||||
if (localnet_addr[i].family != (v6 ? AF_INET6 : AF_INET))
|
||||
continue;
|
||||
if (v6) {
|
||||
size_t prefix_bytes = localnet_addr[i].in6_prefix / CHAR_BIT;
|
||||
size_t prefix_bits = localnet_addr[i].in6_prefix % CHAR_BIT;
|
||||
if (prefix_bytes && memcmp(p_addr_in6->s6_addr, localnet_addr[i].in6_addr.s6_addr, prefix_bytes) != 0)
|
||||
continue;
|
||||
if (prefix_bits && (p_addr_in6->s6_addr[prefix_bytes] ^ localnet_addr[i].in6_addr.s6_addr[prefix_bytes]) >> (CHAR_BIT - prefix_bits))
|
||||
continue;
|
||||
} else {
|
||||
if((p_addr_in->s_addr ^ localnet_addr[i].in_addr.s_addr) & localnet_addr[i].in_mask.s_addr)
|
||||
continue;
|
||||
}
|
||||
PDEBUG("accessing localnet using true_connect\n");
|
||||
return true_connect(sock, addr, len);
|
||||
}
|
||||
|
||||
flags = fcntl(sock, F_GETFL, 0);
|
||||
if(flags & O_NONBLOCK)
|
||||
fcntl(sock, F_SETFL, !O_NONBLOCK);
|
||||
|
||||
memcpy(dest_ip.addr.v6, v6 ? (void*)p_addr_in6 : (void*)p_addr_in, v6?16:4);
|
||||
|
||||
ret = connect_proxy_chain(sock,
|
||||
dest_ip,
|
||||
htons(port),
|
||||
proxychains_pd, proxychains_proxy_count, proxychains_ct, proxychains_max_chain);
|
||||
|
||||
fcntl(sock, F_SETFL, flags);
|
||||
if(ret != SUCCESS)
|
||||
errno = ECONNREFUSED;
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef IS_SOLARIS
|
||||
HOOKFUNC(int, __xnet_connect, int sock, const struct sockaddr *addr, unsigned int len)
|
||||
return connect(sock, addr, len);
|
||||
}
|
||||
#endif
|
||||
|
||||
static struct gethostbyname_data ghbndata;
|
||||
HOOKFUNC(struct hostent*, gethostbyname, const char *name) {
|
||||
INIT();
|
||||
PDEBUG("gethostbyname: %s\n", name);
|
||||
|
||||
if(proxychains_resolver == DNSLF_FORKEXEC)
|
||||
return proxy_gethostbyname_old(name);
|
||||
else if(proxychains_resolver == DNSLF_LIBC)
|
||||
return true_gethostbyname(name);
|
||||
else
|
||||
return proxy_gethostbyname(name, &ghbndata);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
HOOKFUNC(int, getaddrinfo, const char *node, const char *service, const struct addrinfo *hints, struct addrinfo **res) {
|
||||
INIT();
|
||||
PDEBUG("getaddrinfo: %s %s\n", node ? node : "null", service ? service : "null");
|
||||
|
||||
if(proxychains_resolver != DNSLF_LIBC)
|
||||
return proxy_getaddrinfo(node, service, hints, res);
|
||||
else
|
||||
return true_getaddrinfo(node, service, hints, res);
|
||||
}
|
||||
|
||||
HOOKFUNC(void, freeaddrinfo, struct addrinfo *res) {
|
||||
INIT();
|
||||
PDEBUG("freeaddrinfo %p \n", (void *) res);
|
||||
|
||||
if(proxychains_resolver == DNSLF_LIBC)
|
||||
true_freeaddrinfo(res);
|
||||
else
|
||||
proxy_freeaddrinfo(res);
|
||||
}
|
||||
|
||||
HOOKFUNC(int, getnameinfo, const struct sockaddr *sa, socklen_t salen,
|
||||
char *host, GN_NODELEN_T hostlen, char *serv,
|
||||
GN_SERVLEN_T servlen, GN_FLAGS_T flags)
|
||||
{
|
||||
INIT();
|
||||
PFUNC();
|
||||
|
||||
if(proxychains_resolver == DNSLF_LIBC) {
|
||||
return true_getnameinfo(sa, salen, host, hostlen, serv, servlen, flags);
|
||||
} else {
|
||||
if(!salen || !(SOCKFAMILY(*sa) == AF_INET || SOCKFAMILY(*sa) == AF_INET6))
|
||||
return EAI_FAMILY;
|
||||
int v6 = SOCKFAMILY(*sa) == AF_INET6;
|
||||
if(salen < (v6?sizeof(struct sockaddr_in6):sizeof(struct sockaddr_in)))
|
||||
return EAI_FAMILY;
|
||||
if(hostlen) {
|
||||
unsigned char v4inv6buf[4];
|
||||
const void *ip = v6 ? (void*)&((struct sockaddr_in6*)sa)->sin6_addr
|
||||
: (void*)&((struct sockaddr_in*)sa)->sin_addr;
|
||||
unsigned scopeid = 0;
|
||||
if(v6) {
|
||||
if(is_v4inv6(&((struct sockaddr_in6*)sa)->sin6_addr)) {
|
||||
memcpy(v4inv6buf, &((struct sockaddr_in6*)sa)->sin6_addr.s6_addr[12], 4);
|
||||
ip = v4inv6buf;
|
||||
v6 = 0;
|
||||
} else
|
||||
scopeid = ((struct sockaddr_in6 *)sa)->sin6_scope_id;
|
||||
}
|
||||
if(!inet_ntop(v6?AF_INET6:AF_INET,ip,host,hostlen))
|
||||
return EAI_OVERFLOW;
|
||||
if(scopeid) {
|
||||
size_t l = strlen(host);
|
||||
if(snprintf(host+l, hostlen-l, "%%%u", scopeid) >= hostlen-l)
|
||||
return EAI_OVERFLOW;
|
||||
}
|
||||
}
|
||||
if(servlen) {
|
||||
if(snprintf(serv, servlen, "%d", ntohs(SOCKPORT(*sa))) >= servlen)
|
||||
return EAI_OVERFLOW;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
HOOKFUNC(struct hostent*, gethostbyaddr, const void *addr, socklen_t len, int type) {
|
||||
INIT();
|
||||
PDEBUG("TODO: proper gethostbyaddr hook\n");
|
||||
|
||||
static char buf[16];
|
||||
static char ipv4[4];
|
||||
static char *list[2];
|
||||
static char *aliases[1];
|
||||
static struct hostent he;
|
||||
|
||||
if(proxychains_resolver == DNSLF_LIBC)
|
||||
return true_gethostbyaddr(addr, len, type);
|
||||
else {
|
||||
|
||||
PDEBUG("len %u\n", len);
|
||||
if(len != 4)
|
||||
return NULL;
|
||||
he.h_name = buf;
|
||||
memcpy(ipv4, addr, 4);
|
||||
list[0] = ipv4;
|
||||
list[1] = NULL;
|
||||
he.h_addr_list = list;
|
||||
he.h_addrtype = AF_INET;
|
||||
aliases[0] = NULL;
|
||||
he.h_aliases = aliases;
|
||||
he.h_length = 4;
|
||||
pc_stringfromipv4((unsigned char *) addr, buf);
|
||||
return &he;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifndef MSG_FASTOPEN
|
||||
# define MSG_FASTOPEN 0x20000000
|
||||
#endif
|
||||
|
||||
HOOKFUNC(ssize_t, sendto, int sockfd, const void *buf, size_t len, int flags,
|
||||
const struct sockaddr *dest_addr, socklen_t addrlen) {
|
||||
INIT();
|
||||
PFUNC();
|
||||
if (flags & MSG_FASTOPEN) {
|
||||
if (!connect(sockfd, dest_addr, addrlen) && errno != EINPROGRESS) {
|
||||
return -1;
|
||||
}
|
||||
dest_addr = NULL;
|
||||
addrlen = 0;
|
||||
flags &= ~MSG_FASTOPEN;
|
||||
}
|
||||
return true_sendto(sockfd, buf, len, flags, dest_addr, addrlen);
|
||||
}
|
||||
|
||||
#ifdef MONTEREY_HOOKING
|
||||
#define SETUP_SYM(X) do { if (! true_ ## X ) true_ ## X = &X; } while(0)
|
||||
#define SETUP_SYM_OPTIONAL(X)
|
||||
#else
|
||||
#define SETUP_SYM_IMPL(X, IS_MANDATORY) do { if (! true_ ## X ) true_ ## X = load_sym( # X, X, IS_MANDATORY ); } while(0)
|
||||
#define SETUP_SYM(X) SETUP_SYM_IMPL(X, 1)
|
||||
#define SETUP_SYM_OPTIONAL(X) SETUP_SYM_IMPL(X, 0)
|
||||
#endif
|
||||
|
||||
static void setup_hooks(void) {
|
||||
SETUP_SYM(connect);
|
||||
SETUP_SYM(sendto);
|
||||
SETUP_SYM(gethostbyname);
|
||||
SETUP_SYM(getaddrinfo);
|
||||
SETUP_SYM(freeaddrinfo);
|
||||
SETUP_SYM(gethostbyaddr);
|
||||
SETUP_SYM(getnameinfo);
|
||||
#ifdef IS_SOLARIS
|
||||
SETUP_SYM(__xnet_connect);
|
||||
#endif
|
||||
SETUP_SYM(close);
|
||||
SETUP_SYM_OPTIONAL(close_range);
|
||||
}
|
||||
|
||||
#ifdef MONTEREY_HOOKING
|
||||
|
||||
#define DYLD_INTERPOSE(_replacement,_replacee) \
|
||||
__attribute__((used)) static struct{ const void* replacement; const void* replacee; } _interpose_##_replacee \
|
||||
__attribute__((section ("__DATA,__interpose"))) = { (const void*)(unsigned long)&_replacement, (const void*)(unsigned long)&_replacee };
|
||||
#define DYLD_HOOK(F) DYLD_INTERPOSE(pxcng_ ## F, F)
|
||||
|
||||
DYLD_HOOK(connect);
|
||||
DYLD_HOOK(sendto);
|
||||
DYLD_HOOK(gethostbyname);
|
||||
DYLD_HOOK(getaddrinfo);
|
||||
DYLD_HOOK(freeaddrinfo);
|
||||
DYLD_HOOK(gethostbyaddr);
|
||||
DYLD_HOOK(getnameinfo);
|
||||
DYLD_HOOK(close);
|
||||
|
||||
#endif
|
||||
+165
@@ -0,0 +1,165 @@
|
||||
/* (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 *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#define _DEFAULT_SOURCE
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
#ifdef IS_MAC
|
||||
#define _DARWIN_C_SOURCE
|
||||
#endif
|
||||
#include <dlfcn.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-f allows one 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;
|
||||
}
|
||||
|
||||
static const char *dll_name = DLL_NAME;
|
||||
|
||||
static char own_dir[256];
|
||||
static const char *dll_dirs[] = {
|
||||
#ifndef SUPER_SECURE /* CVE-2015-3887 */
|
||||
".",
|
||||
#endif
|
||||
own_dir,
|
||||
LIB_DIR,
|
||||
"/lib",
|
||||
"/usr/lib",
|
||||
"/usr/local/lib",
|
||||
"/lib64",
|
||||
NULL
|
||||
};
|
||||
|
||||
static void set_own_dir(const char *argv0) {
|
||||
size_t l = strlen(argv0);
|
||||
while(l && argv0[l - 1] != '/')
|
||||
l--;
|
||||
if(l == 0 || l >= sizeof(own_dir))
|
||||
#ifdef SUPER_SECURE
|
||||
memcpy(own_dir, "/dev/null/", 11);
|
||||
#else
|
||||
memcpy(own_dir, ".", 2);
|
||||
#endif
|
||||
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 start_argv = 1;
|
||||
int quiet = 0;
|
||||
size_t i;
|
||||
const char *prefix = NULL;
|
||||
|
||||
if(argc == 2 && !strcmp(argv[1], "--help"))
|
||||
return usage(argv);
|
||||
|
||||
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++;
|
||||
} else if(argv[start_argv][1] == 'f') {
|
||||
|
||||
if(start_argv + 1 < argc)
|
||||
path = argv[start_argv + 1];
|
||||
else
|
||||
return usage(argv);
|
||||
|
||||
start_argv += 2;
|
||||
}
|
||||
} else
|
||||
break;
|
||||
}
|
||||
|
||||
if(start_argv >= argc)
|
||||
return usage(argv);
|
||||
|
||||
/* check if path of config file has not been passed via command line */
|
||||
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);
|
||||
|
||||
|
||||
// search DLL
|
||||
|
||||
Dl_info dli;
|
||||
dladdr(own_dir, &dli);
|
||||
set_own_dir(dli.dli_fname);
|
||||
|
||||
i = 0;
|
||||
|
||||
while(dll_dirs[i]) {
|
||||
snprintf(buf, sizeof(buf), "%s/%s", dll_dirs[i], dll_name);
|
||||
if(access(buf, R_OK) != -1) {
|
||||
prefix = dll_dirs[i];
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
if(!prefix) {
|
||||
fprintf(stderr, "couldnt locate %s\n", dll_name);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if(!quiet)
|
||||
fprintf(stderr, LOG_PREFIX "preloading %s/%s\n", prefix, dll_name);
|
||||
|
||||
#if defined(IS_MAC) || defined(IS_OPENBSD)
|
||||
#define LD_PRELOAD_SEP ":"
|
||||
#else
|
||||
/* Dynlinkers for Linux and most BSDs seem to support space
|
||||
as LD_PRELOAD separator, with colon added only recently.
|
||||
We use the old syntax for maximum compat */
|
||||
#define LD_PRELOAD_SEP " "
|
||||
#endif
|
||||
|
||||
#ifdef IS_MAC
|
||||
putenv("DYLD_FORCE_FLAT_NAMESPACE=1");
|
||||
#define LD_PRELOAD_ENV "DYLD_INSERT_LIBRARIES"
|
||||
#else
|
||||
#define LD_PRELOAD_ENV "LD_PRELOAD"
|
||||
#endif
|
||||
char *old_val = getenv(LD_PRELOAD_ENV);
|
||||
snprintf(buf, sizeof(buf), LD_PRELOAD_ENV "=%s/%s%s%s",
|
||||
prefix, dll_name,
|
||||
/* append previous LD_PRELOAD content, if existent */
|
||||
old_val ? LD_PRELOAD_SEP : "",
|
||||
old_val ? old_val : "");
|
||||
putenv(buf);
|
||||
execvp(argv[start_argv], &argv[start_argv]);
|
||||
fprintf(stderr, "proxychains: can't load process '%s'.", argv[start_argv]);
|
||||
perror(" (hint: it's probably a typo)");
|
||||
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
#ifndef MUTEX_H
|
||||
#define MUTEX_H
|
||||
|
||||
#include <pthread.h>
|
||||
# define MUTEX_LOCK(x) pthread_mutex_lock(x)
|
||||
# define MUTEX_UNLOCK(x) pthread_mutex_unlock(x)
|
||||
# define MUTEX_INIT(x) pthread_mutex_init(x, NULL)
|
||||
# define MUTEX_DESTROY(x) pthread_mutex_destroy(x)
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,162 @@
|
||||
# proxychains.conf VER 4.x
|
||||
#
|
||||
# HTTP, SOCKS4a, SOCKS5 tunneling proxifier with DNS.
|
||||
|
||||
|
||||
# The option below identifies how the ProxyList is treated.
|
||||
# only one option should be uncommented at time,
|
||||
# otherwise the last appearing option will be accepted
|
||||
#
|
||||
#dynamic_chain
|
||||
#
|
||||
# Dynamic - Each connection will be done via chained proxies
|
||||
# all proxies chained in the order as they appear in the list
|
||||
# at least one proxy must be online to play in chain
|
||||
# (dead proxies are skipped)
|
||||
# otherwise EINTR is returned to the app
|
||||
#
|
||||
strict_chain
|
||||
#
|
||||
# Strict - Each connection will be done via chained proxies
|
||||
# all proxies chained in the order as they appear in the list
|
||||
# all proxies must be online to play in chain
|
||||
# otherwise EINTR is returned to the app
|
||||
#
|
||||
#round_robin_chain
|
||||
#
|
||||
# Round Robin - Each connection will be done via chained proxies
|
||||
# of chain_len length
|
||||
# all proxies chained in the order as they appear in the list
|
||||
# at least one proxy must be online to play in chain
|
||||
# (dead proxies are skipped).
|
||||
# the start of the current proxy chain is the proxy after the last
|
||||
# proxy in the previously invoked proxy chain.
|
||||
# if the end of the proxy chain is reached while looking for proxies
|
||||
# start at the beginning again.
|
||||
# otherwise EINTR is returned to the app
|
||||
# These semantics are not guaranteed in a multithreaded environment.
|
||||
#
|
||||
#random_chain
|
||||
#
|
||||
# Random - Each connection will be done via random proxy
|
||||
# (or proxy chain, see chain_len) from the list.
|
||||
# this option is good to test your IDS :)
|
||||
|
||||
# Make sense only if random_chain or round_robin_chain
|
||||
#chain_len = 2
|
||||
|
||||
# Quiet mode (no output from library)
|
||||
#quiet_mode
|
||||
|
||||
## Proxy DNS requests - no leak for DNS data
|
||||
# (disable all of the 3 items below to not proxy your DNS requests)
|
||||
|
||||
# method 1. this uses the proxychains4 style method to do remote dns:
|
||||
# a thread is spawned that serves DNS requests and hands down an ip
|
||||
# assigned from an internal list (via remote_dns_subnet).
|
||||
# this is the easiest (setup-wise) and fastest method, however on
|
||||
# systems with buggy libcs and very complex software like webbrowsers
|
||||
# this might not work and/or cause crashes.
|
||||
proxy_dns
|
||||
|
||||
# method 2. use the old proxyresolv script to proxy DNS requests
|
||||
# in proxychains 3.1 style. requires `proxyresolv` in $PATH
|
||||
# plus a dynamically linked `dig` binary.
|
||||
# this is a lot slower than `proxy_dns`, doesn't support .onion URLs,
|
||||
# but might be more compatible with complex software like webbrowsers.
|
||||
#proxy_dns_old
|
||||
|
||||
# method 3. use proxychains4-daemon process to serve remote DNS requests.
|
||||
# this is similar to the threaded `proxy_dns` method, however it requires
|
||||
# that proxychains4-daemon is already running on the specified address.
|
||||
# on the plus side it doesn't do malloc/threads so it should be quite
|
||||
# compatible with complex, async-unsafe software.
|
||||
# note that if you don't start proxychains4-daemon before using this,
|
||||
# the process will simply hang.
|
||||
#proxy_dns_daemon 127.0.0.1:1053
|
||||
|
||||
# set the class A subnet number to use for 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
|
||||
|
||||
### Examples for localnet exclusion
|
||||
## localnet ranges will *not* use a proxy to connect.
|
||||
## note that localnet works only when plain IP addresses are passed to the app,
|
||||
## the hostname resolves via /etc/hosts, or proxy_dns is disabled or proxy_dns_old used.
|
||||
|
||||
## Exclude connections to 192.168.1.0/24 with port 80
|
||||
# localnet 192.168.1.0:80/255.255.255.0
|
||||
|
||||
## Exclude connections to 192.168.100.0/24
|
||||
# localnet 192.168.100.0/255.255.255.0
|
||||
|
||||
## Exclude connections to ANYwhere with port 80
|
||||
# localnet 0.0.0.0:80/0.0.0.0
|
||||
# localnet [::]:80/0
|
||||
|
||||
## RFC6890 Loopback address range
|
||||
## if you enable this, you have to make sure remote_dns_subnet is not 127
|
||||
## you'll need to enable it if you want to use an application that
|
||||
## connects to localhost.
|
||||
# localnet 127.0.0.0/255.0.0.0
|
||||
# localnet ::1/128
|
||||
|
||||
## 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
|
||||
|
||||
### 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 ip port [user pass]
|
||||
# (values separated by 'tab' or 'blank')
|
||||
#
|
||||
# only numeric ipv4 addresses are valid
|
||||
#
|
||||
#
|
||||
# Examples:
|
||||
#
|
||||
# socks5 192.168.67.78 1080 lamer secret
|
||||
# http 192.168.89.3 8080 justu hidden
|
||||
# socks4 192.168.1.49 1080
|
||||
# http 192.168.39.93 8080
|
||||
#
|
||||
#
|
||||
# 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
|
||||
# defaults set to "tor"
|
||||
socks4 127.0.0.1 9050
|
||||
|
||||
Executable
+23
@@ -0,0 +1,23 @@
|
||||
#!/bin/sh
|
||||
# This is a legacy script that uses "dig" or "drill" to do DNS lookups via TCP.
|
||||
|
||||
# DNS server used to resolve names
|
||||
test -z "$DNS_SERVER" && DNS_SERVER=8.8.8.8
|
||||
|
||||
|
||||
if [ $# = 0 ] ; then
|
||||
echo " usage:"
|
||||
echo " proxyresolv <hostname> "
|
||||
exit
|
||||
fi
|
||||
|
||||
|
||||
test -z $LD_PRELOAD && export LD_PRELOAD=libproxychains4.so
|
||||
|
||||
if type dig 1>/dev/null 2>&1 ; then
|
||||
dig $1 @$DNS_SERVER +tcp | awk '/A.?[0-9]+\.[0-9]+\.[0-9]/{print $5;}'
|
||||
elif type drill 1>/dev/null 2>&1 ; then
|
||||
drill -t4 $1 @$DNS_SERVER | awk '/A.+[0-9]+\.[0-9]+\.[0-9]/{print $5;}'
|
||||
else
|
||||
echo "error: neither dig nor drill found" >&2
|
||||
fi
|
||||
+99
@@ -0,0 +1,99 @@
|
||||
#include <sys/socket.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "rdns.h"
|
||||
#include "allocator_thread.h"
|
||||
#include "remotedns.h"
|
||||
|
||||
#ifndef HAVE_SOCK_CLOEXEC
|
||||
#define SOCK_CLOEXEC 0
|
||||
#endif
|
||||
|
||||
//static enum dns_lookup_flavor dns_flavor;
|
||||
#define dns_flavor rdns_get_flavor()
|
||||
|
||||
static struct sockaddr_in rdns_server;
|
||||
|
||||
size_t rdns_daemon_get_host_for_ip(ip_type4 ip, char* readbuf) {
|
||||
struct at_msg msg = {
|
||||
.h.msgtype = ATM_GETNAME,
|
||||
.h.datalen = htons(4),
|
||||
.m.ip = ip,
|
||||
};
|
||||
int fd = socket(AF_INET, SOCK_DGRAM|SOCK_CLOEXEC, 0);
|
||||
sendto(fd, &msg, sizeof(msg.h)+4, 0, (void*)&rdns_server, sizeof(rdns_server));
|
||||
recvfrom(fd, &msg, sizeof msg, 0, (void*)0, (void*)0);
|
||||
close(fd);
|
||||
msg.h.datalen = ntohs(msg.h.datalen);
|
||||
if(!msg.h.datalen || msg.h.datalen > 256) return 0;
|
||||
memcpy(readbuf, msg.m.host, msg.h.datalen);
|
||||
return msg.h.datalen - 1;
|
||||
}
|
||||
|
||||
static ip_type4 rdns_daemon_get_ip_for_host(char* host, size_t len) {
|
||||
struct at_msg msg = {
|
||||
.h.msgtype = ATM_GETIP,
|
||||
};
|
||||
if(len >= 256) return IPT4_INT(-1);
|
||||
memcpy(msg.m.host, host, len+1);
|
||||
msg.h.datalen = htons(len+1);
|
||||
int fd = socket(AF_INET, SOCK_DGRAM|SOCK_CLOEXEC, 0);
|
||||
sendto(fd, &msg, sizeof(msg.h)+len+1, 0, (void*)&rdns_server, sizeof(rdns_server));
|
||||
recvfrom(fd, &msg, sizeof msg, 0, (void*)0, (void*)0);
|
||||
close(fd);
|
||||
if(ntohs(msg.h.datalen) != 4) return IPT4_INT(-1);
|
||||
return msg.m.ip;
|
||||
}
|
||||
|
||||
const char *rdns_resolver_string(enum dns_lookup_flavor flavor) {
|
||||
static const char tab[][7] = {
|
||||
[DNSLF_LIBC] = "off",
|
||||
[DNSLF_FORKEXEC] = "old",
|
||||
[DNSLF_RDNS_THREAD] = "thread",
|
||||
[DNSLF_RDNS_DAEMON] = "daemon",
|
||||
};
|
||||
return tab[flavor];
|
||||
}
|
||||
|
||||
void rdns_init(enum dns_lookup_flavor flavor) {
|
||||
static int init_done = 0;
|
||||
if(!init_done) switch(flavor) {
|
||||
case DNSLF_RDNS_THREAD:
|
||||
at_init();
|
||||
break;
|
||||
case DNSLF_RDNS_DAEMON:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
init_done = 1;
|
||||
}
|
||||
|
||||
void rdns_set_daemon(struct sockaddr_in* addr) {
|
||||
rdns_server = *addr;
|
||||
}
|
||||
|
||||
#if 0
|
||||
enum dns_lookup_flavor rdns_get_flavor(void) {
|
||||
return dns_flavor;
|
||||
}
|
||||
#endif
|
||||
|
||||
size_t rdns_get_host_for_ip(ip_type4 ip, char* readbuf) {
|
||||
switch(dns_flavor) {
|
||||
case DNSLF_RDNS_THREAD: return at_get_host_for_ip(ip, readbuf);
|
||||
case DNSLF_RDNS_DAEMON: return rdns_daemon_get_host_for_ip(ip, readbuf);
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
ip_type4 rdns_get_ip_for_host(char* host, size_t len) {
|
||||
switch(dns_flavor) {
|
||||
case DNSLF_RDNS_THREAD: return at_get_ip_for_host(host, len);
|
||||
case DNSLF_RDNS_DAEMON: return rdns_daemon_get_ip_for_host(host, len);
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
#ifndef RDNS_H
|
||||
#define RDNS_H
|
||||
|
||||
#include <unistd.h>
|
||||
#include <netinet/in.h>
|
||||
#include "ip_type.h"
|
||||
#include "remotedns.h"
|
||||
|
||||
enum dns_lookup_flavor {
|
||||
DNSLF_LIBC = 0,
|
||||
DNSLF_FORKEXEC,
|
||||
|
||||
DNSLF_RDNS_START,
|
||||
DNSLF_RDNS_THREAD = DNSLF_RDNS_START,
|
||||
DNSLF_RDNS_DAEMON,
|
||||
};
|
||||
|
||||
void rdns_init(enum dns_lookup_flavor flavor);
|
||||
void rdns_set_daemon(struct sockaddr_in* addr);
|
||||
const char *rdns_resolver_string(enum dns_lookup_flavor flavor);
|
||||
size_t rdns_get_host_for_ip(ip_type4 ip, char* readbuf);
|
||||
ip_type4 rdns_get_ip_for_host(char* host, size_t len);
|
||||
|
||||
//enum dns_lookup_flavor rdns_get_flavor(void);
|
||||
#define rdns_get_flavor() proxychains_resolver
|
||||
extern enum dns_lookup_flavor proxychains_resolver;
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,31 @@
|
||||
#ifndef REMOTEDNS_H
|
||||
#define REMOTEDNS_H
|
||||
|
||||
#include <unistd.h>
|
||||
#include "ip_type.h"
|
||||
|
||||
#define MSG_LEN_MAX 256
|
||||
|
||||
enum at_msgtype {
|
||||
ATM_GETIP = 0,
|
||||
ATM_GETNAME,
|
||||
ATM_FAIL,
|
||||
ATM_EXIT,
|
||||
};
|
||||
|
||||
struct at_msghdr {
|
||||
unsigned char msgtype; /* at_msgtype */
|
||||
char reserved;
|
||||
unsigned short datalen;
|
||||
};
|
||||
|
||||
struct at_msg {
|
||||
struct at_msghdr h;
|
||||
union {
|
||||
char host[260];
|
||||
ip_type4 ip;
|
||||
} m;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
#include "version.h"
|
||||
static const char version[] = VERSION;
|
||||
const char *proxychains_get_version(void) {
|
||||
return version;
|
||||
}
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
timestamp
|
||||
@@ -0,0 +1,86 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <netdb.h>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/socket.h>
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifndef NI_MAXHOST
|
||||
#define NI_MAXHOST 1025
|
||||
#endif
|
||||
|
||||
static int doit(const char* host, const char* service) {
|
||||
struct addrinfo *result;
|
||||
struct addrinfo *res;
|
||||
int error;
|
||||
|
||||
/* resolve the domain name into a list of addresses */
|
||||
error = getaddrinfo(host, service, 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;
|
||||
}
|
||||
int port = 0;
|
||||
if(res->ai_family == AF_INET) port = ((struct sockaddr_in*)res->ai_addr)->sin_port;
|
||||
else if(res->ai_family == AF_INET6) port = ((struct sockaddr_in6*)res->ai_addr)->sin6_port;
|
||||
port = ntohs(port);
|
||||
printf("hostname: %s, port: %d\n", hostname, port);
|
||||
}
|
||||
|
||||
freeaddrinfo(result);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
/* reproduce use of getaddrinfo as used by nmap 7.91's canonicalize_address */
|
||||
int canonicalize_address(struct sockaddr_storage *ss, struct sockaddr_storage *output) {
|
||||
char canonical_ip_string[NI_MAXHOST];
|
||||
struct addrinfo *ai;
|
||||
int rc;
|
||||
/* Convert address to string. */
|
||||
rc = getnameinfo((struct sockaddr *) ss, sizeof(*ss),
|
||||
canonical_ip_string, sizeof(canonical_ip_string), NULL, 0, NI_NUMERICHOST);
|
||||
assert(rc == 0);
|
||||
struct addrinfo hints = {
|
||||
.ai_family = ss->ss_family,
|
||||
.ai_socktype = SOCK_DGRAM,
|
||||
.ai_flags = AI_NUMERICHOST,
|
||||
};
|
||||
rc = getaddrinfo(canonical_ip_string, NULL, &hints, &ai);
|
||||
if (rc != 0 || ai == NULL)
|
||||
return -1;
|
||||
assert(ai->ai_addrlen > 0 && ai->ai_addrlen <= (int) sizeof(*output));
|
||||
memcpy(output, ai->ai_addr, ai->ai_addrlen);
|
||||
freeaddrinfo(ai);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
int ret;
|
||||
ret = doit("www.example.com", NULL);
|
||||
ret = doit("www.example.com", "80");
|
||||
struct sockaddr_storage o, ss = {.ss_family = PF_INET};
|
||||
struct sockaddr_in *v4 = &ss;
|
||||
struct sockaddr_in6 *v6 = &ss;
|
||||
memcpy(&v4->sin_addr, "\x7f\0\0\1", 4);
|
||||
ret = canonicalize_address(&ss, &o);
|
||||
assert (ret == 0);
|
||||
ss.ss_family = PF_INET6;
|
||||
memcpy(&v6->sin6_addr, "\0\0\0\0" "\0\0\0\0" "\0\0\0\0""\0\0\0\1", 16);
|
||||
ret = canonicalize_address(&ss, &o);
|
||||
assert (ret == 0);
|
||||
return ret;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
#include <stdio.h>
|
||||
#include <netdb.h>
|
||||
#include "../src/common.c"
|
||||
|
||||
void printhostent(struct hostent *hp) {
|
||||
char ipbuf[16];
|
||||
pc_stringfromipv4(hp->h_addr_list[0], ipbuf);
|
||||
printf("alias: %p, len: %d, name: %s, addrlist: %p, addrtype: %d, ip: %s\n",
|
||||
hp->h_aliases,
|
||||
hp->h_length,
|
||||
hp->h_name,
|
||||
hp->h_addr_list,
|
||||
hp->h_addrtype,
|
||||
ipbuf
|
||||
);
|
||||
}
|
||||
int main(int argc, char**argv) {
|
||||
struct hostent* ret;
|
||||
if(argc == 1) return 1;
|
||||
ret = gethostbyname(argv[1]);
|
||||
if(ret) printhostent(ret);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
#include <netdb.h>
|
||||
#include <stdio.h>
|
||||
#include "../src/common.c"
|
||||
|
||||
void printhostent(struct hostent *hp) {
|
||||
char ipbuf[16];
|
||||
pc_stringfromipv4(hp->h_addr_list[0], ipbuf);
|
||||
printf("alias: %p, len: %d, name: %s, addrlist: %p, addrtype: %d, ip: %s\n",
|
||||
hp->h_aliases,
|
||||
hp->h_length,
|
||||
hp->h_name,
|
||||
hp->h_addr_list,
|
||||
hp->h_addrtype,
|
||||
ipbuf
|
||||
);
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
struct hostent *hp;
|
||||
while((hp = gethostent())) {
|
||||
printhostent(hp);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
#include <netdb.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include "../src/common.h"
|
||||
|
||||
/*
|
||||
int gethostent_r(
|
||||
struct hostent *ret, char *buf, size_t buflen,
|
||||
struct hostent **result, int *h_errnop);
|
||||
|
||||
Glibc2 also has reentrant versions gethostent_r(), gethostbyaddr_r(),
|
||||
gethostbyname_r() and gethostbyname2_r().
|
||||
|
||||
The caller supplies a hostent structure ret which will be filled in on success,
|
||||
and a temporary work buffer buf of size buflen.
|
||||
After the call, result will point to the result on success.
|
||||
In case of an error or if no entry is found result will be NULL.
|
||||
The functions return 0 on success and a nonzero error number on failure.
|
||||
In addition to the errors returned by the nonreentrant versions of these functions,
|
||||
if buf is too small, the functions will return ERANGE, and the call should be retried
|
||||
with a larger buffer.
|
||||
The global variable h_errno is not modified, but the address of a variable in which
|
||||
to store error numbers is passed in h_errnop.
|
||||
*/
|
||||
|
||||
void printhostent(struct hostent *hp) {
|
||||
char ipbuf[16];
|
||||
pc_stringfromipv4(hp->h_addr_list[0], ipbuf);
|
||||
printf("alias: %p, len: %d, name: %s, addrlist: %p, addrtype: %d, ip: %s\n",
|
||||
hp->h_aliases,
|
||||
hp->h_length,
|
||||
hp->h_name,
|
||||
hp->h_addr_list,
|
||||
hp->h_addrtype,
|
||||
ipbuf
|
||||
);
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
struct hostent he_buf;
|
||||
struct hostent *he_res;
|
||||
char h_buf[1024];
|
||||
int ch_errno;
|
||||
int ret;
|
||||
do {
|
||||
ret = gethostent_r(&he_buf, h_buf, sizeof(h_buf), &he_res, &ch_errno);
|
||||
printf("ret: %d, h_errno: %d\n", ret, ch_errno);
|
||||
if(ret != 0) {
|
||||
errno = ret;
|
||||
ret = -1;
|
||||
}
|
||||
if(ret == -1) {
|
||||
perror("gethostent_r");
|
||||
break;
|
||||
}
|
||||
if(he_res) {
|
||||
printhostent(he_res);
|
||||
}
|
||||
} while (he_res);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
#include <netdb.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
#define satosin(x) ((struct sockaddr_in *) &(x))
|
||||
#define SOCKADDR(x) (satosin(x)->sin_addr.s_addr)
|
||||
#define SOCKADDR_2(x) (satosin(x)->sin_addr)
|
||||
#define SOCKPORT(x) (satosin(x)->sin_port)
|
||||
#define SOCKFAMILY(x) (satosin(x)->sin_family)
|
||||
|
||||
#define ASSERT(X) { if(!(X)) printf("ASSERTION FAILED: %s @%s:%d\n", # X, __FILE__, __LINE__); }
|
||||
#define CLR() { hbuf[0] = 0; sbuf[0] = 0; }
|
||||
|
||||
int main() {
|
||||
struct sockaddr_in a = {0}, *sa = &a;
|
||||
char hbuf[NI_MAXHOST], sbuf[NI_MAXSERV];
|
||||
a.sin_port = htons(80);
|
||||
memcpy( &a.sin_addr , (char[]) {127,0,0,1}, 4);
|
||||
|
||||
int ret;
|
||||
|
||||
if ((ret = getnameinfo((void*)sa, 0, hbuf, sizeof(hbuf), sbuf,
|
||||
sizeof(sbuf), NI_NUMERICHOST | NI_NUMERICSERV)) == 0)
|
||||
printf("host=%s, serv=%s\n", hbuf, sbuf);
|
||||
else
|
||||
printf("%s\n", gai_strerror(ret));
|
||||
|
||||
ASSERT(ret == EAI_FAMILY);
|
||||
CLR();
|
||||
|
||||
if ((ret = getnameinfo((void*)sa, sizeof a, hbuf, sizeof(hbuf), sbuf,
|
||||
sizeof(sbuf), NI_NUMERICHOST | NI_NUMERICSERV)) == 0)
|
||||
printf("host=%s, serv=%s\n", hbuf, sbuf);
|
||||
else
|
||||
printf("%s\n", gai_strerror(ret));
|
||||
|
||||
ASSERT(ret == EAI_FAMILY);
|
||||
CLR();
|
||||
|
||||
SOCKFAMILY(a) = AF_INET;
|
||||
|
||||
if ((ret = getnameinfo((void*)sa, sizeof a, hbuf, 1, sbuf,
|
||||
sizeof(sbuf), NI_NUMERICHOST | NI_NUMERICSERV)) == 0)
|
||||
printf("host=%s, serv=%s\n", hbuf, sbuf);
|
||||
else
|
||||
printf("%s\n", gai_strerror(ret));
|
||||
|
||||
ASSERT(ret == EAI_OVERFLOW);
|
||||
CLR();
|
||||
|
||||
if ((ret = getnameinfo((void*)sa, sizeof a, hbuf, 0, sbuf,
|
||||
1, NI_NUMERICHOST | NI_NUMERICSERV)) == 0)
|
||||
printf("host=%s, serv=%s\n", hbuf, sbuf);
|
||||
else
|
||||
printf("%s\n", gai_strerror(ret));
|
||||
|
||||
ASSERT(ret == EAI_OVERFLOW);
|
||||
CLR();
|
||||
|
||||
if ((ret = getnameinfo((void*)sa, sizeof(a) - 1, hbuf, 0, sbuf,
|
||||
sizeof(sbuf), NI_NUMERICHOST | NI_NUMERICSERV)) == 0)
|
||||
printf("host=%s, serv=%s\n", hbuf, sbuf);
|
||||
else
|
||||
printf("%s\n", gai_strerror(ret));
|
||||
|
||||
ASSERT(ret == EAI_FAMILY);
|
||||
CLR();
|
||||
|
||||
if ((ret = getnameinfo((void*)sa, sizeof a, hbuf, 0, sbuf,
|
||||
sizeof(sbuf), NI_NUMERICHOST | NI_NUMERICSERV)) == 0)
|
||||
printf("host=%s, serv=%s\n", hbuf, sbuf);
|
||||
else
|
||||
printf("%s\n", gai_strerror(ret));
|
||||
|
||||
ASSERT(ret == 0 && !strcmp("80", sbuf));
|
||||
CLR();
|
||||
|
||||
if ((ret = getnameinfo((void*)sa, sizeof a, hbuf, sizeof hbuf, sbuf,
|
||||
0, NI_NUMERICHOST | NI_NUMERICSERV)) == 0)
|
||||
printf("host=%s, serv=%s\n", hbuf, sbuf);
|
||||
else
|
||||
printf("%s\n", gai_strerror(ret));
|
||||
|
||||
ASSERT(ret == 0 && !strcmp("127.0.0.1",hbuf));
|
||||
CLR();
|
||||
|
||||
|
||||
if ((ret = getnameinfo((void*)sa, sizeof a, hbuf, sizeof(hbuf), sbuf,
|
||||
sizeof(sbuf), NI_NUMERICHOST | NI_NUMERICSERV)) == 0)
|
||||
printf("host=%s, serv=%s\n", hbuf, sbuf);
|
||||
else
|
||||
printf("%s\n", gai_strerror(ret));
|
||||
|
||||
ASSERT(ret == 0 && !strcmp("127.0.0.1",hbuf) && !strcmp("80", sbuf));
|
||||
CLR();
|
||||
|
||||
struct sockaddr_in6 b = {0}, *sb = &b;
|
||||
b.sin6_port = htons(8080);
|
||||
b.sin6_family = AF_INET6;
|
||||
|
||||
memcpy(&b.sin6_addr,"\0\0\0\0\0\0\0\0\0\0\xff\xff\xc0\xa8\1\2", 16);
|
||||
|
||||
if ((ret = getnameinfo((void*)sb, sizeof b, hbuf, sizeof(hbuf), sbuf,
|
||||
sizeof(sbuf), NI_NUMERICHOST | NI_NUMERICSERV)) == 0)
|
||||
printf("host=%s, serv=%s\n", hbuf, sbuf);
|
||||
else
|
||||
printf("%s\n", gai_strerror(ret));
|
||||
|
||||
ASSERT(ret == 0 && !strcmp("192.168.1.2",hbuf) && !strcmp("8080", sbuf));
|
||||
CLR();
|
||||
|
||||
b.sin6_scope_id = 3;
|
||||
memcpy(&b.sin6_addr,"\0\0\xaa\0\0\0\0\0\0\0\0\xff\xc0\xa8\1\2", 16);
|
||||
|
||||
if ((ret = getnameinfo((void*)sb, sizeof b, hbuf, sizeof(hbuf), sbuf,
|
||||
sizeof(sbuf), NI_NUMERICHOST | NI_NUMERICSERV | NI_NUMERICSCOPE)) == 0)
|
||||
printf("host=%s, serv=%s\n", hbuf, sbuf);
|
||||
else
|
||||
printf("%s\n", gai_strerror(ret));
|
||||
|
||||
ASSERT(ret == 0);
|
||||
|
||||
b.sin6_port = 0;
|
||||
b.sin6_scope_id = 0;
|
||||
memcpy(&b.sin6_addr,"\0\0\0\0" "\0\0\0\0" "\0\0\0\0" "\0\0\0\1", 16);
|
||||
|
||||
if ((ret = getnameinfo((void*)sb, sizeof b, hbuf, sizeof(hbuf), NULL,
|
||||
0, NI_NUMERICHOST)) == 0)
|
||||
printf("host=%s\n", hbuf);
|
||||
else
|
||||
printf("%s\n", gai_strerror(ret));
|
||||
|
||||
ASSERT(ret == 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
#include "../src/core.h"
|
||||
#include "../src/common.h"
|
||||
#include <stdio.h>
|
||||
|
||||
void printhostent(struct hostent *hp) {
|
||||
char ipbuf[16];
|
||||
pc_stringfromipv4(hp->h_addr_list[0], ipbuf);
|
||||
printf("alias: %p, len: %d, name: %s, addrlist: %p, addrtype: %d, ip: %s\n",
|
||||
hp->h_aliases,
|
||||
hp->h_length,
|
||||
hp->h_name,
|
||||
hp->h_addr_list,
|
||||
hp->h_addrtype,
|
||||
ipbuf
|
||||
);
|
||||
}
|
||||
int main(int argc, char**argv) {
|
||||
struct hostent* ret;
|
||||
struct gethostbyname_data data;
|
||||
if(argc == 1) return 1;
|
||||
ret = proxy_gethostbyname(argv[1], &data);
|
||||
if(ret) printhostent(ret);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netdb.h>
|
||||
|
||||
#ifndef MSG_FASTOPEN
|
||||
# define MSG_FASTOPEN 0x20000000
|
||||
#endif
|
||||
|
||||
void error(const char *msg)
|
||||
{
|
||||
perror(msg);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if (argc < 4) {
|
||||
printf("Usage: %s host port method(connect or sendto)\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
const char *hostname = argv[1];
|
||||
const int portno = atoi(argv[2]);
|
||||
const char *method = argv[3];
|
||||
char request[BUFSIZ];
|
||||
sprintf(request, "GET / HTTP/1.0\r\nHost: %s\r\n\r\n", hostname);
|
||||
int sockfd, n;
|
||||
struct sockaddr_in serv_addr;
|
||||
struct hostent *server;
|
||||
|
||||
char buffer[BUFSIZ];
|
||||
sockfd = socket(AF_INET, SOCK_STREAM, 0);
|
||||
if (sockfd < 0) error("ERROR opening socket");
|
||||
server = gethostbyname(hostname);
|
||||
if (server == NULL) {
|
||||
fprintf(stderr, "%s: no such host\n", hostname);
|
||||
return 1;
|
||||
}
|
||||
memset(&serv_addr, 0, sizeof(serv_addr));
|
||||
serv_addr.sin_family = AF_INET;
|
||||
memcpy(&serv_addr.sin_addr.s_addr, server->h_addr, server->h_length);
|
||||
serv_addr.sin_port = htons(portno);
|
||||
if (!strcmp(method, "connect")) {
|
||||
if (connect(sockfd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) < 0)
|
||||
error("connect");
|
||||
n = send(sockfd, request, strlen(request), 0);
|
||||
} else if (!strcmp(method, "sendto")) {
|
||||
n = sendto(sockfd, request, strlen(request), MSG_FASTOPEN, (struct sockaddr *)&serv_addr, sizeof(serv_addr));
|
||||
} else {
|
||||
printf("Unknown method %s\n", method);
|
||||
return 1;
|
||||
}
|
||||
if (n < 0)
|
||||
error("send");
|
||||
memset(buffer, 0, BUFSIZ);
|
||||
n = read(sockfd, buffer, BUFSIZ - 1);
|
||||
if (n < 0)
|
||||
error("ERROR reading from socket");
|
||||
printf("%s\n", buffer);
|
||||
close(sockfd);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
#include "../src/shm.h"
|
||||
#include <assert.h>
|
||||
|
||||
#define s(A) (sizeof(A) - 1)
|
||||
#define ss(A) (A), s(A)
|
||||
|
||||
int main() {
|
||||
char buf4096[4096];
|
||||
struct stringpool sp;
|
||||
stringpool_init(&sp);
|
||||
char *r;
|
||||
size_t pos = 0;
|
||||
r = stringpool_add(&sp, ss("AAAAA"));
|
||||
assert(r == sp.start);
|
||||
|
||||
pos += s("AAAAA");
|
||||
assert(sp.alloced == 4096);
|
||||
assert(sp.used == pos);
|
||||
|
||||
r = stringpool_add(&sp, buf4096, sizeof(buf4096));
|
||||
assert(r == sp.start + pos);
|
||||
|
||||
pos += sizeof(buf4096);
|
||||
assert(sp.alloced == 4096 * 2);
|
||||
assert(sp.used == pos);
|
||||
|
||||
r = stringpool_add(&sp, buf4096, 4096 - s("AAAAA"));
|
||||
assert(r == sp.start + pos);
|
||||
pos += 4096 - s("AAAAA");
|
||||
assert(pos == 4096 * 2);
|
||||
|
||||
assert(sp.alloced == 4096 * 2);
|
||||
assert(sp.used == pos);
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <netdb.h>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
static void v4_to_v6(const struct in_addr *v4, struct in6_addr *v6) {
|
||||
memset(v6, 0, sizeof(*v6));
|
||||
v6->s6_addr[10]=0xff;
|
||||
v6->s6_addr[11]=0xff;
|
||||
memcpy(&v6->s6_addr[12], &v4->s_addr, 4);
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
struct addrinfo *result;
|
||||
struct addrinfo *res;
|
||||
const struct addrinfo hints = { .ai_family = AF_INET };
|
||||
int error, sock;
|
||||
|
||||
/* resolve the domain name into a list of addresses */
|
||||
error = getaddrinfo("www.example.com", NULL, &hints, &result);
|
||||
if (error != 0) {
|
||||
fprintf(stderr, "error in getaddrinfo: %s\n", gai_strerror(error));
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if((sock=socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == -1) {
|
||||
perror("socket");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
struct sockaddr_in6 a = { .sin6_family = AF_INET6,
|
||||
.sin6_port = htons(80) };
|
||||
v4_to_v6(&((struct sockaddr_in *)result->ai_addr)->sin_addr, &a.sin6_addr);
|
||||
freeaddrinfo(result);
|
||||
|
||||
if((error = connect(sock, (struct sockaddr *)&a, sizeof(a))) == -1) {
|
||||
perror("connect");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
Executable
+64
@@ -0,0 +1,64 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# This is an actually-safe install command which installs the new
|
||||
# file atomically in the new location, rather than overwriting
|
||||
# existing files.
|
||||
#
|
||||
|
||||
usage() {
|
||||
printf "usage: %s [-D] [-l] [-m mode] src dest\n" "$0" 1>&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
mkdirp=
|
||||
symlink=
|
||||
mode=755
|
||||
|
||||
while getopts Dlm: name ; do
|
||||
case "$name" in
|
||||
D) mkdirp=yes ;;
|
||||
l) symlink=yes ;;
|
||||
m) mode=$OPTARG ;;
|
||||
?) usage ;;
|
||||
esac
|
||||
done
|
||||
shift $(($OPTIND - 1))
|
||||
|
||||
test "$#" -eq 2 || usage
|
||||
src=$1
|
||||
dst=$2
|
||||
tmp="$dst.tmp.$$"
|
||||
|
||||
case "$dst" in
|
||||
*/) printf "%s: %s ends in /\n", "$0" "$dst" 1>&2 ; exit 1 ;;
|
||||
esac
|
||||
|
||||
set -C
|
||||
set -e
|
||||
|
||||
if test "$mkdirp" ; then
|
||||
umask 022
|
||||
case "$2" in
|
||||
*/*) mkdir -p "${dst%/*}" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
trap 'rm -f "$tmp"' EXIT INT QUIT TERM HUP
|
||||
|
||||
umask 077
|
||||
|
||||
if test "$symlink" ; then
|
||||
ln -s "$1" "$tmp"
|
||||
else
|
||||
cat < "$1" > "$tmp"
|
||||
chmod "$mode" "$tmp"
|
||||
fi
|
||||
|
||||
mv -f "$tmp" "$2"
|
||||
test -d "$2" && {
|
||||
rm -f "$2/$tmp"
|
||||
printf "%s: %s is a directory\n" "$0" "$dst" 1>&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
exit 0
|
||||
@@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
|
||||
if test -d .git ; then
|
||||
if type git >/dev/null 2>&1 ; then
|
||||
git describe --tags --match 'v[0-9]*' 2>/dev/null \
|
||||
| sed -e 's/^v//' -e 's/-/-git-/'
|
||||
else
|
||||
sed 's/$/-git/' < VERSION
|
||||
fi
|
||||
else
|
||||
cat VERSION
|
||||
fi
|
||||
Reference in New Issue
Block a user