Skip to content

Commit aabf9df

Browse files
committed
v5.60 rewrite core functions (check change log)
1 parent d0b562c commit aabf9df

File tree

4 files changed

+317
-297
lines changed

4 files changed

+317
-297
lines changed

README.md

+24-12
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
ProxyBound v5.50
1+
ProxyBound v5.60
22
================
33

4-
ProxyBound 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. This is based on proxychains-ng by rofl0r, proxychains by haad and torsocks by dgoulet
4+
ProxyBound force any unix application to use a specific proxy and prevent it from leaking the original ip; Technically, ProxyBound 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. This project is based on proxychain by [netcreature](https://sourceforge.net/u/netcreature/profile/), proxychains-ng by rofl0r, proxychains by haad and torsocks by dgoulet
55

66
Features:
77
=========
88

99
- Proxify applications (like mainstream proxychains)
1010
- Works with tcp (like mainstream proxychains)
11-
- No leaks over udp/raw/icmp/etc...
11+
- No leaks over udp/icmp/etc... (INET & INET6)
1212
- Unsupported protocols are blocked
13-
- Works with chrome/chromium/similar
13+
- Support chrome/chromium/skype/similar
1414
- Incompatible applications are terminated with a proper message
1515
- Many additional settings over environment variable
1616
- etc.
@@ -25,7 +25,7 @@ Used environment variable:
2525
- PROXYBOUND_SOCKS5_PORT: Socks 5 port (default not used)
2626
- PROXYBOUND_FORCE_DNS: Force dns resolv requests through (1 or 0, default 1)
2727
- PROXYBOUND_ALLOW_DNS: Allow direct dns, allow udp port 53 and 853 (1 or 0, default 0)
28-
- PROXYBOUND_ALLOW_LEAKS: Allow/Block unproxyfied protocols "UDP/ICMP/RAW", blocked by default (1 or 0, default 0)
28+
- PROXYBOUND_ALLOW_LEAKS: Allow/Block unproxyfied protocols "UDP/ICMP/ETC", blocked by default (1 or 0, default 0)
2929
- PROXYBOUND_WORKING_INDICATOR: Create '/tmp/proxybound.tmp' when dll is working as intended (1 or 0, default 0)
3030
```
3131

@@ -34,12 +34,6 @@ How it works:
3434

3535
Proxybound hook libc functions like connect(), dynamic loader facilities are used, namely dl_sym() and LD_PRELOAD thus dynamically linked programs are required.
3636

37-
Limits :
38-
========
39-
40-
- IPv6 is blocked and is not supported
41-
- Some applications are incompatible (they will be explicitly terminated 2 sec after startup, to avoid leaks)
42-
4337
Install:
4438
========
4539

@@ -49,7 +43,7 @@ Install:
4943
[optional] sudo make install
5044
```
5145

52-
if you dont install, you can use proxybound from the build directory like this: `./proxybound -f src/proxybound.conf telnet google.com 80`
46+
If you dont install, you can use proxybound from the build directory like this: `./proxybound -f src/proxybound.conf telnet google.com 80`
5347

5448
Install debug version :
5549
=======================
@@ -63,6 +57,18 @@ Install debug version :
6357
Changelog:
6458
==========
6559

60+
**Version 5.60:**
61+
62+
- Fix skype compatibility
63+
- Improve no leak feature
64+
- Improve debug version
65+
- Improve output/log messages
66+
- Rewrite main hooked functions connect
67+
- Rewrite main hooked functions bind
68+
- Rewrite main hooked functions sendmsg
69+
- Rewrite main hooked functions sendto
70+
- Rewrite main hooked functions send
71+
6672
**Version 5.50:**
6773

6874
- Block non tcp packet on send()
@@ -128,6 +134,12 @@ Changelog:
128134
- Import security issue fix CVE-2015-3887
129135
- Used v4.3 (4.03) for initial fork
130136

137+
Limits :
138+
========
139+
140+
- IPv6 is blocked and not supported (currently partially supported)
141+
- Some applications are incompatible (they will be explicitly terminated 2 sec after startup, to avoid leaks)
142+
131143
Configuration:
132144
==============
133145

src/core.c

+26-27
Original file line numberDiff line numberDiff line change
@@ -225,15 +225,15 @@ static int timed_connect(int sock, const struct sockaddr *addr, socklen_t len) {
225225
pfd[0].events = POLLOUT;
226226
fcntl(sock, F_SETFL, O_NONBLOCK);
227227
ret = true_connect(sock, addr, len);
228-
PDEBUG("\nconnect ret=%d\n", ret);
228+
PDEBUG("timed_connect: core.c: ret=%d\n", ret);
229229

230230
if(ret == -1 && errno == EINPROGRESS) {
231231
ret = poll_retry(pfd, 1, tcp_connect_time_out);
232-
PDEBUG("\npoll ret=%d\n", ret);
232+
PDEBUG("timed_connect: core.c: poll ret=%d\n", ret);
233233
if(ret == 1) {
234234
value_len = sizeof(socklen_t);
235235
getsockopt(sock, SOL_SOCKET, SO_ERROR, &value, &value_len);
236-
PDEBUG("\nvalue=%d\n", value);
236+
PDEBUG("timed_connect: core.c: value=%d\n", value);
237237
if(!value)
238238
ret = 0;
239239
else
@@ -259,7 +259,7 @@ static int tunnel_to(int sock, ip_type ip, unsigned short port, proxy_type pt, c
259259
char *dns_name = NULL;
260260
size_t dns_len = 0;
261261

262-
PDEBUG("tunnel_to()\n");
262+
PDEBUG("tunnel_to: core.c: init tunnel_to()\n");
263263

264264
// we use ip addresses with 224.* to lookup their dns name in our table, to allow remote DNS resolution
265265
// the range 224-255.* is reserved, and it won't go outside (unless the app does some other stuff with
@@ -274,13 +274,13 @@ static int tunnel_to(int sock, ip_type ip, unsigned short port, proxy_type pt, c
274274
goto err;
275275
}
276276

277-
PDEBUG("host dns %s\n", dns_name ? dns_name : "<NULL>");
277+
PDEBUG("tunnel_to: core.c: host dns %s\n", dns_name ? dns_name : "<NULL>");
278278

279279
size_t ulen = strlen(user);
280280
size_t passlen = strlen(pass);
281281

282282
if(ulen > 0xFF || passlen > 0xFF || dns_len > 0xFF) {
283-
proxybound_write_log(LOG_PREFIX "error: maximum size of 255 for user/pass or domain name!\n");
283+
proxybound_write_log(LOG_PREFIX "ERROR: USER+PASS/DOMAIN SIZE EXCEEDS MAX VALUE OF 255!\n\n\n");
284284
goto err;
285285
}
286286

@@ -493,7 +493,7 @@ static int tunnel_to(int sock, ip_type ip, unsigned short port, proxy_type pt, c
493493
return SOCKET_ERROR;
494494
}
495495

496-
#define TP " ... "
496+
#define TP "... "
497497
#define DT "Dynamic chain"
498498
#define ST "Strict chain"
499499
#define RT "Random chain"
@@ -507,8 +507,7 @@ static int start_chain(int *fd, proxy_data * pd, char *begin_mark) {
507507
goto error;
508508

509509
pc_stringfromipv4(&pd->ip.octet[0], ip_buf);
510-
proxybound_write_log(LOG_PREFIX "%s " TP " %s:%d ",
511-
begin_mark, ip_buf, htons(pd->port));
510+
proxybound_write_log(LOG_PREFIX "%s " TP "%s:%d\n", begin_mark, ip_buf, htons(pd->port));
512511
pd->ps = PLAY_STATE;
513512
memset(&addr, 0, sizeof(addr));
514513
addr.sin_family = AF_INET;
@@ -521,7 +520,7 @@ static int start_chain(int *fd, proxy_data * pd, char *begin_mark) {
521520
pd->ps = BUSY_STATE;
522521
return SUCCESS;
523522
error1:
524-
proxybound_write_log(TP " timeout\n");
523+
proxybound_write_log(LOG_PREFIX TP "timeout\n");
525524
error:
526525
if(*fd != -1)
527526
close(*fd);
@@ -599,7 +598,7 @@ static int chain_step(int ns, proxy_data * pfrom, proxy_data * pto) {
599598
char *hostname;
600599
char ip_buf[16];
601600

602-
PDEBUG("chain_step()\n");
601+
PDEBUG("chain_step: core.c: init chain_step()\n");
603602

604603
if(pto->ip.octet[0] == remote_dns_subnet) {
605604
hostname = string_from_internal_ip(pto->ip);
@@ -611,20 +610,20 @@ static int chain_step(int ns, proxy_data * pfrom, proxy_data * pto) {
611610
hostname = ip_buf;
612611
}
613612

614-
proxybound_write_log(TP " %s:%d ", hostname, htons(pto->port));
613+
proxybound_write_log(LOG_PREFIX TP "%s:%d\n", hostname, htons(pto->port));
615614
retcode = tunnel_to(ns, pto->ip, pto->port, pfrom->pt, pfrom->user, pfrom->pass);
616615
switch (retcode) {
617616
case SUCCESS:
618617
pto->ps = BUSY_STATE;
619618
break;
620619
case BLOCKED:
621620
pto->ps = BLOCKED_STATE;
622-
proxybound_write_log("<--denied\n");
621+
proxybound_write_log(LOG_PREFIX "denied\n");
623622
close(ns);
624623
break;
625624
case SOCKET_ERROR:
626625
pto->ps = DOWN_STATE;
627-
proxybound_write_log("<--socket error or timeout!\n");
626+
proxybound_write_log(LOG_PREFIX "socket error or timeout!\n");
628627
close(ns);
629628
break;
630629
}
@@ -643,7 +642,7 @@ int connect_proxy_chain(int sock, ip_type target_ip,
643642

644643
p3 = &p4;
645644

646-
PDEBUG("connect_proxy_chain\n");
645+
PDEBUG("connect: core.c: connect_proxy_chain\n");
647646

648647
again:
649648

@@ -660,7 +659,7 @@ int connect_proxy_chain(int sock, ip_type target_ip,
660659
if(!p2)
661660
break;
662661
if(SUCCESS != chain_step(ns, p1, p2)) {
663-
PDEBUG("GOTO AGAIN 1\n");
662+
PDEBUG("connect: core.c: goto again x1\n");
664663
goto again;
665664
}
666665
p1 = p2;
@@ -676,18 +675,18 @@ int connect_proxy_chain(int sock, ip_type target_ip,
676675
alive_count = calc_alive(pd, proxy_count);
677676
offset = 0;
678677
if(!(p1 = select_proxy(FIFOLY, pd, proxy_count, &offset))) {
679-
PDEBUG("select_proxy failed\n");
678+
PDEBUG("connect: core.c: select_proxy failed\n");
680679
goto error_strict;
681680
}
682681
if(SUCCESS != start_chain(&ns, p1, ST)) {
683-
PDEBUG("start_chain failed\n");
682+
PDEBUG("connect: core.c: start_chain failed\n");
684683
goto error_strict;
685684
}
686685
while(offset < proxy_count) {
687686
if(!(p2 = select_proxy(FIFOLY, pd, proxy_count, &offset)))
688687
break;
689688
if(SUCCESS != chain_step(ns, p1, p2)) {
690-
PDEBUG("chain_step failed\n");
689+
PDEBUG("connect: core.c: chain_step failed\n");
691690
goto error_strict;
692691
}
693692
p1 = p2;
@@ -712,7 +711,7 @@ int connect_proxy_chain(int sock, ip_type target_ip,
712711
if(!(p2 = select_proxy(RANDOMLY, pd, proxy_count, &offset)))
713712
goto error_more;
714713
if(SUCCESS != chain_step(ns, p1, p2)) {
715-
PDEBUG("GOTO AGAIN 2\n");
714+
PDEBUG("connect: core.c: goto again x2\n");
716715
goto again;
717716
}
718717
p1 = p2;
@@ -725,7 +724,7 @@ int connect_proxy_chain(int sock, ip_type target_ip,
725724

726725
}
727726

728-
proxybound_write_log(TP " OK\n");
727+
proxybound_write_log(LOG_PREFIX TP "ok\n");
729728
dup2(ns, sock);
730729
close(ns);
731730
return 0;
@@ -736,9 +735,9 @@ int connect_proxy_chain(int sock, ip_type target_ip,
736735
return -1;
737736

738737
error_more:
739-
proxybound_write_log("\n!!!need more proxies!!!\n");
738+
proxybound_write_log(LOG_PREFIX "ERROR: NEED MORE PROXIES!\n\n\n");
740739
error_strict:
741-
PDEBUG("error\n");
740+
PDEBUG("connect: core.c: error\n");
742741

743742
release_all(pd, proxy_count);
744743
if(ns != -1)
@@ -800,23 +799,23 @@ struct hostent *proxy_gethostbyname(const char *name, struct gethostbyname_data*
800799
for(i = 0; i < internal_ips.counter; i++) {
801800
if(internal_ips.list[i]->hash == hash && !strcmp(name, internal_ips.list[i]->string)) {
802801
data->resolved_addr = make_internal_ip(i);
803-
PDEBUG("got cached ip for %s\n", name);
802+
PDEBUG("proxy_gethostbyname: core.c: got cached ip for %s\n", name);
804803
goto have_ip;
805804
}
806805
}
807806
}
808807

809808
// grow list if needed.
810809
if(internal_ips.capa < internal_ips.counter + 1) {
811-
PDEBUG("realloc\n");
810+
PDEBUG("proxy_gethostbyname: core.c: realloc\n");
812811
new_mem = realloc(internal_ips.list, (internal_ips.capa + 16) * sizeof(void *));
813812
if(new_mem) {
814813
internal_ips.capa += 16;
815814
internal_ips.list = new_mem;
816815
} else {
817816
// goto ------------
818817
oom:
819-
proxybound_write_log("out of mem\n");
818+
proxybound_write_log(LOG_PREFIX "ERROR: OUT OF MEMORY!\n\n\n");
820819
goto err_plus_unlock;
821820
}
822821
}
@@ -830,7 +829,7 @@ struct hostent *proxy_gethostbyname(const char *name, struct gethostbyname_data*
830829
if(!new_mem)
831830
goto oom;
832831

833-
PDEBUG("creating new entry %d for ip of %s\n", (int) internal_ips.counter, name);
832+
PDEBUG("proxy_gethostbyname: core.c: creating new entry %d for ip of %s\n", (int) internal_ips.counter, name);
834833

835834
internal_ips.list[internal_ips.counter] = new_mem;
836835
internal_ips.list[internal_ips.counter]->hash = hash;

0 commit comments

Comments
 (0)