Foro de elhacker.net

Programación => Programación Visual Basic => Mensaje iniciado por: Swellow en 6 Noviembre 2011, 22:17 pm



Título: [HELP] Invoke InternetReadFile API
Publicado por: Swellow en 6 Noviembre 2011, 22:17 pm
I've tried almost everything to Invoke that API and I always failed...

I suceed with InternetOpen/InternetOpelUrl/InternetCloseHandle but not that one :/

Código:
Private Declare Function InternetReadFile Lib "wininet.dll" (ByVal hFile As Long, ByVal lpBuffer As String, ByVal dwNumberOfBytesToRead As Long, lNumberOfBytesRead As Long) As Integer

        bDoLoop = InternetReadFile(hInternetOpen, strArray, Len(strArray), lNumberOfBytes)

Can anyone help please?


Título: Re: [HELP] Invoke InternetReadFile API
Publicado por: BlackZeroX en 6 Noviembre 2011, 22:36 pm
.
Código
  1.  
  2. Const scUserAgent = "API-Guide test program"
  3. Const INTERNET_OPEN_TYPE_DIRECT = 1
  4. Const INTERNET_OPEN_TYPE_PROXY = 3
  5. Const INTERNET_FLAG_RELOAD = &H80000000
  6. Const sURL = "http://www.microsoft.com/index.htm"
  7. Private Declare Function InternetOpen Lib "wininet" Alias "InternetOpenA" (ByVal sAgent As String, ByVal lAccessType As Long, ByVal sProxyName As String, ByVal sProxyBypass As String, ByVal lFlags As Long) As Long
  8. Private Declare Function InternetCloseHandle Lib "wininet" (ByRef hInet As Long) As Long
  9. Private Declare Function InternetReadFile Lib "wininet" (ByVal hFile As Long, ByVal sBuffer As String, ByVal lNumBytesToRead As Long, lNumberOfBytesRead As Long) As Integer
  10. Private Declare Function InternetOpenUrl Lib "wininet" Alias "InternetOpenUrlA" (ByVal hInternetSession As Long, ByVal lpszUrl As String, ByVal lpszHeaders As String, ByVal dwHeadersLength As Long, ByVal dwFlags As Long, ByVal dwContext As Long) As Long
  11. Private Sub Form_Load()
  12.    'KPD-Team 1999
  13.    'URL: http://www.allapi.net/
  14.    'E-Mail: KPDTeam@Allapi.net
  15.  
  16.    Dim hOpen As Long, hFile As Long, sBuffer As String, Ret As Long
  17.    'Create a buffer for the file we're going to download
  18.    sBuffer = Space(1000)
  19.    'Create an internet connection
  20.    hOpen = InternetOpen(scUserAgent, INTERNET_OPEN_TYPE_DIRECT, vbNullString, vbNullString, 0)
  21.    'Open the url
  22.    hFile = InternetOpenUrl(hOpen, sURL, vbNullString, ByVal 0&, INTERNET_FLAG_RELOAD, ByVal 0&)
  23.    'Read the first 1000 bytes of the file
  24.    InternetReadFile hFile, sBuffer, 1000, Ret
  25.    'clean up
  26.    InternetCloseHandle hFile
  27.    InternetCloseHandle hOpen
  28.    'Show our file
  29.    MsgBox sBuffer
  30. End Sub
  31.  
  32.  

http://allapi.mentalis.org/apilist/InternetReadFile.shtml

Dulces Lunas!ˇ.


Título: Re: [HELP] Invoke InternetReadFile API
Publicado por: Swellow en 6 Noviembre 2011, 22:44 pm
Thanks for your answer man but its not that that I want. I want to Invoke the API using CallAPIByName.


Título: Re: [HELP] Invoke InternetReadFile API
Publicado por: x64core en 6 Noviembre 2011, 23:20 pm
Thanks for your answer man but its not that that I want. I want to Invoke the API using CallAPIByName.

which callApibyname use?


Título: Re: [HELP] Invoke InternetReadFile API
Publicado por: Swellow en 6 Noviembre 2011, 23:21 pm
Modded CallAPIByName by cobein.


Título: Re: [HELP] Invoke InternetReadFile API
Publicado por: x64core en 6 Noviembre 2011, 23:25 pm
made several cobein  :-\
specify link or the code


Título: Re: [HELP] Invoke InternetReadFile API
Publicado por: BlackZeroX en 6 Noviembre 2011, 23:26 pm
.
I do not see the problem.

for more information: http://msdn.microsoft.com/en-us/library/windows/desktop/aa385103%28v=vs.85%29.aspx

prototype:
Código
  1. Public Function CallAPIByName(ByVal sLib As String, ByVal sMod As String, ParamArray Params()) As Long
  2.  

API to Call

Código
  1.  
  2. BOOL InternetReadFile(
  3.  __in   HINTERNET hFile,
  4.  __out  LPVOID lpBuffer,
  5.  __in   DWORD dwNumberOfBytesToRead,
  6.  __out  LPDWORD lpdwNumberOfBytesRead
  7. );
  8.  
  9. Requirements
  10.  
  11. Minimum supported client Windows 2000 Professional
  12. Minimum supported server Windows 2000 Server
  13. Header Wininet.h
  14. Library Wininet.lib
  15. DLL Wininet.dll
  16.  
  17.  

Código
  1.  
  2. dim hFile as long
  3. dim bBuff(0 to 999) as byte ' lpBuffer = varptr(bBuff(0))
  4. dim dwNumberOfBytesToRead as long
  5. dim lpdwNumberOfBytesRead as long
  6. dim bRes as boolean
  7.  
  8. dwNumberOfBytesToRead = 1000
  9. bRes = callapybyname("wininet", "InternetReadFile", hFile, varptr(bBuff(0)), dwNumberOfBytesToRead, varptr(lpdwNumberOfBytesRead) )
  10.  
  11.  

Dulces Lunas!¡.


Título: Re: [HELP] Invoke InternetReadFile API
Publicado por: BlackZeroX en 6 Noviembre 2011, 23:42 pm
Example FULL:

Código
  1.  
  2. Option Explicit
  3.  
  4. Const scUserAgent = "UserAngent InfraExplorer Plugin."
  5. Const INTERNET_OPEN_TYPE_DIRECT = 1
  6. Const INTERNET_OPEN_TYPE_PROXY = 3
  7. Const INTERNET_FLAG_RELOAD = &H80000000
  8. Const sURL = "http://infrangelux.sytes.net/ScanX/?ip=www.google.com.mx&port=80&nohtml=3"
  9.  
  10. Private Sub Form_Load()
  11.    Dim hOpen       As Long
  12.    Dim hFile       As Long
  13.    Dim bBuffer()   As Byte
  14.    Dim Ret         As Long
  15.    ReDim bBuffer(0 To 0)
  16.    hOpen = lCallApiByName("wininet", "InternetOpenW", StrPtr(scUserAgent), INTERNET_OPEN_TYPE_DIRECT, 0, 0, 0)
  17.    hFile = lCallApiByName("wininet", "InternetOpenUrlW", hOpen, StrPtr(sURL), 0, 0, INTERNET_FLAG_RELOAD, 0)
  18.    Call lCallApiByName("wininet", "InternetReadFile", hFile, VarPtr(bBuffer(0)), 1, VarPtr(Ret))
  19.    Call lCallApiByName("wininet", "InternetCloseHandle", hFile)
  20.    Call lCallApiByName("wininet", "InternetCloseHandle", hOpen)
  21.    MsgBox IIf(Val(StrConv(bBuffer, vbUnicode)) = 1, "Port Enabled", "Port Disabled")
  22. End Sub
  23.  
  24.  

Dulces Lunas!¡.


Título: Re: [HELP] Invoke InternetReadFile API
Publicado por: Swellow en 6 Noviembre 2011, 23:55 pm
@BlackZeroX (Astaroth)
Thanks a lot man!