Code Monkey home page Code Monkey logo

Comments (6)

rofl0r avatar rofl0r commented on May 28, 2024 1

oh, i finally get what this is really about:
basically we have a number of different processes that all use the same proxychains config, and when launching those in the same second they're all seeded with the same value and return same rand() result and therefore select the same proxy from the list. i guess we can fix that by using clock_gettime() to initialize srand(). i'll look into writing a fix tomorrow.

from doxycannon.

audibleblink avatar audibleblink commented on May 28, 2024

@rofl0r thanks for the heads up. def fooled me.

unsure about the ng fork. i won't be able to check for a while, but I'll ping you again when life circumstances allow.

from doxycannon.

rofl0r avatar rofl0r commented on May 28, 2024

i suspect it will work as expected, because the original proxychains 3.1 code used a bogus method to get a random number, which we fixed. it should not be needed to reseed the rng all the time, a single srand() on startup should be sufficient.

from doxycannon.

audibleblink avatar audibleblink commented on May 28, 2024

hey @rofl0r

Sorry it took me so long to look at this. I built from today's master of your fork.

I used the following proxychain4.conf and seemed to be getting similar behavior to what I describe in the readme.

random_chain
quiet_mode
proxy_dns
remote_dns_subnet 224
tcp_read_time_out 15000
tcp_connect_time_out 8000

[ProxyList]
socks5 127.0.0.1 9000
socks5 127.0.0.1 9001
socks5 127.0.0.1 9002
socks5 127.0.0.1 9003
socks5 127.0.0.1 9004
socks5 127.0.0.1 9005
socks5 127.0.0.1 9006
socks5 127.0.0.1 9007
socks5 127.0.0.1 9008
socks5 127.0.0.1 9009

Inserting a sleep ensures a more random distribution between proxies:

$ while :; do curl ifconfig.io; sleep 1.1 ; done

185.112.146.85
185.220.100.254
104.244.75.80
185.220.100.254
198.144.120.234
107.189.10.119


$ while :; do curl ifconfig.io; done

185.191.124.151
185.191.124.151
185.220.100.254
185.220.100.254
185.220.100.254
185.112.146.85
185.112.146.85
107.189.10.119

from doxycannon.

audibleblink avatar audibleblink commented on May 28, 2024

This was the original patch on the haad fork

From bd207014a20b41554207fc9ac9457e61ab570429 Mon Sep 17 00:00:00 2001
From: Alex Flores <[email protected]>
Date: Fri, 30 Mar 2018 14:14:18 -0400
Subject: [PATCH] patch for better random proxy selection

---
 src/core.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/src/core.c b/src/core.c
index c3a624d..b0e3f21 100644
--- a/src/core.c
+++ b/src/core.c
@@ -514,6 +514,19 @@ static int start_chain(int *fd, proxy_data * pd, char *begin_mark) {
 	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 (rand() % range);
+    }
+}
 
 static proxy_data *select_proxy(select_type how, proxy_data * pd, unsigned int proxy_count, unsigned int *offset) {
 	unsigned int i = 0, k = 0;
@@ -522,10 +535,10 @@ static proxy_data *select_proxy(select_type how, proxy_data * pd, unsigned int p
 		return NULL;
 	switch (how) {
 		case RANDOMLY:
-			srand((unsigned int)time(NULL));
+
 			do {
 				k++;
-				i = 0 + (unsigned int) (proxy_count * 1.0 * rand() / (RAND_MAX + 1.0));
+				i = 0 + get_rand_int(proxy_count);
 			} while(pd[i].ps != PLAY_STATE && k < proxy_count * 100);
 			break;
 		case FIFOLY:

from doxycannon.

audibleblink avatar audibleblink commented on May 28, 2024

With my shitty C code (same from above) applied to your fork, I'm getting a more random distribution.

$ while :; do curl ifconfig.io; done
51.15.250.93
185.220.101.17
94.230.208.147
185.220.101.17
87.118.110.27
94.230.208.147
185.220.101.17
185.220.101.194
185.220.100.254
51.15.250.93
185.220.101.205
87.118.110.27
54.38.22.61
^C

from doxycannon.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.