Détails du package

smp-laps-made-in-wapt

retour Revenir à la liste des packages

smp-laps-made-in-wapt

Fichier control :

package           : smp-laps-made-in-wapt
version           : 15
architecture      : all
section           : base
priority          : optional
name              : 
categories        : 
maintainer        : Simon Fonteneau
description       : Passe un mot de passe aléatoire au compte administrateur local de la machine. Chiffre celui-ci avec le certificat du paquet et l'affiche dans le résultat de l'installation. Le mot de passe des machines peut etre récupéré avec l'update_package du paquet.
depends           : 
conflicts         : 
maturity          : REMOVE-ME-TO-USE-PACKAGE
locale            : 
target_os         : 
min_os_version    : 
max_os_version    : 
min_wapt_version  : 1.5
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      : 6ec7959d-08d3-43d5-ade4-663ed63c9e73
valid_from        : 
valid_until       : 
forced_install_on : 
changelog         : 
signer            : wapt.lesfourmisduweb.org
signer_fingerprint: 1e54425be03a2a3ea1a264b40d984c31f17a6a489a3b722acb993cbf6561e903
signature         : lHeNtCxePhlPwgreZTWutwLkMVMfW0IqHkfK0l4CMIlc7A7Yj6zGn/6GqhED2BicBhS6R/ymu6zDeDOhBL++eZ5jq1zfKMhHM5t9Dzc707yMd4wkoQRuILA5q0Cjlb6WRt5CfYHmOGIg8AZJcvatFoobUksifFqalmi3PaHR/shemlxqOsHoj1hS32YhLSx2HdOKDM6iAbdkPZce0tewBJbomgNCh59AHBXPyWTCuQuzBFyGR0uCyOMcIlrKb7vzP0O1v8X435y+J96ur4+NrWTxWRY04lbnLBU0LxIoUM2XcNYHeETwUrnwLRIAJbFcl51Nuluqhzk04jmozXbv9Q==
signature_date    : 2020-07-04T11:02:15.195000
signed_attributes : package,version,architecture,section,priority,name,categories,maintainer,description,depends,conflicts,maturity,locale,target_os,min_os_version,max_os_version,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,signer,signer_fingerprint,signature_date,signed_attributes



Fichier setup.py :

# -*- coding: utf-8 -*-
from setuphelpers import *
import json
from waptcrypto import *
import waptguihelper

import string
import random

uninstallkey = []


def install():
    randompassword = password_generator(size=random.randint(10,16), chars=string.ascii_letters + string.digits)
    list_encrypt = []
    allcrt = glob.glob(r'public-crt\*.crt')
    if not allcrt :
        allcrt = glob.glob(r'WAPT\certificate.crt')
    for crt in allcrt:
        list_encrypt.append(SSLCertificate(crt_filename=crt).encrypt(randompassword).encode('base64'))
    print(json.dumps(list_encrypt))
    run(r'net user administrateur /active:yes')
    run(r'net user administrateur %s' % randompassword)





def print_all_password():

    from waptpackage import PackageEntry
    pe = PackageEntry()
    pe.load_control_from_wapt(os.getcwd())

    import waptcrypto

    urlserver = inifile_readstring(makepath(install_location('WAPT_is1'),'wapt-get.ini'),'global','wapt_server')
    mycrt = inifile_readstring(makepath(user_local_appdata(),'waptconsole','waptconsole.ini'),'global','personal_certificate_path')

    passwordkey = waptguihelper.key_password_dialog('Password for private key',mycrt, '')

    public_cert=SSLCertificate(crt_filename=mycrt)
    fileprivatekey = public_cert.matching_key_in_dirs(private_key_password=passwordkey['keypassword'])
    privatekey = SSLPrivateKey(pem_data=fileprivatekey.as_pem())

    credentials_url = waptguihelper.login_password_dialog('Credentials for wapt server',urlserver,'admin','')
    data = json.loads(wgets(r'https://%s:%s@%s/api/v1/hosts?columns=uuid&limit=10000' % (credentials_url['user'],credentials_url['password'],urlserver.replace('https://',''))))
    for host in data['result']:
        uuid = host['uuid']
        for package in json.loads(wgets(r'https://%s:%s@%s/api/v1/host_data?field=installed_packages&uuid=%s' % (credentials_url['user'],credentials_url['password'],urlserver.replace('https://',''),uuid)))['result']:
            if package['package'] == pe.package :
                for password in json.loads(package['install_output']) :
                    try:
                        password_decode = privatekey.decrypt(password.decode('base64'))
                        print(host['computer_name'] + ';' + password_decode)
                        break
                    except:
                        pass




def password_generator(size=16, chars=string.ascii_letters + string.digits):
    """
    Returns a string of random characters, useful in generating temporary
    passwords for automated password resets.

    size: default=8; override to provide smaller/larger passwords
    chars: default=A-Za-z0-9; override to provide more/less diversity

    Credit: Ignacio Vasquez-Abrams
    Source: http://stackoverflow.com/a/2257449
    """
    return ''.join(random.choice(chars) for i in range(size))


if __name__ == '__main__':
    print_all_password()