tis-encrypt-sample icon

Encrypt Sample

Paquet d’installation silencieuse pour Encrypt Sample

0.4-0

  • package: tis-encrypt-sample
  • name: Encrypt Sample
  • version: 0.4-0
  • categories: Template,Security
  • maintainer: Tranquil IT
  • target_os: all
  • architecture: all
  • signature_date:
  • size: 5.89 Ko

package           : tis-encrypt-sample
version           : 0.4-0
architecture      : all
section           : base
priority          : optional
name              : Encrypt Sample
categories        : Template,Security
maintainer        : Tranquil IT
description       : Encrypt Sample Example
depends           : 
conflicts         : 
maturity          : PROD
locale            : 
target_os         : all
min_wapt_version  : 2.2
sources           : 
installed_size    : 
impacted_process  : 
description_fr    : 
description_pl    : 
description_de    : 
description_es    : 
description_pt    : 
description_it    : 
description_nl    : 
description_ru    : 
audit_schedule    : 
editor            : 
keywords          : 
licence           : 
homepage          : 
package_uuid      : 977bfd30-35e3-45e4-ac70-0d7a2eec1b6d
valid_from        : 
valid_until       : 
forced_install_on : 
changelog         : 
min_os_version    : 
max_os_version    : 
icon_sha256sum    : 9420721210f5d9c50c9e35c9fdbf0a088b30e165df8311c5f2176ce60e122475
signer            : Tranquil IT
signer_fingerprint: 8c5127a75392be9cc9afd0dbae1222a673072c308c14d88ab246e23832e8c6bb
signature_date    : 2025-03-10T16:12:41.000000
signed_attributes : package,version,architecture,section,priority,name,categories,maintainer,description,depends,conflicts,maturity,locale,target_os,min_wapt_version,sources,installed_size,impacted_process,description_fr,description_pl,description_de,description_es,description_pt,description_it,description_nl,description_ru,audit_schedule,editor,keywords,licence,homepage,package_uuid,valid_from,valid_until,forced_install_on,changelog,min_os_version,max_os_version,icon_sha256sum,signer,signer_fingerprint,signature_date,signed_attributes
signature         : hLwDlTsjAxTn7Y+RO7SkaL215EJj1zMC7ctbqOqqX/SLxrR+atfTuFKdK2Bz0QtGzIEwFlZV/AmWnBm8NaTCFcJ0oFGaarYiUimXaswSHXbc7rcF9g/dZSbYR3eBHamcohiGCphqZo1AZtqXYAt/LhZCBzRInIx0YSkpnPhKYsKop+qwetK85bNnmIPOW24etKrRObPo7G487FsZzFkTiPDPcjpjxw1/OxuncPJAYHoEX2jvFuxTw38N52YdWpKuowlC58VZATcrcu7bngLco4XFri9I4c3r159nTFcke6jFw087pN6PgqyQyh9KVmBFOcP8HNui8Wp5kJD0OfT3qw==

# -*- coding: utf-8 -*-
from setuphelpers import *
import json
import base64

encrypted_txt_file = "encrypted_txt.json"


def install():
    encryptlist = json_load_file(encrypted_txt_file)
    if WAPT.host_uuid in encryptlist:
        host_key = WAPT.get_host_key()
        v = base64.b64decode(encryptlist[WAPT.host_uuid])
        encrypted_txt = host_key.decrypt(v).decode("utf-8")
        print(rf"Here is the decrypted text: {encrypted_txt}")
    else:
        error(f"{WAPT.host_uuid} not found in {encrypted_txt_file}\nYou have to update-package and build_upload this package again")

# -*- coding: utf-8 -*-
from setuphelpers import *
import json
import base64
from waptcrypto import SSLCertificate
import waptguihelper
from common import WaptServer
from common import get_requests_client_cert_session
import waptlicences


encrypted_txt_file = "encrypted_txt.json"


def update_package():
    srvwapt_url = inifile_readstring(makepath(install_location("WAPT_is1"), "wapt-get.ini"), "global", "wapt_server")
    credentials_url = waptguihelper.login_password_dialog("Credentials for WAPT Server", srvwapt_url, "admin", "")

    encrypt_txt = waptguihelper.input_dialog("Encrypting with WAPT", "Enter the text to be encrypted: ", "")
    if not encrypt_txt:
        error("Please provide text to be encrypted")

    t = waptlicences.waptserver_login(WAPT.config_filename,credentials_url["user"],credentials_url["password"])
    s = get_requests_client_cert_session(srvwapt_url,  
    cert=(t['client_certificate'],t['client_private_key'],t['client_private_key_password']),
    verify=False
    )

    if not 'session' in t['session_cookies']:
        session_cookies = [u for u in t['session_cookies'] if u['Domain'] == WAPT.waptserver.server_url.split('://')[-1]][0]
    else:
        session_cookies = t['session_cookies']['session']
        session_cookies['Name'] = 'session'

    s.cookies.set(session_cookies['Name'], session_cookies['Value'], domain=session_cookies['Domain'])
    
    host_crt = s.get(f"{srvwapt_url}/api/v3/hosts?columns=host_certificate&limit=1000000")
    data = json.loads(host_crt.content)['result']

    encrypt_dict={}
    for value in data:
        if value["host_certificate"]:
            host_cert = SSLCertificate(crt_string=value["host_certificate"])
            encrypt_dict[value["uuid"]] = base64.b64encode(host_cert.encrypt(encrypt_txt.encode("utf-8"))).decode("utf-8")
            print(value["computer_fqdn"] + ":" + value["uuid"] + ":" + encrypt_dict[value["uuid"]])

    json_write_file(encrypted_txt_file, encrypt_dict)

38d056ab130f7bf7c481c12636a4e9959de36561d3dfcbe54c6e3571bc0c1dc3 : WAPT/certificate.crt
fd37593ec1f147267de53c7760f6c2e0221dc7352eeee2adb340f3db2c4086de : WAPT/control
9420721210f5d9c50c9e35c9fdbf0a088b30e165df8311c5f2176ce60e122475 : WAPT/icon.png
eecb2d09ad79128edc1d1a4ec4789e75e0be78fd20d9c16dd828cdf76d92428d : luti.json
070954ecdfe2ddcbf17df698c5930892d46e2d47f7d803f752b8e361b6298e82 : setup.py
7fe3baaa8a1345e334d92fb12f246b837c6e68b2a4b62c72a568e0d3ec8be28f : update_package.py