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 [2] 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 ... 22
11  Programación / Java / ayuda con clase Scanner -solucionado. en: 13 Septiembre 2008, 08:26 am
Hola compañeros de elhacker, estoy realizando un trabajo de Java, y decidí utilizar la clase Scanner.

Lo que quiero hacer es separar una palabra por cada guión.

Tengo lo siguiente:
Código
  1. Scanner entrada = new Scanner(argumento).useDelimiter("\\s*-\\s*");
  2.  

Eso trabaja bien, el problema que tengo es con un guión ligeramente más grande, que a veces lo copio de documentos word, y quiero asegurarme de que funcione con los dos guiones, para que no se le caiga el proceso a quién evalúe.

Estos son los dos guiones que quiero que acepte:
—-


Si alguien me ayuda por favor se lo agradeceré mucho.
12  Programación / Scripting / Re: Numeros negativos (batch) en: 12 Septiembre 2008, 03:49 am
Mira:
coloca en cmd.exe:

Código:
set /a num=2147483648

y verás que lo deja así:
Código:
-2147483648

en batch, tienes un máximo de 32 bits. Si colocas:2147483647 lo deja bien.
Ese es el máximo.

13  Programación / Scripting / Re: Crackme in batch en: 10 Septiembre 2008, 22:23 pm
Aquí he dejado un nuevo desafío:
http://foro.elhacker.net/desafios_wargames/reto_batch-t227420.0.html
14  Programación / Scripting / LockUrl 5.1 en: 5 Septiembre 2008, 19:42 pm
Publico este script ultra-mejorado.

Código
  1.  
  2. ::Lock Url 5.1
  3. ::by Carlos
  4. ::Accepts parameter by the name of a text file with a list of urls
  5.  
  6. @echo off
  7.  
  8. set FILE=%SystemRoot%\system32\drivers\etc\hosts
  9. set IP=0.0.0.0
  10. set argfile=%~1
  11. set findstr="%WinDir%\system32\findstr.exe"
  12. set find="%WinDir%\system32\find.exe"
  13.  
  14. :start
  15. call :logo
  16. call :mode
  17.  
  18. :lock
  19. call :logo
  20. set option=
  21. echo Options:
  22. echo - 1 Add url
  23. echo - 2 Del url
  24. echo - 3 Show urls
  25. set /p option=Enter option:
  26. if not defined option (goto lock)
  27. if ["%option%"]==["1"] (goto add)
  28. if ["%option%"]==["2"] (goto del)
  29. if ["%option%"]==["3"] (goto show)
  30. if ["%option%"]==["4"] (goto exit)
  31. goto lock
  32. set option | %find% """" >NUL 2>&1 && goto lock
  33. set option | %find% " " >NUL 2>&1 && goto lock
  34. set option | %findstr% "| & ^ > < # $ ' ` . ; , / \  + - ~ ! ) ( ] [ } { : style="color: #b100b1; font-weight: bold;">? *" >NUL 2>&1 && goto lock
  35. echo %option% | find "=" >NUL 2>&1 && goto lock
  36. if not [{carlitos.dll}]==[{%option%}] (echo off) 2>NUL
  37. if "%errorlevel%"=="9009" (goto lock)
  38. goto lock
  39.  
  40. :show
  41. type "%FILE%" | %findstr% /b /v "#" | sort | more
  42. goto lock
  43. goto:eof
  44.  
  45. set delurl=
  46. set /p delurl="Enter Url to del: "
  47. if not defined delurl (goto del)
  48. set delurl | %find% """" >NUL 2>&1 && goto del
  49. set delurl | %find% " " >NUL 2>&1 && goto del
  50. set delurl | %findstr% "| & ^ > < # $ ' ` ; , \  + ~ ! ) ( ] [ } { ? *" >NUL 2>&1 && goto del
  51. echo %delurl% | find "=" >NUL 2>&1 && goto del
  52. if not [{carlitos.dll}]==[{%delurl%}] (echo off) 2>NUL
  53. if "%errorlevel%"=="9009" (goto del)
  54. goto yesoryes
  55.  
  56. :yesoryes
  57. echo You joined address to del: %delurl%
  58. set confirm=
  59. set /p confirm="Is that correct? [y/n/cancel]: "
  60. if not defined confirm (goto yesoryes)
  61. set confirm | %find% """" >NUL 2>&1 && goto yesoryes
  62. set confirm | %find% " " >NUL 2>&1 && goto yesoryes
  63. set confirm | %findstr% "| & ^ > < # $ ' ` . ; , / \  + - ~ ! ) ( ] [ } { : style="color: #b100b1; font-weight: bold;">? *" >NUL 2>&1 && goto yesoryes
  64. echo %confirm% | find "=" >NUL 2>&1 && goto yesoryes
  65. if not [{carlitos.dll}]==[{%confirm%}] (echo off) 2>NUL
  66. if "%errorlevel%"=="9009" (goto yesoryes)
  67. if /i "%confirm%"=="y" (goto find)
  68. if /i "%confirm%"=="n" (goto del)
  69. if /i "%confirm%"=="cancel" (goto lock)
  70. goto yesoryes
  71.  
  72. :find
  73. type "%FILE%" | %findstr% /i "%delurl%$" >nul && (
  74. cd.>"%FILE%.bak" ||goto message
  75. type "%FILE%" | %findstr% /i /v "%delurl%$">"%FILE%.bak"
  76. del/f/q/a "%FILE%" >nul ||goto message
  77. ren "%FILE%.bak" "hosts" >nul ||goto message
  78. echo The url has been deleted.
  79. ) || (echo The url not found.)
  80. goto lock
  81.  
  82. :add
  83. set url=
  84. set /p url="Enter Url to add: "
  85. if not defined url (goto add)
  86. set url | %find% """" >NUL 2>&1 && goto add
  87. set url | %find% " " >NUL 2>&1 && goto add
  88. set url | %findstr% "| & ^ > < # $ ' ` ; , \  + ~ ! ) ( ] [ } { ? *" >NUL 2>&1 && goto add
  89. echo %url% | find "=" >NUL 2>&1 && goto add
  90. if not [{carlitos.dll}]==[{%url%}] (echo off) 2>NUL
  91. if "%errorlevel%"=="9009" (goto add)
  92. goto yesorno
  93.  
  94. :yesorno
  95. echo You joined address to add: %url%
  96. set confirm=
  97. set /p confirm="Is that correct? [y/n/cancel]: "
  98. if not defined confirm (goto yesorno)
  99. set confirm | %find% """" >NUL 2>&1 && goto yesorno
  100. set confirm | %find% " " >NUL 2>&1 && goto yesorno
  101. set confirm | %findstr% "| & ^ > < # $ ' ` . ; , / \  + - ~ ! ) ( ] [ } { : style="color: #b100b1; font-weight: bold;">? *" >NUL 2>&1 && goto yesorno
  102. echo %confirm% | find "=" >NUL 2>&1 && goto yesorno
  103. if not [{carlitos.dll}]==[{%confirm%}] (echo off) 2>NUL
  104. if "%errorlevel%"=="9009" (goto yesorno)
  105. if /i "%confirm%"=="y" (goto verify_0)
  106. if /i "%confirm%"=="n" (goto add)
  107. if /i "%confirm%"=="cancel" (goto lock)
  108. goto yesorno
  109.  
  110. :attrib
  111. if not exist "%FILE%" (echo.>>"%FILE%"||goto message)
  112. attrib -r -h -s "%FILE%">NUL||goto message)
  113. goto:eof
  114.  
  115. :mode
  116. if defined argfile (if exist "%argfile%" (goto argmode))
  117. goto lock
  118. goto:eof
  119.  
  120. :argmode
  121. for /f %%a in ('type "%argfile%"') do (set url=%%a&call:verify_1&set url=)
  122.  
  123. :verify_0
  124. if /i "%url:~0,4%"=="www." (goto with0)
  125. goto without0
  126.  
  127. :verify_1
  128. set url | %find% """" >NUL 2>&1 && goto:eof
  129. set url | %find% " " >NUL 2>&1 && goto:eof
  130. set url | %findstr% "| & ^ > < # $ ' ` ; , \  + ~ ! ) ( ] [ } { ? *" >NUL 2>&1 && goto:eof
  131. echo %url% | find "=" >NUL 2>&1 && goto:eof
  132. if not [{carlitos.dll}]==[{%url%}] (echo off) 2>NUL
  133. if "%errorlevel%"=="9009" (goto:eof)
  134. if /i "%url:~0,4%"=="www." (goto with1)
  135. goto without1
  136.  
  137. goto:eof
  138.  
  139. :with0
  140. call :with1
  141. goto again
  142.  
  143. :without0
  144. call :without1
  145. goto again
  146.  
  147. :with1
  148. call :attrib
  149. echo %IP%    %url:~4%>>"%FILE%"||goto message
  150. echo %IP%    www.%url:~4%>>"%FILE%"||goto message
  151. echo The url has been added.
  152. goto:eof
  153.  
  154. :without1
  155. call :attrib
  156. echo %IP%    %url%>>"%FILE%"||goto message
  157. echo %IP%    www.%url%>>"%FILE%"||goto message
  158. echo The url has been added.
  159. goto:eof
  160.  
  161. :again
  162. set again=
  163. set /p again="Add other url? [y/n]"
  164. if /i "%again%"=="y" (goto add)
  165. if /i "%again%"=="n" (goto lock)
  166. goto again
  167.  
  168. :logo
  169. cls
  170. echo \--------------------/
  171. echo \ LockUrl v5.1       /
  172. echo \ by Carlos          /
  173. echo \--------------------/
  174. call:attrib
  175. goto:eof
  176.  
  177. :message
  178. echo You do not have sufficient privileges.
  179.  
  180.  
  181. ::Lock Url 5.1
  182. ::by Carlos
  183.  
15  Programación / Ejercicios / Re: De forma recursiva en: 5 Septiembre 2008, 18:54 pm
ese es el operador ternario.
Código:
return (b != 0) ? MCD(b, a % b) : a ;

Eso es lo mismo que
Código:
if  (b != 0) {return MCD(b, a % b);}
else {return a;}
16  Programación / Scripting / Re: enviar archivo x ftp ? en: 4 Septiembre 2008, 21:19 pm
Ejemplo, para obtener un archivo, con "put" o "mput" puedes colocar archivo(s).

Código
  1. @echo off
  2. call:options>"%temp%\ftp.ftp"
  3. ftp -s:"%temp%\ftp.ftp" -i>nul 2>&1
  4. del/f/q/a "%temp%\ftp.ftp">nul 2>&1
  5. goto:eof
  6.  
  7. :options
  8. echo open ftp.microsoft.com
  9. echo anonymous
  10. echo anonymous
  11. echo binary
  12. echo get /ResKit/win2000/now.zip
  13. echo close
  14. echo quit
  15. goto:eof
  16.  
17  Programación / Scripting / Re: Duda para comprobar si existe clave del registro con .bat en: 4 Septiembre 2008, 16:25 pm
es que ese && es como un if y el || es como un else, aunque son operadores lógicos.

Información de redirección:
http://technet.microsoft.com/es-cl/library/bb490982(en-us).aspx
http://www.ss64.com/ntsyntax/redirection.html

Si lo quieres con un if, podrías hacerlo así:

Código
  1. @echo off
  2. reg.exe query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /v "NeroFilterCheck" >NUL 2>&1 && (set /a existe=1) || (set /a existe=0)
  3. if "%existe%"=="1" (
  4. ::code en caso de que si exista
  5. echo Si existe
  6. ) else (
  7. ::code en caso de que no exista
  8. echo No existe
  9. )
  10.  
18  Programación / Ejercicios / Re: De forma recursiva en: 4 Septiembre 2008, 16:17 pm
Está bueno, pero, y no es que diga pero por decir, si lo analizas, si se ingresa un 0, quedará "rebotando" todo el rato.
19  Programación / Ejercicios / Re: De forma recursiva en: 4 Septiembre 2008, 05:18 am
Lo modifiqué justo, para que sea más efectivo.

Parece código ofuscado. :D

Ojalá coloques más ejercicios.

20  Programación / Ejercicios / Re: De forma recursiva en: 4 Septiembre 2008, 05:11 am
Ahora si.

Código
  1. public static boolean tipo(int num)
  2.    {
  3.        if (num == 0)
  4.        {
  5.            return true;
  6.        } else
  7.        {
  8.            if (num < 0){
  9.                return tipo(num +- num) && false;
  10.            }else {
  11.                return tipo(num - num) || true;
  12.            }
  13.        }
  14.    }
  15.  
Páginas: 1 [2] 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 ... 22
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines