You are not logged in.

Announcement

 Téléchargez la dernière version stable de GLPI      -     Et vous, que pouvez vous faire pour le projet GLPI ? :  Contribuer
 Download last stable version of GLPI                      -     What can you do for GLPI ? :  Contribute

#1 2009-11-18 16:48:07

stefmcp
Member
Registered: 2009-07-22
Posts: 98

Historisation decryptage password Plugin Compte

Bonjour,

J'ai mis en place l'historisation des decryptages de password sur le plugin compte pour l'utilisation en interne de ce plugin.
Je vous transmet le code si qqs a besoin de cette fonctionnalité ou pour integration dans la prochaine release du plugin.

A chaque decryptage reussi un enregistrement contenant le libelle du mot de passe, le nom du user, et la date et heure est ajouté dans l'historisation. Cette Mise a jour s'effectue de facon transparente et les records d'historisation n'apparaissent dans l'historique que lors du rechargement de la page.

Creer un fichier hisoCompte.js dans le repertoire <ajax>

// ----------------------------------------------------------------------
// Original Author of file: Garret Stephane
// Purpose of file:
// ----------------------------------------------------------------------


var xmlHttp

function callAjax(idcrypt,nameP) {
    if (id.length==0) {
      document.getElementByName("mdp2").innerHTML=""
      return
  }
    xmlHttp=GetXmlHttpObject()
    if (xmlHttp==null) {
      alert ("Browser does not support HTTP Request")
      return
  }
    var url="/glpi/plugins/compte/inc/plugin_compte.histo.php"
    url=url+"?idcrypt="+idcrypt+"&nameP="+nameP
    xmlHttp.onreadystatechange=stateChanged
    xmlHttp.open("POST",url,true)
    xmlHttp.send(null)
}


function stateChanged(){
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    {
        document.getElementByName("mdp2").innerHTML=xmlHttp.responseText
    }
}

function GetXmlHttpObject() {
    var xmlHttp=null;
    try {
        // Firefox, Opera 8.0+, Safari
        xmlHttp=new XMLHttpRequest();
    }
    catch (e) {
        // Internet Explorer
            try {
              xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
          }
            catch (e) {
              xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
          }
    }
    return xmlHttp;
}

Creer un fichier plugin_compte.histo.php dans le repertoire <inc>

<?php
/*
   ----------------------------------------------------------------------
   GLPI - Gestionnaire Libre de Parc Informatique
   Copyright (C) 2003-2008 by the INDEPNET Development Team.

   http://indepnet.net/   http://glpi-project.org/
   ----------------------------------------------------------------------

   LICENSE

   This file is part of GLPI.

   GLPI is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   GLPI is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with GLPI; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   ------------------------------------------------------------------------
*/

// ----------------------------------------------------------------------
// Original Author of file: Garret Stephane
// Purpose of file:
// ----------------------------------------------------------------------

if(!defined('GLPI_ROOT')){
    define('GLPI_ROOT', '../../..');
    include (GLPI_ROOT . "/inc/includes.php");
}

    global $DB,$CFG_GLPI, $LANG;
   
    if(isset($_GET['idcrypt'])) {
   
    //History log
            $changes[0]='0';
            $changes[1]= $_GET['nameP']; 
            $changes[2]= $LANG['plugin_compte'][36] ;
            historyLog ($_GET['idcrypt'],PLUGIN_COMPTE_TYPE,$changes);
    }
   
?>

Modifier le fichier plugin_compte.compte.class.php
Vers la ligne 329

echo "</td><td>&nbsp;<input type='button' name='decrypte' value='".$LANG['plugin_compte'][20]."' class='submit' onclick='var good_hash=\"$hash\";var hash=SHA256(SHA256(document.getElementById(\"aeskey\").value));
            if(hash != good_hash) {
            alert(\"".$LANG['plugin_compte'][22]."\");
            return false;
            };document.getElementsByName(\"mdp2\").item(0).value=AESDecryptCtr(document.getElementsByName(\"mdp\").item(0).value,SHA256(document.getElementById(\"aeskey\").value), 256);return false;'>";

Par

echo "<script src='/glpi/plugins/compte/ajax/histoCompte.js'></script>";
            echo "</td><td>&nbsp;<input type='button' name='decrypte' value='".$LANG['plugin_compte'][20]."' class='submit' onclick='var good_hash=\"$hash\";var hash=SHA256(SHA256(document.getElementById(\"aeskey\").value));
            if(hash != good_hash) {
            alert(\"".$LANG['plugin_compte'][22]."\");
            return false;
            };document.getElementsByName(\"mdp2\").item(0).value=AESDecryptCtr(document.getElementsByName(\"mdp\").item(0).value,SHA256(document.getElementById(\"aeskey\").value), 256);var ret = callAjax(\"$ID\" , document.getElementsByName(\"name\").item(0).value);return false;'>";

Puis dans le fichier plugin_compte.display.function.php
vers la ligne 309

echo "&nbsp;<input type='button' name='decrypte' value='".$LANG['plugin_compte'][20]."' class='submit' onClick='var good_hash=\"$hash\";var hash=SHA256(SHA256(document.getElementById(\"aeskey\").value));
                    if(hash != good_hash) {
                    alert(\"".$LANG['plugin_compte'][22]."\");
                    return false;
                    };alert(AESDecryptCtr(\"".$data['mdp']."\",SHA256(document.getElementById(\"aeskey\").value), 256));return false;'>";

Par

echo "<script src='/glpi/plugins/compte/ajax/histoCompte.js'></script>";
        echo "&nbsp;<input type='button' name='decrypte' value='".$LANG['plugin_compte'][20]."' class='submit' onClick='var good_hash=\"$hash\";var hash=SHA256(SHA256(document.getElementById(\"aeskey\").value));
                    if(hash != good_hash) {
                    alert(\"".$LANG['plugin_compte'][22]."\");
                    return false;
                    }; var ret =callAjax(".$data["ID"].",\"".$data["name"]."\");alert(AESDecryptCtr(\"".$data['mdp']."\",SHA256(document.getElementById(\"aeskey\").value), 256));return false;'>";

Ajouter dans les fichiers fr_FR, en_GB dans le repertoire <locales>

$LANG['plugin_compte'][36] = "Décrypté";  // pour fr_FR

$LANG['plugin_compte'][36] = "Uncrypted";  // pour en_GB


GLPI 0.7.2.4
CentOs 5

Offline

#2 2009-11-18 17:35:09

tsmr
GLPI-DEV
From: Rennes
Registered: 2005-08-26
Posts: 11,632
Website

Re: Historisation decryptage password Plugin Compte

En voila une contribution bien sympatique big_smile

Ajouté a la prochaine version du plugin.
https://forge.indepnet.net/projects/roadmap/accounts

Merci à toi


Xavier Caillaud
Blog GLPI Infotel

Offline

#3 2009-11-19 17:26:22

tsmr
GLPI-DEV
From: Rennes
Registered: 2005-08-26
Posts: 11,632
Website

Re: Historisation decryptage password Plugin Compte

Par contre sur IE8 ca ne marche pas..comme par hasard big_smile


Xavier Caillaud
Blog GLPI Infotel

Offline

#4 2009-11-19 17:57:45

wawa
GLPI-DEV
From: Montpellier / France
Registered: 2006-07-03
Posts: 6,019
Website

Re: Historisation decryptage password Plugin Compte

tsmr wrote:

Par contre sur IE8 ca ne marche pas..comme par hasard big_smile

t'as qu'à dire qu'il y a pas de support IE8 et zou smile

Offline

#5 2009-11-20 15:41:53

stefmcp
Member
Registered: 2009-07-22
Posts: 98

Re: Historisation decryptage password Plugin Compte

Poutant je l'utilise sur IE8 et Firefox 3.5.5 sans problème


GLPI 0.7.2.4
CentOs 5

Offline

#6 2009-11-20 15:44:15

tsmr
GLPI-DEV
From: Rennes
Registered: 2005-08-26
Posts: 11,632
Website

Re: Historisation decryptage password Plugin Compte

apparemment ca viendrait du charset de php du serveur.


Xavier Caillaud
Blog GLPI Infotel

Offline

#7 2009-11-20 16:15:14

stefmcp
Member
Registered: 2009-07-22
Posts: 98

Re: Historisation decryptage password Plugin Compte

Tu peut essayer ca pour voir si ca modifie le comportement, il semblerai que innerHTML soit different en IE8 et cette fonctionnalité n'est pas utile dans ce cas.
je n'ai plus d'erreur sur la page en IE8

Modifier

var url="/glpi/plugins/compte/inc/plugin_compte.histo.php"
    url=url+"?idcrypt="+idcrypt+"&nameP="+nameP
    xmlHttp.onreadystatechange=stateChanged
    xmlHttp.open("POST",url,true)
    xmlHttp.send(null)
}


function stateChanged(){
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    {
        document.getElementByName("mdp2").innerHTML=xmlHttp.responseText
    }
}

par

var url="/glpi/plugins/compte/inc/plugin_compte.histo.php"
    url=url+"?idcrypt="+idcrypt+"&nameP="+nameP
    // xmlHttp.onreadystatechange=stateChanged
    xmlHttp.open("POST",url,true)
    xmlHttp.send(null)
}


// function stateChanged(){
//    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
//     {
//         document.getElementByName("mdp2").innerHTML=xmlHttp.responseText
//     }
// }


GLPI 0.7.2.4
CentOs 5

Offline

Board footer

Powered by FluxBB