3 # ogLoadHiveWindows int_ndisk int_partiton 4 #@brief Localiza los hive del registro de windows (de sistema y usuarios) 5 #@param int_ndisk nº de orden del disco 6 #@param int_partition nº de particion 8 #@exception OG_ERR_FORMAT Formato incorrecto. 9 #@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar. 10 #@version 0.9 - Adaptación a OpenGNSys. 11 #@author Antonio J. Doblas Viso. Universidad de Málaga 20 # Si se solicita, mostrar ayuda. 21 if [
"$*" ==
"help" ]; then
22 ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_partition" \
27 # Error si no se reciben 2 parámetros. 28 [ $# == 2 ] ||
return $(
ogRaiseError $OG_ERR_FORMAT; echo $?)
32 #Comprobaciones redundantes: borrar" 33 #ogDiskToDev $DISK $PART || return $(ogRaiseError $OG_ERR_PARTITION "particion de windows no detectada"; echo $?) 34 #ogGetOsType $DISK $PART | grep "Windows" || return $(ogRaiseError $OG_ERR_NOTOS "no es windows"; echo $?) 35 #VERSION=$(ogGetOsVersion $DISK $PART) 36 #Fin Comprobaciones redundantes: borrar" 39 # primera fase, carga de los hive del sistema 47 return $(
ogRaiseError $OG_ERR_NOTOS
"version windows no detectada"; echo $?)
50 hiveSAM=$(
ogGetPath $DISK $PART /${SYSTEMROOT}/system32/config/SAM)
51 [ -n
"$hiveSAM" ] && export hiveSAM ||
return $(
ogRaiseError $OG_ERR_NOTOS
" hive SAM no detectada"; echo $?)
52 hiveSYSTEM=$(
ogGetPath $DISK $PART /${SYSTEMROOT}/system32/config/system)
53 [ -n
"$hiveSYSTEM" ] && export hiveSYSTEM ||
return $(
ogRaiseError $OG_ERR_NOTOS
"hive SYSTEM no detectada"; echo $?)
54 hiveSOFTWARE=$(
ogGetPath $DISK $PART /${SYSTEMROOT}/system32/config/software)
55 [ -n
"$hiveSOFTWARE" ] && export hiveSOFTWARE ||
return $(
ogRaiseError $OG_ERR_NOTOS
"hive SOFTWARE no detectada"; echo $?)
56 export TEMPhive=/tmp/tmpregistry
58 # segunda fase, carga de los hive de usuarios windows.
61 #TODO WINDOWS XP WINDOWS7
62 BASEHOMEDIR=$(
ogGetPath $DISK $PART /
"Documents and Settings")
63 TMPUSERFILE=
"/tmp/WuserRegAndDAT.tmp" 64 find
"$BASEHOMEDIR/" -type f -name NTUSER.DAT > $TMPUSERFILE
65 LISTUSERS=$(drbl-
chntpw -l $hiveSAM | grep RID |
awk -F
"<" '{print $2}' |
awk -F
">" '{print $1}')
66 #echo
"$BASEHOMEDIR" $LISTUSERS
67 for user in $LISTUSERS
69 # Comprobamos que el usuario registrado tiene .DAT
70 if HOMEDIR=$(cat $TMPUSERFILE | grep -w $user)
72 #echo "$user exportamos los usuarios de windows como variables, y como valor hiveUSERX; donde la X es 3 4 5 6 ... X" 73 export `echo $user=hiveUSER$COUNT`
74 #echo "$user exportamos la variable hiveUSERX con el valor del home de la variable-usuario_windows" 75 ##export `echo hiveUSER$COUNT`="$(echo $HOMEDIR | sed -e 's/ /\\ /'g | sed -e 's/\\/\\\\/g')" 76 export `echo hiveUSER$COUNT`=
"$(echo $HOMEDIR)" 77 #echo " estas variables \$USUARIO -> Identificador del HIVE ; \${!USUARIO} -> path del HIVE " 87 #@brief Actualiza los hive de windows. 91 #@exception OG_ERR_FORMAT Formato incorrecto. 92 #@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar. 93 #@version 0.9 - Adaptación a OpenGNSys. 94 #@author Antonio J. Doblas Viso. Universidad de Málaga 103 #TODO detectar llamada a ogLoadHiveWindows 105 # Si se solicita, mostrar ayuda. 106 if [
"$*" ==
"help" ]; then
107 ogHelp "$FUNCNAME" "$FUNCNAME " \
112 echo drbl-
chntpw -f $TEMPhive $hiveSAM $hiveSYSTEM $hiveSOFTWARE \
"${hiveUSER3}\" \"${hiveUSER4}\" \"${hiveUSER5}\" \"${hiveUSER6}\" \"${hiveUSER7}\" \"${hiveUSER8}\" \"${hiveUSER9}\" > /tmp/run.sh 113 cat /tmp/run.sh; sh /tmp/run.sh; rm -fr $TEMPhive; rm /tmp/run.sh 115 unset hiveSAM hiveSYSTEM hiveSOFTWARE TEMPhive hiveUSER3 hiveUSER4 hiveUSER5 hiveUSER6 hiveUSER7 hiveUSER8 hiveUSER9 122 function ogHiveNTRunMachine () { 123 #echo sintaxis: PathScripts idScripts 124 #echo ejemplo: c:\\\\WINDOSWS\\\\crearusuarios.bat scripts1 125 #echo IMPORTANTE: el path debe llevar dos barras \\, pero como se deben 'escapar' debes poner cuatro \\\\ 126 #echo "identifica 0=$hiveSAM 1=$hiveSystem 2=$hiveSoftware 3=$HiveUser3
" 130 # Si se solicita, mostrar ayuda. 131 if [ "$*
" == "help
" ]; then 132 ogHelp "$FUNCNAME
" "$FUNCNAME PathScripts|command keyName
" \ 133 "$FUNCNAME c:\\\\Windows\\\\crearusuarios.cmd scripts_crearUsuarios
"\ 134 "$FUNCNAME
"cmd /c del c:\ogboot.*" ogcleanboot
"\ 135 "$FUNCNAME Requiere la previa ejecución de ogLoadHive int_disk int_part
"\ 136 "$FUNCNAME Despues requiere el ogUpdateHive
" 141 # Error si no se reciben al menos 1 parámetros. 142 [ $# == 2 ] || return $(ogRaiseError $OG_ERR_FORMAT; echo $?) 145 cat >> $TEMPhive << EOF 147 cd \Microsoft\Windows\CurrentVersion\Run 152 #ogGetRegistryValue /mnt/sda1 software '\Microsoft\Windows\CurrentVersion\Run\og3' 155 function ogNTPolUserOn () { 157 # Si se solicita, mostrar ayuda. 158 if [ "$*
" == "help
" ]; then 159 ogHelp "$FUNCNAME
" "$FUNCNAME id_hive_user
" \ 160 "$FUNCNAME NombreUsuario
"\ 165 # TODO: error si no se ha llamado previamente a ogLoadHiveWindows 166 [ -n $hiveSAM ] || return $(ogRaiseError $OG_ERR_FORMAT "se debe utilizar primero la utilidad
ogLoadHiveWindows"; echo $?) 168 # TODO: error si el usuario no tiene cuenta en windows. 169 drbl-chntpw -l $hiveSAM | grep RID | grep -w $1 || return $(ogRaiseError $OG_ERR_FORMAT "el usuario $1 no tiene cuenta en este windows: Compruebe mayusculas o minusculas
"; echo $?) 171 # TODO: error si no el usario no no tiene HIVE asociado. 172 [ -n "${!1}
" ] || return $(ogRaiseError $OG_ERR_FORMAT "el usuario no tiene hive creado
"; echo $?) 175 HIVEID=$(echo ${!1} | tr -d "hiveUSER
") 178 #echo "IMPORTANTE: la variable HiveUser3=/mnt/windows/Document/\ and/\ Seeting\alumnmos\NTUSER.dat
" 180 #cp /var/EAC/admin/utilswin/Fondo.BMP ${particion}/WINDOWS/ 182 cat >> $TEMPhive << EOF 184 cd \Control Panel\Desktop 186 C:\\WINDOWS\\fondo.bmp 188 cd \Software\Microsoft\Windows\CurrentVersion\Policies 196 nv 4 NoSimpleStartMenu 203 nv 4 NoSMConfigurePrograms 204 ed NoSMConfigurePrograms 207 nv 4 NoChangeStartMenu 219 nv 4 NoRecentDocsHistory 220 ed NoRecentDocsHistory 229 ########################################################## 230 ########################################################## 231 #####librerias de PostConfiguracion v0.1para Advanced Deploy enViorenment########### 232 # Liberado bajo licencia GPL <http://www.gnu.org/licenses/gpl.html>################ 233 ############# 2008 Antonio Jes�s Doblas Viso adv@uma.es ########################## 234 ########### Universidad de Malaga (Spain)############################ 235 ########################################################## 241 function NTChangeName () { 244 echo sintaxis: NTChangeNAME str_$var 245 echo ejemplos: NTCHangeName adi${IPcuatro}-xp 247 cat >> $temporal << EOF 249 ed ControlSet001\Control\ComputerName\ComputerName\ComputerName 251 ed ControlSet001\Services\Tcpip\Parameters\Hostname 253 ed ControlSet001\Services\Tcpip\Parameters\NV Hostname 256 cd \Microsoft\Windows NT\CurrentVersion\Winlogon 264 function NTSetGroupName () { 267 echo sintaxis: NTSetGroupName str_$var 268 echo ejemplos: NTSetGroupName adi 270 cat >> $temporal << EOF 272 ed \Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultDomainName 278 function NTSetOwner (){ 281 echo sintaxis: NtSetOwner str_propietario str_organizacion 282 echo ejemplos: NTSetOwner eu\ politecnica universidad\ de\ malaga 284 cat >> $temporal << EOF 286 ed \Microsoft\Windows NT\CurrentVersion\RegisteredOwner 288 ed \Microsoft\Windows NT\CurrentVersion\RegisteredOrganization 294 function NTAutoLogon (){ 297 echo sintaxis: Int_Activar Int_nves str_usuario str_passwd str_equipo 298 echo ejemplos: 1 2 administrador 3451 $equipo 299 echo IMPORTANTE: cuando AutoLogonCount llegue a 0, activa el AutoAdminLogon a 0. Pero no borra los valores de DefaultPassword 303 export temporal=/tmp/tmpregistry 304 cat >> $temporal << EOF 306 cd \Microsoft\Windows NT\CurrentVersion\Winlogon 316 nv 1 DefaultDomainName 322 echo "debe aparecer done
" $4 323 cat >> $temporal << EOF 329 cat >> $temporal << EOF 337 function NTStatusRatonTeclado (){ 340 echo sintaxis: Int-StatusRaton Int-StatusTeclado 341 echo ejemplos: int=1 activo int=4 desactivado 344 cat >> $temporal << EOF 346 cd \ControlSet001\Services\Mouclass 349 cd \ControlSet001\Services\Kbdclass 355 function NTRunOnceMachine () { 358 echo sintaxis: PathScripts idScripts 359 echo "ejemplo: c:\\\\WINDOSWS\\\\crearusuarios.bat scripts1
" 360 echo "IMPORTANTE: el path debe llevar dos barras \\, pero como se deben
'escapar' debes poner cuatro \\\\
" 363 export temporal=/tmp/tmpregistry 364 cat >> $temporal << EOF 366 cd \Microsoft\Windows\CurrentVersion\RunOnce 373 function NTRunMachine () { 376 echo sintaxis: PathScripts idScripts 377 echo ejemplo: c:\\\\WINDOSWS\\\\crearusuarios.bat scripts1 378 echo IMPORTANTE: el path debe llevar dos barras \\, pero como se deben 'escapar' debes poner cuatro \\\\ 381 export temporal=/tmp/tmpregistry 382 cat >> $temporal << EOF 384 cd \Microsoft\Windows\CurrentVersion\Run 391 function NTRunUser () { 394 echo sintaxis: str_PathWINScripts str_idScripts Int_hive||\$usuario 395 echo ejemplo: c:\\\\WINDOSWS\\\\crearusuarios.bat scripts1 3 396 echo IMPORTANTE: el pathWIN debe llevar dos barras \\, pero como se deben 'escapar' debes poner cuatro \\\\ 397 echo IMPORTANTE: el pathLinux si lleva espacios debe escaparse con una barra \\ 398 echo IMPORTANTE Int_hive: 3 para el primer usuario, 4 para el segundo usuario 399 echo requiere export un HiveUser3=/mnt/windows/Document\ and\ Seeting\alumnmos\NTUSER.dat 402 cat >> $temporal << EOF 404 cd \Software\Microsoft\Windows\CurrentVersion\Run 413 function NTPolUserOn () { 416 Msg "requiere LoadRegistryUser str_user1 str_user2...
" orange 417 echo "sintaxis: Int_hive
" 418 echo "ejemplo: NTPolUserOn 3
" 419 echo "IMPORTANTE: la variable HiveUser3=/mnt/windows/Document/\ and/\ Seeting\alumnmos\NTUSER.dat
" 422 cp /var/EAC/admin/utilswin/Fondo.BMP ${particion}/WINDOWS/ 423 cat >> $temporal << EOF 425 cd \Control Panel\Desktop 427 C:\\WINDOWS\\fondo.bmp 429 cd \Software\Microsoft\Windows\CurrentVersion\Policies 437 nv 4 NoSimpleStartMenu 444 nv 4 NoSMConfigurePrograms 445 ed NoSMConfigurePrograms 448 nv 4 NoChangeStartMenu 460 nv 4 NoRecentDocsHistory 461 ed NoRecentDocsHistory 466 function NTPolUserOFF () { 469 Msg "requiere LoadRegistryUser str_user1 str_user2...
" orange 470 echo "sintaxis: Int_hive
" 471 echo "ejemplo: NTPolUserOFF 3
" 472 echo "IMPORTANTE: la variable HiveUser3=/mnt/windows/Document/\ and/\ Seeting\alumnmos\NTUSER.dat
" 475 cat >> $temporal << EOF 477 cd \Control Panel\Desktop 479 C:\\WINDOWS\\web\\wallpaper\\Felicidad.bmp 481 cd \Software\Microsoft\Windows\CurrentVersion\ 489 function ogSetWindowsChkdisk() { 492 echo sintaxis: true|TRUE|0 false|false|1 493 echo ejemplos: int=0 desactivado int=1 activado 498 valor="autocheck autochk *
";; 505 cat >> $TEMPhive << EOF 507 cd \ControlSet001\Control\Session Manager 516 ### FASE DE PRUEBAS NO FUNCIONA 517 function NTStartRecovery () { 520 echo sintaxis: Int-Status 521 echo ejemplos: int=0 desactivado int=1 activado 525 [ $1 = 0 ] && valor="none
" 526 [ $1 = 1 ] && valor="00000000
" 529 cat >> $TEMPhive << EOF 531 #cd \Policies\Microsoft\Windows\WinRE 533 cd \Policies\Microsoft\Windows 543 #[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WinRE] 547 #[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WinRE] 548 #"DisableSetup
"=dword:00000000 554 function ogSchrootLinux () { 557 local PART DISK DIRCONF SCHROOTDEVICE 559 # Si se solicita, mostrar ayuda. 560 if [ "$*
" == "help
" ]; then 561 ogHelp "$FUNCNAME
" "$FUNCNAME int_ndisk int_partition
" \ 566 # Error si no se reciben 2 parámetros. 567 [ $# == 2 ] || return $(ogRaiseError $OG_ERR_FORMAT; echo $?) 569 DISK=$1; PART=$2; DIRCONF="/etc/schroot
" 572 VERSION=$(ogGetOsVersion $DISK $PART) 573 echo $VERSION | grep "Linux
" || return $(ogRaiseError $OG_ERR_NOTOS "no es linux
"; echo $?) 575 ogUnmount $DISK $PART || return $(ogRaiseError $OG_ERR_NOTOS "no es linux
"; echo $?) 577 SCHROOTDEVICE=$(ogDiskToDev $DISK $PART) 580 rm ${DIRCONF}/mount-defaults 581 rm ${DIRCONF}/schroot.conf 583 cat >> ${DIRCONF}/mount-defaults << EOF 584 # <file system> <mount point> <type> <options> <dump> <pass> 585 proc /proc proc defaults 0 0 586 /dev /dev none rw,bind 0 0 587 /dev/pts /dev/pts none rw,bind 0 0 588 /dev/shm /dev/shm none rw,bind 0 0 592 cat >> ${DIRCONF}/schroot.conf << EOF 596 device=$SCHROOTDEVICE 604 schroot -end-sessiona --all-sessions 608 #/** @function ogDiskToRelativeDev: @brief Traduce los ID de discos o particiones EAC a ID Linux relativos, es decir 1 1 => sda1 609 #@param Admite 1 parametro: $1 int_numdisk 610 #@param Admite 2 parametro: $1 int_numdisk $2 int_partition 611 #@return Para 1 parametros traduce Discos Duros: Devuelve la ruta relativa linux del disco duro indicado con nomenclatura EAC.........ejemplo: IdPartition 1 => sda 612 #@return Para 2 parametros traduce Particiones: Devuelve la ruta relativa linux de la particion indicado con nomenclatura EAC........... ejemplo: IdPartition 2 1 => sdb1 613 #@warning No definidas 615 #@note Notas sin especificar 616 #@version 0.1 - Integracion para Opengnsys - EAC: IdPartition en ATA.lib 617 #@author Antonio J. Doblas Viso. Universidad de Malaga 620 function ogDiskToRelativeDev () { 623 Msg "Info: Traduce el identificador del dispositivo EAC a dispositivo linux \n
" info 624 Msg "Sintaxis1: IdPartition int_disk -----------------Ejemplo1: IdPartition 1 -> sda
" example 625 Msg "Sintaxis2: IdPartition int_disk int_partition --Ejemplo2: IdPartition 1 2 -> sda2
" example 629 #PART="$(
Disk|cut -f$1 -d
' ')$2
" # se comenta esta linea porque doxygen no reconoce la funcion disk y no crea los enlaces y referencias correctas. 630 PART=$(ogDiskToDev|cut -f$1 -d' ')$2 631 echo $PART | cut -f3 -d \/ 635 #/** @function ogDeletePartitionsLabels: @brief Elimina la informacion que tiene el kernel del cliente og sobre los labels de los sistemas de archivos 639 #@attention Requisitos: comando interno linux rm 641 #@version 0.1 - Integracion para Opengnsys - EAC: DeletePartitionTable() en ATA.lib 642 #@author Antonio J. Doblas Viso. Universidad de Malaga 645 function ogDeletePartitionsLabels () { 646 # Si se solicita, mostrar ayuda. 647 if [ "$*
" == "help
" ]; then 648 ogHelp "$FUNCNAME
" "$FUNCNAME
" \ 653 rm /dev/disk/by-label/* # */ COMENTARIO OBLIGATORIO PARA DOXYGEN 657 #/** @function ogInfoCache: @brief muestra la informacion de la CACHE. 658 #@param sin parametros 659 #@return texto que se almacena en $IP.-InfoCache. punto_montaje, tama?oTotal, TamanioOcupado, TaminioLibre, imagenes dentro de la cahce 660 #@warning Salidas de errores no determinada 661 #@warning printf no soportado por busybox 663 #@version 0.1 Date: 27/10/2008 Author Antonio J. Doblas Viso. Universidad de Malaga 665 function ogInfoCache () 667 local info infoFilesystem infoSize infoUsed infoUsedPorcet infoMountedOn content 670 info=`df -h | grep $OGCAC` 671 infoFilesystem=`echo $info | cut -f1 -d" "` 672 infoSize=`echo $info | cut -f2 -d" "` 673 infoUsed=`echo $info | cut -f3 -d" "` 674 infoAvail=`echo $info | cut -f4 -d" "` 675 infoUsedPorcet=`echo $info | cut -f5 -d" "` 676 infoMountedOn=`echo $info | cut -f2 -d" "` 677 if `ls ${OGCAC}$OGIMG > /dev/null 2>&1` 679 cd ${OGCAC}${OPENGNSYS} 680 #content=`find images/ -type f -printf "%h/ %f %s \n
"` busybox no soporta printf 681 content=`find images/ -type f` 686 #echo "$info
" > ${OGLOG}/${IP}-InfoCache 687 #echo "$content
" >> {$OGLOG}/${IP}-InfoCache 690 #echo "$info
" > {$OGLOG}/${IP}-InfoCache 695 #echo " " > {$OGLOG}/${IP}-InfoCache function ogUpdateHiveWindows()
function ogLoadHiveWindows()
function ogRaiseError()
Devuelve el mensaje y el código de error correspondiente. #.
function ogHelp()
Muestra mensaje de ayuda para una función determinda. #.
Funciones para gestión de discos y particiones. #.
function ogGetPath()
Inicia el proceso de arranque de un sistema de archivos. #.