mirror of
https://github.com/haad/proxychains.git
synced 2026-09-14 11:05:48 +05:00
Compare commits
No commits in common. "master" and "proxychains-4.1.0" have entirely different histories.
master
...
proxychain
24
.github/ISSUE_TEMPLATE/bug_report.md
vendored
24
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@ -1,24 +0,0 @@
|
|||||||
---
|
|
||||||
name: Bug report
|
|
||||||
about: Create a report to help us improve
|
|
||||||
title: ''
|
|
||||||
labels: ''
|
|
||||||
assignees: ''
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**Describe the bug**
|
|
||||||
A clear and concise description of what the bug is.
|
|
||||||
|
|
||||||
**To Reproduce**
|
|
||||||
Steps to reproduce the behavior:
|
|
||||||
1. Run command
|
|
||||||
|
|
||||||
**Expected behavior**
|
|
||||||
A clear and concise description of what you expected to happen.
|
|
||||||
|
|
||||||
**Screenshots**
|
|
||||||
If applicable, add screenshots to help explain your problem.
|
|
||||||
|
|
||||||
**Additional context**
|
|
||||||
Add any other context about the problem here.
|
|
||||||
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
@ -1,20 +0,0 @@
|
|||||||
---
|
|
||||||
name: Feature request
|
|
||||||
about: Suggest an idea for this project
|
|
||||||
title: ''
|
|
||||||
labels: ''
|
|
||||||
assignees: ''
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**Is your feature request related to a problem? Please describe.**
|
|
||||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
|
||||||
|
|
||||||
**Describe the solution you'd like**
|
|
||||||
A clear and concise description of what you want to happen.
|
|
||||||
|
|
||||||
**Describe alternatives you've considered**
|
|
||||||
A clear and concise description of any alternative solutions or features you've considered.
|
|
||||||
|
|
||||||
**Additional context**
|
|
||||||
Add any other context or screenshots about the feature request here.
|
|
||||||
55
.github/workflows/buildci.yml
vendored
55
.github/workflows/buildci.yml
vendored
@ -1,55 +0,0 @@
|
|||||||
name: Makefile CI
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [ "master" ]
|
|
||||||
pull_request:
|
|
||||||
branches: [ "master" ]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build-linux-ubuntu:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
|
|
||||||
- name: configure
|
|
||||||
run: ./configure
|
|
||||||
|
|
||||||
- name: Build Proxychains
|
|
||||||
run: make
|
|
||||||
|
|
||||||
- name: Run Proxychains
|
|
||||||
run: ./proxychains4 -v
|
|
||||||
|
|
||||||
- name: Run tests
|
|
||||||
run: ./src/proxychains -f dist/proxychains.conf on
|
|
||||||
|
|
||||||
# - name: Run tests
|
|
||||||
# run: ./src/proxychains -f dist/proxychains.conf curl -o /dev/null -v https://sme.sk
|
|
||||||
|
|
||||||
# - name: Run tests
|
|
||||||
# run: ./src/proxychains -f dist/proxychains.conf ping -c 1 sme.sk
|
|
||||||
build-macos:
|
|
||||||
runs-on: macos-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
|
|
||||||
- name: configure
|
|
||||||
run: ./configure
|
|
||||||
|
|
||||||
- name: Build Proxychains
|
|
||||||
run: make
|
|
||||||
|
|
||||||
- name: Run Proxychains
|
|
||||||
run: ./proxychains4 -v
|
|
||||||
|
|
||||||
- name: Run tests
|
|
||||||
run: ./src/proxychains -f dist/proxychains.conf on
|
|
||||||
|
|
||||||
# - name: Run tests
|
|
||||||
# run: ./src/proxychains -f dist/proxychains.conf curl -o /dev/null -v https://sme.sk
|
|
||||||
|
|
||||||
# - name: Run tests
|
|
||||||
# run: ./src/proxychains -f dist/proxychains.conf ping -t 1 sme.sk
|
|
||||||
|
|
||||||
|
|
||||||
31
.github/workflows/stale.yml
vendored
31
.github/workflows/stale.yml
vendored
@ -1,31 +0,0 @@
|
|||||||
# This workflow warns and then closes issues and PRs that have had no activity for a specified amount of time.
|
|
||||||
#
|
|
||||||
# You can adjust the behavior by modifying this file.
|
|
||||||
# For more information, see:
|
|
||||||
# https://github.com/actions/stale
|
|
||||||
name: Mark stale issues and pull requests
|
|
||||||
|
|
||||||
on:
|
|
||||||
schedule:
|
|
||||||
- cron: '24 3 * * *'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
stale:
|
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
permissions:
|
|
||||||
issues: write
|
|
||||||
pull-requests: write
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/stale@v5
|
|
||||||
with:
|
|
||||||
days-before-stale: 90
|
|
||||||
days-before-close: 120
|
|
||||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
stale-issue-message: 'Stale issue message'
|
|
||||||
stale-pr-message: 'Stale pull request message'
|
|
||||||
stale-issue-label: 'no-issue-activity'
|
|
||||||
exempt-issue-labels: 'docu,roadmap,bug,possible-feature'
|
|
||||||
stale-pr-label: 'no-pr-activity'
|
|
||||||
exempt-pr-labels: 'feature'
|
|
||||||
29
.github/workflows/super-linter.yml
vendored
29
.github/workflows/super-linter.yml
vendored
@ -1,29 +0,0 @@
|
|||||||
# This workflow executes several linters on changed files based on languages used in your code base whenever
|
|
||||||
# you push a code or open a pull request.
|
|
||||||
#
|
|
||||||
# You can adjust the behavior by modifying this file.
|
|
||||||
# For more information, see:
|
|
||||||
# https://github.com/github/super-linter
|
|
||||||
name: Lint Code Base
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [ "master" ]
|
|
||||||
pull_request:
|
|
||||||
branches: [ "master" ]
|
|
||||||
jobs:
|
|
||||||
run-lint:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
with:
|
|
||||||
# Full git history is needed to get a proper list of changed files within `super-linter`
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Lint Code Base
|
|
||||||
uses: github/super-linter@v4
|
|
||||||
env:
|
|
||||||
VALIDATE_ALL_CODEBASE: false
|
|
||||||
DEFAULT_BRANCH: "master"
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
3
.gitignore
vendored
3
.gitignore
vendored
@ -4,8 +4,7 @@
|
|||||||
*.lo
|
*.lo
|
||||||
.deps/
|
.deps/
|
||||||
.libs/
|
.libs/
|
||||||
.*
|
|
||||||
src/*.d
|
|
||||||
# Autoconf stuff
|
# Autoconf stuff
|
||||||
libtool
|
libtool
|
||||||
config.*
|
config.*
|
||||||
|
|||||||
4
AUTHORS
4
AUTHORS
@ -7,8 +7,8 @@ main.c, remote-dns, thread safety, bugfixes, build system, cleanups
|
|||||||
rofl0r.
|
rofl0r.
|
||||||
https://github.com/rofl0r/proxychains
|
https://github.com/rofl0r/proxychains
|
||||||
|
|
||||||
localnet, bugfixes, macos x support, bsd support, packaging
|
localnet, bugfixes
|
||||||
haad.
|
adam hamsik.
|
||||||
https://github.com/haad/proxychains
|
https://github.com/haad/proxychains
|
||||||
|
|
||||||
localnet-port, bugfixes
|
localnet-port, bugfixes
|
||||||
|
|||||||
21
ChangeLog
21
ChangeLog
@ -1,27 +1,6 @@
|
|||||||
ProxyChains version history (public releases)
|
ProxyChains version history (public releases)
|
||||||
====================
|
====================
|
||||||
|
|
||||||
ver 4.2
|
|
||||||
* Introduce BSD support make proxychains available on (NetBSD, FreeBSD ,OpenBSD and DragonFlyBSD)
|
|
||||||
* Update pkgsrc-wip proxychains package to 4.2.0 release and make easy to install and use
|
|
||||||
proxychains
|
|
||||||
-------------------------------------------------------------------------
|
|
||||||
|
|
||||||
ver 4.1
|
|
||||||
* Mac OS X support, create install script.
|
|
||||||
* thread-safe fixes by @rofl0r
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------
|
|
||||||
|
|
||||||
ver 4.0
|
|
||||||
|
|
||||||
changed:
|
|
||||||
* Add a lot of fixes
|
|
||||||
* localnet-patch
|
|
||||||
* remote-dns
|
|
||||||
* thread-safe
|
|
||||||
-------------------------------------------------------------------------
|
|
||||||
|
|
||||||
ver 3.1
|
ver 3.1
|
||||||
|
|
||||||
changed:
|
changed:
|
||||||
|
|||||||
44
Makefile
44
Makefile
@ -9,73 +9,55 @@ prefix = /usr/local
|
|||||||
includedir = $(prefix)/include
|
includedir = $(prefix)/include
|
||||||
libdir = $(prefix)/lib
|
libdir = $(prefix)/lib
|
||||||
confdir = $(prefix)/etc
|
confdir = $(prefix)/etc
|
||||||
datadir = $(prefix)/share
|
|
||||||
|
|
||||||
exec_prefix = $(prefix)
|
exec_prefix = $(prefix)
|
||||||
bindir = $(exec_prefix)/bin
|
bindir = $(exec_prefix)/bin
|
||||||
zshcompdir = $(datadir)/zsh/site-functions
|
|
||||||
|
|
||||||
SRCS = $(sort $(wildcard src/*.c))
|
SRCS = $(sort $(wildcard src/*.c))
|
||||||
OBJS = $(SRCS:.c=.o)
|
OBJS = $(SRCS:.c=.o)
|
||||||
LOBJS = src/core.o src/common.o src/libproxychains.o
|
LOBJS = src/core.o src/common.o src/libproxychains.o
|
||||||
DEPS = $(OBJS:.o=.d)
|
|
||||||
|
|
||||||
CCFLAGS = -MD -Wall -O2 -g -std=c99 -D_GNU_SOURCE -pipe -DTHREAD_SAFE -Werror
|
CCFLAGS = -Wall -O0 -g -std=c99 -D_GNU_SOURCE -pipe -DTHREAD_SAFE -Werror
|
||||||
LDFLAGS = -shared -fPIC
|
LDFLAGS = -shared -fPIC -ldl -lpthread
|
||||||
INC =
|
INC =
|
||||||
PIC = -fPIC
|
PIC = -fPIC
|
||||||
AR = $(CROSS_COMPILE)ar
|
AR = $(CROSS_COMPILE)ar
|
||||||
RANLIB = $(CROSS_COMPILE)ranlib
|
RANLIB = $(CROSS_COMPILE)ranlib
|
||||||
|
|
||||||
LD_SET_SONAME = -Wl
|
LDSO_SUFFIX = so
|
||||||
|
LD_SET_SONAME = -Wl,-soname=
|
||||||
INSTALL_FLAGS = -D -m
|
INSTALL_FLAGS = -D -m
|
||||||
|
|
||||||
-include config.mak
|
-include config.mak
|
||||||
|
|
||||||
|
LDSO_PATHNAME = libproxychains4.$(LDSO_SUFFIX)
|
||||||
|
|
||||||
SHARED_LIBS = $(LDSO_PATHNAME)
|
SHARED_LIBS = $(LDSO_PATHNAME)
|
||||||
ALL_LIBS = $(SHARED_LIBS)
|
ALL_LIBS = $(SHARED_LIBS)
|
||||||
PXCHAINS = proxychains4
|
PXCHAINS = proxychains4
|
||||||
ALL_TOOLS = $(PXCHAINS)
|
ALL_TOOLS = $(PXCHAINS)
|
||||||
|
|
||||||
CCFLAGS+=$(USER_CFLAGS) $(OS_CFLAGS)
|
CCFLAGS+=$(USER_CFLAGS) $(MAC_CFLAGS)
|
||||||
LDFLAGS+=$(USER_LDFLAGS) $(OS_LDFLAGS)
|
LDFLAGS+=$(USER_LDFLAGS) $(MAC_LDFLAGS)
|
||||||
CXXFLAGS+=$(CCFLAGS) $(USER_CFLAGS) $(OS_CFLAGS)
|
CXXFLAGS+=$(CCFLAGS) $(USER_CFLAGS) $(MAC_CFLAGS)
|
||||||
CFLAGS_MAIN=-DLIB_DIR=\"$(libdir)\" -DINSTALL_PREFIX=\"$(prefix)\" -DDLL_NAME=\"$(LDSO_PATHNAME)\" -DSYSCONFDIR=\"$(confdir)\"
|
CFLAGS_MAIN=-DLIB_DIR=\"$(libdir)\" -DINSTALL_PREFIX=\"$(prefix)\" -DDLL_NAME=\"$(LDSO_PATHNAME)\" -DSYSCONFDIR=\"$(confdir)\"
|
||||||
|
|
||||||
UNAME_S := $(shell uname -s)
|
|
||||||
ifeq ($(UNAME_S),Linux)
|
|
||||||
LDSO_PATHNAME = libproxychains.$(LDSO_SUFFIX)
|
|
||||||
LDSO_SUFFIX = so.4
|
|
||||||
endif
|
|
||||||
ifeq ($(UNAME_S),Darwin)
|
|
||||||
LDSO_PATHNAME = libproxychains4.$(LDSO_SUFFIX)
|
|
||||||
LDSO_SUFFIX = dylib
|
|
||||||
endif
|
|
||||||
|
|
||||||
|
|
||||||
all: $(ALL_LIBS) $(ALL_TOOLS)
|
all: $(ALL_LIBS) $(ALL_TOOLS)
|
||||||
|
|
||||||
#install: $(ALL_LIBS:lib/%=$(DESTDIR)$(libdir)/%) $(DESTDIR)$(LDSO_PATHNAME)
|
#install: $(ALL_LIBS:lib/%=$(DESTDIR)$(libdir)/%) $(DESTDIR)$(LDSO_PATHNAME)
|
||||||
install: install-exec install-config install-zsh-completion
|
install:
|
||||||
|
|
||||||
install-exec:
|
|
||||||
install -d $(DESTDIR)/$(bindir) $(DESTDIR)/$(libdir) $(DESTDIR)/$(confdir) $(DESTDIR)/$(includedir)
|
install -d $(DESTDIR)/$(bindir) $(DESTDIR)/$(libdir) $(DESTDIR)/$(confdir) $(DESTDIR)/$(includedir)
|
||||||
install $(INSTALL_FLAGS) 755 $(ALL_TOOLS) src/proxychains src/proxyresolv $(DESTDIR)/$(bindir)/
|
install $(INSTALL_FLAGS) 755 $(ALL_TOOLS) $(DESTDIR)/$(bindir)/
|
||||||
install $(INSTALL_FLAGS) 644 $(ALL_LIBS) $(DESTDIR)/$(libdir)/
|
install $(INSTALL_FLAGS) 644 $(ALL_LIBS) $(DESTDIR)/$(libdir)/
|
||||||
|
|
||||||
install-config:
|
install-config:
|
||||||
install -d $(DESTDIR)/$(confdir)
|
install -d $(DESTDIR)/$(confdir)
|
||||||
install $(INSTALL_FLAGS) 644 src/proxychains.conf $(DESTDIR)/$(confdir)/
|
install $(INSTALL_FLAGS) 644 src/proxychains.conf $(DESTDIR)/$(confdir)/
|
||||||
|
|
||||||
install-zsh-completion:
|
|
||||||
install -d $(DESTDIR)/$(zshcompdir)
|
|
||||||
install $(INSTALL_FLAGS) 644 completions/zsh/_proxychains4 -t $(DESTDIR)/$(zshcompdir)
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f $(ALL_LIBS)
|
rm -f $(ALL_LIBS)
|
||||||
rm -f $(ALL_TOOLS)
|
rm -f $(ALL_TOOLS)
|
||||||
rm -f $(OBJS)
|
rm -f $(OBJS)
|
||||||
rm -f $(DEPS)
|
|
||||||
|
|
||||||
%.o: %.c
|
%.o: %.c
|
||||||
$(CC) $(CCFLAGS) $(CFLAGS_MAIN) $(INC) $(PIC) -c -o $@ $<
|
$(CC) $(CCFLAGS) $(CFLAGS_MAIN) $(INC) $(PIC) -c -o $@ $<
|
||||||
@ -86,6 +68,4 @@ $(LDSO_PATHNAME): $(LOBJS)
|
|||||||
$(ALL_TOOLS): $(OBJS)
|
$(ALL_TOOLS): $(OBJS)
|
||||||
$(CC) src/main.o src/common.o -o $(PXCHAINS)
|
$(CC) src/main.o src/common.o -o $(PXCHAINS)
|
||||||
|
|
||||||
.PHONY: all clean install install-exec install-config install-zsh-completion
|
.PHONY: all clean install install-config
|
||||||
|
|
||||||
-include $(DEPS)
|
|
||||||
115
README
Normal file
115
README
Normal file
@ -0,0 +1,115 @@
|
|||||||
|
ProxyChains ver 4.0 README
|
||||||
|
==========================
|
||||||
|
|
||||||
|
ProxyChains is a UNIX program, that hooks network-related libc functions
|
||||||
|
in dynamically linked programs via a preloaded DLL and redirects the
|
||||||
|
connections through SOCKS4a/5 or HTTP proxies.
|
||||||
|
|
||||||
|
*********** ATTENTION ***********
|
||||||
|
|
||||||
|
this program works only on dynamically linked programs.
|
||||||
|
also both proxychains and the program to call must use
|
||||||
|
the same dynamic linker (i.e. same libc)
|
||||||
|
|
||||||
|
*********************************
|
||||||
|
|
||||||
|
*** Known limitations of the current version: ***
|
||||||
|
|
||||||
|
when a process forks, does a DNS lookup in the child, and then uses
|
||||||
|
the ip in the parent, the corresponding ip mapping will not be found.
|
||||||
|
this is because the fork can't write back into the parents mapping table.
|
||||||
|
IRSSI shows this behaviour, so you have to pass the resolved ip address
|
||||||
|
to it. (you can use the proxyresolv script (requires "dig") to do so)
|
||||||
|
|
||||||
|
this means that you can't currently use tor onion urls for irssi.
|
||||||
|
to solve this issue, an external data store (file, pipe, ...) has to
|
||||||
|
manage the dns <-> ip mapping. of course there has to be proper locking.
|
||||||
|
shm_open, mkstemp, are possible candidates for a file based approach,
|
||||||
|
the other option is to spawn some kind of server process that manages the
|
||||||
|
map lookups. since connect() etc are hooked, this must not be a TCP server.
|
||||||
|
|
||||||
|
I am reluctant on doing this change, because the described behaviour
|
||||||
|
seems pretty idiotic (doing a fork only for a DNS lookup), and irssi
|
||||||
|
is currently the only known affected program.
|
||||||
|
|
||||||
|
*** Installation ***
|
||||||
|
|
||||||
|
# needs a working C compiler, preferably gcc
|
||||||
|
./configure
|
||||||
|
make
|
||||||
|
sudo make install
|
||||||
|
|
||||||
|
Changelog:
|
||||||
|
----------
|
||||||
|
|
||||||
|
Version (4.x) removes the dnsresolver script which required a dynamically
|
||||||
|
linked "dig" binary to be present with remote DNS lookup.
|
||||||
|
this speeds up any operation involving DNS, as the old script had to use TCP.
|
||||||
|
additionally it allows to use .onion urls when used with TOR.
|
||||||
|
also it removed the broken autoconf build system with a simple Makefile.
|
||||||
|
there's a ./configure script though for convenience.
|
||||||
|
it also adds support for a config file passed via command line switches/
|
||||||
|
environment variables.
|
||||||
|
|
||||||
|
Version (3.x) introduces support for DNS resolving through proxy
|
||||||
|
it supports SOCKS4, SOCKS5 and HTTP CONNECT proxy servers.
|
||||||
|
Auth-types: socks - "user/pass" , http - "basic".
|
||||||
|
|
||||||
|
When to use it ?
|
||||||
|
1) When the only way to get "outside" from your LAN is through proxy server.
|
||||||
|
2) To get out from behind restrictive firewall which filters outgoing ports.
|
||||||
|
3) To use two (or more) proxies in chain:
|
||||||
|
like: your_host <--> proxy1 <--> proxy2 <--> target_host
|
||||||
|
4) To "proxify" some program with no proxy support built-in (like telnet)
|
||||||
|
5) Access intranet from outside via proxy.
|
||||||
|
5) To use DNS behind proxy.
|
||||||
|
|
||||||
|
Some cool features:
|
||||||
|
|
||||||
|
* This program can mix different proxy types in the same chain
|
||||||
|
like: your_host <-->socks5 <--> http <--> socks4 <--> target_host
|
||||||
|
* Different chaining options supported
|
||||||
|
random order from the list ( user defined length of chain ).
|
||||||
|
exact order (as they appear in the list )
|
||||||
|
dynamic order (smart exclude dead proxies from chain)
|
||||||
|
* You can use it with any TCP client application, even network scanners
|
||||||
|
yes, yes - you can make portscan via proxy (or chained proxies)
|
||||||
|
for example with Nmap scanner by fyodor (www.insecire.org/nmap).
|
||||||
|
proxychains nmap -sT -PO -p 80 -iR (find some webservers through proxy)
|
||||||
|
* You can use it with servers, like squid, sendmail, or whatever.
|
||||||
|
* DNS resolving through proxy.
|
||||||
|
|
||||||
|
|
||||||
|
Configuration:
|
||||||
|
--------------
|
||||||
|
|
||||||
|
proxychains looks for config file in following order:
|
||||||
|
1) file listed in environment variable ${PROXYCHAINS_CONF_FILE} or
|
||||||
|
provided as a -f argument to proxychains script or binary.
|
||||||
|
2) ./proxychains.conf
|
||||||
|
3) $(HOME)/.proxychains/proxychains.conf
|
||||||
|
4) /etc/proxychains.conf **
|
||||||
|
|
||||||
|
**see more in /etc/proxychains.conf
|
||||||
|
|
||||||
|
Usage Example:
|
||||||
|
|
||||||
|
$ proxychains telnet targethost.com
|
||||||
|
|
||||||
|
in this example it will run telnet through proxy(or chained proxies)
|
||||||
|
specified by proxychains.conf
|
||||||
|
|
||||||
|
Usage Example:
|
||||||
|
|
||||||
|
$ proxychains -f /etc/proxychains-other.conf targethost2.com
|
||||||
|
|
||||||
|
in this example it will use different configuration file then proxychains.conf
|
||||||
|
to connect to targethost2.com host.
|
||||||
|
|
||||||
|
Usage Example:
|
||||||
|
|
||||||
|
$ proxyresolv targethost.com
|
||||||
|
|
||||||
|
in this example it will resolve targethost.com through proxy(or chained proxies)
|
||||||
|
specified by proxychains.conf
|
||||||
|
|
||||||
179
README.md
179
README.md
@ -1,179 +0,0 @@
|
|||||||
# ProxyChains ver. 4.3.0 README
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
|
|
||||||
ProxyChains is a UNIX program, that hooks network-related libc functions
|
|
||||||
in dynamically linked programs via a preloaded DLL and redirects the
|
|
||||||
connections through SOCKS4a/5 or HTTP proxies.
|
|
||||||
|
|
||||||
WARNING: this program works only on dynamically linked programs.
|
|
||||||
also both proxychains and the program to call must use
|
|
||||||
the same dynamic linker (i.e. same libc)
|
|
||||||
|
|
||||||
## Known limitations of the current version
|
|
||||||
|
|
||||||
when a process forks, does a DNS lookup in the child, and then uses
|
|
||||||
the ip in the parent, the corresponding ip mapping will not be found,
|
|
||||||
this is because the fork can't write back into the parents mapping table.
|
|
||||||
IRSSI shows this behavior, so you have to pass the resolved ip address
|
|
||||||
to it. (you can use the proxyresolv script (requires "dig") to do so)
|
|
||||||
|
|
||||||
this means that you can't currently use tor onion urls for irssi.
|
|
||||||
to solve this issue, an external data store (file, pipe, ...) has to
|
|
||||||
manage the dns <-> ip mapping. of course there has to be proper locking.
|
|
||||||
shm_open, mkstemp, are possible candidates for a file based approach,
|
|
||||||
the other option is to spawn some kind of server process that manages the
|
|
||||||
map lookups. since connect() etc are hooked, this must not be a TCP server.
|
|
||||||
|
|
||||||
I am reluctant on doing this change, because the described behavior
|
|
||||||
seems pretty idiotic (doing a fork only for a DNS lookup), and irssi
|
|
||||||
is currently the only known affected program.
|
|
||||||
|
|
||||||
## Installation
|
|
||||||
|
|
||||||
### Using release version
|
|
||||||
|
|
||||||
*Proxychains-4.3.0* are available with pkgsrc to everyone using it on _Linux_,
|
|
||||||
_NetBSD_, _FreeBSD_, _OpenBSD_, _DragonFlyBSD_ or _Mac OS X_. You just need to install
|
|
||||||
pkgsrc-wip repository and run
|
|
||||||
make install
|
|
||||||
in a wip/proxychains directory.
|
|
||||||
|
|
||||||
You can find out more about pkgsrc on link:http://www.pkgsrc.org[pkgsrc] and about pkgsrc-wip on
|
|
||||||
link:https://pkgsrc.org/wip[Pkgsrc-wip homepage]
|
|
||||||
|
|
||||||
### Installing on Mac OS X with homebrew
|
|
||||||
|
|
||||||
You can install current proxychains on Mac OS X with an homebrew. You have to
|
|
||||||
download unofficial link:https://gist.github.com/3792521[homebrew formula] from
|
|
||||||
to your BREW_HOME by default /usr/local/Library/Formula/ and run
|
|
||||||
|
|
||||||
```
|
|
||||||
$ brew install proxychains
|
|
||||||
```
|
|
||||||
|
|
||||||
### Running Current Source code version
|
|
||||||
|
|
||||||
```
|
|
||||||
# needs a working C compiler, preferably gcc
|
|
||||||
./configure
|
|
||||||
make
|
|
||||||
sudo make install
|
|
||||||
```
|
|
||||||
|
|
||||||
## Changelog
|
|
||||||
|
|
||||||
*Version (4.x)* removes the dnsresolver script which required a dynamically
|
|
||||||
linked "dig" binary to be present with remote DNS lookup.
|
|
||||||
this speeds up any operation involving DNS, as the old script had to use TCP.
|
|
||||||
additionally it allows to use .onion urls when used with TOR.
|
|
||||||
also it removed the broken autoconf build system with a simple Makefile.
|
|
||||||
there's a ./configure script though for convenience.
|
|
||||||
it also adds support for a config file passed via command line switches/
|
|
||||||
environment variables.
|
|
||||||
|
|
||||||
*Version (3.x)* introduces support for DNS resolving through proxy
|
|
||||||
it supports SOCKS4, SOCKS5 and HTTP CONNECT proxy servers.
|
|
||||||
|
|
||||||
* Auth-types
|
|
||||||
** socks - "user/pass",
|
|
||||||
** http - "basic"
|
|
||||||
|
|
||||||
## When to use it
|
|
||||||
|
|
||||||
* When the only way to get "outside" from your LAN is through proxy server.
|
|
||||||
* To get out from behind restrictive firewall which filters outgoing ports.
|
|
||||||
* To use two (or more) proxies in chain:
|
|
||||||
|
|
||||||
```
|
|
||||||
like: your_host <--> proxy1 <--> proxy2 <--> target_host
|
|
||||||
```
|
|
||||||
|
|
||||||
* To "proxify" some program with no proxy support built-in (like telnet)
|
|
||||||
* Access intranet from outside via proxy.
|
|
||||||
* To use DNS behind proxy.
|
|
||||||
|
|
||||||
### Some cool features
|
|
||||||
|
|
||||||
* This program can mix different proxy types in the same chain
|
|
||||||
|
|
||||||
```
|
|
||||||
like: your_host <-->socks5 <--> http <--> socks4 <--> target_host
|
|
||||||
```
|
|
||||||
|
|
||||||
* Different chaining options supported
|
|
||||||
random order from the list ( user defined length of chain ).
|
|
||||||
exact order (as they appear in the list )
|
|
||||||
dynamic order (smart exclude dead proxies from chain)
|
|
||||||
* You can use it with any TCP client application, even network scanners
|
|
||||||
yes, yes - you can make portscan via proxy (or chained proxies)
|
|
||||||
for example with Nmap scanner by fyodor (www.insecure.org/nmap).
|
|
||||||
|
|
||||||
```
|
|
||||||
proxychains nmap -sT -PO -p 80 -iR (find some webservers through proxy)
|
|
||||||
```
|
|
||||||
|
|
||||||
* You can use it with servers, like squid, sendmail, or whatever.
|
|
||||||
* DNS resolving through proxy.
|
|
||||||
|
|
||||||
## Configuration
|
|
||||||
|
|
||||||
proxychains looks for configuration in the following order:
|
|
||||||
|
|
||||||
* SOCKS5 proxy host ip and port in environment variable ${PROXYCHAINS_SOCKS5_HOST} ${PROXYCHAINS_SOCKS5_PORT}
|
|
||||||
(if ${PROXYCHAINS_SOCKS5_PORT} is set, no further configuration will be searched. if ${PROXYCHAINS_SOCKS5_HOST} isn't set, host ip will become "127.0.0.1")
|
|
||||||
* file listed in environment variable ${PROXYCHAINS_CONF_FILE} or
|
|
||||||
provided as a -f argument to proxychains script or binary.
|
|
||||||
* ./proxychains.conf
|
|
||||||
* $(HOME)/.proxychains/proxychains.conf
|
|
||||||
* /etc/proxychains.conf
|
|
||||||
|
|
||||||
see more in */etc/proxychains.conf*
|
|
||||||
|
|
||||||
### Usage Example
|
|
||||||
|
|
||||||
```
|
|
||||||
$ proxychains4 telnet targethost.com
|
|
||||||
```
|
|
||||||
|
|
||||||
in this example it will run telnet through proxy(or chained proxies)
|
|
||||||
specified by *proxychains.conf*
|
|
||||||
|
|
||||||
### Usage Example
|
|
||||||
|
|
||||||
```
|
|
||||||
$ proxychains4 -f /etc/proxychains-other.conf targethost2.com
|
|
||||||
```
|
|
||||||
|
|
||||||
in this example it will use different configuration file then *proxychains.conf*
|
|
||||||
to connect to targethost2.com host.
|
|
||||||
|
|
||||||
### Usage Example
|
|
||||||
|
|
||||||
```
|
|
||||||
$ proxyresolv targethost.com
|
|
||||||
```
|
|
||||||
|
|
||||||
in this example it will resolve targethost.com through proxy(or chained proxies)
|
|
||||||
specified by *proxychains.conf*
|
|
||||||
|
|
||||||
### Usage Example:
|
|
||||||
|
|
||||||
```
|
|
||||||
$ ssh -fN -D 4321 some.example.com
|
|
||||||
$ PROXYCHAINS_SOCKS5_HOST=127.0.0.1 PROXYCHAINS_SOCKS5_PORT=4321 proxychains zsh
|
|
||||||
```
|
|
||||||
|
|
||||||
in this example, it will run a shell with all traffic proxied through
|
|
||||||
OpenSSH's "dynamic proxy" (SOCKS5 proxy) on localhost port 4321.
|
|
||||||
|
|
||||||
### Usage Example:
|
|
||||||
|
|
||||||
```
|
|
||||||
$ export PROXY_DNS_SERVER=8.8.8.8
|
|
||||||
$ proxychains4 telnet targethost.com
|
|
||||||
```
|
|
||||||
|
|
||||||
in this example, it will telnet to targethost.com using the 8.8.8.8
|
|
||||||
nameserver supplied by the user through the PROXY_DNS_SERVER
|
|
||||||
8
TODO
8
TODO
@ -1,11 +1,7 @@
|
|||||||
ProxyChains ver 4.0 TODO
|
ProxyChains ver 4.0 TODO
|
||||||
===================
|
===================
|
||||||
|
|
||||||
- hooks for reentrant dns functions, i.e. gethostbyaddr_r
|
|
||||||
- shadowsocks support #133
|
hooks for reentrant dns functions, i.e. gethostbyaddr_r
|
||||||
- proxy change according to attempts #156
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +0,0 @@
|
|||||||
#compdef proxychains4
|
|
||||||
|
|
||||||
_arguments -s -S '1: :{_command_names -e}' '*:: :_normal'
|
|
||||||
38
configure
vendored
38
configure
vendored
@ -1,7 +1,6 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
prefix=/usr/local
|
prefix=/usr/local
|
||||||
develflg=0
|
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
echo "supported arguments"
|
echo "supported arguments"
|
||||||
@ -11,7 +10,6 @@ usage() {
|
|||||||
echo "--libdir=/path default: $prefix/lib"
|
echo "--libdir=/path default: $prefix/lib"
|
||||||
echo "--includedir=/path default: $prefix/include"
|
echo "--includedir=/path default: $prefix/include"
|
||||||
echo "--sysconfdir=/path default: $prefix/etc"
|
echo "--sysconfdir=/path default: $prefix/etc"
|
||||||
echo "--devel default:no (set development mode)"
|
|
||||||
echo "--help : show this text"
|
echo "--help : show this text"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
@ -31,7 +29,6 @@ parsearg() {
|
|||||||
--libdir=*) libdir=`spliteq $1`;;
|
--libdir=*) libdir=`spliteq $1`;;
|
||||||
--includedir=*) includedir=`spliteq $1`;;
|
--includedir=*) includedir=`spliteq $1`;;
|
||||||
--sysconfdir=*) sysconfdir=`spliteq $1`;;
|
--sysconfdir=*) sysconfdir=`spliteq $1`;;
|
||||||
--devel) develflg=1;;
|
|
||||||
--help) usage;;
|
--help) usage;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
@ -40,14 +37,6 @@ ismac() {
|
|||||||
uname -s | grep Darwin
|
uname -s | grep Darwin
|
||||||
}
|
}
|
||||||
|
|
||||||
isbsd() {
|
|
||||||
uname -s | grep BSD
|
|
||||||
}
|
|
||||||
|
|
||||||
islinux() {
|
|
||||||
uname -s | grep Linux
|
|
||||||
}
|
|
||||||
|
|
||||||
while true ; do
|
while true ; do
|
||||||
case $1 in
|
case $1 in
|
||||||
-*) parsearg "$1"; shift;;
|
-*) parsearg "$1"; shift;;
|
||||||
@ -79,45 +68,22 @@ if [ -z "$CC" ] ; then
|
|||||||
CC=cc
|
CC=cc
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $develflg -eq 1 ]; then
|
|
||||||
CFLAGS="-Wextra -Wunused -Wuninitialized -Wconversion -fno-common -g -O0 -DDEBUG"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo CC?=$CC>config.mak
|
echo CC?=$CC>config.mak
|
||||||
[ -z "$CPPFLAGS" ] || echo CPPFLAGS?=$CPPFLAGS>>config.mak
|
[ -z "$CPPFLAGS" ] || echo CPPFLAGS?=$CPPFLAGS>>config.mak
|
||||||
[ -z "$CFLAGS" ] || echo USER_CFLAGS?=$CFLAGS>>config.mak
|
[ -z "$CFLAGS" ] || echo USER_CFLAGS?=$CFLAGS>>config.mak
|
||||||
[ -z "$LDFLAGS" ] || echo USER_LDFLAGS?=$LDFLAGS>>config.mak
|
|
||||||
|
|
||||||
echo prefix=$prefix>>config.mak
|
echo prefix=$prefix>>config.mak
|
||||||
echo exec_prefix=$exec_prefix>>config.mak
|
echo exec_prefix=$exec_prefix>>config.mak
|
||||||
echo bindir=$bindir>>config.mak
|
echo bindir=$bindir>>config.mak
|
||||||
echo libdir=$libdir>>config.mak
|
echo libdir=$libdir>>config.mak
|
||||||
echo includedir=$includedir>>config.mak
|
echo includedir=$includedir>>config.mak
|
||||||
echo sysconfdir=$sysconfdir>>config.mak
|
echo sysconfdir=$sysconfdir>>config.mak
|
||||||
|
|
||||||
if ismac ; then
|
if ismac ; then
|
||||||
arch=`uname -m`
|
|
||||||
|
|
||||||
echo LDSO_SUFFIX=dylib>>config.mak
|
echo LDSO_SUFFIX=dylib>>config.mak
|
||||||
echo OS_CFLAGS+=-DIS_MAC=1 -arch $arch >>config.mak
|
echo MAC_CFLAGS+=-DIS_MAC=1 -arch x86_64 -arch i386 >>config.mak
|
||||||
echo OS_LDFLAGS+=-arch $arch -lpthread -ldl -Wl,>>config.mak
|
echo MAC_LDFLAGS+=-arch x86_64 -arch i386 >>config.mak
|
||||||
echo LD_SET_SONAME=-Wl,-install_name,>>config.mak
|
echo LD_SET_SONAME=-Wl,-install_name,>>config.mak
|
||||||
echo LDSO_SUFFIX=dylib>>config.mak
|
|
||||||
echo INSTALL_FLAGS=-m>>config.mak
|
echo INSTALL_FLAGS=-m>>config.mak
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if islinux ; then
|
|
||||||
echo OS_LDFLAGS=-pthread -ldl -Wl,--no-as-needed>>config.mak
|
|
||||||
echo LD_SET_SONAME=-Wl,-soname= >>config.mak
|
|
||||||
fi
|
|
||||||
|
|
||||||
if isbsd ; then
|
|
||||||
#echo OS_LDFLAGS=
|
|
||||||
#echo OS_CFLAGS
|
|
||||||
echo INSTALL_FLAGS=-m>>config.mak
|
|
||||||
echo LD_SET_SONAME=-Wl,-rpath,$libdir -install_name,>>config.mak
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo done, now run make \&\& make install
|
echo done, now run make \&\& make install
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
13
dist/proxychains.conf
vendored
13
dist/proxychains.conf
vendored
@ -1,13 +0,0 @@
|
|||||||
strict_chain
|
|
||||||
#proxy_dns
|
|
||||||
#remote_dns_subnet 224
|
|
||||||
tcp_read_time_out 15000
|
|
||||||
tcp_connect_time_out 8000
|
|
||||||
|
|
||||||
localnet 127.0.0.0/255.0.0.0
|
|
||||||
|
|
||||||
|
|
||||||
[ProxyList]
|
|
||||||
http 162.243.184.252 8585
|
|
||||||
#socks4 184.170.245.148 4145
|
|
||||||
#raw 162.243.184.252 8585
|
|
||||||
@ -1,13 +1,13 @@
|
|||||||
Begin3
|
Begin3
|
||||||
Title: ProxyChains
|
Title: ProxyChains
|
||||||
Version: 4.3
|
Version: 4.0
|
||||||
Entered-date:
|
Entered-date:
|
||||||
Description:
|
Description:
|
||||||
Keywords:
|
Keywords:
|
||||||
Author: <N37CR347UR3>
|
Author: <N37CR347UR3>
|
||||||
Maintained-by: <haad@netbsd.org>
|
Maintained-by: <haad@netbsd.org>
|
||||||
Primary-site:
|
Primary-site:
|
||||||
Home-page: https://github.com/haad/proxychains
|
Home-page: http://proxychains.sourceforge.net
|
||||||
Original-site:
|
Original-site:
|
||||||
Platforms: Linux and other Unices
|
Platforms: Linux and other Unices
|
||||||
Copying-policy: GNU Public License
|
Copying-policy: GNU Public License
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -16,8 +15,6 @@ char *get_config_path(char* default_path, char* pbuf, size_t bufsize) {
|
|||||||
char *path = default_path;
|
char *path = default_path;
|
||||||
if(check_path(path))
|
if(check_path(path))
|
||||||
return path;
|
return path;
|
||||||
if (!pbuf)
|
|
||||||
goto err;
|
|
||||||
|
|
||||||
// priority 1: env var PROXYCHAINS_CONF_FILE
|
// priority 1: env var PROXYCHAINS_CONF_FILE
|
||||||
path = getenv(PROXYCHAINS_CONF_FILE_ENV_VAR);
|
path = getenv(PROXYCHAINS_CONF_FILE_ENV_VAR);
|
||||||
@ -48,7 +45,6 @@ char *get_config_path(char* default_path, char* pbuf, size_t bufsize) {
|
|||||||
if(check_path(path))
|
if(check_path(path))
|
||||||
return path;
|
return path;
|
||||||
|
|
||||||
err:
|
perror("couldnt find configuration file");
|
||||||
perror("couldn't find configuration file");
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,15 +1,8 @@
|
|||||||
#define PROXYCHAINS_CONF_FILE_ENV_VAR "PROXYCHAINS_CONF_FILE"
|
#define PROXYCHAINS_CONF_FILE_ENV_VAR "PROXYCHAINS_CONF_FILE"
|
||||||
#define PROXYCHAINS_QUIET_MODE_ENV_VAR "PROXYCHAINS_QUIET_MODE"
|
#define PROXYCHAINS_QUIET_MODE_ENV_VAR "PROXYCHAINS_QUIET_MODE"
|
||||||
#define PROXYCHAINS_CONF_FILE "proxychains.conf"
|
#define PROXYCHAINS_CONF_FILE "proxychains.conf"
|
||||||
#define PROXYCHAINS_SOCKS5_PORT_ENV_VAR "PROXYCHAINS_SOCKS5_PORT"
|
|
||||||
#define PROXYCHAINS_SOCKS5_HOST_ENV_VAR "PROXYCHAINS_SOCKS5_HOST"
|
|
||||||
#define PROXYCHAINS_DNS_ENV_VAR "PROXYCHAINS_DNS"
|
|
||||||
#define LOG_PREFIX "[proxychains] "
|
#define LOG_PREFIX "[proxychains] "
|
||||||
|
|
||||||
#define PROXYCHAINS_VERSION_MAJOR 4
|
|
||||||
#define PROXYCHAINS_VERSION_MINOR 3
|
|
||||||
#define PROXYCHAINS_VERSION_BUGFIX 0
|
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
char *get_config_path(char* default_path, char* pbuf, size_t bufsize);
|
char *get_config_path(char* default_path, char* pbuf, size_t bufsize);
|
||||||
138
src/core.c
138
src/core.c
@ -15,7 +15,6 @@
|
|||||||
* *
|
* *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/cdefs.h>
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@ -35,15 +34,10 @@
|
|||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#ifdef THREAD_SAFE
|
#ifdef THREAD_SAFE
|
||||||
|
#include <pthread.h>
|
||||||
pthread_mutex_t internal_ips_lock;
|
pthread_mutex_t internal_ips_lock;
|
||||||
|
#endif
|
||||||
#ifdef __APPLE__
|
|
||||||
pthread_mutex_t internal_getsrvbyname_lock;
|
|
||||||
#endif /* __APPLE__ */
|
|
||||||
|
|
||||||
#endif /* THREAD_SAFE */
|
|
||||||
|
|
||||||
#include "core.h"
|
#include "core.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
@ -68,7 +62,7 @@ uint32_t dalias_hash(char *s0) {
|
|||||||
uint32_t index_from_internal_ip(ip_type internalip) {
|
uint32_t index_from_internal_ip(ip_type internalip) {
|
||||||
ip_type tmp = internalip;
|
ip_type tmp = internalip;
|
||||||
uint32_t ret;
|
uint32_t ret;
|
||||||
ret = (uint32_t) (tmp.octet[3] + (tmp.octet[2] << 8) + (tmp.octet[1] << 16));
|
ret = tmp.octet[3] + (tmp.octet[2] << 8) + (tmp.octet[1] << 16);
|
||||||
ret -= 1;
|
ret -= 1;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -112,7 +106,7 @@ static int poll_retry(struct pollfd *fds, nfds_t nfsd, int timeout)
|
|||||||
//printf("Retry %d\n", time_remain);
|
//printf("Retry %d\n", time_remain);
|
||||||
ret = poll(fds, nfsd, time_remain);
|
ret = poll(fds, nfsd, time_remain);
|
||||||
gettimeofday(&tv, NULL);
|
gettimeofday(&tv, NULL);
|
||||||
time_elapsed = ((int)(tv.tv_sec - start_time.tv_sec) * 1000 + (int)(tv.tv_usec - start_time.tv_usec) / 1000);
|
time_elapsed = ((tv.tv_sec - start_time.tv_sec) * 1000 + (tv.tv_usec - start_time.tv_usec) / 1000);
|
||||||
//printf("Time elapsed %d\n", time_elapsed);
|
//printf("Time elapsed %d\n", time_elapsed);
|
||||||
time_remain = timeout - time_elapsed;
|
time_remain = timeout - time_elapsed;
|
||||||
} while(ret == -1 && errno == EINTR && time_remain > 0);
|
} while(ret == -1 && errno == EINTR && time_remain > 0);
|
||||||
@ -124,9 +118,7 @@ static int poll_retry(struct pollfd *fds, nfds_t nfsd, int timeout)
|
|||||||
|
|
||||||
|
|
||||||
static void encode_base_64(char *src, char *dest, int max_len) {
|
static void encode_base_64(char *src, char *dest, int max_len) {
|
||||||
int n, i;
|
int n, l, i;
|
||||||
size_t l;
|
|
||||||
|
|
||||||
l = strlen(src);
|
l = strlen(src);
|
||||||
max_len = (max_len - 1) / 4;
|
max_len = (max_len - 1) / 4;
|
||||||
for(i = 0; i < max_len; i++, src += 3, l -= 3) {
|
for(i = 0; i < max_len; i++, src += 3, l -= 3) {
|
||||||
@ -172,11 +164,11 @@ void proxychains_write_log(char *str, ...) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t write_n_bytes(int fd, char *buff, size_t size) {
|
static int write_n_bytes(int fd, char *buff, size_t size) {
|
||||||
size_t i = 0;
|
int i = 0;
|
||||||
size_t wrote = 0;
|
size_t wrote = 0;
|
||||||
for(;;) {
|
for(;;) {
|
||||||
i = (size_t) write(fd, &buff[wrote], size - wrote);
|
i = write(fd, &buff[wrote], size - wrote);
|
||||||
if(i <= 0)
|
if(i <= 0)
|
||||||
return i;
|
return i;
|
||||||
wrote += i;
|
wrote += i;
|
||||||
@ -185,7 +177,7 @@ static size_t write_n_bytes(int fd, char *buff, size_t size) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t read_n_bytes(int fd, char *buff, size_t size) {
|
static int read_n_bytes(int fd, char *buff, size_t size) {
|
||||||
int ready;
|
int ready;
|
||||||
size_t i;
|
size_t i;
|
||||||
struct pollfd pfd[1];
|
struct pollfd pfd[1];
|
||||||
@ -196,9 +188,9 @@ static size_t read_n_bytes(int fd, char *buff, size_t size) {
|
|||||||
pfd[0].revents = 0;
|
pfd[0].revents = 0;
|
||||||
ready = poll_retry(pfd, 1, tcp_read_time_out);
|
ready = poll_retry(pfd, 1, tcp_read_time_out);
|
||||||
if(ready != 1 || !(pfd[0].revents & POLLIN) || 1 != read(fd, &buff[i], 1))
|
if(ready != 1 || !(pfd[0].revents & POLLIN) || 1 != read(fd, &buff[i], 1))
|
||||||
return 0;
|
return -1;
|
||||||
}
|
}
|
||||||
return size;
|
return (int) size;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int timed_connect(int sock, const struct sockaddr *addr, socklen_t len) {
|
static int timed_connect(int sock, const struct sockaddr *addr, socklen_t len) {
|
||||||
@ -272,16 +264,12 @@ static int tunnel_to(int sock, ip_type ip, unsigned short port, proxy_type pt, c
|
|||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t len;
|
int len;
|
||||||
unsigned char buff[BUFF_SIZE];
|
unsigned char buff[BUFF_SIZE];
|
||||||
char ip_buf[16];
|
char ip_buf[16];
|
||||||
//memset (buff, 0, sizeof(buff));
|
//memset (buff, 0, sizeof(buff));
|
||||||
|
|
||||||
switch (pt) {
|
switch (pt) {
|
||||||
case RAW_TYPE: {
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case HTTP_TYPE:{
|
case HTTP_TYPE:{
|
||||||
if(!dns_len) {
|
if(!dns_len) {
|
||||||
inet_ntop(AF_INET, &ip.octet[0], ip_buf, sizeof(ip_buf));
|
inet_ntop(AF_INET, &ip.octet[0], ip_buf, sizeof(ip_buf));
|
||||||
@ -310,7 +298,7 @@ static int tunnel_to(int sock, ip_type ip, unsigned short port, proxy_type pt, c
|
|||||||
|
|
||||||
len = strlen((char *) buff);
|
len = strlen((char *) buff);
|
||||||
|
|
||||||
if(len != (size_t) send(sock, buff, len, 0))
|
if(len != send(sock, buff, len, 0))
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
len = 0;
|
len = 0;
|
||||||
@ -404,15 +392,15 @@ static int tunnel_to(int sock, ip_type ip, unsigned short port, proxy_type pt, c
|
|||||||
int c;
|
int c;
|
||||||
*cur++ = 1; // version
|
*cur++ = 1; // version
|
||||||
c = ulen & 0xFF;
|
c = ulen & 0xFF;
|
||||||
*cur++ = (char)c;
|
*cur++ = c;
|
||||||
memcpy(cur, user, (size_t)c);
|
memcpy(cur, user, c);
|
||||||
cur += c;
|
cur += c;
|
||||||
c = passlen & 0xFF;
|
c = passlen & 0xFF;
|
||||||
*cur++ = (char)c;
|
*cur++ = c;
|
||||||
memcpy(cur, pass, (size_t)c);
|
memcpy(cur, pass, c);
|
||||||
cur += c;
|
cur += c;
|
||||||
|
|
||||||
if((size_t)(cur - out) != write_n_bytes(sock, out, (size_t) (cur - out)))
|
if((cur - out) != write_n_bytes(sock, out, cur - out))
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
|
|
||||||
@ -425,7 +413,7 @@ static int tunnel_to(int sock, ip_type ip, unsigned short port, proxy_type pt, c
|
|||||||
return BLOCKED;
|
return BLOCKED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
size_t buff_iter = 0;
|
int buff_iter = 0;
|
||||||
buff[buff_iter++] = 5; // version
|
buff[buff_iter++] = 5; // version
|
||||||
buff[buff_iter++] = 1; // connect
|
buff[buff_iter++] = 1; // connect
|
||||||
buff[buff_iter++] = 0; // reserved
|
buff[buff_iter++] = 0; // reserved
|
||||||
@ -518,19 +506,6 @@ static int start_chain(int *fd, proxy_data * pd, char *begin_mark) {
|
|||||||
return SOCKET_ERROR;
|
return SOCKET_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int get_rand_int(unsigned int range){
|
|
||||||
static FILE *fp;
|
|
||||||
unsigned int randval;
|
|
||||||
if (!fp) {
|
|
||||||
fp = fopen("/dev/urandom", "r");
|
|
||||||
}
|
|
||||||
if(fread(&randval, sizeof(randval), 1, fp)) {
|
|
||||||
return (randval % range);
|
|
||||||
} else {
|
|
||||||
srand((unsigned int)time(NULL));
|
|
||||||
return ((unsigned int)rand() % range);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static proxy_data *select_proxy(select_type how, proxy_data * pd, unsigned int proxy_count, unsigned int *offset) {
|
static proxy_data *select_proxy(select_type how, proxy_data * pd, unsigned int proxy_count, unsigned int *offset) {
|
||||||
unsigned int i = 0, k = 0;
|
unsigned int i = 0, k = 0;
|
||||||
@ -539,10 +514,10 @@ static proxy_data *select_proxy(select_type how, proxy_data * pd, unsigned int p
|
|||||||
return NULL;
|
return NULL;
|
||||||
switch (how) {
|
switch (how) {
|
||||||
case RANDOMLY:
|
case RANDOMLY:
|
||||||
|
srand(time(NULL));
|
||||||
do {
|
do {
|
||||||
k++;
|
k++;
|
||||||
i = 0 + get_rand_int(proxy_count);
|
i = 0 + (unsigned int) (proxy_count * 1.0 * rand() / (RAND_MAX + 1.0));
|
||||||
} while(pd[i].ps != PLAY_STATE && k < proxy_count * 100);
|
} while(pd[i].ps != PLAY_STATE && k < proxy_count * 100);
|
||||||
break;
|
break;
|
||||||
case FIFOLY:
|
case FIFOLY:
|
||||||
@ -577,7 +552,8 @@ static void release_busy(proxy_data * pd, unsigned int proxy_count) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static unsigned int calc_alive(proxy_data * pd, unsigned int proxy_count) {
|
static unsigned int calc_alive(proxy_data * pd, unsigned int proxy_count) {
|
||||||
unsigned int i, alive_count = 0;
|
unsigned int i;
|
||||||
|
int alive_count = 0;
|
||||||
release_busy(pd, proxy_count);
|
release_busy(pd, proxy_count);
|
||||||
for(i = 0; i < proxy_count; i++)
|
for(i = 0; i < proxy_count; i++)
|
||||||
if(pd[i].ps == PLAY_STATE)
|
if(pd[i].ps == PLAY_STATE)
|
||||||
@ -640,7 +616,7 @@ int connect_proxy_chain(int sock, ip_type target_ip,
|
|||||||
|
|
||||||
switch (ct) {
|
switch (ct) {
|
||||||
case DYNAMIC_TYPE:
|
case DYNAMIC_TYPE:
|
||||||
calc_alive(pd, proxy_count);
|
alive_count = calc_alive(pd, proxy_count);
|
||||||
offset = 0;
|
offset = 0;
|
||||||
do {
|
do {
|
||||||
if(!(p1 = select_proxy(FIFOLY, pd, proxy_count, &offset)))
|
if(!(p1 = select_proxy(FIFOLY, pd, proxy_count, &offset)))
|
||||||
@ -664,7 +640,7 @@ int connect_proxy_chain(int sock, ip_type target_ip,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case STRICT_TYPE:
|
case STRICT_TYPE:
|
||||||
calc_alive(pd, proxy_count);
|
alive_count = calc_alive(pd, proxy_count);
|
||||||
offset = 0;
|
offset = 0;
|
||||||
if(!(p1 = select_proxy(FIFOLY, pd, proxy_count, &offset))) {
|
if(!(p1 = select_proxy(FIFOLY, pd, proxy_count, &offset))) {
|
||||||
PDEBUG("select_proxy failed\n");
|
PDEBUG("select_proxy failed\n");
|
||||||
@ -739,7 +715,6 @@ int connect_proxy_chain(int sock, ip_type target_ip,
|
|||||||
|
|
||||||
static const ip_type local_host = { {127, 0, 0, 1} };
|
static const ip_type local_host = { {127, 0, 0, 1} };
|
||||||
|
|
||||||
char hostname[256]; // default maximum length of hostname in linux
|
|
||||||
struct hostent *proxy_gethostbyname(const char *name, struct gethostbyname_data* data) {
|
struct hostent *proxy_gethostbyname(const char *name, struct gethostbyname_data* data) {
|
||||||
char buff[256];
|
char buff[256];
|
||||||
uint32_t i, hash;
|
uint32_t i, hash;
|
||||||
@ -761,12 +736,6 @@ struct hostent *proxy_gethostbyname(const char *name, struct gethostbyname_data*
|
|||||||
data->resolved_addr = inet_addr(buff);
|
data->resolved_addr = inet_addr(buff);
|
||||||
if(data->resolved_addr == (in_addr_t) (-1))
|
if(data->resolved_addr == (in_addr_t) (-1))
|
||||||
data->resolved_addr = (in_addr_t) (local_host.as_int);
|
data->resolved_addr = (in_addr_t) (local_host.as_int);
|
||||||
|
|
||||||
snprintf(hostname,sizeof hostname, "%s", name);
|
|
||||||
data->hostent_space.h_name = hostname;
|
|
||||||
data->hostent_space.h_length = sizeof (in_addr_t);
|
|
||||||
data->hostent_space.h_addrtype = AF_INET;
|
|
||||||
|
|
||||||
return &data->hostent_space;
|
return &data->hostent_space;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -829,12 +798,10 @@ struct hostent *proxy_gethostbyname(const char *name, struct gethostbyname_data*
|
|||||||
|
|
||||||
MUTEX_UNLOCK(&internal_ips_lock);
|
MUTEX_UNLOCK(&internal_ips_lock);
|
||||||
|
|
||||||
strncpy(data->addr_name, name, sizeof(data->addr_name) - 1);
|
strncpy(data->addr_name, name, sizeof(data->addr_name));
|
||||||
|
|
||||||
data->hostent_space.h_name = data->addr_name;
|
data->hostent_space.h_name = data->addr_name;
|
||||||
data->hostent_space.h_length = sizeof(in_addr_t);
|
data->hostent_space.h_length = sizeof(in_addr_t);
|
||||||
data->hostent_space.h_addrtype = AF_INET;
|
|
||||||
|
|
||||||
return &data->hostent_space;
|
return &data->hostent_space;
|
||||||
|
|
||||||
err_plus_unlock:
|
err_plus_unlock:
|
||||||
@ -852,7 +819,7 @@ void proxy_freeaddrinfo(struct addrinfo *res) {
|
|||||||
free(res);
|
free(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
void proxy_getservbyname(const char * service, struct servent *se_buf,
|
void proxy_getserverbyname(const char * service, struct servent *se_buf,
|
||||||
char * buf, size_t buf_len, struct servent **se_result)
|
char * buf, size_t buf_len, struct servent **se_result)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -862,22 +829,22 @@ void proxy_getservbyname(const char * service, struct servent *se_buf,
|
|||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
struct servent *se;
|
struct servent *se;
|
||||||
|
#ifdef THREAD_SAFE
|
||||||
MUTEX_LOCK(&internal_getsrvbyname_lock);
|
MUTEX_LOCK(&internal_getsrvbyname_lock);
|
||||||
if(service) {
|
#endif
|
||||||
|
if(service)
|
||||||
se = getservbyname(service, NULL);
|
se = getservbyname(service, NULL);
|
||||||
|
if (!se)
|
||||||
if ( se != NULL ) {
|
memcpy(se_buf, se, buf_len);
|
||||||
memcpy(se_buf, se, buf_len);
|
*se_result = se_buf;
|
||||||
*se_result = se_buf;
|
#ifdef THREAD_SAFE
|
||||||
} else {
|
|
||||||
*se_result = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
MUTEX_UNLOCK(&internal_getsrvbyname_lock);
|
MUTEX_UNLOCK(&internal_getsrvbyname_lock);
|
||||||
#endif /* __APPLE__ */
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int proxy_getaddrinfo(const char *node, const char *service, const struct addrinfo *hints, struct addrinfo **res) {
|
int proxy_getaddrinfo(const char *node, const char *service, const struct addrinfo *hints, struct addrinfo **res) {
|
||||||
struct gethostbyname_data ghdata;
|
struct gethostbyname_data ghdata;
|
||||||
struct addrinfo_data *space;
|
struct addrinfo_data *space;
|
||||||
@ -890,31 +857,28 @@ int proxy_getaddrinfo(const char *node, const char *service, const struct addrin
|
|||||||
|
|
||||||
// printf("proxy_getaddrinfo node %s service %s\n",node,service);
|
// printf("proxy_getaddrinfo node %s service %s\n",node,service);
|
||||||
space = calloc(1, sizeof(struct addrinfo_data));
|
space = calloc(1, sizeof(struct addrinfo_data));
|
||||||
if(!space)
|
if(!space) goto err1;
|
||||||
return 1;
|
|
||||||
|
|
||||||
if(node && !inet_aton(node, &((struct sockaddr_in *) &space->sockaddr_space)->sin_addr)) {
|
if(node && !inet_aton(node, &((struct sockaddr_in *) &space->sockaddr_space)->sin_addr)) {
|
||||||
hp = proxy_gethostbyname(node, &ghdata);
|
hp = proxy_gethostbyname(node, &ghdata);
|
||||||
if(hp) {
|
if(hp)
|
||||||
memcpy(&((struct sockaddr_in *) &space->sockaddr_space)->sin_addr,
|
memcpy(&((struct sockaddr_in *) &space->sockaddr_space)->sin_addr,
|
||||||
*(hp->h_addr_list), sizeof(in_addr_t));
|
*(hp->h_addr_list), sizeof(in_addr_t));
|
||||||
} else {
|
else
|
||||||
free(space);
|
goto err2;
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if(service)
|
if(service)
|
||||||
proxy_getservbyname(service, &se_buf, buf, sizeof(buf), &se);
|
proxy_getserverbyname(service, &se_buf, buf, sizeof(buf), &se);
|
||||||
|
|
||||||
port = se ? se->s_port : htons((uint16_t)atoi(service ? service : "0"));
|
port = se ? se->s_port : htons(atoi(service ? service : "0"));
|
||||||
((struct sockaddr_in *) &space->sockaddr_space)->sin_port = (in_port_t)port;
|
((struct sockaddr_in *) &space->sockaddr_space)->sin_port = port;
|
||||||
|
|
||||||
*res = p = &space->addrinfo_space;
|
*res = p = &space->addrinfo_space;
|
||||||
assert((size_t)p == (size_t) space);
|
assert((size_t)p == (size_t) space);
|
||||||
|
|
||||||
p->ai_addr = &space->sockaddr_space;
|
p->ai_addr = &space->sockaddr_space;
|
||||||
if(node)
|
if(node)
|
||||||
strncpy(space->addr_name, node, sizeof(space->addr_name) - 1);
|
strncpy(space->addr_name, node, sizeof(space->addr_name));
|
||||||
p->ai_canonname = space->addr_name;
|
p->ai_canonname = space->addr_name;
|
||||||
p->ai_next = NULL;
|
p->ai_next = NULL;
|
||||||
p->ai_family = space->sockaddr_space.sa_family = AF_INET;
|
p->ai_family = space->sockaddr_space.sa_family = AF_INET;
|
||||||
@ -925,12 +889,14 @@ int proxy_getaddrinfo(const char *node, const char *service, const struct addrin
|
|||||||
p->ai_flags = hints->ai_flags;
|
p->ai_flags = hints->ai_flags;
|
||||||
p->ai_protocol = hints->ai_protocol;
|
p->ai_protocol = hints->ai_protocol;
|
||||||
} else {
|
} else {
|
||||||
#ifdef BSD
|
|
||||||
p->ai_flags = (AI_V4MAPPED | AI_ADDRCONFIG);
|
p->ai_flags = (AI_V4MAPPED | AI_ADDRCONFIG);
|
||||||
#else
|
|
||||||
p->ai_flags = (AI_ADDRCONFIG);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
goto out;
|
||||||
|
err2:
|
||||||
|
free(space);
|
||||||
|
err1:
|
||||||
|
return 1;
|
||||||
|
out:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
35
src/core.h
35
src/core.h
@ -20,7 +20,6 @@
|
|||||||
#define __CORE_HEADER
|
#define __CORE_HEADER
|
||||||
#define BUFF_SIZE 8*1024 // used to read responses from proxies.
|
#define BUFF_SIZE 8*1024 // used to read responses from proxies.
|
||||||
#define MAX_LOCALNET 64
|
#define MAX_LOCALNET 64
|
||||||
#define MAX_DNAT 64
|
|
||||||
|
|
||||||
typedef union {
|
typedef union {
|
||||||
unsigned char octet[4];
|
unsigned char octet[4];
|
||||||
@ -42,9 +41,11 @@ extern internal_ip_lookup_table internal_ips;
|
|||||||
|
|
||||||
#ifdef THREAD_SAFE
|
#ifdef THREAD_SAFE
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
pthread_mutex_t internal_ips_lock;
|
||||||
|
|
||||||
extern pthread_mutex_t internal_ips_lock;
|
#ifdef __APPLE__
|
||||||
extern pthread_mutex_t internal_getsrvbyname_lock;
|
pthread_mutex_t internal_getsrvbyname_lock;
|
||||||
|
#endif
|
||||||
|
|
||||||
# define MUTEX_LOCK(x) pthread_mutex_lock(x)
|
# define MUTEX_LOCK(x) pthread_mutex_lock(x)
|
||||||
# define MUTEX_UNLOCK(x) pthread_mutex_unlock(x)
|
# define MUTEX_UNLOCK(x) pthread_mutex_unlock(x)
|
||||||
@ -67,7 +68,6 @@ typedef enum {
|
|||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
HTTP_TYPE,
|
HTTP_TYPE,
|
||||||
RAW_TYPE,
|
|
||||||
SOCKS4_TYPE,
|
SOCKS4_TYPE,
|
||||||
SOCKS5_TYPE
|
SOCKS5_TYPE
|
||||||
} proxy_type;
|
} proxy_type;
|
||||||
@ -95,11 +95,6 @@ typedef struct {
|
|||||||
unsigned short port;
|
unsigned short port;
|
||||||
} localaddr_arg;
|
} localaddr_arg;
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
struct in_addr orig_dst, new_dst;
|
|
||||||
unsigned short orig_port, new_port;
|
|
||||||
} dnat_arg;
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
ip_type ip;
|
ip_type ip;
|
||||||
unsigned short port;
|
unsigned short port;
|
||||||
@ -109,23 +104,20 @@ typedef struct {
|
|||||||
char pass[256];
|
char pass[256];
|
||||||
} proxy_data;
|
} proxy_data;
|
||||||
|
|
||||||
int connect_proxy_chain (int, ip_type, unsigned short, proxy_data *, unsigned int,
|
int connect_proxy_chain (int sock, ip_type target_ip, unsigned short target_port,
|
||||||
chain_type, unsigned int);
|
proxy_data * pd, unsigned int proxy_count, chain_type ct,
|
||||||
|
unsigned int max_chain );
|
||||||
|
|
||||||
void proxychains_write_log(char *, ...);
|
void proxychains_write_log(char *str, ...);
|
||||||
|
|
||||||
typedef int (*connect_t)(int, const struct sockaddr *, socklen_t);
|
typedef int (*connect_t)(int, const struct sockaddr *, socklen_t);
|
||||||
typedef struct hostent* (*gethostbyname_t)(const char *);
|
typedef struct hostent* (*gethostbyname_t)(const char *);
|
||||||
typedef int (*freeaddrinfo_t)(struct addrinfo *);
|
typedef int (*freeaddrinfo_t)(struct addrinfo *);
|
||||||
|
|
||||||
#if (defined __linux__) || (defined __APPLE__)
|
|
||||||
typedef struct hostent *(*gethostbyaddr_t) (const void *, socklen_t, int);
|
typedef struct hostent *(*gethostbyaddr_t) (const void *, socklen_t, int);
|
||||||
#else
|
|
||||||
typedef struct hostent *(*gethostbyaddr_t) (const char *, socklen_t, int);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef int (*getaddrinfo_t)(const char *, const char *, const struct addrinfo *,
|
typedef int (*getaddrinfo_t)(const char *, const char *, const struct addrinfo *,
|
||||||
struct addrinfo **);
|
struct addrinfo **);
|
||||||
|
|
||||||
typedef int (*getnameinfo_t) (const struct sockaddr *, socklen_t, char *,
|
typedef int (*getnameinfo_t) (const struct sockaddr *, socklen_t, char *,
|
||||||
socklen_t, char *, socklen_t, int);
|
socklen_t, char *, socklen_t, int);
|
||||||
|
|
||||||
@ -144,10 +136,11 @@ struct gethostbyname_data {
|
|||||||
char addr_name[1024 * 8];
|
char addr_name[1024 * 8];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct hostent* proxy_gethostbyname(const char *, struct gethostbyname_data *);
|
struct hostent* proxy_gethostbyname(const char *name, struct gethostbyname_data *data);
|
||||||
void proxy_getservbyname(const char *, struct servent *, char *, size_t, struct servent **);
|
|
||||||
int proxy_getaddrinfo(const char *, const char *, const struct addrinfo *, struct addrinfo **);
|
int proxy_getaddrinfo(const char *node, const char *service,
|
||||||
void proxy_freeaddrinfo(struct addrinfo *);
|
const struct addrinfo *hints, struct addrinfo **res);
|
||||||
|
void proxy_freeaddrinfo(struct addrinfo *res);
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
# define PDEBUG(fmt, args...) do { fprintf(stderr,"DEBUG:"fmt, ## args); fflush(stderr); } while(0)
|
# define PDEBUG(fmt, args...) do { fprintf(stderr,"DEBUG:"fmt, ## args); fflush(stderr); } while(0)
|
||||||
|
|||||||
@ -66,17 +66,13 @@ chain_type proxychains_ct;
|
|||||||
proxy_data proxychains_pd[MAX_CHAIN];
|
proxy_data proxychains_pd[MAX_CHAIN];
|
||||||
|
|
||||||
size_t num_localnet_addr = 0;
|
size_t num_localnet_addr = 0;
|
||||||
dnat_arg dnats[MAX_DNAT];
|
|
||||||
size_t num_dnats = 0;
|
|
||||||
|
|
||||||
#ifdef THREAD_SAFE
|
#ifdef THREAD_SAFE
|
||||||
pthread_once_t init_once = PTHREAD_ONCE_INIT;
|
pthread_once_t init_once = PTHREAD_ONCE_INIT;
|
||||||
#endif
|
#endif
|
||||||
static int init_l = 0;
|
static int init_l = 0;
|
||||||
|
|
||||||
static void load_default_settings(chain_type *ct);
|
|
||||||
static inline void get_chain_data(proxy_data * pd, unsigned int *proxy_count, chain_type * ct);
|
static inline void get_chain_data(proxy_data * pd, unsigned int *proxy_count, chain_type * ct);
|
||||||
static void simple_socks5_env(proxy_data * pd, unsigned int *proxy_count, chain_type * ct);
|
|
||||||
|
|
||||||
static void* load_sym(char* symname, void* proxyfunc) {
|
static void* load_sym(char* symname, void* proxyfunc) {
|
||||||
|
|
||||||
@ -105,9 +101,6 @@ static void do_init(void) {
|
|||||||
MUTEX_INIT(&internal_getsrvbyname_lock, NULL);
|
MUTEX_INIT(&internal_getsrvbyname_lock, NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* check for simple SOCKS5 proxy setup */
|
|
||||||
simple_socks5_env(proxychains_pd, &proxychains_proxy_count, &proxychains_ct);
|
|
||||||
|
|
||||||
/* read the config file */
|
/* read the config file */
|
||||||
get_chain_data(proxychains_pd, &proxychains_proxy_count, &proxychains_ct);
|
get_chain_data(proxychains_pd, &proxychains_proxy_count, &proxychains_ct);
|
||||||
|
|
||||||
@ -169,39 +162,29 @@ open_config_file() {
|
|||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* default settings common to get_chain_data and simple_socks5_env */
|
|
||||||
static void load_default_settings(chain_type *ct) {
|
|
||||||
char *env;
|
|
||||||
|
|
||||||
tcp_read_time_out = 4 * 1000;
|
|
||||||
tcp_connect_time_out = 10 * 1000;
|
|
||||||
*ct = DYNAMIC_TYPE;
|
|
||||||
|
|
||||||
env = getenv(PROXYCHAINS_QUIET_MODE_ENV_VAR);
|
|
||||||
if(env && *env == '1')
|
|
||||||
proxychains_quiet_mode = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* get configuration from config file */
|
/* get configuration from config file */
|
||||||
static void get_chain_data(proxy_data * pd, unsigned int *proxy_count, chain_type * ct) {
|
static void get_chain_data(proxy_data * pd, unsigned int *proxy_count, chain_type * ct) {
|
||||||
unsigned int count = 0;
|
int count = 0, port_n = 0, list = 0;
|
||||||
int port_n = 0, list = 0;
|
|
||||||
char buff[1024], type[1024], host[1024], user[1024];
|
char buff[1024], type[1024], host[1024], user[1024];
|
||||||
char *env;
|
char *env;
|
||||||
char local_in_addr_port[32];
|
char local_in_addr_port[32];
|
||||||
char local_in_addr[32], local_in_port[32], local_netmask[32];
|
char local_in_addr[32], local_in_port[32], 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];
|
|
||||||
FILE *file = NULL;
|
FILE *file = NULL;
|
||||||
|
|
||||||
if(proxychains_got_chain_data)
|
if(proxychains_got_chain_data)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
load_default_settings(ct);
|
//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), buff, sizeof(buff));
|
env = get_config_path(getenv(PROXYCHAINS_CONF_FILE_ENV_VAR), buff, sizeof(buff));
|
||||||
file = fopen(env, "r");
|
file = fopen(env, "r");
|
||||||
|
|
||||||
|
env = getenv(PROXYCHAINS_QUIET_MODE_ENV_VAR);
|
||||||
|
if(env && *env == '1')
|
||||||
|
proxychains_quiet_mode = 1;
|
||||||
|
|
||||||
while(fgets(buff, sizeof(buff), file)) {
|
while(fgets(buff, sizeof(buff), file)) {
|
||||||
if(buff[0] != '\n' && buff[strspn(buff, " ")] != '#') {
|
if(buff[0] != '\n' && buff[strspn(buff, " ")] != '#') {
|
||||||
/* proxylist has to come last */
|
/* proxylist has to come last */
|
||||||
@ -221,8 +204,6 @@ static void get_chain_data(proxy_data * pd, unsigned int *proxy_count, chain_typ
|
|||||||
|
|
||||||
if(!strcmp(type, "http")) {
|
if(!strcmp(type, "http")) {
|
||||||
pd[count].pt = HTTP_TYPE;
|
pd[count].pt = HTTP_TYPE;
|
||||||
} else if(!strcmp(type, "raw")) {
|
|
||||||
pd[count].pt = RAW_TYPE;
|
|
||||||
} else if(!strcmp(type, "socks4")) {
|
} else if(!strcmp(type, "socks4")) {
|
||||||
pd[count].pt = SOCKS4_TYPE;
|
pd[count].pt = SOCKS4_TYPE;
|
||||||
} else if(!strcmp(type, "socks5")) {
|
} else if(!strcmp(type, "socks5")) {
|
||||||
@ -285,7 +266,7 @@ static void get_chain_data(proxy_data * pd, unsigned int *proxy_count, chain_typ
|
|||||||
}
|
}
|
||||||
if(local_in_port[0]) {
|
if(local_in_port[0]) {
|
||||||
localnet_addr[num_localnet_addr].port =
|
localnet_addr[num_localnet_addr].port =
|
||||||
(unsigned short) atoi(local_in_port);
|
(short) atoi(local_in_port);
|
||||||
} else {
|
} else {
|
||||||
localnet_addr[num_localnet_addr].port = 0;
|
localnet_addr[num_localnet_addr].port = 0;
|
||||||
}
|
}
|
||||||
@ -298,60 +279,11 @@ static void get_chain_data(proxy_data * pd, unsigned int *proxy_count, chain_typ
|
|||||||
int len;
|
int len;
|
||||||
pc = strchr(buff, '=');
|
pc = strchr(buff, '=');
|
||||||
len = atoi(++pc);
|
len = atoi(++pc);
|
||||||
proxychains_max_chain = (unsigned int) (len ? len : 1);
|
proxychains_max_chain = (len ? len : 1);
|
||||||
} else if(strstr(buff, "quiet_mode")) {
|
} else if(strstr(buff, "quiet_mode")) {
|
||||||
proxychains_quiet_mode = 1;
|
proxychains_quiet_mode = 1;
|
||||||
} else if(strstr(buff, "proxy_dns")) {
|
} else if(strstr(buff, "proxy_dns")) {
|
||||||
proxychains_resolver = 1;
|
proxychains_resolver = 1;
|
||||||
} else if(strstr(buff, "dnat")) {
|
|
||||||
if(sscanf(buff, "%s %21[^ ] %21s\n", user, dnat_orig_addr_port, dnat_new_addr_port) < 3) {
|
|
||||||
fprintf(stderr, "dnat format error");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
/* clean previously used buffer */
|
|
||||||
memset(dnat_orig_port, 0, sizeof(dnat_orig_port) / sizeof(dnat_orig_port[0]));
|
|
||||||
memset(dnat_new_port, 0, sizeof(dnat_new_port) / sizeof(dnat_new_port[0]));
|
|
||||||
|
|
||||||
(void)sscanf(dnat_orig_addr_port, "%15[^:]:%5s", dnat_orig_addr, dnat_orig_port);
|
|
||||||
(void)sscanf(dnat_new_addr_port, "%15[^:]:%5s", dnat_new_addr, dnat_new_port);
|
|
||||||
|
|
||||||
if(num_dnats < MAX_DNAT) {
|
|
||||||
int error;
|
|
||||||
error =
|
|
||||||
inet_pton(AF_INET, dnat_orig_addr,
|
|
||||||
&dnats[num_dnats].orig_dst);
|
|
||||||
if(error <= 0) {
|
|
||||||
fprintf(stderr, "dnat original destination address error\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
error =
|
|
||||||
inet_pton(AF_INET, dnat_new_addr,
|
|
||||||
&dnats[num_dnats].new_dst);
|
|
||||||
if(error <= 0) {
|
|
||||||
fprintf(stderr, "dnat effective destination address error\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(dnat_orig_port[0]) {
|
|
||||||
dnats[num_dnats].orig_port =
|
|
||||||
(unsigned short) atoi(dnat_orig_port);
|
|
||||||
} else {
|
|
||||||
dnats[num_dnats].orig_port = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(dnat_new_port[0]) {
|
|
||||||
dnats[num_dnats].new_port =
|
|
||||||
(unsigned 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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -361,43 +293,9 @@ static void get_chain_data(proxy_data * pd, unsigned int *proxy_count, chain_typ
|
|||||||
proxychains_got_chain_data = 1;
|
proxychains_got_chain_data = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void simple_socks5_env(proxy_data *pd, unsigned int *proxy_count, chain_type *ct) {
|
|
||||||
char *port_string;
|
|
||||||
char *host_string;
|
|
||||||
|
|
||||||
if(proxychains_got_chain_data)
|
|
||||||
return;
|
|
||||||
|
|
||||||
load_default_settings(ct);
|
|
||||||
|
|
||||||
port_string = getenv(PROXYCHAINS_SOCKS5_PORT_ENV_VAR);
|
|
||||||
|
|
||||||
if(!port_string)
|
|
||||||
return;
|
|
||||||
|
|
||||||
host_string = getenv(PROXYCHAINS_SOCKS5_HOST_ENV_VAR);
|
|
||||||
|
|
||||||
if(!host_string)
|
|
||||||
host_string = "127.0.0.1";
|
|
||||||
|
|
||||||
memset(pd, 0, sizeof(proxy_data));
|
|
||||||
|
|
||||||
pd[0].ps = PLAY_STATE;
|
|
||||||
pd[0].ip.as_int = (uint32_t) inet_addr(host_string);
|
|
||||||
pd[0].port = htons((unsigned short) strtol(port_string, NULL, 0));
|
|
||||||
pd[0].pt = SOCKS5_TYPE;
|
|
||||||
proxychains_max_chain = 1;
|
|
||||||
|
|
||||||
if(getenv(PROXYCHAINS_DNS_ENV_VAR))
|
|
||||||
proxychains_resolver = 1;
|
|
||||||
|
|
||||||
*proxy_count = 1;
|
|
||||||
proxychains_got_chain_data = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/******* HOOK FUNCTIONS *******/
|
/******* HOOK FUNCTIONS *******/
|
||||||
|
|
||||||
int connect(int sock, const struct sockaddr *addr, socklen_t len) {
|
int connect(int sock, const struct sockaddr *addr, unsigned int len) {
|
||||||
int socktype = 0, flags = 0, ret = 0;
|
int socktype = 0, flags = 0, ret = 0;
|
||||||
socklen_t optlen = 0;
|
socklen_t optlen = 0;
|
||||||
ip_type dest_ip;
|
ip_type dest_ip;
|
||||||
@ -405,8 +303,6 @@ int connect(int sock, const struct sockaddr *addr, socklen_t len) {
|
|||||||
char str[256];
|
char str[256];
|
||||||
#endif
|
#endif
|
||||||
struct in_addr *p_addr_in;
|
struct in_addr *p_addr_in;
|
||||||
struct sockaddr_in new_addr;
|
|
||||||
dnat_arg *dnat = NULL;
|
|
||||||
unsigned short port;
|
unsigned short port;
|
||||||
size_t i;
|
size_t i;
|
||||||
int remote_dns_connect = 0;
|
int remote_dns_connect = 0;
|
||||||
@ -430,29 +326,6 @@ int connect(int sock, const struct sockaddr *addr, socklen_t len) {
|
|||||||
// check if connect called from proxydns
|
// check if connect called from proxydns
|
||||||
remote_dns_connect = (ntohl(p_addr_in->s_addr) >> 24 == remote_dns_subnet);
|
remote_dns_connect = (ntohl(p_addr_in->s_addr) >> 24 == remote_dns_subnet);
|
||||||
|
|
||||||
// more specific first
|
|
||||||
for(i = 0; i < num_dnats && !remote_dns_connect && !dnat; i++)
|
|
||||||
if(dnats[i].orig_dst.s_addr == p_addr_in->s_addr)
|
|
||||||
if(dnats[i].orig_port && (dnats[i].orig_port == port))
|
|
||||||
dnat = &dnats[i];
|
|
||||||
|
|
||||||
for(i = 0; i < num_dnats && !remote_dns_connect && !dnat; i++)
|
|
||||||
if(dnats[i].orig_dst.s_addr == p_addr_in->s_addr)
|
|
||||||
if(!dnats[i].orig_port)
|
|
||||||
dnat = &dnats[i];
|
|
||||||
|
|
||||||
if (dnat) {
|
|
||||||
if (dnat->new_port)
|
|
||||||
new_addr.sin_port = htons(dnat->new_port);
|
|
||||||
else
|
|
||||||
new_addr.sin_port = htons(port);
|
|
||||||
new_addr.sin_addr = dnat->new_dst;
|
|
||||||
|
|
||||||
addr = (struct sockaddr *)&new_addr;
|
|
||||||
p_addr_in = &((struct sockaddr_in *) addr)->sin_addr;
|
|
||||||
port = ntohs(((struct sockaddr_in *) addr)->sin_port);
|
|
||||||
}
|
|
||||||
|
|
||||||
for(i = 0; i < num_localnet_addr && !remote_dns_connect; i++) {
|
for(i = 0; i < num_localnet_addr && !remote_dns_connect; i++) {
|
||||||
if((localnet_addr[i].in_addr.s_addr & localnet_addr[i].netmask.s_addr)
|
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)) {
|
== (p_addr_in->s_addr & localnet_addr[i].netmask.s_addr)) {
|
||||||
@ -551,11 +424,7 @@ int getnameinfo(const struct sockaddr *sa,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (defined __linux__) || (defined __APPLE__)
|
|
||||||
struct hostent *gethostbyaddr(const void *addr, socklen_t len, int type) {
|
struct hostent *gethostbyaddr(const void *addr, socklen_t len, int type) {
|
||||||
#else
|
|
||||||
struct hostent *gethostbyaddr(const char *addr, socklen_t len, int type) {
|
|
||||||
#endif
|
|
||||||
static char buf[16];
|
static char buf[16];
|
||||||
static char ipv4[4];
|
static char ipv4[4];
|
||||||
static char *list[2];
|
static char *list[2];
|
||||||
|
|||||||
24
src/main.c
24
src/main.c
@ -26,14 +26,10 @@
|
|||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
static int usage(char **argv) {
|
static int usage(char **argv) {
|
||||||
printf( "\nProxychains4: %d.%d.%d\n"
|
printf("\nUsage:\t%s -q -f config_file program_name [arguments]\n"
|
||||||
"Usage:\t%s -q -f config_file program_name [arguments]\n"
|
"\t-q makes proxychains quiet - this overrides the config setting\n"
|
||||||
"\t-v print version and exit\n"
|
"\t-t allows to manually specify a configfile to use\n"
|
||||||
"\t-q makes proxychains quiet - this overrides the config setting\n"
|
"\tfor example : proxychains telnet somehost.com\n" "More help in README file\n\n", argv[0]);
|
||||||
"\t-f allows to manually specify a configfile to use\n"
|
|
||||||
"\n\tfor example : proxychains telnet somehost.com\n"
|
|
||||||
"\n\tMore help in README file\n\n", PROXYCHAINS_VERSION_MAJOR,
|
|
||||||
PROXYCHAINS_VERSION_MINOR, PROXYCHAINS_VERSION_BUGFIX, argv[0]);
|
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,7 +37,7 @@ static const char *dll_name = DLL_NAME;
|
|||||||
|
|
||||||
static char own_dir[256];
|
static char own_dir[256];
|
||||||
static const char *dll_dirs[] = {
|
static const char *dll_dirs[] = {
|
||||||
//".",
|
".",
|
||||||
own_dir,
|
own_dir,
|
||||||
LIB_DIR,
|
LIB_DIR,
|
||||||
"/lib",
|
"/lib",
|
||||||
@ -56,8 +52,7 @@ static void set_own_dir(const char *argv0) {
|
|||||||
while(l && argv0[l - 1] != '/')
|
while(l && argv0[l - 1] != '/')
|
||||||
l--;
|
l--;
|
||||||
if(l == 0)
|
if(l == 0)
|
||||||
//memcpy(own_dir, ".", 2);
|
memcpy(own_dir, ".", 2);
|
||||||
memcpy(own_dir, "/dev/null/", 2);
|
|
||||||
else {
|
else {
|
||||||
memcpy(own_dir, argv0, l - 1);
|
memcpy(own_dir, argv0, l - 1);
|
||||||
own_dir[l] = 0;
|
own_dir[l] = 0;
|
||||||
@ -81,10 +76,6 @@ int main(int argc, char *argv[]) {
|
|||||||
if(argv[start_argv][1] == 'q') {
|
if(argv[start_argv][1] == 'q') {
|
||||||
quiet = 1;
|
quiet = 1;
|
||||||
start_argv++;
|
start_argv++;
|
||||||
} else if(argv[start_argv][1] == 'v') {
|
|
||||||
printf("Proxychains4 version: %d.%d.%d\n", PROXYCHAINS_VERSION_MAJOR, PROXYCHAINS_VERSION_MINOR, PROXYCHAINS_VERSION_BUGFIX);
|
|
||||||
exit(EXIT_SUCCESS);
|
|
||||||
|
|
||||||
} else if(argv[start_argv][1] == 'f') {
|
} else if(argv[start_argv][1] == 'f') {
|
||||||
|
|
||||||
if(start_argv + 1 < argc)
|
if(start_argv + 1 < argc)
|
||||||
@ -115,7 +106,6 @@ int main(int argc, char *argv[]) {
|
|||||||
// search DLL
|
// search DLL
|
||||||
set_own_dir(argv[0]);
|
set_own_dir(argv[0]);
|
||||||
|
|
||||||
i = 0;
|
|
||||||
while(dll_dirs[i]) {
|
while(dll_dirs[i]) {
|
||||||
snprintf(buf, sizeof(buf), "%s/%s", dll_dirs[i], dll_name);
|
snprintf(buf, sizeof(buf), "%s/%s", dll_dirs[i], dll_name);
|
||||||
if(access(buf, R_OK) != -1) {
|
if(access(buf, R_OK) != -1) {
|
||||||
@ -126,7 +116,7 @@ int main(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!prefix) {
|
if(!prefix) {
|
||||||
fprintf(stderr, "couldn't locate %s\n", dll_name);
|
fprintf(stderr, "couldnt locate %s\n", dll_name);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -4,7 +4,7 @@ echo "ProxyChains-4.0 (https://github.com/haad/proxychains)"
|
|||||||
usage() {
|
usage() {
|
||||||
|
|
||||||
echo " usage:"
|
echo " usage:"
|
||||||
echo " $0 [hqv] [-f config-file] <prog> [args]"
|
echo " $0 [hq] [-f config-file] <prog> [args]"
|
||||||
echo " -q make proxychains quiet"
|
echo " -q make proxychains quiet"
|
||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
|
|||||||
@ -73,24 +73,6 @@ localnet 127.0.0.0/255.0.0.0
|
|||||||
## Exclude connections to ANYwhere with port 80
|
## Exclude connections to ANYwhere with port 80
|
||||||
# localnet 0.0.0.0:80/0.0.0.0
|
# localnet 0.0.0.0:80/0.0.0.0
|
||||||
|
|
||||||
|
|
||||||
### Examples for dnat
|
|
||||||
## Trying to proxy connections to destinations which are dnatted,
|
|
||||||
## will result in proxying connections to the new given destinations.
|
|
||||||
## Whenever I connect to 1.1.1.1 on port 1234 actually connect to 1.1.1.2 on port 443
|
|
||||||
# dnat 1.1.1.1:1234 1.1.1.2:443
|
|
||||||
|
|
||||||
## Whenever I connect to 1.1.1.1 on port 443 actually connect to 1.1.1.2 on port 443
|
|
||||||
## (no need to write :443 again)
|
|
||||||
# dnat 1.1.1.2:443 1.1.1.2
|
|
||||||
|
|
||||||
## No matter what port I connect to on 1.1.1.1 port actually connect to 1.1.1.2 on port 443
|
|
||||||
# dnat 1.1.1.1 1.1.1.2:443
|
|
||||||
|
|
||||||
## Always, instead of connecting to 1.1.1.1, connect to 1.1.1.2
|
|
||||||
# dnat 1.1.1.1 1.1.1.2
|
|
||||||
|
|
||||||
|
|
||||||
# ProxyList format
|
# ProxyList format
|
||||||
# type host port [user pass]
|
# type host port [user pass]
|
||||||
# (values separated by 'tab' or 'blank')
|
# (values separated by 'tab' or 'blank')
|
||||||
@ -104,13 +86,12 @@ localnet 127.0.0.0/255.0.0.0
|
|||||||
# http 192.168.39.93 8080
|
# http 192.168.39.93 8080
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# proxy types: http, socks4, socks5, raw
|
# proxy types: http, socks4, socks5
|
||||||
# * raw: The traffic is simply forwarded to the proxy without modification.
|
|
||||||
# ( auth types supported: "basic"-http "user/pass"-socks )
|
# ( auth types supported: "basic"-http "user/pass"-socks )
|
||||||
#
|
#
|
||||||
[ProxyList]
|
[ProxyList]
|
||||||
# add proxy here ...
|
# add proxy here ...
|
||||||
# meanwhile
|
# meanwile
|
||||||
# defaults set to "tor"
|
# defaults set to "tor"
|
||||||
socks4 127.0.0.1 9050
|
socks4 127.0.0.1 9050
|
||||||
|
|
||||||
|
|||||||
@ -2,12 +2,8 @@
|
|||||||
# This script is called by proxychains to resolve DNS names
|
# This script is called by proxychains to resolve DNS names
|
||||||
|
|
||||||
# DNS server used to resolve names
|
# DNS server used to resolve names
|
||||||
|
DNS_SERVER=4.2.2.2
|
||||||
|
|
||||||
if [ -z "$PROXY_DNS_SERVER" ] ; then
|
|
||||||
DNS_SERVER=208.67.222.222 # OpenDNS
|
|
||||||
else
|
|
||||||
DNS_SERVER=$PROXY_DNS_SERVER
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ $# = 0 ] ; then
|
if [ $# = 0 ] ; then
|
||||||
echo " usage:"
|
echo " usage:"
|
||||||
@ -15,10 +11,6 @@ if [ $# = 0 ] ; then
|
|||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
awk 'BEGIN{ARGC=0} {for(i=2;i<=NF;i++){if($i==ARGV[1] && $1!~":"){print $1;found=1}} } END{exit found?0:1}' "$1" </etc/hosts
|
|
||||||
if [ "$?" -eq "0" ]; then
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
export LD_PRELOAD=libproxychains.so
|
export LD_PRELOAD=libproxychains.so
|
||||||
drill $1 @$DNS_SERVER -t | awk '/A.+[0-9]+\.[0-9]+\.[0-9]/{print $5;}'
|
dig $1 @$DNS_SERVER +tcp | awk '/A.+[0-9]+\.[0-9]+\.[0-9]/{print $5;}'
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user