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


Tema destacado: Sigue las noticias más importantes de seguridad informática en el Twitter! de elhacker.NET


  Mostrar Mensajes
Páginas: 1 ... 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 [937] 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 ... 1254
9361  Programación / Scripting / Re: [BATCH] Modificar Registros Fichero por script en: 30 Abril 2013, 12:53 pm
Código
  1. @echo off
  2. Setlocal enabledelayedexpansion
  3.  
  4. For %%# in (*.txt) Do (
  5. Set "Registry=%%~n#"
  6. Set "Date=20!Registry:~0,6!"
  7. Set "Time=!Registry:~6,6!"
  8. Set "Ficha=!Registry:~-4!"
  9. Set "Fixed=00 0 00 0 01"
  10. Set "NewRegistry=!Date! !Time! !Ficha! !Fixed!"
  11.  
  12. Echo Old Registry: !Registry!
  13. Echo New Registry: !NewRegistry!
  14.  
  15. REM Rename "%%#" "!NewRegistry!%%~x#"
  16. )
  17.  
  18. Pause&Exit

Output:
Código:
Old Registry: 130425075500000001010
New Registry: 20130425 075500 1010 00 0 00 0 01

Confirma que es correcto, porque a mi no me cuadran las cosas, como ves obtengo esto:

Código:
20130425 075500 1010 00 0 00 0 01

Pero según tus indicaciones la ficha debería ser "0101"

Deberías especificar cual es el registro fijo de este string: 130425075500000001010

Yo he asumido que la ficha eran los últimos 4 dígitos, pero quizás haya que eliminar el último dígito y coger los ultimos 4, entonces modifica esta línea:
Código:
Set "Ficha=!Registry:~-4!"
Por esta otra:
Código:
Set "Ficha=!Registry:~-5!" & Set "Ficha=!Ficha:~0,4!"

Así obtienes exáctamente el nuevo registro, pero como no sé la estructura del antiguo registro... no sé si es lo correcto.

Saludos!
9362  Programación / Scripting / Re: Modificar Registros Fichero por script en: 30 Abril 2013, 12:36 pm
Muchos detalles, pero falta el más importante... ¿Para Linux o para Windows?, vale, acabo de leer lo del Notepad, a no ser que uses Wine para abrir el notepad en Linux me imagino que trabajs en Windows, haz el favor de especificar el detalle cuando formules preguntas.
9363  Programación / Scripting / Re: como puedo vitar que el comando echo inserte un salto de linea? en: 30 Abril 2013, 12:32 pm
@Meine programmen
EDLIN es para XP


@tiernohack
Puedes crear un procedimiento para setear una variable añadiendo el texto que contienen los archivos, te pongo un ejemplo:

Código
  1. @echo off
  2.  
  3. Set "String="
  4.  
  5. REM Call :Append_String STRING_or_TEXTFILE
  6.  
  7. Call :Append_String "1.txt"
  8. Call :Append_String "como_estas"
  9. Call :Append_String "2.txt"
  10.  
  11. Echo %String%
  12. Echo %String%>"Resp.txt"
  13. Pause&Exit
  14.  
  15. :Append_String
  16. If Not Exist "%~1" (
  17. Set "String=%String%%~1"
  18. ) ELSE (
  19. For /F "Usebackq Delims=" %%# in ("%~1") Do (
  20. Call Set "String=%%String%%%%#"
  21. )
  22. )
  23.  
  24. GOTO:EOF


Output:
Código:
holacomo_estaschao
Presione una tecla para continuar . . .

9364  Programación / Scripting / Re: Ayuda con batch en: 30 Abril 2013, 12:18 pm
@Kriminal_27
Lee las indicaciones de mi firma para no estar editando todos tus mensajes.

Un saludo!
9365  Programación / .NET (C#, VB.NET, ASP) / Re: ¿Cómo crear un visualizador de imágenes con botones de siguiente y anterior? en: 30 Abril 2013, 12:11 pm
Es muy sencillo, indexa las imágenes por ejemplo en un diccionario, y las cargas.



Source:
Código
  1. Public Class Form1
  2.  
  3.    Dim ImageList As New Dictionary(Of Int32, String)
  4.    Dim ImageIndex As Int32 = 0
  5.    Dim TotalImages As Int32 = 0
  6.  
  7.    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  8.        Load_ImageList()
  9.    End Sub
  10.  
  11.    ' Botón "Anterior"
  12.    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  13.        If Not ImageIndex = 1 Then
  14.            ImageIndex -= 1
  15.            PictureBox1.BackgroundImage = Image.FromFile(ImageList.Item(ImageIndex))
  16.        End If
  17.    End Sub
  18.  
  19.    ' Botón "Siguiente"
  20.    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
  21.        If Not ImageIndex = TotalImages Then
  22.            ImageIndex += 1
  23.            PictureBox1.BackgroundImage = Image.FromFile(ImageList.Item(ImageIndex))
  24.        End If
  25.    End Sub
  26.  
  27.    Private Sub Load_ImageList()
  28.        ImageList.Add(1, "F:\Customización\Wallpapers\Animated\[AnimePaper]wallpapers_Bleach_Cilou(1.33)_1280x960_64991.jpg")
  29.        ImageList.Add(2, "F:\Customización\Wallpapers\Animated\0f61391cfd811f6cf57cf74b9fb00211.jpg")
  30.        ImageList.Add(3, "F:\Customización\Wallpapers\Animated\dragon_ball_z_broly_1771x1154_wallpaper_Wallpaper_1920x1440_www.wall321.com.jpg")
  31.        ImageList.Add(4, "F:\Customización\Wallpapers\Girls (Fantasy)\2.jpg")
  32.        ImageList.Add(5, "F:\Customización\Wallpapers\Girls (Fantasy)\7k982aivf38npdom4ol22653m15074a52c3a33c.jpg")
  33.        TotalImages = ImageList.Count
  34.    End Sub
  35.  
  36. End Class
9366  Programación / Scripting / Re: Uso del && y || en batch en: 30 Abril 2013, 11:48 am
Que windows trabaja a un nivel mas bajo que linux y tal...

Que Batch séa un "retrasado" no significa que la shell de Linux séa increíblemente superior a la de Windows, Windows además de Batch también dispone el uso nativo de VisualBasicScript, Jscript, y Powershell, puedes hacer de todo. Si no me equivoco Linux solo dispone de Bash como lenguaje nativo (No lo sé seguro pero...), así que tu me dirás.

saludos!
9367  Programación / .NET (C#, VB.NET, ASP) / Re: El Santo Grial de los programadores, como hacer para que se venza al Mes ? en: 30 Abril 2013, 11:38 am
Una solución sencilla de usar:

Código
  1.    #Region " Trial Period Function "
  2.  
  3.       ' [ Trial Period Function ]
  4.       '
  5.       ' Examples :
  6.       ' Trial_Get(Trial_value.As_Boolean)
  7.       ' MsgBox(String.Format("You have {0} day(s) remaining.", Trial_Get(Trial_value.As_LeftDays)))
  8.  
  9.       Public Enum Trial_value
  10.           As_Boolean
  11.           As_LeftDays
  12.           As_CountDays
  13.       End Enum
  14.  
  15.       ' Trial Period [Get]
  16.       Public Function Trial_Get(ByVal Trial_value As Trial_value)
  17.           'My.Settings.Reset() 'If you want to reset the trial period
  18.           Dim TrialCount As Integer = 0
  19.           TrialCount += 1
  20.           Return Trial_CheckDate(Date.Now.AddDays(TrialCount), Trial_value)
  21.       End Function
  22.  
  23.       ' Trial Period [CheckDate]
  24.       Public Function Trial_CheckDate(ByVal Trial_DateToCheck As Date, ByVal Trial_value As Trial_value)
  25.  
  26.           Dim Trial_retValue As Boolean = False ' Fail safe, default to false
  27.           Dim Trial_usageDatesLeft As Int16 = 7 ' Set here the number of days of Trial period
  28.           Dim Trial_hashedDate As String = Trial_HashDate(Trial_DateToCheck)
  29.  
  30.           If My.Settings.Trial_Period Is Nothing Then My.Settings.Trial_Period = New System.Collections.Specialized.StringCollection
  31.  
  32.           If My.Settings.Trial_Period.Contains(Trial_hashedDate) Then
  33.               Trial_retValue = True
  34.               Trial_usageDatesLeft = CShort(Trial_usageDatesLeft - My.Settings.Trial_Period.Count)
  35.               If Trial_usageDatesLeft <= 0 AndAlso My.Settings.Trial_Period.IndexOf(Trial_hashedDate) <> My.Settings.Trial_Period.Count - 1 Then Trial_retValue = False
  36.           Else
  37.               If My.Settings.Trial_Period.Count < Trial_usageDatesLeft Then My.Settings.Trial_Period.Add(Trial_hashedDate)
  38.               Trial_usageDatesLeft = CShort(Trial_usageDatesLeft - My.Settings.Trial_Period.Count)
  39.               If Trial_usageDatesLeft > 0 Then Trial_retValue = True Else Trial_retValue = False
  40.           End If
  41.  
  42.           Select Case Trial_value
  43.               Case Trial_value.As_Boolean : Return Trial_retValue ' If False then Trial Period is expired
  44.               Case Trial_value.As_LeftDays : Return Trial_usageDatesLeft ' Days left
  45.               Case Trial_value.As_CountDays : Return My.Settings.Trial_Period.Count ' Count days
  46.               Case Else : Return Nothing
  47.           End Select
  48.  
  49.       End Function
  50.  
  51.       ' Trial Period [HashDate]
  52.       Public Function Trial_HashDate(ByVal Trial_DateToHash As Date) As String
  53.           Dim Trial_Hasher As System.Security.Cryptography.MD5 = System.Security.Cryptography.MD5.Create()
  54.           Dim Trial_Data As Byte() = Trial_Hasher.ComputeHash(System.Text.Encoding.Default.GetBytes(Trial_DateToHash.ToLongDateString()))
  55.           Dim Trial_StringBuilder As New System.Text.StringBuilder()
  56.           Dim Trial_IDX As Integer
  57.           For Trial_IDX = 0 To Trial_Data.Length - 1 : Trial_StringBuilder.Append(Trial_Data(Trial_IDX).ToString("x2")) : Next Trial_IDX
  58.           Return Trial_StringBuilder.ToString
  59.       End Function
  60.  
  61.    #End Region


Aquí tienes más snippets interesantes: http://foro.elhacker.net/net/libreria_de_snippets_posteen_aqui_sus_snippets-t378770.0.html
9368  Programación / .NET (C#, VB.NET, ASP) / Re: Detener servicios de windows en: 23 Abril 2013, 01:15 am
Claro, no puedes iniciar un servicio que ya se encuentra iniciado, ni detener uno que ya está detenido.

De todas formas no dás ningún detalle acerca del error, solo dices que "falla", podrías haber mostrado la excepción porque no somos magos para adivinar lo que ocurre.

Pero deduzco que el problema es ese porque en tu código no compruebas el estado del servicio. solo puede ser eso, o que el servicio no se pueda detener por alguna dependencia.

Usa un convertidor online de VBNET a C# con esta función que hice, y listo:

Código
  1. #Region " Change Service Status "
  2.  
  3.    ' [ Change Service Status Function ]
  4.    '
  5.    ' // By Elektro H@cker
  6.    '
  7.    ' Instructions :
  8.    ' Add a reference for "System.ServiceProcess"
  9.    '
  10.    ' Examples :
  11.    ' MsgBox(Change_Service_Status("Temas", Service.StopIt))
  12.    ' MsgBox(Change_Service_Status("Temas", Service.RunIt, True))
  13.  
  14.    Public Enum Service
  15.        RunIt = True
  16.        StopIt = False
  17.    End Enum
  18.  
  19.    Function Change_Service_Status(ByVal ServiceName As String, _
  20.                                   ByVal Run As Service, _
  21.                                   Optional Wait As Boolean = False) As Boolean
  22.  
  23.        Try
  24.            Dim Service As New System.ServiceProcess.ServiceController(ServiceName)
  25.  
  26.            Select Case Service.Status
  27.                Case System.ServiceProcess.ServiceControllerStatus.Stopped And Run
  28.                    Service.Start()
  29.                    If Wait Then Service.WaitForStatus(System.ServiceProcess.ServiceControllerStatus.Running)
  30.                Case System.ServiceProcess.ServiceControllerStatus.Running And Not Run
  31.                    Service.Stop()
  32.                    If Wait Then Service.WaitForStatus(System.ServiceProcess.ServiceControllerStatus.Stopped)
  33.            End Select
  34.  
  35.            Service.Dispose()
  36.            Return True
  37.  
  38.        Catch ex As Exception
  39.            ' Throw New Exception(ex.Message)
  40.            Return False
  41.        End Try
  42.  
  43.    End Function
  44.  
  45. #End Region


Saludos.
9369  Programación / Programación General / Re: Como localizar un nuevo certificado usando CertUtil? en: 22 Abril 2013, 05:25 am
Al final probando cosas he conseguido hacer el código:

Código:
@Echo OFF
Setlocal enabledelayedexpansion


Set "Name=ElektroSoft"
Set "Password=Elektro"
Set "InitialDate=01/01/2013"
Set "ExpireDate=01/01/2050"
Set "SerialNumber=%Random%%Random%%Random%%Random%%Random%"


:: Make certificate
makecert -r -pe -a sha1 -n "CN=%Name%" -b "%InitialDate%" -e "%ExpireDate%" -$ individual -sr LocalMachine -ss my -cy authority -# "%SerialNumber%" "%Name%.cer"


:: Export certificate
For /F "Tokens=2 delims=:" %%# in ('certutil -store my') DO (
if "%%#" NEQ " CN=%Name%" (Set "SerialNumberHash=%%#") ELSE (
certutil -exportPFX -p "%Password%" my "!SerialNumberHash: =!" "%Name%.pfx"
Pause&Exit))


:: Check certificate
REM certutil -store my


:: Delete certificate
REM certutil -delstore MY "%Name%"


saludos :)
9370  Programación / .NET (C#, VB.NET, ASP) / Re: Reemplazar varios caracteres por numeros en: 22 Abril 2013, 04:51 am
OMG!

No me gusta criticar los códigos de los demás pero te has pasado!, desde luego esa no es la manera de hacer las cosas bien...

Ya que vas a usar todo el alfabeto, te recomiendo que lo primero de todo definas el valor de cada letra y lo guardes en algún sitio...así lo tendrás más ordenado y mayor control si luego quieres cambiar algún número...

Prueba de esta manera:

Código
  1. Public Class Form1
  2.  
  3.  
  4.    Dim Alphabet As New Dictionary(Of String, Int16)
  5.  
  6.  
  7.    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  8.  
  9.        TextBox1.Text "abcdef"
  10.  
  11.        Alphabet.Add("a", 5)
  12.        Alphabet.Add("b", 9)
  13.        Alphabet.Add("c", 4)
  14.        Alphabet.Add("d", 1)
  15.        Alphabet.Add("e", 3)
  16.        Alphabet.Add("f", 0)
  17.       ' Alphabet.add(...
  18.  
  19.    End Sub
  20.  
  21.  
  22.    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  23.        For Each Character As String In TextBox1.Text
  24.            TextBox1.Text = Replace(TextBox1.Text, Character, Alphabet.Item(Character))
  25.        Next
  26.    End Sub
  27.  
  28.  
  29. End Class

Saludos!
Páginas: 1 ... 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 [937] 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 ... 1254
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines