Assuming that I use the following code to connect to a SOCKS5 proxy, would connections or packets sent by an applet that I instantiate go through the same proxy?
System.getProperties().setProperty("socksProxySet", "true");
System.getProperties().setProperty("socksProxyHost", "*.*.*.*");
System.getProperties().setProperty("socksProxyPort", "*");
Applet is started using a classloader object from which a newInstance is created.
classLoader = new CustomClassLoader(/* Hashmap of byte arrays */); // Custom classloader that works using byte arrays
Applet applet = (Applet) classLoader.loadClass("class").newInstance();
applet.setStub(stub);
applet.init();
applet.start();
frame.add(applet);
It appears that the answer to this question is yes.
The following code:
public class TestApplet extends Applet {
private String ip;
public void init() {
try {
URL ipCheck = new URL("http://checkip.amazonaws.com");
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(ipCheck.openStream()));
ip = bufferedReader.readLine();
bufferedReader.close();
} catch (Exception e) {
e.printStackTrace();
}
}
public void stop() {
}
public void paint(Graphics g) {
g.setColor(Color.BLACK);
g.fillRect(0, 0, getWidth(), getHeight());
g.setColor(Color.CYAN);
g.drawString("Current IP: " + ip, 10, 20);
}
}
and
public class Boot {
public static void main(String[] args) {
System.getProperties().setProperty("socksProxySet", "true");
System.getProperties().setProperty("socksProxyHost", "71.9.127.141"); //Credits to HideMyAss.com
System.getProperties().setProperty("socksProxyPort", "28045");//Credits to HideMyAss.com
new Thread(new Runnable() {
@Override
public void run() {
try {
Thread.sleep(5000);
} catch (Exception e) {
e.printStackTrace();
}
TestApplet testApplet = new TestApplet();
testApplet.init();
JFrame jFrame = new JFrame();
jFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
jFrame.setSize(500, 500);
jFrame.setContentPane(testApplet);
jFrame.setVisible(true);
}
}).start();
}
}
Outputs: