Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. Option Strict On
  2. Imports System.Runtime.InteropServices
  3.  
  4. 'created by: loyalty
  5. 'Email: loyalty.exe@gmail.com
  6. 'Website: http://loyaltyHF.blogspot.com
  7.  
  8. Module Module1
  9.  
  10.     'http://pinvoke.net/default.aspx/wininet.InternetOpen
  11.    Private Declare Function InternetOpen Lib "wininet.dll" Alias "InternetOpenA" ( _
  12.     ByVal sAgent As String, _
  13.     ByVal lAccessType As Int32, _
  14.     ByVal sProxyName As String, _
  15.     ByVal sProxyBypass As String, _
  16.     ByVal lFlags As Integer) As IntPtr
  17.  
  18.     'http://pinvoke.net/default.aspx/wininet.InternetConnect
  19.    Private Declare Auto Function InternetConnect Lib "wininet.dll" ( _
  20.     ByVal hInternetSession As System.IntPtr, _
  21.     ByVal sServerName As String, _
  22.     ByVal nServerPort As Integer, _
  23.     ByVal sUsername As String, _
  24.     ByVal sPassword As String, _
  25.     ByVal lService As Int32, _
  26.     ByVal lFlags As Int32, _
  27.     ByVal lContext As System.IntPtr) As System.IntPtr
  28.  
  29.     'http://pinvoke.net/default.aspx/wininet.InternetCloseHandle
  30.    Private Declare Function InternetCloseHandle Lib "wininet.dll" ( _
  31.     ByVal hInet As IntPtr) As Boolean
  32.  
  33.     'http://www.pinvoke.net/default.aspx/wininet.InternetGetLastResponseInfo
  34.    Private Declare Function InternetGetLastResponseInfo Lib "wininet.dll" Alias "InternetGetLastResponseInfoA" ( _
  35.     ByRef errorCode As Integer, _
  36.     ByVal buffer As String, _
  37.     ByRef bufferLength As Integer) As <MarshalAs(UnmanagedType.Bool)> Boolean
  38.  
  39.     Private Declare Function HttpOpenRequest Lib "wininet.dll" Alias "HttpOpenRequestA" ( _
  40.     ByVal hHttpSession As IntPtr, _
  41.     ByVal lpszVerb As String, _
  42.     ByVal lpszObjectName As String, _
  43.     ByVal lpszVersion As String, _
  44.     ByVal lpszReferer As String, _
  45.     ByVal lpszAcceptTypes As String, _
  46.     ByVal dwFlags As Integer, _
  47.     ByVal dwContext As Integer) As IntPtr
  48.  
  49.     Private Declare Function HttpSendRequest Lib "wininet.dll" Alias "HttpSendRequestA" ( _
  50.     ByVal hHttpRequest As IntPtr, _
  51.     ByVal lpszHeaders As String, _
  52.     ByVal dwHeadersLength As Integer, _
  53.     ByVal lpOptional As String, _
  54.     ByVal dwOptionalLength As Integer) As Boolean
  55.  
  56.     Private Declare Function InternetReadFile Lib "wininet.dll" ( _
  57.     ByVal hFile As IntPtr, _
  58.     ByVal lpBuffer As String, _
  59.     ByVal dwNumberOfBytesToRead As Integer, _
  60.     ByRef lpNumberOfBytesRead As Integer) As Boolean
  61.  
  62.  
  63.     Private _connect As IntPtr
  64.     Private Property Connect() As IntPtr
  65.         Get
  66.             Return _connect
  67.         End Get
  68.         Set(ByVal value As IntPtr)
  69.             _connect = value
  70.         End Set
  71.     End Property
  72.  
  73.  
  74.     Private _hInet As IntPtr
  75.     Private Property hInet() As IntPtr
  76.         Get
  77.             Return _hInet
  78.         End Get
  79.         Set(ByVal value As IntPtr)
  80.             _hInet = value
  81.         End Set
  82.     End Property
  83.  
  84.     Private _conneted As Boolean
  85.     Public Property Connected() As Boolean
  86.         Get
  87.             Return _conneted
  88.         End Get
  89.         Set(ByVal value As Boolean)
  90.             _conneted = value
  91.         End Set
  92.     End Property
  93.  
  94.     Private Sub OpenConnection(ByVal address As String, ByVal user As String, ByVal pass As String)
  95.         hInet = InternetOpen("Internet Explorer", 1, vbNullString, vbNullString, 0)
  96.         If hInet = IntPtr.Zero Then
  97.             Connected = False
  98.         Else
  99.             Connect = InternetConnect(hInet, address, 80, user, pass, 3, 0, IntPtr.Zero)
  100.             If Connect = IntPtr.Zero Then
  101.                 Connected = False
  102.             Else
  103.                 Connected = True
  104.             End If
  105.         End If
  106.     End Sub
  107.  
  108.     Sub Main()
  109.         Console.Title = "HTTP wininet test -loyalty"
  110.         Console.WriteLine("Url: http://pastebin.com/raw.php?i=di50yjGJ" & vbCrLf)
  111.         OpenConnection("pastebin.com", vbNullString, vbNullString)
  112.         If Connected Then
  113.             Dim req As IntPtr = HttpOpenRequest(Connect, "GET", "/raw.php?i=di50yjGJ", "HTTP/1.0", vbNullString, vbNullString, 524288, 0)
  114.             If Not req = IntPtr.Zero Then
  115.                 If HttpSendRequest(req, vbNullString, 0, vbNullString, 0) Then
  116.                     Dim s As String = Space(255)
  117.                     Dim r As Integer
  118.                     If InternetReadFile(req, s, Len(s), r) Then
  119.                         Console.WriteLine("Page Content: " & s.TrimEnd)
  120.                         Console.WriteLine("Content Length: " & r)
  121.                     Else
  122.                         Console.WriteLine("Error reading the file!")
  123.                     End If
  124.                 Else
  125.                     Console.WriteLine("Error sending the request!")
  126.                 End If
  127.             Else
  128.                 Console.WriteLine("Error opening the request!")
  129.             End If
  130.         Else
  131.             Console.WriteLine("Unable to connect!")
  132.         End If
  133.         Console.ReadKey()
  134.     End Sub
  135.  
  136. End Module