How to get mac address with input ip address

Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Aug 2009
Posts: 1
Reputation: JoJo1811 is an unknown quantity at this point 
Solved Threads: 0
JoJo1811 JoJo1811 is offline Offline
Newbie Poster

Re: How to get mac address with input ip address

 
0
  #11
Aug 4th, 2009
Originally Posted by Jx_Man View Post
Try This following Code :
  1. Option Explicit
  2.  
  3. Private Const No_ERROR = 0
  4.  
  5. Private Declare Function inet_addr Lib "wsock32.dll" (ByVal s As String) As Long
  6. Private Declare Function SendARP Lib "iphlpapi.dll" (ByVal DestIp As Long, ByVal ScrIP As Long, pMacAddr As Long, PhyAddrLen As Long) As Long
  7. Private Declare Sub CopyMemory Lib "kernel32.dll" Alias "RtlMoveMemory" (dst As Any, src As Any, ByVal bcount As Long)
  8.  
  9. Private Function GetRemoteMACAddress(ByVal sRemoteIP As String, sRemoteMacAddress As String) As Boolean
  10. Dim dwRemoteIp As Long
  11. Dim pMacAddr As Long
  12. Dim bpMacAddr() As Byte
  13. Dim PhyAddrLen As Long
  14. Dim cnt As Long
  15. Dim tmp As String
  16.  
  17. dwRemoteIp = inet_addr(sRemoteIP)
  18. If dwRemoteIp <> 0 Then
  19. PhyAddrLen = 6
  20. If SendARP(dwRemoteIp, 0&, pMacAddr, PhyAddrLen) = No_ERROR Then
  21. If pMacAddr <> 0 And PhyAddrLen <> 0 Then
  22. ReDim bpMacAddr(0 To PhyAddrLen - 1)
  23. CopyMemory bpMacAddr(0), pMacAddr, ByVal PhyAddrLen
  24. For cnt = 0 To PhyAddrLen - 1
  25. If bpMacAddr(cnt) = 0 Then
  26. tmp = tmp & "00-"
  27. Else
  28. tmp = tmp & Hex$(bpMacAddr(cnt)) & "-"
  29. End If
  30. Next
  31.  
  32. If Len(tmp) > 0 Then
  33. sRemoteMacAddress = Left$(tmp, Len(tmp) - 1)
  34. GetRemoteMACAddress = True
  35. End If
  36.  
  37. Exit Function
  38. Else
  39. GetRemoteMACAddress = False
  40. End If
  41. Else
  42. GetRemoteMACAddress = False
  43. End If
  44. Else
  45. GetRemoteMACAddress = False
  46. End If
  47. End Function
  48.  
  49. Private Sub btnGetMac_Click()
  50. Dim sRemoteMacAddress As String
  51. If Len(txtIpAddress.Text) > 0 Then
  52. If GetRemoteMACAddress(txtIpAddress.Text, sRemoteMacAddress) Then
  53. lblMacAddress.Caption = sRemoteMacAddress
  54. Else
  55. lblMacAddress.Caption = "(SendARP call failed)"
  56. End If
  57. End If
  58. End Sub
Actually this code can use as hacking tool, so use this code carefully friend.

It seems like this pic :
Attachment 5027
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!
Last edited by JoJo1811; Aug 4th, 2009 at 10:41 pm. Reason: one more error
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 2
Reputation: luquin is an unknown quantity at this point 
Solved Threads: 0
luquin luquin is offline Offline
Newbie Poster

Re: How to get mac address with input ip address

 
0
  #12
Aug 26th, 2009
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...
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 2
Reputation: luquin is an unknown quantity at this point 
Solved Threads: 0
luquin luquin is offline Offline
Newbie Poster

Re: How to get mac address with input ip address

 
0
  #13
Aug 26th, 2009
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...
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC