Skip to content

Commit 0be6b8c

Browse files
zombieCraigpbarry-r7
authored andcommitted
Fixes rapid7#8022
Adds detection for ELM327 chips reporting CAN ERROR when vehicle is off. Addes some enhanced UDS Error codes. Cleaned up reporting from getvinfo if the vehicle is off or not connected.
1 parent 78586f0 commit 0be6b8c

File tree

3 files changed

+55
-6
lines changed

3 files changed

+55
-6
lines changed

lib/rex/post/hwbridge/extensions/automotive/uds_errors.rb

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ module Automotive
88

99
module UDSErrors
1010

11+
# Negative Response Codes (NDC)
1112
ERR_MNEMONIC = {
1213
0x10 => "GR",
1314
0x11 => "SNS",
@@ -54,7 +55,25 @@ module UDSErrors
5455
0x73 => "WBSC",
5556
0x78 => "RCRRP",
5657
0x7E => "SFNSIAS",
57-
0x7F => "SNSIAS"
58+
0x7F => "SNSIAS",
59+
0x81 => "RTH",
60+
0x82 => "RTL",
61+
0x83 => "EIR",
62+
0x84 => "EINR",
63+
0x85 => "ERTTL",
64+
0x86 => "TTH",
65+
0x87 => "TTL",
66+
0x88 => "VSTH",
67+
0x89 => "VSTL",
68+
0x8A => "TPTH",
69+
0x8B => "TPTL",
70+
0x8C => "TRNIN",
71+
0x8D => "TRNIG",
72+
0x8F => "BSNC",
73+
0x90 => "SLNIP",
74+
0x91 => "TCCL",
75+
0x92 => "VTH",
76+
0x93 => "VTL"
5877
}
5978

6079
ERR_DESC = {
@@ -80,7 +99,25 @@ module UDSErrors
8099
"WBSC" => "Wrong Block Sequence Counter",
81100
"RCRRP" => "Request Correctly Received, but Response is Pending",
82101
"SFNSIAS" => "Sub-Function Not Supoorted In Active Session",
83-
"SNSIAS" => "Service Not Supported In Active Session"
102+
"SNSIAS" => "Service Not Supported In Active Session",
103+
"RTH" => "RPM Too High",
104+
"RTL" => "RPM Too Low".
105+
"EIR" => "Engine is Running",
106+
"EINR" => "Engine is not Running",
107+
"ERTTL" => "Engine Run Time Too Low",
108+
"TTH" => "Temperature Too High",
109+
"TTL" => "Temperature Too Low",
110+
"VSTH" => "Vehicle Speed Too High",
111+
"VSTL" => "Vehicle Speed Too Low",
112+
"TPTH" => "Throttle Pedal Too High",
113+
"TPTL" => "Throttle Pedal Too Low",
114+
"TRNIN" => "Transmission Range Not in Neutral",
115+
"TRNIG" => "Transmission Range Not in Gear",
116+
"BSNC" => "Brake Switch Not Closed",
117+
"SLNIP" => "Shifter Lever Not In Park",
118+
"TCCL" => "Torque Converter Clutch Locked",
119+
"VTH" => "Voltage Too High",
120+
"VTL" => "Voltage Too Low"
84121
}
85122

86123
end

modules/post/hardware/automotive/getvinfo.rb

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,13 @@ def initialize(info={})
3333
end
3434

3535
def run
36-
pids = get_current_data_pids(datastore['CANBUS'], datastore['SRCID'], datastore['DSTID'])
37-
print_status("Available PIDS for pulling realtime data: #{pids.size} pids")
38-
print_status(" #{pids.inspect}")
36+
pids = get_current_data_pids(datastore["CANBUS"], datastore["SRCID"], datastore["DSTID"])
37+
if pids.size == 0
38+
print_status("No reported PIDs. You may not be properly connected")
39+
else
40+
print_status("Available PIDS for pulling realtime data: #{pids.size} pids")
41+
print_status(" #{pids.inspect}")
42+
end
3943
if pids.include? 1
4044
data = get_monitor_status(datastore['CANBUS'], datastore['SRCID'], datastore['DSTID'])
4145
print_status(" MIL (Engine Light) : #{data['MIL'] ? 'ON' : 'OFF'}") if data.key? "MIL"
@@ -75,7 +79,7 @@ def run
7579
end
7680
end
7781
pids = get_vinfo_supported_pids(datastore['CANBUS'], datastore['SRCID'], datastore['DSTID'])
78-
print_status("Mode $09 Vehicle Info Supported PIDS: #{pids.inspect}")
82+
print_status("Mode $09 Vehicle Info Supported PIDS: #{pids.inspect}") if pids.size > 0
7983
pids.each do |pid|
8084
# Handle known pids
8185
if pid == 2

tools/hardware/elm327_relay.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,10 @@ def cansend(id, data)
249249
send_cmd(data)
250250
@packets_sent += 1
251251
@last_sent = Time.now()
252+
if resp == "CAN ERROR"
253+
result["success"] = false
254+
return result
255+
end
252256
result["success"] = true
253257
result
254258
end
@@ -273,6 +277,10 @@ def isotpsend_and_wait(srcid, dstid, data, timeout, maxpkts)
273277
resp = send_cmd(data)
274278
@packets_sent += 1
275279
@last_sent = Time.now()
280+
if resp == "CAN ERROR"
281+
result["success"] = false
282+
return result
283+
end
276284
result["Packets"] = []
277285
resp.split(/\r/).each do |line|
278286
pkt = {}

0 commit comments

Comments
 (0)