Files
sigma-rules/rta/smb_connection.py
T

47 lines
1.3 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: Outbound SMB from a User Process
# RTA: smb_connection.py
# ATT&CK: T1105
# Description: Initiates an SMB connection to a target machine, without going through the normal Windows APIs.
import socket
import sys
from . import common
2022-09-08 12:50:39 -04:00
from . import RtaMetadata
metadata = RtaMetadata(
uuid="b0e3e1bb-dfa5-473a-8862-b2d1d42819ce",
platforms=["windows"],
endpoint=[],
siem=[{"rule_id": "c82c7d8f-fb9e-4874-a4bd-fd9e3f9becf1", "rule_name": "Direct Outbound SMB Connection"}],
techniques=["T1021"],
)
2020-06-29 23:07:16 -06:00
SMB_PORT = 445
2023-10-03 10:47:58 -04:00
@common.requires_os(*metadata.platforms)
2020-06-29 23:07:16 -06:00
def main(ip=None):
ip = ip or common.get_ip()
# connect to rpc
common.log("Connecting to {}:{}".format(ip, SMB_PORT))
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((ip, 445))
common.log("Sending HELLO")
s.send(b"HELLO!")
2021-08-15 06:29:10 +02:00
common.log("Shutting down the connection...")
2020-06-29 23:07:16 -06:00
s.close()
common.log("Closed connection to {}:{}".format(ip, SMB_PORT))
if __name__ == "__main__":
exit(main(*sys.argv[1:]))