mirror of
https://github.com/2006-Scape/Parabot.git
synced 2026-07-06 16:50:39 +00:00
redid my proxys tuff after my ragequit, have fun ppz.
This commit is contained in:
@@ -0,0 +1,24 @@
|
|||||||
|
package org.parabot.core.asm;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import org.objectweb.asm.commons.Remapper;
|
||||||
|
|
||||||
|
public class ClassRemapper extends Remapper {
|
||||||
|
private static HashMap<String, String> remapNames = new HashMap<String, String>();
|
||||||
|
static {
|
||||||
|
remapNames.put("java/net/Socket", "org/parabot/core/network/proxy/ProxySocket");
|
||||||
|
remapNames.put("java/net/NetworkInterface", "org/parabot/core/network/NetworkInterface");
|
||||||
|
remapNames.put("java/lang/Runtime", "org/parabot/core/network/Runtime");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String map(String str) {
|
||||||
|
String s = remapNames.get(str);
|
||||||
|
if (s != null) {
|
||||||
|
return s;
|
||||||
|
} else {
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -20,8 +20,10 @@ import java.util.zip.ZipInputStream;
|
|||||||
|
|
||||||
import org.objectweb.asm.ClassReader;
|
import org.objectweb.asm.ClassReader;
|
||||||
import org.objectweb.asm.ClassWriter;
|
import org.objectweb.asm.ClassWriter;
|
||||||
|
import org.objectweb.asm.commons.RemappingClassAdapter;
|
||||||
import org.objectweb.asm.tree.ClassNode;
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
import org.parabot.core.Directories;
|
import org.parabot.core.Directories;
|
||||||
|
import org.parabot.core.asm.ClassRemapper;
|
||||||
import org.parabot.core.build.BuildPath;
|
import org.parabot.core.build.BuildPath;
|
||||||
import org.parabot.core.io.SizeInputStream;
|
import org.parabot.core.io.SizeInputStream;
|
||||||
import org.parabot.core.ui.components.VerboseLoader;
|
import org.parabot.core.ui.components.VerboseLoader;
|
||||||
@@ -177,6 +179,8 @@ public class ClassPath {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ClassRemapper class_mapper = new ClassRemapper();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads class from input stream
|
* Loads class from input stream
|
||||||
*
|
*
|
||||||
@@ -187,7 +191,10 @@ public class ClassPath {
|
|||||||
ClassReader cr = new ClassReader(in);
|
ClassReader cr = new ClassReader(in);
|
||||||
ClassNode cn = new ClassNode();
|
ClassNode cn = new ClassNode();
|
||||||
cr.accept(cn, 0);
|
cr.accept(cn, 0);
|
||||||
classes.put(cn.name, cn);
|
RemappingClassAdapter rca = new RemappingClassAdapter(cn,class_mapper);
|
||||||
|
ClassNode remapped = new ClassNode();
|
||||||
|
cn.accept(rca);
|
||||||
|
classes.put(cn.name, remapped);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+5
-5
@@ -1,13 +1,13 @@
|
|||||||
package org.parabot.core.spoofer;
|
package org.parabot.core.network;
|
||||||
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.SocketException;
|
import java.net.SocketException;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
|
|
||||||
public class MacAddress {
|
public class NetworkInterface {
|
||||||
public static byte[] mac = new byte[] { 11, 11, 11, 11, 11, 11 };
|
public static byte[] mac = new byte[] { 11, 11, 11, 11, 11, 11 };
|
||||||
private static byte[] realMac;
|
private static byte[] realMac;
|
||||||
private static MacAddress cached;
|
private static NetworkInterface cached;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
try {
|
try {
|
||||||
@@ -37,9 +37,9 @@ public class MacAddress {
|
|||||||
return mac;
|
return mac;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MacAddress getByInetAddress(InetAddress addr) {
|
public static NetworkInterface getByInetAddress(InetAddress addr) {
|
||||||
if (cached == null)
|
if (cached == null)
|
||||||
cached = new MacAddress();
|
cached = new NetworkInterface();
|
||||||
return cached;
|
return cached;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
package org.parabot.core.network;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class Runtime {
|
||||||
|
|
||||||
|
private java.lang.Runtime rt;
|
||||||
|
|
||||||
|
private static Runtime cached;
|
||||||
|
|
||||||
|
private Runtime(java.lang.Runtime rt){
|
||||||
|
this.rt = rt;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void addShutdownHook(Thread t){
|
||||||
|
rt.addShutdownHook(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int availableProcessors(){
|
||||||
|
return rt.availableProcessors();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void exit(int i){
|
||||||
|
rt.exit(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Process exec(String str) throws IOException{
|
||||||
|
System.out.println("RT:" + str);
|
||||||
|
System.out.println("RT:" + str);
|
||||||
|
return rt.exec(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Process exec(String[] cmdarray) throws IOException{
|
||||||
|
StringBuffer sb = new StringBuffer();
|
||||||
|
for(int i = 0; i < cmdarray.length;i++){
|
||||||
|
sb.append(cmdarray[i] + (i < cmdarray.length - 1 ? "," : ""));
|
||||||
|
}
|
||||||
|
System.out.println("RT: {" + sb + "}");
|
||||||
|
System.out.println("RT: {" + sb + "}");
|
||||||
|
return rt.exec(cmdarray);
|
||||||
|
}
|
||||||
|
|
||||||
|
public long freeMemory(){
|
||||||
|
return rt.freeMemory();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void gc(){
|
||||||
|
rt.gc();
|
||||||
|
}
|
||||||
|
|
||||||
|
public long maxMemory(){
|
||||||
|
return rt.maxMemory();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Runtime getRuntime(){
|
||||||
|
if(cached == null)
|
||||||
|
cached = new Runtime(java.lang.Runtime.getRuntime());
|
||||||
|
return cached;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,274 @@
|
|||||||
|
package org.parabot.core.network.proxy;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.DataInputStream;
|
||||||
|
import java.io.DataOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.net.InetAddress;
|
||||||
|
import java.net.InetSocketAddress;
|
||||||
|
import java.net.Socket;
|
||||||
|
import java.net.SocketAddress;
|
||||||
|
import java.net.UnknownHostException;
|
||||||
|
import java.nio.channels.SocketChannel;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
|
||||||
|
import org.parabot.core.ui.utils.UILog;
|
||||||
|
|
||||||
|
public class ProxySocket extends Socket {
|
||||||
|
|
||||||
|
private static List<ProxySocket> connections = new ArrayList<ProxySocket>();
|
||||||
|
|
||||||
|
private static ProxyType proxyType = ProxyType.HTTP;
|
||||||
|
|
||||||
|
private static int proxyPort = 0;
|
||||||
|
|
||||||
|
private InetAddress addr;
|
||||||
|
private int port;
|
||||||
|
|
||||||
|
private static InetAddress proxyInetAddress = null;
|
||||||
|
|
||||||
|
private InetSocketAddress cachedAddr;
|
||||||
|
|
||||||
|
public static int closeConnections() {
|
||||||
|
int value = 0;
|
||||||
|
for (ProxySocket socket : connections)
|
||||||
|
try {
|
||||||
|
connections.remove(socket);
|
||||||
|
if (socket.isClosed())
|
||||||
|
continue;
|
||||||
|
socket.close();
|
||||||
|
value++;
|
||||||
|
} catch (Exception e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProxySocket(InetAddress addr, int port) throws IOException {
|
||||||
|
super(addr, port);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProxySocket() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProxySocket(String host, int port) throws IOException {
|
||||||
|
super(host, port);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setProxy(ProxyType type, String host, int port) {
|
||||||
|
try {
|
||||||
|
proxyInetAddress = InetAddress.getByName(host);
|
||||||
|
proxyPort = port;
|
||||||
|
proxyType = type;
|
||||||
|
} catch (UnknownHostException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static InetAddress getProxyAddress() {
|
||||||
|
return proxyInetAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getProxyPort() {
|
||||||
|
return proxyPort;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ProxyType getProxyType() {
|
||||||
|
return proxyType;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void connect(SocketAddress addr) throws IOException {
|
||||||
|
connections.add(this);
|
||||||
|
if (addr instanceof InetSocketAddress) {
|
||||||
|
InetSocketAddress isa = (InetSocketAddress) addr;
|
||||||
|
this.addr = InetAddress.getByName(isa.getHostString());
|
||||||
|
this.port = isa.getPort();
|
||||||
|
}
|
||||||
|
if (proxyInetAddress != null && proxyPort > 0) {
|
||||||
|
try {
|
||||||
|
super.connect(cachedAddr = new InetSocketAddress(
|
||||||
|
proxyInetAddress, proxyPort));
|
||||||
|
initProxy();
|
||||||
|
} catch (Exception e) {
|
||||||
|
UILog.log("Proxy Error", e.getMessage(),
|
||||||
|
JOptionPane.ERROR_MESSAGE);
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
super.connect(addr);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initProxy() throws IOException {
|
||||||
|
System.out.println("Proxying:" + addr + ":" + port + " Over:"
|
||||||
|
+ proxyInetAddress + ":" + proxyPort + " Type:" + proxyType);
|
||||||
|
switch (proxyType) {
|
||||||
|
case HTTP:
|
||||||
|
http_connect();
|
||||||
|
break;
|
||||||
|
case SOCKS4:
|
||||||
|
socks4_connect();
|
||||||
|
break;
|
||||||
|
case SOCKS5:
|
||||||
|
socks5_connect();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new IOException("Unsupported proxy type:" + proxyType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void http_connect() throws IOException {
|
||||||
|
InputStream in = getInputStream();
|
||||||
|
BufferedReader br = new BufferedReader(new InputStreamReader(in));
|
||||||
|
OutputStream out = getOutputStream();
|
||||||
|
out.write(("CONNECT " + addr.getHostAddress() + ":" + port + "\r\n")
|
||||||
|
.getBytes());
|
||||||
|
// out.write("Connection:keep-alive\r\n".getBytes());
|
||||||
|
out.write("\r\n".getBytes());
|
||||||
|
String str;
|
||||||
|
while ((str = br.readLine()) != null) {
|
||||||
|
if (str.length() == 0)
|
||||||
|
break;
|
||||||
|
if (!str.startsWith("HTTP"))
|
||||||
|
continue;
|
||||||
|
int code = Integer.parseInt(str.substring(9, 12));
|
||||||
|
switch (code) {
|
||||||
|
case 404:
|
||||||
|
throw new IOException(
|
||||||
|
"Proxy seems to think we're connecting to a webpage...");
|
||||||
|
case 403:
|
||||||
|
throw new IOException(
|
||||||
|
"Proxy doesn't support connecting to port: " + port
|
||||||
|
+ "! Try a different proxy.");
|
||||||
|
}
|
||||||
|
if (code / 100 != 2)
|
||||||
|
throw new IOException(
|
||||||
|
"Unable to connect to proxy server! HTTP Error code:"
|
||||||
|
+ code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void socks4_connect() throws IOException {
|
||||||
|
DataOutputStream out = new DataOutputStream(getOutputStream());
|
||||||
|
DataInputStream in = new DataInputStream(getInputStream());
|
||||||
|
|
||||||
|
out.write(0x04);
|
||||||
|
out.write(0x01); // connection type (TCP stream)
|
||||||
|
out.writeShort(port);
|
||||||
|
byte[] b = addr.getAddress();
|
||||||
|
if (b.length != 4)
|
||||||
|
throw new IOException("Unsupported IP type for socksv4!");
|
||||||
|
out.write(b);
|
||||||
|
out.write(0); // the userID stuff, 0 means end of string (null
|
||||||
|
// terminated)
|
||||||
|
out.flush();
|
||||||
|
|
||||||
|
if (in.read() != 0x00) // null byte
|
||||||
|
throw new IOException("Proxy server dun goofed");
|
||||||
|
if (in.read() != 0x5a)
|
||||||
|
throw new IOException(
|
||||||
|
"Proxy server was unable to connect to server!");
|
||||||
|
|
||||||
|
in.readShort(); // ignored
|
||||||
|
in.readFully(b); // ignored
|
||||||
|
}
|
||||||
|
|
||||||
|
private void socks5_connect() throws IOException {
|
||||||
|
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(0); // the authentication (none)
|
||||||
|
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
|
||||||
|
throw new IOException("Proxy server declined request!");
|
||||||
|
|
||||||
|
// now to write the actual request
|
||||||
|
out.write(0x05); // again the socks version
|
||||||
|
out.write(0x01); // the connection type (0x01 = TCP Connection)
|
||||||
|
out.write(0x00); // the reserve byte, un-used
|
||||||
|
byte[] b = addr.getAddress();
|
||||||
|
out.write(b.length == 4 ? 0x01 : 0x04); // if ipv4 or ipv6 (0x03 =
|
||||||
|
// domain name, but that's
|
||||||
|
// unsupported as of yet)
|
||||||
|
out.write(b);
|
||||||
|
out.writeShort(port);
|
||||||
|
out.flush();
|
||||||
|
|
||||||
|
// now to read the server's reply
|
||||||
|
if (in.read() != 0x05) // socks version (again)
|
||||||
|
throw new IOException("Proxy server dun goofed");
|
||||||
|
int reply = in.read();
|
||||||
|
if (reply == 0x08)
|
||||||
|
throw new IOException("Bad address sent to proxy server");
|
||||||
|
if (reply != 0x00)
|
||||||
|
throw new IOException("Unable to connect to server!");
|
||||||
|
in.read(); // reserve byte
|
||||||
|
int addrType = in.read();
|
||||||
|
b = new byte[4];
|
||||||
|
switch (addrType) {
|
||||||
|
case 0x01:
|
||||||
|
b = new byte[4];
|
||||||
|
break;
|
||||||
|
case 0x04:
|
||||||
|
b = new byte[16];
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new IOException("Bad address type from proxy server!");
|
||||||
|
}
|
||||||
|
in.readFully(b);
|
||||||
|
in.readShort(); // the returned port #, ignored
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getPort() {
|
||||||
|
if (super.getInetAddress().equals(proxyInetAddress))
|
||||||
|
return port;
|
||||||
|
return super.getPort();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public InetAddress getInetAddress() {
|
||||||
|
if (super.getInetAddress().equals(proxyInetAddress))
|
||||||
|
return addr;
|
||||||
|
return super.getInetAddress();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SocketAddress getRemoteSocketAddress() {
|
||||||
|
if (super.getInetAddress().equals(proxyInetAddress))
|
||||||
|
return cachedAddr;
|
||||||
|
return super.getRemoteSocketAddress();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SocketChannel getChannel() {
|
||||||
|
if (super.getInetAddress().equals(proxyInetAddress))
|
||||||
|
return null;
|
||||||
|
return super.getChannel();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() throws IOException {
|
||||||
|
connections.remove(this);
|
||||||
|
super.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setType(ProxyType pt) {
|
||||||
|
proxyType = pt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getConnectionCount() {
|
||||||
|
return connections.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package org.parabot.core.network.proxy;
|
||||||
|
|
||||||
|
public enum ProxyType {
|
||||||
|
SOCKS5, SOCKS4, HTTP
|
||||||
|
}
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package org.parabot.core.spoofer;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* User: Jeroen
|
|
||||||
* Date: 18/02/14
|
|
||||||
* Time: 16:54
|
|
||||||
*/
|
|
||||||
public class Proxy {
|
|
||||||
public static void setProxy(String host, int port){
|
|
||||||
System.getProperties().put("proxyHost", host);
|
|
||||||
System.getProperties().put("proxyPort", port);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -102,8 +102,7 @@ public class BotUI extends JFrame implements ActionListener, ComponentListener,
|
|||||||
System.exit(0);
|
System.exit(0);
|
||||||
break;
|
break;
|
||||||
case "Network":
|
case "Network":
|
||||||
NetworkUI UI = new NetworkUI();
|
NetworkUI.getInstance().setVisible(true);
|
||||||
UI.frame.setVisible(true);
|
|
||||||
break;
|
break;
|
||||||
case "Run":
|
case "Run":
|
||||||
if(pauseScript) {
|
if(pauseScript) {
|
||||||
|
|||||||
@@ -1,111 +1,285 @@
|
|||||||
package org.parabot.core.ui;
|
package org.parabot.core.ui;
|
||||||
|
|
||||||
import org.parabot.core.spoofer.Proxy;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.util.HashMap;
|
import java.awt.event.KeyEvent;
|
||||||
|
import java.awt.event.KeyListener;
|
||||||
|
import java.net.SocketException;
|
||||||
|
|
||||||
public class NetworkUI {
|
import javax.swing.Box;
|
||||||
public JFrame frame;
|
import javax.swing.BoxLayout;
|
||||||
private JTextField proxyHostField;
|
import javax.swing.JButton;
|
||||||
private JTextField proxyPortField;
|
import javax.swing.JComboBox;
|
||||||
private HashMap<String, Integer> socksVersions;
|
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;
|
||||||
|
|
||||||
public NetworkUI() {
|
import org.parabot.core.network.NetworkInterface;
|
||||||
this.socksVersions = new HashMap<String, Integer>();
|
import org.parabot.core.network.proxy.ProxySocket;
|
||||||
initialize();
|
import org.parabot.core.network.proxy.ProxyType;
|
||||||
}
|
import org.parabot.core.ui.utils.UILog;
|
||||||
|
|
||||||
public static void main(String[] args){
|
public class NetworkUI extends JFrame implements KeyListener, ActionListener,
|
||||||
NetworkUI window = new NetworkUI();
|
DocumentListener {
|
||||||
window.frame.setVisible(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initialize() {
|
/**
|
||||||
socksVersions.put("Socks 4", 4);
|
*
|
||||||
socksVersions.put("Socks 5", 5);
|
*/
|
||||||
frame = new JFrame();
|
private static final long serialVersionUID = 1L;
|
||||||
frame.setResizable(false);
|
|
||||||
frame.setBounds(100, 100, 450, 300);
|
|
||||||
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
|
||||||
frame.getContentPane().setLayout(null);
|
|
||||||
|
|
||||||
JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
|
private static NetworkUI instance;
|
||||||
tabbedPane.setBounds(6, 6, 438, 233);
|
|
||||||
frame.getContentPane().add(tabbedPane);
|
|
||||||
|
|
||||||
JPanel proxy = new JPanel();
|
private JComboBox<ProxyType> proxyType;
|
||||||
tabbedPane.addTab("Proxy", null, proxy, null);
|
private JTextField proxyHost;
|
||||||
proxy.setLayout(null);
|
private IntTextField proxyPort;
|
||||||
|
private JButton submitButton;
|
||||||
|
|
||||||
JLabel socksOption = new JLabel("Socks version");
|
JList<String>[] macList;
|
||||||
socksOption.setBounds(6, 6, 87, 16);
|
JScrollPane[] macScrollList;
|
||||||
proxy.add(socksOption);
|
|
||||||
|
|
||||||
final JComboBox<String> socksOptions = new JComboBox<String>();
|
private NetworkUI() {
|
||||||
for (String key : socksVersions.keySet()) {
|
initGUI();
|
||||||
socksOptions.addItem(key);
|
}
|
||||||
}
|
|
||||||
socksOptions.setBounds(105, 2, 127, 27);
|
|
||||||
proxy.add(socksOptions);
|
|
||||||
|
|
||||||
JLabel proxyHost = new JLabel("Proxy host");
|
public static NetworkUI getInstance() {
|
||||||
proxyHost.setBounds(6, 66, 87, 16);
|
return instance == null ? instance = new NetworkUI() : instance;
|
||||||
proxy.add(proxyHost);
|
}
|
||||||
|
|
||||||
proxyHostField = new JTextField();
|
@Override
|
||||||
proxyHostField.setBounds(105, 60, 127, 28);
|
public void setVisible(boolean b) {
|
||||||
proxy.add(proxyHostField);
|
BotUI.getInstance().setEnabled(!b);
|
||||||
proxyHostField.setColumns(10);
|
if (ProxySocket.getProxyAddress() != null)
|
||||||
|
proxyHost.setText(ProxySocket.getProxyAddress().getHostName());
|
||||||
|
proxyPort.setText("" + ProxySocket.getProxyPort());
|
||||||
|
proxyType.setSelectedItem(ProxySocket.getProxyType());
|
||||||
|
setLocationRelativeTo(BotUI.getInstance());
|
||||||
|
super.setVisible(b);
|
||||||
|
}
|
||||||
|
|
||||||
JLabel proxyPort = new JLabel("Proxy port");
|
@SuppressWarnings("unchecked")
|
||||||
proxyPort.setBounds(6, 126, 87, 16);
|
private void initGUI() {
|
||||||
proxy.add(proxyPort);
|
proxyType = new JComboBox<ProxyType>(ProxyType.values());
|
||||||
|
proxyType.setSelectedItem(ProxySocket.getProxyType());
|
||||||
|
|
||||||
proxyPortField = new JTextField();
|
proxyHost = new JTextField();
|
||||||
proxyPortField.setBounds(105, 120, 127, 28);
|
proxyHost.addKeyListener(this);
|
||||||
proxy.add(proxyPortField);
|
|
||||||
proxyPortField.setColumns(10);
|
|
||||||
|
|
||||||
JPanel macAddress = new JPanel();
|
proxyPort = new IntTextField(80, 5);
|
||||||
tabbedPane.addTab("Mac address", null, macAddress, null);
|
proxyPort.setColumns(5);
|
||||||
macAddress.setLayout(null);
|
proxyPort.addKeyListener(this);
|
||||||
|
|
||||||
JLabel enableSpoofer = new JLabel("Enable mac spoofer");
|
submitButton = new JButton("Submit");
|
||||||
enableSpoofer.setBounds(6, 80, 99, 16);
|
submitButton.addActionListener(this);
|
||||||
macAddress.add(enableSpoofer);
|
|
||||||
|
|
||||||
final ButtonGroup bg = new ButtonGroup();
|
byte[] mac = new byte[6];
|
||||||
JRadioButton spooferYes = new JRadioButton("Yes");
|
try {
|
||||||
spooferYes.setBounds(117, 76, 59, 23);
|
mac = NetworkInterface.getRealHardwareAddress();
|
||||||
macAddress.add(spooferYes);
|
} 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);
|
||||||
|
|
||||||
JRadioButton spooferNo = new JRadioButton("No");
|
}
|
||||||
spooferNo.setBounds(188, 76, 59, 23);
|
JPanel p = createPanelUI();
|
||||||
macAddress.add(spooferNo);
|
add(p);
|
||||||
spooferNo.setSelected(true);
|
setResizable(false);
|
||||||
|
setDefaultCloseOperation(HIDE_ON_CLOSE);
|
||||||
|
pack();
|
||||||
|
setTitle("Network Settings");
|
||||||
|
}
|
||||||
|
|
||||||
bg.add(spooferYes);
|
private JPanel createPanelUI() {
|
||||||
bg.add(spooferNo);
|
JPanel ret = new JPanel();
|
||||||
|
ret.setLayout(new BoxLayout(ret, BoxLayout.LINE_AXIS));
|
||||||
|
Box main = Box.createVerticalBox();
|
||||||
|
|
||||||
JButton submit = new JButton("Submit");
|
Box type = Box.createHorizontalBox();
|
||||||
submit.addActionListener(new ActionListener() {
|
type.add(new JLabel("Proxy Type: "));
|
||||||
public void actionPerformed(ActionEvent e) {
|
type.add(proxyType);
|
||||||
if (!proxyHostField.getText().isEmpty() && !proxyPortField.getText().isEmpty()){
|
|
||||||
try{
|
Box host = Box.createHorizontalBox();
|
||||||
Integer.parseInt(proxyPortField.getText());
|
host.add(new JLabel("Proxy Host: "));
|
||||||
}catch (Exception ex){
|
host.add(proxyHost);
|
||||||
System.out.println("The given port is not a numeric value");
|
|
||||||
return;
|
Box port = Box.createHorizontalBox();
|
||||||
}
|
port.add(new JLabel("Proxy Port: "));
|
||||||
Proxy.setProxy(proxyHostField.getText(), Integer.parseInt(proxyPortField.getText()));
|
port.add(proxyPort);
|
||||||
frame.setVisible(false);
|
|
||||||
}
|
Box macBox = Box.createHorizontalBox();
|
||||||
}
|
macBox.add(new JLabel("MAC:"));
|
||||||
});
|
for (int i = 0; i < macList.length; i++) {
|
||||||
submit.setBounds(327, 243, 117, 29);
|
macBox.add(new JScrollPane(macList[i]));
|
||||||
frame.getContentPane().add(submit);
|
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 {
|
||||||
|
System.out.println("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<String> createMacList() {
|
||||||
|
String[] hexStrings = new String[256];
|
||||||
|
for (int i = 0; i < 256; i++) {
|
||||||
|
hexStrings[i] = String.format("%02X", i);
|
||||||
|
}
|
||||||
|
JList<String> ret = new JList<String>(hexStrings);
|
||||||
|
ret.setVisibleRowCount(3);
|
||||||
|
ret.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
class IntTextField extends JTextField {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
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 {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
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) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user