0

I am trying to create a computerized bot to hit a particular website through HTTP connection through different IPs mostly through proxies.

I have created script based on following code

System.getProperties().put( "proxySet", "true" );
System.setProperty("http.proxyHost", "<PROXY IP>");
System.setProperty("http.proxyPort", "<PORT>");

ourURL = new URL("<TARGET WEBSITE>");
huc = (HttpURLConnection) ourURL.openConnection();
huc.setRequestMethod("GET");

But the problem in above code is when I check referring url, it takes my public IP only and not the proxy IP. Can someone help me in fixing this.

Safi Baig
  • 89
  • 1
  • 3
  • 12
  • what does your proxy code do to remove the referring url. The proxy may just be passing it through (or adding it). – Scary Wombat May 02 '14 at 06:49
  • I am checking referring url through the target website's analytics. If I am not wrong, this would be the path of bot. PROGRAM->MY PUBLIC IP->PROXY IP->TARGET WEBSITE. This was target website should take proxy IP. – Safi Baig May 02 '14 at 06:55
  • But unless your proxy is written to hide such information then it would still remain. There are other uses for proxy servers other than just to hide your ip address. – Scary Wombat May 02 '14 at 06:57
  • So you say that there is no way I can hide my IP. Basically I am trying out to create artificial visitors for the target website from different IPs. This is only for experimental purpose only if it can be done. – Safi Baig May 02 '14 at 07:00
  • Yes, there are some proxy servers which will do exactly what you want. Try searching for `hide my ip address proxy server` – Scary Wombat May 02 '14 at 07:05
  • see http://whatismyipaddress.com/proxy-server – Scary Wombat May 02 '14 at 07:09
  • This is through website. Also it shows unknown IP. How can we do it through code. Like say I have 100 proxy IPs in my db and want to hit the website through these IPs on a certain interval. – Safi Baig May 02 '14 at 07:31
  • You mean you want to use false ip addresses rather than having the ip address stripped? – Scary Wombat May 02 '14 at 07:42
  • If so see http://stackoverflow.com/questions/5317513/c-sharp-how-to-spoof-ip-address-for-webrequest – Scary Wombat May 02 '14 at 07:45

1 Answers1

1

As of java 1.5, you need to use something like the code below for proxy before openConnection:

System.setProperty("http.proxyHost", "proxy.****.com");
System.setProperty("http.proxyPort", "####");
 Authenticator authenticator = new Authenticator() {
                public PasswordAuthentication getPasswordAuthentication() {
                    return (new PasswordAuthentication("user",
                            "pwd".toCharArray()));
                }
            };
Authenticator.setDefault(authenticator);
Hirak
  • 3,601
  • 1
  • 22
  • 33