GitLab IES San Clemente

Commit 3ef67b5f authored by ciberCE - Prado Cimadevila's avatar ciberCE - Prado Cimadevila
Browse files

Carga ficheiros

parents
import zipfile
import os
def backuptoZip(folder):
folder = os.path.abspath(folder)
number = 1
while True:
zipFileName = os.path.basename(folder) + '_' + str(number) + '.zip'
if not os.path.exists(zipFileName):
break
number =number + 1
backupZip = zipfile.ZipFile(zipFileName, 'w')
for foldername, subfolders, filenames in os.walk(folder):
backupZip.write(foldername)
for filename in filenames:
backupZip.write(os.path.join(foldername,filename))
backupZip.close()
print('Fin del proceso')
BPC|BCKUP:1|SEND:0|AUTH:1
import requests
import backup
# función para leer el archivo flow.txt
def procesar_data(d):
if d is not None:
datos = d.split('|')
operador = datos[0]
comando1 = datos[1]
comando2 = datos[2]
comando3 = datos[3]
resultado = operador, comando1, comando2, comando3
return resultado
# Recuperamos los datos
if __name__ == '__main__':
# repositorio
res = requests.get('https://raw.githubusercontent.com/a21borjapc/ppsegura/main/flow.txt')
# datos
datos = procesar_data(res.text)
# separar partes separadas por :
isBackup = datos[1].split(':')[1]
isSent = datos[2].split(':')[1]
isAuth = datos[3].split(':')[1]
# imprimimos las acciones detectadas
print("Backup: ", isBackup)
print("Enviar?: ", isSent)
print("Autorizado:",isAuth)
if int(isBackup) == 1 and int(isAuth) == 1:
backup.backuptoZip('data')
else:
print('El proceso de copia de seguridad esta deshabilitado')
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment