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

 

 


Tema destacado: (TUTORIAL) Aprende a emular Sentinel Dongle By Yapis


  Mostrar Mensajes
Páginas: 1 ... 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 [925] 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 ... 1236
9241  Programación / .NET (C#, VB.NET, ASP) / Re: Librería de Snippets !! (Posteen aquí sus snippets) en: 13 Abril 2013, 17:29 pm
· Devuelve la resolución de la pantalla primária o de la pantalla extendida

Código
  1. #Region " Get Screen Resolution "
  2.  
  3.    ' [ Get Screen Resolution Function ]
  4.    '
  5.    ' // By Elektro H@cker
  6.    '
  7.    ' Examples :
  8.    ' MsgBox(Get_Screen_Resolution(False).ToString)
  9.    ' MsgBox(Get_Screen_Resolution(True).ToString)
  10.    ' Me.Size = Get_Screen_Resolution()
  11.  
  12.    Private Function Get_Screen_Resolution(ByVal Get_Extended_Screen_Resolution As Boolean) As Point
  13.  
  14.        If Not Get_Extended_Screen_Resolution Then
  15.            Return New Point(My.Computer.Screen.Bounds.Width, My.Computer.Screen.Bounds.Height)
  16.        Else
  17.            Dim X As Integer, Y As Integer
  18.  
  19.            For Each screen As Screen In screen.AllScreens
  20.                X += screen.Bounds.Width
  21.                Y += screen.Bounds.Height
  22.            Next
  23.  
  24.            Return New Point(X, Y)
  25.        End If
  26.  
  27.    End Function
  28.  
  29. #End Region
9242  Programación / .NET (C#, VB.NET, ASP) / Re: Librería de Snippets !! (Posteen aquí sus snippets) en: 13 Abril 2013, 15:50 pm
· Convierte entero a caracter

Código
  1. #Region " Byte To Char "
  2.  
  3.    ' [ Byte To Char Function ]
  4.    '
  5.    ' // By Elektro H@cker
  6.    '
  7.    ' Examples :
  8.    ' MsgBox(Byte_To_Char(97)) ' Result: a
  9.  
  10.    Private Function Byte_To_Char(ByVal int As Int32) As String
  11.        Return Convert.ToChar(int)
  12.    End Function
  13.  
  14. #End Region



· Convierte caracter a entero

Código
  1. #Region " Char To Byte "
  2.  
  3.    ' [ Char To Byte Function ]
  4.    '
  5.    ' // By Elektro H@cker
  6.    '
  7.    ' Examples :
  8.    ' MsgBox(Char_To_Byte("a")) ' Result: 97
  9.    ' Dim MyChar As String = "a" : MsgBox(Chr(Char_To_Byte(MyChar))) ' Result: a    ( ...xD )
  10.  
  11.    Private Function Char_To_Byte(ByVal str As String) As Int32
  12.        Dim character As Char = str & "c"
  13.        Return Convert.ToByte(character)
  14.    End Function
  15.  
  16. #End Region



· Obtiene el SHA1 de un string

Código
  1. #Region " Get SHA1 Of String "
  2.  
  3.    ' [ Get SHA1 Of String Function ]
  4.    '
  5.    ' Examples :
  6.    ' MsgBox(Get_SHA1_Of_String("Hello")) ' Result: D2EFCBBA102ED3339947E85F4141EB08926E40E9
  7.  
  8.    Private Function Get_SHA1_Of_String(ByVal str As String) As String
  9.        'create our SHA1 provider
  10.        Dim sha As System.Security.Cryptography.SHA1 = New System.Security.Cryptography.SHA1CryptoServiceProvider()
  11.        Dim hashedValue As String = String.Empty
  12.        'hash the data
  13.        Dim hashedData As Byte() = sha.ComputeHash(System.Text.Encoding.Unicode.GetBytes(str))
  14.  
  15.        'loop through each byte in the byte array
  16.        For Each b As Byte In hashedData
  17.            'convert each byte and append
  18.            hashedValue += String.Format("{0,2:X2}", b)
  19.        Next
  20.  
  21.        'return the hashed value
  22.        Return hashedValue
  23.    End Function
  24.  
  25. #End Region



· Obtiene el SHA1 de un archivo

Código
  1. #Region " Get SHA1 Of File "
  2.  
  3.    ' [ Get SHA1 Of File Function ]
  4.    '
  5.    ' Examples :
  6.    ' MsgBox(Get_SHA1_Of_File("C:\File.txt"))
  7.  
  8.    Private Function Get_SHA1_Of_File(ByVal File As String) As String
  9.        Dim File_Stream As New System.IO.FileStream(File, IO.FileMode.Open)
  10.        Dim sha As New System.Security.Cryptography.SHA1CryptoServiceProvider
  11.        Dim hash As Array
  12.        Dim shaHash As String
  13.        Dim sb As New System.Text.StringBuilder
  14.  
  15.        sha.ComputeHash(File_Stream)
  16.        hash = sha.Hash
  17.        For Each hashByte As Byte In hash : sb.Append(String.Format("{0:X1}", hashByte)) : Next
  18.        shaHash = sb.ToString
  19.        File_Stream.Close()
  20.  
  21.        Return shaHash
  22.    End Function
  23.  
  24. #End Region



· cifra un string en AES

Código
  1. #Region " AES Encrypt "
  2.  
  3.    ' [ AES Encrypt Function ]
  4.    '
  5.    ' Examples :
  6.    ' MsgBox(AES_Encrypt("Test_Text", "Test_Password")) ' Result: cv/vYwpl51/dxbxSMNSPSg==
  7.  
  8.    Public Function AES_Encrypt(ByVal input As String, ByVal pass As String) As String
  9.        Dim AES As New System.Security.Cryptography.RijndaelManaged
  10.        Dim Hash_AES As New System.Security.Cryptography.MD5CryptoServiceProvider
  11.        Dim encrypted As String = ""
  12.        Try
  13.            Dim hash(31) As Byte
  14.            Dim temp As Byte() = Hash_AES.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(pass))
  15.            Array.Copy(temp, 0, hash, 0, 16)
  16.            Array.Copy(temp, 0, hash, 15, 16)
  17.            AES.Key = hash
  18.            AES.Mode = Security.Cryptography.CipherMode.ECB
  19.            Dim DESEncrypter As System.Security.Cryptography.ICryptoTransform = AES.CreateEncryptor
  20.            Dim Buffer As Byte() = System.Text.ASCIIEncoding.ASCII.GetBytes(input)
  21.            encrypted = Convert.ToBase64String(DESEncrypter.TransformFinalBlock(Buffer, 0, Buffer.Length))
  22.            Return encrypted
  23.        Catch ex As Exception
  24.            Return Nothing
  25.        End Try
  26.    End Function
  27.  
  28. #End Region



· descifra un string AES

Código
  1. #Region " AES Decrypt "
  2.  
  3.    ' [ AES Decrypt Function ]
  4.    '
  5.    ' Examples :
  6.    ' MsgBox(AES_Decrypt("cv/vYwpl51/dxbxSMNSPSg==", "Test_Password")) ' Result: Test_Text
  7.  
  8.    Public Function AES_Decrypt(ByVal input As String, ByVal pass As String) As String
  9.        Dim AES As New System.Security.Cryptography.RijndaelManaged
  10.        Dim Hash_AES As New System.Security.Cryptography.MD5CryptoServiceProvider
  11.        Dim decrypted As String = ""
  12.        Try
  13.            Dim hash(31) As Byte
  14.            Dim temp As Byte() = Hash_AES.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(pass))
  15.            Array.Copy(temp, 0, hash, 0, 16)
  16.            Array.Copy(temp, 0, hash, 15, 16)
  17.            AES.Key = hash
  18.            AES.Mode = Security.Cryptography.CipherMode.ECB
  19.            Dim DESDecrypter As System.Security.Cryptography.ICryptoTransform = AES.CreateDecryptor
  20.            Dim Buffer As Byte() = Convert.FromBase64String(input)
  21.            decrypted = System.Text.ASCIIEncoding.ASCII.GetString(DESDecrypter.TransformFinalBlock(Buffer, 0, Buffer.Length))
  22.            Return decrypted
  23.        Catch ex As Exception
  24.            Return Nothing
  25.        End Try
  26.    End Function
  27.  
  28. #End Region



· Devuelve el código fuente de una URL

Código
  1. #Region " Get URL SourceCode "
  2.  
  3.    ' [ Get URL SourceCode Function ]
  4.    '
  5.    ' Examples :
  6.    ' MsgBox(Get_URL_SourceCode("http://www.el-hacker.com"))
  7.  
  8.    Function Get_URL_SourceCode(ByVal url As String) As String
  9.  
  10.        Dim sourcecode As String = String.Empty
  11.  
  12.        Try
  13.            Dim request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create(url)
  14.            Dim response As System.Net.HttpWebResponse = request.GetResponse()
  15.            Dim sr As System.IO.StreamReader = New System.IO.StreamReader(response.GetResponseStream())
  16.            sourcecode = sr.ReadToEnd()
  17.        Catch ex As Exception
  18.            MsgBox(ex.Message)
  19.        End Try
  20.  
  21.        Return sourcecode
  22.  
  23.    End Function
  24.  
  25. #End Region



· Intercambia entre el modo pantalla completa o modo normal.

Código
  1. #Region " Toogle FullScreen "
  2.  
  3.    ' [ Toogle FullScreen ]
  4.    '
  5.    ' // By Elektro H@cker
  6.    '
  7.    ' Examples :
  8.    ' Toogle_FullScreen()
  9.  
  10.    Dim MyFormBorderStyle = Me.FormBorderStyle
  11.    Dim MyWindowState = Me.WindowState
  12.    Dim MyTopMost = Me.TopMost
  13.    Dim IsFullscreened As Boolean
  14.  
  15.    Public Sub Toogle_FullScreen()
  16.        If Not IsFullscreened Then
  17.            IsFullscreened = True
  18.            Me.FormBorderStyle = FormBorderStyle.None
  19.            Me.WindowState = FormWindowState.Maximized
  20.            Me.TopMost = True
  21.        ElseIf IsFullscreened Then
  22.            IsFullscreened = False
  23.            Me.FormBorderStyle = MyFormBorderStyle
  24.            Me.WindowState = MyWindowState
  25.            Me.TopMost = MyTopMost
  26.        End If
  27.    End Sub
  28.  
  29. #End Region



· Devuelve la versión del Framework con el que se ha desarrollado una applicación (o DLL).

Código
  1. #Region " Get FrameWork Of File "
  2.  
  3.    ' [ Get FrameWork Of File Function ]
  4.    '
  5.    ' Examples :
  6.    ' MsgBox(Get_FrameWork_Of_File("C:\My .Net Application.exe"))
  7.  
  8.    Private Function Get_FrameWork_Of_File(ByVal File As String) As String
  9.        Try
  10.            Dim FW As System.Reflection.Assembly = Reflection.Assembly.ReflectionOnlyLoadFrom(File)
  11.            Return FW.ImageRuntimeVersion
  12.        Catch ex As Exception
  13.            Return Nothing ' Is not managed code
  14.        End Try
  15.    End Function
  16.  
  17. #End Region



· Devuelve positivo si el número es primo

Código
  1. #Region " Number Is Prime? "
  2.  
  3.    ' [ Number Is Prime? Function ]
  4.    '
  5.    ' Examples :
  6.    ' MsgBox(Number_Is_Prime(4)) ' Result: False
  7.  
  8.    Private Function Number_Is_Prime(ByVal Number As Long, Optional ByVal f As Integer = 2) As Boolean
  9.        If Number = f Then Return True
  10.        If Number Mod f = 0 Or Number = 1 Then Return False _
  11.        Else Return Number_Is_Prime(Number, f + 1)
  12.    End Function
  13.  
  14. #End Region



· Valida si un string se puede usar como nombre de archivo en Windows

Código
  1. #Region " Validate Windows FileName "
  2.  
  3.    ' [ Validate Windows FileName Function ]
  4.    '
  5.    ' Examples :
  6.    ' MsgBox(Validate_Windows_FileName("C:\Test.txt")) ' Result: True
  7.    ' MsgBox(Validate_Windows_FileName("C:\Te&st.txt")) ' Result: False
  8.  
  9.    Private Function Validate_Windows_FileName(ByRef FileName As String) As Boolean
  10.        Dim Windows_Reserved_Chars As String = "\/:*?""<>|"
  11.  
  12.        For i As Integer = 0 To FileName.Length - 1
  13.            If Windows_Reserved_Chars.Contains(FileName(i)) Then
  14.                Return False ' FileName is not valid
  15.            End If
  16.        Next
  17.  
  18.        Return True ' FileName is valid
  19.    End Function
  20.  
  21. #End Region



· cifra un string a Base64

Código
  1. #Region " String To Base64 "
  2.  
  3.    ' [ String To Base64 Function ]
  4.    '
  5.    ' // By Elektro H@cker
  6.    '
  7.    ' Examples :
  8.    ' MsgBox(String_To_Base64("Test")) ' Result: VGVzdA==
  9.  
  10.    Private Function String_To_Base64(ByVal str As String) As String
  11.        Return Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(str))
  12.    End Function
  13.  
  14. #End Region



· descifra un string Base64 a string

Código
  1. #Region " Base64 To String "
  2.  
  3.    ' [ Base64 To String Function ]
  4.    '
  5.    ' // By Elektro H@cker
  6.    '
  7.    ' Examples :
  8.    ' MsgBox(Base64_To_String("VGVzdA==")) ' Result: Test
  9.  
  10.    Private Function Base64_To_String(ByVal str As String) As String
  11.        Return System.Text.Encoding.ASCII.GetString(Convert.FromBase64String(str))
  12.    End Function
  13.  
  14. #End Region
9243  Programación / .NET (C#, VB.NET, ASP) / Re: Librería de Snippets !! (Posteen aquí sus snippets) en: 13 Abril 2013, 12:58 pm
· Enviar texto a una ventana PERO sin activar el foco de esa ventana :)

Ejemplo de uso:
Código
  1.    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  2.        ' Abrimos una instancia minimizada del bloc de notas
  3.        Process.Start("CMD", "/C Start /MIN Notepad.exe")
  4.        ' Y enviamos el texto a la instancia minimizada del bloc de notas!
  5.        ' Nota: El while es para esperar a que el notepad termine de cargar, no es algo imprescindible.
  6.        While Not SendKeys_To_App("notepad.exe", "By Elektro H@cker" & vbCrLf & "... :D") : Application.DoEvents() : End While
  7.    End Sub

Función:
Código
  1. #Region " SendKeys To App "
  2.  
  3.    ' [ SendKeys To App Function ]
  4.    '
  5.    ' // By Elektro H@cker
  6.    '
  7.    ' Examples :
  8.    ' SendKeys_To_App("notepad.exe", "By Elektro H@cker" & vbCrLf & "... :D")
  9.  
  10.    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
  11.    Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
  12.    Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long
  13.    Private Const EM_REPLACESEL = &HC2
  14.  
  15.    Private Function SendKeys_To_App(ByVal App_Name As String, ByVal str As String) As Boolean
  16.        Dim nPadHwnd As Long, ret As Long, EditHwnd As Long
  17.        Dim APP_WindowTitle As String
  18.  
  19.        If App_Name.ToLower.EndsWith(".exe") Then App_Name = App_Name.Substring(0, App_Name.Length - 4) ' Rename APP Name
  20.  
  21.        Dim ProcessArray = Process.GetProcessesByName(App_Name)
  22.        If ProcessArray.Length = 0 Then
  23.            Return False ' App not found
  24.        Else
  25.            APP_WindowTitle = ProcessArray(0).MainWindowTitle ' Set window title of the APP
  26.        End If
  27.  
  28.        nPadHwnd = FindWindow(App_Name, APP_WindowTitle)
  29.  
  30.        If nPadHwnd > 0 Then
  31.            EditHwnd = FindWindowEx(nPadHwnd, 0&, "Edit", vbNullString) ' Find edit window
  32.            If EditHwnd > 0 Then ret = SendMessage(EditHwnd, EM_REPLACESEL, 0&, str) ' Send text to edit window
  33.            Return True  ' Text sended
  34.        Else
  35.            Return False ' Name/Title not found
  36.        End If
  37.  
  38.    End Function
  39.  
  40. #End Region
9244  Programación / .NET (C#, VB.NET, ASP) / Re: Librería de Snippets !! (Posteen aquí sus snippets) en: 13 Abril 2013, 12:02 pm
@ABDERRAMAH
Gracias por aportar!



Mi recopilación personal de snippets ha sido re-ordenada y actualizada en el post principal, ya son un total de 200 snippets! :)

Saludos.
9245  Programación / .NET (C#, VB.NET, ASP) / Re: Problema con variables dinámicas... en: 12 Abril 2013, 21:06 pm
Porque sí como key del diccionario colocas el nombre de la variable, luego accedes al valor por ese nombre

No entendí nada de eso cuando te leí por primera vez, sincéramente ni sabía como usar el dictionary para mi propósito a pesar de ver el ejemplo del MSDN, ni tampoco me ibas a ofrecer un ejemplo de uso por más que insistiese xD, así que dejé el tema en blanco.

Ahora ya he aprendido a usar los diccionarios y los hastables porque he podido ver un buen ejemplo para las variables, y era mucho más sencillo de lo que me imaginé xD

Dictionary rules!

Gracias Nov.



EDITO:

Aquí dejo un ejemplo de uso:
Código
  1.        Dim MyDictionary As New Dictionary(Of String, Boolean)
  2.  
  3.        MyDictionary.Add("A", True)
  4.        MyDictionary.Add("B", False)
  5.        MyDictionary.Add("C", Nothing)
  6.  
  7.        ' Set value
  8.        MyDictionary.Item("C") = True
  9.  
  10.        ' Get Value
  11.        MsgBox(MyDictionary.Item("C"))

Y aquí el uso que le he dado:
Código
  1.    Dim CheckBoxes_Dictionary As New Dictionary(Of String, Boolean)
  2.  
  3.    Private Sub Main_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  4.        CheckBox_A.Tag = "A"
  5.        CheckBox_B.Tag = "B"
  6.        CheckBox_C.Tag = "C"
  7.  
  8.        CheckBoxes_Dictionary.Add("A_Enabled", Nothing)
  9.        CheckBoxes_Dictionary.Add("B_Enabled", Nothing)
  10.        CheckBoxes_Dictionary.Add("C_Enabled", Nothing)
  11.    End Sub
  12.  
  13.    Private Sub CheckBoxes_CheckedChanged(sender As Object, e As EventArgs) Handles _
  14.        CheckBox_A.CheckedChanged, _
  15.        CheckBox_B.CheckedChanged, _
  16.        CheckBox_C.CheckedChanged
  17.  
  18.        CheckBoxes_Dictionary.Item(sender.tag & "_Enabled") = sender.Checked
  19.  
  20.    End Sub
9246  Programación / .NET (C#, VB.NET, ASP) / Re: Librería de Snippets !! (Posteen aquí sus snippets) en: 12 Abril 2013, 11:15 am
Cargar configuración desde un archivo INI

Código
  1. Dim INI_File As String = ".\Test.ini"

Código
  1. ' By Elektro H@cker
  2.  
  3.    Private Sub Load_INI_settings()
  4.  
  5.        Dim Line As String = Nothing
  6.        Dim ValueName As String = Nothing
  7.        Dim Value
  8.  
  9.        Dim xRead As IO.StreamReader
  10.        xRead = IO.File.OpenText(INI_File)
  11.        Do Until xRead.EndOfStream
  12.  
  13.            Line = xRead.ReadLine().ToLower
  14.            ValueName = Line.Split("=")(0).ToLower
  15.            Value = Line.Split("=")(1)
  16.  
  17.            If ValueName = "Game".ToLower Then TextBox_Game.Text = Value
  18.            If ValueName = "SaveSettings".ToLower  Then CheckBox_SaveSettings.Checked = Value
  19.  
  20.        Loop
  21.  
  22.        xRead.Close()
  23.        xRead.Dispose()
  24.  
  25.    End Sub
9247  Programación / .NET (C#, VB.NET, ASP) / Re: [Ayuda] Monitorear procesos C# en: 12 Abril 2013, 10:57 am
Esto monitoriza el tiempo transcurrido para todos los procesos que se ejecuten, te servirá para obtener sólo el "dato" de si se ha ejecutado:

http://foro.elhacker.net/net/winwatcher_winforms_application_source-t377465.0.html

9248  Programación / Programación General / Re: Que Game Engine utilizar?? en: 11 Abril 2013, 14:50 pm
Citar
Unity — a game engine not tailored to a specific gamestyle for web, Windows, Mac OS X and Linux. The free version is feature limited compared to the PRO version. Support for the iPhone, Android, Nintendo Wii, PlayStation 3, and the Xbox 360 is available as addon licenses.

Yo no sé nada del tema, pero aquí tienes más game engines:
Game engines (abajo del todo pone las gratis)
Free game engines

Saludos
9249  Programación / .NET (C#, VB.NET, ASP) / Re: [APORTE] Plantillas de Game Launchers para juegos de Steam en: 11 Abril 2013, 09:58 am
Cierta persona me ha comentado que los ejecutables dan error en XP y no se pueden abrir.

Para los que quieran poder usar las plantillas en XP, deben modificar (eliminar) esta línea del archivo Main.Designer.vb

Código:
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)

No entiendo como el própio código generado por el designer es incompatible con XP, pero bueno... una grácia más de Microsoft!.

Saludos!
9250  Programación / Scripting / Re: Problema con apertura en batch en: 10 Abril 2013, 19:54 pm
En el primer script:

Código:
Start """" ".\Subcarpeta\Segundo script.bat"

saludos
Páginas: 1 ... 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 [925] 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 ... 1236
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines