elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.
 
Inicio Ayuda Buscar Ingresar Registrarse
29 Mayo 2012, 09:02  


Tema destacado: ¡Aprende hacking con práctica! - WarZone, el wargame de elhacker.net

+  Foro de elhacker.net
|-+  Programación
| |-+  Programación Visual Basic (Moderadores: LeandroA, seba123neo, raul338)
| | |-+  Seriales de Pen-Drives conectados (SRC)
0 Usuarios y 2 Visitantes están viendo este tema.
Páginas: 1 [2] Ir Abajo Respuesta Imprimir
Autor Tema: Seriales de Pen-Drives conectados (SRC)  (Leído 2,469 veces)
Maurice_Lupin

Desconectado Desconectado

Mensajes: 110


GPS


Ver Perfil
Re: Seriales de Pen-Drives conectados (SRC)
« Respuesta #15 en: 4 Diciembre 2011, 20:09 »

Hola tengo una consulta la clase: "{53f56307-b6bf-11d0-94f2-00a0c91efb8b}" me detecta hasta las unidades de disco IDE, si alguien tuviera discos SATA para ver si los detecta
Código
Public Function FlashSerials() As String
   Dim cad As String
  Dim TGUID As GUID
 
  Call IIDFromString(StrPtr("{53f56307-b6bf-11d0-94f2-00a0c91efb8b}"), TGUID)
 
  Dim hDev As Long
  ' puntero a la clase de los USB
  hDev = SetupDiGetClassDevs(TGUID, &H0, &H0, &H12)
 
  If hDev = -1 Then Exit Function
 
  Dim lCount       As Long
  Dim lSize        As Long
  Dim DTL          As SP_DEVICE_INTERFACE_DETAIL_DATA
  Dim DTA          As SP_DEVICE_INTERFACE_DATA
 
  DTA.cbSize = Len(DTA)
  DTL.cbSize = &H5
  lCount = &H0
 
  While Not (SetupDiEnumDeviceInterfaces(hDev, &H0, TGUID, lCount, DTA) = &H0)
 
    Call SetupDiGetDeviceInterfaceDetail(hDev, DTA, ByVal &H0, &H0, lSize, ByVal &H0)
 
    Call SetupDiGetDeviceInterfaceDetail(hDev, DTA, DTL, ByVal lSize, lSize, ByVal &H0)
 
    If UBound(Split(DTL.strDevicePath, "#")) > 1 Then
       cad = cad & Split(UCase$(DTL.strDevicePath), "#")(1) & _
        " - " & Split(UCase$(DTL.strDevicePath), "#")(2) & Chr$(&HD)
       'cad = cad & DTL.strDevicePath & Chr(10)
    End If
 
    lCount = lCount + 1
  Wend
 
  Call SetupDiDestroyDeviceInfoList(hDev)
  FlashSerials = cad
  If FlashSerials = "" Then FlashSerials = "No hay conexiones"
 
End Function
 


En línea
Hasseds

Desconectado Desconectado

Mensajes: 144



Ver Perfil
Re: Seriales de Pen-Drives conectados (SRC)
« Respuesta #16 en: 4 Diciembre 2011, 22:24 »

Hola Maurice_Lupin , la clase 53f56307-b6bf-11d0-94f2-00a0c91efb8b si detecta los discos Sata 1 y sata 2, todavia no pude probar con Sata 3 pero seguramente tambien los detecta ya que es la misma interface.

Esta clase tambien detecta (o enumera mejor dicho) Discos IDE, ZIP de interface IDE y Dispositivos de almacenamiento USB... por lo tanto deberás filtrar los retornos de acuerdo a lo que quieras listar, por ejemplo en el codigo original solo listé la interface USB

 If InStr(UCase$(DTL.strDevicePath), "USB") Then      

http://foro.elhacker.net/programacion_visual_basic/seriales_de_pendrives_conectados_src-t331333.0.html;msg1664147#msg1664147



Nota: Las interfaces "IDE" & Sata no retornan el Serial verdadero por esta vía... A Diferencia de la interface USB que sí se puede obtener con este método


La clase a5dcbf10-6530-11d2-901f-00c04fb951ed solo enumera Dispositivos de almacenamiento USB, por lo tanto no hay que "filtrar retornos"
http://foro.elhacker.net/programacion_visual_basic/seriales_de_pendrives_conectados_src-t331333.0.html;msg1629437#msg1629437










« Última modificación: 5 Diciembre 2011, 01:39 por Hasseds » En línea

Sergio Desanti
Maurice_Lupin

Desconectado Desconectado

Mensajes: 110


GPS


Ver Perfil
Re: Seriales de Pen-Drives conectados (SRC)
« Respuesta #17 en: 5 Diciembre 2011, 06:51 »

Gracias Hasseds, usando WMI me devuelve casi el mismo serial de IDE que utilizando la clase 53f56307-b6bf-11d0-94f2-00a0c91efb8b , estas seguro que no es el serial verdadero?  :-[

Saludos.

En línea
BlackZeroX (Astaroth)
Wiki

Desconectado Desconectado

Mensajes: 2.832


I'Love...!¡.


Ver Perfil WWW
Re: Seriales de Pen-Drives conectados (SRC)
« Respuesta #18 en: 5 Diciembre 2011, 09:12 »

.
Aclarando un punto crucial es que NO SE LE CONOCE COMO CLASES son GUID esos identificadores...

Dulces Lunas!¡.
En línea

Web Principal-->[ Blog(VB6) | Host File (Public & Private) | Scan Port | (New)MyInfraPC (Descubre mi Contraseña venefi. $) ]



The Dark Shadow is my passion.
El infierno es mi Hogar, mi novia es Lilith y el metal mi
Hasseds

Desconectado Desconectado

Mensajes: 144



Ver Perfil
Re: Seriales de Pen-Drives conectados (SRC)
« Respuesta #19 en: 5 Diciembre 2011, 18:52 »

Sí, en adelante será mejor referirse a estas clases de dispositivos como GUID.





estas seguro que no es el serial verdadero?  :-[


Segurísimo !!!


Seriales de Hard Disk conectados (Solo funciona como usuario Administrador ):


Código
 
Option Explicit
 
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Function: SerialHD
' Autor: Adrian Desanti (Dessa)
' Creditos: es una adaptacion a mis necesidades de una clase de Antonio Giuliana
' Agradecimientos: Karcrak (IsAdministrador)
' Requisitos : Windows NT + Administrador
' Rertorno: retorna el serial verdadero de Discos IDE o S-ATA conectados
' Serial verdadero: Es el que figura en la etiqueta del Disco y no cambia al formatear
' Fecha : V.2 Septiembre 2010
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Private Declare Function CheckTokenMembership Lib "ADVAPI32" (ByVal TokenHandle As Long, ByVal pSidToCheck As Long, ByRef IsMember As Boolean) As Long
 
Private Declare Function GetVersion Lib "KERNEL32" () As Long
Private Declare Function CreateFile Lib "KERNEL32" Alias "CreateFileA" (ByVal lpFileName As String, ByVal dwDesiredAccess As Long, ByVal dwShareMode As Long, ByVal lpSecurityAttributes As Long, ByVal dwCreationDisposition As Long, ByVal dwFlagsAndAttributes As Long, ByVal hTemplateFile As Long) As Long
Private Declare Function CloseHandle Lib "KERNEL32" (ByVal hObject As Long) As Long
Private Declare Function DeviceIoControl Lib "KERNEL32" (ByVal hDevice As Long, ByVal dwIoControlCode As Long, lpInBuffer As Any, ByVal nInBufferSize As Long, lpOutBuffer As Any, ByVal nOutBufferSize As Long, lpBytesReturned As Long, ByVal lpOverlapped As Long) As Long
Private Declare Sub ZeroMemory Lib "KERNEL32" Alias "RtlZeroMemory" (dest As Any, ByVal numBytes As Long)
 
Private Type IDEREGS
   bFeaturesReg As Byte: bSectorCountReg As Byte: bSectorNumberReg As Byte: bCylLowReg As Byte: bCylHighReg As Byte: bDriveHeadReg As Byte: bCommandReg As Byte: bReserved As Byte
End Type
Private Type SENDCMDINPARAMS
   cBufferSize As Long: irDriveRegs As IDEREGS: bDriveNumber As Byte: bReserved(1 To 3) As Byte: dwReserved(1 To 4) As Long
End Type
Private Type DRIVERSTATUS
   bDriveError As Byte: bIDEStatus As Byte: bReserved(1 To 2) As Byte: dwReserved(1 To 2) As Long
End Type
Private Type SENDCMDOUTPARAMS
   cBufferSize As Long: DStatus As DRIVERSTATUS: bBuffer(1 To 512) As Byte
End Type
 
Private Declare Function IIDFromString Lib "ole32" (ByVal lpsz As Long, ByRef lpiid As GUID) As Long
Private Declare Function SetupDiGetClassDevs Lib "setupapi.dll" Alias "SetupDiGetClassDevsA" (ByVal ClassGuid As Long, ByVal Enumerator As Long, ByVal HwndParent As Long, ByVal flags As Long) As Long
Private Declare Function SetupDiEnumDeviceInterfaces Lib "setupapi.dll" (ByVal DeviceInfoSet As Long, ByVal DeviceInfoData As Long, ByRef InterfaceClassGuid As GUID, ByVal MemberIndex As Long, ByRef DeviceInterfaceData As SP_DEVICE_INTERFACE_DATA) As Long
Private Declare Function SetupDiDestroyDeviceInfoList Lib "setupapi.dll" (ByVal DeviceInfoSet As Long) As Long
 
Private Type GUID
   Data1 As Long: Data2 As Integer: Data3 As Integer: Data4(0 To 7) As Byte
End Type
 
Private Type SP_DEVICE_INTERFACE_DATA
   cbSize As Long: InterfaceClassGuid As GUID: flags As Long: Reserved As Long
End Type
 
 
Private Sub Form_Load()
 
 If (GetVersion And &HFF) > &H5 Then
   If App.LogMode = 0 Then
       MsgBox "En Vista o Seven ejecutar compilado en modo Administrador"
       End
   End If
 End If
 
 
 AutoRedraw = True
 FontBold = True
 Caption = ""
 Print SerialHD()
 
 
 
End Sub
 
Public Function SerialHD() As String
 
 If (GetVersion And &HFF) < 5 Then
   SerialHD = "Sistema Operativo No válido"
   Exit Function
 End If
 
 If IsAdministrador = False Then
   SerialHD = "Se requiere usuario Administrador"
   Exit Function
 End If
 
 Dim RetDiskCount  As Long
 
 RetDiskCount = DiskCount()
 
 If RetDiskCount < 0 Then
   SerialHD = "DiskCount No válido"
   Exit Function
 End If
 
 Dim nDisco        As Long
 Dim hdh           As Long
 Dim hddfr         As Byte
 Dim hddln         As Byte
 Dim bin           As SENDCMDINPARAMS
 Dim bout          As SENDCMDOUTPARAMS
 Dim br            As Long
 Dim x             As Byte
 Dim s             As String
 
 For nDisco = 0 To RetDiskCount - 1 ' los ciclos del For serán solo la cantidad de "PhysicalDrive" conectados
   
     hdh = CreateFile("\\.\PhysicalDrive" & nDisco, &H3, &H0, &H0, &H3, &H0, &H0)
 
     If hdh = -1 Then
         If nDisco = 0 Then
             SerialHD = " IDE " & nDisco & " = " & "Error en CreateFile" & vbNewLine
         Else
             SerialHD = SerialHD & " IDE " & nDisco & " = " & "Error en CreateFile" & vbNewLine
         End If
     Else
         hddfr = 21 ' Posicion en el buffer del SerialNumber
         hddln = 20 ' Tamaño resrvado en el buffer para el SerialNumber
         
         Call ZeroMemory(bin, Len(bin))
         Call ZeroMemory(bout, Len(bout))
 
         With bin
             .bDriveNumber = nDisco
             .cBufferSize = 512
           With .irDriveRegs
               If (nDisco And 1) Then
                   .bDriveHeadReg = &HB0
               Else
                   .bDriveHeadReg = &HA0
               End If
               .bCommandReg = &HEC
               .bSectorCountReg = 1
               .bSectorNumberReg = 1
           End With
         End With
 
         'DFP_RECEIVE_DRIVE_DATA = &H7C088
         Call DeviceIoControl(hdh, &H7C088, bin, Len(bin), bout, Len(bout), br, 0)
 
         s = ""
         For x = hddfr To hddfr + hddln - 1 Step 2
             If bout.bBuffer(x + 1) = 0 Then Exit For
             s = s & Chr(bout.bBuffer(x + 1))
             If bout.bBuffer(x) = 0 Then Exit For
             s = s & Chr(bout.bBuffer(x))
         Next x
         Call CloseHandle(hdh)
 
         If Trim$(s) <> "" Then
             SerialHD = SerialHD & " IDE " & nDisco & " = " & Trim$(s) & vbNewLine
         End If
     End If
 
 Next nDisco
 
End Function
 
Private Function DiskCount() As Long
 
   Dim TGUID   As GUID
   Dim hDev    As Long
 
   Call IIDFromString(StrPtr("{53f56307-b6bf-11d0-94f2-00a0c91efb8b}"), TGUID)
 
   '&H12 ===> DIGCF_PRESENT = &H10 Or DIGCF_DEVICEINTERFACE = &H2
   hDev = SetupDiGetClassDevs(VarPtr(TGUID), &H0, &H0, &H12)
 
   If hDev = -1 Then
     DiskCount = -1
     Exit Function
   End If
 
   Dim Cnt As Long
   Dim DTA  As SP_DEVICE_INTERFACE_DATA
   DTA.cbSize = Len(DTA)
 
   While Not (SetupDiEnumDeviceInterfaces(hDev, &H0, TGUID, Cnt, DTA) = &H0)
       Cnt = Cnt + 1
   Wend
 
   Call SetupDiDestroyDeviceInfoList(hDev)
 
   DiskCount = Cnt
 
End Function
 
Private Function IsAdministrador() As Boolean
  Dim SID(1)  As Currency
  SID(0) = 36028797018964.0193@
  SID(1) = 233646220.9056@
  Call CheckTokenMembership(&H0, VarPtr(SID(0)), IsAdministrador)
End Function
 
 
 



« Última modificación: 6 Diciembre 2011, 00:23 por Hasseds » En línea

Sergio Desanti
Maurice_Lupin

Desconectado Desconectado

Mensajes: 110


GPS


Ver Perfil
Re: Seriales de Pen-Drives conectados (SRC)
« Respuesta #20 en: 6 Diciembre 2011, 05:41 »

 :( pensé que eran verdaderos, gracias, habrá que ejecutar como administrador  :xD

Saludos.
En línea
Páginas: 1 [2] Ir Arriba Respuesta Imprimir 

Ir a:  

Powered by SMF 1.1.16 | SMF © 2006-2008, Simple Machines