Giter VIP home page Giter VIP logo

virtualcar's Introduction

Notice: This project is original version of vircar. The change of name occured on 12/04/17.

virtualcar

virtualcar (vir-tual-car) is a CAN-based wrapper written in C, that acts as a virtual car. The core is listening to the virtual CAN device and parse, analyze and transmit signal from nodes to nodes, or in other way manipulate with request.

This software is licensed under GNU General Public V3 license. Please, keep the software open source and contribute to the project if you want.

The project is developed on top of SocketCAN module and therefore requires Linux based system. I am currently rewriting the SocketCAN module for MacOS and you may fork the repository from duraki/socketcanx.

a car? really?

Yes! A fully, functional car.
Well, not really no. It does represent a car/vehicle but in a limited spirit and form. I was writing a post about cyber-attacks on a vehicle systems and another one that show virtualcar in action, and didn't have necessary (hardware) equipment to test the techniques, so I wrote this to let myself experiment a bit.

So a few months passed, and I talked about this little code on a BalCCon 2k16 where I offered a small introduction to these cyber-attacks, plus you could buy me a drink and I'd tell you some secrets. So I renamed this project and I'll try to develop some nodes as per request in Issues board. Meanwhile, I'd appreciate pull requests that make sense.

functionality

Currently, virtualcar offers several different controllers or nodes that understand a particular signal and either accept or reject the CAN frame. I'm implementing both data frames and RTR. The RTR has some basic functions like asking for value of an instrument.

virtualcar nodes:

  • NODE_SIGNAL_DOOR_MODE - Door actions
  • NODE_SIGNAL_EHPS_MODE - EHPS actions

TODO nodes (@see nodes.h):

  • NODE_SIGNAL_INST_MODE
  • NODE_SIGNAL_ENGN_MODE
  • NODE_SIGNAL_MABS_MODE
  • NODE_SIGNAL_MESP_MODE
  • NODE_SIGNAL_AIRB_MODE
  • NODE_SIGNAL_NAVG_MODE
  • NODE_SIGNAL_TRNC_MODE

virtualcar-web

I'm sorry, the virtualcar-web is being developed and there is some kind of version floating as a private repository and a submodule in this repo. Anyway, virtualcar-web should be used as web-interface to manipulate with virtualcar daemon. It's written in Rails and support some interesting things but more about that inside virtualcar-web repository and README file.

$ git submodule init
Submodule 'virtualcar-web' (...) registered for path 'virtualcar-web'

$ git submodule update
Cloning into 'virtualcar-web'...
...

To update or fetch the virtualcar-web project:

$ cd virtualcar/virtualcar-web
$ git fetch
...

$ git merge origin/master

requirements

I love to write pure native scripts. The only requirement for now is that you are running under GNU Linux and have can-utils installed on your system.

  • gcc
  • linux kernel (can.h)
  • can-utils

compile & running

To clone the repo and compile it from source:

$ git clone https://github.com/duraki/virtualcar.git
$ cd virtualcar 
$ make
$ chmod 777 virtualcar 

To run virtualcar use sudo (entirely for CAN bus device linking)

$ sudo ./virtualcar
Welcome to vir(tual) car.
~
=========================================
https://github.com/duraki/virtualcar

# waiting for operation

To exit vircar use Ctrl+C.
To kill a car and remove protocol use:

$ ./virtualcar k
ka-boom, pfw, aaa, ts
*car exploded*

outro

If you are interested in car hacking, write me on twitter. Any additional options and CAN nodes should be accepted if they follow RTR or Accept/Desctruct operation. Please, keep the code and project with clean lines of code.

virtualcar's People

Contributors

duraki avatar spiperac avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

virtualcar's Issues

I meet a problem when I compile,how to solve ?

root@ubuntu:~/virtualcar# make
gcc -pthread src/include/lib.h src/include/lib.c src/include/colors.h src/virtualcar.c -o virtualcar
src/include/lib.h:97:37: warning: ‘struct canfd_frame’ declared inside parameter list [enabled by default]
 int parse_canframe(char *cs, struct canfd_frame *cf);
                                     ^
src/include/lib.h:97:37: warning: its scope is only this definition or declaration, which is probably not what you want [enabled by default]
src/include/lib.h:150:44: warning: ‘struct canfd_frame’ declared inside parameter list [enabled by default]
 void fprint_canframe(FILE *stream , struct canfd_frame *cf, char *eol, int sep, int maxdlen);
                                            ^
src/include/lib.h:151:41: warning: ‘struct canfd_frame’ declared inside parameter list [enabled by default]
 void sprint_canframe(char *buf , struct canfd_frame *cf, int sep, int maxdlen);
                                         ^
src/include/lib.h:183:49: warning: ‘struct canfd_frame’ declared inside parameter list [enabled by default]
 void fprint_long_canframe(FILE *stream , struct canfd_frame *cf, char *eol, int view, int maxdlen);
                                                 ^
src/include/lib.h:184:46: warning: ‘struct canfd_frame’ declared inside parameter list [enabled by default]
 void sprint_long_canframe(char *buf , struct canfd_frame *cf, int view, int maxdlen);
                                              ^
src/include/lib.h:212:19: warning: ‘struct canfd_frame’ declared inside parameter list [enabled by default]
                   const char *sep);
                   ^
src/include/colors.h: In function ‘printlog’:
src/include/colors.h:37:5: warning: incompatible implicit declaration of built-in function ‘sprintf’ [enabled by default]
     sprintf(log, "%s%s %s \n", color, message, RESET);
     ^
src/include/colors.h:38:5: warning: incompatible implicit declaration of built-in function ‘printf’ [enabled by default]
     printf(log);
     ^
In file included from src/virtualcar.c:50:0:
src/car.c: In function ‘send_can_frame’:
src/car.c:74:2: warning: passing argument 1 of ‘parse_canframe’ from incompatible pointer type [enabled by default]
  required_mtu = parse_canframe(&sframe, &frame);
  ^
In file included from src/car.c:43:0,
                 from src/virtualcar.c:50:
src/include/lib.h:97:5: note: expected ‘char *’ but argument is of type ‘char **’
 int parse_canframe(char *cs, struct canfd_frame *cf);
     ^
In file included from src/virtualcar.c:51:0:
src/include/colors.h: In function ‘printlog’:
src/include/colors.h:38:5: warning: format not a string literal and no format arguments [-Wformat-security]
     printf(log);
     ^
src/virtualcar.c: In function ‘main’:
src/virtualcar.c:134:9: warning: too many arguments for format [-Wformat-extra-args]
         printf(GREEN, "\nThread created successfully\n" RESET);

Unable to compile

Hi, I tried to install per your instructions and received the following error:

dirtynix@dirtynix:~/virtualcar$ make
gcc -pthread src/virtualcar.c -o virtualcar
In file included from src/virtualcar.c:50:0:
src/car.c: In function ‘send_can_frame’:
src/car.c:74:32: warning: passing argument 1 of ‘parse_canframe’ from incompatible pointer type [-Wincompatible-pointer-types]
required_mtu = parse_canframe(&sframe, &frame);
^
In file included from src/car.c:43:0,
from src/virtualcar.c:50:
src/include/lib.h:97:5: note: expected ‘char *’ but argument is of type ‘char **’
int parse_canframe(char *cs, struct canfd_frame *cf);
^
In file included from src/virtualcar.c:51:0:
src/bus.c: At top level:
src/bus.c:44:5: error: redefinition of ‘send_can_frame’
int send_can_frame(char *sframe)
^
In file included from src/virtualcar.c:50:0:
src/car.c:60:5: note: previous definition of ‘send_can_frame’ was here
int send_can_frame(char *sframe)
^
In file included from src/virtualcar.c:51:0:
src/bus.c: In function ‘send_can_frame’:
src/bus.c:59:30: error: expected expression before ‘=’ token
ifr.ifr_name[IFNAMSIZ-1[ = '\0';
^
src/bus.c:64:1: error: expected ‘]’ before ‘}’ token
}
^
src/bus.c:64:1: error: expected ‘;’ before ‘}’ token
Makefile:7: recipe for target 'all' failed
make: *** [all] Error 1

What am I doing wrong?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.