mirror of
https://github.com/2006-Scape/Parabot.git
synced 2026-07-07 16:49:10 +00:00
Added authentication to proxies, made a fix of sora for linux users and the transparantcy issue.
This commit is contained in:
@@ -31,6 +31,10 @@ public class ProxySocket extends Socket {
|
|||||||
private InetAddress addr;
|
private InetAddress addr;
|
||||||
private int port;
|
private int port;
|
||||||
|
|
||||||
|
private static String username = null, password = null;
|
||||||
|
|
||||||
|
public static boolean auth = false;
|
||||||
|
|
||||||
private static InetAddress proxyInetAddress = null;
|
private static InetAddress proxyInetAddress = null;
|
||||||
|
|
||||||
private InetSocketAddress cachedAddr;
|
private InetSocketAddress cachedAddr;
|
||||||
@@ -183,14 +187,32 @@ public class ProxySocket extends Socket {
|
|||||||
DataOutputStream out = new DataOutputStream(getOutputStream());
|
DataOutputStream out = new DataOutputStream(getOutputStream());
|
||||||
DataInputStream in = new DataInputStream(getInputStream());
|
DataInputStream in = new DataInputStream(getInputStream());
|
||||||
out.write(0x05); // the version
|
out.write(0x05); // the version
|
||||||
out.write(1); // number of authentication methods (no auth for now)
|
out.write(auth ? 2 : 1); // number of authentication methods (no auth
|
||||||
|
// for now)
|
||||||
out.write(0); // the authentication (none)
|
out.write(0); // the authentication (none)
|
||||||
|
if (auth) {
|
||||||
|
out.write(2);
|
||||||
|
}
|
||||||
out.flush();
|
out.flush();
|
||||||
|
|
||||||
if (in.read() != 0x05) // remote proxy version
|
if (in.read() != 0x05) // remote proxy version
|
||||||
throw new IOException("Proxy server is not supported!");
|
throw new IOException("Proxy server is not supported!");
|
||||||
if (in.read() != 0x00) // make sure shit is a vaild request
|
switch (in.read()) { // auth method
|
||||||
|
case 0:
|
||||||
|
break; // no auth
|
||||||
|
case 2:
|
||||||
|
// username and pass stuff
|
||||||
|
out.write(0x01); // user/pass version #
|
||||||
|
out.write(username.length());
|
||||||
|
out.write(username.getBytes());
|
||||||
|
out.write(password.length());
|
||||||
|
out.write(password.getBytes());
|
||||||
|
out.flush();
|
||||||
|
in.read(); // skip the version
|
||||||
|
if (in.read() == 0) // Successful login, continue
|
||||||
|
break;
|
||||||
|
default:
|
||||||
throw new IOException("Proxy server declined request!");
|
throw new IOException("Proxy server declined request!");
|
||||||
|
}
|
||||||
|
|
||||||
// now to write the actual request
|
// now to write the actual request
|
||||||
out.write(0x05); // again the socks version
|
out.write(0x05); // again the socks version
|
||||||
@@ -271,4 +293,13 @@ public class ProxySocket extends Socket {
|
|||||||
return connections.size();
|
return connections.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void setLogin(String user, char[] pass) {
|
||||||
|
setLogin(user,new String(pass));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setLogin(String user, String pass) {
|
||||||
|
username = user;
|
||||||
|
password = pass;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,11 +1,13 @@
|
|||||||
package org.parabot.core.ui;
|
package org.parabot.core.ui;
|
||||||
|
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
|
||||||
|
import javax.swing.JDialog;
|
||||||
|
|
||||||
import org.parabot.core.ui.components.PaintComponent;
|
import org.parabot.core.ui.components.PaintComponent;
|
||||||
import org.parabot.environment.OperatingSystem;
|
import org.parabot.environment.OperatingSystem;
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
import java.awt.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Everel
|
* @author Everel
|
||||||
@@ -22,7 +24,17 @@ public class BotDialog extends JDialog {
|
|||||||
setUndecorated(true);
|
setUndecorated(true);
|
||||||
getRootPane().setOpaque(false);
|
getRootPane().setOpaque(false);
|
||||||
if (!OperatingSystem.getOS().equals(OperatingSystem.OTHER)) {
|
if (!OperatingSystem.getOS().equals(OperatingSystem.OTHER)) {
|
||||||
|
try {
|
||||||
setBackground(new Color(0, 0, 0, 0));
|
setBackground(new Color(0, 0, 0, 0));
|
||||||
|
} catch (UnsupportedOperationException e) {
|
||||||
|
//My "fix" for the perpixel errors some user have when using VPSes
|
||||||
|
if (e.getMessage().contains("PERPIXEL_TRANS")) {
|
||||||
|
System.err
|
||||||
|
.println("WARNING: We were unable to set a translucent background!"
|
||||||
|
+ "\n\tThis generally occurs with old/outdated graphics drivers. Please consider updating them if possible."
|
||||||
|
+ "\n\tParabot will still attempt to run, however some GUI elements may or may not function.");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
setFocusableWindowState(true);
|
setFocusableWindowState(true);
|
||||||
setPreferredSize(botUI.getSize());
|
setPreferredSize(botUI.getSize());
|
||||||
@@ -54,4 +66,3 @@ public class BotDialog extends JDialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,24 @@
|
|||||||
package org.parabot.core.ui;
|
package org.parabot.core.ui;
|
||||||
|
|
||||||
import org.parabot.core.network.NetworkInterface;
|
import java.awt.event.ActionEvent;
|
||||||
import org.parabot.core.network.proxy.ProxySocket;
|
import java.awt.event.ActionListener;
|
||||||
import org.parabot.core.network.proxy.ProxyType;
|
import java.awt.event.KeyEvent;
|
||||||
import org.parabot.core.ui.utils.UILog;
|
import java.awt.event.KeyListener;
|
||||||
|
import java.net.SocketException;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.Box;
|
||||||
|
import javax.swing.BoxLayout;
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JCheckBox;
|
||||||
|
import javax.swing.JComboBox;
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JList;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JPasswordField;
|
||||||
|
import javax.swing.JScrollPane;
|
||||||
|
import javax.swing.JTextField;
|
||||||
|
import javax.swing.ListSelectionModel;
|
||||||
import javax.swing.border.EmptyBorder;
|
import javax.swing.border.EmptyBorder;
|
||||||
import javax.swing.event.DocumentEvent;
|
import javax.swing.event.DocumentEvent;
|
||||||
import javax.swing.event.DocumentListener;
|
import javax.swing.event.DocumentListener;
|
||||||
@@ -13,11 +26,11 @@ import javax.swing.text.AttributeSet;
|
|||||||
import javax.swing.text.BadLocationException;
|
import javax.swing.text.BadLocationException;
|
||||||
import javax.swing.text.Document;
|
import javax.swing.text.Document;
|
||||||
import javax.swing.text.PlainDocument;
|
import javax.swing.text.PlainDocument;
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
import org.parabot.core.network.NetworkInterface;
|
||||||
import java.awt.event.KeyEvent;
|
import org.parabot.core.network.proxy.ProxySocket;
|
||||||
import java.awt.event.KeyListener;
|
import org.parabot.core.network.proxy.ProxyType;
|
||||||
import java.net.SocketException;
|
import org.parabot.core.ui.utils.UILog;
|
||||||
|
|
||||||
public class NetworkUI extends JFrame implements KeyListener, ActionListener,
|
public class NetworkUI extends JFrame implements KeyListener, ActionListener,
|
||||||
DocumentListener {
|
DocumentListener {
|
||||||
@@ -31,8 +44,12 @@ public class NetworkUI extends JFrame implements KeyListener, ActionListener,
|
|||||||
private IntTextField proxyPort;
|
private IntTextField proxyPort;
|
||||||
private JButton submitButton;
|
private JButton submitButton;
|
||||||
|
|
||||||
JList<String>[] macList;
|
private JList<String>[] macList;
|
||||||
JScrollPane[] macScrollList;
|
private JScrollPane[] macScrollList;
|
||||||
|
|
||||||
|
private JCheckBox authCheckBox;
|
||||||
|
private JTextField authUsername;
|
||||||
|
private JPasswordField authPassword;
|
||||||
|
|
||||||
private NetworkUI() {
|
private NetworkUI() {
|
||||||
initGUI();
|
initGUI();
|
||||||
@@ -58,6 +75,8 @@ public class NetworkUI extends JFrame implements KeyListener, ActionListener,
|
|||||||
proxyType = new JComboBox<ProxyType>(ProxyType.values());
|
proxyType = new JComboBox<ProxyType>(ProxyType.values());
|
||||||
proxyType.setSelectedItem(ProxySocket.getProxyType());
|
proxyType.setSelectedItem(ProxySocket.getProxyType());
|
||||||
|
|
||||||
|
proxyType.addActionListener(this);
|
||||||
|
|
||||||
proxyHost = new JTextField();
|
proxyHost = new JTextField();
|
||||||
proxyHost.addKeyListener(this);
|
proxyHost.addKeyListener(this);
|
||||||
|
|
||||||
@@ -84,6 +103,15 @@ public class NetworkUI extends JFrame implements KeyListener, ActionListener,
|
|||||||
macList[i].ensureIndexIsVisible(value > 0 ? value - 1 : value);
|
macList[i].ensureIndexIsVisible(value > 0 ? value - 1 : value);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
authCheckBox = new JCheckBox("Auth");
|
||||||
|
authCheckBox.addActionListener(this);
|
||||||
|
|
||||||
|
authUsername = new JTextField();
|
||||||
|
authUsername.setEnabled(false);
|
||||||
|
authPassword = new JPasswordField();
|
||||||
|
authPassword.setEnabled(false);
|
||||||
|
|
||||||
JPanel p = createPanelUI();
|
JPanel p = createPanelUI();
|
||||||
add(p);
|
add(p);
|
||||||
setResizable(false);
|
setResizable(false);
|
||||||
@@ -109,6 +137,19 @@ public class NetworkUI extends JFrame implements KeyListener, ActionListener,
|
|||||||
port.add(new JLabel("Proxy Port: "));
|
port.add(new JLabel("Proxy Port: "));
|
||||||
port.add(proxyPort);
|
port.add(proxyPort);
|
||||||
|
|
||||||
|
Box auth = Box.createHorizontalBox();
|
||||||
|
auth.add(authCheckBox);
|
||||||
|
|
||||||
|
auth.add(Box.createHorizontalStrut(3));
|
||||||
|
|
||||||
|
auth.add(new JLabel("User:"));
|
||||||
|
auth.add(authUsername);
|
||||||
|
|
||||||
|
auth.add(Box.createHorizontalStrut(3));
|
||||||
|
|
||||||
|
auth.add(new JLabel("Pass:"));
|
||||||
|
auth.add(authPassword);
|
||||||
|
|
||||||
Box macBox = Box.createHorizontalBox();
|
Box macBox = Box.createHorizontalBox();
|
||||||
macBox.add(new JLabel("MAC:"));
|
macBox.add(new JLabel("MAC:"));
|
||||||
for (int i = 0; i < macList.length; i++) {
|
for (int i = 0; i < macList.length; i++) {
|
||||||
@@ -127,6 +168,9 @@ public class NetworkUI extends JFrame implements KeyListener, ActionListener,
|
|||||||
main.add(Box.createVerticalStrut(5));
|
main.add(Box.createVerticalStrut(5));
|
||||||
main.add(port);
|
main.add(port);
|
||||||
|
|
||||||
|
main.add(Box.createVerticalStrut(5));
|
||||||
|
main.add(auth);
|
||||||
|
|
||||||
main.add(Box.createVerticalStrut(5));
|
main.add(Box.createVerticalStrut(5));
|
||||||
main.add(macBox);
|
main.add(macBox);
|
||||||
|
|
||||||
@@ -179,6 +223,23 @@ public class NetworkUI extends JFrame implements KeyListener, ActionListener,
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent arg0) {
|
public void actionPerformed(ActionEvent arg0) {
|
||||||
|
boolean b = false;
|
||||||
|
|
||||||
|
if (arg0.getSource() == proxyType) {
|
||||||
|
authCheckBox.setEnabled(proxyType.getSelectedItem() == ProxyType.SOCKS5);
|
||||||
|
b = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (b || arg0.getSource() == authCheckBox) {
|
||||||
|
b = authCheckBox.isSelected() && authCheckBox.isEnabled();
|
||||||
|
ProxySocket.auth = b;
|
||||||
|
authUsername.setEnabled(b);
|
||||||
|
authPassword.setEnabled(b);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ProxySocket.setLogin(authUsername.getText(), authPassword.getPassword());
|
||||||
|
|
||||||
byte[] mac = new byte[macList.length];
|
byte[] mac = new byte[macList.length];
|
||||||
for (int i = 0; i < mac.length; i++)
|
for (int i = 0; i < mac.length; i++)
|
||||||
mac[i] = (byte) Short.parseShort(
|
mac[i] = (byte) Short.parseShort(
|
||||||
|
|||||||
Reference in New Issue
Block a user