Added authentication to proxies, made a fix of sora for linux users and the transparantcy issue.

This commit is contained in:
matt123337@hotmail.com
2015-02-27 11:43:34 -05:00
parent a8683b6345
commit 45e1b5a76f
3 changed files with 129 additions and 26 deletions
@@ -31,6 +31,10 @@ public class ProxySocket extends Socket {
private InetAddress addr;
private int port;
private static String username = null, password = null;
public static boolean auth = false;
private static InetAddress proxyInetAddress = null;
private InetSocketAddress cachedAddr;
@@ -183,14 +187,32 @@ public class ProxySocket extends Socket {
DataOutputStream out = new DataOutputStream(getOutputStream());
DataInputStream in = new DataInputStream(getInputStream());
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)
if (auth) {
out.write(2);
}
out.flush();
if (in.read() != 0x05) // remote proxy version
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!");
}
// now to write the actual request
out.write(0x05); // again the socks version
@@ -270,5 +292,14 @@ public class ProxySocket extends Socket {
public static int getConnectionCount() {
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;
import java.awt.Color;
import java.awt.Dimension;
import javax.swing.JDialog;
import org.parabot.core.ui.components.PaintComponent;
import org.parabot.environment.OperatingSystem;
import javax.swing.*;
import java.awt.*;
/**
*
* @author Everel
@@ -21,19 +23,29 @@ public class BotDialog extends JDialog {
botUI.setDialog(this);
setUndecorated(true);
getRootPane().setOpaque(false);
if (!OperatingSystem.getOS().equals(OperatingSystem.OTHER)) {
setBackground(new Color(0, 0, 0, 0));
}
if (!OperatingSystem.getOS().equals(OperatingSystem.OTHER)) {
try {
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);
setPreferredSize(botUI.getSize());
setSize(botUI.getSize());
setVisible(true);
setContentPane(PaintComponent.getInstance(botUI.getSize()));
botUI.setVisible(true);
}
public void setDimensions(Dimension dimension) {
public void setDimensions(Dimension dimension) {
setUndecorated(true);
getRootPane().setOpaque(false);
setBackground(new Color(0, 0, 0, 0));
@@ -44,14 +56,13 @@ public class BotDialog extends JDialog {
setContentPane(PaintComponent.getInstance());
PaintComponent.getInstance().setDimensions(dimension);
}
public static BotDialog getInstance(BotUI botUI) {
return instance == null ? instance = new BotDialog(botUI) : instance;
}
public static BotDialog getInstance() {
return getInstance(null);
}
}
@@ -1,11 +1,24 @@
package org.parabot.core.ui;
import org.parabot.core.network.NetworkInterface;
import org.parabot.core.network.proxy.ProxySocket;
import org.parabot.core.network.proxy.ProxyType;
import org.parabot.core.ui.utils.UILog;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
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.event.DocumentEvent;
import javax.swing.event.DocumentListener;
@@ -13,11 +26,11 @@ import javax.swing.text.AttributeSet;
import javax.swing.text.BadLocationException;
import javax.swing.text.Document;
import javax.swing.text.PlainDocument;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.net.SocketException;
import org.parabot.core.network.NetworkInterface;
import org.parabot.core.network.proxy.ProxySocket;
import org.parabot.core.network.proxy.ProxyType;
import org.parabot.core.ui.utils.UILog;
public class NetworkUI extends JFrame implements KeyListener, ActionListener,
DocumentListener {
@@ -31,8 +44,12 @@ public class NetworkUI extends JFrame implements KeyListener, ActionListener,
private IntTextField proxyPort;
private JButton submitButton;
JList<String>[] macList;
JScrollPane[] macScrollList;
private JList<String>[] macList;
private JScrollPane[] macScrollList;
private JCheckBox authCheckBox;
private JTextField authUsername;
private JPasswordField authPassword;
private NetworkUI() {
initGUI();
@@ -58,6 +75,8 @@ public class NetworkUI extends JFrame implements KeyListener, ActionListener,
proxyType = new JComboBox<ProxyType>(ProxyType.values());
proxyType.setSelectedItem(ProxySocket.getProxyType());
proxyType.addActionListener(this);
proxyHost = new JTextField();
proxyHost.addKeyListener(this);
@@ -84,6 +103,15 @@ public class NetworkUI extends JFrame implements KeyListener, ActionListener,
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();
add(p);
setResizable(false);
@@ -109,6 +137,19 @@ public class NetworkUI extends JFrame implements KeyListener, ActionListener,
port.add(new JLabel("Proxy Port: "));
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();
macBox.add(new JLabel("MAC:"));
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(port);
main.add(Box.createVerticalStrut(5));
main.add(auth);
main.add(Box.createVerticalStrut(5));
main.add(macBox);
@@ -179,6 +223,23 @@ public class NetworkUI extends JFrame implements KeyListener, ActionListener,
@Override
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];
for (int i = 0; i < mac.length; i++)
mac[i] = (byte) Short.parseShort(