The MTK platform obtains IMSI numbers and how to intercept various messages in the system.

Source: Internet
Author: User

 

The MTK platform obtains the imsi number in the SIM card of the local machine.

 

The company developed the MTK platform. The boss requested the mobile phone number of the SIM card on the local machine to be obtained from the MTK code. After checking a lot of information, the result would not be available, the reason is that the mobile phone number is not directly stored in the SIM card, but is bound when the signal passes through the mobile operator (mobile, Unicom, or Telecom). imsi is an attribute Number of the SIM card, in the mobile system, it is bound to the SIM card number. After an account is opened, it is bound to the mobile phone number. The process of opening an account is to send your imsi and mobile phone number to the switch HLR, in this way, the switch will find you.

Second, the "ID" of the sim can also uniquely identify a user, but the Sim can be re-handled. Considering that the unified phone number does not correspond to the SIM card information after the re-done, it is not very good, however, you cannot get a mobile phone number. You can only do this first.

In terms of implementation, it is much easier to obtain the imsi number in the SIM card. below is my detailed implementation method (there are two methods ):

Method 1:

Void btl_send_msg_get_imsi (void) // send messages to the l4c layer from the MMI Layer
{
Myqueue message;
SetProtocolEventHandler (btl_sim_imsi_rsp, PRT_GET_IMSI_RSP); // bind a function to the PRT_GET_IMSI_RSP message
Message. oslSrcId = MOD_MMI; // sends the Message source module.
Message. oslDestId = MOD_L4C; // target module of the Message
Message. oslMsgId = PRT_GET_IMSI_REQ; // Message ID
Message. oslDataPtr = NULL; // Message carrying data
Message. oslPeerBuffPtr = NULL;
OslMsgSendExtQueue (& Message); // send a Message to an external queue
Kal_prompt_trace (MOD_MMI, "btl_send_msg_get_imsi ");
}

Void btl_sim_imsi_rsp (void * info) // The function automatically called when the PRT_GET_IMSI_RSP message occurs.
{
Char imsi_imei_num [17]; // defines the character array for storing the IMSI number: The IMSI number must not exceed 15 characters, but the simulator will get a 16-digit number plus one-digit Terminator.
Mmi_smu_get_imsi_rsp_struct * local_data = (mmi_smu_get_imsi_rsp_struct *) info; // the information obtained.
Kal_prompt_trace (MOD_MMI, "btl_sim_imsi_rsp1"); //
Strcpy (imsi_imei_num, (char *) local_data-> imsi); // store the SIM in the array
_ Cprintf ("-----------------------------------/n ");
_ Cprintf ("the imsi number is: % s/n", imsi_imei_num); // print the obtained IMSI number on the console.
Kal_prompt_trace (MOD_MMI, "btl_sim_imsi_rsp2 ");
}

After the function is declared, the btl_send_get_imsi () function can be called anywhere in any file. When the system has a message PRT_GET_IMSI_RSP, The btl_sim_imsi_rsp () function will be called (), the parameter of this function is the data transmitted when the message PRT_GET_IMSI_RSP occurs. The system automatically transmits the parameter to this function. In this way, you can get the IMSI Number of the SIM card of the local machine.

The second method is to define the event capture function to capture the time when the system occurs. When an event (such as a call event, rejection event, or SMS event) occurs) it will be captured when it occurs, and we can do some processing on our own.

1) define the event capture function: FlySky_EventHook (unsigned short ID, void * pMsg)

Void FlySky_EventHook (unsigned short ID, void * pMsg)

{

Char imsiNum [17];

Char phoneNUm [20];

 

Memset (& imsiNum, 0, sizeof (imsiNum); // The initialization array is '/0' to ensure the correctness of the subsequent values.

Memset (& phonenum, 0, 0, sizeof (phonenum); // same as above

 

Switch (ID)

{

Case prt_incomingcall_event: // call event occurred

{

IncomingCall flysky_msg;

 

/* Get the incoming call number */

Memset (& flysky_msg, 0, sizeof (flysky_msg); // initialize the struct flysky_msg to avoid incorrect values after obtaining information

Derivecallinfo (PMSG, & flysky_msg); // converts L4 call events to incomingcall structural events.

Strcpy (phonenum, (const char *) flysky_msg.number); // obtain the phone number of the incoming call.

 

/* Test to get the imsi */

Btl_send_msg_get_imsi (); // call events are used for testing. A message is sent to the l4c layer when a call is sent.


}

Case prt_incomingcall_rejected: // reject a call

{

Break;

}

Case PRT_GET_IMSI_RSP: // get IMSI Request Reply

{

Btl_sim_imsi_rsp (PMSG); // transmits the data information of the message to btl_sim_imsi_rsp.

Break;

}

Default:

Break;

}

}

 

Void btl_send_msg_get_imsi (void)
{
MYQUEUE Message;
// SetProtocolEventHandler (btl_sim_imsi_rsp, PRT_GET_IMSI_RSP );
Message. oslSrcId = MOD_MMI;
Message. oslDestId = MOD_L4C;
Message. oslMsgId = PRT_GET_IMSI_REQ;
Message. osldataptr = NULL;
Message. oslpeerbuffptr = NULL;
Oslmsgsendextqueue (& message );
Kal_prompt_trace (mod_mmi, "btl_send_msg_get_imsi ");
}

Void btl_sim_imsi_rsp (void * info)
{
Char imsi_imei_num [17];
Mmi_smu_get_imsi_rsp_struct * local_data = (mmi_smu_get_imsi_rsp_struct *) Info;
Kal_prompt_trace (MOD_MMI, "btl_sim_imsi_rsp1 ");
Strcpy (imsi_imei_num, (char *) local_data-> imsi );
// _ Cprintf ("-------------------------------------/n ");
// _ Cprintf ("the imsi number is: % s/n", imsi_imei_num );
Kal_prompt_trace (MOD_MMI, "btl_sim_imsi_rsp2 ");
}

 

First, you must put the FlySky_EventHook () function in MMITask. declare the MMI_task function in the c file: extern void FlySky_EventHook (unsigned short ID, void * pMsg); then add the following between the "default: ProtocolEventHandler ()" and "break" of the MMI_task function: flySky_EventHook (Message. oslMsgId,
(Void *) Message. oslDataPtr );

In this way, all the system events can be captured. to capture the time, you can directly generate the message corresponding to the event in the case in FlySky_EventHook, and process the events in the message accordingly.

 

Note: It is easier to obtain the IMSI number on the MTK platform, but it is a 16-digit string in the simulator. The IMSI (International Mobile User ID) can be found in the online materials) it consists of up to 15 digits, that is, 15 digits. The reason is that the SIM card is not real on the simulator. Therefore, we need to perform a real test, you also need to download it to the real machine for a test.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.