mirror of
https://github.com/2006-Scape/Parabot.git
synced 2026-07-08 00:38:38 +00:00
Added Matt's proxy and mac changer
This commit is contained in:
@@ -0,0 +1,25 @@
|
|||||||
|
package org.matt123337.patcher;
|
||||||
|
|
||||||
|
import org.objectweb.asm.commons.Remapper;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
public class ClassRemapper extends Remapper {
|
||||||
|
private static HashMap<String, String> remapNames = new HashMap<String, String>();
|
||||||
|
static {
|
||||||
|
remapNames.put("java/net/Socket", "org/matt123337/proxy/ProxySocket");
|
||||||
|
remapNames.put("java/net/NetworkInterface",
|
||||||
|
"org/matt123337/spoofer/NetworkInterface");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String map(String str) {
|
||||||
|
String s = remapNames.get(str);
|
||||||
|
if (s != null) {
|
||||||
|
System.out.println("[CLASS_REMAP] " + str + " => " + s);
|
||||||
|
return s;
|
||||||
|
} else {
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+217
@@ -0,0 +1,217 @@
|
|||||||
|
package org.matt123337.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;
|
||||||
|
|
||||||
|
public class ProxySocket extends Socket {
|
||||||
|
|
||||||
|
private static ProxyType proxyType = ProxyType.HTTP;
|
||||||
|
|
||||||
|
private static int proxyPort = -1;
|
||||||
|
|
||||||
|
private InetAddress addr;
|
||||||
|
private int port;
|
||||||
|
|
||||||
|
private static InetAddress proxyInetAddress = null;
|
||||||
|
|
||||||
|
private InetSocketAddress cachedAddr;
|
||||||
|
|
||||||
|
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);
|
||||||
|
proxyType = type;
|
||||||
|
} catch (UnknownHostException e) {
|
||||||
|
// ignored
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void connect(SocketAddress addr) throws IOException {
|
||||||
|
if (addr instanceof InetSocketAddress) {
|
||||||
|
InetSocketAddress isa = (InetSocketAddress) addr;
|
||||||
|
this.addr = InetAddress.getByName(isa.getHostString());
|
||||||
|
this.port = isa.getPort();
|
||||||
|
}
|
||||||
|
if (proxyInetAddress != null && proxyPort != -1) {
|
||||||
|
super.connect(cachedAddr = new InetSocketAddress(proxyInetAddress,
|
||||||
|
proxyPort));
|
||||||
|
initProxy();
|
||||||
|
} else
|
||||||
|
super.connect(addr);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initProxy() throws IOException {
|
||||||
|
System.out.println("[SOCKET_HOOK] 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);
|
||||||
|
}
|
||||||
|
if (code / 100 != 2)
|
||||||
|
throw new IOException(
|
||||||
|
"Unable to connect to server! 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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+5
@@ -0,0 +1,5 @@
|
|||||||
|
package org.matt123337.proxy;
|
||||||
|
|
||||||
|
public enum ProxyType {
|
||||||
|
SOCKS5,SOCKS4,HTTP
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package org.matt123337.spoofer;
|
||||||
|
|
||||||
|
import java.net.InetAddress;
|
||||||
|
|
||||||
|
public class NetworkInterface {
|
||||||
|
|
||||||
|
private byte[] mac = new byte[]{11,11,11,11,11,11};
|
||||||
|
|
||||||
|
private static NetworkInterface cached;
|
||||||
|
|
||||||
|
public byte[] getHardwareAddress(){
|
||||||
|
System.out.println("[NI_HOOK] Mac Address Spoofed!");
|
||||||
|
return mac;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static NetworkInterface getByInetAddress(InetAddress addr){
|
||||||
|
if(cached == null)
|
||||||
|
cached = new NetworkInterface();
|
||||||
|
return cached;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,9 +1,11 @@
|
|||||||
package org.parabot;
|
package org.parabot;
|
||||||
|
|
||||||
|
import org.matt123337.patcher.ClassRemapper;
|
||||||
|
import org.objectweb.asm.commons.RemappingClassAdapter;
|
||||||
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
import org.parabot.core.Core;
|
import org.parabot.core.Core;
|
||||||
import org.parabot.core.Directories;
|
import org.parabot.core.Directories;
|
||||||
import org.parabot.core.forum.AccountManager;
|
import org.parabot.core.forum.AccountManager;
|
||||||
import org.parabot.core.spoofing.Ip;
|
|
||||||
import org.parabot.core.ui.LoginUI;
|
import org.parabot.core.ui.LoginUI;
|
||||||
import org.parabot.core.ui.ServerSelector;
|
import org.parabot.core.ui.ServerSelector;
|
||||||
import org.parabot.core.ui.utils.UILog;
|
import org.parabot.core.ui.utils.UILog;
|
||||||
@@ -85,11 +87,16 @@ public final class Landing {
|
|||||||
password = args[++i];
|
password = args[++i];
|
||||||
break;
|
break;
|
||||||
case "-proxy":
|
case "-proxy":
|
||||||
Ip.spoofIP(args[++i], args[++i]);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public ClassNode remapClasses(ClassNode c){
|
||||||
|
ClassNode ret = new ClassNode();
|
||||||
|
RemappingClassAdapter adapter = new RemappingClassAdapter(ret,new ClassRemapper());
|
||||||
|
c.accept(adapter);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user