A modification and replay method for Bluetooth vehicle control instructions

By parsing and replacing BLE data packets, the modification and replay of Bluetooth car control instructions is realized, which solves the problem of being unable to effectively test the security of the low-power Bluetooth car control protocol in the existing technology, and improves the accuracy of the Bluetooth car control function. reliability.

CN116193411BActive Publication Date: 2024-08-23GUANGDONG WEICHEN INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310080587.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-02-02
Publication Date
2024-08-23
Estimated Expiration
2043-02-02

AI Technical Summary

Technical Problem

The existing Bluetooth car control technology lacks an effective method for modifying and replaying car control instructions, and cannot efficiently conduct safety testing for the low-power Bluetooth car control protocol.

Method used

By parsing BLE packets into hexadecimal character data, disassembling and replacing relevant fields, reverse engineering the original binary data, and replaying the modified packets based on the target MAC address and security level. Specific steps include using trshark and xxd tools to parse and convert the data, grep and sed tools to locate and replace data frame fields, and finally using xxd-r to reverse the data into binary format for replay.

Benefits of technology

It realizes the direct modification and replay of the Bluetooth car control command data packet, and improves the depth and functional reliability of the Bluetooth car control command test.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116193411B
    Figure CN116193411B
Patent Text Reader

Abstract

The present invention relates to the technical field of automobile Bluetooth control, and relates to a modification and replay method of a Bluetooth vehicle control instruction, which comprises the following steps: S1: parsing a BLE data packet into hexadecimal character data; S2: disassembling the parsed data according to the BLE protocol stack; S3: replacing the relevant fields in the selected BLE data frame with the modified fields; S4: reversing the replaced data into original binary data; S5: replaying the modified data according to the target MAC address, MAC address type and seclevel. The present invention can realize direct modification and replay of a Bluetooth vehicle control instruction data packet; improve the depth of the Bluetooth vehicle control instruction test, and ensure the reliability of the Bluetooth vehicle control function.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the technical field of automobile Bluetooth control, in particular to a method for modifying and replaying a Bluetooth vehicle control instruction. Background Art

[0002] With the growing development of wireless control technology for intelligent connected cars, Bluetooth technology is increasingly used in in-vehicle electronic devices. Among them, low-power Bluetooth is suitable for IoT applications that transmit small amounts of data at lower speeds, and the operating frequency band is 2.4GHz. The release of Bluetooth 5 and Bluetooth mesh has further expanded the application of low-power Bluetooth. The cost of low-power Bluetooth chipsets and modules has been rapidly decreasing, making it an ideal connection solution for developing cost-effective in-vehicle infotainment systems.

[0003] In the automotive industry, the low-power Bluetooth protocol is almost universally used in the field of mobile phone wireless car control. As low-power Bluetooth car control technology is increasingly used in cars, it becomes more and more complex, and the reliability of the protocol and communication lacks multi-dimensional testing. Currently, there is no effective and practical method for modifying and replaying car control commands.

[0004] Although there are some open source tools that can analyze Bluetooth data packets, it is still impossible to modify and replay Bluetooth transmission data directly through analysis tools, and it is impossible to efficiently perform security tests on Bluetooth control commands. Therefore, it is necessary to develop a method for modifying and replaying Bluetooth control commands to verify the security of low-power Bluetooth control protocols. Summary of the invention

[0005] The present invention provides a method for modifying and replaying a Bluetooth vehicle control instruction, which can realize direct modification and replay of a Bluetooth vehicle control instruction data packet.

[0006] A method for modifying and replaying a Bluetooth vehicle control instruction according to the present invention comprises the following steps:

[0007] S1: parse the BLE data packet into hexadecimal character data;

[0008] S2: Disassemble the parsed data according to the BLE protocol stack;

[0009] S3: Replace the relevant fields in the selected BLE data frame with the modified fields;

[0010] S4: Reverse the replaced data to the original binary data;

[0011] S5: Replay the modified data according to the target MAC address, MAC address type, and seclevel.

[0012] Preferably, in S1, the BLE data packet is in BTsnoop format, and the BTsnoop format is used to record data of the interaction between the Bluetooth protocol stack and the chip.

[0013] Preferably, the BTsnoop format includes a File Header and a Packet Record. The File Header is a fixed-length field that contains general information about the format of the packet file and the packet records it contains, including an identification mode, a version number, and a data link type. The Packet Record is a continuous data packet field that includes the original length, the data field length, the data packet flag, the packet loss record, a timestamp, and a data packet variable-length field.

[0014] Preferably, in S1, the data payload contained in the variable length field of the data packet is parsed into a visible string using the trshark tool as input for modification, and the BLE original hexadecimal data packet is converted into a hexadecimal string data packet using the xxd tool to prepare for subsequent replacement positioning.

[0015] Preferably, in S2, the specific method is: calculate the data frame length Frame Len field position, the host control layer interface length HCI Total Length field position, and the logical link control and adaptation protocol layer data payload length L2CAPPDU Length field position; and according to the length of the modified data payload, calculate the specific values ​​of Frame Len, HCI Total Length and L2CAP PDU Length, and record them.

[0016] Preferably, in S3, the source BLE data packet is replaced according to the disassembled and calculated fields; the specific method of replacement is: locate the data frame to be modified through the grep tool, replace the converted hexadecimal string data packet with the calculated values ​​of Frame Len, HCITotal Length and L2CAPPDU Length of the modified data using the sed tool, and synchronously replace the input modified data payload.

[0017] Preferably, in S4, xxd-r is used to reverse the hexadecimal data to original binary data in preparation for subsequent replay.

[0018] Preferably, in S5, the replay method is: parsing the write feature value of the acquired BTsnoop format data packet, and then reading the modified Value value to write data to the target write feature to complete the replay.

[0019] The present invention can realize direct modification and replay of a Bluetooth vehicle control instruction data packet, improve the depth of the Bluetooth vehicle control instruction test, and ensure the reliability of the Bluetooth vehicle control function. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] Figure 1 It is a flow chart of a method for modifying and replaying a Bluetooth vehicle control command in an embodiment;

[0021] Figure 2 is a diagram showing an example of a modified BTsnoop file format in an embodiment;

[0022] Figure 3 is an example diagram of replacement specifications in the embodiment;

[0023] Figure 4 This is an example diagram of the BLE data frame data channel PDU format in the embodiment. DETAILED DESCRIPTION

[0024] In order to further understand the content of the present invention, the present invention is described in detail in conjunction with the accompanying drawings and embodiments. It should be understood that the embodiments are only for explaining the present invention and are not intended to limit it.

[0025] Example

[0026] like Figure 1 As shown, this embodiment provides a method for modifying and replaying a Bluetooth vehicle control command, which includes the following steps:

[0027] S1: Parse BLE data packet: parse BLE data packet into hexadecimal character data;

[0028] The BLE data packet parsed in this embodiment is in BTsnoop format, which is used to record the data of the interaction between the Bluetooth protocol stack and the chip, such as Figure 2As shown, it includes File Header and Packet Record. File Header is a fixed-length field that contains general information about the format of the packet file and the packet records it contains, such as Identification Pattern, Version Number, and Datalink Type. Packet Record is a continuous data packet field, including Original Length, Include Length, Packet Flags, Cumulative Drops, Timestamp Microseconds, and Packet Data. Since other fields are relatively fixed except for Packet Data, Original Length, and Include Length, the data payload contained in Packet Data is parsed as a visible string using the trshark tool as input for modification, and the BLE original hexadecimal data packet is converted into a hexadecimal string data packet using the xxd tool to prepare for subsequent replacement and positioning.

[0029] S2: Disassemble the BLE data frame field: disassemble the parsed data according to the BLE protocol stack;

[0030] The specific method of disassembling the BLE data frame field is as follows: Since the relative position of the fields is fixed, the data frame length (Frame Len) field position, the host control layer interface length (HCI Total Length) field position, and the logical link control and adaptation protocol layer data payload length (L2CAP PDU Length) field position can be inferred. And according to the length of the modified data payload, the specific values ​​of Frame Len, HCI Total Length and L2CAP PDU Length are calculated and recorded. The remaining fields, such as the timestamp, will not affect the final data packet encapsulation, so this method does not involve modification.

[0031] S3: Replace BLE data frame fields: replace the relevant fields in the selected BLE data frame with the modified fields;

[0032] Replace the source BLE data packet according to the disassembled and calculated fields. The specific method of replacement is: use the grep tool to locate the data frame that needs to be modified, such as Figure 3As shown in the figure, the values ​​of Frame Len, HCI TotalLength and L2CAP PDU Length of the modified data are calculated and replaced with the hexadecimal string data packet converted in S101 using the sed tool, and the input modified data payload is replaced synchronously. BLE is different from the classic Bluetooth with a wide variety of data packets. The data packet format of each physical layer of BLE is the same, which contains the preamble (Preamble), access address (AccessAddress), protocol data unit (PDU, such as Figure 4 As shown), cyclic redundancy check code (CRC). The preamble is used by the receiver to perform frequency synchronization, symbol timing estimation and automatic gain control (AGC) training; the access address is used to distinguish the 32-bit identification code of different connections or different periodic broadcasts; the protocol unit data is used to load the data to be transmitted, including two formats: broadcast PDU and data communication PDU; the cyclic redundancy check code is a 24-bit CRC, which is calculated based on the PDU and is used to verify the correctness of the data packet PDU. The BTsnoop format data packet obtained by this method is an HCI layer data packet, which only contains the PDU layer in the above format, and the modified data packet is a data communication PDU. The preamble is automatically generated by the link layer (PHY); the access address is generated according to the input parameter before sending; the protocol data unit is the field replaced by this method; the data payload and length value are replaced; the cyclic redundancy check code is also calculated and generated at the link layer based on the PDU.

[0033] S4: Reverse the replaced data: reverse the replaced data to the original binary data;

[0034] The xxd command in Linux can generate a hexadecimal output for a given standard input or file, and can also convert the hexadecimal output to the original binary format. In S1, this method uses the xxd tool to convert the BTsnoop data packet into a hexadecimal string. The disassembly and replacement operations in S2 and S3 are based on the BTsnoop data packet converted by the xxd command in S1. After the modification operation is completed, xxd-r is used to reverse the hexadecimal data to the original binary data in preparation for subsequent replay.

[0035] S5: Replay the modified BLE data packet: replay the modified data according to the target MAC address, MAC address type and seclevel.

[0036] The BLE data packet object replayed by this method is only for Bluetooth devices that do not perform BLE data write encryption and BLE connection authentication mechanism. In BLE, characteristic values ​​are composed of one or more attributes, services are composed of one or more characteristic values, and services are grouped by service declarations, and characteristic values ​​are grouped by characteristic value declarations. The replay method of this method is: parse the write characteristic value through the obtained BTsnoop format data packet, and then read the modified Value value to write data to the target write characteristic to complete the replay. In the previous step, the Value value has been modified and replaced. This method directly replays the modified BTsnoop format file.

[0037] The present invention can realize direct modification and replay of a Bluetooth vehicle control instruction data packet, improve the depth of the Bluetooth vehicle control instruction test, and ensure the reliability of the Bluetooth vehicle control function.

[0038] The present invention and its embodiments are described schematically above, and the description is not restrictive. The drawings show only one embodiment of the present invention, and the actual structure is not limited thereto. Therefore, if a person skilled in the art is inspired by it and designs a structural method and an embodiment similar to the technical solution without creativity without departing from the purpose of the invention, they shall all fall within the protection scope of the present invention.

Claims

1. A method for modifying and replaying a Bluetooth vehicle control command, characterized in that: The following steps are involved: S1: parse the BLE data packet into hexadecimal character data; S2: disassemble the parsed data according to the BLE protocol stack; in S2, the specific method is: calculate the data frame length Frame Len field position, the host control layer interface length HCI Total Length field position, and the logical link control and adaptation protocol layer data payload length L2CAPPDU Length field position; and according to the length of the modified data payload, calculate the specific values ​​of Frame Len, HCI Total Length and L2CAP PDU Length, and record them; S3: Replace the relevant fields in the selected BLE data frame with the modified fields; in S3, replace the source BLE data packet according to the disassembled and calculated fields; the specific method of replacement is: locate the data frame to be modified by the grep tool, replace the converted hexadecimal string data packet with the values ​​of the Frame Len, HCI Total Length and L2CAP PDU Length of the calculated modified data by the sed tool, and synchronously replace the input modified data payload; S4: Reverse the replaced data to the original binary data; S5: Replay the modified data according to the target MAC address, MAC address type, and seclevel.

2. The method for modifying and replaying a Bluetooth vehicle control command according to claim 1, characterized in that: In S1, the BLE data packet is in BTsnoop format, which is used to record the data of the interaction between the Bluetooth protocol stack and the chip.

3. A method for modifying and replaying a Bluetooth vehicle control command according to claim 2, characterized in that: The BTsnoop format includes File Header and Packet Record. File Header is a fixed-length field that contains general information about the format of the packet file and the packet records it contains, including identification mode, version number, and data link type; Packet Record is a continuous data packet field that includes original length, data field length, data packet flag, packet loss record, timestamp, and data packet variable length field.

4. A method for modifying and replaying a Bluetooth vehicle control command according to claim 3, characterized in that: In S1, the data payload contained in the variable-length field of the data packet is parsed into a visible string using the trshark tool as the input for modification, and the BLE original hexadecimal data packet is converted into a hexadecimal string data packet using the xxd tool to prepare for subsequent replacement positioning.

5. A method for modifying and replaying a Bluetooth vehicle control command according to claim 4, characterized in that: In S4, xxd-r is used to reverse the hexadecimal data to the original binary data in preparation for subsequent replay.