Added support for SOCKS v5 Server

CLI only, the switch is "-s".

Accepted formats:
user:password@host
user:password@host:port
host
host:port
This commit is contained in:
randomcommitter 2018-04-18 16:33:09 +01:00 committed by GitHub
parent 1dadd26e05
commit bf056a75d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,7 +7,9 @@ import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileNotFoundException;
import java.net.Authenticator;
import java.net.MalformedURLException;
import java.net.PasswordAuthentication;
import java.net.URL;
import java.util.Arrays;
import java.util.List;
@ -95,6 +97,30 @@ public class App {
Utils.setConfigBoolean("file.overwrite", true);
}
if (cl.hasOption('s')) {
String sservfull = cl.getOptionValue('s').trim();
if (sservfull.lastIndexOf("@") != -1) {
int sservli = sservfull.lastIndexOf("@");
String userpw = sservfull.substring(0, sservli);
String[] usersplit = userpw.split(":");
String user = usersplit[0];
String password = usersplit[1];
Authenticator.setDefault(new Authenticator(){
protected PasswordAuthentication getPasswordAuthentication(){
PasswordAuthentication p = new PasswordAuthentication(user, password.toCharArray());
return p;
}
});
sservfull = sservfull.substring(sservli + 1);
}
String[] servsplit = sservfull.split(":");
if (servsplit.length == 2) {
System.setProperty("socksProxyPort", servsplit[1]);
}
System.setProperty("socksProxyHost", servsplit[0]);
}
if (cl.hasOption('t')) {
Utils.setConfigInteger("threads.size", Integer.parseInt(cl.getOptionValue('t')));
}
@ -195,6 +221,7 @@ public class App {
String url = cl.getOptionValue('u').trim();
ripURL(url, cl.hasOption("n"));
}
}
/**
@ -242,6 +269,7 @@ public class App {
opts.addOption("n", "no-prop-file", false, "Do not create properties file.");
opts.addOption("f", "urls-file", true, "Rip URLs from a file.");
opts.addOption("v", "version", false, "Show current version");
opts.addOption("s", "socks-server", true, "Use socks server ([user:password]@host[:port]");
return opts;
}