Files
sigma-rules/rta/smb_connection.py
T
Ross Wolf a0d3b4bd23 Populate RTA directory.
Co-Authored-By: Brent Murphy <56412096+bm11100@users.noreply.github.com>
Co-Authored-By: Daniel Stepanic <57736958+dstepanic17@users.noreply.github.com>
Co-Authored-By: David French <56409778+threat-punter@users.noreply.github.com>
Co-Authored-By: Joe Desimone <56411054+joe-desimone@users.noreply.github.com>
Co-Authored-By: Justin Ibarra <brokensound77@users.noreply.github.com>
2020-06-29 23:07:18 -06:00

35 lines
984 B
Python

# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
# or more contributor license agreements. Licensed under the Elastic License;
# you may not use this file except in compliance with the Elastic License.
# 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
SMB_PORT = 445
@common.requires_os(common.WINDOWS)
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!")
common.log("Shutting down the conection...")
s.close()
common.log("Closed connection to {}:{}".format(ip, SMB_PORT))
if __name__ == "__main__":
exit(main(*sys.argv[1:]))