090600
This commit is contained in:
28
roles/graylog_collector/files/run_commands.py
Normal file
28
roles/graylog_collector/files/run_commands.py
Normal file
@@ -0,0 +1,28 @@
|
||||
import subprocess, os
|
||||
|
||||
commands = [
|
||||
'hostname',
|
||||
'rundll32 C:\\Users\\USERNAME\\AppData\\Local\\Temp\\easygoing.dat,#1',
|
||||
'nltest /domain_trusts /all_trusts',
|
||||
'nltest /domain_trusts',
|
||||
'net view /all /domain',
|
||||
'net view /all',
|
||||
'net group "Domain Admins" /domain',
|
||||
'chcp',
|
||||
'ipconfig /all',
|
||||
'net config workstation',
|
||||
'systeminfo'
|
||||
]
|
||||
|
||||
output_file = 'command_results.txt'
|
||||
|
||||
with open(output_file, 'w', encoding='utf-8') as file:
|
||||
for command in commands:
|
||||
try:
|
||||
result = subprocess.run(command, shell=True, capture_output=True, text=True)
|
||||
file.write(f"Command: {command}\n")
|
||||
file.write(f"Output:\n{result.stdout}\n")
|
||||
file.write(f"Error:\n{result.stderr}\n")
|
||||
file.write('-'*50 + '\n\n')
|
||||
except Exception as e:
|
||||
file.write(f"Command: {command}\nError: {str(e)}\n" + '-'*50 + '\n\n')
|
||||
Reference in New Issue
Block a user