Giter VIP home page Giter VIP logo

udshunter's Introduction

UDShunter

UDS hunter is a software which is made for scan UDS id and pentest services.

install UDS hunter python environment

> pip install python-can
> pip install udsoncan
> pip install can-isotp

TODO

we are working hard on this repository, but now we haven't implemented any features yet.

About

  • LittleRx :

  • TEST

udshunter's People

Contributors

littlerx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

pawel-modine

udshunter's Issues

udscan

import sys
import getopt
import os
import time
import can

"""
can.message(timestamp=0.0,                   //时间戳
            arbitration_id=0,                //报文id
            is_extended_id=True,             //是否为扩展帧
            is_remote_frame=False,           //是否为远程帧
            is_error_frame=False,            //是否为错误帧
            channel=None,                    //通道
            dlc=None,                        //dlc大小
            data=None,                       //数据
            is_fd=False,                     //是否为canfd
            is_rx=True,                      //是否为接收帧
            bitrate_switch=False,            //比特率开关
            error_state_indicator=False,       
            check=False)   
"""
"""
recv(timeout=None) 
            Block waiting for a message from the Bus.
            None to wait indefinitely.
"""

def udsidscan (canbus):
    idstart = 0x700
    idend = 0x7FF
    datareq = [0x02, 0x10, 0x01, 0x55, 0x55, 0x55, 0x55, 0x55]
    dataresp = [0x06, 0x50, 0x01]

    print("\r\nMessage sent on {}".format(canbus.channel_info))
    for id in range(idstart, idend):
        msgreq = can.Message(timestamp=time.time(), arbitration_id=id, data=datareq, is_extended_id=False)
        canbus.send(msgreq)
        t_end = time.time() + 1  # 超过100ms未收到uds响应报文则认为该id不支持诊断
        while time.time() < t_end:
            msgresp = canbus.recv(0.03)   # 阻塞接收报文的时间,超过100ms未收到任何报文则函数执行结束,100ms内收到任一报文则函数执行结束
            if msgresp is not None and list(msgresp.data)[0:3] == dataresp:
                print("----------------------------------------------------------------------")
                print(msgreq)
                print(msgresp)
    print("----------------------------------------------------------------------")

helpinfo = "udscan caninterface [options]\n" \
            "-h,--help      \n" \
            "-f             0:can 1:canfd\n" \
            "--bitrate      default 500000\n" \
            "--dbitrate     default 2000000\n" \
            "--bustype      can bus type\n" \
            "--channel      can channel"

def main (argv):

    print()
    if len(sys.argv) < 2:
        print("arguments number [%d] is invalid." %(len(sys.argv)))
        exit(0)
    if len(sys.argv) == 2:
        opts, args = getopt.getopt(sys.argv[1:], "h", ["help"])
        for opt, arg in opts:
            if opt in ("-h", "--help"):
                print(helpinfo)
                exit(0)
    canintf = sys.argv[1]
    # default configurations
    canfd = 0
    bitrate = 500000
    dbitrate = 2000000
    channel = "can0"
    bustype = "socketcan"
    # arguments parser
    opts, args = getopt.getopt(sys.argv[2:], "f", ["bitrate=", "dbitrate=", "channel=", "bustype="])
    for opt, arg in opts:
        if opt in ("-f"):
            canfd = 1
        elif opt in ("--bitrate"):
            bitrate = arg
        elif opt in ("--dbitrate"):
            dbitrate = arg
        elif opt in ("--channel"):
            channel = arg
        elif opt in ("--bustype"):
            bustype = arg

    print("caninterface [%s] canfd[%d] bitrate[%d] dbitrate[%d] bustype[%s] channel[%s]"
          %(canintf, canfd, bitrate, dbitrate, bustype, channel))
    # can interface up
    if canfd:
        os.system("sudo ip link set %s up type can bitrate %d dbitrate %d fd on" %(canintf, bitrate, dbitrate))
        #cmd = "sudo ip link set " + canintf + " up type can bitrate " + bitrate + " dbitrate " + dbitrate + " fd on";
    else:
        os.system("sudo ip link set %s up type can bitrate %d fd on" %(canintf, bitrate))
        #cmd = "sudo ip link set " + canintf + " up type can bitrate " + bitrate + " on";

    # bus = can.interface.Bus(bustype='bmcan', channel=0, bitrate=500000, data_bitrate=2000000, tres=True)
    # bus = can.interface.Bus(bustype='socketcan', channel='vcan0', bitrate=250000)
    # bus = can.interface.Bus(bustype='pcan', channel='PCAN_USBBUS1', bitrate=250000)
    # bus = can.interface.Bus(bustype='ixxat', channel=0, bitrate=250000)
    # bus = can.interface.Bus(bustype='vector', app_name='CANalyzer', channel=0, bitrate=250000)

    canbus = can.interface.Bus(bustype=bustype, channel=channel)

    udsidscan(canbus)

    canbus.shutdown()

if __name__ == "__main__":
    main(sys.argv)

关于向DID写入数据时的诊断会话状态问题

req = services.WriteDataByIdentifier.make_request(did,value,{did: BinCodeC})

建议增加:在 10 01 会话和 10 03 会话下分别尝试写入

某些被测件中现象如下:
10 01 会话状态下发起DID写入数据请求,被测端无响应
10 03 会话状态下发起DID写入数据请求,被测端回复否定响应

因此不同会话状态下可能导致测试结果不同。

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.