A method and system for parsing controller local area network protocols based on static and dynamic analysis of in-vehicle infotainment systems
By reverse programming and multi-priority triggering rules of vehicle control applications, combined with heartbeat message filtering and timestamp matching, efficient and widely applicable automated reverse parsing of the CAN bus protocol is achieved, solving the problems of low efficiency and poor versatility in existing technologies.
Patent Information
- Application Number
- CN202611510280.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-28
- Publication Date
- 2026-11-17
AI Technical Summary
Existing CAN bus protocol reverse engineering solutions are inefficient and lack versatility. They rely on dedicated hardware or vehicle-specific hard-coded vulnerabilities, making it difficult to achieve high coverage and high accuracy in automated reverse engineering.
By performing reverse program slicing analysis on the vehicle control application, a control flow graph is constructed, user interface components and their resource identifiers are extracted, and automated dynamic triggering is performed using multi-priority triggering rules. Combined with heartbeat message filtering and timestamp matching algorithms, high-accuracy extraction of CAN messages is achieved.
Without requiring a real vehicle environment or specialized equipment, it achieves efficient and widely applicable automated reverse parsing of CAN messages, improving component trigger coverage and parsing accuracy, and reducing deployment costs.
Smart Images

Figure CN123123489A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of vehicle network information security technology, and in particular to a method and system for parsing Controller Area Network (CAN) protocol based on static and dynamic analysis of in-vehicle infotainment systems. Background Technology
[0002] The in-vehicle infotainment system (Head Unit) has become the core interface for drivers to interact with intelligent connected vehicles. Early head units only had basic multimedia functions such as radio and CD playback. As the level of vehicle intelligence continues to improve, the head unit has gradually evolved into a mobile platform that can install various applications. Users can use the installed vehicle control applications to monitor and adjust the status of vehicle components in multiple domains such as the body, chassis, and powertrain, such as air conditioning settings, switching on and off driver assistance functions, and switching driving modes.
[0003] Modern vehicles commonly employ CAN-based in-vehicle network protocols to facilitate communication between the vehicle's infotainment system (V2S) and other electronic control units (ECUs). Upon responding to user input, the V2S converts the corresponding vehicle control function into a CAN message, which is then transmitted via the CAN bus to the ECU within the target domain to complete the actual control. A CAN message primarily consists of an identifier (ID) and a data segment (Data). The identifier identifies the message type, while the data segment carries the specific control parameters. However, although the frame format of CAN messages has been standardized, the definitions of CAN identifiers and data segment fields used by different vehicle manufacturers are often proprietary and not publicly disclosed. This poses challenges for vehicle network security assessments, fault diagnosis, and vulnerability discovery. Therefore, it is necessary to propose a technical solution capable of automatically reverse-engineering the semantic information of CAN messages sent by the V2S.
[0004] Existing CAN protocol reverse engineering solutions have the following shortcomings: First, the method of manually clicking on vehicle control components on the in-vehicle interface one by one and simultaneously observing the corresponding CAN traffic changes is inefficient, labor-intensive, and prone to missing relevant messages when CAN bus traffic is complex. Second, some solutions rely on the correlation between the numerical change trend of CAN message data segments and the vehicle state change trend (such as vehicle speed, acceleration, etc.) for semantic inference. Such solutions usually require expert experience or physical laws for auxiliary judgment, and the accuracy of semantic recognition is limited. Furthermore, when vehicle manufacturers perform numerical transformation processing on the CAN message data, this type of trend-matching method becomes less effective. The effectiveness of the solution will further decline; third, some solutions use specialized equipment such as robotic arms to automate the interaction with real vehicles or professional diagnostic equipment to eliminate manual operation, but such solutions rely on expensive specialized hardware and real vehicle environments, resulting in high deployment costs and poor availability; fourth, some solutions perform static code analysis on the dedicated diagnostic application that comes with the vehicle system to extract vulnerabilities or configuration information related to hard-coded CAN messages, but such solutions are highly dependent on the hard-coded content pre-written in the application of specific vehicle models, making them difficult to apply to modern vehicle system application scenarios where CAN configuration information is dynamically distributed by a remote server, and also difficult to apply to vehicle models that do not have publicly available diagnostic applications, resulting in poor versatility and adaptability.
[0005] Furthermore, considering the development of large language model intelligent agents and general graphical user interface (GUI) automated testing tools, they can also be used for automated interaction testing of in-vehicle applications to trigger vehicle control functions, thereby assisting in subsequent traffic analysis. However, due to the prevalent absence of textual descriptions for function icons in in-vehicle application interfaces, such general tools often struggle to accurately understand the actual functional semantics of interface components. Moreover, they are prone to employing unreasonable operation sequences during interaction (e.g., misjudging certain necessary operations as invalid and performing rollbacks), resulting in component trigger coverage and recognition accuracy failing to meet actual reverse engineering requirements.
[0006] In summary, there is an urgent need for a technical solution that can achieve automated, high-coverage, and high-accuracy reverse engineering of the CAN bus protocol corresponding to the in-vehicle infotainment system without relying on dedicated diagnostic equipment and a real vehicle environment, or on hard-coded vulnerabilities of specific vehicle models or human experience. Summary of the Invention
[0007] The purpose of this invention is to address the problems of low efficiency, poor versatility, and reliance on dedicated hardware or vehicle-specific hard-coding vulnerabilities in existing CAN bus protocol reverse analysis schemes by providing a controller area network protocol parsing method based on static and dynamic analysis of in-vehicle infotainment systems.
[0008] To achieve the above objectives, the technical solution adopted by this invention is a controller local area network protocol parsing method based on static and dynamic analysis of in-vehicle infotainment systems, comprising the following steps: S1. Perform reverse program slicing analysis on the vehicle control application in the vehicle system operating system, construct the control flow graph of the vehicle control application, take the Android listener binding application interface as the analysis entry point, reverse trace the function calling the listener binding application interface to obtain the top-level function of vehicle control, and extract the vehicle control user interface components and their resource identifiers based on the top-level function of vehicle control. S2. According to the pre-set multi-priority triggering rules, the extracted vehicle control user interface components are automatically and dynamically triggered, and the triggering log is recorded during the triggering process. The triggering log includes the resource identifier of the triggered vehicle control user interface component, the timestamp of the triggering time, and the number of triggers. S3. Collect the CAN messages sent by the vehicle unit through the CAN bus during the execution of step S2. Based on the frequency of the CAN messages corresponding to each CAN identifier, determine the CAN messages whose frequency exceeds the preset frequency threshold as heartbeat messages and filter them to obtain the filtered CAN messages. S4. The timestamps in the trigger log and the timestamps of the filtered CAN messages are associated and matched based on the same source time reference generated by the same machine record. The timestamp of each trigger event is used as the left boundary of the search, and the time interval between the current trigger event and the next trigger event is combined with a preset time threshold to determine the right boundary of the search. Within the time interval determined by the left boundary and the right boundary, the CAN message associated with the corresponding trigger event is extracted from the filtered CAN messages. Based on the semantic information of the vehicle control user interface components recorded in the trigger log, the semantics of the vehicle control function represented by the extracted CAN message is determined, thereby obtaining the mapping relationship between the vehicle control function and the CAN message.
[0009] According to a second aspect of the present invention, a reverse analysis system for the CAN bus protocol of an in-vehicle infotainment system is provided, the system comprising an in-vehicle application analysis module, a dynamic triggering module, and a CAN traffic conversion module; The in-vehicle application analysis module is used to perform reverse program slicing analysis on the vehicle control application in the vehicle operating system, construct the control flow graph of the vehicle control application, use the Android listener binding application interface as the analysis entry point, reverse trace the function calling the listener binding application interface to obtain the top-level function of vehicle control, and extract the vehicle control user interface components and their resource identifiers based on the top-level function of vehicle control. The dynamic triggering module is used to automatically and dynamically trigger the extracted vehicle control user interface components according to the pre-set multi-priority triggering rules, and record the triggering log during the triggering process. The CAN traffic conversion module is used to collect CAN messages sent by the vehicle unit through the CAN bus during dynamic triggering, filter heartbeat messages, and synchronize the timestamps in the trigger log with the timestamps of the filtered CAN messages according to the same source time base generated by the same machine record. Based on time boundary matching, the module extracts CAN messages associated with the corresponding triggering event from the filtered CAN messages to obtain the mapping relationship between vehicle control functions and CAN messages.
[0010] According to a third aspect of the present invention, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the steps of the above-described method.
[0011] According to a fourth aspect of the present invention, an electronic device is provided, including a processor and a memory for storing processor-executable instructions, the processor being configured to implement the steps of the above-described method.
[0012] The beneficial effects of this invention are as follows: On the one hand, by performing reverse program slicing analysis on the vehicle infotainment application, the vehicle control user interface components are automatically extracted, avoiding the tedious process of manually checking each interface component one by one. Furthermore, it does not rely on the visual recognition of interface icons, overcoming the limitation of general graphical interface automated testing tools in understanding vehicle-specific icons. On the other hand, by designing multi-priority triggering rules that take into account task logic, interface change magnitude, occurrence sequence, and hierarchical depth, the efficiency of automated triggering can be significantly improved while ensuring component trigger coverage. In addition, through heartbeat message filtering and a time boundary matching algorithm based on trigger log timestamps, high-accuracy extraction of target vehicle control messages from high-noise CAN traffic is achieved. The extracted messages can directly inherit semantic information from the trigger logs, eliminating the need for trend-matching semantic inference based on human experience or physical laws. The overall solution requires no dedicated interactive equipment such as robotic arms or a real vehicle environment, and does not rely on hard-coded vulnerabilities in specific vehicle applications. It has advantages such as low deployment cost, wide applicability to various vehicle models, high reverse analysis efficiency, and high result accuracy. Attached Figure Description
[0013] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.
[0014] Figure 1 This is an exemplary embodiment of the present invention, which provides a general flowchart of a controller local area network protocol parsing method based on static and dynamic analysis of an in-vehicle infotainment system; Figure 2 This is a schematic diagram of a vehicle control user interface component located by reverse program slicing, provided by an exemplary embodiment of the present invention; Figure 3 This is a flowchart of a resource identifier extraction algorithm for a vehicle control user interface component provided in an exemplary embodiment of the present invention; Figure 4 This is a schematic diagram of a multi-priority triggering rule provided by an exemplary embodiment of the present invention; Figure 5 This is a schematic diagram of an exemplary embodiment of the present invention for extracting CAN messages based on time boundary matching; Figure 6 This is a block diagram of a CAN bus protocol reverse analysis system for an in-vehicle infotainment system provided by an exemplary embodiment of the present invention. Detailed Implementation
[0015] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with one or more embodiments of the present invention; rather, they are merely examples of methods and systems consistent with some aspects of one or more embodiments of the present invention.
[0016] The application scenario of this embodiment is as follows: The vehicle infotainment system is custom-developed based on a mature mobile terminal operating system framework (e.g., based on the Android framework). The vehicle infotainment system is connected to the vehicle network via CAN bus pins. After responding to user operations on interface components, vehicle control applications installed in the vehicle infotainment system (such as air conditioning settings applications, vehicle settings applications, etc.) convert the corresponding vehicle control actions into corresponding CAN messages and send them via the CAN bus. This invention aims to automatically establish the mapping relationship between vehicle control functions and their corresponding CAN messages, relying solely on the analysis of the vehicle infotainment system itself, without requiring a real vehicle or dedicated diagnostic equipment.
[0017] Analysis of the initialization module: To enable subsequent program analysis and automated triggering tasks, an analysis tool is first installed on the vehicle's operating system. This analysis tool is a standard application that does not require any system-level permissions and can be installed via various methods, such as copying to a USB drive, the vehicle's built-in app store, or application distribution channels provided by the vehicle manufacturer. The specific installation method is not limited. Since different vehicles of the same model typically use the same CAN message format, analysis only needs to be completed on one vehicle system, and the resulting vehicle control function and CAN message mapping relationship can be reused. The CAN message acquisition device is a commercial CAN analyzer, externally connected to the vehicle's CAN pins via a lead wire. To receive messages sent by the vehicle system via the CAN bus, the CAN bus communication parameters used by the vehicle system also need to be determined. Specifically, the pre-set CAN bus communication parameter combinations (including whether the CAN FD protocol is used, the arbitration domain baud rate, the data domain baud rate, etc.) are iterated through. For each parameter combination, CAN messages are attempted to be received. If a valid CAN message is received normally, the corresponding parameter combination is determined as the CAN bus communication parameters used by the vehicle system.
[0018] Reverse programming to extract vehicle control user interface components: To identify the target application carrying vehicle control functions in the vehicle's operating system, this embodiment obtains the package information (e.g., package name) and application metadata (e.g., application tags) of each application based on the application management service of the vehicle's operating system. It then detects whether the package information and application metadata contain pre-defined domain keywords (e.g., keywords related to vehicle settings and vehicle control). If they are found, the corresponding application is identified as a candidate vehicle control application, and the subsequent reverse program slicing analysis is performed on this candidate vehicle control application.
[0019] In vehicle control applications, a user clicking a user interface component triggers a corresponding vehicle control action. This is because the component is typically bound to a listener function (such as a click event listener or a state change event listener), and the click operation triggers the vehicle control logic implemented within that listener function. Since in-vehicle operating systems are usually custom-developed based on mature operating system frameworks, even listener functions implemented by third-party developers still need to call the official application programming interfaces (APIs) provided by the native operating system to implement specific functions. Therefore, the above characteristics are universal. However, the binding relationship between user interface components and their listener functions often involves complex function call chains spanning multiple classes, making direct location difficult.
[0020] To address this, the present invention proposes a reverse program slicing analysis method: First, construct the control flow graph of the vehicle control application; then, use the listener binding application interface provided by the operating system (e.g., the interface for binding click event listeners and state change event listeners) as the analysis entry point; next, recursively trace the functions that call the above-mentioned listener binding application interface along the control flow graph until it is impossible to trace upwards further, thereby locating the top-level function of vehicle control (e.g., the interface initialization function). Figure 2 A schematic diagram of the analysis process is shown.
[0021] After obtaining the top-level function for vehicle control, it is necessary to further associate it with specific vehicle control user interface components. This embodiment utilizes the following characteristic: when a class object corresponding to a certain interface component is created, its constructor is called. Therefore, it first checks whether there is a listener binding operation in the constructor of the class corresponding to the vehicle control user interface component. If it exists, the corresponding user interface component can be directly located from the constructor. If there is no listener binding operation in the constructor (i.e., the listener binding operation occurs outside the constructor, such as in the interface creation function), then it checks whether the view type field object in the class defining the top-level function for vehicle control has been assigned a value and whether the listener binding has been completed through the top-level function for vehicle control. If so, the corresponding field object is identified as the vehicle control user interface component. Through the above two complementary positioning methods, accurate positioning of the vehicle control user interface component can be achieved under different component binding implementation methods.
[0022] Extraction of relevant information from vehicle control user interface components: To support subsequent automated triggering, it is also necessary to extract the resource identifiers of each vehicle control user interface component. In the implementation of the vehicle's operating system, resource identifiers are typically used as call parameters for the view component application programming interface (i.e., the interface for finding the corresponding component in the interface based on the identifier) and are assigned to the corresponding view type field object. Based on this, this invention proposes a resource identifier extraction algorithm, the process of which is as follows: Figure 3 As shown.
[0023] Specifically, a queue of functions to be analyzed is constructed using the view binding function that assigns a value to the target field object as the initial function, and the initial function is added to this queue. Subsequently, the function at the head of the queue is taken as the current function to be analyzed, and the statements in the function are traversed in the reverse order of execution, while maintaining a set of intermediate variables in the assignment chain. For each statement traversed, if the statement is an assignment statement to the target field object or an intermediate variable already recorded in the set, the right operand of the statement is further determined: if the right operand is a call statement to find the application interface of the view component, the parameter of the call statement is directly determined as the resource identifier to be extracted and returned; if the right operand is a call statement to another function, the other function is added to the queue of functions to be analyzed so that the algorithm can be recursively executed for the function to find the resource identifier; if the right operand is not one of the above two types of call statements, it is added to the set as a new intermediate variable so that the source of the assignment of the intermediate variable can be continued to be tracked in the traversal of subsequent statements. If the statement encountered during the traversal is a call to another function (and not the right operand scenario of the assignment statement mentioned above), the called function is also added to the queue of functions to be analyzed for recursive searching. This traversal process is repeated until a resource identifier is successfully extracted from the queue of functions to be analyzed, or the queue is empty.
[0024] Furthermore, view change information caused by the triggering of the vehicle control user interface components is extracted for setting trigger priorities in subsequent dynamic triggering phases. This view change information includes three categories: minor changes, partial changes, and window switching. Minor changes correspond to situations where a preset specific interface is not called after triggering (e.g., only a button press highlight effect is generated); partial changes correspond to situations where a preset interface partial submission interface is called after triggering (e.g., interface switching between different functional modules); and window switching corresponds to situations where a preset window launch interface is called after triggering (i.e., a complete window jump occurs after triggering). Specifically, the aforementioned preset interfaces are used as the analysis entry point, and the same analysis method as the aforementioned reverse program slicing is employed to trace upwards and locate the vehicle control user interface components that call these interfaces, thereby identifying the view change category of each component.
[0025] Furthermore, by combining the resource identifiers, function call chains, and text content of the vehicle control user interface components, semantic analysis is performed using methods such as keyword matching to determine the vehicle control semantic information corresponding to the component (e.g., whether it is the main control switch of a certain functional module, what specific vehicle control function it corresponds to, etc.). The extracted resource identifiers, view change information, and semantic information will be uniformly recorded to support subsequent automatic triggering and CAN message semantic determination.
[0026] Dynamic triggering based on multi-priority rules: To improve automated triggering efficiency while ensuring trigger coverage, and to avoid missing some vehicle control user interface components due to unreasonable triggering order, this invention proposes a multi-priority triggering rule, such as... Figure 4 As shown, the following four rules are listed in descending order of priority. When a component satisfies multiple rules simultaneously, they are compared lexicographically from rule one to rule four to determine priority: Rule 1: Vehicle control user interface components with specific logical meanings should be triggered first. Since the availability of some vehicle control functions depends on whether a specific component (such as the master switch of a certain functional module) has been enabled, if such components with specific logical meanings are not triggered first, other components controlled by them may be unavailable and cannot be effectively triggered. Therefore, such components should be triggered first.
[0027] Rule 2: Vehicle control user interface components that cause minor view changes upon triggering should be triggered before those that cause major view changes. Significant view changes (such as window switching) caused by a component will disrupt the current interface context. Triggering such components too early may cause other untriggered components in the current interface to become invisible. Therefore, triggering such components should be delayed, prioritizing minor changes, localized changes, and then window switching.
[0028] Rule 3: Newly emerging vehicle control user interface components are triggered before existing ones. Since triggering certain components leads to the appearance of new vehicle control user interface components, failing to trigger these newly emerging components first may cause them to disappear again without being triggered. Therefore, newly emerging components should be triggered first.
[0029] Rule 4: Vehicle control user interface components located deeper in the user interface hierarchy are triggered before those located at shallower levels. Since the user interface hierarchy is typically tree-like, deeper nodes often correspond to finer-grained functional units (e.g., specific parameter configuration items for a function should be configured before the confirmation button is pressed), therefore components at deeper levels should be triggered first.
[0030] Based on the above rules, the specific process of dynamic triggering is as follows: Vehicle control user interface components that are currently visible but not yet triggered are assigned corresponding priorities according to the above multi-priority triggering rules and added to a priority queue. Each time, the vehicle control user interface component with the highest priority is retrieved from the priority queue, and a manual click operation is simulated to trigger it using the native service provided by the operating system. The newly generated vehicle control user interface components caused by this operation are then reassigned priority and added to the priority queue. This process of retrieving, triggering, and updating the queue is repeated until the priority queue is empty, thereby completing the automated triggering of all vehicle control user interface components in the application.
[0031] During the triggering process, a corresponding trigger log is recorded. The trigger log includes the operation details of this trigger (such as the total number of clicks, the click time interval, the timestamp of the trigger time, the sub-component structure of the clicked component, etc.) and the detailed information of the triggered component (such as resource identifier, component text content and content description information). The above information together reflect the semantics of the CAN message extracted later.
[0032] CAN Flow Conversion: During dynamic triggering, CAN messages sent by the vehicle's infotainment system via the CAN bus are synchronously acquired. Since the CAN bus contains a large number of high-frequency heartbeat messages, unfiltered messages would interfere with subsequent analysis. Therefore, the acquired CAN messages are first preprocessed: the frequency of each CAN identifier's corresponding message is counted, and a minimum frequency threshold is calculated accordingly. CAN messages corresponding to CAN identifiers whose frequency exceeds the minimum frequency threshold are identified as heartbeat messages and removed from the acquired CAN messages, thus obtaining filtered CAN messages.
[0033] Because the automated triggering process follows a specific time pattern (i.e., the aforementioned trigger log), the generated CAN messages also exhibit corresponding time characteristics: the time difference between the moment a vehicle control user interface component is clicked and the moment the corresponding CAN message is acquired is usually extremely small (e.g., on the order of 1 millisecond); simultaneously, for a single trigger event, the vehicle's infotainment system typically sends multiple CAN messages with identical content to ensure control reliability. Based on these time characteristics, this invention proposes a CAN message extraction method based on time boundary matching, such as... Figure 5 As shown.
[0034] Specifically, firstly, the timestamps in the trigger log and the filtered CAN messages are synchronized using a common time base generated from the same machine record. Then, for each trigger event recorded in the trigger log, the timestamp of that trigger event is used as the left boundary of the search interval, since CAN messages are not sent before vehicle control is triggered. Next, the time interval between the current trigger event and the next trigger event in the trigger log is obtained, and this time interval, combined with a pre-set time threshold (e.g., half the click time interval), is used to determine the right boundary of the search interval. Using the time interval determined by the left and right boundaries, CAN messages falling within this time interval are retrieved from the filtered CAN messages and extracted as the CAN messages corresponding to the current trigger event. Since the trigger log records the functional semantics of the vehicle control user interface components executed this time, the semantics of the extracted CAN messages can be directly determined from this, without relying on indirect inference methods such as vehicle state trend matching. By repeating the above extraction process for all trigger events recorded in the trigger log, the reverse parsing of the CAN messages corresponding to all vehicle control functions in the vehicle control application can be completed, and the mapping relationship between vehicle control functions and CAN messages can be obtained. This mapping relationship can be used for subsequent vehicle network security assessment, fault diagnosis and other purposes.
[0035] System Implementation Example: Corresponding to the above methods, the present invention also provides a CAN bus protocol parsing system based on static and dynamic analysis of in-vehicle infotainment systems, such as... Figure 6 As shown, the system includes an analysis initialization module, an in-vehicle application analysis module, a dynamic triggering module, and a CAN flow conversion module.
[0036] The analysis initialization module is used to install analysis tools that do not require system-level permissions into the vehicle's operating system, and to traverse preset CAN bus communication parameter combinations to determine the CAN bus communication parameters used by the vehicle, thus preparing the environment for subsequent analysis.
[0037] The in-vehicle application analysis module is used to obtain the package information and application metadata of each application according to the application management service of the vehicle system to determine the candidate vehicle control application, and to perform reverse program slicing analysis on the candidate vehicle control application to construct its control flow graph. The Android listener binding application interface is used as the analysis entry point to reverse trace and locate the top-level function of vehicle control, and then extract the vehicle control user interface components and their resource identifiers, view change information and semantic information.
[0038] The dynamic triggering module is used to automatically and dynamically trigger the vehicle control user interface components extracted by the vehicle application analysis module according to the pre-set multi-priority triggering rules, and record the triggering log during the triggering process.
[0039] The CAN traffic conversion module is used to collect CAN messages sent by the vehicle unit through the CAN bus during the dynamic triggering process of the dynamic triggering module, count the occurrence frequency of messages corresponding to each CAN identifier to determine and filter heartbeat messages, and synchronize the timestamps in the trigger log with the timestamps of the filtered CAN messages based on the same source time base generated by the same machine record. Based on the time boundary matching algorithm, the CAN messages associated with the corresponding trigger events are extracted from the filtered CAN messages, and finally the mapping relationship between vehicle control functions and CAN messages is obtained.
[0040] Those skilled in the art will understand that all or part of the steps of the above embodiments can be implemented by hardware or by a program instructing related hardware. The program can be stored in a computer-readable storage medium, such as a magnetic disk, optical disk, read-only memory (ROM), or random access memory (RAM). Accordingly, the present invention also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of any of the methods described in the foregoing method embodiments. The present invention also provides an electronic device including a processor, a network interface, memory, non-volatile memory, and an internal bus, wherein the processor is configured to read a corresponding computer program from the non-volatile memory into memory for execution, to implement the steps of any of the methods described in the foregoing method embodiments.
[0041] The above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A controller local area network protocol parsing method based on static and dynamic analysis of in-vehicle infotainment systems, characterized in that, Includes the following steps: S1. Perform reverse program slicing analysis on the vehicle control application in the vehicle system operating system, construct the control flow graph of the vehicle control application, take the Android listener binding application interface as the analysis entry point, trace the function calling the listener binding application interface in reverse along the control flow graph to obtain the top-level function of vehicle control; extract the vehicle control user interface components and their resource identifiers, the view change information caused by being triggered, and the corresponding vehicle control semantic information based on the top-level function of vehicle control. S2. According to the pre-set multi-priority triggering rules, the vehicle control user interface component is automatically and dynamically triggered, and a triggering log is recorded; the triggering log includes the resource identifier of the triggered vehicle control user interface component, the timestamp of the triggering time, and the number of triggers; S3. Collect the CAN messages sent by the vehicle unit through the CAN bus during the execution of step S2, count the frequency of CAN messages corresponding to each CAN identifier, determine the CAN messages corresponding to CAN identifiers whose frequency exceeds the preset frequency threshold as heartbeat messages and filter them to obtain filtered CAN messages. S4. The timestamps in the trigger log and the timestamps of the filtered CAN messages are correlated and matched based on the same source time base generated by the same machine record. For each trigger event recorded in the trigger log, based on the timing characteristic that the CAN message is not earlier than the corresponding trigger event, the timestamp of the trigger event is used as the left boundary of the search, and the time interval between the trigger event and the next trigger event is combined with a preset time threshold to determine the right boundary of the search. Within the time interval determined by the left boundary and the right boundary, the CAN message associated with the corresponding trigger event is extracted from the filtered CAN messages, and the semantic information of the vehicle control user interface components recorded in the trigger log is used to determine the semantics of the vehicle control function represented by the extracted CAN message, thereby obtaining the mapping relationship between the vehicle control function and the CAN message.
2. The method according to claim 1, characterized in that, Step S1 is preceded by: The package information and application metadata of each application are obtained according to the application management service of the vehicle system. The package information and application metadata are checked to see if they contain preset domain keywords. If they do, the corresponding application is identified as a candidate vehicle control application. The reverse program slicing analysis in step S1 is performed on the candidate vehicle control application.
3. The method according to claim 1, characterized in that, The step S1, which involves extracting the vehicle control user interface components based on the top-level vehicle control function, includes: Detect whether there is a listener binding operation in the constructor of the class corresponding to the vehicle control user interface component; if so, locate the vehicle control user interface component from the constructor. If the listener binding operation is not present in the constructor, then in the class that defines the top-level function of vehicle control, it is detected whether the field object of the view type is assigned a value and the listener is bound through the top-level function of vehicle control. If so, the corresponding field object is identified as the vehicle control user interface component.
4. The method according to claim 3, characterized in that, Extracting the resource identifiers of the vehicle control user interface components includes: The view binding function that assigns the value to the target field object is used as the initial function to construct a queue of functions to be analyzed. Take out the functions to be analyzed from the queue of functions to be analyzed, traverse each statement in the queue in the reverse order of execution, and maintain a set of intermediate variables of the assignment chain; For each assignment statement encountered during iteration, if its left operand is a target field object or an intermediate variable already recorded in the collection, then its right operand is determined: if the right operand is a call statement for finding the application interface of the view component, then the parameter of the call statement is determined as a resource identifier and returned; if the right operand is a call statement for another function, then the other function is added to the queue of functions to be analyzed; if the right operand is not one of the above two types of call statements, then it is added to the collection as a new intermediate variable. If the statement encountered during the iteration is a call statement to another function, then the called function is added to the queue of functions to be analyzed. Repeat the above process until a resource identifier is extracted or the queue of functions to be analyzed is empty.
5. The method according to claim 3, characterized in that, Extract vehicle control semantic information corresponding to vehicle control user interface components, including: By combining the resource identifier, function call chain, and text content of the vehicle control user interface component, keyword matching is used to determine whether the vehicle control user interface component is the main control switch of a specific functional module and its corresponding vehicle control function, thereby obtaining the vehicle control semantic information. Extract view change information caused by the triggering of vehicle control user interface components, including: Using a preset specific interface as the analysis entry point, the same analysis method as the reverse program slicing analysis is used to reverse trace and locate the vehicle control user interface component that calls the preset specific interface, so as to identify the view change category to which each vehicle control user interface component belongs; wherein, the case where the preset specific interface is not called after triggering corresponds to a slight change, the case where the preset interface partial submission class interface is called after triggering corresponds to a partial change, and the case where the preset window launch class interface is called after triggering corresponds to a window switch.
6. The method according to claim 1 or 5, characterized in that, The multi-priority triggering rules mentioned in step S2, in descending order of priority, include: Rule 1: Based on the vehicle control semantic information, vehicle control user interface components with specific logical meanings will be triggered first; wherein, the vehicle control user interface components with specific logical meanings include the main control switch of a specific functional module. If the main control switch is not triggered first, other vehicle control user interface components controlled by it will be in an unavailable state. Rule 2: Based on the view change information, vehicle control user interface components that cause a smaller degree of view change after being triggered will be triggered first, in order of slight change, local change, and window switching. Rule 3: During the triggering process, newly emerging vehicle control user interface components take precedence over existing vehicle control user interface components. Rule 4: Vehicle control user interface components located in deeper layers of the user interface hierarchy are triggered before vehicle control user interface components located in shallower layers.
7. The method according to claim 1, characterized in that, Step S2 involves automatically and dynamically triggering the vehicle control user interface components, including: The vehicle control user interface components that are visible in the current interface but have not yet been triggered are assigned corresponding priorities according to the multi-priority triggering rules and added to the priority queue. Each time, the highest priority vehicle control user interface component is taken from the priority queue, and a manual click operation is simulated to trigger it through the native service provided by the vehicle operating system. The newly generated vehicle control user interface component caused by the operation is then re-assigned priority and added to the priority queue. Repeat the above process of retrieving, triggering, and updating the queue until the priority queue is empty, in order to complete the automated triggering of all vehicle control user interface components in the vehicle control application.
8. The method according to claim 1, characterized in that, In step S3, the frequency of CAN messages corresponding to each CAN identifier is counted, and CAN identifier messages with a frequency exceeding a preset frequency threshold are identified as heartbeat messages and filtered out, including: The occurrence frequency of each CAN identifier in the collected CAN messages is counted, and the minimum frequency threshold is calculated as the preset frequency threshold. CAN messages corresponding to CAN identifiers whose occurrence frequency exceeds the minimum frequency threshold are identified as heartbeat messages and removed from the collected CAN messages.
9. The method according to claim 1, characterized in that, Step S1 is preceded by: Install an analysis tool that does not require system-level privileges into the vehicle's operating system, and execute steps S1 to S4 using the analysis tool; By iterating through the preset CAN bus communication parameter combinations and detecting whether CAN messages can be received normally, the baud rate of the CAN bus arbitration domain and the baud rate of the data domain used by the vehicle unit are determined.
10. A reverse engineering system for the CAN bus protocol of an in-vehicle infotainment system, characterized in that, include: It includes an analysis initialization module, an in-vehicle application analysis module, a dynamic triggering module, and a CAN flow conversion module. These modules are coupled sequentially via data flow. The analysis initialization module is used to install analysis tools that do not require system-level permissions into the vehicle's operating system, and to traverse preset CAN bus communication parameter combinations to determine the CAN bus communication parameters used by the vehicle. The in-vehicle application analysis module is used to perform reverse program slicing analysis on the vehicle control application in the vehicle system operating system, construct the control flow graph of the vehicle control application, use the Android listener binding application interface as the analysis entry point, trace the function of the listener binding application interface in reverse along the control flow graph to obtain the top-level function of vehicle control, and extract the vehicle control user interface components and their resource identifiers, the view change information caused by being triggered and the corresponding vehicle control semantic information based on the top-level function of vehicle control, and output them to the dynamic triggering module. The dynamic triggering module is used to locate the vehicle control user interface component based on the resource identifier, automatically and dynamically trigger the vehicle control user interface component according to the multi-priority triggering rules preset according to the vehicle control semantic information and the view change information, and record a trigger log including the resource identifier of the triggered component, the timestamp of the triggering time and the number of triggers, and output it to the CAN flow conversion module. The CAN traffic conversion module is used to collect CAN messages sent by the vehicle unit via the CAN bus during the dynamic triggering process of the dynamic triggering module, count the frequency of CAN messages corresponding to each CAN identifier to determine and filter heartbeat messages, synchronize the timestamps in the trigger log with the timestamps of the filtered CAN messages based on the same source time base generated by the same machine record, and, based on the timing characteristic that CAN messages are not earlier than the corresponding trigger events, use the timestamp of each trigger event as the left boundary of the search, and use the time interval between the current trigger event and the next trigger event combined with a preset time threshold to determine the right boundary of the search. Within the time interval determined by the left boundary and the right boundary of the search, extract the CAN messages associated with the corresponding trigger events from the filtered CAN messages, and determine the semantics of the vehicle control functions represented by the extracted CAN messages according to the vehicle control semantic information recorded in the trigger log, thereby obtaining the mapping relationship between vehicle control functions and CAN messages.
