mirror of
https://github.com/2006-Scape/Parabot.git
synced 2026-07-07 16:49:10 +00:00
Low level proxy support added, MAC address spoofing done, basic runtime interception done
Signed-off-by: matt123337 <matt123337@hotmail.com>
This commit is contained in:
@@ -1,16 +1,19 @@
|
||||
package org.parabot;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.UIManager;
|
||||
|
||||
import org.matt123337.proxy.ProxySocket;
|
||||
import org.matt123337.proxy.ProxyType;
|
||||
import org.parabot.core.Core;
|
||||
import org.parabot.core.Directories;
|
||||
import org.parabot.core.forum.AccountManager;
|
||||
import org.parabot.core.spoofing.Ip;
|
||||
import org.parabot.core.ui.LoginUI;
|
||||
import org.parabot.core.ui.ServerSelector;
|
||||
import org.parabot.core.ui.utils.UILog;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Parabot v2
|
||||
*
|
||||
@@ -84,9 +87,14 @@ public final class Landing {
|
||||
username = args[++i];
|
||||
password = args[++i];
|
||||
break;
|
||||
case "-proxy":
|
||||
Ip.spoofIP(args[++i], args[++i]);
|
||||
break;
|
||||
case "-proxy":
|
||||
String type = args[++i];
|
||||
String ip = args[++i];
|
||||
String port = args[++i];
|
||||
if (!handleProxy(type, ip, port)) {
|
||||
System.exit(1);
|
||||
}
|
||||
break;
|
||||
case "-loadlocal":
|
||||
Core.setLoadLocal(true);
|
||||
break;
|
||||
@@ -94,5 +102,26 @@ public final class Landing {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean handleProxy(String type, String ip, String port) {
|
||||
ProxyType proxyType = null;
|
||||
for (ProxyType pt : ProxyType.values()) {
|
||||
if (pt.name().equalsIgnoreCase(type)) {
|
||||
proxyType = pt;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (proxyType == null) {
|
||||
System.err.println("Unknown proxy type:" + type);
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
int p = Integer.parseInt(port);
|
||||
ProxySocket.setProxy(proxyType, ip, p);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,8 +18,10 @@ import java.util.jar.JarOutputStream;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
import org.matt123337.proxy.ClassRemapper;
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.commons.RemappingClassAdapter;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
import org.parabot.core.Directories;
|
||||
import org.parabot.core.build.BuildPath;
|
||||
@@ -186,7 +188,8 @@ public class ClassPath {
|
||||
protected void loadClass(InputStream in) throws IOException {
|
||||
ClassReader cr = new ClassReader(in);
|
||||
ClassNode cn = new ClassNode();
|
||||
cr.accept(cn, 0);
|
||||
RemappingClassAdapter adapter = new RemappingClassAdapter(cn,new ClassRemapper());
|
||||
cr.accept(adapter, ClassReader.EXPAND_FRAMES);
|
||||
classes.put(cn.name, cn);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
package org.parabot.core.spoofing;
|
||||
|
||||
/**
|
||||
* User: Jeroen
|
||||
* Date: 27/11/13
|
||||
* Time: 16:04
|
||||
*/
|
||||
public class Ip {
|
||||
public static void spoofIP(String host, String port) {
|
||||
System.getProperties().setProperty("socksProxySet", "true");
|
||||
System.getProperties().setProperty("socksProxyHost", host);
|
||||
System.getProperties().setProperty("socksProxyPort", port);
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import org.parabot.core.ui.images.Images;
|
||||
import org.parabot.core.ui.utils.SwingUtil;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
@@ -49,9 +50,12 @@ public class BotUI extends JFrame implements ActionListener {
|
||||
JMenuBar menubar = new JMenuBar();
|
||||
|
||||
JMenu mnuFile = new JMenu("File");
|
||||
JMenuItem proxy = new JMenuItem("Network");
|
||||
JMenuItem exit = new JMenuItem("Exit");
|
||||
proxy.addActionListener(this);
|
||||
exit.addActionListener(this);
|
||||
|
||||
mnuFile.add(proxy);
|
||||
mnuFile.add(exit);
|
||||
menubar.add(mnuFile);
|
||||
|
||||
@@ -96,6 +100,11 @@ public class BotUI extends JFrame implements ActionListener {
|
||||
case "Exit":
|
||||
System.exit(0);
|
||||
break;
|
||||
case "Network":
|
||||
NetworkUI proxy = NetworkUI.getInstance();
|
||||
proxy.setLocationRelativeTo(BotUI.getInstance());
|
||||
proxy.setVisible(true);
|
||||
break;
|
||||
default:
|
||||
System.out.println("Invalid command: ");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,268 @@
|
||||
package org.parabot.core.ui;
|
||||
|
||||
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.Box;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JList;
|
||||
import javax.swing.JPanel;
|
||||
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;
|
||||
import javax.swing.text.AttributeSet;
|
||||
import javax.swing.text.BadLocationException;
|
||||
import javax.swing.text.Document;
|
||||
import javax.swing.text.PlainDocument;
|
||||
|
||||
import org.matt123337.proxy.ProxySocket;
|
||||
import org.matt123337.proxy.ProxyType;
|
||||
import org.matt123337.spoofer.NetworkInterface;
|
||||
import org.parabot.core.ui.components.LogArea;
|
||||
import org.parabot.core.ui.utils.UILog;
|
||||
|
||||
public class NetworkUI extends JFrame implements KeyListener, ActionListener,
|
||||
DocumentListener {
|
||||
|
||||
private static NetworkUI instance;
|
||||
|
||||
private JComboBox<ProxyType> proxyType;
|
||||
private JTextField proxyHost;
|
||||
private IntTextField proxyPort;
|
||||
private JButton submitButton;
|
||||
|
||||
JList[] macList;
|
||||
JScrollPane[] macScrollList;
|
||||
|
||||
private NetworkUI() {
|
||||
initGUI();
|
||||
}
|
||||
|
||||
public static NetworkUI getInstance() {
|
||||
return instance == null ? instance = new NetworkUI() : instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVisible(boolean b) {
|
||||
BotUI.getInstance().setEnabled(!b);
|
||||
if (ProxySocket.getProxyAddress() != null)
|
||||
proxyHost.setText(ProxySocket.getProxyAddress().getHostName());
|
||||
proxyPort.setText("" + ProxySocket.getProxyPort());
|
||||
proxyType.setSelectedItem(ProxySocket.getProxyType());
|
||||
super.setVisible(b);
|
||||
}
|
||||
|
||||
private void initGUI() {
|
||||
proxyType = new JComboBox<ProxyType>(ProxyType.values());
|
||||
proxyType.setSelectedItem(ProxySocket.getProxyType());
|
||||
|
||||
proxyHost = new JTextField();
|
||||
proxyHost.addKeyListener(this);
|
||||
|
||||
proxyPort = new IntTextField(80, 5);
|
||||
proxyPort.setColumns(5);
|
||||
proxyPort.addKeyListener(this);
|
||||
|
||||
submitButton = new JButton("Submit");
|
||||
submitButton.addActionListener(this);
|
||||
|
||||
byte[] mac = new byte[6];
|
||||
try {
|
||||
mac = NetworkInterface.getRealHardwareAddress();
|
||||
} catch (SocketException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
macList = new JList[mac.length];
|
||||
macScrollList = new JScrollPane[mac.length];
|
||||
for (int i = 0; i < mac.length; i++) {
|
||||
int value = mac[i] & 0xFF;
|
||||
macList[i] = createMacList();
|
||||
macList[i].setSelectedIndex(value);
|
||||
macScrollList[i] = new JScrollPane(macList[i]);
|
||||
macList[i].ensureIndexIsVisible(value > 0 ? value - 1 : value);
|
||||
|
||||
}
|
||||
JPanel p = createPanelUI();
|
||||
add(p);
|
||||
setResizable(false);
|
||||
setDefaultCloseOperation(HIDE_ON_CLOSE);
|
||||
pack();
|
||||
setTitle("Network Settings");
|
||||
}
|
||||
|
||||
private JPanel createPanelUI() {
|
||||
JPanel ret = new JPanel();
|
||||
ret.setLayout(new BoxLayout(ret, BoxLayout.LINE_AXIS));
|
||||
Box main = Box.createVerticalBox();
|
||||
|
||||
Box type = Box.createHorizontalBox();
|
||||
type.add(new JLabel("Proxy Type: "));
|
||||
type.add(proxyType);
|
||||
|
||||
Box host = Box.createHorizontalBox();
|
||||
host.add(new JLabel("Proxy Host: "));
|
||||
host.add(proxyHost);
|
||||
|
||||
Box port = Box.createHorizontalBox();
|
||||
port.add(new JLabel("Proxy Port: "));
|
||||
port.add(proxyPort);
|
||||
|
||||
Box macBox = Box.createHorizontalBox();
|
||||
macBox.add(new JLabel("MAC:"));
|
||||
for (int i = 0; i < macList.length; i++) {
|
||||
macBox.add(new JScrollPane(macList[i]));
|
||||
macBox.add(Box.createHorizontalStrut(5));
|
||||
}
|
||||
|
||||
Box submit = Box.createHorizontalBox();
|
||||
submit.add(submitButton);
|
||||
|
||||
main.add(type);
|
||||
|
||||
main.add(Box.createVerticalStrut(5));
|
||||
main.add(host);
|
||||
|
||||
main.add(Box.createVerticalStrut(5));
|
||||
main.add(port);
|
||||
|
||||
main.add(Box.createVerticalStrut(5));
|
||||
main.add(macBox);
|
||||
|
||||
main.add(Box.createVerticalStrut(5));
|
||||
main.add(submit);
|
||||
|
||||
ret.add(main);
|
||||
ret.setBorder(new EmptyBorder(10, 10, 10, 10));
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
Object source = e.getSource();
|
||||
if (source == proxyPort || source == proxyHost) {
|
||||
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
|
||||
actionPerformed(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyReleased(KeyEvent arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(KeyEvent arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changedUpdate(DocumentEvent arg0) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertUpdate(DocumentEvent arg0) {
|
||||
if (proxyPort.isValid()) {
|
||||
proxyPort.setText("" + proxyPort.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeUpdate(DocumentEvent arg0) {
|
||||
insertUpdate(arg0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
byte[] mac = new byte[macList.length];
|
||||
for (int i = 0; i < mac.length; i++)
|
||||
mac[i] = (byte) Short.parseShort((String) macList[i].getSelectedValue(), 16);
|
||||
NetworkInterface.mac = mac;
|
||||
|
||||
try {
|
||||
if(ProxySocket.getConnectionCount() > 0) {
|
||||
try {
|
||||
LogArea.log("Closing Existing Connections...");
|
||||
ProxySocket.closeConnections();
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
ProxySocket.setProxy((ProxyType) proxyType.getSelectedItem(),
|
||||
proxyHost.getText(), proxyPort.getValue());
|
||||
UILog.log("Info", "Network settings have been set!");
|
||||
} catch (Exception e) {
|
||||
UILog.log("Error",
|
||||
"Unable to set proxy info!\n\nReason:" + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
setVisible(false);
|
||||
}
|
||||
|
||||
private JList createMacList() {
|
||||
String[] hexStrings = new String[256];
|
||||
for (int i = 0; i < 256; i++) {
|
||||
hexStrings[i] = String.format("%02X", i);
|
||||
}
|
||||
JList ret = new JList<String>(hexStrings);
|
||||
ret.setVisibleRowCount(3);
|
||||
ret.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
return ret;
|
||||
}
|
||||
|
||||
class IntTextField extends JTextField {
|
||||
public IntTextField(int defval, int size) {
|
||||
super("" + defval, size);
|
||||
}
|
||||
|
||||
protected Document createDefaultModel() {
|
||||
return new IntTextDocument();
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
try {
|
||||
int i = Integer.parseInt(getText());
|
||||
return i > 0 && i <= 25565;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
try {
|
||||
return Integer.parseInt(getText());
|
||||
} catch (NumberFormatException e) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
class IntTextDocument extends PlainDocument {
|
||||
public void insertString(int offs, String str, AttributeSet a)
|
||||
throws BadLocationException {
|
||||
if (str == null)
|
||||
return;
|
||||
String oldString = getText(0, getLength());
|
||||
String newString = oldString.substring(0, offs) + str
|
||||
+ oldString.substring(offs);
|
||||
try {
|
||||
Integer.parseInt(newString.replace("-", "") + "0");
|
||||
super.insertString(offs, str, a);
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,8 @@ package org.parabot.core.ui.utils;
|
||||
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
import org.parabot.core.ui.BotUI;
|
||||
|
||||
/**
|
||||
*
|
||||
* Log messages to the log user interface which is attached to the bot user interface
|
||||
@@ -17,7 +19,7 @@ public class UILog {
|
||||
|
||||
public static void log(final String title, final String message,
|
||||
int messageType) {
|
||||
JOptionPane.showMessageDialog(null, message, title,
|
||||
JOptionPane.showMessageDialog(BotUI.getInstance(), message, title,
|
||||
messageType);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user