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

 

 


Tema destacado: Entrar al Canal Oficial Telegram de elhacker.net


  Mostrar Mensajes
Páginas: 1 ... 733 734 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 ... 1236
7471  Programación / Scripting / Re: [APORTE] [VBS] Snippets para manipular reglas de bloqueo del firewall de Windows en: 3 Febrero 2014, 20:19 pm
Al final, como dije, añadí estas opciones al menú contextual (para archivos executables sólamente)



También hice un instalador, si alguien lo quiere... ~> http://www.mediafire.com/download/e8chmiqq6behvmc/Firewall.exe

Un saludo!
7472  Programación / .NET (C#, VB.NET, ASP) / Re: Combinaciones letras o numeros en: 3 Febrero 2014, 19:01 pm
12 13 55 <--asi es que me hacen falta

¿Y esta linea no te dice nada?:

Código
  1. TextBox2.Text = String.Join("; ", RandomizeArray(IntArray))

...Es que vamos!!!, Luis, joer... esta claro q no hay manera...

Para separar los números por un espacio, pues, muy óbviamente, debes modificar el string que usas como separador:

Código:
String.Join(Separador, Colección)

Ejemplo:
Código
  1. MsgBox(String.Join(Convert.ToChar(Keys.Space), {1I, 2I, 3I, 4I, 5I}.ToArray))


Y para lo de seleccionar "pares" de elementos no te aconsejo hacelro desde la función, haz las cosas de forma ordenada,
primero desordenas todos los elementos del array, y luego ese array desordenado (que contiene todos los números) lo usas para ir sacando los que quieras ...esto lo puedes automatizar con un For o usando Linq:

Código
  1. Public Class Form1
  2.  
  3.    Private Shadows Sub Shown() Handles MyBase.Shown
  4.  
  5.        Dim Elementos As Integer() =
  6.        {
  7.          1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
  8.          11, 12, 13, 14, 15, 16, 17, 18
  9.        }
  10.  
  11.        For X As Integer = 0 To Elementos.Count - 1 Step 4
  12.  
  13.            MessageBox.Show(
  14.                String.Format("{0} {1} {2} {3}",
  15.                    Elementos(X),
  16.                    If(Not (X + 1) >= Elementos.Count, Elementos(X + 1), String.Empty),
  17.                    If(Not (X + 2) >= Elementos.Count, Elementos(X + 2), String.Empty),
  18.                    If(Not (X + 3) >= Elementos.Count, Elementos(X + 3), String.Empty),
  19.                    "Cuatro Elementos"
  20.                )
  21.            )
  22.  
  23.        Next X
  24.  
  25.        Application.Exit()
  26.  
  27.    End Sub
  28.  
  29. End Class


O puedes hacerlo de forma mas manual:
Código
  1.    Public Class Form1
  2.  
  3.    Private Sub Form1_Load() Handles MyBase.Load
  4.  
  5.        Dim Elementos As Integer() =
  6.        {
  7.          1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
  8.          11, 12, 13, 14, 15, 16, 17, 18
  9.        }
  10.  
  11.        Dim Cantidad As Integer = 4
  12.  
  13.        Dim Primeros_Cuatro_Elementos As Integer() =
  14.            (From Elemento As Integer In Elementos
  15.             Take Cantidad).ToArray
  16.  
  17.        Dim Siguientes_Cuatro_Elementos As Integer() =
  18.            (From Elemento As Integer In Elementos
  19.             Skip Primeros_Cuatro_Elementos.Count
  20.             Take Cantidad).ToArray
  21.  
  22.        Dim Todo_El_Resto_De_Elementos As Integer() =
  23.            (From Elemento As Integer In Elementos
  24.             Skip Primeros_Cuatro_Elementos.Count _
  25.             +
  26.             Siguientes_Cuatro_Elementos.Count).ToArray
  27.  
  28.        MessageBox.Show(String.Join(Convert.ToChar(Keys.Space), Primeros_Cuatro_Elementos), "Primeros_Cuatro_Elementos")
  29.        MessageBox.Show(String.Join(Convert.ToChar(Keys.Space), Siguientes_Cuatro_Elementos), "Siguientes_Cuatro_Elementos")
  30.        MessageBox.Show(String.Join(Convert.ToChar(Keys.Space), Todo_El_Resto_De_Elementos), "Todo_El_Resto_De_Elementos")
  31.  
  32.        Application.Exit()
  33.  
  34.    End Sub
  35.  
  36. End Class

Saludos.
7473  Programación / Scripting / [APORTE] [VBS] Snippets para manipular reglas de bloqueo del firewall de Windows en: 3 Febrero 2014, 11:56 am
Bueno, he codeado este mini Script para determinar si un proceso (existente) tiene las conexiones entrantes o salientes bloqueadas por el firewall de Windows.

Mi intención es usar este script desde unas opciones que crearé en el menú contextual de Windows para bloquear conexiones, desbloquear, y comprobar si un proceso ya está bloqueado.

EDITO: Mejorado.
Código
  1. ' *********************
  2. ' FirewallRuleCheck.vbs
  3. ' *********************
  4. ' By Elektro
  5.  
  6.  
  7. ' ------------
  8. ' Description:
  9. ' ------------
  10. '
  11. ' This script determines whether a program has the Inbound or Outbound connections blocked by the Windows Firewall rules.
  12. '
  13. ' NOTE: Possibly this script will not work under Windows XP where;
  14. '       the Netsh syntax is different and maybe the Firewall registry values could be diferent too, I've don't tested it.
  15. '       Tested on Windows 8.
  16.  
  17.  
  18. ' -------
  19. ' Syntax:
  20. ' -------
  21. '
  22. ' FirewallRuleCheck.vbs "[File]" "[ConnectionType]" "[ReturnResult]"
  23.  
  24.  
  25. ' -----------
  26. ' Parameters:
  27. ' -----------
  28. '
  29. ' [File]
  30. ' This parameter indicates the file to check their connection status.
  31. ' The value should be the relative or absolute filepath of an existing file.
  32. '
  33. ' [ConnectionType]
  34. ' This parameter indicates whether to check inbound or outbound connection status.
  35. ' The value should be "In" or "Out".
  36. '
  37. ' [ReturnResult]
  38. ' This parameter indicates whether the result should be returned without displaying any info;
  39. ' for example, when calling this script from other script to expect a Boolean result.
  40. ' The value is Optional, and should be "True" or "False". Default value is "False".
  41.  
  42.  
  43. ' ---------------
  44. ' Usage examples:
  45. ' ---------------
  46. '
  47. ' FirewallRuleCheck.vbs "C:\Program.exe"  IN
  48. ' FirewallRuleCheck.vbs "C:\Program.exe" OUT
  49. ' BooleanExitCode = FirewallRuleCheck.vbs "C:\Program.exe"  IN True
  50. ' BooleanExitCode = FirewallRuleCheck.vbs "C:\Program.exe" OUT True
  51.  
  52.  
  53. ' -----------
  54. ' Exit codes:
  55. ' -----------
  56. '
  57. ' When 'ReturnResult' parameter is set to 'False':
  58. '      0: Successful exit.
  59. '      1: Missing arguments or too many arguments.
  60. '      2: File not found.
  61. '      3: Wrong value specified for parameter '[ConnectionType]'
  62. '      4: Wrong value specified for parameter '[ReturnResult]'
  63. '      5: Specific Error.
  64. '
  65. ' When 'ReturnResult' parameter is set to 'True':
  66. '     -1: 'True'  (Rule is not added).
  67. '      0: 'False' (Rule is already added).
  68. '      (All the other ExitCodes: '1', '2', '3', '4' and '5' can happen in this mode, except '0')
  69.  
  70.  
  71. ' *************
  72. Option Explicit
  73.  
  74. Const MsgBoxSyntax   = "FirewallRuleCheck.vbs ""[File]"" ""[ConnectionType]"" ""[ReturnResult]"""
  75. Const MsgBoxCaption  = "Firewall Rule Check"
  76. Const MsgBoxErrorIco = 16
  77. Const MsgBoxInfoIco  = 64
  78. Const MsgBoxDebugIco = 48
  79.  
  80. Dim objFile        ' Indicates the file object.
  81. Dim objReg         ' Indicates the registry object.
  82. Dim Root           ' Indicates the root registry key.
  83. Dim Key            ' Indicates the registry key.
  84. Dim MatchData      ' Indicates the data to match.
  85. Dim Values         ' Indicates the registry value collection.
  86. Dim Value          ' Indicates the registry value.
  87. Dim Data           ' Indicates the registry data.
  88. Dim DataIsMatched  ' Indicates whether the data is matched.
  89. Dim ConnectionType ' Indicates whether to check inbound or outbound connection status.
  90. Dim ReturnResult   ' Indicates whether the result should be returned without displaying any info;
  91.                   ' for example, when calling this script from other script to expect a Boolean result.
  92. Dim DebugMode      ' Indicates whether the debug mode is activated.
  93.  
  94.  
  95. ' Set the debug mode to 'True' if need to test the values.
  96. DebugMode = False
  97.  
  98. ' Set the 'HKEY_LOCAL_MACHINE' as Root registry key.
  99. Root = &H80000002
  100.  
  101. ' Set the Firewall rules registry location as key.
  102. Key = "SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\FirewallRules"
  103.  
  104. ' Sets the Registry object.
  105. Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
  106.  
  107. ' Argument error handling.
  108. If Wscript.Arguments.Count = 0 Then
  109.  
  110. ' Notify the error to the user.
  111. MsgBox "Syntax:" & VBNewLine & _
  112.       MsgBoxSyntax          , _
  113.       MsgBoxErrorIco, MsgBoxCaption
  114.  
  115. ' Exit with reason: 'Missing arguments'.
  116. Wscript.Quit(1)
  117.  
  118. ElseIf Wscript.Arguments.Count < 2 Then
  119.  
  120. ' Notify the error to the user.
  121. MsgBox "Missing arguments."  & _
  122.       VBNewLine & VBNewLine & _
  123.       "Syntax:" & VBNewLine & _
  124.       MsgBoxSyntax          , _
  125.       MsgBoxErrorIco, MsgBoxCaption
  126.  
  127. ' Exit with reason: 'Missing arguments'.
  128. Wscript.Quit(1)
  129.  
  130. ElseIf Wscript.Arguments.Count = 3 Then
  131.  
  132. If LCase(Wscript.Arguments(2)) = LCase("True") Then
  133. ReturnResult = True
  134.  
  135. Elseif LCase(Wscript.Arguments(2)) = LCase("False") Then
  136. ReturnResult = False
  137.  
  138. Else
  139.  
  140. ' Notify the error to the user.
  141. MsgBox "Wrong value specified for parameter 'Return Result'", _
  142.       MsgBoxErrorIco, MsgBoxCaption
  143.  
  144. ' Exit with reason: 'Wrong value specified for parameter '[Return Result]''.
  145. Wscript.Quit(4)
  146.  
  147. End If
  148.  
  149. ElseIf Wscript.Arguments.Count > 3 Then
  150.  
  151. ' Notify the error to the user.
  152. MsgBox "Too many arguments." & _
  153.       VBNewLine & VBNewLine & _
  154.       "Syntax:" & VBNewLine & _
  155.       MsgBoxSyntax          , _
  156.       MsgBoxErrorIco, MsgBoxCaption
  157.  
  158. ' Exit with reason: 'Too many arguments'.
  159. Wscript.Quit(1)
  160.  
  161. End If
  162.  
  163. On Error Resume Next
  164.  
  165. ' Set the FileObject with the file passed through the first argument.
  166. Set objFile = Createobject("Scripting.FileSystemObject"). _
  167.              GetFile(Wscript.Arguments(0))
  168.  
  169. ' File-Error handling.
  170. If Err.Number = 53 Then
  171.  
  172. ' Notify the error to the user.
  173. MsgBox "File not found:"   & _
  174.       vbnewline           & _
  175.       Wscript.Arguments(0), _
  176.       MsgBoxErrorIco, MsgBoxCaption
  177.  
  178. ' Exit with reason: 'File not found'.
  179. Wscript.Quit(2)
  180.  
  181. End If
  182.  
  183. ' Set the partial data to match on each value-data.
  184. If LCase(Wscript.Arguments(1)) = LCase("IN") Then
  185.  
  186. ' Set the ConnectionType to 'Inbound'
  187. ConnectionType = "Inbound"
  188.  
  189. Elseif LCase(Wscript.Arguments(1)) = LCase("OUT") Then
  190.  
  191. ' Set the ConnectionType to 'Outbound'
  192. ConnectionType = "Outbound"
  193.  
  194. Else ' Wrong argument.
  195.  
  196. ' Notify the error to the user.
  197. MsgBox "Wrong value specified for parameter '[ConnectionType]'", _
  198.       MsgBoxErrorIco, MsgBoxCaption
  199.  
  200. ' Exit with reason: 'Wrong value specified for parameter '[ConnectionType]''.
  201. Wscript.Quit(3)
  202.  
  203. End If
  204.  
  205. ' Set the data to match (It's a portion of the firewall rule).
  206. MatchData = "Action=Block|Active=TRUE|Dir=" & Wscript.Arguments(1) & "|App=" & objFile.Path
  207.  
  208. ' Enumerate the registry values.
  209. objReg.EnumValues Root, Key, Values
  210.  
  211. If DebugMode Then
  212.  
  213. ' Notify the debug information.
  214. MsgBox "File: "            & objFile.Path   & vbnewline & vbnewline & _
  215.       "ConnectionType: "  & ConnectionType & vbnewline & vbnewline & _
  216.       "Key: "             & Key            & vbnewline & vbnewline & _
  217.       "Value count: "     & UBound(Values) & vbnewline & vbnewline & _
  218.       "MatchData: "       & MatchData      & vbnewline             , _
  219.       MsgBoxDebugIco,     "Debug Info | "  & MsgBoxCaption
  220.  
  221. End If
  222.  
  223. ' Loop through the enumerated registry values.
  224. For Each Value In Values
  225.  
  226. ' Get the registry data.
  227. objReg.GetStringValue Root, Key, Value, Data
  228.  
  229. ' If registry data is not empty then...
  230. If Not IsNull(Data) Then
  231. ' Match the partial data onto the registry data.
  232.  
  233. ' If partial data matched in into the data then...
  234. If InStr(1, Data, MatchData, 1) Then
  235.  
  236. ' Set the DataIsMatched flag to 'True'.
  237. DataIsMatched = True
  238.  
  239. ' ...and stop the iteration.
  240. Exit For
  241.  
  242. End If ' // InStr()
  243.  
  244. End If ' // IsNull()
  245.  
  246. Next ' // Value
  247.  
  248. ' Error handling.
  249. If Err.Number <> 0 Then
  250.  
  251. ' Notify the error to the user.
  252. MsgBox "Error Code: "   & Err.Number & vbnewline & _
  253.       "Error Source: " & Err.Source & vbnewline & _
  254.       "Description: "  & Err.Description        , _
  255.       MsgBoxErrorIco, MsgBoxCaption
  256.  
  257. ' Exit with reason: 'Specific error'.
  258. Wscript.Quit(5)
  259.  
  260. End If
  261.  
  262. If ReturnResult Then
  263.  
  264. If DataIsMatched = True Then
  265. ' Exit with boolean result 'True' (Rule already exist).
  266. Wscript.Quit(-1)
  267. Else
  268. ' Exit with boolean result 'False' (Rule doesn't exist).
  269. Wscript.Quit(0)
  270. End If
  271.  
  272. End If
  273.  
  274. ' This (ridiculous) conversion is needed;
  275. ' because the VBS engine prints the boolean value into a MsgBox;
  276. ' according to the OS language ( Spanish: Verdadero|Falso )
  277. If DataIsMatched = True Then
  278. DataIsMatched = "True"
  279. Else
  280. DataIsMatched = "False"
  281. End If
  282.  
  283. ' Notify the information to the user.
  284. MsgBox "File: "       & objFile.Name    & vbnewline & _
  285.       "Connection: " & ConnectionType  & vbnewline & _
  286.       "Blocked?: "   & DataIsMatched               , _
  287.       MsgBoxInfoIco, MsgBoxCaption
  288.  
  289. ' Exit successfully.
  290. Wscript.Quit(0)

Ejemplos de uso:

Código:
Wscript.exe ThisScript.vbs "C:\Program.exe" IN

Código:
Wscript.exe ThisScript.vbs "C:\Program.exe" OUT

PD: No sé si funcionará en WindowsXP, por que Netsh usa una sintaxis distinta a las versiones posteriores de Windows y supongo que en los valores de las claves de las reglas del Firewall también se verán reflejados estos cambios de sintaxis, no lo sé, no lo he comprobado.

Saludos!





Otro script, para añadir reglas de bloqueo de conexiones entrantes o salientes del firewall de Windows:

( Estos scripts dependen del primer script, 'FirewallRuleCheck.vbs', puesto que llaman a dicho script para verificar si una regla existe o si no existe )

EDITO: Mejorado
Código
  1. ' *******************
  2. ' FirewallRuleAdd.vbs
  3. ' *******************
  4. ' By Elektro
  5.  
  6.  
  7. ' ------------
  8. ' Description:
  9. ' ------------
  10. '
  11. ' This Script adds a Firewall rule to block the Inbound or Outbound connections of a file.
  12. '
  13. ' NOTE: Possibly this script will not work under Windows XP where;
  14. '       the Netsh syntax is different and maybe the Firewall registry values could be diferent too, I've don't tested it.
  15. '       Tested on Windows 8.
  16.  
  17.  
  18. ' -------
  19. ' Syntax:
  20. ' -------
  21. '
  22. ' FirewallRuleAdd.vbs "[File]" "[ConnectionType]"
  23.  
  24.  
  25. ' -----------
  26. ' Parameters:
  27. ' -----------
  28. '
  29. ' [File]
  30. ' This parameter indicates the file to block.
  31. ' The value should be the relative or absolute filepath of an existing file.
  32. '
  33. ' [ConnectionType]
  34. ' This parameter indicates whether to add a rule to block inbound or outbound connections.
  35. ' The value should be "In" or "Out".
  36.  
  37.  
  38. ' ---------------
  39. ' Usage examples:
  40. ' ---------------
  41. '
  42. ' FirewallRuleAdd.vbs "C:\Program.exe" IN
  43. ' FirewallRuleAdd.vbs "C:\Program.exe" OUT
  44.  
  45.  
  46. ' -----------
  47. ' Exit codes:
  48. ' -----------
  49. '
  50. ' -1: Rule already exist.
  51. '  0: Successful exit.
  52. '  1: Missing arguments or too many arguments.
  53. '  2: File not found.
  54. '  3: Wrong value specified for parameter '[ConnectionType]'
  55. '  4: Specific Error.
  56.  
  57.  
  58. ' *************
  59. Option Explicit
  60.  
  61. Const MsgBoxSyntax   = "FirewallRuleAdd.vbs ""[File]"" ""[ConnectionType]"""
  62. Const MsgBoxCaption  = "Firewall Rule Add"
  63. Const MsgBoxErrorIco = 16
  64. Const MsgBoxInfoIco  = 64
  65. Const MsgBoxDebugIco = 48
  66.  
  67. Dim objFile        ' Indicates the File Object.
  68. Dim Process        ' Indicates the process to run.
  69. Dim Arguments      ' Indicates the process arguments.
  70. Dim Result         ' Indicates the result (Exit Code) of the process.
  71. Dim ConnectionType ' Indicates whether to block inbound or outbound connections.
  72. Dim DebugMode      ' Indicates whether the debug mode is activated.
  73.  
  74.  
  75. ' Set the debug mode to 'True' if need to test the values.
  76. DebugMode = False
  77.  
  78. ' Argument error handling.
  79. If Wscript.Arguments.Count = 0 Then
  80.  
  81. ' Notify the error to the user.
  82. MsgBox "Syntax:" & VBNewLine & _
  83.       MsgBoxSyntax          , _
  84.       MsgBoxErrorIco, MsgBoxCaption
  85.  
  86. ' Exit with reason: 'Missing arguments' error-code.
  87. Wscript.Quit(1)
  88.  
  89. ElseIf Wscript.Arguments.Count < 2 Then
  90.  
  91. ' Notify the error to the user.
  92. MsgBox "Missing arguments."  & _
  93.       VBNewLine & VBNewLine & _
  94.       "Syntax:" & VBNewLine & _
  95.       MsgBoxSyntax          , _
  96.       MsgBoxErrorIco, MsgBoxCaption
  97.  
  98. ' Exit with reason: 'Missing arguments'.
  99. Wscript.Quit(1)
  100.  
  101. ElseIf Wscript.Arguments.Count > 2 Then
  102.  
  103. ' Notify the error to the user.
  104. MsgBox "Too many arguments." & _
  105.       VBNewLine & VBNewLine & _
  106.       "Syntax:" & VBNewLine & _
  107.       MsgBoxSyntax          , _
  108.       MsgBoxErrorIco, MsgBoxCaption
  109.  
  110. ' Exit with reason: 'Too many arguments'.
  111. Wscript.Quit(1)
  112.  
  113. ElseIf Wscript.Arguments.Count = 2 Then
  114.  
  115. If LCase(Wscript.Arguments(1)) = LCase("IN") Then
  116.  
  117. ' Set the ConnectionType to 'Inbound'
  118. ConnectionType = "Inbound"
  119.  
  120. Elseif LCase(Wscript.Arguments(1)) = LCase("OUT") Then
  121.  
  122. ' Set the ConnectionType to 'Outbound'
  123. ConnectionType = "Outbound"
  124.  
  125. Else ' Wrong argument.
  126.  
  127. ' Notify the error to the user.
  128. MsgBox "Wrong value specified for parameter '[ConnectionType]'", _
  129.       MsgBoxErrorIco, MsgBoxCaption
  130.  
  131. ' Exit with reason: 'Wrong value specified for parameter '[ConnectionType]''.
  132. Wscript.Quit(3)
  133.  
  134. End If
  135.  
  136. End If
  137.  
  138. On Error Resume Next
  139.  
  140. ' Set the FileObject with the file passed through the first argument.
  141. Set objFile = Createobject("Scripting.FileSystemObject"). _
  142.              GetFile(Wscript.Arguments(0))
  143.  
  144. ' File-Error handling.
  145. If Err.Number = 53 Then
  146.  
  147. ' Notify the error to the user.
  148. MsgBox "File not found:"   & _
  149.       vbnewline           & _
  150.       Wscript.Arguments(0), _
  151.       MsgBoxErrorIco, MsgBoxCaption
  152.  
  153. ' Exit with reason: 'File not found'.
  154. Wscript.Quit(2)
  155.  
  156. End If
  157.  
  158. ' Set the firewall process.
  159. Process   = "netsh.exe"
  160.  
  161. ' Set the firewall rule parameters to add Inbound or Outbound blocking rule.
  162. Arguments = "AdvFirewall Firewall Add Rule"       & _
  163.            " Name=" & """" & objFile.Name & """" & _
  164.            " Dir="  & Wscript.Arguments(1)       & _
  165.            " Action=Block"                       & _
  166.            " Program=" & """" & objFile.Path & """"
  167.  
  168. ' Call the 'FirewallRuleCheck' script to retrieve their exit code;
  169. ' This way I determine whether the bloking rule already exist or not.
  170. Result = WScript.CreateObject("WScript.Shell"). _
  171.         Run("FirewallRuleCheck.vbs"    & " " & _
  172.             """" & objFile.Path & """" & " " & _
  173.             Wscript.Arguments(1)       & " " & _
  174.             "True", 0, True)
  175.  
  176. If DebugMode Then
  177.  
  178. ' Notify the debug information.
  179. MsgBox "File: "            & objFile.Path   & vbnewline & vbnewline & _
  180.       "ConnectionType: "  & ConnectionType & vbnewline & vbnewline & _
  181.       "Process: "         & Process        & vbnewline & vbnewline & _
  182.       "Arguments: "       & Arguments      & vbnewline & vbnewline & _
  183.       "Reult: "           & Result         & vbnewline             , _
  184.       MsgBoxDebugIco,     "Debug Info | "  & MsgBoxCaption
  185.  
  186. End If
  187.  
  188. ' Error handling.
  189. If Err.Number <> 0 Then
  190.  
  191. ' Notify the error to the user.
  192. MsgBox "Error Code: "   & Err.Number & vbnewline & _
  193.       "Error Source: " & Err.Source & vbnewline & _
  194.       "Description: "  & Err.Description        , _
  195.       MsgBoxErrorIco, MsgBoxCaption
  196.  
  197. ' Exit with reason: 'Specific error'.
  198. Wscript.Quit(5)
  199.  
  200. End If
  201.  
  202. If Result = -1 Then ' Rule already exist.
  203.  
  204. ' Notify the error to the user.
  205. MsgBox ConnectionType & " connection blocking rule already exist for file:" & _
  206.       vbnewline                                                            & _
  207.       objFile.Name                                                         , _
  208.       MsgBoxErrorIco, MsgBoxCaption
  209.  
  210. ' Exit with reason: 'Rule already exist'.
  211. Wscript.Quit(-1)
  212.  
  213. Else ' Rule added successfully.
  214.  
  215. WScript.CreateObject("WScript.Shell").Run Process & " " & Arguments, 0, True
  216.  
  217. ' Notify the information to the user.
  218. MsgBox ConnectionType & " connection blocking rule successfully added for file:" & _
  219.       vbnewline                                                                 & _
  220.       objFile.Name                                                              , _
  221.       MsgBoxInfoIco, MsgBoxCaption
  222.  
  223. End If
  224.  
  225. ' Exit successfully.
  226. Wscript.Quit(0)





Y otro para eliminar reglas:

EDITO: Mejorado
Código
  1. ' *******************
  2. ' FirewallRuleDel.vbs
  3. ' *******************
  4. ' By Elektro
  5.  
  6.  
  7. ' ------------
  8. ' Description:
  9. ' ------------
  10. '
  11. ' This Script deletes an existing firewall rule that is blocking the Inbound or Outbound connections of a file.
  12. '
  13. ' NOTE: Possibly this script will not work under Windows XP where;
  14. '       the Netsh syntax is different and maybe the Firewall registry values could be diferent too, I've doesn't tested it.
  15. '       Tested on Windows 8.
  16.  
  17.  
  18. ' -------
  19. ' Syntax:
  20. ' -------
  21. '
  22. ' FirewallRuleDel.vbs "[File]" "[ConnectionType]"
  23.  
  24.  
  25. ' -----------
  26. ' Parameters:
  27. ' -----------
  28. '
  29. ' [File]
  30. ' This parameter indicates the file to block.
  31. ' The value should be the relative or absolute filepath of an existing file.
  32. '
  33. ' [ConnectionType]
  34. ' This parameter indicates whether to delete the rule that is blocking inbound or outbound connections.
  35. ' The value should be "In" or "Out".
  36.  
  37.  
  38. ' ---------------
  39. ' Usage examples:
  40. ' ---------------
  41. '
  42. ' FirewallRuleDel.vbs "C:\Program.exe" IN
  43. ' FirewallRuleDel.vbs "C:\Program.exe" OUT
  44.  
  45.  
  46. ' -----------
  47. ' Exit codes:
  48. ' -----------
  49. '
  50. ' -1: Rule doesn't exist.
  51. '  0: Successful exit.
  52. '  1: Missing arguments or too many arguments.
  53. '  2: File not found.
  54. '  3: Wrong value specified for parameter '[ConnectionType]'
  55. '  4: Specific Error.
  56.  
  57.  
  58. ' *************
  59. Option Explicit
  60.  
  61. Const MsgBoxSyntax   = "FirewallRuleDel.vbs ""[File]"" ""[ConnectionType]"""
  62. Const MsgBoxCaption  = "Firewall Rule Del"
  63. Const MsgBoxErrorIco = 16
  64. Const MsgBoxInfoIco  = 64
  65. Const MsgBoxDebugIco = 48
  66.  
  67. Dim objFile        ' Indicates the File Object.
  68. Dim Process        ' Indicates the process to run.
  69. Dim Arguments      ' Indicates the process arguments.
  70. Dim Result         ' Indicates the result (Exit Code) of the process.
  71. Dim ConnectionType ' Indicates whether to unblock inbound or outbound connections.
  72. Dim DebugMode      ' Indicates whether the debug mode is activated.
  73.  
  74.  
  75. ' Set the debug mode to 'True' if need to test the values.
  76. DebugMode = False
  77.  
  78. ' Argument error handling.
  79. If Wscript.Arguments.Count = 0 Then
  80.  
  81. ' Notify the error to the user.
  82. MsgBox "Syntax:" & VBNewLine & _
  83.       MsgBoxSyntax          , _
  84.       MsgBoxErrorIco, MsgBoxCaption
  85.  
  86. ' Exit with reason: 'Missing arguments' error-code.
  87. Wscript.Quit(1)
  88.  
  89. ElseIf Wscript.Arguments.Count < 2 Then
  90.  
  91. ' Notify the error to the user.
  92. MsgBox "Missing arguments."  & _
  93.       VBNewLine & VBNewLine & _
  94.       "Syntax:" & VBNewLine & _
  95.       MsgBoxSyntax          , _
  96.       MsgBoxErrorIco, MsgBoxCaption
  97.  
  98. ' Exit with reason: 'Missing arguments'.
  99. Wscript.Quit(1)
  100.  
  101. ElseIf Wscript.Arguments.Count > 2 Then
  102.  
  103. ' Notify the error to the user.
  104. MsgBox "Too many arguments." & _
  105.       VBNewLine & VBNewLine & _
  106.       "Syntax:" & VBNewLine & _
  107.       MsgBoxSyntax          , _
  108.       MsgBoxErrorIco, MsgBoxCaption
  109.  
  110. ' Exit with reason: 'Too many arguments'.
  111. Wscript.Quit(1)
  112.  
  113. ElseIf Wscript.Arguments.Count = 2 Then
  114.  
  115. If LCase(Wscript.Arguments(1)) = LCase("IN") Then
  116.  
  117. ' Set the ConnectionType to 'Inbound'
  118. ConnectionType = "Inbound"
  119.  
  120. Elseif LCase(Wscript.Arguments(1)) = LCase("OUT") Then
  121.  
  122. ' Set the ConnectionType to 'Outbound'
  123. ConnectionType = "Outbound"
  124.  
  125. Else ' Wrong argument.
  126.  
  127. ' Notify the error to the user.
  128. MsgBox "Wrong value specified for parameter '[ConnectionType]'", _
  129.   MsgBoxErrorIco, MsgBoxCaption
  130.  
  131. ' Exit with reason: 'Wrong value specified for parameter '[ConnectionType]''.
  132. Wscript.Quit(3)
  133.  
  134. End If
  135.  
  136. End If
  137.  
  138. On Error Resume Next
  139.  
  140. ' Set the FileObject with the file passed through the first argument.
  141. Set objFile = Createobject("Scripting.FileSystemObject"). _
  142.              GetFile(Wscript.Arguments(0))
  143.  
  144. ' File-Error handling.
  145. If Err.Number = 53 Then
  146.  
  147. ' Notify the error to the user.
  148. MsgBox "File not found:"   & _
  149.       vbnewline           & _
  150.       Wscript.Arguments(0), _
  151.       MsgBoxErrorIco, MsgBoxCaption
  152.  
  153. ' Exit with reason: 'File not found'.
  154. Wscript.Quit(2)
  155.  
  156. End If
  157.  
  158. ' Set the firewall process.
  159. Process   = "netsh.exe"
  160.  
  161. ' Set the firewall rule parameters to delete Inbound or Outbound blocking rule.
  162. Arguments = "AdvFirewall Firewall Delete Rule"    & _
  163.            " Name=" & """" & objFile.Name & """" & _
  164.            " Dir="  & Wscript.Arguments(1)
  165.  
  166. ' Call the 'FirewallRuleCheck' script to retrieve their exit code;
  167. ' This way I determine whether the bloking rule is exist or not.
  168. Result = WScript.CreateObject("WScript.Shell"). _
  169.         Run("FirewallRuleCheck.vbs"    & " " & _
  170.             """" & objFile.Path & """" & " " & _
  171.             Wscript.Arguments(1)       & " " & _
  172.             "True", 0, True)
  173.  
  174. If DebugMode Then
  175.  
  176. ' Notify the debug information.
  177. MsgBox "File: "            & objFile.Path   & vbnewline & vbnewline & _
  178.       "ConnectionType: "  & ConnectionType & vbnewline & vbnewline & _
  179.       "Process: "         & Process        & vbnewline & vbnewline & _
  180.       "Arguments: "       & Arguments      & vbnewline & vbnewline & _
  181.       "Reult: "           & Result         & vbnewline             , _
  182.       MsgBoxDebugIco,     "Debug Info | "  & MsgBoxCaption
  183.  
  184. End If
  185.  
  186. ' Error handling.
  187. If Err.Number <> 0 Then
  188.  
  189. ' Notify the error to the user.
  190. MsgBox "Error Code: "   & Err.Number & vbnewline & _
  191.       "Error Source: " & Err.Source & vbnewline & _
  192.       "Description: "  & Err.Description        , _
  193.       MsgBoxErrorIco, MsgBoxCaption
  194.  
  195. ' Exit with reason: 'Specific error'.
  196. Wscript.Quit(5)
  197.  
  198. End If
  199.  
  200. If Result = 0 Then ' Rule doesn't exist.
  201.  
  202. ' Notify the error to the user.
  203. MsgBox ConnectionType & " connection blocking rule doesn't exist for file:" & _
  204.       vbnewline                                                            & _
  205.       objFile.Name                                                         , _
  206.       MsgBoxErrorIco, MsgBoxCaption
  207.  
  208. ' Exit with reason: 'Rule doesn't exist'.
  209. Wscript.Quit(-1)
  210.  
  211. Else ' Rule deleted successfully.
  212.  
  213. WScript.CreateObject("WScript.Shell").Run Process & " " & Arguments, 0, True
  214.  
  215. ' Notify the information to the user.
  216. MsgBox ConnectionType & " connection block rule successfully deleted for file:" & _
  217.       vbnewline                                                                & _
  218.       objFile.Name                                                             , _
  219.       MsgBoxInfoIco, MsgBoxCaption
  220.  
  221. End If
  222.  
  223. ' Exit successfully.
  224. Wscript.Quit(0)
7474  Media / Multimedia / Re: ¿Cual seria la mejor forma de automatizar esta tarea para crea video musical?... en: 3 Febrero 2014, 09:52 am
@Kurono90

Perdona por tardar en contestar.

Muchas gracias por la ayuda y el detalle que te has tomado de extender las explicaciones, sin duda es genial.

Lo de la unión de los archivos MP3 era cosa facil para mi, no pedí ayuda para eso, me sabe mal que te hayas molestado tanto en explicarme eso, no era necesario la verdad :P

La idea de tener que usar el avisynth para la tarea junto a un conversor de video te lo agradezco pero no me agrada mucho la idea porque yo lo que reálmente quería evitar era tener que especificar la cantidad de loops (como muestras en el script de AviSynth) porque voy a usar Audios de duración indeterminda y también Videos de duración indeterminada;

así que me puse a indagar una solución alternativa y descubrí que en el AfterEffects, existe una opción para hacer un Loop infinito de la pista de video hasta la duración total de la pista de audio, sin necesidad de especificar la cantidad de veces que el video tiene que repetirse, el problema es que no hay manera de automatizar el aplicado de efectos en el AfterEffects (al menos, que yo sepa) y además es necesario la recompresión del video (o al menos, eso creo);

y al final decidí usar el VirtualDubMod y copiar la pista de video (CTRL+C, CTRL+V, más sencillo imposible) hasta que dure lo mismo que la pista de audio, y al menos, esto no requiere recompresión y es un programa que consume escasos recursos, pero tengo el mismo problema... no veo modo de automatizar esta tarea con el VDubMod, así que estoy igual que como empecé.

¿No sabrás si el FFMPEG soporta la inserción de un script AviSynth? (en la documentación oficial no veo parámetros para esto, pero son infinitos y quizás se me ha pasado),
porque se me acaba de ocurrir que sería un procedimiento muy facil de automatizar desde la consola:

1. Desarrollar una mini-aplicación para medir la duración de la pista de Video y la de audio (o en su defecto usar MediaInfo CLI para obtener la duración) y hacer los cálculos necesarios.
2. Escribir de forma automática el script de AviSyth usando el valor adecuado en el parámetro "Loop()" (según los cálculos obtenidos en el primer paso).
3. Muxear las pistas usando FFMPEG, usando el script de avisynth para repetir el bucle del video (si es necesario la recompresión para hacer el loop pues bueno, no me importaría de esta manera).

PD: Solo necesitaría ayuda para saber como es la sintaxis adecuada para usar AviSynth en FFMPEG (si fuese posible usarlo)


Un saludo!
7475  Media / Multimedia / Re: Alternativa a DVDFab en: 3 Febrero 2014, 09:28 am
No, al hacer un copy de un DVD entra en juego el Muxeado el Copiado y el Ripeo, porque:

1. Eliminas pistas
2. Comprimes las pistas
3. Copias las pistas

Por esa razón, se denomina 'Rip' en toda regla, la re-codificación es simplemente eso ...codificación, no quieras hacer de la codificación el conjunto total del Ripping ...porque no lo es, los programas 'Rippers', además de recodificar el video, también lo remuxean, así que si no quieres reconocerlo a pesar de mis explicaciones y las de Wikipedia ...pues bueno, no es mi problema, pero creo que ha quedado bastante claro, y yo voy a dejar de discutir este tema porque no tengo que dar explicaciones porque venga un chaval a querer intentar ilustrar dandome lecciones a mi y a los demás sobre las diferencias (erroneas) entre A y B, diferencias que ya conozco de sobra puesto que llevo en este mundillo desde antes de que nacieras, y para colmo decirme que si no encuentro software es porque lo busco las cosas mal ...en fín.

PD: Porfavor, si algún mod lee esto, cierren el tema ya...

Saludos!
7476  Media / Multimedia / Re: Alternativa a DVDFab en: 3 Febrero 2014, 08:26 am
Siento decirlo, pero, como otro dato cultural, te equivocas, el término correcto es ripear (Ripping):
Cita de: Wikipedia
Ripping is the process of copying audio or video content to a hard disk, typically from removable media such as compact disc (CD) or DVD
Ripping is often used to shift formats, and to edit, duplicate or back up media content.

¿Nunca has escuchado la expresión "Ripear un juego"?, pues al ripear un DVD de video no creo que se muxeen las pistas, en todo caso se demuxea (si eliminas alguna pista/subtiulo) pero sin volver a unir las demás, y también se puede comprimir (de un DVD9 a DVD5) desde estos programas, lo que envuelve aún más el termino ripear y/o codificar.

Óbviamente encontrarás productos que se denominen "DVD Ripper" (EJ: StaxRip) que cumplan funciones de conversión (codificación) de video, porque también es el término correcto en este contexto.

Respecto al otro comentario (dejando claro con esto que óbviamente he buscado por Rip, ya que es el término correcto), simplemente hay demasiada basura en el software que se puede encontrar hoy en dia por internet, no ha sido nada facil encontrar un software que tenga las mismas características que DVDFab, no vas a encontrar un producto que se llame "DVD Muxer" y esperar que hagan rips.

Un saludo!
7477  Sistemas Operativos / Windows / Re: Registro Bloqueado windows 7 en: 3 Febrero 2014, 07:56 am
hola, te aclaro tus dudas:

1. Puedes usar RegAlyzer y programas parecidos para mirar y/o modificar cualquier clave de registro incluso aunque tengas la restricción del Regedit activado en las políticas de usuario o aunque intentes modificar una clave en la que no tengas permisos suficientes de usuario.

2. Los cambios en las políticas de usuario (como el script que has mostrado del registro) si que funcionan, pero muchos cambios en el sistema requieren cerrar sesión/reiniciar el PC para que los cambios surgan efecto, y modificar las políticas de usuario es uno de esos casos que lo requieren.

3. Con el script de tu ejemplo no se consigue modificar el valor, la sintaxis de un script de Regedit es muy estricta, y debe quedar así:

Código:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\system]
"DisableRegistryTools"=dword:00000000

Si pones el valor y los datos a la derecha de la clave como en tu ejemplo, no da error, pero automáticamente se omite.

Saludos
7478  Media / Multimedia / Re: Alternativa a DVDFab en: 3 Febrero 2014, 07:49 am
Hola

Revivo este post para comentar que por fin encontré la alternativa perfecta al problemático DVDFAB (hasta ayer seguía sin encontrar un software que lo pudiese igualar xD).

Aiseesoft DVD Copy

y

Aiseesoft Blu-Ray Copy

(Luego están los productos "Ripper" y "Converter" de la misma familia, que hacen otras cosas muy distintas...y son los que yo probé en su dia)

Como su nombre indica, obviamente uno trabaja DVD's y el otro BD's, es prácticamente como la característica de copiado del DVDFAB, puedes abrir una carpeta que contenga un DVD/BD, seleccionar la película principal, customizar las pistas de audio, video, y subtitulos que quieres ripear, eliminar el menú de la película ...todo de forma muy cómoda.

...En fin, dos programas muy buenos (y de pago) que funcionan perféctamente en Windows 8.1 sin congelar el PC, a diferencia del DVDFAB.

Un saludo!
7479  Programación / Scripting / Re: Ayuda - Leer Caracter por Caracter en: 3 Febrero 2014, 07:03 am
como lo ejecuto y le mando estos parametros (archivo y 5) para que los procese?

No te lo tomes a mal pero para venir de un lenguaje como C/C++ te veo bastante perezoso para Googlear información básica (el manejo de argumentos en X lenguaje) :¬¬ ~> http://ss64.com/vb/arguments.html

Entonces deberías reemplazar esta orden:
Citar
Código
  1. WScript.Echo Caesar("hola",5)

Por esta otra:
Código
  1. WScript.StdOut.Write(Caesar(WScript.Arguments(0), WScript.Arguments(1)))

Para llamar al Script y redireccionar la salida del Script a un archivo de texto puedes hacerlo así:
Código
  1. Cscript.exe //NoLogo "Caesar.vbs" "hola" 5 > "RESULTADO.TXT"

Como viste en el ejemplo uso un string como parámetro y no un archivo de texto "fuente.txt", la razón es que usar archivos de texto en mi opinión es primitivo, estoy convencido de que podrías trabajar diréctamente con Strings sin necesidad de crear/manipular archivos secundarios en el HDD, de todas formas te muestro los cambios que deberías hacer al Script VBS para tomar un archivo de texto como primer argumento:

Código
  1. ' Cojo la primera linea del archivo que le pases como argumento.
  2. str = Split(CreateObject("Scripting.FileSystemObject"). _
  3. OpenTextFile(WScript.Arguments(0), 1).ReadAll(), vbnewline)(0)
  4.  
  5. WScript.StdOut.Write(Caesar(str, WScript.Arguments(1)))

En la consola...:
Código
  1. Cscript.exe //NoLogo "Caesar.vbs" "FUENTE.TXT" 5 > "RESULTADO.TXT"

Saludos!
7480  Programación / Scripting / Re: Duda Cambiar Dominio A La Pc Windows Xp en: 3 Febrero 2014, 06:39 am
Hola

Citar
Código:
REG ADD HKLM\SYSTEM\CurrentControlSet\services\Tcpip\Parameters /v "NV Hostname" /t REG_SZ /d %1 " NOMBRE DEL NUEVO HOST " /F 1>NUL

En todas las órdenes estás usando el parámetro especial %1, si elimimnas eso en cada linea en teoría ya te deberian funcionar.
Aquí tienes un mini ejemplo y una pregunta parecida ~> http://foro.elhacker.net/scripting/dar_nombre_a_la_pc_con_la_mac_address-t404488.0.html;msg1903396#msg1903396


Sobre el funcionamiento del comando REG no entraré en detalles ...puedes aprender el uso de cada parámetro leyendo la ayuda del comando en la consola:
Código:
REG /?

Saludos
Páginas: 1 ... 733 734 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 ... 1236
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines