12 # Función ficticia para lanzar chntpw con timeout de 5 s., evitando cuelgues del programa. 16 CHNTPW=$(which drbl-
chntpw)
17 CHNTPW=${CHNTPW:-$(which
chntpw)}
18 timeout --foreground 5s $CHNTPW -e
"$@" 43 # Si se solicita, mostrar ayuda. 44 if [
"$*" ==
"help" ]; then
45 ogHelp "$FUNCNAME" "$FUNCNAME path_mountpoint str_hive str_key" \
46 "$FUNCNAME /mnt/sda1 SOFTWARE '\Microsoft\NewKey'" 49 # Error si no se reciben 3 parámetros. 51 # Camino del fichero de registro. 55 chntpw
"$FILE" << EOT &> /dev/null
86 # Si se solicita, mostrar ayuda. 87 if [
"$*" ==
"help" ]; then
88 ogHelp "$FUNCNAME" "$FUNCNAME path_mountpoint str_hive str_valuename [str_valuetype]" \
89 "$FUNCNAME /mnt/sda1 SOFTWARE '\Microsoft\NewKey\Value1'" \
90 "$FUNCNAME /mnt/sda1 SOFTWARE '\Microsoft\NewKey\Value1' DWORD" 93 # Error si no se reciben 3 o 4 parámetros. 94 [ $# == 3 -o $# == 4 ] ||
ogRaiseError $OG_ERR_FORMAT ||
return $?
95 # Camino del fichero de registro. 105 # Devolver el dato del valor de registro. 139 # Si se solicita, mostrar ayuda. 140 if [
"$*" ==
"help" ]; then
141 ogHelp "$FUNCNAME" "$FUNCNAME path_mountpoint str_hive str_key" \
142 "$FUNCNAME /mnt/sda1 SOFTWARE '\Microsoft\NewKey'" 145 # Error si no se reciben 3 parámetros. 147 # Camino del fichero de registro. 150 # Añadir nueva clave.
151 chntpw
"$FILE" << EOT &> /dev/null
181 # Si se solicita, mostrar ayuda. 182 if [
"$*" ==
"help" ]; then
183 ogHelp "$FUNCNAME" "$FUNCNAME path_mountpoint str_hive str_valuename" \
184 "$FUNCNAME /mnt/sda1 SOFTWARE '\Microsoft\NewKey\Value1'" 187 # Error si no se reciben 3 parámetros. 189 # Camino del fichero de registro. 192 # Devolver el dato del valor de registro.
226 # Si se solicita, mostrar ayuda. 227 if [
"$*" ==
"help" ]; then
228 ogHelp "$FUNCNAME" "$FUNCNAME path_mountpoint [str_hive|str_user]" \
229 "$FUNCNAME /mnt/sda1 SOFTWARE => /mnt/sda1/WINDOWS/System32/config/SOFTWARE" \
230 "$FUNCNAME /mnt/sda1 user1 => /mnt/sda1/Users/user1/NTUSER.DAT" 233 # Error si no se reciben 2 parámetros. 236 # Camino del fichero de registro de usuario o de sistema (de menor a mayor prioridad). 237 FILE=
"$(ogGetPath "/$1/Windows/System32/config/$2
")" 238 [ -z
"$FILE" ] && FILE=
"$(ogGetPath "/$1/Users/$2/NTUSER.DAT
")" 239 [ -z
"$FILE" ] && FILE=
"$(ogGetPath "/$1/winnt/system32/config/$2
")" 240 [ -z
"$FILE" ] && FILE=
"$(ogGetPath "/$1/Documents and Settings/$2/NTUSER.DAT
")" 241 [ -f
"$FILE" ] && echo
"$FILE" ||
ogRaiseError $OG_ERR_NOTFOUND
"$1 $2" ||
return $?
269 # Si se solicita, mostrar ayuda. 270 if [
"$*" ==
"help" ]; then
271 ogHelp "$FUNCNAME" "$FUNCNAME path_mountpoint str_hive str_valuename" \
272 "$FUNCNAME /mnt/sda1 SOFTWARE '\Microsoft\NewKey\Value1' ==> 1" 275 # Error si no se reciben 3 parámetros. 277 # Camino del fichero de registro. 280 # Devolver el dato del valor de registro.
317 # Si se solicita, mostrar ayuda. 318 if [
"$*" ==
"help" ]; then
319 ogHelp "$FUNCNAME" "$FUNCNAME path_mountpoint str_hive str_key" \
320 "$FUNCNAME /mnt/sda1 SOFTWARE '\Microsoft\Windows\CurrentVersion'" 323 # Error si no se reciben 3 parámetros. 326 # Camino del fichero de registro. 329 # Devolver la lista de claves de registro.
330 chntpw
"$FILE" << EOT 2> /dev/null |
awk 'BEGIN {FS="[<>]"} $1~/^ $/ {print $2}' 358 # Si se solicita, mostrar ayuda. 359 if [
"$*" ==
"help" ]; then
360 ogHelp "$FUNCNAME" "$FUNCNAME path_mountpoint str_hive str_key" \
361 "$FUNCNAME /mnt/sda1 SOFTWARE '\Microsoft\Windows\CurrentVersion'" 364 # Error si no se reciben 3 parámetros. 366 # Camino del fichero de registro. 369 # Devolver la lista de claves de registro.
370 chntpw
"$FILE" << EOT 2> /dev/null |
awk 'BEGIN {FS="[<>]"} $1~/REG_/ {print $2}' 400 local FILE i n tmpfile
402 # Si se solicita, mostrar ayuda. 403 if [
"$*" ==
"help" ]; then
404 ogHelp "$FUNCNAME" "$FUNCNAME path_mountpoint str_hive str_valuename str_data" \
405 "$FUNCNAME /mnt/sda1 SOFTWARE '\Key\SubKey\StringValue' \"Abcde Fghij\"" \
406 "$FUNCNAME /mnt/sda1 SOFTWARE '\Key\SubKey\DwordValue' 1" \
407 "$FUNCNAME /mnt/sda1 SOFTWARE '\Key\SubKey\BinaryValue' \"04 08 0C 10\"" 410 # Error si no se reciben 4 parámetros. 412 # Camino del fichero de registro. 415 # Fichero temporal para componer la entrada al comando
"chntpw".
417 trap
"rm -f $tmpfile" 1 2 3 9 15
419 # Comprobar tipo de datos del valor del registro.
424 if [ -n
"$(chntpw "$FILE
" < $tmpfile 2> /dev/null | grep "BINARY.*<${3##*\\}>
")" ]; then
425 # Procesar tipo binario (incluir nº de bytes y líneas de 16 parejas hexadecimales). 426 [[
"$4 " =~ ^([0-9A-F]{2} )*$ ]] ||
ogRaiseError $OG_ERR_FORMAT
"\"$4\"" ||
return $?
433 # Formato de líneas hexadecimales: :OFFSET XX YY ZZ ... (hasta 16 parejas). 434 for (( i=0; i<n; i+=48 ));
do 435 printf
":%05x %s\n" $[i/3]
"${4:$i:48}" >> $tmpfile
437 echo -e
"s\nq\ny" >> $tmpfile
439 # Cambiar el dato del valor de registro para cadenas y bytes. 451 chntpw "$FILE" < $tmpfile &> /dev/null
function ogGetHivePath()
Función básica que devuelve el camino del fichero con una sección del registro. #.
function ogAddRegistryKey()
Añade una nueva clave al registro de Windows. #.
function ogListRegistryValues()
Lista los nombres de valores de una determinada clave del registro de Windows. #. ...
function ogRaiseError()
Devuelve el mensaje y el código de error correspondiente. #.
function ogHelp()
Muestra mensaje de ayuda para una función determinda. #.
function ogDeleteRegistryValue()
Elimina un valor del registro de Windows. #.
function ogListRegistryKeys()
Lista los nombres de subclaves de una determinada clave del registro de Windows. #.
function ogAddRegistryValue()
Añade un nuevo valor al registro de Windows, indicando su tipo de datos. #.
function ogGetRegistryValue()
Devuelve el dato de un valor del registro de Windows. #.
function ogDeleteRegistryKey()
Elimina una clave del registro de Windows con todo su contenido. #.
function ogSetRegistryValue()
Establece el dato asociado a un valor del registro de Windows. #.