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

 

 


Tema destacado: Rompecabezas de Bitcoin, Medio millón USD en premios


  Mostrar Mensajes
Páginas: 1 ... 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 [750] 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 ... 1236
7491  Programación / Scripting / Re: [AYUDA][PYTHON] los scripts que compilo a ejecutable con py2exe no me funcionan en: 29 Enero 2014, 16:02 pm
Citar
Código:
ImportError: No module named sip

La descripción del error es clara, no se encuentra el módulo SIP porque no lo has añadido al convertir el script a exe, la solución a ese error lo tienes al final de mi respuesta:
Cita de: elektro
quizás símplemente no hayas añadido los módulos necesarios de pyqt4 a tu exe al usar py2exe ~> http://www.py2exe.org/index.cgi/Py2exeAndPyQt

Sobre lo de cx_feeze, bueno, si te molestases en abrir la url y leer las primeras lineas entenderías lo que es y porque te lo pasé:
Cita de: cx_Freeze
cx_Freeze is a set of scripts and modules for freezing Python scripts into executables, in much the same way that py2exe and py2app do. Unlike these two tools, cx_Freeze is cross platform and should work on any platform that Python itself works on. It supports Python 2.3 or higher (including Python 3), since it makes use of the zip import facility which was introduced in 2.3.

Saludos!
7492  Programación / Scripting / Re: [AYUDA][PYTHON] los scripts que compilo a ejecutable con py2exe no me funcionan en: 29 Enero 2014, 12:58 pm
Mi pregunta es porque no anda despues de convertirlo a EXE

Rapuesta rápida: Porque todos los novatos hemos cometido el mismo error de utilizar (el obsoleto) py2exe, ya que la información en internet y los típicos tutoriales están muy desactualizados.
Solución: http://cx-freeze.sourceforge.net/

cuando lo compile a ".exe" tan solo aparecio el CMD un segundo y desaparecio..

Si ejecutas el exe diréctamente desde la consola evitarás que se abra en una ventana y por ende que se cierre, y así podrás ver el tipo de error del que se trate, ya que en realidad puede ser por varias razones pero básicamente es por estar utilizando un software obsoleto... quizás estés usando python 3.X y py2exe no soporta py 3.X (cosa que no es de extrañar, ya que la última release de py2exe es del 2008 y hay decenas de requests sin respuesta pidiendo soporte para py 3.X), o quizás símplemente no hayas añadido los módulos necesarios de pyqt4 a tu exe al usar py2exe ~> http://www.py2exe.org/index.cgi/Py2exeAndPyQt

Saludos!
7493  Programación / Programación General / Re: Cómo cambiar el hash de un archivo en: 28 Enero 2014, 23:19 pm
Otra alternativa que se me acaba de ocurrir sin requerir el uso de programas de terceros:



Si le añadiste información de propiedades a tu ensamblado ...quítaselas, en cambio si no le añadiste ninguna ...añádele. Esto producirá un cambio en el tamaño del exe compilado, por lo tanto el hash calculado será distinto.

Saludos
7494  Programación / Scripting / Re: Dudas sobre Text Manipulator Routine de Elektro en: 28 Enero 2014, 22:02 pm
Segúramente el error sea por las comillas dobles, la comilla doble está reservada y debes escapar el símbolo si lo quieres utilizar dentro de un argumento:
Código
  1. Call :TEXTMAN RL 237 "zabbix_agentd.conf" "UserParameter=specHWShort,cscript.exe /nologo ^"C:\Program Files\Zabbix Agent\specHWShort.vbs^" "

Si te sigue sin funcionar prueba a escapar también el símbolo del "=" por si están afectando al FOR:
Código
  1. Call :TEXTMAN I 135 "zabbix_agentd.conf" "HostMetadataItem^=system.uname"
  2. Call :TEXTMAN RL 237 "zabbix_agentd.conf" "UserParameter^=specHWShort,cscript.exe /nologo ^"C:\Program Files\Zabbix Agent\specHWShort.vbs^" "

Y si aún así te sigue sin funcionar, deberías utilizar alguna utilidad externa como SED ~> http://gnuwin32.sourceforge.net/packages/sed.htm

PD: Imagino que despues de llamar al método estarás haciendo una pausa en el código como esto:
Código:
Call :TEXTMAN ...
Call :TEXTMAN ...
Pause

...De lo contrario, es normal que te de un error.

Saludos!
7495  Programación / Scripting / Re: Dudas sobre Text Manipulator Routine de Elektro en: 28 Enero 2014, 21:40 pm
Hola, he probado a llamar al método utilizando el parámetro "I" seguido del parámetro "RL" y en mi caso me funcionó, quizás sea un error muy específico :-/.

¿Te sale algún mensaje de error?
¿Puedes describir el mensaje de error?
¿Puedes mostrar el contenido exacto de la linea 237?
También sería buena idea que mostrases el script completo que estás usando para llamar al TextMan.

De todas formas aquí tienes la última versión que hice del script por si estuvieras usando una versión antigua...
Citar
Código:
@Echo OFF


:: TEXT MANIPULATOR ROUTINE v0.5
:: by Elektro H@cker
 

REM SYNTAX:
::
:: TEXTMAN [ACTION] [LINE(S)] [FILE] [TEXT]
::
:: * [LINE(S)] parameter is Optional for some actions
:: * [TEXT] parameter is Optional for some actions
 

REM ACTIONS:
::
::  AB  = ADD_BEGINNING      * Add text to the beginning of a line.
::  AE  = ADD_ENDING         * Add text to the end of a line.
::  E   = ERASE              * Delete a line.
::  I   = INSERT             * Add a empty line (Or a line with text).
::  RL  = REPLACE_LINE       * Replace a entire line.
::  RS  = REPLACE_STRING     * Replace word from line.
::  RSA = REPLACE_STRING_ALL * Replace word from all lines.
::  C+  = CHARACTER_PLUS     * Delete the first "X" characters from all lines.
::  C-  = CHARACTER_LESS     * Delete the last  "X" characters from all lines.
::  L+  = LINE_PLUS          * Cut the first "X" amount of lines.
::  L-  = LINE_LESS          * Cut the last  "X" amount of lines.
::  GL  = GET_LINE           * Delete all except "X" line.
::  GR  = GET_RANGE          * Delete all except "X" range of lines.
 

REM EXAMPLES:
::
:: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: ::
::                                                                         ::
:: Delete the line 3                                                       ::
:: Call :TEXTMAN E 3 "Test.txt"                                            ::
::                                                                         ::                                                                        
:: Add a string to the beginning of line 3                                 ::
:: Call :TEXTMAN AL 3 "Test.txt" "Elektro H@cker"                          ::
::                                                                         ::                                                                      
:: Add a string to the end of line 3.                                      ::
:: Call :TEXTMAN AR 3 "Test.txt" "Elektro H@cker"                          ::
::                                                                         ::                                                                      
:: Add a empty line at line 3.                                             ::
:: Call :TEXTMAN I 3 "Test.txt"                                            ::
::                                                                         ::                                                                      
:: Add a line with a word at line 3.                                       ::
:: Call :TEXTMAN I 3 "Test.txt" "Elektro H@cker"                           ::
::                                                                         ::    
:: Replace the line 3 with "Elektro H@cker".                               ::
:: Call :TEXTMAN RL 3 "Test.txt" "Elektro H@cker"                          ::
::                                                                         ::
:: Replace the words "Elektro" to "H@cker" in line 3.                      ::
:: Call :TEXTMAN RS 3 "Test.txt" "Elektro" "H@cker"                        ::
::                                                                         ::
:: Replace the words "Elektro" to "H@cker" in all lines.                   ::
:: Call :TEXTMAN RSA "Test.txt" "Elektro" "H@cker"                         ::
::                                                                         ::
:: Delete the first 3 characters in all lines.                             ::
:: Call :TEXTMAN C+ 3 "Test.txt"                                           ::
::                                                                         ::
:: Delete the last 3 characters in all lines.                              ::
:: Call :TEXTMAN C- 3 "Test.txt"                                           ::
::                                                                         ::
:: Delete the first 3 lines.                                               ::
:: Call :TEXTMAN L+ 3 "Test.txt"                                           ::
::                                                                         ::
:: Delete the last 3 lines.                                                ::
:: Call :TEXTMAN L- 3 "Test.txt"                                           ::
::                                                                         ::
:: Delete all except the line number 3.                                    ::
:: Call :TEXTMAN SL 3 "Test.txt"                                           ::
::                                                                         ::
:: Delete all except the 3 to 9 range of lines.                            ::
:: Call :TEXTMAN SR 3 9 "Test.txt"                                         ::
::                                                                         ::
:: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: ::
 

:TEXTMAN
(SET /A "A=0", "LINE=0", "TOTAL_LINES=0")  &  (CALL :%~1 %* || (ECHO Invalid parameter & Exit /B 1)) & (GOTO:EOF)
:AB
(For /F "tokens=1* delims=]" %%A in ('type "%~3" ^| find /n /v ""') DO (Call Set /A "LINE+=1" && (CMD /C "IF NOT "%%LINE%%" EQU "%~2" (if "%%B" EQU "" (Echo+>> "%~3.NEW") ELSE ((Echo %%B)>> "%~3.NEW")) ELSE (if "%%B" EQU "" ((Echo %~4)>> "%~3.NEW") ELSE ((Echo %~4%%B)>> "%~3.NEW"))"))) && (CALL :RENAMER "%~3") & (GOTO:EOF)
:AE
(For /F "tokens=1* delims=]" %%A in ('type "%~3" ^| find /n /v ""') DO (Call Set /A "LINE+=1" && (CMD /C "IF NOT "%%LINE%%" EQU "%~2" (if "%%B" EQU "" (Echo+>> "%~3.NEW") ELSE ((Echo %%B)>> "%~3.NEW")) ELSE ((Echo %%B%~4)>> "%~3.NEW")"))) && (CALL :RENAMER "%~3") & (GOTO:EOF)
:E
(For /F "tokens=1* delims=]" %%A in ('type "%~3" ^| find /n /v ""') DO (Call Set /A "LINE+=1" && (CMD /C "IF NOT "%%LINE%%" EQU "%~2" (if "%%B" EQU "" (Echo+>> "%~3.NEW") ELSE ((Echo %%B) >> "%~3.NEW"))"))) && (CALL :RENAMER "%~3") & (GOTO:EOF)
:I
(For /F "tokens=1* delims=]" %%A in ('type "%~3" ^| find /n /v ""') DO (Call Set /A "LINE+=1" && (CMD /C "IF     "%%LINE%%" EQU "%~2" (IF NOT "%~4" EQU "" ((Echo %~4) >> "%~3.NEW") ELSE (Echo+>> "%~3.NEW"))" & (if "%%B" EQU "" (Echo+>> "%~3.NEW") ELSE ((Echo %%B)>> "%~3.NEW"))))) && (CALL :RENAMER "%~3") & (GOTO:EOF)
:RL
(For /F "tokens=1* delims=]" %%A in ('type "%~3" ^| find /n /v ""') DO (Call Set /A "LINE+=1" && (CMD /C "IF NOT "%%LINE%%" EQU "%~2" (if "%%B" EQU "" (Echo+>> "%~3.NEW") ELSE ((Echo %%B)>> "%~3.NEW")) ELSE ((Echo %~4)>> "%~3.NEW")"))) && (CALL :RENAMER "%~3") & (GOTO:EOF)
:RS
(For /F "tokens=1* delims=]" %%A in ('type "%~3" ^| find /n /v ""') DO (Call Set /A "LINE+=1" && (CMD /C "IF NOT "%%LINE%%" EQU "%~2" (if "%%B" EQU "" (Echo+>> "%~3.NEW") ELSE ((Echo %%B)>> "%~3.NEW")) ELSE (CALL SET "STRING=%%B" &&     (if "%%B" EQU "" (Echo+>> "%~3.NEW") ELSE ((CALL ECHO %%STRING:%~4=%~5%%)>> "%~3.NEW")))"))) && (CALL :RENAMER "%~3") & (GOTO:EOF)
:RSA
(For /F "tokens=1* delims=]" %%A in ('type "%~2" ^| find /n /v ""') DO (CALL SET "STRING=%%B" && (if "%%B" EQU "" (Echo+>> "%~2.NEW") ELSE ((CALL ECHO %%STRING:%~3=%~4%%)>>"%~2.NEW")))) && (CALL :RENAMER "%~2") & (GOTO:EOF)
:C+
(For /F "usebackq tokens=*" %%@ in ("%~3") DO (Call Set   "LINE=%%@" && (CALL ECHO %%LINE:~%~2%% >>      "%~3.NEW"))) && (CALL :RENAMER "%~3") & (GOTO:EOF)
:C-
(For /F "usebackq tokens=*" %%@ in ("%~3") DO (Call Set   "LINE=%%@" && (CALL ECHO %%LINE:~0,-%~2%% >>   "%~3.NEW"))) && (CALL :RENAMER "%~3") & (GOTO:EOF)
:L+
(Call SET /A "A=%~2") && (Call TYPE "%~3" |@MORE +%%A%% > "%~3.NEW") && (CALL :RENAMER "%~3") & (GOTO:EOF)
:L-
(For /F "tokens=1* delims=]" %%A in ('type "%~3" ^| find /n /v ""') DO (CALL SET /A "TOTAL_LINES+=1")) & (CALL SET /A "TOTAL_LINES-=%~2-1") & (For /F "tokens=1* delims=]" %%A in ('type "%~3" ^| find /n /v ""') DO (Call Set /A "LINE+=1" & Call echo "%%LINE%%"|@FIND "%%TOTAL_LINES%%" >NUL) && (CALL :RENAMER "%~3" && GOTO:EOF) || (Echo %%B >> "%~3.NEW"))
:GL
(Call SET /A "A=%~2" && Call SET /A "A-=1") && (Call TYPE "%~3" |@MORE +%%A%% > "%temp%\getline.tmp") && (For /F "tokens=1* delims=]" %%A in ('type "%temp%\getline.tmp" ^| find /n /v ""') DO ((if "%%B" EQU "" (Echo+>> "%~3.NEW") ELSE ((Echo %%B)> "%~3.NEW"))) && ((CALL :RENAMER "%~3") & (GOTO:EOF)))
:GR
(For /F "tokens=1* delims=]" %%A in ('type "%~4" ^| find /n /v ""') DO (Call Set /A "LINE+=1" && (CMD /C "(IF "%%LINE%%" GEQ "%~2" IF "%%LINE%%" LEQ "%~3" (if "%%B" EQU "" (Echo+>> "%~4.NEW") ELSE ((Echo %%B)>> "%~4.NEW"))) && (IF "%%LINE%%" EQU "%~3" Exit /B 1)" || ((CALL :RENAMER "%~4") & (GOTO:EOF)))))

:RENAMER
(REN "%~1" "%~nx1.BAK") & (MOVE /Y "%~1.BAK" "%TEMP%\" >NUL) & (REN "%~1.NEW" "%~nx1") & (GOTO:EOF)

Saludos!
7496  Programación / .NET (C#, VB.NET, ASP) / Re: Librería de Snippets !! (Compartan aquí sus snippets) en: 28 Enero 2014, 18:49 pm
Una versión pulida de mi ayudante para convertir archivos Reg a Bat

Código
  1. ' ***********************************************************************
  2. ' Assembly : Reg2Bat
  3. ' Author   : Elektro
  4. ' Modified : 01-28-2014
  5. ' ***********************************************************************
  6. ' <copyright file="Reg2Bat.vb" company="Elektro Studios">
  7. '     Copyright (c) Elektro Studios. All rights reserved.
  8. ' </copyright>
  9. ' ***********************************************************************
  10.  
  11. #Region " Usage Examples "
  12.  
  13. ' Dim BatchScript As String = Reg2Bat.Convert("C:\RegistryFile.reg")
  14.  
  15. ' IO.File.WriteAllText("Converted.bat", Reg2Bat.Convert("C:\RegistryFile.reg"), System.Text.Encoding.Default)
  16.  
  17. #End Region
  18.  
  19. #Region " Imports "
  20.  
  21. Imports System.ComponentModel
  22. Imports System.IO
  23. Imports System.Text
  24. Imports System.Text.RegularExpressions
  25.  
  26. #End Region
  27.  
  28. ''' <summary>
  29. ''' Converts a Registry Script to a Batch Script.
  30. ''' </summary>
  31. Public Class Reg2Bat
  32.  
  33. #Region " ReadOnly Strings "
  34.  
  35.    ''' <summary>
  36.    ''' Indicates the resulting Batch-Script Header.
  37.    ''' </summary>
  38.    Private Shared ReadOnly BatchHeader As String =
  39.    <a>:: Converted with Reg2Bat by Elektro
  40.  
  41. @Echo OFF
  42. </a>.Value
  43.  
  44.    ''' <summary>
  45.    ''' Indicates the resulting Batch-Script Footer.
  46.    ''' </summary>
  47.    Private Shared ReadOnly BatchFooter As String =
  48.    <a>
  49. Pause&amp;Exit</a>.Value
  50.  
  51.    ''' <summary>
  52.    ''' Indicates the Batch syntax StringFormat of a Comment-Line command.
  53.    ''' </summary>
  54.    Private Shared ReadOnly BatchStringFormat_Comment As String =
  55.    <a>REM {0}</a>.Value
  56.  
  57.    ''' <summary>
  58.    ''' Indicates the Batch syntax StringFormat of a REG Key-Add command.
  59.    ''' </summary>
  60.    Private Shared ReadOnly BatchStringFormat_KeyAdd As String =
  61.    <a>REG ADD "{0}" /F</a>.Value
  62.  
  63.    ''' <summary>
  64.    ''' Indicates the Batch syntax StringFormat of a REG Key-Delete command.
  65.    ''' </summary>
  66.    Private Shared ReadOnly BatchStringFormat_KeyDelete As String =
  67.    <a>REG DELETE "{0}" /F</a>.Value
  68.  
  69.    ''' <summary>
  70.    ''' Indicates the Batch syntax StringFormat of a REG DefaultValue-Add command.
  71.    ''' </summary>
  72.    Private Shared ReadOnly BatchStringFormat_DefaultValueAdd As String =
  73.    <a>REG ADD "{0}" /V "" /D {1} /F</a>.Value
  74.  
  75.    ''' <summary>
  76.    ''' Indicates the Batch syntax StringFormat of a REG Value-Add REG_SZ command.
  77.    ''' </summary>
  78.    Private Shared ReadOnly BatchStringFormat_ValueAdd_REGSZ As String =
  79.    <a>REG ADD "{0}" /V "{1}" /T "REG_SZ" /D "{2}" /F</a>.Value
  80.  
  81.    ''' <summary>
  82.    ''' Indicates the Batch command StringFormat of a REG Value-Add BINARY command.
  83.    ''' </summary>
  84.    Private Shared ReadOnly BatchStringFormat_ValueAdd_BINARY As String =
  85.    <a>REG ADD "{0}" /V "{1}" /T "REG_BINARY" /D "{2}" /F</a>.Value
  86.  
  87.    ''' <summary>
  88.    ''' Indicates the Batch syntax StringFormat of a REG Value-Add DWORD command.
  89.    ''' </summary>
  90.    Private Shared ReadOnly BatchStringFormat_ValueAdd_DWORD As String =
  91.    <a>REG ADD "{0}" /V "{1}" /T "REG_DWORD" /D "{2}" /F</a>.Value
  92.  
  93.    ''' <summary>
  94.    ''' Indicates the Batch syntax StringFormat of a REG Value-Add QWORD command.
  95.    ''' </summary>
  96.    Private Shared ReadOnly BatchStringFormat_ValueAdd_QWORD As String =
  97.    <a>REG ADD "{0}" /V "{1}" /T "REG_QWORD" /D "{2}" /F</a>.Value
  98.  
  99.    ''' <summary>
  100.    ''' Indicates the Batch syntax StringFormat of a REG Value-Add EXPAND_SZ command.
  101.    ''' </summary>
  102.    Private Shared ReadOnly BatchStringFormat_ValueAdd_EXPANDSZ As String =
  103.    <a>REG ADD "{0}" /V "{1}" /T "REG_EXPAND_SZ" /D "{2}" /F</a>.Value
  104.  
  105.    ''' <summary>
  106.    ''' Indicates the Batch syntax StringFormat of a REG Value-Add MULTI_SZ command.
  107.    ''' </summary>
  108.    Private Shared ReadOnly BatchStringFormat_ValueAdd_MULTISZ As String =
  109.    <a>REG ADD "{0}" /V "{1}" /T "REG_MULTI_SZ" /D "{2}" /F</a>.Value
  110.  
  111.    ''' <summary>
  112.    ''' Indicates the Batch syntax StringFormat of a REG Value-Delete command.
  113.    ''' </summary>
  114.    Private Shared ReadOnly BatchStringFormat_ValueDelete As String =
  115.    <a>REG DELETE "{0}" /V "{1}" /F</a>.Value
  116.  
  117.    ''' <summary>
  118.    ''' Indicates the string to split a BINARY registry line.
  119.    ''' </summary>
  120.    Private Shared ReadOnly RegistryValueSplitter_BINARY As String =
  121.    <a>=HEX</a>.Value
  122.  
  123.    ''' <summary>
  124.    ''' Indicates the string to split a DWORD registry line.
  125.    ''' </summary>
  126.    Private Shared ReadOnly RegistryValueSplitter_DWORD As String =
  127.    <a>=DWORD:</a>.Value
  128.  
  129.    ''' <summary>
  130.    ''' Indicates the string to split a QWORD registry line.
  131.    ''' </summary>
  132.    Private Shared ReadOnly RegistryValueSplitter_QWORD As String =
  133.    <a>=HEX\(b\):</a>.Value
  134.  
  135.    ''' <summary>
  136.    ''' Indicates the string to split a EXPAND_SZ registry line.
  137.    ''' </summary>
  138.    Private Shared ReadOnly RegistryValueSplitter_EXPANDSZ As String =
  139.    <a>=HEX\(2\):</a>.Value
  140.  
  141.    ''' <summary>
  142.    ''' Indicates the string to split a MULTI_SZ registry line.
  143.    ''' </summary>
  144.    Private Shared ReadOnly RegistryValueSplitter_MULTISZ As String =
  145.    <a>=HEX\(7\):</a>.Value
  146.  
  147.    ''' <summary>
  148.    ''' Indicates the string to split a REG_SZ registry line.
  149.    ''' </summary>
  150.    Private Shared ReadOnly RegistryValueSplitter_REGSZ As String =
  151.    <a>"="</a>.Value
  152.  
  153. #End Region
  154.  
  155. #Region " Enumerations "
  156.  
  157.    ''' <summary>
  158.    ''' Indicates the data type of a registry value.
  159.    ''' </summary>
  160.    Public Enum RegistryValueType As Integer
  161.  
  162.        ''' <summary>
  163.        ''' A null-terminated string.
  164.        ''' This will be either a Unicode or an ANSI string.
  165.        ''' </summary>
  166.        REG_SZ = 0
  167.  
  168.        ''' <summary>
  169.        ''' Binary data.
  170.        ''' </summary>
  171.        BINARY = 1
  172.  
  173.        ''' <summary>
  174.        ''' A 32-bit number.
  175.        ''' </summary>
  176.        DWORD = 2
  177.  
  178.        ''' <summary>
  179.        ''' A 64-bit number.
  180.        ''' </summary>
  181.        QWORD = 3
  182.  
  183.        ''' <summary>
  184.        ''' A null-terminated string that contains unexpanded references to environment variables
  185.        ''' (for example, "%WinDir%").
  186.        ''' </summary>
  187.        EXPAND_SZ = 4
  188.  
  189.        ''' <summary>
  190.        ''' A sequence of null-terminated strings, terminated by an empty string (\0).
  191.        '''
  192.        ''' The following is an example:
  193.        ''' String1\0String2\0String3\0LastString\0\0
  194.        ''' The first \0 terminates the first string,
  195.        ''' the second to the last \0 terminates the last string,
  196.        ''' and the final \0 terminates the sequence.
  197.        ''' Note that the final terminator must be factored into the length of the string.
  198.        ''' </summary>
  199.        MULTI_SZ = 5
  200.  
  201.    End Enum
  202.  
  203. #End Region
  204.  
  205. #Region " Public Methods "
  206.  
  207.    ''' <summary>
  208.    ''' Converts a Registry Script to a Batch Script.
  209.    ''' </summary>
  210.    ''' <param name="RegistryFile">Indicates the registry file to convert.</param>
  211.    ''' <returns>System.String.</returns>
  212.    Public Shared Function Convert(ByVal RegistryFile As String) As String
  213.  
  214.        ' Split the Registry content.
  215.        Dim RegistryContent As String() =
  216.            String.Join("@@@Reg2Bat@@@", File.ReadAllLines(RegistryFile)).
  217.                   Replace("\@@@Reg2Bat@@@  ", Nothing).
  218.                   Replace("@@@Reg2Bat@@@", Environment.NewLine).
  219.                   Split(Environment.NewLine)
  220.  
  221.        ' Where the registry line to convert will be stored.
  222.        Dim RegLine As String = String.Empty
  223.  
  224.        ' Where the registry key to convert will be stored.
  225.        Dim RegKey As String = String.Empty
  226.  
  227.        ' Where the registry value to convert will be stored.
  228.        Dim RegVal As String = String.Empty
  229.  
  230.        ' Where the registry data to convert will be stored.
  231.        Dim RegData As String = String.Empty
  232.  
  233.        ' Where the decoded registry strings will be stored.
  234.        Dim BatchCommands As New StringBuilder
  235.  
  236.        ' Writes the specified Batch-Script Header.
  237.        BatchCommands.AppendLine(BatchHeader)
  238.  
  239.        ' Start reading the Registry File.
  240.        For X As Long = 0 To RegistryContent.LongLength - 1
  241.  
  242.            RegLine = RegistryContent(X).Trim
  243.  
  244.            Select Case True
  245.  
  246.                Case RegLine.StartsWith(";"), RegLine.StartsWith("#")  ' It's a comment line.
  247.  
  248.                    BatchCommands.AppendLine(
  249.                        String.Format(BatchStringFormat_Comment, RegLine.Substring(1, RegLine.Length - 1).Trim))
  250.  
  251.                Case RegLine.StartsWith("[-") ' It's a key to delete.
  252.  
  253.                    RegKey = RegLine.Substring(2, RegLine.Length - 3).Trim
  254.                    BatchCommands.AppendLine(String.Format(BatchStringFormat_KeyDelete, RegKey))
  255.  
  256.                Case RegLine.StartsWith("[") ' It's a key to add.
  257.  
  258.                    RegKey = RegLine.Substring(1, RegLine.Length - 2).Trim
  259.                    BatchCommands.AppendLine(String.Format(BatchStringFormat_KeyAdd, RegKey))
  260.  
  261.                Case RegLine.StartsWith("@=") ' It's a default value to add.
  262.  
  263.                    RegData = RegLine.Split("@=").Last
  264.                    BatchCommands.AppendLine(String.Format(BatchStringFormat_DefaultValueAdd, RegKey, RegData))
  265.  
  266.                Case RegLine.StartsWith("""") _
  267.                AndAlso RegLine.Split("=").Last = "-" ' It's a value to delete.
  268.  
  269.                    RegVal = RegLine.Substring(1, RegLine.Length - 4)
  270.                    BatchCommands.AppendLine(String.Format(BatchStringFormat_ValueDelete, RegKey, RegVal))
  271.  
  272.                Case RegLine.StartsWith("""") ' It's a value to add.
  273.  
  274.                    Select Case RegLine.Split("=")(1).Split(":").First.ToUpper
  275.  
  276.                        Case "HEX" ' It's a Binary value.
  277.                            RegVal = FormatRegistryString(GetRegistryValue(RegLine, RegistryValueType.BINARY))
  278.                            RegData = GetRegistryData(RegLine, RegistryValueType.BINARY)
  279.                            BatchCommands.AppendLine(
  280.                                String.Format(BatchStringFormat_ValueAdd_BINARY, RegKey, RegVal, RegData))
  281.  
  282.                        Case "DWORD" ' It's a DWORD value.
  283.                            RegVal = FormatRegistryString(GetRegistryValue(RegLine, RegistryValueType.DWORD))
  284.                            RegData = GetRegistryData(RegLine, RegistryValueType.DWORD)
  285.                            BatchCommands.AppendLine(
  286.                                String.Format(BatchStringFormat_ValueAdd_DWORD, RegKey, RegVal, RegData))
  287.  
  288.                        Case "HEX(B)" ' It's a QWORD value.
  289.                            RegVal = FormatRegistryString(GetRegistryValue(RegLine, RegistryValueType.QWORD))
  290.                            RegData = GetRegistryData(RegLine, RegistryValueType.QWORD)
  291.                            BatchCommands.AppendLine(
  292.                                String.Format(BatchStringFormat_ValueAdd_QWORD, RegKey, RegVal, RegData))
  293.  
  294.                        Case "HEX(2)"  ' It's a EXPAND_SZ value.
  295.                            RegVal = FormatRegistryString(GetRegistryValue(RegLine, RegistryValueType.EXPAND_SZ))
  296.                            RegData = FormatRegistryString(GetRegistryData(RegLine, RegistryValueType.EXPAND_SZ))
  297.                            BatchCommands.AppendLine(
  298.                                String.Format(BatchStringFormat_ValueAdd_EXPANDSZ, RegKey, RegVal, RegData))
  299.  
  300.                        Case "HEX(7)" ' It's a MULTI_SZ value.
  301.                            RegVal = FormatRegistryString(GetRegistryValue(RegLine, RegistryValueType.MULTI_SZ))
  302.                            RegData = FormatRegistryString(GetRegistryData(RegLine, RegistryValueType.MULTI_SZ))
  303.                            BatchCommands.AppendLine(
  304.                                String.Format(BatchStringFormat_ValueAdd_MULTISZ, RegKey, RegVal, RegData))
  305.  
  306.                        Case Else ' It's a REG_SZ value.
  307.                            RegVal = FormatRegistryString(GetRegistryValue(RegLine, RegistryValueType.REG_SZ))
  308.                            RegData = FormatRegistryString(GetRegistryData(RegLine, RegistryValueType.REG_SZ))
  309.                            BatchCommands.AppendLine(
  310.                                String.Format(BatchStringFormat_ValueAdd_REGSZ, RegKey, RegVal, RegData))
  311.  
  312.                    End Select ' RegLine.Split("=")(1).Split(":").First.ToUpper
  313.  
  314.            End Select ' RegLine.StartsWith("""")
  315.  
  316.        Next X ' RegLine
  317.  
  318.        ' Writes the specified Batch-Script Footer.
  319.        BatchCommands.AppendLine(BatchFooter)
  320.  
  321.        Return BatchCommands.ToString
  322.  
  323.    End Function
  324.  
  325. #End Region
  326.  
  327. #Region " Private Methods "
  328.  
  329.    ''' <summary>
  330.    ''' Gets the registry value of a registry line.
  331.    ''' </summary>
  332.    ''' <param name="RegistryLine">Indicates the registry line.</param>
  333.    ''' <param name="RegistryValueType">Indicates the type of the registry value.</param>
  334.    ''' <returns>System.String.</returns>
  335.    Private Shared Function GetRegistryValue(ByVal RegistryLine As String,
  336.                                             ByVal RegistryValueType As RegistryValueType) As String
  337.  
  338.        Dim Value As String = String.Empty
  339.  
  340.        Select Case RegistryValueType
  341.  
  342.            Case RegistryValueType.BINARY
  343.                Value = Regex.Split(RegistryLine,
  344.                                    RegistryValueSplitter_BINARY,
  345.                                    RegexOptions.IgnoreCase Or RegexOptions.Singleline).First()
  346.  
  347.            Case RegistryValueType.DWORD
  348.                Value = Regex.Split(RegistryLine,
  349.                                    RegistryValueSplitter_DWORD,
  350.                                    RegexOptions.IgnoreCase Or RegexOptions.Singleline).First()
  351.  
  352.            Case RegistryValueType.QWORD
  353.                Value = Regex.Split(RegistryLine,
  354.                                    RegistryValueSplitter_QWORD,
  355.                                    RegexOptions.IgnoreCase Or RegexOptions.Singleline).First()
  356.  
  357.            Case RegistryValueType.EXPAND_SZ
  358.                Value = Regex.Split(RegistryLine,
  359.                                    RegistryValueSplitter_EXPANDSZ,
  360.                                    RegexOptions.IgnoreCase Or RegexOptions.Singleline).First()
  361.  
  362.            Case RegistryValueType.MULTI_SZ
  363.                Value = Regex.Split(RegistryLine,
  364.                                    RegistryValueSplitter_MULTISZ,
  365.                                    RegexOptions.IgnoreCase Or RegexOptions.Singleline).First()
  366.  
  367.            Case RegistryValueType.REG_SZ
  368.                Value = Regex.Split(RegistryLine,
  369.                                    RegistryValueSplitter_REGSZ,
  370.                                    RegexOptions.IgnoreCase Or RegexOptions.Singleline).First()
  371.  
  372.        End Select
  373.  
  374.        If Value.StartsWith("""") Then
  375.            Value = Value.Substring(1, Value.Length - 1)
  376.        End If
  377.  
  378.        If Value.EndsWith("""") Then
  379.            Value = Value.Substring(0, Value.Length - 1)
  380.        End If
  381.  
  382.        Return Value
  383.  
  384.    End Function
  385.  
  386.    ''' <summary>
  387.    ''' Gets the registry data of a registry line.
  388.    ''' </summary>
  389.    ''' <param name="RegistryLine">Indicates the registry line.</param>
  390.    ''' <param name="RegistryValueType">Indicates the type of the registry value.</param>
  391.    ''' <returns>System.String.</returns>
  392.    Private Shared Function GetRegistryData(ByVal RegistryLine As String,
  393.                                            ByVal RegistryValueType As RegistryValueType) As String
  394.  
  395.        Dim Data As String = String.Empty
  396.  
  397.        Select Case RegistryValueType
  398.  
  399.            Case RegistryValueType.BINARY
  400.  
  401.                Data = Regex.Split(RegistryLine,
  402.                                   Regex.Split(RegistryLine,
  403.                                               RegistryValueSplitter_BINARY, RegexOptions.IgnoreCase Or RegexOptions.Singleline).First &
  404.                                               RegistryValueSplitter_BINARY,
  405.                                   RegexOptions.IgnoreCase Or RegexOptions.Singleline).
  406.                                   Last.
  407.                                   Replace(",", Nothing)
  408.  
  409.            Case RegistryValueType.DWORD
  410.  
  411.                Data = Regex.Split(RegistryLine,
  412.                                   Regex.Split(RegistryLine,
  413.                                               RegistryValueSplitter_DWORD, RegexOptions.IgnoreCase Or RegexOptions.Singleline).First &
  414.                                               RegistryValueSplitter_DWORD,
  415.                                   RegexOptions.IgnoreCase Or RegexOptions.Singleline).
  416.                                   Last.
  417.                                   Replace(",", Nothing)
  418.  
  419.                Data = "0x" & Data
  420.  
  421.            Case RegistryValueType.QWORD
  422.  
  423.                RegistryLine =
  424.                    String.Join(Nothing,
  425.                                Regex.Split(RegistryLine,
  426.                                            Regex.Split(RegistryLine,
  427.                                                        RegistryValueSplitter_QWORD, RegexOptions.IgnoreCase Or RegexOptions.Singleline).First &
  428.                                                        RegistryValueSplitter_QWORD,
  429.                                            RegexOptions.IgnoreCase Or RegexOptions.Singleline).
  430.                                            Last.
  431.                                            Reverse)
  432.  
  433.                For Each [Byte] As String In RegistryLine.Split(",")
  434.                    Data &= String.Join(Nothing, [Byte].Reverse)
  435.                Next [Byte]
  436.  
  437.                Data = "0x" & Data
  438.  
  439.            Case RegistryValueType.EXPAND_SZ
  440.  
  441.                RegistryLine = Regex.Split(RegistryLine,
  442.                                            Regex.Split(RegistryLine,
  443.                                                        RegistryValueSplitter_EXPANDSZ, RegexOptions.IgnoreCase Or RegexOptions.Singleline).First &
  444.                                                        RegistryValueSplitter_EXPANDSZ,
  445.                                            RegexOptions.IgnoreCase Or RegexOptions.Singleline).
  446.                                            Last.
  447.                                            Replace(",00", "").
  448.                                            Replace("00,", "")
  449.  
  450.                For Each [Byte] As String In RegistryLine.Split(",")
  451.                    Data &= Chr(Val("&H" & [Byte]))
  452.                Next [Byte]
  453.  
  454.                Data = Data.Replace("""", "\""")
  455.  
  456.            Case RegistryValueType.MULTI_SZ
  457.  
  458.                RegistryLine = Regex.Split(RegistryLine,
  459.                                            Regex.Split(RegistryLine,
  460.                                                        RegistryValueSplitter_MULTISZ, RegexOptions.IgnoreCase Or RegexOptions.Singleline).First &
  461.                                                        RegistryValueSplitter_MULTISZ,
  462.                                            RegexOptions.IgnoreCase Or RegexOptions.Singleline).
  463.                                            Last.
  464.                                            Replace(",00,00,00", ",\0").
  465.                                            Replace(",00", "").
  466.                                            Replace("00,", "")
  467.  
  468.                For Each [Byte] In RegistryLine.Split(",")
  469.  
  470.                    If [Byte] = "\0" Then
  471.                        Data &= "\0" ' Multiline separator.
  472.                    Else
  473.                        Data &= Chr(Val("&H" & [Byte]))
  474.                    End If
  475.  
  476.                Next
  477.  
  478.                Return Data.Replace("""", "\""")
  479.  
  480.            Case RegistryValueType.REG_SZ
  481.  
  482.                Data = Regex.Split(RegistryLine,
  483.                                   Regex.Split(RegistryLine,
  484.                                               RegistryValueSplitter_REGSZ, RegexOptions.IgnoreCase Or RegexOptions.Singleline).First &
  485.                                               RegistryValueSplitter_REGSZ,
  486.                                   RegexOptions.IgnoreCase Or RegexOptions.Singleline).
  487.                                   Last
  488.  
  489.                Data = Data.Substring(0, Data.Length - 1).Replace("\\", "\")
  490.  
  491.        End Select
  492.  
  493.        Return Data
  494.  
  495.    End Function
  496.  
  497.    ''' <summary>
  498.    ''' Properly formats a registry string to insert it in a Batch command string.
  499.    ''' </summary>
  500.    ''' <param name="RegistryString">Indicates the Reg Batch command string.</param>
  501.    ''' <returns>System.String.</returns>
  502.    Private Shared Function FormatRegistryString(ByVal RegistryString As String) As String
  503.  
  504.        RegistryString = RegistryString.Replace("%", "%%")
  505.        If Not RegistryString.Contains("""") Then
  506.            Return RegistryString
  507.        End If
  508.  
  509.        RegistryString = RegistryString.Replace("\""", """")
  510.  
  511.        Dim strArray() As String = RegistryString.Split("""")
  512.  
  513.        For X As Long = 1 To strArray.Length - 1 Step 2
  514.  
  515.            strArray(X) = strArray(X).Replace("^", "^^") ' This replacement need to be THE FIRST.
  516.            strArray(X) = strArray(X).Replace("<", "^<")
  517.            strArray(X) = strArray(X).Replace(">", "^>")
  518.            strArray(X) = strArray(X).Replace("|", "^|")
  519.            strArray(X) = strArray(X).Replace("&", "^&")
  520.            ' strArray(X) = strArray(X).Replace("\", "\\")
  521.  
  522.        Next X
  523.  
  524.        Return String.Join("\""", strArray)
  525.  
  526.    End Function
  527.  
  528. #End Region
  529.  
  530. #Region " Hidden methods "
  531.  
  532.    ' These methods are purposely hidden from Intellisense just to look better without unneeded methods.
  533.    ' NOTE: The methods can be re-enabled at any-time if needed.
  534.  
  535.    <EditorBrowsable(EditorBrowsableState.Never)>
  536.    Public Shadows Sub Equals()
  537.    End Sub
  538.  
  539.    <EditorBrowsable(EditorBrowsableState.Never)>
  540.    Public Shadows Sub ReferenceEquals()
  541.    End Sub
  542.  
  543. #End Region
  544.  
  545. End Class
7497  Programación / Programación General / Re: JAVA en: 27 Enero 2014, 23:07 pm
Hola

Debes saber que hay un buscador en el foro que se puede usar para encontrar tutoriales de iniciación, además dispones de una sección entera dedicada a Java, y otra sección de Programación general donde además, por si fuera poco, adentro de ambas secciones existen temas importantes colgados con chinchetas relacionados con lo que andas buscando ...pero es una pena que siempre haya alguien que no lea las normas del foro, ni los temas con chincheta, ni use el buscador del foro, ni busque en Google.       ...como es el caso.

Saludos!
7498  Programación / Programación General / Re: Cómo cambiar el hash de un archivo en: 27 Enero 2014, 22:12 pm

Nota: Esta última versión la estoy haciendo en .NET


por poner un ejemplo podrías probar a ofuscar tu ensamblado y/o empaquetarlo.

EDITO: Aqui tienes algunas herramientas ~> VISUAL STUDIO 2013 ELEKTRO ULTIMATE PACK

PD: Las preguntas relacionadas con .NET van en el subforo de .NET.

saludos!
7499  Foros Generales / Foro Libre / Re: ¿Os descargais series y peliculas? en: 27 Enero 2014, 22:01 pm
Es "malo" o "criminal" un mendigo que roba una barra de pan? Pues quizás opineis que si, pero para mi se llama "supervivencia" o "justicia".

robar siempre es malo, no trates de justificarlo de esa manera, si es cierto que no es lo mismo robar por necesidad que por avaricia, pero robar es robar y esta mal.

Pues yo tengo el mismo punto de perspectiva que @Zomkar...

Robar ni está mal ni está bien, podriamos iniciar un tema sobre la ética y el significado del bien o el mal donde llegariamos a la conclusión de que sólamente son conceptos, no cosas reales, y por ende robar es un hecho, una acción ...y nada más, ni está bien ni está mal ...simplemente unos tendrán el concepto de que es algo positivo, y otros el concepto de que es algo negativo, y quien decide si está bien o mal como para escribirlo en una Ley ...no pinta nada.

Esto yo no lo digo para justificar, lo digo porque es la realidad, si un mendigo roba por necesidad ...yo no le aplaudiré, pero mucho menos le castigaré por haberlo echo.

...Pues con el tema de la pirateria me parece exáctamente igual, es algo necesario, a menos que sea una oveja del rebaño que esté dispuesta a ser engañada y pagar un precio que no debería ser así, claro...como la ley dice que tienes que pagarlo y no puedes copiarlo... ¿acaso yo he tomado parte en la decisión de que esa la ley de pirateria exista por el bien común de todos?, no, pues para mi esa ley no existe, igual que muchas otras leyes ridículas como darse un beso en la calle (creo que era en Francia). porque exista una ley que diga algo, eso no tiene que ser lo correcto, y yo me guio por lo que pienso que es correcto y lo que no, no por lo que la ley de "X" pais me diga lo que no se puede hacer "porque sí".

Saludos!
7500  Foros Generales / Foro Libre / Re: ¿Os descargais series y peliculas? en: 27 Enero 2014, 21:22 pm
El producto final que venden las compañias (películas, videojuegos) es demasiado caro, y cada vez más, la piratería hoy en día es aceptado por el 99,9% y es lo más normal del mundo porque no somos tontos, y nos damos cuentas de que el precio original de su venta es desconmesurada, no equivale al esfuerzo que han dedicado para hacer el producto (tener en cuenta que las ganancias se de ellos se cuentan en decenas o cientos o miles d millones de dolares, no en solo los 60€ que tu pagas por comprar ese producto, decidme a quien de ustedes les pagan esa cantidad por vender algo?...), así que si eso no cambia nunca ...tampoco lo haremos nosotros, el robo es lo que las compañias intentan hacer, descargarse una película no es robar, es compartir.



Saludos!
Páginas: 1 ... 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 [750] 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 ... 1236
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines