954,148 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How to get mac address with input ip address

Hi All,
How can i get mac address from other computers with input ip address?

Please helps
Best Regards...

Estella
Junior Poster in Training
99 posts since Jan 2008
Reputation Points: 64
Solved Threads: 7
 

use this api function estella :

Private Declare Function inet_addr Lib "wsock32.dll" (ByVal s As String) As Long
Private Declare Function SendARP Lib "iphlpapi.dll" (ByVal DestIp As Long, ByVal ScrIP As Long, pMacAddr As Long, PhyAddrLen As Long) As Long
Private Declare Sub CopyMemory Lib "kernel32.dll" Alias "RtlMoveMemory" (dst As Any, src As Any, ByVal bcount As Long)
Jx_Man
Nearly a Senior Poster
3,328 posts since Nov 2007
Reputation Points: 1,372
Solved Threads: 444
 

That's excellent, I've wondered how that was done.
(rep added)

jonifen
Junior Poster
152 posts since Nov 2007
Reputation Points: 13
Solved Threads: 17
 

thx for the reply jx_man, but i really newbie in this. may i get some ex code please???

Best Regards...

Estella
Junior Poster in Training
99 posts since Jan 2008
Reputation Points: 64
Solved Threads: 7
 

Try This following Code :

Option Explicit

Private Const No_ERROR = 0

Private Declare Function inet_addr Lib "wsock32.dll" (ByVal s As String) As Long
Private Declare Function SendARP Lib "iphlpapi.dll" (ByVal DestIp As Long, ByVal ScrIP As Long, pMacAddr As Long, PhyAddrLen As Long) As Long
Private Declare Sub CopyMemory Lib "kernel32.dll" Alias "RtlMoveMemory" (dst As Any, src As Any, ByVal bcount As Long)

Private Function GetRemoteMACAddress(ByVal sRemoteIP As String, sRemoteMacAddress As String) As Boolean
    Dim dwRemoteIp As Long
    Dim pMacAddr As Long
    Dim bpMacAddr() As Byte
    Dim PhyAddrLen As Long
    Dim cnt As Long
    Dim tmp As String
    
    dwRemoteIp = inet_addr(sRemoteIP)
    If dwRemoteIp <> 0 Then
        PhyAddrLen = 6
        If SendARP(dwRemoteIp, 0&, pMacAddr, PhyAddrLen) = No_ERROR Then
            If pMacAddr <> 0 And PhyAddrLen <> 0 Then
                ReDim bpMacAddr(0 To PhyAddrLen - 1)
                CopyMemory bpMacAddr(0), pMacAddr, ByVal PhyAddrLen
                For cnt = 0 To PhyAddrLen - 1
                    If bpMacAddr(cnt) = 0 Then
                        tmp = tmp & "00-"
                    Else
                        tmp = tmp & Hex$(bpMacAddr(cnt)) & "-"
                    End If
                Next
                
                If Len(tmp) > 0 Then
                    sRemoteMacAddress = Left$(tmp, Len(tmp) - 1)
                    GetRemoteMACAddress = True
                End If
                
                Exit Function
            Else
                GetRemoteMACAddress = False
            End If
        Else
            GetRemoteMACAddress = False
        End If
    Else
        GetRemoteMACAddress = False
    End If
End Function

Private Sub btnGetMac_Click()
Dim sRemoteMacAddress As String
If Len(txtIpAddress.Text) > 0 Then
    If GetRemoteMACAddress(txtIpAddress.Text, sRemoteMacAddress) Then
        lblMacAddress.Caption = sRemoteMacAddress
    Else
        lblMacAddress.Caption = "(SendARP call failed)"
    End If
End If
End Sub

Actually this code can use as hacking tool, so use this code carefully friend.

It seems like this pic : MAC Address.bmp

Attachments MAC_Address.bmp (127.71KB)
Jx_Man
Nearly a Senior Poster
3,328 posts since Nov 2007
Reputation Points: 1,372
Solved Threads: 444
 

Wow, Thx a lot Jx_Man. this a wonderful code.

Estella
Junior Poster in Training
99 posts since Jan 2008
Reputation Points: 64
Solved Threads: 7
 

you're welcome.
happy coding and once again careful with the code.

Jx_Man
Nearly a Senior Poster
3,328 posts since Nov 2007
Reputation Points: 1,372
Solved Threads: 444
 

wonderful code... :)

Neji
Light Poster
28 posts since Feb 2008
Reputation Points: 34
Solved Threads: 1
 

AMAZING... that's all i can say.. ^^

batsam
Newbie Poster
1 post since May 2009
Reputation Points: 10
Solved Threads: 0
 

Get MAC and IP addresses into your C# or any .NET programs by this DLL (download from this Link)

http://www.fileupyours.com/view/246666/CSharp%20Get%20MAC%20IP%20address%20DLL.zip

The program module DLL in this link is written in C# to provide the programmer the easiest method to find the MAC and the IP addresses of the PC, laptop or server. Download the ZIP file and extract DLL (6 Kb) and the PDF explaining how to add this DLL into your program. You dont have to define any field or any program module in your development environment. Just add the DLL file into the references in Visual Studio Solution Browser. Read the PDF file, everything is explained there, so easy, just few lines and all the network adapter MAC and IP addresses are in your program.

By Omer IRKAD [email]omer.irkad@hotmail.com[/email]

Get MAC and IP addresses into your C# or any .NET programs by this DLL (download from this Link)

http://www.fileupyours.com/view/246666/CSharp%20Get%20MAC%20IP%20address%20DLL.zip

omer.irkad
Newbie Poster
1 post since May 2009
Reputation Points: 10
Solved Threads: 0
 

Try This following Code :

Option Explicit

Private Const No_ERROR = 0

Private Declare Function inet_addr Lib "wsock32.dll" (ByVal s As String) As Long
Private Declare Function SendARP Lib "iphlpapi.dll" (ByVal DestIp As Long, ByVal ScrIP As Long, pMacAddr As Long, PhyAddrLen As Long) As Long
Private Declare Sub CopyMemory Lib "kernel32.dll" Alias "RtlMoveMemory" (dst As Any, src As Any, ByVal bcount As Long)

Private Function GetRemoteMACAddress(ByVal sRemoteIP As String, sRemoteMacAddress As String) As Boolean
    Dim dwRemoteIp As Long
    Dim pMacAddr As Long
    Dim bpMacAddr() As Byte
    Dim PhyAddrLen As Long
    Dim cnt As Long
    Dim tmp As String
    
    dwRemoteIp = inet_addr(sRemoteIP)
    If dwRemoteIp <> 0 Then
        PhyAddrLen = 6
        If SendARP(dwRemoteIp, 0&, pMacAddr, PhyAddrLen) = No_ERROR Then
            If pMacAddr <> 0 And PhyAddrLen <> 0 Then
                ReDim bpMacAddr(0 To PhyAddrLen - 1)
                CopyMemory bpMacAddr(0), pMacAddr, ByVal PhyAddrLen
                For cnt = 0 To PhyAddrLen - 1
                    If bpMacAddr(cnt) = 0 Then
                        tmp = tmp & "00-"
                    Else
                        tmp = tmp & Hex$(bpMacAddr(cnt)) & "-"
                    End If
                Next
                
                If Len(tmp) > 0 Then
                    sRemoteMacAddress = Left$(tmp, Len(tmp) - 1)
                    GetRemoteMACAddress = True
                End If
                
                Exit Function
            Else
                GetRemoteMACAddress = False
            End If
        Else
            GetRemoteMACAddress = False
        End If
    Else
        GetRemoteMACAddress = False
    End If
End Function

Private Sub btnGetMac_Click()
Dim sRemoteMacAddress As String
If Len(txtIpAddress.Text) > 0 Then
    If GetRemoteMACAddress(txtIpAddress.Text, sRemoteMacAddress) Then
        lblMacAddress.Caption = sRemoteMacAddress
    Else
        lblMacAddress.Caption = "(SendARP call failed)"
    End If
End If
End Sub

Actually this code can use as hacking tool, so use this code carefully friend.

It seems like this pic : MAC Address.bmp

hi, i would like to enquiry about the following:
lblMacAddress.Caption --> is this a label in visual studio? if not,what do i use?
CopyMemory bpMacAddr(0), pMacAddr, ByVal PhyAddrLen -
byMacAddr error: Method arguement must be enclosed in parenthesis
ByVal error: expression expected.
Left$ --> has no parameters and return type cannot be indexed.

i am currently using visual studio 2005. Kindly help me regarding the mentioned issue . Thanks!

JoJo1811
Newbie Poster
1 post since Aug 2009
Reputation Points: 10
Solved Threads: 0
 

i was long searching for that code that estalla asked... though i could copy that code, is it ok for you if i will try to use it also? thanks, so much!

please...

luquin
Newbie Poster
2 posts since Aug 2009
Reputation Points: 10
Solved Threads: 0
 

i was long searching for such code estella asked... though i could copy it, can ask your permission to use it also? please... my purpose is educational... please sir...

luquin
Newbie Poster
2 posts since Aug 2009
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You