Java applets and proxies

Assuming I use the following code to connect to the SOCKS5 proxy, will the connections or packets sent by the applet that I create go through the same proxy?

System.getProperties().setProperty("socksProxySet", "true");
System.getProperties().setProperty("socksProxyHost", "*.*.*.*");
System.getProperties().setProperty("socksProxyPort", "*");

An applet is launched using the classloader object from which 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);
+4
source share
2 answers

The answer seems to be 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:

enter image description here

+2
source

Tyler, if I understood your question correctly - yes. But this is due to a caveat: the System properties you set will only be saved through the current JVM instance.

, , JVM, .

+1

Source: https://habr.com/ru/post/1569222/


All Articles