viernes, 13 de julio de 2018

Habilitar y Deshabilitar USB BitLocker


Crear un archivo .VBS y copiar lo siguiente:


''''''''''''''''''''''''''''''''''
'Enable and disable USB BitLocker'
'BY Armando H. Mateu.            '
''''''''''''''''''''''''''''''''''

Set WshShell = CreateObject("WScript.Shell")
'RDVDenyWriteAccess and FDVDenyWriteAccess
parameter1 = "FDVDenyWriteAccess"
parameter2 = "RDVDenyWriteAccess"
Convert(parameter1)
Convert(parameter2)

Sub Convert(parameter)
myKey = "HKLM\SYSTEM\CurrentControlSet\Policies\Microsoft\FVE\" + parameter
lcValue1 = WSHShell.RegRead(myKey)

  If lcValue1 = "0" Then
     WshShell.RegWrite myKey, "1", "REG_DWORD"
     WshShell.Popup "Bloqueado"
  Else
     WshShell.RegWrite myKey, "0", "REG_DWORD"
     WshShell.Popup "DesBloqueado"
  End If

End Sub



Saludos!,
Armando H. Mateu.

miércoles, 30 de septiembre de 2015

Monitoreo de carpetas con VBS ejecutando PUTTY

Se requiere el monitoreo de una carpeta para ejecutar una tarea en otro servidor, al detectar archivo .TXT, conectarse a un servidor y ejecutar un shell script.

Archivo VBS:

Dim Wshshell,FSO
set fso = CreateObject("Scripting.FileSystemObject")
set directory = fso.GetFolder("C:\Carpeta\").Files

for each file in directory if Mid(file.NAME,len(file.NAME)-3,4) = ".TXT" then   Set wshshell = wscript.CreateObject("WScript.Shell")   Wshshell.run "putty.exe -ssh USUARIO@192.168.1.100 -pw PASSWORD -m Comandos.txt"   MsgBox file.NAME & " - " & Mid(file.NAME,len(file.NAME)-3,4)   Exit For Else    MsgBox file.NAME & " - " & Mid(file.NAME,len(file.NAME)-3,4) End If next

El archivo comando contiene todo lo que puedes ejecutar en un terminal o consola en este caso usamos

Archivo Comandos.txt: cd /carpeta
ls -l
sh script.sh

Solo faltaria crear una tarea programada ejecutando el archivo VBS, para que realice el monitoreo de la carpeta,


Saludos!!,
Armando Mateu.

jueves, 27 de agosto de 2015

Ocultar contraseña a simple vista en un Bash

Cuando estamos escribiendo un Shell Scripting, posiblemente no nos gustaría mostrar una contraseña a simple vista que pueda ser recordada facilmente,  por lo tanto vamos a dificultar esta lectura a la vista de los usuarios.

Primer Script, que se conecta a un FTP, para descargar archivos .txt

echo "Conectado al servidor para descargar archivos"
ftp -n 172.25.250.272 << EOF
user armando hola
binary
prompt
mget *.txt
quit
EOF



Como podemos ver el usuario es armando y la contraseña es hola, muy facil de recordar!!, ahora vamos a dificultar un poco el recordar la contraseña.

martes, 18 de agosto de 2015

Creando un reporte ALV en ABAP

Creación de un reporte en ABAP utilizando un simple ALV para mostrar datos de la tabla SPFLI.
*&---------------------------------------------------------------------*
*& Report  ZAHM_ALV_DEMO
*&
*&---------------------------------------------------------------------*
*&Descripcion: Mostrar diferentes formas de crear un ALVGrid.
*&Programo...: Armando H Mateu.
*&Fecha......: 18/08/2015.
*&---------------------------------------------------------------------*

REPORT  ZAHM_ALV_DEMO.

include ZAHM_ALV_DEMO_TOP.
include ZAHM_ALV_DEMO_SUB.

START-OF-SELECTION.
  PERFORM obtener_datos.
  PERFORM crear_cabecera.
  PERFORM crear_catalogo.
  PERFORM mostrar_cabecera.
  PERFORM mostrar_reporte.

martes, 2 de diciembre de 2014

javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No subject alternative names present

¡Problemas para consumir un Web Services con SSL!!...

dump Error:
"Exception in thread "main" com.sun.xml.internal.ws.client.ClientTransportException: HTTP transport error: javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No subject alternative names matching IP address IP found"

Explicación del problema:

No subject alternative names present

Sample Alt Name Stack Trace
javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No subject alternative names present
In most cases this is a hostname/SSL certificate CN mismatch. This commonly happens when a self-signed certificate issued to localhost is placed on a machine that is accessed by IP address. It should be noted that generating a certificate with an IP address for a common name, e.g. CN=192.168.1.1,OU=Middleware,dc=vt,dc=edu, will not work in most cases where the client making the connection is Java. For example the Java CAS client will throw SSL errors on connecting to a CAS server secured with a certificate containing an IP address in the CN.


La Solución es sobre escribir el método Java de verificación del HostName sobre la aplicación que consume el Web Service de la siguiente manera:
  static {
    HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() {
      public boolean verify(String hostname, SSLSession session) {
        if (hostname.equals("IP.IP.IP.IP")) {
          return true;
        }
        return false;
      }
    });
  }


Saludos!! Armando Mateu.