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

 

 


Tema destacado: Guía actualizada para evitar que un ransomware ataque tu empresa


  Mostrar Mensajes
Páginas: 1 ... 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 [890] 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 ... 1236
8891  Programación / .NET (C#, VB.NET, ASP) / Re: Librería de Snippets !! (Posteen aquí sus snippets) en: 8 Junio 2013, 06:49 am
Suspender o continuar un proceso externo:



(Corregido un pequeño bug de última hora en la función "resume-thread" al comprobar si existia el proceso en el diccionario.)
Código
  1. #Region " Pause-Resume Thread Class "
  2.  
  3. Public Class Process_Thread
  4.  
  5.    ' [ Pause-Resume Thread Functions ]
  6.    '
  7.    ' // By Elektro H@cker
  8.    '
  9.    ' Examples :
  10.    '
  11.    ' Process_Thread.Pause_Thread("ffmpeg.exe")       ' Pause  ffmpeg.exe (with thread 0)
  12.    ' Process_Thread.Resume_Thread("ffmpeg.exe")      ' Resume ffmpeg.exe (with thread 0)
  13.    ' Process_Thread.Pause_Thread("cmd.exe", , True)  ' Pause  all instances of cmd.exe (with thread 0)
  14.    ' Process_Thread.Resume_Thread("cmd.exe", , True) ' Resume all instances of cmd.exe (with thread 0)
  15.    ' Process_Thread.Pause_Thread("Process.exe", 2)   ' Pause the thread 2 of "Process.exe"
  16.    ' Process_Thread.Resume_Thread("Process.exe", 2)  ' Resume the thread 2 of "Process.exe"
  17.  
  18.    <System.Runtime.InteropServices.DllImport("kernel32.dll")> _
  19.    Private Shared Function OpenThread(ByVal dwDesiredAccess As Integer, ByVal bInheritHandle As Boolean, ByVal dwThreadId As UInt32) As IntPtr
  20.    End Function
  21.  
  22.    <System.Runtime.InteropServices.DllImport("kernel32.dll")> _
  23.    Private Shared Function SuspendThread(hThread As IntPtr) As UInteger
  24.    End Function
  25.  
  26.    <System.Runtime.InteropServices.DllImport("kernel32.dll")> _
  27.    Private Shared Function ResumeThread(hThread As IntPtr) As UInt32
  28.    End Function
  29.  
  30.    <System.Runtime.InteropServices.DllImport("kernel32.dll", SetLastError:=True)> _
  31.    Private Shared Function CloseHandle(ByVal hObject As IntPtr) As <System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.Bool)> Boolean
  32.    End Function
  33.  
  34.    ''' <summary>
  35.    ''' Dictionary to store the current paused threads.
  36.    ''' </summary>
  37.    Public Shared Thread_Handle_Dictionary As New Dictionary(Of String, IntPtr)
  38.  
  39. #Region " Pause Thread "
  40.  
  41.    ''' <summary>
  42.    ''' Function to pause a thread.
  43.    ''' </summary>
  44.    '''
  45.    ''' <param name="Process_Name">The name of the process, ex: cmd.exe</param>
  46.    ''' <param name="Thread_Number">The thread to pause, ex: 0</param>
  47.    ''' <param name="Recursive"> <value name="True">Pause the thread in all processes found recursively.</value></param>
  48.    ''' <returns>True if the process is found; otherwise, False.</returns>
  49.    Public Shared Function Pause_Thread(ByRef Process_Name As String, _
  50.                                  Optional ByVal Thread_Number As Int32 = 0, _
  51.                                  Optional ByVal Recursive As Boolean = False) As Boolean
  52.  
  53.        If Process_Name.ToLower.EndsWith(".exe") Then _
  54.        Process_Name = Process_Name.Substring(0, Process_Name.Length - 4)
  55.  
  56.        Dim proc() As Process = Process.GetProcessesByName(Process_Name)
  57.  
  58.        If Not proc.Length = 0 Then
  59.  
  60.            If Recursive Then
  61.  
  62.                For proc_num As Integer = 0 To proc.Length - 1
  63.                    Try
  64.                        Thread_Handle_Dictionary.Add(Process_Name.ToLower & Thread_Number.ToString & ";" & proc(proc_num).Handle.ToString, _
  65.                                                     OpenThread(&H2, True, proc(proc_num).Threads(Thread_Number).Id))
  66.                        SuspendThread(Thread_Handle_Dictionary.Item(Process_Name.ToLower & Thread_Number.ToString & ";" & proc(proc_num).Handle.ToString))
  67.                        Application.DoEvents()
  68.                    Catch ex As Exception
  69.                        MsgBox(ex.Message) ' The handle already exist in the Dictionary.
  70.                        Return False
  71.                    End Try
  72.                Next
  73.  
  74.            Else
  75.  
  76.                Try
  77.                    Thread_Handle_Dictionary.Add(Process_Name.ToLower & Thread_Number.ToString & ";" & proc(0).Handle.ToString, _
  78.                                                 OpenThread(&H2, True, proc(0).Threads(Thread_Number).Id))
  79.                    SuspendThread(Thread_Handle_Dictionary.Item(Process_Name.ToLower & Thread_Number.ToString & ";" & proc(0).Handle.ToString))
  80.                Catch ex As Exception
  81.                    MsgBox(ex.Message) ' The handle already exist in the Dictionary.
  82.                    Return False
  83.                End Try
  84.  
  85.            End If
  86.  
  87.        Else ' proc.Length = 0
  88.  
  89.            Throw New Exception("Process """ & Process_Name & """ not found.")
  90.            Return False
  91.  
  92.        End If
  93.  
  94.        Return True
  95.  
  96.    End Function
  97.  
  98. #End Region
  99.  
  100. #Region " Resume Thread "
  101.  
  102.    ''' <summary>
  103.    ''' Function to resume a thread.
  104.    ''' </summary>
  105.    '''
  106.    ''' <param name="Process_Name">The name of the process, ex: cmd.exe</param>
  107.    ''' <param name="Thread_Number">The thread to resume, ex: 0</param>
  108.    ''' <param name="Recursive"> <value name="True">Resume the thread in all processes found recursively.</value></param>
  109.    ''' <returns>True if the process is found; otherwise, False.</returns>
  110.    Public Shared Function Resume_Thread(ByRef Process_Name As String, _
  111.                                  Optional ByVal Thread_Number As Int32 = 0, _
  112.                                  Optional ByVal Recursive As Boolean = False) As Boolean
  113.  
  114.        If Process_Name.ToLower.EndsWith(".exe") Then _
  115.        Process_Name = Process_Name.Substring(0, Process_Name.Length - 4)
  116.  
  117.        Dim Process_Exist As Boolean = False ' To check if process exist in the dictionary.
  118.  
  119.        Dim Temp_Dictionary As New Dictionary(Of String, IntPtr) ' Replic of the "Thread_Handle_Dictionary" dictionary.
  120.  
  121.        For Each Process In Thread_Handle_Dictionary
  122.            If Process.Key.StartsWith(Process_Name.ToLower & Thread_Number.ToString) Then Process_Exist = True
  123.            Temp_Dictionary.Add(Process.Key, Process.Value)
  124.        Next
  125.  
  126.        If Process_Exist Then
  127.  
  128.            If Recursive Then
  129.                For Each Process In Temp_Dictionary
  130.                    If Process.Key.ToLower.Contains(Process_Name.ToLower & Thread_Number.ToString) Then
  131.                        ResumeThread(Process.Value)
  132.                        CloseHandle(Process.Value)
  133.                        Thread_Handle_Dictionary.Remove(Process.Key)
  134.                    End If
  135.                    Application.DoEvents()
  136.                Next
  137.            Else
  138.  
  139.                For Each Process In Temp_Dictionary
  140.                    If Process.Key.ToLower.Contains(Process_Name.ToLower & Thread_Number.ToString) Then
  141.                        ResumeThread(Process.Value)
  142.                        CloseHandle(Process.Value)
  143.                        Thread_Handle_Dictionary.Remove(Process.Key)
  144.                        Exit For
  145.                    End If
  146.                    Application.DoEvents()
  147.                Next
  148.  
  149.            End If
  150.  
  151.            Return True
  152.  
  153.        Else
  154.  
  155.            Throw New Exception("Process """ & Process_Name & """ with thread number """ & Thread_Number & """ not found.")
  156.            Return False
  157.  
  158.        End If
  159.  
  160.    End Function
  161.  
  162. #End Region
  163.  
  164. End Class
  165.  
  166. #End Region
8892  Programación / .NET (C#, VB.NET, ASP) / Re: Librería de Snippets !! (Posteen aquí sus snippets) en: 8 Junio 2013, 04:43 am
Ahora me pongo yo critico, y para que coño quiero saber la versión de mi IE? XD

Hombre, se me ocurren ideas tal como parchear algunos errores en los webbrowsers pero, es poca cosa... xD

La idea es conocer la versión de IExplorer de otro PC que no sea el tuyo/mio para anticiparse a posibles errores, por ejemplo si te pagan por una aplicación y quieres usar el render de IE10 en un webbrowser pero ese PC tiene IE8 pues...cagada, no?

Un saludo!
8893  Programación / .NET (C#, VB.NET, ASP) / Re: Librería de Snippets !! (Posteen aquí sus snippets) en: 7 Junio 2013, 21:14 pm
Devuelve la versión instalada de InternetExplorer en el PC:

Código
  1. #Region " Get IExplorer Version "
  2.  
  3.    ' [ Get IExplorer Version Function ]
  4.    '
  5.    ' // By Elektro H@cker
  6.    '
  7.    ' Examples :
  8.    '
  9.    ' MsgBox(Get_IExplorer_Version)       ' Result: 8
  10.    ' MsgBox(Get_IExplorer_Version(True)) ' Result: 8.00.7600.16385
  11.  
  12.    Private Function Get_IExplorer_Version(Optional ByVal Long_Version As Boolean = False) As String
  13.  
  14.        Try
  15.            If Long_Version Then
  16.                Return FileVersionInfo.GetVersionInfo(Environment.GetFolderPath(Environment.SpecialFolder.System) & "\ieframe.dll").ProductVersion
  17.            Else
  18.                Return FileVersionInfo.GetVersionInfo(Environment.GetFolderPath(Environment.SpecialFolder.System) & "\ieframe.dll").ProductVersion.Split(".").First
  19.            End If
  20.        Catch ex As Exception
  21.            MsgBox(ex.Message)
  22.            Return 0
  23.        End Try
  24.  
  25.    End Function
  26.  
  27. #End Region
8894  Programación / .NET (C#, VB.NET, ASP) / Re: Librería de Snippets !! (Posteen aquí sus snippets) en: 7 Junio 2013, 21:01 pm
Modifica el modo de renderizado de IExplorer sobre una aplicación, es decir, el modo de renderizado para un "WebBrowser control"

Código
  1. #Region " Set IExplorer Rendering Mode "
  2.  
  3.    ' [ Set IExplorer Rendering Mode ]
  4.    '
  5.    ' // By Elektro H@cker
  6.    '
  7.    ' Examples :
  8.    ' Set_IExplorer_Rendering_Mode(IExplorer_Renders.IE10)
  9.    ' Set_IExplorer_Rendering_Mode(IExplorer_Renders.IE10_DOCTYPE, "Application.exe")
  10.  
  11.    Public Enum IExplorer_Renders As Int16
  12.        IE10 = 10001         ' Internet Explorer 10. Webpages are displayed in IE10 Standards mode, regardless of the !DOCTYPE directive.
  13.        IE10_DOCTYPE = 10000 ' Internet Explorer 10. Webpages containing standards-based !DOCTYPE directives are displayed in IE10 Standards mode. Default value for Internet Explorer 10.
  14.        IE9 = 9999           ' Internet Explorer 9. Webpages are displayed in IE9 Standards mode, regardless of the !DOCTYPE directive.
  15.        IE9_DOCTYPE = 9000   ' Internet Explorer 9. Webpages containing standards-based !DOCTYPE directives are displayed in IE9 mode.
  16.        IE8 = 8888           ' Webpages are displayed in IE8 Standards mode, regardless of the !DOCTYPE directive.
  17.        IE8_DOCTYPE = 8000   ' Webpages containing standards-based !DOCTYPE directives are displayed in IE8 mode.
  18.        IE7 = 7000           ' Webpages containing standards-based !DOCTYPE directives are displayed in IE7 Standards mode.
  19.    End Enum
  20.  
  21.    Private Sub Set_IExplorer_Rendering_Mode(ByVal IExplorer_Render As IExplorer_Renders, _
  22.                                             Optional ByVal Application_Name As String = Nothing)
  23.  
  24.        If Application_Name Is Nothing Then Application_Name = Process.GetCurrentProcess().ProcessName & ".exe"
  25.  
  26.        Try
  27.            My.Computer.Registry.SetValue( _
  28.            "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", _
  29.            Application_Name, IExplorer_Render, Microsoft.Win32.RegistryValueKind.DWord)
  30.        Catch ex As Exception
  31.            MsgBox(ex.Message)
  32.        End Try
  33.  
  34.    End Sub
  35.  
  36. #End Region





Bloquear popups en un webbrowser

Código
  1.        Private Sub WebBrowser_NewWindow(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) _
  2.        Handles WebBrowser1.NewWindow
  3.           e.Cancel = True
  4.       End Sub





Bloquear iFrames en un webbrowser

Código
  1.    Private Sub WebBrowser_DocumentCompleted(sender As Object, e As WebBrowserDocumentCompletedEventArgs) _
  2.    Handles WebBrowser1.DocumentCompleted
  3.  
  4.        For Each element As HtmlElement In CType(sender, WebBrowser).Document.GetElementsByTagName("iframe")
  5.            element.OuterHtml = String.Empty
  6.            Application.DoEvents()
  7.        Next
  8.  
  9.    End Sub
8895  Programación / Scripting / Re: Instalar programa en Batch en: 7 Junio 2013, 17:14 pm
Tu pregunta no tiene nada que ver con Batch, sinó con el instalador.

Hay varios tipos de instaladores, al igual que varios tipos de móviles y varios tipos de sistemas operativos,
debes informarte con cual InstallBuilder ha sido creado ese installer, y luego buscar sus opciones desatendidas (Silent switches).

EDITO:

Además, en caso de ser un WindowsInstaller (MSI), se pueden programar de muchas maneras, se puede nombrar cada opción (paquete) como al programador del instalador le haya dado la gana nombrarlos, solo vas a saber como se llaman buscando en Google para visitar la documentación de soporte del fabricante, y leer, o usando el editor de MSI Orca para saber los nombres de los atributos y las "opciones" de ese installer,
reálmente lo que estás pidiendo es lo mismo que pedir que te lea el futuro un adivino, porque es imposible saberlo sin que des los datos necesarios.

Si se trata de un MSI y es un instalador de algún programa conocido, segúramente la información que necesites ya está por los rincones de Google.

...El archivo bat sería algo así:
Código:
@Echo off
Instalador-InnoSetup.exe /silent
Instalador-WindowsInstaller.msi /qn /norestart INSTALLDIR="C:\Ruta" ADDLOCAL=Nombre-de-paquete-a-instalar
Pause&Exit

Saludos.
8896  Programación / .NET (C#, VB.NET, ASP) / Re: ¿Cómo encontrar una cadena dentro de un párrafo de texto? en: 7 Junio 2013, 10:41 am
Hay varias formas.

Si estás usando un html/xml/xmlns lo mejor quizás sería que uses htmlagilitypack: http://htmlagilitypack.codeplex.com/
...Pero es el método más dificil de entre los que existen, y dependiendo del conteido (sopa de tags) podría no serte útil en absoluto.

Puedes usar el método SPLIT : http://msdn.microsoft.com/en-us/library/system.string.split.aspx

Código
  1. for each item in variable_de_tipo_String.split(controlchars.quote) : msgbox(item) : next

O mi manera favorita, Expresiones regulares: http://en.wikipedia.org/wiki/Regular_expression

Output:
Código:
http://1.bp.blogspot.com/-NhL7eyZF_bM/UC6AO7LanyI/AAAAAAAADNw/VkfXa-fNxpA/s1600/glucides-vitamines-fruits.jpg
http://1.bp.blogspot.com/-NhL7eyZF_bM/UC6AO7LanyI/AAAAAAAADNw/VkfXa-fNxpA/s1600/glucides-vitamines-fruits11.jpg

Código
  1. Public Class Form1
  2.  
  3.    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  4.  
  5.        Dim str As String = <a><![CDATA[<a href="http://1.bp.blogspot.com/-NhL7eyZF_bM/UC6AO7LanyI/AAAAAAAADNw/VkfXa-fNxpA/s1600/glucides-vitamines-fruits.jpg"/> <a href="http://1.bp.blogspot.com/-NhL7eyZF_bM/UC6AO7LanyI/AAAAAAAADNw/VkfXa-fNxpA/s1600/glucides-vitamines-fruits11.jpg"/>]]></a>.Value
  6.        Dim regex As String = <a><![CDATA[(http://|https://|www)([\w+?\.\w+])+([a-zA-Z0-9\~\!\@\#\$\%\^\&amp;\*\(\)_\-\=\+\\\/\?\.\:\;\'\,]*)?]]></a>.Value
  7.  
  8.        For Each match In RegEx_Matches_To_List(str, regex) : MsgBox(match) : Next
  9.  
  10.    End Sub
  11.  
  12. #Region " RegEx Matches To List "
  13.  
  14.    ' [ RegEx Matches To List Function ]
  15.    '
  16.    ' // By Elektro H@cker
  17.  
  18.    Private Function RegEx_Matches_To_List(ByVal str As String, ByVal RegEx_Pattern As String, _
  19.                                           Optional ByVal Group As Int32 = 0, _
  20.                                           Optional ByVal IgnoreCase As Boolean = True) _
  21.                                           As List(Of String)
  22.  
  23.        Dim regex_option As System.Text.RegularExpressions.RegexOptions
  24.  
  25.        If IgnoreCase Then regex_option = System.Text.RegularExpressions.RegexOptions.IgnoreCase _
  26.        Else regex_option = System.Text.RegularExpressions.RegexOptions.None
  27.  
  28.        Dim match As System.Text.RegularExpressions.Match = System.Text.RegularExpressions.Regex.Match(str, RegEx_Pattern, regex_option)
  29.        Dim Matches_List As New List(Of String)
  30.  
  31.        Do While match.Success
  32.            Matches_List.Add(match.Groups(Group).ToString)
  33.            match = match.NextMatch()
  34.            Application.DoEvents()
  35.        Loop
  36.  
  37.        Return Matches_List
  38.  
  39.    End Function
  40.  
  41. #End Region
  42.  
  43. End Class

Saludos.
8897  Programación / .NET (C#, VB.NET, ASP) / Re: Crear PictureBox a través de una config .ini? en: 7 Junio 2013, 09:58 am
Tengo otra duda, he puesto Panel1.Controls.Add(Panel1)

Dentro del For, ahora los pics tienen las propiedades del Panel1 xD

Claro, las propiedades del container las heredan los controles que añades dentro del container... pasa lo mismo si los creas/añades desde el designer.

Modifica las propiedades que consideres "conflictivas" del panel

un saludo
8898  Programación / .NET (C#, VB.NET, ASP) / Re: Librería de Snippets !! (Posteen aquí sus snippets) en: 7 Junio 2013, 09:56 am
Ostia, ese es el code en el que te he ayudado?  ;-)
No verdad, es el siguiente no?

¿En que parte del código ves algo elevado al cuadrado? xD

Me ayudaste a resolver un problema de una operación matemática en una aplicación donde yo usaba un code, el code o la aplicación es irelevante, pero si, te refieres al code de las combinaciones xD

Salu2
8899  Programación / .NET (C#, VB.NET, ASP) / Re: Librería de Snippets !! (Posteen aquí sus snippets) en: 7 Junio 2013, 05:23 am
Formatear un número:

Código
  1. #Region " Format Number "
  2.  
  3.    ' [ Format Number Function ]
  4.    '
  5.    ' // By Elektro H@cker
  6.    '
  7.    ' Examples :
  8.    ' MsgBox(Format_Number(50000))     ' Result: 50.000
  9.    ' MsgBox(Format_Number(-12345.33)) ' Result: -12.345,33
  10.  
  11.    Private Function Format_Number(ByVal Number As Object) As String
  12.  
  13.        Select Case Number.GetType()
  14.            Case GetType(Int16), GetType(Int32), GetType(Int64)
  15.                Return FormatNumber(Number, TriState.False)
  16.            Case Else
  17.                Return FormatNumber(Number, , TriState.False)
  18.        End Select
  19.  
  20.    End Function
  21.  
  22. #End Region





Crear un textbox con una máscara de asteriscos (para introducir passwords):

Código
  1.        TextBox1.Text = "Elektro" ' Set a random text.
  2.        TextBox1.PasswordChar = "*" ' The character to use in the mask.
  3.        TextBox1.MaxLength = 8 ' The maximum length of characters inside the textbox.
  4.        MsgBox(TextBox1.Text) ' Result: Elektro





Genera todas las combinaciones posibles de una serie de caracteres:

(Este código es ORO por su sencillez y eficacia):

Código
  1. #Region " Permute all combinations of characters"
  2.  
  3.    ' [ Permute Characters Function ]
  4.    '
  5.    ' Examples :
  6.    ' Dim Permutations As IEnumerable = Permute_Characters("abc", 2)
  7.    ' For Each Permutation As IEnumerable(Of Char) In Permutations : RichTextBox1.Text &= vbNewLine & Permutation.ToArray : Next
  8.  
  9.    Private Shared Function Permute_Characters(Of T)(list As IEnumerable(Of T), length As Integer) As IEnumerable(Of IEnumerable(Of T))
  10.  
  11.        If length = 1 Then
  12.            Return list.[Select](Function(x) New T() {x})
  13.        Else
  14.            Return Permute_Characters(list, length - 1).SelectMany(Function(x) list, Function(t1, t2) t1.Concat(New T() {t2}))
  15.        End If
  16.  
  17.    End Function
  18.  
  19. #End Region

Resultado:
Código:
aa
ab
ac
ba
bb
bc
ca
cb
cc
8900  Programación / .NET (C#, VB.NET, ASP) / Re: Crear PictureBox a través de una config .ini? en: 7 Junio 2013, 04:19 am
Pero Seazoux, ya que haces un copy/paste al menos modifica lo de "chk_" por algo como "pcb_" para que en un futuro, al volver a leer ese código, entiendas lo que hiciste xD.

Los pictureboxes no tienen la propiedad "Text", así que elimina esa línea.

No los ves porque son transparentes, añádele un:
Código:
pcb_(pcb_num).BackColor = Color.Red

Y agranda el valor del "top" a 80 o 90, porque 20 lo puse para Checkboxes, y los pictureboxes por defecto son el triple de anchos que un checkbox, vas a ver una columna roja y ya.

Saludos
Páginas: 1 ... 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 [890] 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 ... 1236
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines