redid my proxys tuff after my ragequit, have fun ppz.

This commit is contained in:
matt123337
2014-02-24 17:20:57 -05:00
parent 3cf94702a9
commit fd5be2da22
9 changed files with 642 additions and 110 deletions
@@ -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.ClassWriter;
import org.objectweb.asm.commons.RemappingClassAdapter;
import org.objectweb.asm.tree.ClassNode;
import org.parabot.core.Directories;
import org.parabot.core.asm.ClassRemapper;
import org.parabot.core.build.BuildPath;
import org.parabot.core.io.SizeInputStream;
import org.parabot.core.ui.components.VerboseLoader;
@@ -176,6 +178,8 @@ public class ClassPath {
}
}
}
ClassRemapper class_mapper = new ClassRemapper();
/**
* Loads class from input stream
@@ -187,7 +191,10 @@ public class ClassPath {
ClassReader cr = new ClassReader(in);
ClassNode cn = new ClassNode();
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);
}
/**
@@ -1,13 +1,13 @@
package org.parabot.core.spoofer;
package org.parabot.core.network;
import java.net.InetAddress;
import java.net.SocketException;
import java.util.Enumeration;
public class MacAddress {
public class NetworkInterface {
public static byte[] mac = new byte[] { 11, 11, 11, 11, 11, 11 };
private static byte[] realMac;
private static MacAddress cached;
private static NetworkInterface cached;
static {
try {
@@ -37,9 +37,9 @@ public class MacAddress {
return mac;
}
public static MacAddress getByInetAddress(InetAddress addr) {
public static NetworkInterface getByInetAddress(InetAddress addr) {
if (cached == null)
cached = new MacAddress();
cached = new NetworkInterface();
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);
}
}
+1 -2
View File
@@ -102,8 +102,7 @@ public class BotUI extends JFrame implements ActionListener, ComponentListener,
System.exit(0);
break;
case "Network":
NetworkUI UI = new NetworkUI();
UI.frame.setVisible(true);
NetworkUI.getInstance().setVisible(true);
break;
case "Run":
if(pauseScript) {
+263 -89
View File
@@ -1,111 +1,285 @@
package org.parabot.core.ui;
import org.parabot.core.spoofer.Proxy;
import javax.swing.*;
import java.awt.event.ActionEvent;
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 {
public JFrame frame;
private JTextField proxyHostField;
private JTextField proxyPortField;
private HashMap<String, Integer> socksVersions;
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;
public NetworkUI() {
this.socksVersions = new HashMap<String, Integer>();
initialize();
}
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 static void main(String[] args){
NetworkUI window = new NetworkUI();
window.frame.setVisible(true);
}
public class NetworkUI extends JFrame implements KeyListener, ActionListener,
DocumentListener {
private void initialize() {
socksVersions.put("Socks 4", 4);
socksVersions.put("Socks 5", 5);
frame = new JFrame();
frame.setResizable(false);
frame.setBounds(100, 100, 450, 300);
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.getContentPane().setLayout(null);
/**
*
*/
private static final long serialVersionUID = 1L;
JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
tabbedPane.setBounds(6, 6, 438, 233);
frame.getContentPane().add(tabbedPane);
private static NetworkUI instance;
JPanel proxy = new JPanel();
tabbedPane.addTab("Proxy", null, proxy, null);
proxy.setLayout(null);
private JComboBox<ProxyType> proxyType;
private JTextField proxyHost;
private IntTextField proxyPort;
private JButton submitButton;
JLabel socksOption = new JLabel("Socks version");
socksOption.setBounds(6, 6, 87, 16);
proxy.add(socksOption);
JList<String>[] macList;
JScrollPane[] macScrollList;
final JComboBox<String> socksOptions = new JComboBox<String>();
for (String key : socksVersions.keySet()) {
socksOptions.addItem(key);
}
socksOptions.setBounds(105, 2, 127, 27);
proxy.add(socksOptions);
private NetworkUI() {
initGUI();
}
JLabel proxyHost = new JLabel("Proxy host");
proxyHost.setBounds(6, 66, 87, 16);
proxy.add(proxyHost);
public static NetworkUI getInstance() {
return instance == null ? instance = new NetworkUI() : instance;
}
proxyHostField = new JTextField();
proxyHostField.setBounds(105, 60, 127, 28);
proxy.add(proxyHostField);
proxyHostField.setColumns(10);
@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());
setLocationRelativeTo(BotUI.getInstance());
super.setVisible(b);
}
JLabel proxyPort = new JLabel("Proxy port");
proxyPort.setBounds(6, 126, 87, 16);
proxy.add(proxyPort);
@SuppressWarnings("unchecked")
private void initGUI() {
proxyType = new JComboBox<ProxyType>(ProxyType.values());
proxyType.setSelectedItem(ProxySocket.getProxyType());
proxyPortField = new JTextField();
proxyPortField.setBounds(105, 120, 127, 28);
proxy.add(proxyPortField);
proxyPortField.setColumns(10);
proxyHost = new JTextField();
proxyHost.addKeyListener(this);
JPanel macAddress = new JPanel();
tabbedPane.addTab("Mac address", null, macAddress, null);
macAddress.setLayout(null);
proxyPort = new IntTextField(80, 5);
proxyPort.setColumns(5);
proxyPort.addKeyListener(this);
JLabel enableSpoofer = new JLabel("Enable mac spoofer");
enableSpoofer.setBounds(6, 80, 99, 16);
macAddress.add(enableSpoofer);
submitButton = new JButton("Submit");
submitButton.addActionListener(this);
final ButtonGroup bg = new ButtonGroup();
JRadioButton spooferYes = new JRadioButton("Yes");
spooferYes.setBounds(117, 76, 59, 23);
macAddress.add(spooferYes);
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);
JRadioButton spooferNo = new JRadioButton("No");
spooferNo.setBounds(188, 76, 59, 23);
macAddress.add(spooferNo);
spooferNo.setSelected(true);
}
JPanel p = createPanelUI();
add(p);
setResizable(false);
setDefaultCloseOperation(HIDE_ON_CLOSE);
pack();
setTitle("Network Settings");
}
bg.add(spooferYes);
bg.add(spooferNo);
private JPanel createPanelUI() {
JPanel ret = new JPanel();
ret.setLayout(new BoxLayout(ret, BoxLayout.LINE_AXIS));
Box main = Box.createVerticalBox();
JButton submit = new JButton("Submit");
submit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (!proxyHostField.getText().isEmpty() && !proxyPortField.getText().isEmpty()){
try{
Integer.parseInt(proxyPortField.getText());
}catch (Exception ex){
System.out.println("The given port is not a numeric value");
return;
}
Proxy.setProxy(proxyHostField.getText(), Integer.parseInt(proxyPortField.getText()));
frame.setVisible(false);
}
}
});
submit.setBounds(327, 243, 117, 29);
frame.getContentPane().add(submit);
}
}
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 {
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) {
}
}
}
}
}