Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

GET Request + finding status code

How can I make GET request to the API and then save the HTTP status code?
For sale message me
Are you talking about banner grabbing, like with net cat or telnet?
Earning for the year 2017:
super spooky
(Nov 6, 2016 02:13 PM)Papa Cuda Wrote:  Are you talking about banner grabbing headers?
Basically, I want to do something like

GET http://api.domain.com/profiles/<input&gt;

Then save the code it returns (403, 404, etc)
For sale message me
(Nov 6, 2016 02:14 PM)Egregious Jr. Wrote:  Basically, I want to do something like

GET http://api.domain.com/profiles/<input&gt;

Then save the code it returns (403, 404, etc)

If I'm understanding you correctly open a terminap and type

PHP Code

<?php 
nc 
-v targetip > codereturns.txt 

Then

PHP Code

<?php 
GET 
/ HTTP / 1.1
Host
: target ip 

I think this is what you want? IF it's not I apologize and I'll reform my answer.
Earning for the year 2017:
super spooky
(Nov 6, 2016 02:17 PM)Papa Cuda Wrote:  If I'm understanding you correctly open a terminap and type

PHP Code

<?php 
nc 
-v targetip > codereturns.txt 

Then

PHP Code

<?php 
GET 
/ HTTP / 1.1
Host
: target ip 

I think this is what you want? IF it's not I apologize and I'll reform my answer.
Uhm, this is the vb.net section, I'm looking for how to do this in vb.net.
For sale message me
(Nov 6, 2016 02:20 PM)Egregious Jr. Wrote:  Uhm, this is the vb.net section, I'm looking for how to do this in vb.net.

🤣 oh my god I'm sorry I wasted your time.

This may actually help

PHP Code

<?php 
Imports System
.Threading
Imports System
.Net
Imports System
.Net.Sockets
Imports System
.Text
Imports System
.IO

Module Module1
    
Public ScanningThreads As Integer
    Sub Main
()
  
Console.WriteLine("Enter number of threads and press ENTER (50 is a good choice)")
  
ScanningThreads = Convert.ToInt32(Console.ReadLine())
  
FillPortsList()
  Try
    For 
i As Integer = 0 To ScanningThreads
    Dim GrabberThread 
As New Thread(AddressOf GrabBannerJob)
    
GrabberThread.Start()
    
Next i
  
Catch ex As Exception
    Console
.WriteLine(ex.ToString())
    
Console.ReadLine()
  
End Try
    
End Sub

    
Public _rng As New Random()

    Public Function 
rNext(ByVal min As Integer, ByVal max As Integer) As Integer
  
Return _rng.Next(min, max)
    
End Function

    Public Function 
GenerateIp() As String
  
Return rNext(11, 239) & "." & rNext(1, 255) & "." & rNext(1, 255) & "." & rNext(1, 255)
    
End Function

    Public 
PortsList As New List(Of Integer)()

    Public 
Sub FillPortsList()
  
PortsList.Add(21)
  
PortsList.Add(22)
  
PortsList.Add(1406)
  
PortsList.Add(25)
  
PortsList.Add(5900)
    
End Sub

    
Public Sub SockConnect(ByVal sIpadress As String, ByVal sPort As Integer)
  
Dim data As Byte() = New Byte(1023) {}
  
Dim stringData As String
  Dim recv 
As Integer
  Dim ipep 
As New IPEndPoint(IPAddress.Parse(sIpadress), sPort)
  
Dim server As New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
  Try
    
server.Connect(ipep)
    
Dim ns As New NetworkStream(server)
    If 
ns.CanRead Then
    recv 
= ns.Read(data, 0, data.Length)
    
stringData = Encoding.ASCII.GetString(data, 0, recv)
    If 
stringData <> "" Then
    Console
.WriteLine(sIpadress & ":" & sPort & " : " & stringData)
    
File.AppendAllText("banners.txt", sIpadress & ":" & sPort & " : " & stringData & vbCr & vbLf)
    
End If
    Else
    
ns.Close()
    
server.Close()
    
End If
  Catch
  
End Try

    
End Sub

    
Public Sub GrabBannerJob()
  While 
True
    
Try
    
Dim ipadress As String = GenerateIp()
    For 
Each lPort As Integer In PortsList
    Dim port 
As Integer = lPort
    SockConnect
(ipadress, port)
    
Next
                
Catch
                
End Try
            
End While
        
End Sub
End Module 
Earning for the year 2017:
super spooky
(Nov 6, 2016 02:23 PM)Papa Cuda Wrote:  🤣 oh my god I'm sorry I wasted your time.

This may actually help

PHP Code

<?php 
Imports System
.Threading
Imports System
.Net
Imports System
.Net.Sockets
Imports System
.Text
Imports System
.IO

Module Module1
    
Public ScanningThreads As Integer
    Sub Main
()
  
Console.WriteLine("Enter number of threads and press ENTER (50 is a good choice)")
  
ScanningThreads = Convert.ToInt32(Console.ReadLine())
  
FillPortsList()
  Try
    For 
i As Integer = 0 To ScanningThreads
    Dim GrabberThread 
As New Thread(AddressOf GrabBannerJob)
    
GrabberThread.Start()
    
Next i
  
Catch ex As Exception
    Console
.WriteLine(ex.ToString())
    
Console.ReadLine()
  
End Try
    
End Sub

    
Public _rng As New Random()

    Public Function 
rNext(ByVal min As Integer, ByVal max As Integer) As Integer
  
Return _rng.Next(min, max)
    
End Function

    Public Function 
GenerateIp() As String
  
Return rNext(11, 239) & "." & rNext(1, 255) & "." & rNext(1, 255) & "." & rNext(1, 255)
    
End Function

    Public 
PortsList As New List(Of Integer)()

    Public 
Sub FillPortsList()
  
PortsList.Add(21)
  
PortsList.Add(22)
  
PortsList.Add(1406)
  
PortsList.Add(25)
  
PortsList.Add(5900)
    
End Sub

    
Public Sub SockConnect(ByVal sIpadress As String, ByVal sPort As Integer)
  
Dim data As Byte() = New Byte(1023) {}
  
Dim stringData As String
  Dim recv 
As Integer
  Dim ipep 
As New IPEndPoint(IPAddress.Parse(sIpadress), sPort)
  
Dim server As New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
  Try
    
server.Connect(ipep)
    
Dim ns As New NetworkStream(server)
    If 
ns.CanRead Then
    recv 
= ns.Read(data, 0, data.Length)
    
stringData = Encoding.ASCII.GetString(data, 0, recv)
    If 
stringData <> "" Then
    Console
.WriteLine(sIpadress & ":" & sPort & " : " & stringData)
    
File.AppendAllText("banners.txt", sIpadress & ":" & sPort & " : " & stringData & vbCr & vbLf)
    
End If
    Else
    
ns.Close()
    
server.Close()
    
End If
  Catch
  
End Try

    
End Sub

    
Public Sub GrabBannerJob()
  While 
True
    
Try
    
Dim ipadress As String = GenerateIp()
    For 
Each lPort As Integer In PortsList
    Dim port 
As Integer = lPort
    SockConnect
(ipadress, port)
    
Next
                
Catch
                
End Try
            
End While
        
End Sub
End Module 
Don't think that's it. No problem lol
For sale message me
(Nov 6, 2016 02:13 PM)Papa Cuda Wrote:  Are you talking about banner grabbing, like with net cat or telnet?


(Nov 6, 2016 02:17 PM)Papa Cuda Wrote:  If I'm understanding you correctly open a terminap and type

PHP Code

<?php 
nc 
-v targetip > codereturns.txt 

Then

PHP Code

<?php 
GET 
/ HTTP / 1.1
Host
: target ip 

I think this is what you want? IF it's not I apologize and I'll reform my answer.


(Nov 6, 2016 02:23 PM)Papa Cuda Wrote:  🤣 oh my god I'm sorry I wasted your time.

This may actually help

PHP Code

<?php 
Imports System
.Threading
Imports System
.Net
Imports System
.Net.Sockets
Imports System
.Text
Imports System
.IO

Module Module1
    
Public ScanningThreads As Integer
    Sub Main
()
  
Console.WriteLine("Enter number of threads and press ENTER (50 is a good choice)")
  
ScanningThreads = Convert.ToInt32(Console.ReadLine())
  
FillPortsList()
  Try
    For 
i As Integer = 0 To ScanningThreads
    Dim GrabberThread 
As New Thread(AddressOf GrabBannerJob)
    
GrabberThread.Start()
    
Next i
  
Catch ex As Exception
    Console
.WriteLine(ex.ToString())
    
Console.ReadLine()
  
End Try
    
End Sub

    
Public _rng As New Random()

    Public Function 
rNext(ByVal min As Integer, ByVal max As Integer) As Integer
  
Return _rng.Next(min, max)
    
End Function

    Public Function 
GenerateIp() As String
  
Return rNext(11, 239) & "." & rNext(1, 255) & "." & rNext(1, 255) & "." & rNext(1, 255)
    
End Function

    Public 
PortsList As New List(Of Integer)()

    Public 
Sub FillPortsList()
  
PortsList.Add(21)
  
PortsList.Add(22)
  
PortsList.Add(1406)
  
PortsList.Add(25)
  
PortsList.Add(5900)
    
End Sub

    
Public Sub SockConnect(ByVal sIpadress As String, ByVal sPort As Integer)
  
Dim data As Byte() = New Byte(1023) {}
  
Dim stringData As String
  Dim recv 
As Integer
  Dim ipep 
As New IPEndPoint(IPAddress.Parse(sIpadress), sPort)
  
Dim server As New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
  Try
    
server.Connect(ipep)
    
Dim ns As New NetworkStream(server)
    If 
ns.CanRead Then
    recv 
= ns.Read(data, 0, data.Length)
    
stringData = Encoding.ASCII.GetString(data, 0, recv)
    If 
stringData <> "" Then
    Console
.WriteLine(sIpadress & ":" & sPort & " : " & stringData)
    
File.AppendAllText("banners.txt", sIpadress & ":" & sPort & " : " & stringData & vbCr & vbLf)
    
End If
    Else
    
ns.Close()
    
server.Close()
    
End If
  Catch
  
End Try

    
End Sub

    
Public Sub GrabBannerJob()
  While 
True
    
Try
    
Dim ipadress As String = GenerateIp()
    For 
Each lPort As Integer In PortsList
    Dim port 
As Integer = lPort
    SockConnect
(ipadress, port)
    
Next
                
Catch
                
End Try
            
End While
        
End Sub
End Module 

You deserve a -3 for shit posting, please stay out of this forum if you have no clue what you're talking about. I get the feeling you're trolling too.




@Op What library are you using to create the Http connection? WebClient, HttpWebRequest or HttpClient?
(Nov 6, 2016 04:20 PM)+Haze Wrote:  You deserve a -3 for shit posting, please stay out of this forum if you have no clue what you're talking about. I get the feeling you're trolling too.




@Op What library are you using to create the Http connection? WebClient, HttpWebRequest or HttpClient?
I believe HttpWebRequest.
For sale message me
I have 0 knowledge of vb.net but google is a very powerful tool

http://stackoverflow.com/questions/69234...ode-400-ba

Looks like you need to catch an exception from WebException then just
HttpWebResponse httpResponse = (HttpWebResponse) response;
httpResponse.StatusCode <- will be your HTTP response code

Hope I was of at least some assistance.
(Nov 6, 2016 04:29 PM)Diaxin Wrote:  I have 0 knowledge of vb.net but google is a very powerful tool

http://stackoverflow.com/questions/69234...ode-400-ba

Looks like you need to catch an exception from WebException then just
HttpWebResponse httpResponse = (HttpWebResponse) response;
httpResponse.StatusCode <- will be your HTTP response code

Hope I was of at least some assistance.
Thanks. I'll look into that.
For sale message me
isnt it just...

https://msdn.microsoft.com/en-us/library....110).aspx
(Nov 6, 2016 02:07 PM)Egregious Jr. Wrote:  How can I make GET request to the API and then save the HTTP status code?

The HttpWebResponse has a property called StatusCode.

For the glory of humanity
Thanks guys, I will take a look at those.
For sale message me
https://gist.github.com/GekkeVent/cfd456...f3e64ed8ca
This might help on your WebRequest journey.


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Python] by SIM-4173254Sep 18, 2020 09:18 AM 5 140 Sep 18, 2020 09:18 AM
Last Post: SIM-4173254
[C#] by DotexeAug 5, 2017 04:23 PM 0 154 Aug 5, 2017 04:23 PM
Last Post: Dotexe
[.NET] by _WiZ_Jun 29, 2012 12:42 AM 8 131 Jun 29, 2012 12:42 AM
Last Post: _WiZ_