Februari 02, 2010

Program Mendeteksi MAC Address


Apakah itu MAC Address?MAC Address adalah singkatan dari Media Accsess Control Address,secara mudahnya adalah nomor seri unik yang "terpasang" dikartu jaringan. Jadi MAC Address ada di level hardware.Ya...mirip-mirip IP address,tetapi formatnya berbedadengan format IP Address.Tetapi disisi lain,kegunaannya juga hampir sama yaitu sebagai penanda unik,hanya saja penanda ini bercokolnya pada harware kartu jaringan.
Dalam banyak hal,mengetahui MAC Address cukup membantu dalam menggali informasi lebih banyak mengenai suatu host.

Untuk Sourcodenya seperti di bawah ini:

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 SrcIP As Long,_
pMacAddr As Long,_
PhyAddrLen As Long)As Long

Private Declare Sub CopyMemory Lib "kernel32"_
Alias "RtMoveMemory"_
(dst As Any,_
src As Any,_
ByVal bcount As Long)

Private Sub Command1_Click()
Dim sRemoteMacAddress As String

If Len(Text1.Text) > 0 Then
If GetRemoteMACAddress(Text1.Text, sRemoteMacAddress) Then
Label3.Caption = sRemoteMacAddress
Else
Label3.Caption = "(SendARP call failed)"
End If
End If
End Sub

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

NB: Menggunakan VB

0 komentar:

 
Narendra Site Copyright © 2009 Blogger Template Designed by Bie Blogger Template