11package com .reajason .javaweb .memshell ;
22
3- import com .reajason .javaweb .memshell .config .*;
4- import com .reajason .javaweb .memshell .generator .*;
5- import com .reajason .javaweb .memshell .generator .command .CommandGenerator ;
3+ import com .reajason .javaweb .memshell .config .GenerateResult ;
4+ import com .reajason .javaweb .memshell .config .InjectorConfig ;
5+ import com .reajason .javaweb .memshell .config .ShellConfig ;
6+ import com .reajason .javaweb .memshell .config .ShellToolConfig ;
7+ import com .reajason .javaweb .memshell .generator .InjectorGenerator ;
68import com .reajason .javaweb .memshell .server .AbstractShell ;
79import com .reajason .javaweb .memshell .utils .CommonUtil ;
810import org .apache .commons .lang3 .StringUtils ;
@@ -45,7 +47,7 @@ public static GenerateResult generate(ShellConfig shellConfig, InjectorConfig in
4547 shellToolConfig .setShellClass (shellClass );
4648 }
4749
48- byte [] shellBytes = generateShellBytes (shellConfig , shellToolConfig );
50+ byte [] shellBytes = shellConfig . getShellTool (). generateBytes (shellConfig , shellToolConfig );
4951
5052 injectorConfig .setInjectorClass (injectorClass );
5153 injectorConfig .setShellClassName (shellToolConfig .getShellClassName ());
@@ -66,25 +68,4 @@ public static GenerateResult generate(ShellConfig shellConfig, InjectorConfig in
6668 .injectorInnerClassBytes (innerClassBytes )
6769 .build ();
6870 }
69-
70- private static byte [] generateShellBytes (ShellConfig shellConfig , ShellToolConfig shellToolConfig ) {
71- switch (shellConfig .getShellTool ()) {
72- case Godzilla :
73- return new GodzillaGenerator (shellConfig , (GodzillaConfig ) shellToolConfig ).getBytes ();
74- case Command :
75- return new CommandGenerator (shellConfig , (CommandConfig ) shellToolConfig ).getBytes ();
76- case Behinder :
77- return new BehinderGenerator (shellConfig , (BehinderConfig ) shellToolConfig ).getBytes ();
78- case Suo5 :
79- return new Suo5Generator (shellConfig , ((Suo5Config ) shellToolConfig )).getBytes ();
80- case AntSword :
81- return new AntSwordGenerator (shellConfig , (AntSwordConfig ) shellToolConfig ).getBytes ();
82- case NeoreGeorg :
83- return new NeoreGeorgGenerator (shellConfig , (NeoreGeorgConfig ) shellToolConfig ).getBytes ();
84- case Custom :
85- return new CustomShellGenerator (shellConfig , (CustomConfig ) shellToolConfig ).getBytes ();
86- default :
87- throw new UnsupportedOperationException ("Unknown shell tool: " + shellConfig .getShellTool ());
88- }
89- }
9071}
0 commit comments