Hack Forums
[.NET] [VB.NET] Display MAC Address From Enterd Local Machines IP - 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] [VB.NET] Display MAC Address From Enterd Local Machines IP (/showthread.php?tid=505397)



[VB.NET] Display MAC Address From Enterd Local Machines IP - codepoet - Jun 26, 2010



Description:
Code
This Displays MAC Address, add 1 textbox call it MacLocalIPAddressBox and one label called MACAddressDisplayLabel. Then all you need to do is add the code below
and add local machines ip addresss ie 192.168.1.1 then press the button and the label will display the mac address for each local machines ip.

Declarations:
Code
Declare Function SendARP Lib "iphlpapi.dll" Alias "SendARP" (ByVal DestIP As Int32, ByVal SrcIP As Int32, ByVal pMacAddr() As Byte, ByRef PhyAddrLen As Int32) As Int32

Code:
Code
Public Shared Function GetMac(ByVal ipAddr As String) As String

        Dim macAddress As String = String.Empty
        Try
            Dim destIP As Net.IPAddress = Net.IPAddress.Parse(ipAddr)
            Dim IP() As Byte = destIP.GetAddressBytes()
            Dim IPInt As Int32 = BitConverter.ToInt32(IP, 0)
            Dim mac() As Byte = New Byte(5) {}
            SendARP(IPInt, 0, mac, mac.Length)
            macAddress = BitConverter.ToString(mac, 0, mac.Length)
        Catch ex As Exception
            Debug.Write(ex.Message)
        End Try
        Return macAddress

End Function

Usage:
Code
Private Sub button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1.Click

Me.MACAddressDisplayLabel.Text = GetMac(Me.MacLocalIPAddressBox.Text)
End Sub

I Hope This helped you all.


-NathanE




* - g1ll1s - Jun 26, 2010

Thanks, do you know how to scan a network and get ip's and computer names in vb.net?

Thanks


* - codepoet - Jun 26, 2010

(Jun 26, 2010 11:08 PM)g1ll1s Wrote:  Thanks, do you know how to scan a network and get ip's and computer names in vb.net?

Thanks

I don't fully understand what you are asking but, you can scan an ip for open ports. but you can not get computer information unless that computer send that info to you via (using) RATs, Keyloggers and RootKits.


* - g1ll1s - Jun 26, 2010

Well, what I mean is this:

Click button 1, then it retrieves all the computers (Internal) ip's that are on your LAN and writes them to a label.

Like a network scanner.


* - codepoet - Jun 26, 2010

(Jun 26, 2010 11:15 PM)g1ll1s Wrote:  Well, what I mean is this:

Click button 1, then it retrieves all the computers (Internal) ip's that are on your LAN and writes them to a label.

Like a network scanner.

Well in that case that might actually be possible. ill look into that.

looks like i forund my next project 😁

-NathanE