Advertisement
iApplet

Manipulator (KRClient, M): 90akn

Mar 25th, 2012
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.94 KB | None | 0 0
  1. import javassist.ClassPool;
  2. import javassist.CtClass;
  3. import javassist.CtMethod;
  4. import javassist.CtField;
  5.  
  6. /**
  7.  *
  8.  * @author Flav
  9.  */
  10. public class Manipulator {
  11.     public static void main(String[] args) {
  12.    
  13.     //PARAMS
  14.     String butlerElement = "bp";
  15.     String chatFrame = "wa";
  16.     String FunctionChatFrame = "k";
  17.     String chatPanel = "qn";
  18.     String delimeter = "v";
  19.     //ENDE
  20.    
  21.         ClassPool cp = ClassPool.getDefault();
  22.         cp.importPackage("java.applet.AppletContext");
  23.         cp.importPackage("java.net.URL");
  24.         cp.importPackage("java.util.Enumeration");
  25.         cp.importPackage("java.util.StringTokenizer");
  26.  
  27.         try {
  28.             CtClass groupChat = cp.get("fr");
  29.            
  30.             CtField ca = CtField.make("public kTokenHandler kHandler;", groupChat);
  31.             groupChat.addField(ca);
  32.  
  33.             groupChat.addMethod(CtMethod.make(
  34.                 "public AppletContext getAppletContext() {"
  35.             +       "return new Context();"
  36.             +   "}"
  37.             , groupChat));
  38.  
  39.             groupChat.addMethod(CtMethod.make(
  40.                 "public URL getCodeBase() {"
  41.             +       "return new URL(Parameter.get(\"codebase\"));"
  42.             +   "}"
  43.             , groupChat));
  44.  
  45.             groupChat.getDeclaredMethod(
  46.                 "getDocumentBase"
  47.             ).setBody(
  48.                 "{"
  49.             +       "return new URL(Parameter.get(\"documentbase\"));"
  50.             +   "}"
  51.             );
  52.  
  53.             groupChat.getDeclaredMethod(
  54.                 "getParameter", new CtClass[] { cp.get("java.lang.String") }
  55.             ).setName("getParameterHook");
  56.             groupChat.addMethod(CtMethod.make(
  57.                 "public String getParameter(String param1) {"
  58.             +       "String param = Parameter.get($1);"
  59.             +       "return param != null ? param : getParameterHook($1);"
  60.             +   "}"
  61.             , groupChat));
  62.  
  63.  
  64.             groupChat.addMethod(CtMethod.make(
  65.                 "public String getButler() {"
  66.             +       "return (String) bp.elementAt(0);"
  67.             +   "}"
  68.             , groupChat));
  69.            
  70.             groupChat.addMethod(CtMethod.make(
  71.                 "public String getAppletVersion() {"
  72.             +   "    return \"90akn\";"
  73.             +   "}"
  74.             , groupChat));
  75.  
  76.             groupChat.addMethod(CtMethod.make(
  77.                 "public String getNickname() {"
  78.             +       "return _();"
  79.             +   "}"
  80.             , groupChat));
  81.  
  82.             groupChat.addMethod(CtMethod.make(
  83.                 "public String getChannel() {"
  84.             +       "return ba();"
  85.             +   "}"
  86.             , groupChat));
  87.  
  88.             groupChat.addMethod(CtMethod.make(
  89.                 "public Enumeration getChannels() {"
  90.             +       "return l();"
  91.             +   "}"
  92.             , groupChat));
  93.  
  94.             groupChat.addMethod(CtMethod.make(
  95.                 "public void print(String param1, String param2) {"
  96.             +       chatFrame +" frame = " + FunctionChatFrame+"($1);"
  97.  
  98.             +       "if (frame != null) {"
  99.             +           chatPanel + " panel = frame.a;"
  100.             +           "panel.l($2);"
  101.             +       "}"
  102.             +   "}"
  103.             , groupChat));
  104.  
  105.             groupChat.addMethod(CtMethod.make(
  106.                 "public void receive(String param1) {"
  107.             //+       "if ($1 != null){return;}"
  108.             +       "if ($1.startsWith(\":\" + " + delimeter+")) {"
  109.             +           "a($1, (\":\" + " + delimeter +").length());"
  110.             +       "} else {"
  111.             +           "af(new StringTokenizer($1, " + delimeter +", $1.startsWith(\"k\" + " + delimeter + ")));"
  112.             +       "}"
  113.             +   "}"
  114.             , groupChat));
  115.  
  116.             groupChat.addMethod(CtMethod.make(
  117.                 "public void send(String param1) {"
  118.             +       "a($1, false, 0);"
  119.             +   "}"
  120.             , groupChat));
  121.  
  122.             groupChat.getDeclaredMethod(
  123.                 "a", new CtClass[] { cp.get("java.lang.String"), cp.get("int") }
  124.             ).setName("parseModuleInput");
  125.             groupChat.addMethod(CtMethod.make(
  126.                 "private final void a(String param1, int param2) {"
  127.             +       "parseModuleInput($1, $2);"
  128.             +   "}"
  129.             , groupChat));
  130.  
  131.             groupChat.getDeclaredMethod(
  132.                 "af", new CtClass[] { cp.get("java.util.StringTokenizer") }
  133.             ).setName("parseInput");
  134.             groupChat.addMethod(CtMethod.make(
  135.                 "private final void af(StringTokenizer param1) {"
  136.                
  137.             +       "String opcode = $1.nextToken();"
  138.             +       "StringBuilder buffer = new StringBuilder(opcode);"
  139.  
  140.             +       "while ($1.hasMoreTokens()) {"
  141.             +           "if (!opcode.equals(\"k\")) {"
  142.             +               "buffer.append(" + delimeter+");"
  143.             +           "}"
  144.  
  145.             +           "buffer.append($1.nextToken());"
  146.             +       "}"
  147.  
  148.             +       "String packet = buffer.toString();"
  149.             +       "packet = kHandler.input(packet);"
  150.             +       "if (packet == null){return;}" 
  151.             +       "parseInput(new StringTokenizer(packet, " +delimeter+", packet.startsWith(\"k\" + "+ delimeter +")));"
  152.             +   "}"
  153.             , groupChat));
  154.  
  155.             groupChat.getDeclaredMethod(
  156.                 "a", new CtClass[] { cp.get("java.lang.String"), cp.get("boolean"), cp.get("int") }
  157.             ).setName("parseOutput");
  158.             groupChat.addMethod(CtMethod.make(
  159.                 "public synchronized boolean a(String param1, boolean param2, int param3) {"
  160.             +       "$1 = kHandler.output($1);"
  161.             +       "if ($1 == null){return false;}"
  162.             +       "String[] tokens = $1.split("+ delimeter+");"
  163.            
  164.             +       "if (tokens[0].equals(\"e\")) {"
  165.             +           "String msg = tokens[2];"
  166.             +           "String cmd = msg.substring(1).split(\" \")[0].trim().toLowerCase();"
  167.             +           "String arg = \"\";"
  168.  
  169.             +           "if (msg.length() > cmd.length() + 1) {"
  170.             +               "arg = msg.substring(msg.indexOf(' ') + 1);"
  171.             +           "}"
  172.  
  173.             +           "if (cmd.equals(\"sample\")) {"
  174.             +               "print(getChannel(), \"Du hast soeben die Sample-Funktion benutzt.\");"
  175.             +               "return true;"
  176.             +           "}"
  177.             +       "}"
  178.  
  179.             +       "return parseOutput($1, $2, $3);"
  180.             +   "}"
  181.             , groupChat));
  182.  
  183.             groupChat.writeFile();
  184.         } catch (Exception e) {
  185.             e.printStackTrace();
  186.         }
  187.     }
  188. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement