This is an example of remotely loading an image from a Tor Hidden Service into a Java applet to display for a user not using the Tor Client.
Let's start with the web server set up. This is where the applet and Tor Client/Privoxy will be hosted.
Step 1) With a web server of your choosing Apache, Nginx, PHP, install and configure a Tor Client and Privoxy Service on this web server. This is what our applet will use to access the image on the .onion service.
Code: Select all
apt-get install tor
apt-get install privoxy
Code: Select all
forward-socks4a / localhost:9050 .
Code: Select all
listen-address xx.xxx.xxx.xxx:8118
You will need the .onion domain address for the applet. See the Tor docs on configuring a Tor hidden service.
Step 3) On your development system compile and self sign the Java code (the code will be posted below).
Quick guide to self sign the code
Code: Select all
javac LoadImage.java
jar cvf LoadImage.jar LoadImage.class
keytool -genkey -validity 3650 -keystore pKeyStore -alias keyName
keytool -selfcert -keystore pKeyStore -alias keyName -validity 3650
jarsigner -keystore pKeyStore LoadImage.jar keyName
LoadImage.java
Code: Select all
import java.awt.Image;
import javax.imageio.*;
import java.io.*;
import java.net.*;
import javax.swing.ImageIcon;
import javax.swing.JApplet;
import javax.swing.JFrame;
import javax.swing.JLabel;
import java.awt.Dimension;
import java.awt.image.BufferedImage;
import java.lang.*;
public class LoadImage extends JApplet
{
Image image;
public LoadImage()
{
try {
SocketAddress address = new InetSocketAddress("xx.xx.xxx.xx", 8118);
Proxy proxy = new Proxy(Proxy.Type.HTTP, address);
URL url = new URL("http://1234ABCD.onion/mabo/static/mountains.png");
URLConnection conn = url.openConnection(proxy);
InputStream inStream = conn.getInputStream();
BufferedImage image = ImageIO.read(inStream);
JLabel label = new JLabel(new ImageIcon(image));
label.setMinimumSize(new Dimension(200, 200));
this.add(label);
setVisible(true);
}
catch (Exception e) {
e.printStackTrace();
}
}
}
Code: Select all
<applet archive="LoadImage.jar" codebase="http://tofolderwithapplet/cryaboutit/static/" code="LoadImage.class" width="420" height="280"></applet>
*cheers
Thanks to Gogeta and Cats for there assistance and support in figuring this out.
-----------------------
This link will expire but here is a temporary example: Link Expired