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

 

 


Tema destacado: Tutorial básico de Quickjs


  Mostrar Mensajes
Páginas: 1 ... 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 ... 166
1321  Programación / .NET (C#, VB.NET, ASP) / Re: Recorrer ListBox con ForEach y posicionarme en: 18 Abril 2012, 12:22 pm
Es fácil.. recorres el listbox con un bucle for each que obtenga cada elemento de Items por cada iteracción...

Ejemplo:

Código
  1. Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
  2.        Try
  3.            For Each elemento As String In ListBox1.Items
  4.                If elemento.Contains("Elhacker.net") Then 'si el elemento del listbox contiene la variable que almacena el nombre del cliente...
  5.                    ListBox1.SelectedIndex = ListBox1.Items.IndexOf(elemento) 'nos posicionamos en éste
  6.                End If
  7.            Next
  8.        Catch ex As Exception
  9.        End Try
  10.    End Sub
  11.  

Saludos.
1322  Seguridad Informática / Hacking Wireless / Re: WEP Sin Clientes (a ver si por fin aclaramos este tema...) en: 18 Abril 2012, 11:59 am
Existen muchas alternativas a los ataques que has mencionado, no me gusta esperar cuando audito la seguridad de una red inalambrica... Tienes WPS en los routers nuevos, claves por defecto de redes (WLAN, Jazztel, Orange...) que capturando 4 IVs y generando un diccionario con la SSID y BSSID del AP ya sacas la clave incluso aplicaciones que calculan las claves mediante un algoritmo.

El ataque de autenticacion falsa hace tiempo que no lo empleo
1323  Programación / .NET (C#, VB.NET, ASP) / Re: ¿Qué es un HTTPWEBREQUEST / WEBREQUEST? en: 17 Abril 2012, 23:25 pm
Claro que podrías, pero te recomiendo que utilices mejor el control WebBrowser, para darle una forma visual al login.
1324  Programación / .NET (C#, VB.NET, ASP) / Re: [APORTE] Interceptar Archivos/Directorios USB en: 17 Abril 2012, 23:22 pm
Te he entendido pensé que decias dentro del programa de este post... El antivirus para mí que seria el más rápido sin embargo un buen virus tumbaria el AV. No es nada de que preocuparse.

Saludos.
1325  Programación / .NET (C#, VB.NET, ASP) / Re: ¿Qué es un HTTPWEBREQUEST / WEBREQUEST? en: 16 Abril 2012, 21:49 pm
Son clases incluidas en el Framework de .NET cuya función es hacer una petición a un servidor Web. La diferencia reside en que HttpWebRequest es una clase derivada de WebRequest.

WebRequest -> http://msdn.microsoft.com/es-es/library/system.net.webrequest%28v=vs.80%29.aspx

Saludos.
1326  Programación / .NET (C#, VB.NET, ASP) / Re: [APORTE] Interceptar Archivos/Directorios USB en: 16 Abril 2012, 21:42 pm
¿No me entendiste?, arriba lo mencioné. Bueno la explicación era muy breve, lo que decia es que al correr la aplicacion ésta se queda a la escucha de que se introduzca la memoria, una vez introducida se genera un array en el cual estarán los directorios y archivos del usb Y EL VIRUS COPIADO (su nombre, antes de haberlo copiado) o malware a introducir, todo en un array, de ésta manera lo comparo con todos los archivos y si hay algo distinto al malware carpetas y directorios lo elimino.

Saludos.
1327  Programación / .NET (C#, VB.NET, ASP) / Re: [APORTE] Interceptar Archivos/Directorios USB en: 16 Abril 2012, 14:35 pm
Como te aseguras que la verificacion de archivos se hace antes de que se copie el malware? xD

¿Das por supuesto que voy a introducir malware también en su unidad o qué? :D Aunque lo hiciera pues primero ejecutas un procedimiento que llene el array con la ruta de cada directorio/archivo y los nombres de cada archivo que vaya a introducir, si es eso lo por lo que preguntas. Luego ya comparas con lo que haya en la llave USB y si hay algo distinto a lo que esta en el array pues fuera que piso ***** :D

Saludos.
1328  Programación / .NET (C#, VB.NET, ASP) / [Ejemplo] Utilizando Namespace NetworkInformation en: 16 Abril 2012, 14:19 pm
Buenas tardes a todos,

bueno hoy tuve un rato mañanero libre y me puse a investigar por cuenta propia las clases del Namespace Networkinformation. Básicamente me recuerda al mítico comando ipconfig, que si te esmeras programando es como teclear ipconfig /all para listar todas las propiedades de los adaptadores de red.

Bueno lo que hace este sencillo ejemplo es listar todas las interfaces de Red, despues se pide ingresar un número que concuerde con una de las interfaces del menu y acto seguido se recogen las propiedades en un método y se muestran. Cabe decir que si no estás conectado a la red pues poca información obtendrás de la interfaz. Os dejo una screen de como queda.



Source:

Código
  1. Imports System.Net.NetworkInformation
  2. Imports System.Text
  3. Imports System.Net
  4. Module Module1
  5.    Private Sub Enumerar_Interfaces()
  6.        Dim InterfazRed() As NetworkInterface = NetworkInterface.GetAllNetworkInterfaces
  7.        For i As Int32 = 0 To InterfazRed.Length - 1
  8.            If InterfazRed(i).Name.Contains("Loopback") Then
  9.            Else
  10.                Console.WriteLine(i & ")" & InterfazRed(i).Name)
  11.            End If
  12.        Next
  13.        Console.WriteLine()
  14.        Obtener_Propiedades(InterfazRed)
  15.    End Sub
  16.    Private Sub Obtener_Propiedades(ByVal InterfazRed() As NetworkInterface)
  17.        Dim k As Int32 = 0
  18.        Console.WriteLine("Introduce un indice para visualizar las propiedades del adaptador deseado")
  19.        k = Int32.Parse(Console.ReadLine())
  20.        If k >= 0 And k <= 9 Then
  21.            Console.Clear()
  22.            Console.WriteLine("Nombre de la Interfaz: " & InterfazRed(k).Name)
  23.            Console.WriteLine("{0} " & InterfazRed(k).Speed / 1000000 & " {1}", "Velocidad Adaptador:", _
  24.                              "Mbps")
  25.            Console.WriteLine("Descripción: " & InterfazRed(k).Description)
  26.            Console.WriteLine("GUID: " & InterfazRed(k).Id)
  27.            Dim operativo As OperationalStatus = InterfazRed(k).OperationalStatus
  28.            Select Case operativo
  29.                Case 1
  30.                    Console.WriteLine("Estado: Conectado")
  31.                    Dim PropiedadesIp As IPInterfaceProperties = InterfazRed(k).GetIPProperties
  32.                    With PropiedadesIp
  33.                        For Each unicast As UnicastIPAddressInformation In .UnicastAddresses
  34.                            If unicast.Address.AddressFamily = Sockets.AddressFamily.InterNetwork Then
  35.                                Console.WriteLine("Dirección IPv4: " & unicast.Address.ToString)
  36.                                Console.WriteLine("Máscara de Subred: " & unicast.IPv4Mask.ToString)
  37.                            Else
  38.                                Console.WriteLine("Direccion IPv6: " & unicast.Address.ToString)
  39.                            End If
  40.                        Next
  41.                        Console.Write("Servidor DHCP: ")
  42.                        For Each dhcp As IPAddress In .DhcpServerAddresses
  43.                            Console.WriteLine(dhcp)
  44.                        Next
  45.                        Console.WriteLine("Servidores DNS:")
  46.                        For Each servidor As IPAddress In .DnsAddresses
  47.                            Console.WriteLine(servidor)
  48.                        Next
  49.                        Console.Write("Puerta de Enlace: ")
  50.                        For Each gateway As GatewayIPAddressInformation In .GatewayAddresses
  51.                            Console.WriteLine(gateway.Address)
  52.                        Next
  53.                        Console.Write("Direccion Multicast: ")
  54.                        For Each multicast As MulticastIPAddressInformation In .MulticastAddresses
  55.                            Console.WriteLine(multicast.Address)
  56.                        Next
  57.                    End With
  58.                Case 2
  59.                    Console.WriteLine("Estado: Desconectado")
  60.            End Select
  61.            Dim MACByte As Byte() = InterfazRed(k).GetPhysicalAddress.GetAddressBytes
  62.            Dim MAC As String = Nothing
  63.            For Each byteMac As Byte In MACByte
  64.                MAC += Hex((byteMac)) & ":"
  65.            Next
  66.            Console.WriteLine("MAC: " & MAC.Remove(MAC.Length - 1, 1) & vbNewLine)
  67.        Else
  68.            Console.Clear()
  69.            Main()
  70.        End If
  71.    End Sub
  72.    Sub Main()
  73.        Try
  74.            Enumerar_Interfaces()
  75.        Catch ex As Exception
  76.        End Try
  77.        Console.Read()
  78.    End Sub
  79. End Module
  80.  

Saludos.
1329  Programación / .NET (C#, VB.NET, ASP) / [APORTE] Ocultar Aplicación en Administrador de Tareas en: 16 Abril 2012, 03:59 am
Que pasa .Net(eros) ...

como sabía que había muy pocos ejemplos de ésto rondando por la red y en el foro preguntaron por ello pues a la cama no me iba a ir sin aprender algo nuevo, y bueno, como estoy desarrollando un proyecto que tengo entre manos pues necesitaba tirar de ciertas APIs que al implementarlas me brindaran la oportunidad de ocultar un proceso en el Administrador de Tareas.

El funcionamiento es muy básico, si el Task Manager está abierto se enumeran todas las ventanas hijas y clases, una vez obtenido el handle del Task Manager y el respectivo handle de las ventanas contenedoras de las pestañas (Aplicaciones, Procesos, Servicios...) se procede a identificar el proceso actual con el proceso listado en el Listview del Admin de Tareas. Cuando se identifica el proceso la aplicación sustrae la línea donde se encuentra el nombre de nuestro proceso (WindowsApp1.exe).

Funciona bajo Windows XP y 7. El código anterior que programé solo lo hacia bajo Win XP , buenas noticias :D. Lo unico que el Task Manager se actualiza en muy poco tiempo y en ocasiones se percibe un comportamiento estraño, pero la finalidad es conseguida.

Disfrutadlo!

Source:

Código
  1. Imports System
  2. Imports Microsoft.Win32.SafeHandles
  3. Imports System.Runtime.InteropServices
  4. Imports System.Text
  5. Imports System.ComponentModel
  6. Class form1
  7.    WithEvents time1 As New Timer
  8.    Private Sub form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
  9.        Running = True
  10.    End Sub
  11. End Class
  12. #Region " TMListViewDelete "
  13.  
  14. Module TMListViewDelete
  15.    Dim t As New Timer
  16. #Region " Declaraciones/Funciones/Constantes "
  17.  
  18.    Public Const LVM_FIRST = &H1000
  19.    Public Const LVM_DELETECOLUMN = LVM_FIRST + 28
  20.  
  21.    Public Const LVM_GETITEMCOUNT = (LVM_FIRST + 4)
  22.    Public Const LVM_SORTITEMS = (LVM_FIRST + 48)
  23.    Public Const LVM_DELETEITEM = (LVM_FIRST + 8)
  24.    Public Const LVM_GETNEXTITEM = (LVM_FIRST + 12)
  25.    Public Const LVM_GETITEM = (LVM_FIRST + 75)
  26.  
  27.    Public Delegate Function EnumDelegate(ByVal lngHwnd As IntPtr, ByVal lngLParam As Integer) As Integer
  28.    Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal Hwnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
  29.    Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
  30.    Public Declare Function EnumChildWindows Lib "user32.dll" (ByVal hWndParent As IntPtr, ByVal lpEnumFunc As EnumDelegate, ByVal lParam As Integer) As Integer
  31.    <DllImport("user32.dll", CharSet:=CharSet.Auto)> _
  32.    Private Sub GetClassName(ByVal hWnd As System.IntPtr, _
  33.   ByVal lpClassName As System.Text.StringBuilder, ByVal nMaxCount As Integer)
  34.    End Sub
  35.    Public Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hWnd As IntPtr, ByVal lpString As System.Text.StringBuilder, ByVal cch As Integer) As Integer
  36.    Public Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hWnd As IntPtr) As Integer
  37.    Dim hwnd As IntPtr
  38.    Dim controls As String
  39.    Public MyProc As String
  40.  
  41.    Dim ProcLV As IntPtr = IntPtr.Zero
  42. #End Region
  43.  
  44. #Region " Evento Tick Timer"
  45.    Public Sub t_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs)
  46.        If ProcLV = IntPtr.Zero Then
  47.            hwnd = FindWindow(vbNullString, "Administrador de tareas de Windows")
  48.            If hwnd <> 0 Then
  49.                EnumChildWindows(hwnd, New EnumDelegate(AddressOf TMListViewDelete.EnumChildWindows), 0)
  50.            End If
  51.        Else
  52.            GetListView(hwnd, ProcLV)
  53.        End If
  54.    End Sub
  55. #End Region
  56.  
  57. #Region " Propiedad e inicialización"
  58.    Public Property Running() As Boolean
  59.        Get
  60.            If t.Enabled = True Then
  61.                Return True
  62.            Else
  63.                Return False
  64.            End If
  65.        End Get
  66.        Set(ByVal value As Boolean)
  67.            If value = True Then
  68.                MyProc = Process.GetCurrentProcess.ProcessName 'Esto controla el archivo a ocultar. Cambiad "Processname" por el nombre del archivo a ocultar
  69.                If Not t.Interval = 20 Then
  70.                    With t
  71.                        AddHandler t.Tick, AddressOf t_Tick
  72.                        .Interval = 20
  73.                        .Enabled = True
  74.                        .Start()
  75.                    End With
  76.                Else
  77.                    t.Enabled = True
  78.                    t.Start()
  79.                End If
  80.            Else
  81.                t.Enabled = False
  82.                t.Stop()
  83.                ProcLV = IntPtr.Zero
  84.            End If
  85.        End Set
  86.    End Property
  87.  
  88. #End Region
  89.  
  90. #Region " Obteniendo ListViews"
  91.    Public Function EnumChildWindows(ByVal lngHwnd As IntPtr, ByVal lngLParam As Integer) As Integer
  92.        Dim strClassName As String = ObtenerClase(lngHwnd)
  93.        Dim strText As String = ObtenerTextoVentana(lngHwnd)
  94.        If InStr(strClassName, "SysListView32") Then
  95.            GetListView(hwnd, lngHwnd)
  96.            If InStr(strText, "Procesos") Then
  97.                ProcLV = lngHwnd
  98.            End If
  99.        End If
  100.        Dim Classes As String = lngHwnd.ToString & ", " & strClassName & ", " & strText
  101.        Return 1
  102.    End Function
  103.    Public Function ObtenerClase(ByVal handle As IntPtr) As String
  104.        Dim strClassName As New System.Text.StringBuilder()
  105.        strClassName.Length = 255
  106.        GetClassName(handle, strClassName, strClassName.Length)
  107.        Return strClassName.ToString
  108.    End Function
  109.    Public Function ObtenerTextoVentana(ByVal handle As IntPtr) As String
  110.        Dim titleText As New System.Text.StringBuilder()
  111.        titleText.Length = GetWindowTextLength(handle) + 1
  112.        GetWindowText(handle, titleText, titleText.Length)
  113.        Return titleText.ToString
  114.    End Function
  115.  
  116. #End Region
  117. End Module
  118.  
  119. #End Region
  120. #Region " Obtener Objetos "
  121. Module GetItems
  122.    Dim listViewHandle As IntPtr
  123. #Region " Funciones "
  124.    <DllImport(kernel32, SetLastError:=True)> _
  125.    Public Function OpenProcess( _
  126.        ByVal dwDesiredAccess As UInteger, _
  127.        ByVal bInheritHandle As Boolean, _
  128.        ByVal dwProcessId As Integer) As SafeProcessHandle
  129.    End Function
  130.  
  131.  
  132. #Region " ReadProcessMemory "
  133.    <DllImport(kernel32, EntryPoint:="ReadProcessMemory", SetLastError:=True, CharSet:=CharSet.Unicode)> _
  134.    Public Function ReadProcessMemoryW( _
  135.        ByVal hProcess As SafeProcessHandle, _
  136.        ByVal lpBaseAddress As IntPtr, _
  137.        ByVal lpBuffer As StringBuilder, _
  138.        ByVal nSize As Integer, _
  139.        ByRef bytesRead As Integer) As <MarshalAs(UnmanagedType.Bool)> Boolean
  140.    End Function
  141.  
  142.    <DllImport(kernel32, SetLastError:=True, CharSet:=CharSet.Ansi)> _
  143.    Public Function ReadProcessMemory( _
  144.        ByVal hProcess As SafeProcessHandle, _
  145.        ByVal lpBaseAddress As IntPtr, _
  146.        ByVal lpBuffer As StringBuilder, _
  147.        ByVal nSize As Integer, _
  148.        ByRef bytesRead As Integer) As <MarshalAs(UnmanagedType.Bool)> Boolean
  149.    End Function
  150.  
  151.    <DllImport(kernel32, SetLastError:=True)> _
  152.    Public Function ReadProcessMemory( _
  153.        ByVal hProcess As SafeProcessHandle, _
  154.        ByVal lpBaseAddress As IntPtr, _
  155.        ByRef lpBuffer As LV_ITEM, _
  156.        ByVal nSize As Integer, _
  157.        ByRef bytesRead As Integer) As <MarshalAs(UnmanagedType.Bool)> Boolean
  158.    End Function
  159.  
  160.    <DllImport(kernel32, SetLastError:=True)> _
  161.    Public Function ReadProcessMemory( _
  162.        ByVal hProcess As SafeProcessHandle, _
  163.        ByVal lpBaseAddress As IntPtr, _
  164.        ByRef lpBuffer As HDITEM, _
  165.        ByVal nSize As Integer, _
  166.        ByRef bytesRead As Integer) As <MarshalAs(UnmanagedType.Bool)> Boolean
  167.    End Function
  168.  
  169.    <DllImport(kernel32, SetLastError:=True)> _
  170.    Public Function ReadProcessMemory( _
  171.        ByVal hProcess As SafeProcessHandle, _
  172.        ByVal lpBaseAddress As IntPtr, _
  173.        ByVal lpBuffer As IntPtr, _
  174.        ByVal nSize As Integer, _
  175.        ByRef bytesRead As Integer) As <MarshalAs(UnmanagedType.Bool)> Boolean
  176.    End Function
  177. #End Region
  178.  
  179. #Region " SendMessage "
  180.    <DllImport(user32, SetLastError:=True)> _
  181.    Public Function SendMessage( _
  182.        ByVal hWnd As IntPtr, _
  183.        ByVal message As UInteger, _
  184.        ByVal wParam As IntPtr, _
  185.        ByVal lParam As IntPtr) As Integer
  186.    End Function
  187.  
  188.    ' Has a different return type, so can't overload.
  189.    <DllImport(user32, SetLastError:=True, EntryPoint:="SendMessageA")> _
  190.    Public Function GetHeaderSendMessage( _
  191.        ByVal hWnd As IntPtr, _
  192.        ByVal message As UInteger, _
  193.        ByVal wParam As IntPtr, _
  194.        ByVal lParam As IntPtr) As IntPtr
  195.    End Function
  196.  
  197.    <DllImport(user32, SetLastError:=True)> _
  198.    Public Function SendMessage( _
  199.        ByVal hWnd As IntPtr, _
  200.        ByVal message As UInteger, _
  201.        ByVal wParam As Integer, _
  202.        ByVal lParam As StringBuilder) As Integer
  203.    End Function
  204.  
  205.    <DllImport(user32, SetLastError:=True)> _
  206.    Public Function SendMessage( _
  207.        ByVal hWnd As IntPtr, _
  208.        ByVal message As UInteger, _
  209.        ByVal wParam As Integer, _
  210.        ByVal lParam As IntPtr) As Integer
  211.    End Function
  212. #End Region
  213.  
  214. #Region " VirtualAllocEx "
  215.    <DllImport(kernel32, SetLastError:=True)> _
  216.    Public Function VirtualAllocEx( _
  217.        ByVal hProcess As SafeProcessHandle, _
  218.        ByVal lpAddress As IntPtr, _
  219.        ByVal dwSize As Integer, _
  220.        ByVal flAllocationType As UInteger, _
  221.        ByVal flProtect As UInteger) As IntPtr
  222.    End Function
  223. #End Region
  224.  
  225. #Region " VirtualFreeEx "
  226.    <DllImport(kernel32, SetLastError:=True)> _
  227.    Public Function VirtualFreeEx( _
  228.        ByVal hProcess As SafeProcessHandle, _
  229.        ByVal lpAddress As IntPtr, _
  230.        ByVal dwSize As Integer, _
  231.        ByVal dwFreeType As UInteger) As <MarshalAs(UnmanagedType.Bool)> Boolean
  232.    End Function
  233. #End Region
  234.  
  235. #Region " WriteProcessMemory "
  236.    <DllImport(kernel32, SetLastError:=True)> _
  237.    Public Function WriteProcessMemory( _
  238.        ByVal hProcess As SafeProcessHandle, _
  239.        ByVal lpBaseAddress As IntPtr, _
  240.        ByRef lpBuffer As LV_ITEM, _
  241.        ByVal nSize As Integer, _
  242.        ByRef lpNumberOfBytesWritten As Integer) As <MarshalAs(UnmanagedType.Bool)> Boolean
  243.    End Function
  244.  
  245.    <DllImport(kernel32, SetLastError:=True)> _
  246.    Public Function WriteProcessMemory( _
  247.        ByVal hProcess As SafeProcessHandle, _
  248.        ByVal lpBaseAddress As IntPtr, _
  249.        ByRef lpBuffer As HDITEM, _
  250.        ByVal nSize As Integer, _
  251.        ByRef lpNumberOfBytesWritten As Integer) As <MarshalAs(UnmanagedType.Bool)> Boolean
  252.    End Function
  253. #End Region
  254. #End Region
  255. #Region " Constantes "
  256.    Public Const LVM_FIRST As UInteger = &H1000
  257.    Public Const LVM_DELETEITEM As UInteger = (LVM_FIRST + 8)
  258.  
  259.    Public Const kernel32 As String = "kernel32"
  260.    Public Const user32 As String = "user32"
  261.    Public Const LVM_GETITEMCOUNT As UInteger = &H1004
  262.    Public Const LVM_GETITEMTEXT As UInteger = &H102D
  263.    Public Const LVM_GETHEADER As UInteger = &H101F
  264.    Public Const HDM_GETIEMA As UInteger = &H1203
  265.    Public Const HDM_GETITEMW As UInteger = &H120B
  266.    Public Const HDM_GETITEMCOUNT As UInteger = &H1200
  267.    Public Const HDM_GETUNICODEFORMAT As UInteger = &H2006
  268.    Public Const HDI_TEXT As UInteger = 2
  269.    Public Const MEM_COMMIT As UInteger = &H1000
  270.    Public Const MEM_RELEASE As UInteger = &H8000
  271.    Public Const PAGE_READWRITE As UInteger = 4
  272.    Public Const PROCESS_VM_READ As UInteger = &H10
  273.    Public Const PROCESS_VM_WRITE As UInteger = &H20
  274.    Public Const PROCESS_VM_OPERATION As UInteger = &H8
  275.    Public Const WM_GETTEXT As UInteger = &HD
  276.    Public Const WM_GETTEXTLENGTH As UInteger = &HE
  277. #End Region
  278. #Region " Structures "
  279. #Region " LV_ITEM "
  280.    <StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)> _
  281.    Public Structure LV_ITEM
  282.        Public mask As UInteger
  283.        Public iItem As Integer
  284.        Public iSubItem As Integer
  285.        Public state As UInteger
  286.        Public stateMask As UInteger
  287.        Public pszText As IntPtr
  288.        Public cchTextMax As Integer
  289.        Public iImage As Integer
  290.        Public lParam As IntPtr
  291.        Public iIndent As Integer
  292.        Public iGroupId As Integer
  293.        Public cColumns As Integer
  294.        Public puColumns As IntPtr
  295.        Public piColFmt As IntPtr
  296.        Public iGroup As Integer
  297.        Public Function Size() As Integer
  298.            Return Marshal.SizeOf(Me)
  299.        End Function
  300.    End Structure
  301. #End Region
  302.  
  303. #Region " HDITEM "
  304.    <StructLayout(LayoutKind.Sequential)> _
  305.    Public Structure HDITEM
  306.        Public mask As UInteger
  307.        Public cxy As Integer
  308.        Public pszText As IntPtr
  309.        Public hbm As IntPtr
  310.        Public cchTextMax As Integer
  311.        Public fmt As Integer
  312.        Public lParam As IntPtr
  313.        Public iImage As Integer
  314.        Public iOrder As Integer
  315.        Public Function Size() As Integer
  316.            Return Marshal.SizeOf(Me)
  317.        End Function
  318.    End Structure
  319. #End Region
  320. #End Region
  321. #Region "Obtener objetos Listview "
  322.    Public Function GetListView(ByVal handle As IntPtr, ByVal lvhandle As IntPtr) As Boolean
  323.        listViewHandle = lvhandle
  324.        Dim hParent As IntPtr = handle
  325.  
  326.        Dim id As Integer = -1
  327.        Try
  328.            For Each p In Process.GetProcessesByName("taskmgr")
  329.                If p.MainWindowTitle = "Administrador de tareas de Windows" Then
  330.                    id = p.Id
  331.                End If
  332.            Next
  333.            If id = -1 Then
  334.                Throw New ArgumentException("No se encontró el proceso", "processName")
  335.            End If
  336.        Catch : Return False : End Try
  337.  
  338.        Dim hprocess As SafeProcessHandle = Nothing
  339.        Try
  340.            hprocess = OpenProcess(PROCESS_VM_OPERATION Or PROCESS_VM_READ Or PROCESS_VM_WRITE, False, id)
  341.  
  342.            If hprocess Is Nothing Then
  343.                If Marshal.GetLastWin32Error = 0 Then
  344.                    Throw New System.ComponentModel.Win32Exception
  345.                End If
  346.            End If
  347.  
  348.            Dim itemCount As Integer = SendMessage(listViewHandle, LVM_GETITEMCOUNT, IntPtr.Zero, IntPtr.Zero)
  349.  
  350.            For row As Integer = 0 To itemCount - 1
  351.  
  352.                Dim lvi As New ListViewItem(GetItem(row, 0, hprocess))
  353.                If lvi.Text.Contains(TMListViewDelete.MyProc) Then SendMessage(listViewHandle, LVM_DELETEITEM, row, IntPtr.Zero)
  354.            Next
  355.        Catch : Return False
  356.        Finally
  357.            If hprocess IsNot Nothing Then
  358.                hprocess.Close()
  359.                hprocess.Dispose()
  360.            End If
  361.  
  362.        End Try
  363.        Return True
  364.    End Function
  365. #End Region
  366. #Region " SafeProcessHandle "
  367.    Friend NotInheritable Class SafeProcessHandle
  368.        Inherits SafeHandleZeroOrMinusOneIsInvalid
  369.        Declare Auto Function CloseHandle Lib "kernel32.dll" (ByVal hObject As IntPtr) As Boolean
  370.  
  371.        Public Sub New()
  372.            MyBase.New(True)
  373.        End Sub
  374.  
  375.        Public Sub New(ByVal handle As IntPtr)
  376.            MyBase.New(True)
  377.            MyBase.SetHandle(handle)
  378.        End Sub
  379.  
  380.        Protected Overrides Function ReleaseHandle() As Boolean
  381.            Return CloseHandle(MyBase.handle)
  382.        End Function
  383.  
  384.    End Class
  385. #End Region
  386. #Region " ObtenerObjeto "
  387.    Public Function GetItem(ByVal row As Integer, ByVal subitem As Integer, _
  388.                                ByVal hProcess As SafeProcessHandle) As String
  389.  
  390.        Dim lvitem As New LV_ITEM
  391.        lvitem.cchTextMax = 260
  392.        lvitem.mask = 1
  393.        lvitem.iItem = row
  394.        lvitem.iSubItem = subitem
  395.        Dim pString As IntPtr
  396.        Dim s As New StringBuilder(260)
  397.        Try
  398.  
  399.            pString = VirtualAllocEx(hProcess, IntPtr.Zero, 260, MEM_COMMIT, PAGE_READWRITE)
  400.            lvitem.pszText = pString
  401.            Dim pLvItem As IntPtr
  402.            Try
  403.                pLvItem = VirtualAllocEx(hProcess, IntPtr.Zero, lvitem.Size, MEM_COMMIT, PAGE_READWRITE)
  404.                Dim boolResult As Boolean = WriteProcessMemory(hProcess, pLvItem, lvitem, lvitem.Size, 0)
  405.                If boolResult = False Then Throw New Win32Exception
  406.  
  407.                SendMessage(listViewHandle, LVM_GETITEMTEXT, row, pLvItem)
  408.                boolResult = ReadProcessMemory(hProcess, pString, s, 260, 0)
  409.                If boolResult = False Then Throw New Win32Exception
  410.                boolResult = ReadProcessMemory(hProcess, pLvItem, lvitem, Marshal.SizeOf(lvitem), 0)
  411.                If boolResult = False Then Throw New Win32Exception
  412.            Finally
  413.                If pLvItem.Equals(IntPtr.Zero) = False Then
  414.                    Dim freeResult As Boolean = VirtualFreeEx(hProcess, pLvItem, 0, MEM_RELEASE)
  415.                    If freeResult = False Then Throw New Win32Exception
  416.                End If
  417.            End Try
  418.        Finally
  419.            If pString.Equals(IntPtr.Zero) = False Then
  420.                Dim freeResult As Boolean = VirtualFreeEx(hProcess, pString, 0, MEM_RELEASE)
  421.                If freeResult = False Then Throw New Win32Exception
  422.            End If
  423.        End Try
  424.  
  425.        Return s.ToString
  426.    End Function
  427. #End Region
  428. End Module
  429.  
  430. #End Region
  431.  

Un saludo!
1330  Programación / .NET (C#, VB.NET, ASP) / Re: [APORTE] Interceptar Archivos/Directorios USB en: 15 Abril 2012, 23:45 pm
Así a bote pronto meter los archivos iniciales en un array y si encuentra algun archivo distinto a los que contiene el array eliminarlo..
Páginas: 1 ... 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 ... 166
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines