how to fingerprint a user's machine?

B

Ben Callister

hello-

i need to have a way to accurately 'fingerprint' an end-user's machine. the
resulting 'fingerprint' needs to be a simple string-based value. currently,
i have created the function listed below that i am using to do this.
however, this appears to break down from time to time and i cant determine
exactly why.

i know that enabling/disable network connections will change the produced
value, but is there something else that would change this? perhaps the type
of encryption i am using? should i use another one? when i run this function
lots of times, it produces the same fingerprint. however, it appears to
change later in the future, and i havent been able to detect why because it
doesnt change each time i call this function.

i am totally open to changing my approach entirely. like i said, i simply
need *some* way to accurately identify an end-user's machine
(programmatically, of course).

can someone please provide me with thoughts and an example that will
accomplish this task better?

many thanks!
ben

--------------------

using System;
using System.Management;
using System.Security.Cryptography;

namespace QC.Forensics.Hardware
{
public class LocalMachine
{
public static string MachineFingerprint
{
get
{
//get the collection of all of the network adapters on the local machine
ManagementClass pManagementClass = new
ManagementClass("Win32_NetworkAdapterConfiguration");
ManagementObjectCollection pMOColl = pManagementClass.GetInstances();

//build our fingerprint, based on all the MAC addresses for each network
card installed on the local machine
string sFingerprint = "";
string sCurMACAddress = "";
foreach(ManagementObject pCurMO in pMOColl)
{
sCurMACAddress = "";
try
{
sCurMACAddress = pCurMO["MacAddress"].ToString();
}
catch { }
if (sCurMACAddress != "")
{
if (sFingerprint == "") sFingerprint = sCurMACAddress;
else sFingerprint = sFingerprint + ":" + sCurMACAddress;
}
}

//now hash our value to get our true fingerprint
byte[] aInBits = System.Text.ASCIIEncoding.ASCII.GetBytes(sFingerprint);
SHA1 pHasher = new SHA1CryptoServiceProvider();
byte[] aOutBits = pHasher.ComputeHash(aInBits);
sFingerprint = Convert.ToBase64String(aOutBits);

return sFingerprint;
}
}
}
}
 
W

William Stacey [MVP]

If your using fx 2.0, you could do this. Not sure if order changes based on
up/down status (i.e. plug/unplug), but that would be easy to test:



byte[] bytes;

if (NetworkInterface.GetIsNetworkAvailable())

bytes =
Encoding.ASCII.GetBytes(NetworkInterface.GetAllNetworkInterfaces()[0].GetPhysicalAddress().ToString());

else

bytes =
Encoding.UTF8.GetBytes(IPGlobalProperties.GetIPGlobalProperties().HostName);

return Convert.ToBase64String(SHA1.Create().ComputeHash(bytes));
 
W

William Stacey [MVP]

Update. Use first regardless of status.



byte[] bytes;

NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();

if (nics.Length > 0)

bytes =
Encoding.ASCII.GetBytes(nics[0].GetPhysicalAddress().ToString());

else

bytes =
Encoding.UTF8.GetBytes(IPGlobalProperties.GetIPGlobalProperties().HostName);

return Convert.ToBase64String(SHA1.Create().ComputeHash(bytes));
 
B

Ben Callister

by 'fx 2.0' do you simply mean '.NET Framework 2.0?' if so, what does the
'fx' stand for?
thanks,
ben
 
W

William Stacey [MVP]

Yes 2.0. fx is short for framework.

--
William Stacey [MVP]

| by 'fx 2.0' do you simply mean '.NET Framework 2.0?' if so, what does the
| 'fx' stand for?
| thanks,
| ben
|
|
| | > If your using fx 2.0, you could do this. Not sure if order changes
based
| > on
| > up/down status (i.e. plug/unplug), but that would be easy to test:
| >
| >
| >
| > byte[] bytes;
| >
| > if (NetworkInterface.GetIsNetworkAvailable())
| >
| > bytes =
| >
Encoding.ASCII.GetBytes(NetworkInterface.GetAllNetworkInterfaces()[0].GetPhysicalAddress().ToString());
| >
| > else
| >
| > bytes =
| >
Encoding.UTF8.GetBytes(IPGlobalProperties.GetIPGlobalProperties().HostName);
| >
| > return Convert.ToBase64String(SHA1.Create().ComputeHash(bytes));
| >
| >
| > --
| > William Stacey [MVP]
| >
| >
| >
|
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top