Détails du package smp-laps-made-in-wapt_14_all_REMOVE-ME-TO-USE-PACKAGE.wapt
retour Revenir à la liste des packages

smp-laps-made-in-wapt

ATTENTION CE DÉPÔT n'est plus compatible 1.3 vous devez migrer en 1.5.1.21 !

Fichier control :

package           : smp-laps-made-in-wapt
version           : 14
architecture      : all
section           : base
priority          : optional
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    : 
audit_schedule    : 
signer            : wapt.lesfourmisduweb.org
signer_fingerprint: 8da83ebdac1a25e820b186510d049f47407b11835b0664fdc5bacd3595b1671d
signature         : dxud+9ymGC6R9Mrh0DgmhKXeGIU3Bt/TbmLdqSll1dk2ia3C80n00Lq6kYUxqT2StmEsWMQs5Czhqvkal+dL7R/nkU/+8Z91VZaLAjsVqJyjVqf6JCJ6NI22CCwcqQognO0RDTyztM/VfORo2hLMv7wxFHBmsYtzjXPb684MXpxVi1KZGVnbcXPntR0lkTKhWKT4d9qswPE04jRTIiQ/D1bc1fULra5s/GllgUTGBD+1VKBgkl4j3+oDkj1o9Gz7benblO977RsCDa6Qzp2X4dEsDxmFzaIrzLfgYuZ8UFFcKvDn/OTX39tGdZ96ZlTzc282B3pqpj6RH58jCDft9A==
signature_date    : 20180605-204510
signed_attributes : package,version,architecture,section,priority,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,audit_schedule,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(ur'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(ur'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()