手機防盜軟體實現(源碼)

來源:互聯網
上載者:User

前段時間母親手機遭賊了,以防萬一,如果自己手機丟了,肯定會更鬱悶,記得很多手機有防盜功能,如果更換了sim卡就會,手機就會自動把新的

sim卡手機號,gps座標,什麼的發送到綁定的手機上。網上查了下資料,這類這類軟體也挺多的。看了看功能也不是很複雜,就自己寫了個玩玩

開發環境 vs2008 wm6   .net cf 3.5

 

實現方法很簡單
1.每一個sim都有唯一的一個IMSI編號,可以根據IMSI編號來判斷手機是否更換sim卡
2.如果檢測到IMSI不是自己的sim卡的,可以確定其他人可能在用你的手機。
3.每次開機程式自動運行,檢測到別人如果使用你的手機,自動把他的通話記錄,跟gps座標發送到綁定好的手機號上。
4.知道用你手機人的手機號,最近通話記錄,gps座標後,再自己想辦法找到這人吧。

 

具體代碼
1.取sim卡IMSI編號
使用 TapiLib.dll類庫中的ControlTapi.GetIMSINumber()取到sim卡imsi編號
2.判斷是不是自己的sim卡
            string simStr=ControlTapi.GetIMSINumber();
            if (simStr.Length != 0)
            {
                if (simStr != SIM)
                {
其中SIM為事先取好的自己手機卡的IMSI編號

3.取最近通話記錄代碼
        [StructLayout(LayoutKind.Sequential)]
        public struct CALLLOGENTRY
        {
            public UInt32 cbSize;
            public UInt64 ftStartTime;
            public UInt64 ftEndTime;
            public short iom;

            public bool fOutgoing;
            public bool fConnected;
            public bool fEnded;

            public bool fRoam;
            public short cidt;
            public IntPtr pszNumber;
            public IntPtr pszName;
            public IntPtr pszNameType;
            public IntPtr pszNote;
        };
        [DllImport("phone.dll", EntryPoint = "PhoneOpenCallLog", SetLastError = true)] //首先要PhoneOpenCallLog開啟通話記錄控制代碼
        private static extern int PhoneOpenCallLog(ref IntPtr pHandle);

        [DllImport("phone.dll", EntryPoint = "PhoneCloseCallLog", SetLastError = true)] //要調用PhoneCloseCallLog關閉控制代碼
        private static extern int PhoneCloseCallLog(IntPtr pHandle);

        [DllImport("phone.dll", EntryPoint = "PhoneGetCallLogEntry", SetLastError = true)]
        private static extern int PhoneGetCallLogEntry(IntPtr pHandke, ref CALLLOGENTRY pEntry);
        //用PhoneGetCallLogEntry方法會返回一個通話記錄結構,在該結構中,包含號碼、姓名、通話開始時間、通話結束時間等資訊。

        private string GetLog()
        {
            string CallInfo = "";

            try
            {
                IntPtr handle = IntPtr.Zero;   //控制代碼

                CALLLOGENTRY entry = new CALLLOGENTRY();
                PhoneOpenCallLog(ref handle);   //首先要PhoneOpenCallLog開啟通話記錄控制代碼
                entry.cbSize = (uint)Marshal.SizeOf(entry);   //返回類的非託管大小

                if (handle != IntPtr.Zero)
                {
                    while (PhoneGetCallLogEntry(handle, ref entry) == 0)   //擷取通話記錄
                    {                       //Marshal.PtrToStringUni   複製指定數目的字元
                        string phoneNumber = Marshal.PtrToStringUni(entry.pszNumber);   //號碼
                        string name = Marshal.PtrToStringUni(entry.pszName);   //姓名

                        if (phoneNumber == null)
                        {
                            phoneNumber = string.Empty;
                        }

                        if (name == null)
                        {
                            name = string.Empty;
                        }

                        string temp = (phoneNumber.Trim() + name.Trim());
                        CallInfo = CallInfo + temp;
                    }
                    PhoneCloseCallLog(handle);

                    if (CallInfo.Length < 140)
                    {
                        return CallInfo;
                    }
                    else
                    {
                        return CallInfo.Substring(0,140);
                    }
                }
                else
                {
                    int error = Marshal.GetLastWin32Error();
                    return "";
                }
            }
            catch (Exception ep)
            {
                //MessageBox.Show(ep.ToString());
                return "";
            }
            finally
            {
            }
           
        }
4.取gps座標代碼
        GpsDeviceState device = null;
        GpsPosition position = null;
        Gps gps = new Gps();

        void gps_DeviceStateChanged(object sender, DeviceStateChangedEventArgs args)
        {
            device = args.DeviceState;
        }

        protected void gps_LocationChanged(object sender, LocationChangedEventArgs args)
        {
            position = args.Position;
            str = "";
            if (position != null)
            {
                //維度
                if (position.LatitudeValid)
                {
                    str += position.Latitude;
                }
                //經度
                if (position.LongitudeValid)
                {
                    str += " " + position.Longitude;

 

 

5.傳送簡訊代碼
                    SmsMessage msg = new SmsMessage(PHONE, str);
                    msg.Send();
6.打包為開機啟動程式
打包cab檔案時,只需把捷徑添加到Startup檔案夾下面就ok。

 

不足之處。
1.gps代碼根據sdk中修改的,只是衛星定位的,根據基站定位的代碼不知如何?,只有當使用手機的人走到衛星訊號好的地方時才能把座標發

出去
2.發送的gps座標 ,只是一個大體的位置,幾百米以內的範圍,有些浮動
3.如果手機被恢復出廠預設值,或者被刷機,程式肯定不能運行了

即使gps訊號不好的情況下只是得到使用手機人的電話號碼,跟通話記錄,用處也是挺大的。代碼只是寫著玩的,提供下參考思路代碼

如果你發現有什麼不合理的,需要改進的地方,或者你有什麼更好的實現方法郵件聯絡328452421@qq.com(qq常年不線上,郵件聯絡) 朱曉 (泰山學院)。相互交流 謝謝

 

源碼  http://download.csdn.net/source/3239409

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.