Hack Forums
[.NET] Website To Ip VB.NET + Source! - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [.NET] Website To Ip VB.NET + Source! (/showthread.php?tid=4733431)



Website To Ip VB.NET + Source! - TheFullyFledged - Mar 16, 2015

Website To Ip VB.NET + Source!


DOWNLOAD


Code
dropbox.com/s/sqku1bfhgpm60xq/Website%20To%20Ip.exe?dl=0

virustotal .com/en/file/c38aac45c4e819beadd0e09bcf5108ceee208b1f16d8aa50436641e4d9082574/analysis/


Code
Imports System.Net
Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
      Dim Hostname As IPHostEntry = Dns.GetHostByName(TextBox1.Text)
      Dim ip As IPAddress() = Hostname.AddressList
      TextBox2.Text = ip(0).ToString
    End Sub

    Private Sub Label1_Click(sender As Object, e As EventArgs) Handles Label1.Click

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
      TextBox1.Clear()
      TextBox2.Clear()
    End Sub
End Class



* - evilivid - Mar 16, 2015

Can you explain what you have done here? Do you understand the functionality of the dns class and net namespace?

edit: Lol OP viewed his thread, then viewd my reputation, then reported my post, i think.


* - Odus - Mar 16, 2015

https://hackforums.net/showthread.php?tid=4731782

Did you make a new account?


* - TheFullyFledged - Mar 16, 2015

(Mar 16, 2015 11:51 AM)Odus Wrote:  hackforums .net/showthread.php?tid=4731782

Did you make a new account?
No thats my friend he stole my program and posted it i'm trying to get him to take it down!



* - evilivid - Mar 16, 2015

(Mar 16, 2015 11:58 AM)TheFullyFledged Wrote:  No thats my friend he stole my program and posted it i'm trying to get him to take it down!

Your font is hard to read and your friend and you both posted the same snippet of code and it appears neither of you understand what it does.

Dim Hostname As IPHostEntry = Dns.GetHostByName(TextBox1.Text)
Dim ip As IPAddress() = Hostname.AddressList
TextBox2.Text = ip(0).ToString

Also you only returned a single address from the host.


* - TheFullyFledged - Mar 16, 2015

(Mar 16, 2015 12:12 PM)evilivid Wrote:  Your font is hard to read and your friend and you both posted the same snippet of code and it appears neither of you understand what it does.

Dim Hostname As IPHostEntry = Dns.GetHostByName(TextBox1.Text)
Dim ip As IPAddress() = Hostname.AddressList
TextBox2.Text = ip(0).ToString

Also you only returned a single address from the host.

Im still learning but thanks for the feedback


* - evilivid - Mar 16, 2015

(Mar 16, 2015 12:14 PM)TheFullyFledged Wrote:  Im still learning but thanks for the feedback

Then learn what you are doing.

You are using System.Net
You are using IPHostentry class, it's very simple.
You used the IPaddress class, you can get IP6 as well as IP4 however you only get one. "ip(0)"


* - n0$f3ratu$ - Mar 16, 2015

Code
Private Function GetIPAddress()
      Try
      Dim req As HttpWebRequest = WebRequest.Create("http://wtfismyip.com/text")
      Dim res As HttpWebResponse = req.GetResponse()
      Dim Stream As Stream = res.GetResponseStream()
      Dim sr As StreamReader = New StreamReader(Stream)
      Return (sr.ReadToEnd())
      Catch error_t As Exception
      MessageBox.Show(error_t.ToString)
      End Try
      Return Nothing
    End Function

Code
Private Function GetIPv4Address() As String
      GetIPv4Address = String.Empty
      Dim strHostName As String = Dns.GetHostName()
      Dim iphe As IPHostEntry = Dns.GetHostEntry(strHostName)

      For i As Integer = LBound(iphe.AddressList) To UBound(iphe.AddressList) Step 1
      Dim ipheal As IPAddress = iphe.AddressList(i)
      If ipheal.AddressFamily = Sockets.AddressFamily.InterNetwork Then
            GetIPv4Address = ipheal.ToString()
      End If
      Next
    End Function



* - Stаlkеr - Mar 16, 2015

(Mar 16, 2015 12:51 PM)n0$f3ratu$ Wrote:  
Code
Private Function GetIPAddress()
      Try
      Dim req As HttpWebRequest = WebRequest.Create("http://wtfismyip.com/text")
      Dim res As HttpWebResponse = req.GetResponse()
      Dim Stream As Stream = res.GetResponseStream()
      Dim sr As StreamReader = New StreamReader(Stream)
      Return (sr.ReadToEnd())
      Catch error_t As Exception
      MessageBox.Show(error_t.ToString)
      End Try
      Return Nothing
    End Function

Code
Private Function GetIPv4Address() As String
      GetIPv4Address = String.Empty
      Dim strHostName As String = Dns.GetHostName()
      Dim iphe As IPHostEntry = Dns.GetHostEntry(strHostName)

      For i As Integer = LBound(iphe.AddressList) To UBound(iphe.AddressList) Step 1
      Dim ipheal As IPAddress = iphe.AddressList(i)
      If ipheal.AddressFamily = Sockets.AddressFamily.InterNetwork Then
      GetIPv4Address = ipheal.ToString()
      End If
      Next
    End Function

Pretty clean and easy to understand nice code mate ✌


* - Odus - Mar 16, 2015

(Mar 16, 2015 01:04 PM)Zer0 Gh0st Wrote:  Pretty clean and easy to understand nice code mate ✌

I spot a lot of room for improvement, even if his code is completely unrelated.

Code
Private ReadOnly _wc As New WebClient
Private Function FetchPublic() As String
    Return _wc.DownloadString("http://wtfismyip.com/text")
End Function
Private Function FetchIPv4() As String
    Return Dns.GetHostEntry(Dns.GetHostName).AddressList.First(Function(a) a.AddressFamily.Equals(AddressFamily.InterNetwork)).ToString()
End Function

Edit: Forgot the webclient.


* - ๖ۣۜSyria - Mar 16, 2015

Why all this work when we can all go to cmd and and type ping www.google.com?


* - Ninja - Mar 17, 2015

This has already been posted hundreds of times and is one search on Google away.


* - Streetlight. - Mar 17, 2015

Wow! Next gen level programs thank you so much!