1 | #!/bin/bash |
---|
2 | #/** |
---|
3 | #@file Registry.lib |
---|
4 | #@brief Librería o clase Registry |
---|
5 | #@class Boot |
---|
6 | #@brief Funciones para gestión del registro de Windows. |
---|
7 | #@version 1.0.1 |
---|
8 | #@warning License: GNU GPLv3+ |
---|
9 | #*/ |
---|
10 | |
---|
11 | |
---|
12 | #/** |
---|
13 | # ogAddRegistryKey path_mountpoint str_hive str_keyname |
---|
14 | #@brief Añade una nueva clave al registro de Windows. |
---|
15 | #@version 1.0.1 - Nueva función |
---|
16 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
17 | #@date 2011-05-18 |
---|
18 | #*/ ## |
---|
19 | function ogAddRegistryKey () |
---|
20 | { |
---|
21 | } |
---|
22 | |
---|
23 | #/** |
---|
24 | # ogAddRegistryValue path_mountpoint str_hive str_valuename str_valuedata |
---|
25 | #@brief Añade un nuevo valor (dupla nombre/valor) al registro de Windows. |
---|
26 | #@version 1.0.1 - Nueva función |
---|
27 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
28 | #@date 2011-05-18 |
---|
29 | #*/ ## |
---|
30 | function ogAddRegistryValue () |
---|
31 | { |
---|
32 | } |
---|
33 | |
---|
34 | |
---|
35 | #/** |
---|
36 | # ogChangeRegistryKey path_mountpoint str_hive str_keyname |
---|
37 | #@brief Modifica el nombre de una clave al registro de Windows. |
---|
38 | #@version 1.0.1 - Nueva función |
---|
39 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
40 | #@date 2011-05-18 |
---|
41 | #*/ ## |
---|
42 | function ogChangeRegistryKey () |
---|
43 | { |
---|
44 | } |
---|
45 | |
---|
46 | #/** |
---|
47 | # ogChangeRegistryValue path_mountpoint str_hive str_valuename str_valuedata |
---|
48 | #@brief Modifica el nombre de un valor (dupla nombre/valor) al registro de Windows. |
---|
49 | #@version 1.0.1 - Nueva función |
---|
50 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
51 | #@date 2011-05-18 |
---|
52 | #*/ ## |
---|
53 | function ogChangeRegistryValue () |
---|
54 | { |
---|
55 | } |
---|
56 | |
---|
57 | |
---|
58 | #/** |
---|
59 | # ogDeleteRegistryKey path_mountpoint str_hive str_keyname |
---|
60 | #@brief Elimina una clave del registro de Windows con todo su contenido. |
---|
61 | #@version 1.0.1 - Nueva función |
---|
62 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
63 | #@date 2011-05-20 |
---|
64 | #*/ ## |
---|
65 | function ogDeleteRegistryKey () |
---|
66 | { |
---|
67 | } |
---|
68 | |
---|
69 | #/** |
---|
70 | # ogDeleteRegistryValue path_mountpoint str_hive str_valuename str_valuedata |
---|
71 | #@brief Elimina un valor del registro de Windows. |
---|
72 | #@version 1.0.1 - Nueva función |
---|
73 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
74 | #@date 2011-05-20 |
---|
75 | #*/ ## |
---|
76 | function ogDeleteRegistryValue () |
---|
77 | { |
---|
78 | } |
---|
79 | |
---|
80 | |
---|
81 | #/** |
---|
82 | # ogGetHivePath path_mountpoint str_hive |
---|
83 | #@brief Función básica que devuelve el camino del fichero con una sección del registro. |
---|
84 | #@param path_mountpoint directorio donde está montado el sistema Windows |
---|
85 | #@param str_hive sección del registro |
---|
86 | #@return str_path - camino del fichero de registro |
---|
87 | #@exception OG_ERR_FORMAT Formato incorrecto. |
---|
88 | #@exception OG_ERR_NOTFOUND Disco o partición no corresponden con un dispositivo. |
---|
89 | #@note hive = { default, sam, security, software, system, components } |
---|
90 | #@warning El sistema de archivos de Windows debe estar montada previamente. |
---|
91 | #@version 1.0.1 - Nueva función |
---|
92 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
93 | #@date 2011-05-18 |
---|
94 | #*/ ## |
---|
95 | function ogGetHivePath () |
---|
96 | { |
---|
97 | # Variables locales. |
---|
98 | local FILE FILENT FILEXP |
---|
99 | |
---|
100 | # Si se solicita, mostrar ayuda. |
---|
101 | if [ "$*" == "help" ]; then |
---|
102 | ogHelp "$FUNCNAME" "$FUNCNAME path_mountpoint str_hive" |
---|
103 | return |
---|
104 | fi |
---|
105 | # Error si no se reciben 2 parámetros. |
---|
106 | [ $# == 2 ] || ogRaiseError $OG_ERR_FORMAT || return $? |
---|
107 | |
---|
108 | # Camino del fichero de registro en NT/2000 o XP/Vista/7. |
---|
109 | FILENT=$(ogGetPath "/$1/winnt/system32/config/$2") |
---|
110 | [ -f $FILENT ] && FILE="$FILENT" |
---|
111 | FILEXP=$(ogGetPath "/$1/windows/system32/config/$2") |
---|
112 | [ -f $FLEHXP ] && FILE="$FILEXP" |
---|
113 | [ ! -f $FILE ] && ogRaiseError OG_ERR_NOTFOUND "$1,$2" && return $? |
---|
114 | |
---|
115 | echo "$FILE" |
---|
116 | } |
---|
117 | |
---|
118 | |
---|
119 | #/** |
---|
120 | # ogGetRegistryValue path_mountpoint str_hive str_valuename |
---|
121 | #@brief Devuelve el dato de un valor del registro de Windows. |
---|
122 | #@param path_mountpoint directorio donde está montado el sistema Windows |
---|
123 | #@param str_hive sección del registro |
---|
124 | #@param str_valuename nombre del valor |
---|
125 | #@return str_valuedata - datos del valor. |
---|
126 | #@exception OG_ERR_FORMAT Formato incorrecto. |
---|
127 | #@exception OG_ERR_NOTFOUND Disco o partición no corresponden con un dispositivo. |
---|
128 | #@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar. |
---|
129 | #@note hive = { default, sam, security, software, system, components } |
---|
130 | #@warning Requisitos: chntpw, awk |
---|
131 | #@warning La partición de Windows debe estar montada previamente. |
---|
132 | #@version 0.9 - Adaptación para OpenGNSys. |
---|
133 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
134 | #@date 2009-09-11 |
---|
135 | #*/ ## |
---|
136 | function ogGetRegistryValue () |
---|
137 | { |
---|
138 | # Variables locales. |
---|
139 | local FILE |
---|
140 | |
---|
141 | # Si se solicita, mostrar ayuda. |
---|
142 | if [ "$*" == "help" ]; then |
---|
143 | ogHelp "$FUNCNAME" "$FUNCNAME path_mountpoint str_hive str_valuename" |
---|
144 | return |
---|
145 | fi |
---|
146 | # Error si no se reciben 3 parámetros. |
---|
147 | [ $# == 3 ] || ogRaiseError $OG_ERR_FORMAT || return $? |
---|
148 | |
---|
149 | # Camino del fichero de registro. |
---|
150 | FILE=$(ogGetHivePath "$1" "$2") || return $? |
---|
151 | |
---|
152 | # Devolver el dato del valor de registro. |
---|
153 | # /* (comentario Doxygen) |
---|
154 | chntpw $FILE << FIN 2>/dev/null | awk '/> Value/ {getline;print $0;}' |
---|
155 | cd ${3%\\*} |
---|
156 | cat ${3##*\\} |
---|
157 | q |
---|
158 | FIN |
---|
159 | # (comentario Doxygen) */ |
---|
160 | } |
---|
161 | |
---|
162 | |
---|
163 | #/** |
---|
164 | # ogListRegistryKey path_mountpoint str_hive str_key |
---|
165 | #@brief Lista los nombres de claves de una determinada clave del registro de Windows. |
---|
166 | #@param path_mountpoint directorio donde está montado el sistema Windows |
---|
167 | #@param str_hive sección del registro |
---|
168 | #@param str_key clave de registro |
---|
169 | #@return str_subkey ... - lista de subclaves |
---|
170 | #@exception OG_ERR_FORMAT Formato incorrecto. |
---|
171 | #@exception OG_ERR_NOTFOUND Disco o particion no corresponden con un dispositivo. |
---|
172 | #@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar. |
---|
173 | #@note hive = { default, sam, security, software, system, components } |
---|
174 | #@warning Requisitos: chntpw, awk |
---|
175 | #@warning La partición de Windows debe estar montada previamente. |
---|
176 | #@version 0.9 - Adaptación para OpenGNSys. |
---|
177 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
178 | #@date 2009-09-23 |
---|
179 | #@version 1.0.1 - Renombrada de ogListRegistryKeys |
---|
180 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
181 | #@date 2011-05-18 |
---|
182 | #*/ ## |
---|
183 | function ogListRegistryKey () |
---|
184 | { |
---|
185 | # Variables locales. |
---|
186 | local FILE |
---|
187 | |
---|
188 | # Si se solicita, mostrar ayuda. |
---|
189 | if [ "$*" == "help" ]; then |
---|
190 | ogHelp "$FUNCNAME" "$FUNCNAME path_mountpoint str_hive str_key" |
---|
191 | return |
---|
192 | fi |
---|
193 | # Error si no se reciben 3 parámetros. |
---|
194 | [ $# == 3 ] || ogRaiseError $OG_ERR_FORMAT || return $? |
---|
195 | |
---|
196 | # Camino del fichero de registro. |
---|
197 | FILE=$(ogGetHivePath "$1" "$2") || return $? |
---|
198 | |
---|
199 | # Devolver la lista de claves de registro. |
---|
200 | chntpw $FILE << FIN 2>/dev/null | awk 'BEGIN {FS="[<>]"} $1~/^ $/ {print $2}' |
---|
201 | ls $3 |
---|
202 | q |
---|
203 | FIN |
---|
204 | } |
---|
205 | |
---|
206 | |
---|
207 | #/** |
---|
208 | # ogSetRegistryValue path_mountpoint str_hive str_valuename str_valuedata |
---|
209 | #@brief Establece el dato asociado a un valor del registro de Windows. |
---|
210 | #@param path_mountpoint directorio donde está montado el sistema Windows |
---|
211 | #@param str_hive tipo de registro |
---|
212 | #@param str_valuename nombre del valor de registro |
---|
213 | #@param str_valuedata dato del valor de registro |
---|
214 | #@return (nada) |
---|
215 | #@exception OG_ERR_FORMAT Formato incorrecto. |
---|
216 | #@exception OG_ERR_NOTFOUND Disco o partición no corresponden con un dispositivo. |
---|
217 | #@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar. |
---|
218 | #@note hive = { default, sam, security, software, system, components } |
---|
219 | #@warning Requisitos: chntpw, awk |
---|
220 | #@warning La partición de Windows debe estar montada previamente. |
---|
221 | #@version 0.9 - Adaptación para OpenGNSys. |
---|
222 | #@author Ramon Gomez, ETSII Universidad de Sevilla |
---|
223 | #@date 2009-09-24 |
---|
224 | #*/ ## |
---|
225 | function ogSetRegistryValue () |
---|
226 | { |
---|
227 | # Variables locales. |
---|
228 | local FILE |
---|
229 | |
---|
230 | # Si se solicita, mostrar ayuda. |
---|
231 | if [ "$*" == "help" ]; then |
---|
232 | ogHelp "$FUNCNAME" "$FUNCNAME path_mountpoint str_hive str_valuename str_data" |
---|
233 | return |
---|
234 | fi |
---|
235 | # Error si no se reciben 4 parámetros. |
---|
236 | [ $# == 4 ] || ogRaiseError $OG_ERR_FORMAT || return $? |
---|
237 | |
---|
238 | # Camino del fichero de registro. |
---|
239 | FILE=$(ogGetHivePath "$1" "$2") || return $? |
---|
240 | |
---|
241 | # Cambiar el dato del valor de registro. |
---|
242 | chntpw $FILE << FIN &>/dev/null |
---|
243 | ed $3 |
---|
244 | $4 |
---|
245 | q |
---|
246 | y |
---|
247 | FIN |
---|
248 | } |
---|
249 | |
---|