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


Tema destacado: Arreglado, de nuevo, el registro del warzone (wargame) de EHN


  Mostrar Mensajes
Páginas: 1 ... 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 [873] 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 ... 1254
8721  Programación / .NET (C#, VB.NET, ASP) / Re: Como puedo hacer que al cerrar una ventana un textbox se guarde solo en: 17 Julio 2013, 21:15 pm
Por "ventana" imagino que te refieres al formulario.

Código
  1. Public Class Form1
  2.  
  3.    Private Sub Form1_Load(sender As Object, e As EventArgs) _
  4.    Handles MyBase.Load
  5.  
  6.        TextBox1.Text = My.Settings.Texto
  7.  
  8.    End Sub
  9.  
  10.    Private Sub Form1_FormClosing(sender As Object, e As FormClosingEventArgs) _
  11.    Handles MyBase.FormClosing
  12.  
  13.        My.Settings.Texto = TextBox1.Text
  14.  
  15.    End Sub
  16.  
  17. End Class

1 - Crear un textbox y llámalo "Textbox1"

2 - Crear una propiedad en las "Settings" de tu proyecto, de tipo "String" y "User", y llámala "Texto".

3 - Googlear en caso de no saber seguir el paso 2.

Saludos
8722  Programación / Scripting / Re: [BATCH] Problema con diccionario en: 17 Julio 2013, 21:06 pm
@zikotik
Si además muestras el output en la CMD, la rapidez disminuye x2, te lo digo por experiencia, no hagas esto en Batch.

Saludos
8723  Programación / Scripting / Re: [BATCH] Problema con diccionario en: 17 Julio 2013, 04:47 am
Intenté tanto con ^ como con ^^ y nada.

Lo que te dije funciona para mostrar el caracter conflictivo "!" cuando la expansión de variables está activada como lo está en el código que has mostrado:

Código
  1. setlocal enabledelayedexpansion
  2. Echo ^^!

...Óbviamente es un ejemplo que debes adaptar al resto de tu código.





Yo diréctamente te diría que los temas complicados y donde se maneja mucho texto lo tratases en cualquier otro lenguaje que no sea Batch, pero  si reálmente estás dispuesto a hacerlo sólo en Batch y si además quieres incluir los caracteres conflictivos "!" "?" pues entonces el code no va a poder quedar tán perfecto ni simplificado como deseas.

De todas formas no necesitas usar enabledelayedexpansion en el código.

Código
  1. @echo off
  2. title Diccionario
  3.  
  4. set "chars=a b c d e f g h i j k l m n o p q r s t u w w x y z 0 1 2 3 4 5 6 7 8 9 ! ."
  5. set /A "ini=0"
  6. set /A "wor=0"
  7.  
  8. set /p lenght=Lenght:
  9.  
  10. call :generar
  11.  
  12. pause&exit
  13.  
  14.  
  15. :generar
  16. set /a "wor+=1"
  17. title Palabra "%wor%"
  18. if %ini% neq %lenght% (
  19. set /a "ini+=1"
  20. for %%c in (%chars%) do (call :generar %~1%%c)
  21. set /a "ini-=1"
  22. ) else (
  23. echo.%1
  24. echo.%1>>"diccionario_%lenght%.txt"
  25. )
  26. goto:eof


Aquí tienes una alternativa funcional para mostrar los dos caracteres:

Código
  1. @echo off
  2. title Diccionario
  3.  
  4. rem set "chars=a b c d e f g h i j k l m n o p q r s t u w w x y z 0 1 2 3 4 5 6 7 8 9 ! ? ."
  5. set /A "ini=0"
  6. set /A "wor=0"
  7.  
  8. (
  9. Echo bla bla bla
  10. Echo bla bla bla
  11. )>"%TEMP%\chars.txt"
  12.  
  13. set /p lenght=Lenght:
  14.  
  15. call :generar
  16.  
  17. pause&exit
  18.  
  19.  
  20. :generar
  21. set /a "wor+=1"
  22. title Palabra "%wor%"
  23. if %ini% neq %lenght% (
  24. set /a "ini+=1"
  25. for /F %%c in ('type "%TEMP%\chars.txt"') do (call :generar %~1%%c)
  26. set /a "ini-=1"
  27. ) else (
  28. echo.%1
  29. echo.%1>>"diccionario_%lenght%.txt"
  30. )
  31. goto:eof


Tampoco me voy a esmerar mucho más tratándose de Batch y sus limitaciones.

Saludos!
8724  Programación / .NET (C#, VB.NET, ASP) / Re: Como insertar fecha en la que abrí por ultima vez un form(no la fecha actual) C# en: 17 Julio 2013, 04:00 am
1. Justo después de un logueo escribes la fecha de ese preciso momento donde quieras (archivo de texto, registro de windows, setting de la aplicación...)
(Esa será la fecha del último login.)

2. Al loguearte de nuevo, lees el valor desde el lugar donde lo guardaste, lo muestras.

3. En el próximo logueo repetir el paso 1 y 2, y así sucesivamente en cada logueo...

Tán sencillo como eso,
un saludo.
8725  Programación / Scripting / Re: [BATCH] Problema con diccionario en: 17 Julio 2013, 03:55 am
Escapa:

Código
  1. Echo ^^!

Saludos
8726  Media / Multimedia / Re: cambiar propiedades de audio mp3 en: 15 Julio 2013, 21:40 pm
"velocidad de muestra de sonido" y "velocidad de transmisión

Es decir, el "Sampling rate" y el "Bitrate".

Pues necesitas recodificar el archivo MP3, puedes hacerlo con cualquier conversor de Audio, te recomiendo dBPoweramp.



Saludos
8727  Programación / .NET (C#, VB.NET, ASP) / Re: Como hacer que al escrinbir en un textbox en otro salga otro texto en: 15 Julio 2013, 21:32 pm
Ya pero el probrlema esque al compilar me da eror esa palabra justamente ...
Y donde pongo la palabra que tiene que cambiar y a la que tiene que cambiar?

No es una palabra, es un objeto. Si de verdad estás interesado en esto debes estudiar para dejar de ver las cosas como "palabras" sueltas.

Te da error de compilación porque no has declarado ninguna variable que se llame "Server"  (y que contenga la función "HtmlEncode") .

PD: Anda que tu también Ikillnukes, darle códigos así a alguien que está empezando para liarle aún más...

Código
  1. Public Class Form1
  2.  
  3.    Dim Server As System.Web.HttpUtility
  4.  
  5.    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  6.        MsgBox(Server.HtmlEncode("<b> Hello World! </b>"))
  7.    End Sub
  8.  
  9. End Class
  10.  

@Alexperto
Ikillnukes te ha dado lo que necesitas, pero óbviamente sólo es un ejemplo de uso para que tu lo adaptes a tu código.
...Es muy fácil hacer lo que necesitas, si no te lo damos hecho es porque con una Googleada ya sabrías resolverlo.

Un saludo!
8728  Programación / Scripting / Re: Problema en script para cifrar [Python] en: 15 Julio 2013, 15:35 pm
Estás reemplazando el caracter en todo el texto.

Tenemos la palabra "hello", y lo que hace tu script es esto:
 - Replace "h" por "l" en todo el texto, resultado: "lello"
Ahí se puede ver cláramente que al llegar a las otras dos "ll" va a haber un conflicto porque también vas a reemplazar la primera "l".

Solución: No hagas diréctamente las modificaciones sobre el argumento "text", o usa replace para reemplazar un caracter en X posición del texto, pero no el caracter en el texto entero.

Código
  1. def crypt(text,x):
  2.    abc = "abcdefghijklmnopqrstuvwxyz"
  3.    newtext = ""
  4.    for i in range (0,len(text.lower())):
  5.        n = abc.find(text[i])
  6.        if n<0:
  7.            newtext = newtext + text[i]
  8.        if n>=0:
  9.         newtext = newtext + abc[(n+x)%len(abc)]
  10.    return newtext.upper()

Saludos
8729  Programación / .NET (C#, VB.NET, ASP) / Re: Error al capturar texto de pagina web VB.NET 2008 en: 14 Julio 2013, 18:03 pm
¿Tú qué opinas?
No soy quien para opinar sobre protocolos, el nivel web no es lo mio xD.

Lo que si tengo claro es que los headers hay que eliminarlos y agregar los de Shoutcast, al menos eso es lo que he visto hacer por ahí, pero con eso no parece ser suficiente para requerir la información del "Status" del server.

Saludos!
8730  Programación / .NET (C#, VB.NET, ASP) / Re: Librería de Snippets !! (Posteen aquí sus snippets) en: 14 Julio 2013, 17:05 pm
He ideado esya función para convertir un archivo REG a un script BAT.

La verdad es que no me ha costado mucho, ya había desarrollado antes la manera de convertir usando Ruby y sólo he tenido que trasladar el código que hice y agregarle las mejoras de VBNET xD.


Código
  1.    #Region " Reg2Bat "
  2.  
  3.       ' [ Reg2Bat Function ]
  4.       '
  5.       ' // By Elektro H@cker
  6.       '
  7.       ' Examples :
  8.       ' MsgBox(Reg2Bat("C:\Registry.reg"))
  9.  
  10.    Private Function Reg2Bat(ByVal Reg_File As String) As String
  11.  
  12.        ' Source Input
  13.        ' Join he lines, delete the Regedit linebreaks characters: "\  ", and then split the lines.
  14.        Dim RegFile() As String = Split( _
  15.                                  String.Join("@@@Reg2Bat@@@", IO.File.ReadAllLines(Reg_File)) _
  16.                                  .Replace("\@@@Reg2Bat@@@  ", "") _
  17.                                  .Replace("@@@Reg2Bat@@@", Environment.NewLine), _
  18.                                  Environment.NewLine)
  19.  
  20.        Dim RegLine As String = String.Empty ' Where the Regedit Line will be stored.
  21.        Dim RegKey As String = String.Empty ' Where the Regedit Key will be stored.
  22.        Dim RegVal As String = String.Empty ' Where the Regedit Value will be stored.
  23.        Dim RegData As String = String.Empty ' Where the Regedit Data will be stored.
  24.  
  25.        Dim Batch_Commands As String = String.Empty ' Where the decoded Regedit strings will be stored.
  26.  
  27.        ' Check if first line of Reg File has a valid Regedit signature
  28.        For X As Int64 = 0 To RegFile.LongLength - 1
  29.  
  30.            RegLine = RegFile(X).Trim
  31.  
  32.            While RegLine = String.Empty
  33.                X += 1
  34.                RegLine = RegFile(X).Trim
  35.            End While
  36.  
  37.            If Not RegLine.ToLower = "windows registry editor version 5.00" Then
  38.                Throw New Exception("This is not a valid Regedit v5.00 script.")
  39.                Return Nothing
  40.            Else
  41.                Batch_Commands &= ":: Converted with REG2BAT By Elektro H@cker" & Environment.NewLine & Environment.NewLine
  42.                Batch_Commands &= String.Format("REM {0}", RegLine) & Environment.NewLine & Environment.NewLine
  43.                Exit For
  44.            End If
  45.  
  46.        Next
  47.  
  48.        ' Start reading the Regedit File
  49.        For X As Int64 = 0 To RegFile.LongLength - 1
  50.  
  51.            RegLine = RegFile(X).Trim
  52.  
  53.            Select Case True
  54.  
  55.                Case RegLine.StartsWith(";") ' Comment line
  56.  
  57.                    Batch_Commands &= Environment.NewLine
  58.                    Batch_Commands &= String.Format("REM {0}", RegLine.Substring(1, RegLine.Length - 1).Trim)
  59.                    Batch_Commands &= Environment.NewLine
  60.  
  61.                Case RegLine.StartsWith("[-") ' Key to delete
  62.  
  63.                    RegKey = RegLine.Substring(2, RegLine.Length - 3).Trim
  64.                    Batch_Commands &= String.Format("REG DELETE ""{0}"" /F", RegKey)
  65.                    Batch_Commands &= Environment.NewLine
  66.  
  67.                Case RegLine.StartsWith("[") ' Key to add
  68.  
  69.                    RegKey = RegLine.Substring(1, RegLine.Length - 2).Trim
  70.                    Batch_Commands &= String.Format("REG ADD ""{0}"" /F", RegKey)
  71.                    Batch_Commands &= Environment.NewLine
  72.  
  73.                Case RegLine.StartsWith("@=") ' Default Value to add
  74.  
  75.                    RegData = Split(RegLine, "@=", , CompareMethod.Text).Last
  76.                    Batch_Commands &= String.Format("REG ADD ""{0}"" /V  """" /D {1} /F", RegKey, RegData)
  77.                    Batch_Commands &= Environment.NewLine
  78.  
  79.                Case RegLine.StartsWith("""") _
  80.                AndAlso RegLine.Split("=").Last = "-"  ' Value to delete
  81.  
  82.                    RegVal = RegLine.Substring(1, RegLine.Length - 4)
  83.                    Batch_Commands &= String.Format("REG DELETE ""{0}"" /V ""{1}"" /F", RegKey, RegVal)
  84.                    Batch_Commands &= Environment.NewLine
  85.  
  86.                Case RegLine.StartsWith("""") ' Value to add
  87.  
  88.                    RegLine = RegLine.Replace("\\", "\") ' Replace Double "\\" to single "\".
  89.  
  90.                    ' Check data type:
  91.                    Select Case RegLine.Split("=")(1).Split(":")(0).ToLower
  92.  
  93.                        Case "hex" ' Binary
  94.  
  95.                            RegVal = Split(RegLine, "=hex:", , CompareMethod.Text)(0)
  96.                            RegData = Split(RegLine, (RegVal & "=hex:"), , CompareMethod.Text).Last.Replace(",", "")
  97.                            Batch_Commands &= String.Format("REG ADD ""{0}"" /V {1} /T ""REG_BINARY"" /D ""{2}"" /F", RegKey, RegVal, RegData)
  98.                            Batch_Commands &= Environment.NewLine
  99.  
  100.                        Case "dword" ' DWORD
  101.  
  102.                            RegVal = Split(RegLine, "=dword:", , CompareMethod.Text)(0)
  103.                            RegData = "0x" & Split(RegLine, (RegVal & "=dword:"), , CompareMethod.Text).Last
  104.                            Batch_Commands &= String.Format("REG ADD ""{0}"" /V {1} /T ""REG_DWORD"" /D ""{2}"" /F", RegKey, RegVal, RegData)
  105.                            Batch_Commands &= Environment.NewLine
  106.  
  107.                        Case "hex(b)" ' QWORD
  108.  
  109.                            Dim TempData As String = "0x"
  110.                            RegVal = Split(RegLine, "=hex(b):", , CompareMethod.Text)(0)
  111.                            RegData = StrReverse(Split(RegLine, (RegVal & "=hex(b):"), , CompareMethod.Text).Last)
  112.                            For Each [byte] In RegData.Split(",") : TempData &= StrReverse([byte]) : Next
  113.                            Batch_Commands &= String.Format("REG ADD ""{0}"" /V {1} /T ""REG_QWORD"" /D ""{2}"" /F", RegKey, RegVal, TempData)
  114.                            Batch_Commands &= Environment.NewLine
  115.  
  116.                        Case "hex(2)"  ' EXPAND SZ
  117.  
  118.                            Dim TempData As String = String.Empty
  119.                            RegVal = Split(RegLine, "=Hex(2):", , CompareMethod.Text)(0)
  120.                            RegData = Split(RegLine, (RegVal & "=hex(2):"), , CompareMethod.Text).Last.Replace(",00", "").Replace("00,", "")
  121.                            For Each [byte] In RegData.Split(",") : TempData &= Chr(Val("&H" & [byte])) : Next
  122.                            TempData = TempData.Replace("%", "%%").Replace("""", "\""")
  123.                            Batch_Commands &= String.Format("REG ADD ""{0}"" /V {1} /T ""REG_EXPAND_SZ"" /D ""{2}"" /F", RegKey, RegVal, TempData)
  124.                            Batch_Commands &= Environment.NewLine
  125.  
  126.                        Case "hex(7)" ' MULTI SZ
  127.  
  128.                            Dim TempData As String = String.Empty
  129.                            RegVal = Split(RegLine, "=Hex(7):", , CompareMethod.Text)(0)
  130.                            RegData = Split(RegLine, (RegVal & "=hex(7):"), , CompareMethod.Text).Last.Replace(",00,00,00", ",\0").Replace(",00", "").Replace("00,", "")
  131.  
  132.                            For Each [byte] In RegData.Split(",")
  133.  
  134.                                If [byte] = "\0" Then
  135.                                    TempData &= "\0" ' Line separator for multiline.
  136.                                Else
  137.                                    TempData &= Chr(Val("&H" & [byte]))
  138.                                End If
  139.  
  140.                            Next
  141.  
  142.                            TempData = TempData.Replace("%", "%%").Replace("""", "\""")
  143.                            Batch_Commands &= String.Format("REG ADD ""{0}"" /V {1} /T ""REG_MULTI_SZ"" /D ""{2}"" /F", RegKey, RegVal, TempData)
  144.                            Batch_Commands &= Environment.NewLine
  145.  
  146.                        Case Else ' REG SZ
  147.  
  148.                            RegVal = Split(RegLine, """=""", , CompareMethod.Text)(0)
  149.                            RegData = Split(RegLine, (RegVal & """="""), , CompareMethod.Text).Last
  150.                            Batch_Commands &= String.Format("REG ADD ""{0}"" /V {1}"" /T ""REG_SZ"" /D ""{2} /F", RegKey, RegVal, RegData)
  151.                            Batch_Commands &= Environment.NewLine
  152.  
  153.                    End Select
  154.  
  155.            End Select
  156.  
  157.        Next
  158.  
  159.        Return Batch_Commands
  160.  
  161.    End Function
  162.  
  163.    #End Region
  164.  
Páginas: 1 ... 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 [873] 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 ... 1254
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines