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

 

 


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


  Mostrar Mensajes
Páginas: [1]
1  Programación / Programación Visual Basic / Re: Como puedo descargar un archivo de Internet con Visual Basic 6 en: 1 Julio 2009, 02:41 am
usando el control "inet"

vas a menu proyecto>componentes y buscas/activas el "Microsoft Internet transfer"

y aki te doy un code que encontre por ahi...
Citar
Mediante el control Inet (Internet Transfer control), podemos descargar un archivo desde una dirección Url (archivo de texto o binario) y mostrar el progreso de descarga en una Progress bar. En este ejemplo se descarga desde la página de Softonic el programa Warez.exe y se vá mostrando el progreso
Colocar 1 control Inet y 1 progress bar. El archivo se guarda en la carpeta donde se ejecute el programa.

necesitas un Control Inet, un Progress, un command

Código:
Private Sub Command1_Click()
ProgressBar1.Value = 0
Inet1.AccessType = icUseDefault
Inet1.URL = "http://download.warezclient.com/WarezP2P_DLC.exe"
Inet1.Execute , "GET" 'Indicamos que vamos a descargar o recuperar un _
archivo desde una url
End Sub

Private Sub Inet1_StateChanged(ByVal State As Integer)
Dim vtData As Variant 'acá almacenamos los datos

Select Case State

Case icResponseCompleted
Dim bDone As Boolean: bDone = False
Dim tempArray() As Byte ' Un array para grabar los datos en un archivo
'Para saber el tamaño del fichero en bytes
filesize = Inet1.GetHeader("Content-length")
'Establecemos el Max del = a al tamaño del archivo
ProgressBar1.Max = filesize
contenttype = Inet1.GetHeader("Content-type")
'Creamos y abrimos un nuevo archivo en modo binario
Open App.Path + "\WarezP2P_DLC.exe" For Binary Access Write As #1

' Leemos de a 1 Kbytes. El segundo parámetro indica _
el tipo de fichero. Tipo texto o tipo Binario, en este caso _
binario
vtData = Inet1.GetChunk(1024, icByteArray)

DoEvents
'Si el tamaño del fichero es 0 ponemos bDone en True para que no _
entre en el bucle
If Len(vtData) = 0 Then
bDone = True
End If

Do While Not bDone
'Almacenamos en un array el contenido del archivo
tempArray = vtData
'Escribimos el archivo en disco
Put #1, , tempArray
'Aumentamos la barra
ProgressBar1.Value = ProgressBar1.Value + Len(vtData) * 2
' Leemos de pedazos de a 1 kb (1024 bytes)
vtData = Inet1.GetChunk(1024, icByteArray)
DoEvents

If Len(vtData) = 0 Then
bDone = True
End If
Loop

Close #1
ProgressBar1.Value = 0

End Select
End Sub

el autor se llama luciano

Está muy bien el uso del Control Internet Transfer para una conexión a internet directa, pero como pudiera hacerlo con dicho control si la conexión es mediante un proxy que requiere autentificación.  :huh: :huh: :huh:
2  Programación / Programación Visual Basic / Re: Listar los recursos compartidos de un equipo remoto!! en: 25 Marzo 2009, 17:37 pm
Olas encontre un excelente code pero no logro modificarlo para que me pinche poniendo una IP como tal...

Aki les va...

' This code need 2 Label, 1 Listbox and 1 Button.

Código
  1. Option Explicit
  2.  
  3. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  4. ' Copyright ©1996-2009 VBnet, Randy Birch, All Rights Reserved.
  5. ' Some pages may also contain other copyrights by the author.
  6. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  7. ' Distribution: You can freely use this code in your own
  8. '               applications, but you may not reproduce
  9. '               or publish this code on any web site,
  10. '               online service, or distribute as source
  11. '               on any media without express permission.
  12. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  13.  
  14. 'Windows type used to call the Net API
  15. Private Const MAX_PREFERRED_LENGTH As Long = -1
  16. Private Const NERR_SUCCESS As Long = 0&
  17. Private Const ERROR_MORE_DATA As Long = 234&
  18. Private Const LB_SETTABSTOPS As Long = &H192
  19.  
  20. 'See NetServerEnum demo for complete
  21. 'list of server types supported
  22. Private Const SV_TYPE_ALL As Long = &HFFFFFFFF
  23. Private Const SV_TYPE_WORKSTATION As Long = &H1
  24. Private Const SV_TYPE_SERVER As Long = &H2
  25.  
  26. Private Const STYPE_ALL As Long = -1  'note: my const
  27. Private Const STYPE_DISKTREE As Long = 0
  28. Private Const STYPE_PRINTQ As Long = 1
  29. Private Const STYPE_DEVICE As Long = 2
  30. Private Const STYPE_IPC As Long = 3
  31. Private Const STYPE_SPECIAL As Long = &H80000000
  32. Private Const ACCESS_READ  As Long = &H1
  33. Private Const ACCESS_WRITE As Long = &H2
  34. Private Const ACCESS_CREATE As Long = &H4
  35. Private Const ACCESS_EXEC As Long = &H8
  36. Private Const ACCESS_DELETE As Long = &H10
  37. Private Const ACCESS_ATRIB As Long = &H20
  38. Private Const ACCESS_PERM As Long = &H40
  39. Private Const ACCESS_ALL As Long = ACCESS_READ Or _
  40.                                   ACCESS_WRITE Or _
  41.                                   ACCESS_CREATE Or _
  42.                                   ACCESS_EXEC Or _
  43.                                   ACCESS_DELETE Or _
  44.                                   ACCESS_ATRIB Or _
  45.                                   ACCESS_PERM
  46. 'for use on Win NT/2000 only
  47. Private Type SERVER_INFO_100
  48.  sv100_platform_id As Long
  49.  sv100_name As Long
  50. End Type
  51.  
  52. 'shi2_current_uses: number of current connections to the resource
  53. 'shi2_max_uses    : max concurrent connections resource can accommodate
  54. 'shi2_netname     : share name of a resource
  55. 'shi2_passwd      : share's password when
  56. '                  (server running with share-level security)
  57. 'shi2_path        : local path for the shared resource
  58. 'shi2_permissions : shared resource's permissions
  59. '                  (servers running with share-level security)
  60. 'shi2_remark      : string containing optional comment about the resource
  61. 'shi2_type        : the type of the shared resource
  62. Private Type SHARE_INFO_2
  63.  shi2_netname As Long
  64.  shi2_type As Long
  65.  shi2_remark As Long
  66.  shi2_permissions As Long
  67.  shi2_max_uses As Long
  68.  shi2_current_uses As Long
  69.  shi2_path As Long
  70.  shi2_passwd As Long
  71. End Type
  72.  
  73. Private Declare Function NetServerEnum Lib "netapi32" _
  74.  (ByVal servername As Long, _
  75.   ByVal level As Long, _
  76.   buf As Any, _
  77.   ByVal prefmaxlen As Long, _
  78.   entriesread As Long, _
  79.   totalentries As Long, _
  80.   ByVal servertype As Long, _
  81.   ByVal domain As Long, _
  82.   resume_handle As Long) As Long
  83.  
  84. Private Declare Function NetShareEnum Lib "netapi32" _
  85.  (ByVal servername As Long, _
  86.   ByVal level As Long, _
  87.   bufptr As Long, _
  88.   ByVal prefmaxlen As Long, _
  89.   entriesread As Long, _
  90.   totalentries As Long, _
  91.   resume_handle As Long) As Long
  92.  
  93. Private Declare Function NetApiBufferFree Lib "netapi32" _
  94.   (ByVal Buffer As Long) As Long
  95.  
  96. Private Declare Sub CopyMemory Lib "kernel32" _
  97.   Alias "RtlMoveMemory" _
  98.  (pTo As Any, uFrom As Any, _
  99.   ByVal lSize As Long)
  100.  
  101. Private Declare Function lstrlenW Lib "kernel32" _
  102.  (ByVal lpString As Long) As Long
  103.  
  104. Private Declare Function SendMessage Lib "user32" _
  105.   Alias "SendMessageA" _
  106.  (ByVal hwnd As Long, _
  107.   ByVal wMsg As Long, _
  108.   ByVal wParam As Long, _
  109.   lParam As Any) As Long
  110.  
  111.  
  112. Private Sub Form_Load()
  113.  
  114.   ReDim TabArray(0 To 4) As Long
  115.  
  116.   TabArray(0) = 73
  117.   TabArray(1) = 125
  118.   TabArray(2) = 151
  119.   TabArray(3) = 232
  120.  
  121.  'Clear any existing tabs
  122.  'and set the list tabstops
  123.   Call SendMessage(List1.hwnd, LB_SETTABSTOPS, 0&, ByVal 0&)
  124.   Call SendMessage(List1.hwnd, LB_SETTABSTOPS, 4&, TabArray(0))
  125.   List1.Refresh
  126.  
  127.   Command1.Caption = "Net Share Enum"
  128.   Label1.Caption = "call success (0) or error :"
  129.   Label2.Caption = ""
  130.  
  131. End Sub
  132.  
  133.  
  134. Private Sub Command1_Click()
  135.  
  136.   Dim bufptr          As Long  'output
  137.   Dim dwServer        As Long  'pointer to the server
  138.   Dim dwEntriesread   As Long  'out
  139.   Dim dwTotalentries  As Long  'out
  140.   Dim dwResumehandle  As Long  'out
  141.   Dim success         As Long
  142.   Dim nStructSize     As Long
  143.   Dim cnt             As Long
  144.   Dim usrname         As String
  145.   Dim bServer         As String
  146.   Dim shi2            As SHARE_INFO_2
  147.  
  148.  'demo using the local machine
  149.   bServer = "\\" & Environ$("COMPUTERNAME") & vbNullString
  150.  
  151.  'create pointer to the machine name
  152.   dwServer = StrPtr(bServer)
  153.  
  154.   success = NetShareEnum(dwServer, _
  155.                          2, _
  156.                          bufptr, _
  157.                          MAX_PREFERRED_LENGTH, _
  158.                          dwEntriesread, _
  159.                          dwTotalentries, _
  160.                          dwResumehandle)
  161.  
  162.   List1.Clear
  163.   Label2.Caption = success
  164.  
  165.   If success = NERR_SUCCESS And _
  166.      success <> ERROR_MORE_DATA Then
  167.  
  168.      nStructSize = LenB(shi2)
  169.  
  170.      For cnt = 0 To dwEntriesread - 1
  171.  
  172.        'get one chunk of data and cast
  173.        'into an SHARE_INFO_2 type, and
  174.        'add the data to a list
  175.         CopyMemory shi2, ByVal bufptr + (nStructSize * cnt), nStructSize
  176.  
  177.         List1.AddItem GetPointerToByteStringW(shi2.shi2_netname) & vbTab & _
  178.                       GetConnectionType(shi2.shi2_type) & vbTab & _
  179.                       GetConnectionPermissions(shi2.shi2_permissions) & vbTab & _
  180.                       GetPointerToByteStringW(shi2.shi2_remark) & vbTab & _
  181.                       GetPointerToByteStringW(shi2.shi2_path)  ' & vbTab & _
  182.  
  183.      Next
  184.  
  185.   End If
  186.  
  187.   Call NetApiBufferFree(bufptr)
  188.  
  189. End Sub
  190.  
  191.  
  192. Private Function GetConnectionPermissions(ByVal dwPermissions As Long) As String
  193.  
  194.  'Permissions are only returned a shared
  195.  'resource running with share-level security.
  196.  'A server running user-level security ignores
  197.  'this member, so the function returns
  198.  '"not applicable".
  199.   Dim tmp As String
  200.  
  201.   If (dwPermissions And ACCESS_READ) Then tmp = tmp & "R"
  202.   If (dwPermissions And ACCESS_WRITE) Then tmp = tmp & " W"
  203.   If (dwPermissions And ACCESS_CREATE) Then tmp = tmp & " C"
  204.   If (dwPermissions And ACCESS_DELETE) Then tmp = tmp & " D"
  205.   If (dwPermissions And ACCESS_EXEC) Then tmp = tmp & " E"
  206.   If (dwPermissions And ACCESS_ATRIB) Then tmp = tmp & " A"
  207.   If (dwPermissions And ACCESS_PERM) Then tmp = tmp & " P"
  208.  
  209.   If Len(tmp) = 0 Then tmp = "n/a"
  210.  
  211.   GetConnectionPermissions = tmp
  212.  
  213.  
  214. End Function
  215.  
  216.  
  217. Private Function GetConnectionType(ByVal dwConnectType As Long) As String
  218.  
  219.  'compare connection type value
  220.   Select Case dwConnectType
  221.      Case STYPE_DISKTREE: GetConnectionType = "disk drive"
  222.      Case STYPE_PRINTQ:   GetConnectionType = "print queue"
  223.      Case STYPE_DEVICE:   GetConnectionType = "communication device"
  224.      Case STYPE_IPC:      GetConnectionType = "ipc"
  225.      Case STYPE_SPECIAL:  GetConnectionType = "administrative"
  226.      Case Else
  227.  
  228.        'weird case. On my NT2000 machines,
  229.        'I have to do this to identify the
  230.        'IPC$ share type
  231.         Select Case (dwConnectType Xor STYPE_SPECIAL) 'rtns 3 if IPC
  232.            Case STYPE_IPC: GetConnectionType = "ipc"
  233.            Case Else:      GetConnectionType = "undefined"
  234.         End Select
  235.  
  236.   End Select
  237.  
  238. End Function
  239.  
  240. Public Function GetPointerToByteStringW(ByVal dwData As Long) As String
  241.  
  242.   Dim tmp() As Byte
  243.   Dim tmplen As Long
  244.  
  245.   If dwData <> 0 Then
  246.  
  247.      tmplen = lstrlenW(dwData) * 2
  248.  
  249.      If tmplen <> 0 Then
  250.  
  251.         ReDim tmp(0 To (tmplen - 1)) As Byte
  252.         CopyMemory tmp(0), ByVal dwData, tmplen
  253.         GetPointerToByteStringW = tmp
  254.  
  255.     End If
  256.  
  257.   End If
  258.  
  259. End Function

Funciona Perfectamente, pero en algunas PCs de la red me devuelve Error 5 que es Acceso Denegado accediendo a PCs que están disponibles y con acceso ¿Alguna ayuda de como solucionarlo?  :huh: :huh: :huh:
Páginas: [1]
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines