Analysis Environment Build report
1. Overview
This document is a team that carried out the BoB 12th NVR Vulnability Analysis project.This is a report described by ENVY (Kim Chan-in, Park Myung-hoon, Shin Myung-jin, Yang Gang-min, Lee Yu-kyeong) on the establishment of the Hikvision analysis environment.
1.1. Necessity
Debugging the binary that is activating the service is essential to proceed with the vulnerability analysis of hikvision. Therefore, in this document, we describe how to debug watchdog by bypassing it.
2. Analysis
If you debug the "sc_hicore" binary using the gdb tool, you can see that it is output as follows.
~~~~~~~~~~~~pid (492) will exit!
~~~~~~~~~~~~FN:[fn_master_status]
~~~~~~~~~~~~iRet [-88][Session Handle Err!!]
[165249.722559] [HKBSP][hik_wdt hik_wdt.1]hik-wdt:hikwdt_isr. I'm so Sorry (>_<)…
[165249.730063] [HKBSP][hik_wdt hik_wdt.1]hik-wdt:hikwdt_isr. last_feedwdt:4311458247(jiffies64:4311461694,timeout:25)If you look at the log, you can see that the watchdog feeding is rebooted after the timeout. The watchdog feeding timeout is set in the "hisi_watchdog_init" function of the "libplatform.so" file.
HPR_INT32 __fastcall hisi_watchdog_init(HPR_UINT32 uTimeOut)
{
HPR_UINT32 iDogTimeOut; // [sp+Ch] [bp-14h] BYREF
iDogTimeOut = uTimeOut;
if ( h_g_wdFd < 0 )
{
h_g_wdFd = open64("/dev/watchdog", 1);
if ( h_g_wdFd == -1 )
_assert("h_g_wdFd != -1", "src/hisi_bsp.c", 2480);
}
if ( call_ioctl(h_g_wdFd, 0xC0045706, &iDogTimeOut) >= 0 )
{
fprintf((FILE *)stderr, "fun:%s, line:%d ", "hisi_watchdog_init", 2491);
fprintf(
(FILE *)stderr,
"hisi_watchdog_init(%s, %d) ok iDogTimeOut:%d Sec!\n",
"/dev/watchdog",
h_g_wdFd,
iDogTimeOut);
return 0;
}
else
{
if ( util_dbg_open() )
util_debug("src/hisi_bsp.c", 2485, "hisi_watchdog_init", 2, "hisi_watchdog_init error!\n");
return -1;
}
}When the function is decoded, it can be seen that the timeout is set as much as the "uTimeOut" variable transmitted to the factor. Therefore, it was possible to bypass the watchdog by modifying the part and increasing the time that becomes the timeout.
As in the code above, by patching the "uTimeOut" variable to allocate 0xFFFFFFFFFFFFFF, the timeout time could be increased and debugging could be performed.
3. Deploy Analytical Environment Boot Script
I will explain the boot script for increasing watchdog timeout. First of all, the contents of "start.sh " and "S90start_ubifs" were modified as follows.
In the case of the "S90start_ubifs" script, before executing the "start.sh " script, the network was held and nfs was added to move the modified start.sh .
The "start.sh" script increased the timeout by allowing the "sc_hicore" binary to run after counting nfs to change "libplatform.so " to patched "libplatform.so " and then moving the patched library to run the "sc_hicore" binary. Therefore, the full script for this is as follows.
Last updated