0-day Vulnerability Scan: SpringShell or Spring4Shell

Here’s a Task I created to detect where the Spring framework has been embedded in the WAR file.
We have the relevance targeting Linux hosts where Java process version is >=9

override wait
timeout_seconds=60
disposition=terminate
parameter "scriptFile" = "{parent folder of parent folder of client folder of current site}/detectSpring.sh"
delete "{parameter "scriptFile"}"
createfile until __end__ 
#!/bin/bash
test -d /var/opt/BESClient/ || mkdir -p /var/opt/BESClient/
for war in $(locate -b --regex '[.]war$'); do war_file=$(basename "$war"); echo $(file $war) | grep -qv ' directory' && mkdir -p /tmp/bigfix && cp "$war" /tmp/bigfix/ && cd /tmp/bigfix && unzip -qjun "$war_file" && if ls | egrep -q -e 'spring-beans-.*.jar' -e 'CachedIntrospectionResuLts.class'; then echo "$war"; fi; rm -rf /tmp/bigfix/*; done > /var/opt/BESClient/Spring.txt
exit 0
__end__ 
move __createfile "{parameter "scriptFile"}" 
wait chmod 555 "{parameter "scriptFile"}" 
wait /bin/bash "{parameter "scriptFile"}"

Blockquote

Property to read the output is -

if exists files "Spring.txt" of parent folders of parent folders of client folders of sites "actionsite" then unique values of (it as trimmed string) of (if exists property "locked lines" then locked lines of it else lines of it) of files "Spring.txt" of parent folders of parent folders of client folders of sites "actionsite" else "N/A"

3 Likes