WebDAV
(Web-based Distributed Authoring and Versioning) is a web-base that allows users to edit files or manage their own files to the computer with Remote WebDAV.
Why WebDAV Web Folders?
- Access files anywhere. And easy access permissions.
- Web access to files, web browser now.
- Users can not edit files within the same time.
- Security configuration because it can use SSL Encryption to work through.
- Support access to files from Windows, Linux, Mac OS X, bla bla bla y + bla
Eso me pregunto yo, por qué WebDav folders!!!
Cuando eres un consultor te toca meterte en pozos de otros «sapos».
Esta vez me tocó descifrar un elaborado sistema montado en un Centos con un apache 1 (hace tiempo que no veía uno, el último en un pentesting 😛 hace unos meses)
Pues me encontré unos usuarios Windows, autenticándose contra un LDAP, cosa que me gustó gratamente, ya que siempre lo vi en laboratorio y nunca en un entorno real de producción. La verdad que como todo servidor Linux, es muy robusto. Y puede desaparecer la humanidad que ese servidor seguirá funcionando mientras tenga corriente eléctrica.
El tema fue encontrarme con menos de 10 carpetas como unidad de red al que se conectan los usuarios al logearse una vez en el Windows 7.
La verdad que el vbscript está currado, y es digno de ser puesto en este blog
Hay una serie de unos 20 scripts que se encargan de sincronizar automáticamente los usuarios creados con Ldap al Alfresco. En una integración total en conjunto a un Drupal. Quien lo hizo, la verdad que ha dedicado mucho tiempo y esfuerzo hacerlo. Y funciona bastante bien.
El tema es que cuando eres sapo de otro pozo y no tienes ni idea de lo que hay detrás montado, aún teniendo los password de Alfresco, el servidor, la intranet, el drupal, la base de datos, y todo lo demás, cuesta un poco entender la lógico, fin y conocimientos de quién ha montado este endiablado sistema. Se que para muchos frikis de Linux, es una forma de asegurarse que ningún usuario común de Windows con conocimiento básicos de Linux se meta en su pozo.
Así que me tocó a mi meterme en este pozo y entender cómo está montado un sistema con Vpn, cifrados raros, gestión deocumental con alfresco que publica y comparte sus directorios con Webdav y la participación de PGINA y otras herramientas muy guapas como herramientas que mapean webdav y las ponen automáticamente en equipo.
Lo primero que aparece al logearse tras el LDAP es lo siguiente.
Una ventana del IExplorer para poder acceder a la red.
Automáticamente rellene el usuario con el nombre de usuario, y la verdad que no entiendo porque no se ingenió para que pusiera automáticamente la contraseña. El caso es que hay que ponerla.
He visto soluciones más simples para mapear unidades de WebDav en Windows, sin necesidad de dar tantas vueltas. Y que el usuario no tenga que escribir su contraseña. Claro que desde el punto de vista de «Seguridad» así es mucho más seguro.
Bien vamos a ir al script que es lo que interesa.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
' Script inicio Intranet ' v0.1: llamada a webdrive para conectar con servidor de ficheros (escrito como fichero batch). ' v1.0: ' - migracion a vbscript ' - configuración fondo escritorio ' - configuración bloqueo en inactividad ' - W7: anclaje de firefox en barra de tareas, desanclaje de IE ' v1.1, 2012/12/06: ' - forzar que IE no compruebee si es navegador por defecto ' - W7: forzar Firefox como navegador por defecto (para WXP, usar script ff_default_browser.bat) ' - eliminar perfil de Firefox para forzar su reconstrucción (tras despliegue de FF 17.0.1 ESR) ' -> eliminar cuando se hayan actualizado los perfiles ' - usa NirCmd para capturar la pantalla (verificar configuración fondo escritorio y FF/IE en barra tareas) ' v1.2, 2012/12/16: ' - envío de captura de pantalla por correo electrónico ' - cambio de URL de conexión a servidor (sustitución intranet por alfresco.care) ' v1.2.1, 2012/12/17: ' - se elimina opción de delivery report en envío de email ' v1.2.2, 2012/12/18: ' - wallpaper en bmp para que WXP lo muestre correctamente ' v1.2.3, 2012/12/27: ' - se desactiva la captura de pantalla y envío de correo ' - se desactiva la eliminación del perfil de Firefox, al haberse ejecutado ya en todos los perfiles ' v1.2.4, 2013/06/30: ' - conexión a servidor CARE por webdav usando NetDrive (ndcmd) ' v1.2.5, 2014/12/19: ' - se comenta parte de centrado de dialogo IE por error 800a0046 version = "1.2.5" Set objShell = CreateObject("WScript.Shell") Set objNetwork = CreateObject("WScript.Network") Set objShApp = CreateObject("Shell.Application") userName = objShell.ExpandEnvironmentStrings("%USERNAME%") computerName = objShell.ExpandEnvironmentStrings("%COMPUTERNAME%") userProfile = objShell.ExpandEnvironmentStrings("%USERPROFILE%") systemRoot = objShell.ExpandEnvironmentStrings("%SYSTEMROOT%") programFiles = objShell.ExpandEnvironmentStrings("%ProgramFiles%") appData = objShell.ExpandEnvironmentStrings("%AppData%") ' Deteccion de version del SO strOS = objShell.RegRead("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProductName") isW7 = inStr(strOS, "Windows 7") ' Establecer fondo escritorio Empresa sWallPaper = systemRoot & "\Web\Wallpaper\empresa_wallpaper.bmp" objShell.RegWrite "HKCU\Control Panel\Desktop\Wallpaper", sWallPaper objShell.Regwrite "HKCU\Software\Microsoft\Internet Explorer\Desktop\General\Wallpaper", sWallPaper objShell.Regwrite "HKCU\Software\Microsoft\Internet Explorer\Desktop\General\BackupWallpaper", sWallPaper ' Establecer bloqueo tras 15min inactividad objShell.RegWrite "HKCU\Control Panel\Desktop\ScreenSaveActive", "1" objShell.RegWrite "HKCU\Control Panel\Desktop\ScreenSaveTimeOut", "900" objShell.RegWrite "HKCU\Control Panel\Desktop\ScreenSaverIsSecure", "1" objShell.RegWrite "HKCU\Control Panel\Desktop\SCRNSAVE.EXE", systemRoot & "\system32\scrnsave.scr" ' Configurar IE para que no detecte si es el navegador por defecto objShell.RegWrite "HKCU\Software\Microsoft\Internet Explorer\Main\Check_Associations", "No" ' Especifico para W7 / WXP if (isW7) then ' W7 ' Configurar firefox como navegador por defecto objShell.RegWrite "HKCU\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\ftp\UserChoice\Progid", "FirefoxURL" objShell.RegWrite "HKCU\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice\Progid", "FirefoxURL" objShell.RegWrite "HKCU\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\https\UserChoice\Progid", "FirefoxURL" objShell.RegWrite "HKCU\Software\Clients\StartMenuInternet\", "FIREFOX.EXE" ' Eliminar IE del inicio rapido DesanclarBarraTareas CSIDL_PROGRAMS, "", "Internet Explorer.lnk" ' Agregar FF al inicio rapido AnclarBarraTareas CSIDL_COMMON_PROGRAMS, "", "Mozilla Firefox.lnk" ' Desactivar tab presentacion IE10 objShell.RegWrite "HKCU\Software\Microsoft\Internet Explorer\Main\DisableFirstRunCustomize", 1, "REG_DWORD" objShell.RegWrite "HKCU\Software\Microsoft\Internet Explorer\Main\IE10RunOncePerInstallCompleted", 1, "REG_DWORD" objShell.RegWrite "HKCU\Software\Microsoft\Internet Explorer\Main\IE10TourShown", 1, "REG_DWORD" objShell.RegWrite "HKCU\Software\Microsoft\Internet Explorer\Main\IE10RunOnceCompletionTime", 1, "REG_BINARY" objShell.RegWrite "HKCU\Software\Microsoft\Internet Explorer\Main\IE10TourShownTime", 1, "REG_BINARY" else ' WXP ' Configurar firefox como navegador por defecto: en script regedit independiente end if ' Conectar a servidor de ficheros mDrive = "S" mURL = "http://alfresco.server/alfresco/webdav/empresa" ' Desconectar primero set objFolder = objShApp.NameSpace(mDrive & ":\") if (not objFolder is nothing) then objShell.Run Enquote("%PROGRAMFILES%\NetDrive\ndcmd.exe") & " -d -l " & mDrive, 0, true end if ' Conectar a webdav, con login Do login = GetLogin( "Conectar con el Servidor Empresa" & String( 3, "." ), userName ) if (not IsEmpty(login)) then objShell.Run Enquote("%PROGRAMFILES%\NetDrive\ndcmd.exe") & " -m -l " & mDrive & " -c utf8 -u " & login(0) & " -p " & login(1) & " -U " & mURL, 0, true set objFolder = objShApp.NameSpace(mDrive & ":\") if (not objFolder is nothing) then objFolder.Self.Name = "Servidor CARE" objShApp.Open(mDrive & ":\") result = vbOK else result = MsgBox("Error al conectar con el servidor ", vbExclamation+vbRetryCancel, "Conectando al servidor ...") end if else result = vbCancel end if Loop While result = vbRetry ' ' Libreria ' ' Utilidades function Enquote(sSource) Enquote = chr(34) & sSource & chr(34) end function ' Gestión de la barra de tareas Const CSIDL_COMMON_PROGRAMS = &H17 Const CSIDL_PROGRAMS = &H2 Sub AnclarBarraTareas(csidl, sCarpeta, sAccesoDirecto) Set objShellApp = CreateObject("Shell.Application") Set objAllUsersProgramsFolder = objShellApp.NameSpace(csidl) strAllUsersProgramsPath = objAllUsersProgramsFolder.Self.Path Set objFolder = objShellApp.Namespace(strAllUsersProgramsPath & sCarpeta) Set objFolderItem = objFolder.ParseName(sAccesoDirecto) Set colVerbs = objFolderItem.Verbs For Each objVerb in colVerbs If Replace(objVerb.name, "&", "") = "Anclar a la barra de tareas" Then objVerb.DoIt Next end Sub Sub DesanclarBarraTareas(csidl, sCarpeta, sAccesoDirecto) Set objShellApp = CreateObject("Shell.Application") Set objAllUsersProgramsFolder = objShellApp.NameSpace(csidl) strAllUsersProgramsPath = objAllUsersProgramsFolder.Self.Path Set objFolder = objShellApp.Namespace(strAllUsersProgramsPath & sCarpeta) Set objFolderItem = objFolder.ParseName(sAccesoDirecto) Set colVerbs = objFolderItem.Verbs For Each objVerb in colVerbs If Replace(objVerb.name, "&", "") = "Desanclar de la barra de tareas" Then objVerb.DoIt Next end Sub Function GetLogin( myPrompt, username ) ' Basada en GetPassword de http://www.robvanderwoude.com Dim objIE ' Create an IE object Set objIE = CreateObject( "InternetExplorer.Application" ) ' specify some of the IE window's settings objIE.Navigate "about:blank" objIE.Document.Title = myPrompt objIE.ToolBar = False objIE.Resizable = False objIE.StatusBar = False objIE.Width = 320 objIE.Height = 180 ' Center the dialog window on the screen 'With objIE.document.parentWindow.screen ' objIE.Left = (.AvailWidth - objIE.Width ) \ 2 ' objIE.Top = (.Availheight - objIE.Height) \ 2 'End With ' Wait till IE is ready Do While objIE.Busy WScript.Sleep 100 Loop ' Insert the HTML code to prompt for a password objIE.Document.Body.InnerHTML = " " _ |
& «<div style=»»text-align: center; font: 12px Segoe UI, Arial; margin-top: 10px»»>» _
& «<div style=»»padding: 5px;»»>» _
& «<label style=»»display: inline-block; width: 12ex; text-align: right;»»>Usuario:</label>» _
& «<input style=»»display: inline-block; width: 150px; margin-left: 10px;»» type=»»text»» size=»»30″» id=»»Username»» value=»»» & username & «»»>» _
& «</div>» _
& «<div style=»»padding: 5px;»»>» _
& «<label style=»»display: inline-block; width: 12ex; text-align: right;»»>Contraseña:</label>» _
& «<input style=»»display: inline-block; width: 150px; margin-left: 10px;»» type=»»password»» size=»»20″» id=»»Password»»>» _
& «</div>» _
& «<input type=»»hidden»» id=»»OK»» name=»»OK»» value=»»0″»>» _
& «<div style=»»margin-top: 15px»»>» _
& «<input style=»»font: 12px Segoe UI, Arial;»» type=»»submit»» value=»»Conectar»» onclick=»»VBScript:OK.Value=1″»>» _
& «</div>» _
& «</div>»
‘ Hide the scrollbars
objIE.Document.Body.Style.overflow = «auto»
‘ Make the window visible
objIE.Visible = True
‘ Set focus on password input field
objIE.Document.All.Password.Focus
‘ Wait till the OK button has been clicked
On Error Resume Next
Do While objIE.Document.All.OK.Value = 0
WScript.Sleep 100
‘ Error handling code by Denis St-Pierre
If Err Then ‘user clicked red X (or alt-F4) to close IE window
IELogin = Array( «», «» )
objIE.Quit
Set objIE = Nothing
Exit Function
End if
Loop
On Error Goto 0
‘ Read the password from the dialog window
Dim login(2)
login(0) = objIE.Document.All.Username.Value
login(1) = objIE.Document.All.Password.Value
GetLogin = login
‘ Close and release the object
objIE.Quit
Set objIE = Nothing
End Function
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>fin del code>>>