mirror of
https://github.com/norandom/log2ml.git
synced 2024-12-04 22:53:44 +00:00
Simulator code to auto-accept Excel Macros
This commit is contained in:
parent
2a0ad000ae
commit
24886d88e7
BIN
2-4-initial-access-malware/Simulator/enable_content.png
Executable file
BIN
2-4-initial-access-malware/Simulator/enable_content.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 891 B |
49
2-4-initial-access-malware/Simulator/simulator.py
Executable file
49
2-4-initial-access-malware/Simulator/simulator.py
Executable file
@ -0,0 +1,49 @@
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import pyautogui
|
||||
|
||||
def open_excel_with_macros(file_path):
|
||||
# Get the directory of the current script/executable
|
||||
base_path = getattr(sys, '_MEIPASS', os.path.dirname(os.path.abspath(__file__)))
|
||||
enable_button_image = os.path.join(base_path, 'enable_content.png')
|
||||
|
||||
# Open Excel through the OS start menu or command line
|
||||
os.startfile(file_path)
|
||||
time.sleep(5) # Wait for Excel to open
|
||||
|
||||
# Custom timeout mechanism to locate the 'Enable Content' button
|
||||
timeout = 10 # 10 seconds timeout
|
||||
start_time = time.time()
|
||||
enable_button = None
|
||||
|
||||
while (time.time() - start_time) < timeout:
|
||||
enable_button = pyautogui.locateCenterOnScreen(enable_button_image, confidence=0.8)
|
||||
if enable_button:
|
||||
pyautogui.click(enable_button)
|
||||
break
|
||||
time.sleep(1) # Check every 1 second
|
||||
|
||||
if not enable_button:
|
||||
print("Enable Content button not found, continuing...")
|
||||
|
||||
# Wait for any macros to finish running or other processing
|
||||
time.sleep(10) # Adjust time based on expected macro execution time
|
||||
|
||||
# Close Excel without saving
|
||||
pyautogui.hotkey('alt', 'f4')
|
||||
time.sleep(1)
|
||||
pyautogui.press('n') # Press 'n' in response to Excel's save prompt
|
||||
|
||||
def main():
|
||||
directory = r'C:\Users\mariu\Desktop\Corpus' # Adjust the path to your files
|
||||
files = os.listdir(directory)
|
||||
excel_files = [file for file in files if file.endswith(('.xlsx', '.xlsm'))]
|
||||
|
||||
for file in excel_files:
|
||||
full_path = os.path.join(directory, file)
|
||||
open_excel_with_macros(full_path)
|
||||
time.sleep(5) # Adjust as needed between openings
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
Loading…
Reference in New Issue
Block a user