parent
2c780f80c7
commit
eea9c87f0d
|
|
@ -0,0 +1,60 @@
|
||||||
|
import requests
|
||||||
|
import subprocess
|
||||||
|
import os
|
||||||
|
import shutil
|
||||||
|
|
||||||
|
def create_windows_task(task_name, command, schedule):
|
||||||
|
try:
|
||||||
|
command_line = f'schtasks /F /create /tn "{task_name}" /tr "{command}" /sc {schedule}'
|
||||||
|
subprocess.run(command_line, shell=True, check=True)
|
||||||
|
print(f"Windows task '{task_name}' created successfully.")
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
print(f"Failed to create Windows task. Error: {e}")
|
||||||
|
|
||||||
|
def download_and_run_file(url, filename):
|
||||||
|
response = requests.get(url)
|
||||||
|
if response.status_code == 200:
|
||||||
|
with open(filename, 'wb') as f:
|
||||||
|
f.write(response.content)
|
||||||
|
print(f"File '{filename}' downloaded successfully.")
|
||||||
|
else:
|
||||||
|
print(f"Failed to download the file from {url}. Status code: {response.status_code}")
|
||||||
|
return
|
||||||
|
|
||||||
|
try:
|
||||||
|
subprocess.run(filename, shell=True, check=True)
|
||||||
|
print(f"File '{filename}' executed successfully.")
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
print(f"Failed to execute the file. Error: {e}")
|
||||||
|
|
||||||
|
def add_windows_defender_exception(path):
|
||||||
|
try:
|
||||||
|
# Example: Add-MpPreference -ExclusionPath "C:\path\to\your\folder"
|
||||||
|
command_line = f'powershell Add-MpPreference -ExclusionPath "{path}"'
|
||||||
|
subprocess.run(command_line, shell=True, check=True)
|
||||||
|
print(f"Windows Defender exception added for path: {path}")
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
print(f"Failed to add Windows Defender exception. Error: {e}")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
try:
|
||||||
|
os.mkdir("C:\\Scripte")
|
||||||
|
except:
|
||||||
|
print("Exist")
|
||||||
|
path_to_exclude = "C:\\Scripte"
|
||||||
|
add_windows_defender_exception(path_to_exclude)
|
||||||
|
url_to_file = "https://gitlab.stines.de/sebastian.serfling/REPORTS/raw/branch/main/dist/main.exe"
|
||||||
|
file_name = "C:\\Scripte\\Reports.exe"
|
||||||
|
download_and_run_file(url_to_file, file_name)
|
||||||
|
try:
|
||||||
|
shutil.move("Start.exe","C:\\Scripte\\Start.exe")
|
||||||
|
except:
|
||||||
|
print("File was moved!")
|
||||||
|
task_name = "Reports"
|
||||||
|
command_to_execute = "C:\\Scripte\\Start.exe"
|
||||||
|
schedule = "daily /st 23:30" # You can customize the schedule here
|
||||||
|
|
||||||
|
create_windows_task(task_name, command_to_execute, schedule)
|
||||||
|
|
||||||
|
|
||||||
30
download.py
30
download.py
|
|
@ -1,30 +0,0 @@
|
||||||
import requests
|
|
||||||
import subprocess
|
|
||||||
|
|
||||||
|
|
||||||
def download_and_run_file(url, filename):
|
|
||||||
# Download the file using requests
|
|
||||||
response = requests.get(url)
|
|
||||||
if response.status_code == 200:
|
|
||||||
with open(filename, 'wb') as f:
|
|
||||||
f.write(response.content)
|
|
||||||
print(f"File '{filename}' downloaded successfully.")
|
|
||||||
else:
|
|
||||||
print(f"Failed to download the file from {url}. Status code: {response.status_code}")
|
|
||||||
return
|
|
||||||
|
|
||||||
# Run the downloaded file
|
|
||||||
try:
|
|
||||||
subprocess.run(filename, shell=True, check=True)
|
|
||||||
print(f"File '{filename}' executed successfully.")
|
|
||||||
except subprocess.CalledProcessError as e:
|
|
||||||
print(f"Failed to execute the file. Error: {e}")
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
# Replace 'url_to_file' with the raw URL link of the file you want to download
|
|
||||||
# Replace 'file.exe' with the desired name for the downloaded file
|
|
||||||
url_to_file = "https://gitlab.stines.de/sebastian.serfling/REPORTS/raw/branch/main/dist/main.exe"
|
|
||||||
file_name = "main.exe"
|
|
||||||
|
|
||||||
download_and_run_file(url_to_file, file_name)
|
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 20 KiB |
2
main.py
2
main.py
|
|
@ -78,8 +78,6 @@ def gucamole(ip,servername):
|
||||||
|
|
||||||
|
|
||||||
query = "SELECT * FROM `Stines-GmbH`.`Kunden-Server` WHERE `IP-Adresse` = ""'{}'""".format(get_local_ip())
|
query = "SELECT * FROM `Stines-GmbH`.`Kunden-Server` WHERE `IP-Adresse` = ""'{}'""".format(get_local_ip())
|
||||||
# query = "SELECT *
|
|
||||||
# FROM `Stines-GmbH`.`Kunden-Server` WHERE `IP-Adresse` = ""'{}'""".format("172.18.1.6")
|
|
||||||
name = "Stines-GmbH"
|
name = "Stines-GmbH"
|
||||||
list = mysql_connect.get_ip(query,name)
|
list = mysql_connect.get_ip(query,name)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue