如何确定手机是唯一的。
问题:我有一部手机,我如何能确定我的手机是世界上唯一的?
补充:
1、如果你告诉我用IEMI码来识别,那么请告诉我如何能保证IEMI码不被别人修改。
2、如果你告诉我用手机号来识别,那么请告诉我如何用代码读取到手机号(模拟器我也能读出来,我需要的是真机)。
3、如果你有其他方法,那就太好了,我就需要其他方案。
[解决办法]
windows mobile 上面有个unique id ,是根据app的guid和硬件的一些属性运算得来的
HRESULT GetDeviceUniqueID(
LPBYTE pbApplicationData,
DWORD cbApplictionData,
DWORD dwDeviceIDVersion,
LPBYTE pbDeviceIDOutput,
DWORD *pcbDeviceIDOutput
);
不知道离你的要求还远不远
[解决办法]
namespace DeviceID{ /// <summary> /// Summary description for DeviceID. /// </summary> public class DeviceID : System.Windows.Forms.Form { public DeviceID() { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // } /// <summary> /// Clean up any resources being used. /// </summary> protected override void Dispose( bool disposing ) { base.Dispose( disposing ); } #region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { // // DeviceID // this.Text = "DeviceID"; this.Load += new System.EventHandler(this.DeviceID_Load); } static void Main() { Application.Run(new DeviceID()); } #endregion private static Int32 METHOD_BUFFERED = 0; private static Int32 FILE_ANY_ACCESS = 0; private static Int32 FILE_DEVICE_HAL = 0x00000101; private const Int32 ERROR_NOT_SUPPORTED = 0x32; private const Int32 ERROR_INSUFFICIENT_BUFFER = 0x7A; private static Int32 IOCTL_HAL_GET_DEVICEID = ((FILE_DEVICE_HAL) << 16) | ((FILE_ANY_ACCESS) << 14) | ((21) << 2) | (METHOD_BUFFERED); [DllImport("coredll.dll", SetLastError=true)] private static extern bool KernelIoControl(Int32 dwIoControlCode, IntPtr lpInBuf, Int32 nInBufSize, byte[] lpOutBuf, Int32 nOutBufSize, ref Int32 lpBytesReturned); private static string GetDeviceID() { // Initialize the output buffer to the size of a // Win32 DEVICE_ID structure. byte[] outbuff = new byte[20]; Int32 dwOutBytes; bool done = false; Int32 nBuffSize = outbuff.Length; // Set DEVICEID.dwSize to size of buffer. Some platforms look at // this field rather than the nOutBufSize param of KernelIoControl // when determining if the buffer is large enough. BitConverter.GetBytes(nBuffSize).CopyTo(outbuff, 0); dwOutBytes = 0; // Loop until the device ID is retrieved or an error occurs. while (! done) { if (KernelIoControl(IOCTL_HAL_GET_DEVICEID, IntPtr.Zero, 0, outbuff, nBuffSize, ref dwOutBytes)) { done = true; } else { int error = Marshal.GetLastWin32Error(); switch (error) { case ERROR_NOT_SUPPORTED: throw new NotSupportedException( "IOCTL_HAL_GET_DEVICEID is not supported on this device", new Win32Exception(error)); case ERROR_INSUFFICIENT_BUFFER: // The buffer is not big enough for the data. The // required size is in the first 4 bytes of the output // buffer (DEVICE_ID.dwSize). nBuffSize = BitConverter.ToInt32(outbuff, 0); outbuff = new byte[nBuffSize]; // Set DEVICEID.dwSize to size of buffer. Some // platforms look at this field rather than the // nOutBufSize param of KernelIoControl when // determining if the buffer is large enough. BitConverter.GetBytes(nBuffSize).CopyTo(outbuff, 0); break; default: throw new Win32Exception(error, "Unexpected error"); } } } // Copy the elements of the DEVICE_ID structure. Int32 dwPresetIDOffset = BitConverter.ToInt32(outbuff, 0x4); Int32 dwPresetIDSize = BitConverter.ToInt32(outbuff, 0x8); Int32 dwPlatformIDOffset = BitConverter.ToInt32(outbuff, 0xc); Int32 dwPlatformIDSize = BitConverter.ToInt32(outbuff, 0x10); StringBuilder sb = new StringBuilder(); for (int i = dwPresetIDOffset; i < dwPresetIDOffset + dwPresetIDSize; i++) { sb.Append(String.Format("{0:X2}", outbuff[i])); } sb.Append("-"); for (int i = dwPlatformIDOffset; i < dwPlatformIDOffset + dwPlatformIDSize; i ++ ) { sb.Append( String.Format("{0:X2}", outbuff[i])); } return sb.ToString(); } private void DeviceID_Load(object sender, System.EventArgs e) { try { // Show the device ID. string strDeviceID = GetDeviceID(); MessageBox.Show("Device ID: " + strDeviceID); // Show the device name. string deviceName = System.Net.Dns.GetHostName(); MessageBox.Show("Device Name: " + deviceName); } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } } }}
[解决办法]
1.sim卡里的一些信息是唯一的,开机后会把这些信息传送给网络,网络通过这些信息来确定电话号码。比如sim卡里有个数123,运营商把这个123和电话号码321绑定,如果有人呼叫电话号码321,运营商就会去寻找sim卡编号为123的用户。就是说电话号码是存在运营商那里的,手机不可能知道。另外,这也只能识别sim卡不能确定手机。
2.IMEI在技术上过于脆弱。
3.某些基带处理器的chip id是唯一的。
4.某些芯片支持otp(one time program)寄存器,出厂前为每台手机写入唯一的串号,在写入的同时给某个引脚加入电压熔断efuse,就可以永久改变这个寄存器。
5.购买安全芯片。
6.对某块用户区flash做crc校验。
如果你是手机生产商读chip id是最简单有效的方法,第四第五也都不错。
如果你是手机设计公司,需要外包给工厂生产,第四个方法可能会给工厂出卖你的机会。
如果你是面向终端用户的第三方软件提供商,通常没有调用太底层的接口所以第一种和第六种方法虽然不够完美,但是也是一种选择。
如果你是面向集成商的第三方软件提供商,放弃技术手段吧,你提供的库很容易被拆开并破解。你应该在sp服务法律手段上想法子。