Skip to content

Latest commit

 

History

History
224 lines (161 loc) · 9.73 KB

2_software-gcs.md

File metadata and controls

224 lines (161 loc) · 9.73 KB

GCS(Ground Control System)

Table of Contents

1. Introduction

1.1. GCS Concepts

GCS, short for Ground Control Station, is software designed for various operations such as drone control and mission. (QGroundControl is recommended in PX4)

1.2. GCS Functions

  • Autonomous flight and real-time flight path control.
  • Map data processing, flight route analysis,
  • Geofence (If necessary, create a no-fly zone)

1.3. Status of GCS by drone.

ardupilot px4 dji
mission planner qground control ground station

1.4. ELF vs AppImage

Prior to analyzing vulnerabilities in QGC, we identified the Release file QGroundControl.AppImage using checksec.sh to check memory protection techniques.
Untitled

All protection techniques except NX can be seen to be turned off, due to the nature of AppImage extensions. Untitled (1)

As shown in the following figure, AppImage is stored together in the form of squashfs with the execution binaries and libraries to meet dependencies. So we're going to... sudo mount ./qgroundcontrol.AppImage mountpoint -o offset=188392 I checked the binaries that were actually built through the command, and again the memory protection techniques. Untitled (2) Untitled (3)

2. Analyze Environment

2.1. Build QGC

2.1.1. Installing QT

Since QGC uses the QT library as a Cross-Platform library, it downloads QT and compiles it through QT Creator.

  1. Download and run the Qt installer

  2. QT version (5.15.2) and component settings image

  3. Install additional packages

    sudo apt-get install speech-dispatcher libudev-dev libsdl2-dev patchelf
    
  4. Clone the repository, including the submodule

    git clone --recursive -j8 https://github.com/mavlink/qgroundcontrol.git
    
  5. Submodule Update

    git submodule update --recursive
    

2.1.2. Build using GUI

  1. qgroundcontrol project open

  2. Click on the hammer to proceed with the build

    image

2.1.3. Build using CLI

  1. Create makefile
    cd qgroundcontrol
    mkdir build
    cd build
    ~/Qt/5.15.2/gcc_64/bin/qmake ../
    
  2. Build
    make
    

2.2. Sanitizer

2.2.1. Using the Sanitizer with the GUI

  1. Projects > Build > Build Steps > qmake > Additional arguments

  2. Modify Argument as below

    image

2.2.2. Using Sanitizer with CLI

  1. Create makefile

    cd qgroundcontrol
    mkdir build
    cd build
    ~/Qt/5.15.2/gcc_64/bin/qmake ../
    
  2. Add sanitizer on makefile's CC, CXX, LINK

    image

3. Vulnerability Analysis Methodology

3.1. Vulnerability Analysis through Source Code Auditing

3.1.1. MAVLINK Handle Function Auditing

From the QGC source directory src/Vehicle/Vehicle.ccIf you look at the 593line of , it handles the mavlink packet in a function called Vehicle:::_mavlinkMessageRecovered(). Therefore, we audited according to the flow of the function.

3.1.2. QGC GUI Functional Auditing

In the QGC program, the functions implemented with GUI were analyzed to find vulnerabilities.

3.2. Vulnerability Analysis through Fuzzing

3.2.1. Mavlink Fuzzer

Since QGC also uses the same mavlink protocol as PX4, it was able to find vulnerabilities in the three functions using the fuzzer that was previously made.

3.2.2. QGC With AFL++

We used AFL++ for code coverage-based fuzzing. First, since AFL++ basically performs fuzzing using file I/O, we changed afl-forkserver.c to use UDP as follows.

int client_socket;
    struct sockaddr_in serverAddress;



    memset(&serverAddress, 0, sizeof(serverAddress));
    

    serverAddress.sin_family = AF_INET;
    inet_aton("127.0.0.1", (struct in_addr*) &serverAddress.sin_addr.s_addr);
    serverAddress.sin_port = htons(14540);
    serverAddresss.sin_family = AF_INET;


    // socket create
    if ((client_socket = socket(PF_INET, SOCK_DGRAM, 0)) == -1)
    {
        printf("socket create fail\n");
        exit(0);
    }


    sendto(client_socket, buf, len, 0, (struct sockaddr*)&serverAddress, sizeof(serverAddress));

    // socket close
    close(client_socket);

Afterwards, he modified Makefile and changed compiler to apl-g++ to conduct fuzzing. However, three problems arise if we proceed this way.

  1. AFL sends packets first before QGC is turned on.
  2. If you do not receive Heartbeat, you do not receive other packets.
  3. AFL can be measured only when the program is terminated.

We used the following methods to solve problems.

Untitled Diagram drawio (1) (1)
For the first troubleshooting, the following UDP Server broadcasts were required to load the socket of QGC before sending heartbeat packets and generated packets.

if (heatbeatFlag){exit(0);}
heatbeatFlag = 1

Next, to solve the second and third problems, _uas->receiveMessage(message) at src/Vehicle/Vehicle.cc; the code was added below to terminate the QGC when receiving the heartbeat and the generated packet.

Untitled (5)
As a result of fuzzing in the above two ways, 120 uniq hands were found as follows, but no crash came out. Because the method mutates the full packet, it cannot pass through the crc verification routine of mavlink.

GCS_fuzzing drawio
Therefore, we modified the code of the UDP relay server and proceeded with fuzzing again with the following structure.
The structure mutates only the 'payload' part of Mavlink in AFL++ and transmits a full packet containing CRC values from the UDP server.

Untitled (6)
As a result, many crashes could be obtained as follows. All of these crashes were vulnerabilities found in the 4dfuzzer above, but it seems that they can be useful as future work by applying them.

Table of Contents

Introduction

  1. Research background and goal
  2. Previous studies

Methodology

  1. UAV software
    1. Flight controller software
    2. MAVROS
  2. Ground Control System software
    1. Introduction
    2. Analyze Environment
    3. Vulneralility Analysis Methodology
  3. Hardware
    1. GPS Module
    2. PX4 Optical Flow
    3. PX4 Telemetry Radio
    4. Wifi Module

Result

  1. Project results