Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/OpenIPC.Viewer.App/ViewModels/Dialogs/CameraEditorViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,9 @@ private void ApplyRtspTemplate(string vendor)
"xm" => (
$"rtsp://{host}:554/user={user}&password={Password}&channel=1&stream=0.sdp?real_stream",
$"rtsp://{host}:554/user={user}&password={Password}&channel=1&stream=1.sdp?real_stream"),
"xm-sofia" => (
$"rtsp://{host}:554/user={user}&password={SofiaHash(Password)}&channel=1&stream=0.sdp?real_stream",
$"rtsp://{host}:554/user={user}&password={SofiaHash(Password)}&channel=1&stream=1.sdp?real_stream"),
"hikvision" => (
$"rtsp://{host}:554/Streaming/Channels/101",
$"rtsp://{host}:554/Streaming/Channels/102"),
Expand All @@ -198,6 +201,23 @@ private void ApplyRtspTemplate(string vendor)
};
}

// XM/Xiongmai "Sofia" password digest (NETSurveillance/DVRIP): pairs of MD5
// bytes summed mod 62, mapped to [0-9A-Za-z], 8 chars. Newer XM firmwares
// reject the plaintext password in the RTSP URL and want this instead
// (empty password hashes to the well-known "tlJwpbo6"). MD5 here is a
// protocol requirement, not our choice of cryptography.
private static string SofiaHash(string password)
{
var md5 = System.Security.Cryptography.MD5.HashData(System.Text.Encoding.UTF8.GetBytes(password));
var chars = new char[8];
for (var i = 0; i < 8; i++)
{
var n = (md5[2 * i] + md5[2 * i + 1]) % 62;
chars[i] = (char)(n < 10 ? '0' + n : n < 36 ? 'A' + n - 10 : 'a' + n - 36);
}
return new string(chars);
}

[RelayCommand(CanExecute = nameof(CanTestConnection))]
private async Task TestConnectionAsync()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
<MenuFlyout Placement="BottomEdgeAlignedRight">
<MenuItem Header="OpenIPC (Majestic)" Command="{Binding ApplyRtspTemplateCommand}" CommandParameter="openipc" />
<MenuItem Header="XM / Xiongmai (NETSurveillance)" Command="{Binding ApplyRtspTemplateCommand}" CommandParameter="xm" />
<MenuItem Header="XM / Xiongmai (Sofia hash)" Command="{Binding ApplyRtspTemplateCommand}" CommandParameter="xm-sofia" />
<MenuItem Header="Hikvision" Command="{Binding ApplyRtspTemplateCommand}" CommandParameter="hikvision" />
<MenuItem Header="Dahua / Amcrest" Command="{Binding ApplyRtspTemplateCommand}" CommandParameter="dahua" />
<MenuItem Header="Reolink" Command="{Binding ApplyRtspTemplateCommand}" CommandParameter="reolink" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
x:Class="OpenIPC.Viewer.App.Views.Dialogs.CameraEditorWindow"
x:DataType="vm:CameraEditorViewModel"
Title="{Binding Title}"
Width="520" Height="640"
Width="560" Height="680"
WindowStartupLocation="CenterOwner"
CanResize="False"
Background="{StaticResource Bg1Brush}">
Expand Down
Loading