Thanks to visit codestin.com
Credit goes to github.com

Skip to content

CJW-MAPU/Canttack

Repository files navigation

Requirements

  • requirements.txt

Example

After git pull and install requirements

Update

2.* : Implement inject attack about can-fd data.

2.2.* : Dataset build methodology separation about carnival data and avante data.



Canntack Cookbook

view help

python canttack.py 

or

python canttack.py [-h | --help]

view command help

python canttack.py dataset [-h | --help]

python canttack.py inject [-h | --help]

check version

python canttack.py [-V | --version]

Create Normal Dataset (.txt to .csv)

python canttack.py dataset [-T | --target] TARGET \
    [-n | --name] NAME (--can | --can-fd) (--avante | --carnival)
  • TARGET(required) : Raw data file name (e.g., normal_data_filename)
  • NAME(required) : Export data file name (e.g., dataset_filename)

Create Normal Dataset Example

Suppose you own a file called avante_can_normal_data.txt and you want to convert it to avante_can_data.csv.

python canttack.py dataset -T avante_can_normal_data -n avante_can_data --can --avante

Suppose you own a file called carnival_fd_normal_data.txt and you want to convert it to carnival_fd_data.csv.

python canttack.py dataset -T carnival_fd_normal_data -n carnival_fd_data --can-fd --carnival

Inject Attack

python canttack.py inject [-T | --target] TARGET [-n | --name] NAME \
        [-c | --count] COUNT [-p | --packet] PACKET \
        (--can | --can-fd) (--dos | --fuzzing | --replay | --spoofing)
  • TARGET(required) : Dataset file name (e.g., dataset_filename)
  • NAME(required) : Attack injected dataset file name (e.g., attack_dataset_filename)
  • COUNT(optional) : Number of attacks to inject
    • default : 10 (If attack type is replay, default is 1.)
  • Packet(optional) : The attack packet you want to inject
    • default : DefaultPacket.json

Inject Attack Example

  • If you want inject a DoS attack defined by default into a CAN dataset called can_data.csv to output.csv.
python canttack.py inject -T can_data -n output --can --dos
  • If you want inject a DoS attack defined in CustomPacket.json directly into the CAN dataset called can_data.csv to output.csv
python canttack.py inject -T can_data -n output -p CustomPacket --can --dos 
  • If you want to inject 20 DoS attacks defined in CustomPacket.json directly into the CAN dataset called can_data.csv to output.csv
python canttack.py inject -T can_data -n output -c 20 -p CustomPacket --can --dos
  • etc.
python canttack.py inject -T fd_data -n output -c 14 -p CustomPacket --can-fd --replay

python canttack.py inject -T can_data -n output --can --fuzzing

python canttack.py inject -T can_data -n output -p CustomPacket --can --spoofing

JSON file format (DefaultPacket.json)

  • In the case of a fuzzing attack, (id, dlc, and payload) are randomly generated, so they are not defined.
{
  "can": {
    "dos": {
      "id": CAN_ID(string),
      "dlc": CAN_DLC(string),
      // Configuration with reference to DLC
      "payload": CAN_PAYLOAD(string, delimeter = whitespace)
    },
    "replay": {
      "path": CAN_PACKET_CHUNKS_FILE_PATH(string, format = *.csv)
    },
    "spoofing": {
      "id": "...",
      "dlc": "...",
      "payload": "..."
    }
  },
  "can-fd": {
     "dos": {
       "id": CAN_FD_ID(string),
       "dlc": CAN_FD_DLC(string),
       "flg": CAN_FD_FLG(string),
       "dir": CAN_FD_DIR(string),
       // Configuration with reference to DLC
       "payload": CAN_FD_PAYLOAD(string, delimeter = whitespace)
    },
    "replay": {
      "path": CAN_FD_PACKET_CHUNKS_FILE_PATH(string, format = *.csv)
    },
    "spoofing": {
      "id": "...",
      "dlc": "...",
      "flg": "...",
      "dir": "...",
      "payload": "..."
    }
  }
}

About

Command program to build {CAN | CAN FD | Automotive Ethernet} dataset.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published