Files
sigma-rules/rta/powershell_base64_gzip.py
T

39 lines
1.2 KiB
Python
Raw Normal View History

2020-06-29 23:07:16 -06:00
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
2021-03-03 22:12:11 -09:00
# or more contributor license agreements. Licensed under the Elastic License
# 2.0; you may not use this file except in compliance with the Elastic License
# 2.0.
2020-06-29 23:07:16 -06:00
# Name: PowerShell with base64/gzip
# RTA: powershell_base64_gzip.py
# ATT&CK: T1140
# Description: Calls PowerShell with command-line that contains base64/gzip
from . import common
2022-09-08 12:50:39 -04:00
from . import RtaMetadata
2020-06-29 23:07:16 -06:00
2022-09-08 12:50:39 -04:00
metadata = RtaMetadata(
uuid="38defc7e-7234-45a2-83ef-e845d0eba3f2",
platforms=["windows"],
endpoint=[],
siem=[
{
"rule_id": "81fe9dc6-a2d7-4192-a2d8-eed98afc766a",
"rule_name": "PowerShell Suspicious Payload Encoded and Compressed",
}
],
techniques=["T1140", "T1027", "T1059"],
)
2023-10-03 10:47:58 -04:00
@common.requires_os(*metadata.platforms)
2020-06-29 23:07:16 -06:00
def main():
common.log("PowerShell with base64/gzip")
2022-09-08 12:50:39 -04:00
command = "powershell.exe -noni -nop -w hidden -c &([scriptblock]::create((New-Object IO.StreamReader(New-Object IO.Compression.GzipStream((New-Object IO.MemoryStream(,[Convert]::FromBase64String(aaa)" # noqa: E501
2020-06-29 23:07:16 -06:00
common.execute(command)
if __name__ == "__main__":
exit(main())