Advertisement
Guest User

Untitled

a guest
May 14th, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.29 KB | None | 0 0
  1. import org.osbot.rs07.api.Client;
  2. import org.osbot.rs07.listener.LoginResponseCodeListener;
  3. import org.osbot.rs07.script.Script;
  4. import org.osbot.rs07.script.ScriptManifest;
  5. import org.osbot.rs07.utility.ConditionalSleep;
  6. import util.LoginEvent;
  7.  
  8. import java.sql.*;
  9.  
  10. @ScriptManifest(author = "Sibbernski", name = "sibbernskiAccountLocker", info = "hekkoi", version = 0.1, logo = "")
  11.  
  12. public class sibbernskiLocker extends Script {
  13.  
  14.     private boolean bannedOrLocked = false;
  15.  
  16.     private String[] params;
  17.     private String username;
  18.     private String password;
  19.     private String proxyId;
  20.     private LoginEvent loginEvent;
  21.  
  22.  
  23.     @Override
  24.     public void onStart() {
  25.         params = getParameters().split("/");
  26.         username = params[0];
  27.         password = params[1];
  28.         proxyId = params[2];
  29.         loginEvent = new LoginEvent(username, password);
  30.     }
  31.  
  32.     @Override
  33.     public int onLoop() throws InterruptedException {
  34.         if (!loginEvent.hasFinished() || !loginEvent.hasFailed()) {
  35.             loginCharacter();
  36.         }
  37.  
  38.         return 1000;
  39.     }
  40.  
  41.     @Override
  42.     public void onResponseCode(int code) {
  43.         log("Response code: " + code);
  44.         if (code != 2 && code != 9 && code != 5 && code != 21) {
  45.             log("login failed with code " + code);
  46.             stop();
  47.         }
  48.         switch (code) {
  49.             case 4:
  50.                 updateLockStatus();
  51.                 this.stop(true);
  52.                 System.exit(0);
  53.                 break;
  54.             case 18:
  55.                 updateBanStatus();
  56.                 this.stop(true);
  57.                 System.exit(0);
  58.                 break;
  59.         }
  60.     }
  61.  
  62.     private void updateLockStatus() {
  63.         try {
  64.             String host = "localhost:3306";
  65.             String db = "muling";
  66.             String user = "root";
  67.             String pass = "";
  68.             String connStr = String.format("jdbc:mysql://%s/%s?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC", host, db);
  69.             Connection conn = DriverManager.getConnection(connStr, user, pass);
  70.             ResultSet result = conn.createStatement().executeQuery("SELECT * FROM newaccs WHERE AccountName='" + username + "'");
  71.             if (result.next()) {
  72.                 String query = "UPDATE newaccs set AccountLocked='yes', AssignedProxy='" + proxyId + "' WHERE AccountName='" + username + "'";
  73.                 PreparedStatement preparedStmt = conn.prepareStatement(query);
  74.                 preparedStmt.executeUpdate();
  75.                 log("Account was locked, updated db.");
  76.                 bannedOrLocked = true;
  77.             }
  78.         } catch (SQLException e) {
  79.             log(e);
  80.         }
  81.     }
  82.  
  83.     private void updateBanStatus() {
  84.         try {
  85.             String host = "localhost:3306";
  86.             String db = "muling";
  87.             String user = "root";
  88.             String pass = "";
  89.             String connStr = String.format("jdbc:mysql://%s/%s?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC", host, db);
  90.             Connection conn = DriverManager.getConnection(connStr, user, pass);
  91.             ResultSet result = conn.createStatement().executeQuery("SELECT * FROM newaccs WHERE AccountName='" + username + "'");
  92.             if (result.next()) {
  93.                 String query = "UPDATE newaccs set AccountBanned='yes', AssignedProxy='" + proxyId + "' WHERE AccountName='" + username + "'";
  94.                 PreparedStatement preparedStmt = conn.prepareStatement(query);
  95.                 preparedStmt.executeUpdate();
  96.                 log("Account was banned, updated db.");
  97.                 bannedOrLocked = true;
  98.             }
  99.         } catch (SQLException e) {
  100.             log(e);
  101.         }
  102.     }
  103.  
  104.     private void loginCharacter() throws InterruptedException {
  105.         log("Login...");
  106.         sleep(2000);
  107.         if (getClient().getLoginState() != null && getClient().getLoginState() != Client.LoginState.LOADING_MAP && !getClient().isLoggedIn()) {
  108.             if (loginEvent != null && loginEvent.isWorking()) {
  109.                 return;
  110.             }
  111.             log("Logging: " + username);
  112.             loginEvent = new LoginEvent(username, password);
  113.             execute(loginEvent);
  114.         }
  115.     }
  116.  
  117. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement