Skip to content

Edit findl4jvulnerabilities #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 54 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
34f709c
Decompress ZIP
s-nix Dec 15, 2021
a1dbb05
Add param block
s-nix Dec 15, 2021
513f86e
Fix formatting
s-nix Dec 15, 2021
e53773a
Fix issue with running in separate directory
s-nix Dec 15, 2021
bd32483
Fix param and YARA scan path
s-nix Dec 15, 2021
cb80687
Edit README and add .gitignore
s-nix Dec 15, 2021
d939126
Implement Everything search
s-nix Dec 15, 2021
e1338b7
Update README
s-nix Dec 15, 2021
92aa766
Update .gitignore
s-nix Dec 16, 2021
e8ed7e5
Update .gitignore
s-nix Dec 16, 2021
432396f
Add Luna detection
s-nix Dec 16, 2021
125df45
Update README
s-nix Dec 16, 2021
c8809c5
Update Command-Help
s-nix Dec 16, 2021
01b8007
Fix big in single drive selection from gwmi
s-nix Dec 16, 2021
d192e7b
Remove old comment
s-nix Dec 16, 2021
5263271
Spacing
s-nix Dec 16, 2021
5dd8ee9
Add Everything exception and remove -include
s-nix Dec 17, 2021
a9fc0ae
Stop Everything if running
s-nix Dec 17, 2021
083f03c
Uninstall Everything service first
s-nix Dec 17, 2021
d137f3b
Uninstall everything service on fail
s-nix Dec 20, 2021
7338bf8
Add C++ install and Yara skip condition
s-nix Dec 21, 2021
6ff773c
Sleep for C++
s-nix Dec 21, 2021
27afc2a
Revoking C++
s-nix Dec 21, 2021
67320a7
Rename PS1
s-nix Dec 21, 2021
2cb0307
Add regions and bootstrap
s-nix Dec 21, 2021
ffaac7c
Implement robust logging and robocopy
s-nix Dec 21, 2021
4c86dcc
Implement log size management
s-nix Dec 21, 2021
504c6ef
Update README
s-nix Dec 21, 2021
963cf1c
Update README
s-nix Dec 21, 2021
2e0deb9
Update .gitignore
s-nix Dec 21, 2021
c89d362
Update YARA definitions
s-nix Dec 21, 2021
ca40642
Fix backwards compat for Expand-Archive
s-nix Dec 21, 2021
67acbf6
Update README
s-nix Dec 21, 2021
85dc832
Update README.md
s-nix Dec 21, 2021
7fdd1a0
Update README.md
s-nix Dec 21, 2021
78c090f
Update README.md
s-nix Dec 21, 2021
f0635bd
Implement PowerShell upgrade
s-nix Dec 21, 2021
3bf00ea
Create CODEOWNERS
s-nix Jul 5, 2022
6e4a982
Bump version of log4shell from 1.3.0 to 1.6.1
s-nix Nov 17, 2022
05c5e71
Merge pull request #5 from ProVal-Tech/1-version-of-log4shell-is-out-…
s-nix Nov 17, 2022
cf784bd
Add warning suppression and symlink switches
s-nix Nov 17, 2022
6c45f0c
Add additional logging
s-nix Nov 17, 2022
c8e46d0
Merge pull request #6 from ProVal-Tech/4-suppress-warning-messages-fr…
s-nix Nov 17, 2022
4a1f7ea
Replace Get-WMIObject with Get-CimInstance
s-nix Nov 17, 2022
fc919e0
Merge pull request #7 from ProVal-Tech/2-use-get-ciminstance-instead-…
s-nix Nov 17, 2022
1128c98
Move luna and yara to Call Operator
s-nix Nov 17, 2022
9a33ad4
Merge pull request #8 from ProVal-Tech/3-change-calls-to-external-exes
s-nix Nov 17, 2022
888c641
start looking for lookupdir
ChrisCalv Jan 5, 2023
5bf02d5
Adjust L4J script, add logic to read md5s
ChrisCalv Jan 18, 2023
cdd1567
Update formatting and logic for consistency
s-nix Jan 20, 2023
3a2e94e
Merge pull request #10 from ProVal-Tech/feat-jndimanager-md5
s-nix Feb 3, 2023
48f16c5
Adjust Script
ChrisCalv Mar 24, 2023
c161686
Merge pull request #11 from ProVal-Tech/edit-find-log4jvulnerabilities
s-nix Mar 24, 2023
c664b0b
Adjust Content,
ChrisCalv Mar 28, 2023
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
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @nixuno
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
*.txt
*.log
*.csv
log4shell.exe
Everything/*
Everything.zip
.vscode/*
4 changes: 4 additions & 0 deletions EverythingConfig.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[Everything]
auto_include_removable_refs_volumes=1
auto_include_removable_volumes=1
hide_empty_search_results=1
513 changes: 513 additions & 0 deletions Find-L4JVulnerabilities.ps1

Large diffs are not rendered by default.

Binary file not shown.
23 changes: 17 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
# Log4Shell Enumeration, Mitigation and Attack Detection Tool
### Build 8b, 13th December 2021
_By Datto, For the MSP Community_
_Based on Build 8b By Datto_

## Fork Edits
- Added param block, preserving initial `$env` variable usage
- Changed appropriate paths to point to the location of the script and not the current directory of the shell
- Editing some formatting
- Implemented Everything search option
- Implemented Luna scan from https://github.com/lunasec-io/lunasec/tree/master/tools/log4shell
- Overhauled logging system
- Added Robocopy option before using Get-ChildItem
- Implemented PowerShell upgrade

## Summary
This is a PowerShell-based script that can be run on a Windows system (it has been neither written for, nor tested with, other platforms) to:
Expand All @@ -9,7 +18,7 @@ This is a PowerShell-based script that can be run on a Windows system (it has be
* _This is not conclusive and should be used for reference only_
* Using the YARA tool and [Florian Roth's definitions](https://github.com/Neo23x0/signature-base/blob/master/yara/expl_log4j_cve_2021_44228.yar), check all JAR, LOG and TXT files on the system for indicators of Log4Shell attacks

The script was originally developed as a Component for the [Datto RMM software](www.datto.com/rmm); however, as part of Datto's ongoing commitment to the MSP, it has been released for free for the Community.
The script was originally developed as a Component for the [Datto RMM software](www.datto.com/rmm); however, as part of Datto's ongoing commitment to the MSP, it has been released for free for the Community and heavily modified by ProVal Tech.

## Usage

Expand All @@ -19,8 +28,8 @@ Three environment variables _(ie: $env:variableName)_ must be furnished, either
* Value of 2: Scan all fixed and removable drives
* Value of 3: Scan all drives, including Network drives _(Slowest scan time -- may take several hours)_
* usrUpdateDefs
* Value of `true`: Download the latest YARA definitions from Florian Roth to scan files against
* Value of `false`: Use definitions attached
* Value of `$True`: Download the latest YARA definitions from Florian Roth to scan files against
* Value of `$False`: Use definitions attached
* usrMitigate
* Value of Y: Inoculate system by setting `LOG4J_FORMAT_MSG_NO_LOOKUPS` environment variable to `TRUE`
* Value of N: De-inoculate system by setting `LOG4J_FORMAT_MSG_NO_LOOKUPS` environment variable to `FALSE` (Use with caution!)
Expand All @@ -30,8 +39,10 @@ Three environment variables _(ie: $env:variableName)_ must be furnished, either

* [Yara](https://github.com/VirusTotal/yara) 4.1.3-1755 (32- & 64-bit) & COPYING document
* Florian Roth's YARA definitions for Log4Shell as of 13th December 2021

* [Luna](https://github.com/lunasec-io/lunasec/tree/master/tools/log4shell)
## Credits
This script was written by seagull for Datto RMM and the wider MSP Community. It may be freely copied, edited and redistributed provided credits to Datto, seagull & a link to this GitHub repo remain in the comments.
YARA is a tool by the VirusTotal project. The definitions used here were created by Florian Roth.
www.datto.com/rmm

Forked and modified by [ProVal Tech](https://www.provaltech.com)
175 changes: 175 additions & 0 deletions expl_log4j_cve_2021_44228.yar
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@

rule EXPL_Log4j_CallBackDomain_IOCs_Dec21_1 {
meta:
description = "Detects IOCs found in Log4Shell incidents that indicate exploitation attempts of CVE-2021-44228"
author = "Florian Roth"
reference = "https://gist.github.com/superducktoes/9b742f7b44c71b4a0d19790228ce85d8"
date = "2021-12-12"
score = 60
strings:
$xr1 = /\b(ldap|rmi):\/\/([a-z0-9\.]{1,16}\.bingsearchlib\.com|[a-z0-9\.]{1,40}\.interact\.sh|[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}):[0-9]{2,5}\/([aZ]|ua|Exploit|callback|[0-9]{10}|http443useragent|http80useragent)\b/
condition:
1 of them
}

rule EXPL_JNDI_Exploit_Patterns_Dec21_1 {
meta:
description = "Detects JNDI Exploit Kit patterns in files"
author = "Florian Roth"
reference = "https://github.com/pimps/JNDI-Exploit-Kit"
date = "2021-12-12"
score = 60
strings:
$ = "/Basic/Command/Base64/"
$ = "/Basic/ReverseShell/"
$ = "/Basic/TomcatMemshell"
$ = "/Basic/JettyMemshell"
$ = "/Basic/WeblogicMemshell"
$ = "/Basic/JBossMemshell"
$ = "/Basic/WebsphereMemshell"
$ = "/Basic/SpringMemshell"
$ = "/Deserialization/URLDNS/"
$ = "/Deserialization/CommonsCollections1/Dnslog/"
$ = "/Deserialization/CommonsCollections2/Command/Base64/"
$ = "/Deserialization/CommonsBeanutils1/ReverseShell/"
$ = "/Deserialization/Jre8u20/TomcatMemshell"
$ = "/TomcatBypass/Dnslog/"
$ = "/TomcatBypass/Command/"
$ = "/TomcatBypass/ReverseShell/"
$ = "/TomcatBypass/TomcatMemshell"
$ = "/TomcatBypass/SpringMemshell"
$ = "/GroovyBypass/Command/"
$ = "/WebsphereBypass/Upload/"
condition:
1 of them
}

rule EXPL_Log4j_CVE_2021_44228_JAVA_Exception_Dec21_1 {
meta:
description = "Detects exceptions found in server logs that indicate an exploitation attempt of CVE-2021-44228"
author = "Florian Roth"
reference = "https://gist.github.com/Neo23x0/e4c8b03ff8cdf1fa63b7d15db6e3860b"
date = "2021-12-12"
score = 60
strings:
$xa1 = "header with value of BadAttributeValueException: "

$sa1 = ".log4j.core.net.JndiManager.lookup(JndiManager"
$sa2 = "Error looking up JNDI resource"
condition:
$xa1 or all of ($sa*)
}

rule EXPL_Log4j_CVE_2021_44228_Dec21_Soft {
meta:
description = "Detects indicators in server logs that indicate an exploitation attempt of CVE-2021-44228"
author = "Florian Roth"
reference = "https://twitter.com/h113sdx/status/1469010902183661568?s=20"
date = "2021-12-10"
modified = "2021-12-12"
score = 60
strings:
$ = "${jndi:ldap:/"
$ = "${jndi:rmi:/"
$ = "${jndi:ldaps:/"
$ = "${jndi:dns:/"
$ = "${jndi:iiop:/"
$ = "${jndi:http:/"
$ = "${jndi:nis:/"
$ = "${jndi:nds:/"
$ = "${jndi:corba:/"
condition:
1 of them
}

rule EXPL_Log4j_CVE_2021_44228_Dec21_OBFUSC {
meta:
description = "Detects obfuscated indicators in server logs that indicate an exploitation attempt of CVE-2021-44228"
author = "Florian Roth"
reference = "https://twitter.com/h113sdx/status/1469010902183661568?s=20"
date = "2021-12-12"
score = 60
strings:
$x1 = "$%7Bjndi:"
$x2 = "%2524%257Bjndi"
$x3 = "%2F%252524%25257Bjndi%3A"
$x4 = "${jndi:${lower:"
$x5 = "${::-j}${"
$x6 = "${${env:BARFOO:-j}"
$x7 = "${::-l}${::-d}${::-a}${::-p}"
$x8 = "${base64:JHtqbmRp"
condition:
1 of them
}

rule EXPL_Log4j_CVE_2021_44228_Dec21_Hard {
meta:
description = "Detects indicators in server logs that indicate the exploitation of CVE-2021-44228"
author = "Florian Roth"
reference = "https://twitter.com/h113sdx/status/1469010902183661568?s=20"
date = "2021-12-10"
modified = "2021-12-12"
score = 80
strings:
$x1 = /\$\{jndi:(ldap|ldaps|rmi|dns|iiop|http|nis|nds|corba):\/[\/]?[a-z-\.0-9]{3,120}:[0-9]{2,5}\/[a-zA-Z\.]{1,32}\}/
$fp1r = /(ldap|rmi|ldaps|dns):\/[\/]?(127\.0\.0\.1|192\.168\.|172\.[1-3][0-9]\.|10\.)/
condition:
$x1 and not 1 of ($fp*)
}

rule SUSP_Base64_Encoded_Exploit_Indicators_Dec21 {
meta:
description = "Detects base64 encoded strings found in payloads of exploits against log4j CVE-2021-44228"
author = "Florian Roth"
reference = "https://twitter.com/Reelix/status/1469327487243071493"
date = "2021-12-10"
score = 70
strings:
/* curl -s */
$sa1 = "Y3VybCAtcy"
$sa2 = "N1cmwgLXMg"
$sa3 = "jdXJsIC1zI"
/* |wget -q -O- */
$sb1 = "fHdnZXQgLXEgLU8tI"
$sb2 = "x3Z2V0IC1xIC1PLS"
$sb3 = "8d2dldCAtcSAtTy0g"
condition:
1 of ($sa*) and 1 of ($sb*)
}

rule SUSP_JDNIExploit_Indicators_Dec21 {
meta:
description = "Detects indicators of JDNI usage in log files and other payloads"
author = "Florian Roth"
reference = "https://github.com/flypig5211/JNDIExploit"
date = "2021-12-10"
modified = "2021-12-12"
score = 70
strings:
$xr1 = /(ldap|ldaps|rmi|dns|iiop|http|nis|nds|corba):\/\/[a-zA-Z0-9\.]{7,80}:[0-9]{2,5}\/(Basic\/Command\/Base64|Basic\/ReverseShell|Basic\/TomcatMemshell|Basic\/JBossMemshell|Basic\/WebsphereMemshell|Basic\/SpringMemshell|Basic\/Command|Deserialization\/CommonsCollectionsK|Deserialization\/CommonsBeanutils|Deserialization\/Jre8u20\/TomcatMemshell|Deserialization\/CVE_2020_2555\/WeblogicMemshell|TomcatBypass|GroovyBypass|WebsphereBypass)\//
condition:
filesize < 100MB and $xr1
}

rule SUSP_EXPL_OBFUSC_Dec21_1{
meta:
description = "Detects obfuscation methods used to evade detection in log4j exploitation attempt of CVE-2021-44228"
author = "Florian Roth"
reference = "https://twitter.com/testanull/status/1469549425521348609"
date = "2021-12-11"
score = 60
strings:
/* ${lower:X} - single character match */
$ = { 24 7B 6C 6F 77 65 72 3A ?? 7D }
/* ${upper:X} - single character match */
$ = { 24 7B 75 70 70 65 72 3A ?? 7D }
/* URL encoded lower - obfuscation in URL */
$ = "$%7blower:"
$ = "$%7bupper:"
$ = "%24%7bjndi:"
$ = "$%7Blower:"
$ = "$%7Bupper:"
$ = "%24%7Bjndi:"
condition:
1 of them
}
Loading