1
/* -*-mode:java; c-basic-offset:2; -*- */
2
import com.jcraft.jsch.*;
4
import java.awt.event.*;
7
public class ViaSOCKS5{
8
public static void main(String[] arg){
16
String host=JOptionPane.showInputDialog("Enter username@hostname",
17
System.getProperty("user.name")+
19
String user=host.substring(0, host.indexOf('@'));
20
host=host.substring(host.indexOf('@')+1);
22
Session session=jsch.getSession(user, host, 22);
24
String proxy=JOptionPane.showInputDialog("Enter proxy server",
26
proxy_host=proxy.substring(0, proxy.indexOf(':'));
27
proxy_port=Integer.parseInt(proxy.substring(proxy.indexOf(':')+1));
29
session.setProxy(new ProxySOCKS5(proxy_host, proxy_port));
31
// username and password will be given via UserInfo interface.
32
UserInfo ui=new MyUserInfo();
33
session.setUserInfo(ui);
35
//java.util.Hashtable config=new java.util.Hashtable();
36
//config.put("compression.s2c", "zlib,non");
37
//config.put("compression.c2s", "zlib,none");
38
//session.setConfig(config);
42
Channel channel=session.openChannel("shell");
44
channel.setInputStream(System.in);
45
channel.setOutputStream(System.out);
50
System.out.println(e);
54
public static class MyUserInfo implements UserInfo{
55
public String getPassword(){ return passwd; }
56
public boolean promptYesNo(String str){
57
Object[] options={ "yes", "no" };
58
int foo=JOptionPane.showOptionDialog(null,
61
JOptionPane.DEFAULT_OPTION,
62
JOptionPane.WARNING_MESSAGE,
63
null, options, options[0]);
68
JTextField passwordField=(JTextField)new JPasswordField(20);
70
public String getPassphrase(){ return null; }
71
public boolean promptPassphrase(String message){ return true; }
72
public boolean promptPassword(String message){
73
Object[] ob={passwordField};
75
JOptionPane.showConfirmDialog(null, ob, message,
76
JOptionPane.OK_CANCEL_OPTION);
77
if(result==JOptionPane.OK_OPTION){
78
passwd=passwordField.getText();
83
public void showMessage(String message){
84
JOptionPane.showMessageDialog(null, message);