mirror of
https://github.com/2006-Scape/Parabot.git
synced 2026-07-07 16:49:10 +00:00
Added option to randomize MAC address
This commit is contained in:
@@ -61,12 +61,12 @@ public class NetworkInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void setMac(byte[] mac2) {
|
public static void setMac(byte[] mac2) {
|
||||||
System.out.println("Setting mac address to:" + formatMac(mac2));
|
System.out.println("Setting mac address to: " + formatMac(mac2));
|
||||||
mac = mac2;
|
mac = mac2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String formatMac(byte[] mac){
|
public static String formatMac(byte[] mac){
|
||||||
StringBuffer b = new StringBuffer();
|
StringBuilder b = new StringBuilder();
|
||||||
for(int i = 0; i < 6;i++){
|
for(int i = 0; i < 6;i++){
|
||||||
b.append(String.format("%02X", mac[i]));
|
b.append(String.format("%02X", mac[i]));
|
||||||
if(i < 5)
|
if(i < 5)
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import java.awt.event.ActionEvent;
|
|||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
import java.awt.event.KeyListener;
|
import java.awt.event.KeyListener;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
public class NetworkUI extends JFrame implements KeyListener, ActionListener,
|
public class NetworkUI extends JFrame implements KeyListener, ActionListener,
|
||||||
DocumentListener {
|
DocumentListener {
|
||||||
@@ -36,6 +37,7 @@ public class NetworkUI extends JFrame implements KeyListener, ActionListener,
|
|||||||
private JCheckBox authCheckBox;
|
private JCheckBox authCheckBox;
|
||||||
private JTextField authUsername;
|
private JTextField authUsername;
|
||||||
private JPasswordField authPassword;
|
private JPasswordField authPassword;
|
||||||
|
private JButton randomize;
|
||||||
|
|
||||||
private NetworkUI() {
|
private NetworkUI() {
|
||||||
initGUI();
|
initGUI();
|
||||||
@@ -84,9 +86,25 @@ public class NetworkUI extends JFrame implements KeyListener, ActionListener,
|
|||||||
macList[i].setSelectedIndex(value);
|
macList[i].setSelectedIndex(value);
|
||||||
macScrollList[i] = new JScrollPane(macList[i]);
|
macScrollList[i] = new JScrollPane(macList[i]);
|
||||||
macList[i].ensureIndexIsVisible(value > 0 ? value - 1 : value);
|
macList[i].ensureIndexIsVisible(value > 0 ? value - 1 : value);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
randomize = new JButton("Randomize MAC");
|
||||||
|
randomize.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
Random rand = new Random();
|
||||||
|
byte[] macAddr = new byte[6];
|
||||||
|
rand.nextBytes(macAddr);
|
||||||
|
macAddr[0] = (byte)(macAddr[0] & (byte)254);
|
||||||
|
for (int i = 0; i < macAddr.length; i++) {
|
||||||
|
int value = macAddr[i] & 0xFF;
|
||||||
|
macList[i].setSelectedIndex(value);
|
||||||
|
macList[i].ensureIndexIsVisible(value > 0 ? value - 1 : value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
authCheckBox = new JCheckBox("Auth");
|
authCheckBox = new JCheckBox("Auth");
|
||||||
authCheckBox.setSelected(ProxySocket.auth);
|
authCheckBox.setSelected(ProxySocket.auth);
|
||||||
authCheckBox.addActionListener(this);
|
authCheckBox.addActionListener(this);
|
||||||
@@ -143,6 +161,8 @@ public class NetworkUI extends JFrame implements KeyListener, ActionListener,
|
|||||||
}
|
}
|
||||||
|
|
||||||
Box submit = Box.createHorizontalBox();
|
Box submit = Box.createHorizontalBox();
|
||||||
|
main.add(Box.createVerticalStrut(5));
|
||||||
|
submit.add(randomize);
|
||||||
submit.add(submitButton);
|
submit.add(submitButton);
|
||||||
|
|
||||||
main.add(type);
|
main.add(type);
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ public class Script implements Runnable {
|
|||||||
frameWorkType = TYPE_OTHER;
|
frameWorkType = TYPE_OTHER;
|
||||||
}
|
}
|
||||||
Core.verbose("Running script...");
|
Core.verbose("Running script...");
|
||||||
Logger.addMessage("Script started.");
|
Logger.addMessage("Script started.", true);
|
||||||
try {
|
try {
|
||||||
while(this.state != STATE_STOPPED) {
|
while(this.state != STATE_STOPPED) {
|
||||||
if(context.getRandomHandler().checkAndRun()) {
|
if(context.getRandomHandler().checkAndRun()) {
|
||||||
@@ -118,7 +118,7 @@ public class Script implements Runnable {
|
|||||||
}
|
}
|
||||||
Core.verbose("Script stopped/finished, unloading and stopping...");
|
Core.verbose("Script stopped/finished, unloading and stopping...");
|
||||||
onFinish();
|
onFinish();
|
||||||
Logger.addMessage("Script stopped.");
|
Logger.addMessage("Script stopped.", false);
|
||||||
context.getServerProvider().unloadScript(this);
|
context.getServerProvider().unloadScript(this);
|
||||||
this.state = STATE_STOPPED;
|
this.state = STATE_STOPPED;
|
||||||
context.setRunningScript(null);
|
context.setRunningScript(null);
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ public class RandomHandler {
|
|||||||
public boolean checkAndRun() {
|
public boolean checkAndRun() {
|
||||||
for(Random r : this.activeRandoms) {
|
for(Random r : this.activeRandoms) {
|
||||||
if(r.activate()) {
|
if(r.activate()) {
|
||||||
Logger.addMessage("Running random '" + r.getName() + "'");
|
Logger.addMessage("Running random '" + r.getName() + "'", true);
|
||||||
r.execute();
|
r.execute();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ public class UlirathaClient extends Thread {
|
|||||||
case 75:
|
case 75:
|
||||||
valid = stream.readBoolean();
|
valid = stream.readBoolean();
|
||||||
if (valid) {
|
if (valid) {
|
||||||
Logger.addMessage("We're connected with the Uliratha server!");
|
Logger.addMessage("We're connected with the Uliratha server!", false);
|
||||||
connected = true;
|
connected = true;
|
||||||
}else{
|
}else{
|
||||||
socket.close();
|
socket.close();
|
||||||
@@ -89,11 +89,11 @@ public class UlirathaClient extends Thread {
|
|||||||
|
|
||||||
public void connectionBroken(NIOSocket nioSocket, Exception exception) {
|
public void connectionBroken(NIOSocket nioSocket, Exception exception) {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
Logger.addMessage("We lost connection with the Uliratha server, reconnecting...");
|
Logger.addMessage("We lost connection with the Uliratha server, reconnecting...", false);
|
||||||
reconnect();
|
reconnect();
|
||||||
connected = false;
|
connected = false;
|
||||||
}else{
|
}else{
|
||||||
Logger.addMessage("We're disconnected from the Uliratha server");
|
Logger.addMessage("We're disconnected from the Uliratha server", false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user