elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: AIO elhacker.NET 2021 Compilación herramientas análisis y desinfección malware


+  Foro de elhacker.net
|-+  Programación
| |-+  Scripting
| | |-+  Resolucion de IP DNS VBSCRIPT
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Resolucion de IP DNS VBSCRIPT  (Leído 1,443 veces)
efer27

Desconectado Desconectado

Mensajes: 27


Ver Perfil
Resolucion de IP DNS VBSCRIPT
« en: 4 Abril 2013, 16:48 pm »

Buenas tardes,

Tengo un problema, bueno uno de muchos. Ahora el problema va por VBSCRIPT planteo el requerimiento.

Tengo que realizar informacion de un una relacion de maquinas las cuales tengo que hacr ping y tengo que resolver el IP y que resuelve el DNS.

Hostname        IP       PING            DNS
MyPc          127.0.0.1  OK          MyPC.Dominio.com
Mypc2        127.0.0.2   NO_OK   No register host

Esta  informacion pasarlo a un CSV.

Pero tambien necesito trabajar con los equipos por separado es decir que me saque un log por separado de los equipos que hacen ping y los que no. esto esta en un TXT.

si alguien me puede ayudar se lo agradecería adjunto el codigo.

Código:

Dim strComputerName, ScriptPath, OnlineFileName, OfflineFileName
Dim ArgObj, OnlineFile, OfflineFile, oInputFile, InputFileName
Dim ReadLineArray(3000), a, b, c, Temp

Const ForAppending = 8
Const ForReading = 1
Const ForWriting = 2
Const ReadTheFile = False
Const CreateTheFile = True

' Valores de Formato
Const ASCII = 0
Const UniCode = -1
Const Default = -2

Set oFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = WScript.CreateObject("WScript.Shell")

' ********************   Declaracion de Varibles  ********************

' Declaracion de nombre de archivos
'*********************************************************************
FilePath=CreateObject("Scripting.FileSystemObject").GetAbsolutePathName(".")


Set ArgObj = WScript.Arguments
If WScript.Arguments.count > 0 Then
  InputFileName = UCase(ArgObj(0))
Else
  InputFileName = FilePath & "\IP_List.txt"
End If

OnlineFileName = FilePath & "\OnlineSystems.txt"
OfflineFileName = FilePath & "\OfflineSystems.txt"


' Elimina los arhivos TXT Online y Offline si es que existe
'*********************************************************************
If oFSO.FileExists(OfflineFileName) = True Then
  oFSO.deletefile OfflineFileName, force
End If
If oFSO.FileExists (OnlineFileName)  Then
  oFSO.deletefile OnlineFileName, force
End If

' Crea los Archivos Online y Offline
'*********************************************************************
oFSO.CreateTextFile OnlineFileName, CreateTheFile
oFSO.CreateTextFile OfflineFileName, CreateTheFile

' Abre el archivo y lee el contenido
'*********************************************************************
Set OnlineFile=oFSO.OpenTextFile(OnlineFileName, ForWriting, ReadTheFile)
Set OfflineFile=oFSO.OpenTextFile(OfflineFileName, ForWriting, ReadTheFile)
Set oInputFile=oFSO.OpenTextFile(InputFileName, ForReading, ReadTheFile)

' Loop through the InputFile to get all the computer names and then check to see if they are online or not.

' Importa la informacion del archivo en el array
'*********************************************************************
Do while not oInputFile.AtEndOfStream
  a = a + 1
  ReadLineArray(a) = Trim(oInputFile.ReadLine) ' Reads the line of text
Loop

' Busca duplicaciones
'*********************************************************************
For b = 1 To a
  ' If data matches, then set the duplicates in the array to "" (blank)
  For c = (b + 1) To a
    If trim(ReadlineArray(b)) <> "" And trim(ReadLineArray(b)) = trim(ReadLineArray(c)) Then
      ' Found a duplicate!  Set it to blank
      ReadLineArray(c) = ""
    End If
  Next
Next

' Copy information into "output.txt" text file (exclude blank lines).
'*********************************************************************
For b = 1 To a
  If trim(ReadlineArray(b)) <> "" Then
    strComputerName = trim(ReadlineArray(b))
    IsConnectible
  End If
Next

' Cierra todos los archivos abiertos
'*********************************************************************
OnlineFile.close
OfflineFile.close

' Let user know the program has completed its operation.
wscript.echo "Finished"
'*********************************************************************

Function IsConnectible

  Dim objPing,objStatus
   
  ' Test to see if the remote machine is online or offline
'*********************************************************************
  Set objPing = GetObject("winmgmts:{impersonationLevel=impersonate}")._
  ExecQuery("select Replysize from Win32_PingStatus where address = '" & strComputerName & "'")
   
  ' Test for the status.  If the system is Null or if its offline or does not exist on the network,
  ' then dump the results to "Offline.txt", else, dump it to "online.txt"
'*********************************************************************
  For Each objStatus in objPing
    If  IsNull(objStatus.ReplySize) Then
      ' Machine is offline --> dump the results to "Offline.txt"
      OfflineFile.Writeline strComputerName
    Else
      ' Machine is online  --> dump the results to "Online.txt"
      OnlineFile.Writeline strComputerName
    End If
  Next
   
  ' Destruye las variable de memoria
'*********************************************************************
  Set objPing=Nothing
  Set objStatus=Nothing

End Function




En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
VBScript: Angry Birds Pong in VBScript [HTA + VBS] (100% Notepad) by JohnConnor
Scripting
JohnConnor 1 4,974 Último mensaje 4 Marzo 2013, 23:34 pm
por dato000
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines