Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 037bd195db | |||
| fada3ace65 | |||
| ef67d76e54 | |||
| 62cf2425b1 | |||
| bab6cf7b75 |
11
.claude/settings.local.json
Normal file
11
.claude/settings.local.json
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"permissions": {
|
||||||
|
"allow": [
|
||||||
|
"Bash(dotnet build:*)",
|
||||||
|
"Bash(git add:*)",
|
||||||
|
"Bash(git commit -m \"$(cat <<''EOF''\nRelease v1.2.0: Integrate osquery for enhanced system information\n\nMajor Features:\n- Integrated osquery for comprehensive system information gathering\n- Added OsqueryService for executing SQL queries against system tables\n- Implemented Osquery Console tab for interactive SQL queries\n\nSystem Info Improvements:\n- Enhanced system info collection using osquery tables\n- Added support for multiple GPU detection\n- Improved memory detection with proper GB formatting\n- Fixed OS Architecture detection (x64/x86)\n- Better network interface detection (IPv4 only)\n- Human-readable timestamp formatting\n\nUI/UX Enhancements:\n- Added window resizing with corner drag support\n- Implemented dynamic window sizing (SizeToContent)\n- Added ScrollViewer for content overflow\n- Improved IP address formatting with bullet points\n- Added field labels to all system info displays\n- Set minimum/maximum window size constraints\n\nBug Fixes:\n- Fixed XAML StackPanel Spacing property issue\n- Merged duplicate MainWindow constructors\n- Fixed non-nullable field warnings\n- Fixed EventHandler nullability signatures\n- Removed redundant hostname/OS name fields\n- Fixed GPU registry query to detect all GPUs\n\n🤖 Generated with [Claude Code](https://claude.com/claude-code)\n\nCo-Authored-By: Claude <noreply@anthropic.com>\nEOF\n)\")"
|
||||||
|
],
|
||||||
|
"deny": [],
|
||||||
|
"ask": []
|
||||||
|
}
|
||||||
|
}
|
||||||
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
[submodule "deps/osquery"]
|
||||||
|
path = deps/osquery
|
||||||
|
url = https://github.com/osquery/osquery.git
|
||||||
@@ -1,32 +1,46 @@
|
|||||||
<!--
|
<!--
|
||||||
This file allow for customizing your build process.
|
This file allows for customizing your build process.
|
||||||
See: https://learn.microsoft.com/visualstudio/msbuild/customize-your-build
|
See: https://learn.microsoft.com/visualstudio/msbuild/customize-your-build
|
||||||
-->
|
-->
|
||||||
<Project>
|
<Project>
|
||||||
<!--
|
|
||||||
Uncomment if you need to enable inclusion of another Directory.Build.props file from a parent directory
|
|
||||||
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />
|
|
||||||
-->
|
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<LangVersion>12</LangVersion>
|
<LangVersion>12</LangVersion>
|
||||||
<AccelerateBuildsInVisualStudio>true</AccelerateBuildsInVisualStudio>
|
<AccelerateBuildsInVisualStudio>true</AccelerateBuildsInVisualStudio>
|
||||||
<!--
|
|
||||||
If you you like to see source generated files saved to disk you can enable the following:
|
|
||||||
https://learn.microsoft.com/dotnet/csharp/roslyn-sdk/source-generators-overview?WT.mc_id=DT-MVP-5003472
|
|
||||||
-->
|
|
||||||
<!--<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>-->
|
<!--<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>-->
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<!--
|
|
||||||
This allows all projects to share the same user secrets file.
|
|
||||||
If you want project to have their own, set it to a different GUID on each project.
|
|
||||||
See: https://learn.microsoft.com/dotnet/architecture/microservices/secure-net-microservices-web-applications/developer-app-secrets-storage
|
|
||||||
-->
|
|
||||||
<PropertyGroup Label="User Secrets">
|
<PropertyGroup Label="User Secrets">
|
||||||
<UserSecretsId>1ef91ee6-7b55-474e-ab2b-2d164b723a56</UserSecretsId>
|
<UserSecretsId>1ef91ee6-7b55-474e-ab2b-2d164b723a56</UserSecretsId>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- 🔹 Automatically derive version from latest Git tag -->
|
||||||
|
<Target Name="GetVersionFromGit" BeforeTargets="GetAssemblyVersion">
|
||||||
|
<!-- Get the most recent tag (like v1.1.1) -->
|
||||||
|
<Exec Command="git describe --tags --abbrev=0" ConsoleToMSBuild="true" IgnoreExitCode="true">
|
||||||
|
<Output TaskParameter="ConsoleOutput" PropertyName="GitTag" />
|
||||||
|
</Exec>
|
||||||
|
|
||||||
|
<!-- Strip leading 'v' if present -->
|
||||||
|
<PropertyGroup>
|
||||||
|
<GitVersion>$([System.Text.RegularExpressions.Regex]::Replace('$(GitTag)', '^v', ''))</GitVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<!-- Fallback if no tags exist yet -->
|
||||||
|
<PropertyGroup Condition="'$(GitVersion)' == ''">
|
||||||
|
<GitVersion>0.0.0</GitVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<!-- Apply to assembly and file versions -->
|
||||||
|
<Message Text="🔖 Using version: $(GitVersion)" Importance="High" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Version>$(GitVersion)</Version>
|
||||||
|
<FileVersion>$(GitVersion)</FileVersion>
|
||||||
|
<AssemblyVersion>$(GitVersion)</AssemblyVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Target>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
BIN
LD-SysInfo/Assets/osqueryi.exe
Normal file
BIN
LD-SysInfo/Assets/osqueryi.exe
Normal file
Binary file not shown.
39
LD-SysInfo/Config.cs
Normal file
39
LD-SysInfo/Config.cs
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
#nullable disable
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace LD_SysInfo
|
||||||
|
{
|
||||||
|
public class AppConfig
|
||||||
|
{
|
||||||
|
[JsonProperty("ServerUrl")] public string ServerUrl { get; set; } = "https://yourserver.com/api/status";
|
||||||
|
[JsonProperty("EnableLogging")] public bool EnableLogging { get; set; } = true;
|
||||||
|
[JsonProperty("KeepAlivePeriod")] public int KeepAlivePeriod { get; set; } = 30;
|
||||||
|
[JsonProperty("SystemInfoInterval")] public int SystemInfoInterval { get; set; } = 60;
|
||||||
|
[JsonProperty("ClientIdentifier")] public string ClientIdentifier { get; set; } = "your-default-client-id";
|
||||||
|
[JsonProperty("Auth")] public AuthConfig Auth { get; set; } = new();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class AuthConfig
|
||||||
|
{
|
||||||
|
[JsonProperty("Username")] public string Username { get; set; } = "testuser";
|
||||||
|
[JsonProperty("Password")] public string Password { get; set; } = "testpassword";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class ConfigManager
|
||||||
|
{
|
||||||
|
private static readonly string ConfigPath = Path.Combine(AppContext.BaseDirectory, "config.json");
|
||||||
|
|
||||||
|
public static AppConfig LoadConfig(string? pathOverride = null)
|
||||||
|
{
|
||||||
|
string path = pathOverride ?? ConfigPath;
|
||||||
|
if (!File.Exists(path))
|
||||||
|
throw new FileNotFoundException($"Config file not found at {path}");
|
||||||
|
|
||||||
|
string json = File.ReadAllText(path);
|
||||||
|
return JsonConvert.DeserializeObject<AppConfig>(json) ?? new AppConfig();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,6 +12,17 @@
|
|||||||
<OutputPath>C:\Users\Sonder\source\repos\psg-oversight-app\BuildDir\bin\Debug\net8.0-windows\</OutputPath>
|
<OutputPath>C:\Users\Sonder\source\repos\psg-oversight-app\BuildDir\bin\Debug\net8.0-windows\</OutputPath>
|
||||||
<IncludeSatelliteAssembliesForPublish>false</IncludeSatelliteAssembliesForPublish>
|
<IncludeSatelliteAssembliesForPublish>false</IncludeSatelliteAssembliesForPublish>
|
||||||
|
|
||||||
|
<!-- 🔢 Version Info -->
|
||||||
|
<AssemblyVersion>1.2.0.0</AssemblyVersion>
|
||||||
|
<FileVersion>1.2.0.0</FileVersion>
|
||||||
|
<Version>1.2.0</Version>
|
||||||
|
|
||||||
|
<!-- ✅ Enables source metadata and Git info -->
|
||||||
|
<Deterministic>true</Deterministic>
|
||||||
|
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
|
||||||
|
<RepositoryUrl>https://gitea.psg.net.au/your-repo</RepositoryUrl>
|
||||||
|
<IncludeSourceRevisionInInformationalVersion>true</IncludeSourceRevisionInInformationalVersion>
|
||||||
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
@@ -37,9 +48,13 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ApplicationDefinition Remove="App.xaml" />
|
<ApplicationDefinition Remove="App.xaml" />
|
||||||
|
<None Remove="Assets\osqueryi.exe" />
|
||||||
<None Remove="Assets\trayicon.ico" />
|
<None Remove="Assets\trayicon.ico" />
|
||||||
<None Remove="config.json" />
|
<None Remove="config.json" />
|
||||||
<Content Include="Assets\LDShortcut.ico" />
|
<Content Include="Assets\LDShortcut.ico" />
|
||||||
|
<Content Include="Assets\osqueryi.exe">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
<Page Include="App.xaml" />
|
<Page Include="App.xaml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -11,11 +11,15 @@
|
|||||||
|
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
Title="PSG - Oversight"
|
Title="PSG - Oversight"
|
||||||
Height="500"
|
SizeToContent="Height"
|
||||||
Width="400"
|
Width="420"
|
||||||
|
MinHeight="400"
|
||||||
|
MinWidth="350"
|
||||||
|
MaxHeight="800"
|
||||||
Icon="Assets/trayicon.ico"
|
Icon="Assets/trayicon.ico"
|
||||||
WindowStyle="None"
|
WindowStyle="None"
|
||||||
AllowsTransparency="True"
|
AllowsTransparency="True"
|
||||||
|
ResizeMode="CanResizeWithGrip"
|
||||||
Background="Transparent"
|
Background="Transparent"
|
||||||
Foreground="{DynamicResource TextDarkBrush}">
|
Foreground="{DynamicResource TextDarkBrush}">
|
||||||
|
|
||||||
@@ -174,15 +178,23 @@
|
|||||||
<!-- 🔹 Titlebar -->
|
<!-- 🔹 Titlebar -->
|
||||||
<Border Grid.Row="0"
|
<Border Grid.Row="0"
|
||||||
CornerRadius="12,12,0,0"
|
CornerRadius="12,12,0,0"
|
||||||
|
Background="{DynamicResource BackgroundDarkBrush}"
|
||||||
Background="{DynamicResource BackgroundDarkBrush}" Margin="0,0,2,2">
|
Margin="0,0,2,2">
|
||||||
<Grid MouseDown="TitleBar_MouseDown">
|
<Grid MouseDown="TitleBar_MouseDown">
|
||||||
|
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="10,0,0,0">
|
||||||
<TextBlock Text="PSG - Oversight"
|
<TextBlock Text="PSG - Oversight"
|
||||||
VerticalAlignment="Center"
|
|
||||||
Margin="10,0,0,0"
|
|
||||||
FontSize="22"
|
FontSize="22"
|
||||||
FontWeight="Bold"
|
FontWeight="Bold"
|
||||||
Foreground="{DynamicResource TitleBrush}" />
|
Foreground="{DynamicResource TitleBrush}" />
|
||||||
|
<TextBlock x:Name="VersionTextBlock"
|
||||||
|
Text="v0.0.0"
|
||||||
|
FontSize="12"
|
||||||
|
VerticalAlignment="Bottom"
|
||||||
|
Margin="8,0,0,3"
|
||||||
|
Foreground="{DynamicResource TitleBrush}"
|
||||||
|
Opacity="0.7" />
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
|
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
|
||||||
<Button Width="30" Height="30" Click="MinimizeWindow_Click" Style="{StaticResource WindowButtonStyle}">
|
<Button Width="30" Height="30" Click="MinimizeWindow_Click" Style="{StaticResource WindowButtonStyle}">
|
||||||
<materialDesign:PackIcon Kind="WindowMinimize" Width="20" Height="20" />
|
<materialDesign:PackIcon Kind="WindowMinimize" Width="20" Height="20" />
|
||||||
@@ -193,11 +205,11 @@
|
|||||||
<Button Width="30" Height="30" Click="CloseWindow_Click" Style="{StaticResource CloseButtonStyle}">
|
<Button Width="30" Height="30" Click="CloseWindow_Click" Style="{StaticResource CloseButtonStyle}">
|
||||||
<materialDesign:PackIcon Kind="WindowClose" Width="20" Height="20" />
|
<materialDesign:PackIcon Kind="WindowClose" Width="20" Height="20" />
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Border>
|
</Border>
|
||||||
|
|
||||||
|
|
||||||
<!-- 🔹 Tabs + Theme Toggle -->
|
<!-- 🔹 Tabs + Theme Toggle -->
|
||||||
<Grid Grid.Row="1" Background="{DynamicResource BackgroundDarkBrush}">
|
<Grid Grid.Row="1" Background="{DynamicResource BackgroundDarkBrush}">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
@@ -217,6 +229,7 @@
|
|||||||
<TabItem Header="SysInfo" FontSize="16"/>
|
<TabItem Header="SysInfo" FontSize="16"/>
|
||||||
<TabItem Header="InstalledApps" FontSize="16"/>
|
<TabItem Header="InstalledApps" FontSize="16"/>
|
||||||
<TabItem Header="Status" FontSize="16"/>
|
<TabItem Header="Status" FontSize="16"/>
|
||||||
|
<TabItem Header="Osquery" FontSize="16"/>
|
||||||
</TabControl>
|
</TabControl>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
@@ -256,6 +269,7 @@
|
|||||||
|
|
||||||
<!-- 🔹 SysInfo Tab -->
|
<!-- 🔹 SysInfo Tab -->
|
||||||
<TabItem Header="SysInfo">
|
<TabItem Header="SysInfo">
|
||||||
|
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled">
|
||||||
<StackPanel Margin="5,0,5,0" VerticalAlignment="Top">
|
<StackPanel Margin="5,0,5,0" VerticalAlignment="Top">
|
||||||
<TextBlock x:Name="HostnameTextBlock" Text="Hostname" FontSize="12" Margin="5" Foreground="{DynamicResource TextBrush}" />
|
<TextBlock x:Name="HostnameTextBlock" Text="Hostname" FontSize="12" Margin="5" Foreground="{DynamicResource TextBrush}" />
|
||||||
<TextBlock x:Name="OSNameTextBlock" Text="OS Name" FontSize="12" Margin="5" Foreground="{DynamicResource TextBrush}" />
|
<TextBlock x:Name="OSNameTextBlock" Text="OS Name" FontSize="12" Margin="5" Foreground="{DynamicResource TextBrush}" />
|
||||||
@@ -267,46 +281,49 @@
|
|||||||
<TextBlock x:Name="ProcessorArchitectureTextBlock" Text="Processor Architecture" FontSize="12" Margin="5" Foreground="{DynamicResource TextBrush}" />
|
<TextBlock x:Name="ProcessorArchitectureTextBlock" Text="Processor Architecture" FontSize="12" Margin="5" Foreground="{DynamicResource TextBrush}" />
|
||||||
|
|
||||||
|
|
||||||
|
<!-- New fields -->
|
||||||
|
<TextBlock x:Name="MemoryTextBlock" Text="Total Memory" FontSize="12" Margin="5" Foreground="{DynamicResource TextBrush}" />
|
||||||
|
<TextBlock x:Name="GpuTextBlock" Text="GPU(s)" FontSize="12" Margin="5" Foreground="{DynamicResource TextBrush}" TextWrapping="Wrap" />
|
||||||
|
<TextBlock x:Name="IpTextBlock" Text="IP Addresses" FontSize="12" Margin="5" Foreground="{DynamicResource TextBrush}" TextWrapping="Wrap" />
|
||||||
|
<TextBlock x:Name="CollectedAtTextBlock" Text="Last updated: N/A" FontSize="12" Margin="8,10,5,5" Foreground="{DynamicResource TextDarkBrush}" FontStyle="Italic" />
|
||||||
|
|
||||||
|
<StackPanel Orientation="Horizontal" Margin="5,8,5,5" HorizontalAlignment="Left">
|
||||||
|
<Button Content="Refresh now"
|
||||||
|
Style="{StaticResource CustomRaisedButton}"
|
||||||
|
Background="{DynamicResource PrimaryBrush}"
|
||||||
|
Foreground="{DynamicResource SelectedLightBrush}"
|
||||||
|
Click="RefreshButton_Click"
|
||||||
|
Width="120"
|
||||||
|
Margin="0,0,8,0" />
|
||||||
<Button Content="Export to CSV"
|
<Button Content="Export to CSV"
|
||||||
Style="{StaticResource CustomRaisedButton}"
|
Style="{StaticResource CustomRaisedButton}"
|
||||||
Background="{DynamicResource PrimaryBrush}"
|
Background="{DynamicResource PrimaryBrush}"
|
||||||
Foreground="{DynamicResource SelectedLightBrush}"
|
Foreground="{DynamicResource SelectedLightBrush}"
|
||||||
Click="ExportToCsvButton_Click"
|
Click="ExportToCsvButton_Click"
|
||||||
Width="200"
|
Width="120"
|
||||||
Margin="5"
|
Margin="0,0,8,0" />
|
||||||
HorizontalAlignment="Left" />
|
|
||||||
|
|
||||||
<Button Content="Save System Info"
|
<Button Content="Save System Info"
|
||||||
Style="{StaticResource CustomRaisedButton}"
|
Style="{StaticResource CustomRaisedButton}"
|
||||||
Background="{DynamicResource PrimaryBrush}"
|
Background="{DynamicResource PrimaryBrush}"
|
||||||
Foreground="{DynamicResource SelectedLightBrush}"
|
Foreground="{DynamicResource SelectedLightBrush}"
|
||||||
Click="StoreSystemInfoButton_Click"
|
Click="StoreSystemInfoButton_Click"
|
||||||
Width="200"
|
Width="120" />
|
||||||
Margin="5"
|
</StackPanel>
|
||||||
HorizontalAlignment="Left" />
|
|
||||||
|
|
||||||
<CheckBox
|
<CheckBox x:Name="IncludeInstalledAppsCheckBox"
|
||||||
x:Name="IncludeInstalledAppsCheckBox"
|
|
||||||
Content="Include installed Apps?"
|
Content="Include installed Apps?"
|
||||||
FontSize="14"
|
FontSize="14"
|
||||||
Margin="5"
|
Margin="5"
|
||||||
Foreground="{DynamicResource TextDarkBrush}"
|
Foreground="{DynamicResource TextDarkBrush}"
|
||||||
Style="{StaticResource MaterialDesignCheckBox}" />
|
Style="{StaticResource MaterialDesignCheckBox}" />
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<TextBlock x:Name="StatusTextBlock"
|
<TextBlock x:Name="StatusTextBlock"
|
||||||
FontSize="14"
|
FontSize="14"
|
||||||
FontWeight="SemiBold"
|
FontWeight="SemiBold"
|
||||||
Margin="10,5"
|
Margin="10,5"
|
||||||
Foreground="{DynamicResource ErrorBrush}" />
|
Foreground="{DynamicResource ErrorBrush}" />
|
||||||
|
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
</ScrollViewer>
|
||||||
</TabItem>
|
</TabItem>
|
||||||
|
|
||||||
<!-- 🔹 InstalledApps Tab -->
|
<!-- 🔹 InstalledApps Tab -->
|
||||||
@@ -393,6 +410,52 @@
|
|||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
|
<!-- 🔹 Osquery Console Tab -->
|
||||||
|
<TabItem Header="Osquery">
|
||||||
|
<Grid Background="{DynamicResource BackgroundDarkBrush}" Margin="10">
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
<RowDefinition Height="*"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
|
<TextBlock Text="Enter Osquery SQL:" FontWeight="Bold" Margin="0,0,0,4" Foreground="{DynamicResource TextLightBrush}"/>
|
||||||
|
<TextBox x:Name="OsqueryQueryBox"
|
||||||
|
Grid.Row="1"
|
||||||
|
Height="60"
|
||||||
|
TextWrapping="Wrap"
|
||||||
|
VerticalScrollBarVisibility="Auto"
|
||||||
|
Background="#252526"
|
||||||
|
Foreground="White"
|
||||||
|
FontFamily="Consolas"
|
||||||
|
FontSize="14"
|
||||||
|
AcceptsReturn="True"
|
||||||
|
Text="SELECT * FROM system_info;" />
|
||||||
|
|
||||||
|
<Button Grid.Row="1"
|
||||||
|
Content="Run Query"
|
||||||
|
HorizontalAlignment="Right"
|
||||||
|
VerticalAlignment="Top"
|
||||||
|
Width="120"
|
||||||
|
Margin="0,4,0,0"
|
||||||
|
Click="RunOsqueryQuery_Click"/>
|
||||||
|
|
||||||
|
<TextBox x:Name="OsqueryOutputBox"
|
||||||
|
Grid.Row="2"
|
||||||
|
Margin="0,10,0,0"
|
||||||
|
TextWrapping="Wrap"
|
||||||
|
VerticalScrollBarVisibility="Auto"
|
||||||
|
HorizontalScrollBarVisibility="Auto"
|
||||||
|
Background="#1e1e1e"
|
||||||
|
Foreground="#dcdcdc"
|
||||||
|
FontFamily="Consolas"
|
||||||
|
FontSize="13"
|
||||||
|
AcceptsReturn="True"
|
||||||
|
IsReadOnly="True"
|
||||||
|
Text="Results will appear here..." />
|
||||||
|
</Grid>
|
||||||
|
</TabItem>
|
||||||
|
|
||||||
</TabControl>
|
</TabControl>
|
||||||
</Border>
|
</Border>
|
||||||
|
|
||||||
|
|||||||
@@ -1,24 +1,33 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using Microsoft.Win32;
|
|
||||||
using System.IO;
|
|
||||||
using System.Windows.Threading;
|
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Animation;
|
||||||
|
using System.Windows.Threading;
|
||||||
|
|
||||||
using Hardcodet.Wpf.TaskbarNotification;
|
using Hardcodet.Wpf.TaskbarNotification;
|
||||||
|
|
||||||
|
using LD_SysInfo.Models;
|
||||||
using LD_SysInfo.Services;
|
using LD_SysInfo.Services;
|
||||||
|
|
||||||
|
using MaterialDesignColors;
|
||||||
|
|
||||||
|
using MaterialDesignThemes.Wpf;
|
||||||
|
|
||||||
|
using Microsoft.Win32;
|
||||||
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using System.Windows.Media.Animation;
|
|
||||||
using LD_SysInfo.Models;
|
|
||||||
using MaterialDesignColors;
|
|
||||||
using MaterialDesignThemes.Wpf;
|
|
||||||
using System.Windows.Input;
|
|
||||||
using Application = System.Windows.Application;
|
using Application = System.Windows.Application;
|
||||||
using System.Windows.Media;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -29,24 +38,45 @@ namespace LD_SysInfo
|
|||||||
{
|
{
|
||||||
|
|
||||||
private static readonly HttpClient httpClient = new HttpClient();
|
private static readonly HttpClient httpClient = new HttpClient();
|
||||||
private static AppConfig _config;
|
private static AppConfig _config = null!; // Initialized in LoadConfig
|
||||||
private static string jwtToken = null; // 🔹 Store the JWT token globally in the app
|
private static string? jwtToken = null; // 🔹 Store the JWT token globally in the app
|
||||||
private readonly DispatcherTimer messageClearTimer;
|
private readonly DispatcherTimer messageClearTimer = null!; // Initialized in constructor
|
||||||
private readonly DispatcherTimer postTimer;
|
private readonly DispatcherTimer postTimer = null!; // Initialized in constructor
|
||||||
private readonly DispatcherTimer keepAliveTimer;
|
private readonly DispatcherTimer keepAliveTimer = null!; // Initialized in constructor
|
||||||
|
private readonly DispatcherTimer tokenRefreshTimer = null!; // Initialized in constructor
|
||||||
private readonly Uri LightThemeUri = new Uri("pack://application:,,,/Themes/LightTheme.xaml", UriKind.Absolute);
|
private readonly Uri LightThemeUri = new Uri("pack://application:,,,/Themes/LightTheme.xaml", UriKind.Absolute);
|
||||||
private readonly Uri DarkThemeUri = new Uri("pack://application:,,,/Themes/DarkTheme.xaml", UriKind.Absolute);
|
private readonly Uri DarkThemeUri = new Uri("pack://application:,,,/Themes/DarkTheme.xaml", UriKind.Absolute);
|
||||||
private bool isDarkTheme = false;
|
private bool isDarkTheme = false;
|
||||||
|
private SystemInfo _cachedSystemInfo = null!; // Initialized in DisplaySystemInfo
|
||||||
|
|
||||||
private static readonly string ConfigPath = Path.Combine(AppContext.BaseDirectory, "config.json");
|
private static readonly string ConfigPath = Path.Combine(AppContext.BaseDirectory, "config.json");
|
||||||
|
|
||||||
|
|
||||||
public MainWindow()
|
public MainWindow()
|
||||||
{
|
{
|
||||||
|
|
||||||
// ⚠️ Temporary SSL Certificate Bypass - For Testing Only
|
// ⚠️ Temporary SSL Certificate Bypass - For Testing Only
|
||||||
System.Net.ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;
|
System.Net.ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;
|
||||||
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
var exePath = Assembly.GetEntryAssembly()?.Location;
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(exePath))
|
||||||
|
{
|
||||||
|
exePath = Process.GetCurrentProcess().MainModule?.FileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(exePath))
|
||||||
|
{
|
||||||
|
var fvi = FileVersionInfo.GetVersionInfo(exePath);
|
||||||
|
var productVersion = fvi.ProductVersion ?? "0.0.0";
|
||||||
|
var cleanVersion = productVersion.Split('+')[0];
|
||||||
|
VersionTextBlock.Text = $"v{cleanVersion}";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
VersionTextBlock.Text = "v0.0.0";
|
||||||
|
}
|
||||||
LoadConfig();
|
LoadConfig();
|
||||||
DisplaySystemInfo();
|
DisplaySystemInfo();
|
||||||
AutoLogin();
|
AutoLogin();
|
||||||
@@ -74,11 +104,42 @@ namespace LD_SysInfo
|
|||||||
keepAliveTimer.Tick += KeepAliveTimer_Tick;
|
keepAliveTimer.Tick += KeepAliveTimer_Tick;
|
||||||
keepAliveTimer.Start();
|
keepAliveTimer.Start();
|
||||||
|
|
||||||
|
// 🔄 Initialize the Token Refresh timer to refresh token proactively before expiration
|
||||||
|
// Tokens expire in 60 minutes, so refresh at 50 minutes to be safe
|
||||||
|
tokenRefreshTimer = new DispatcherTimer();
|
||||||
|
tokenRefreshTimer.Interval = TimeSpan.FromMinutes(50);
|
||||||
|
tokenRefreshTimer.Tick += TokenRefreshTimer_Tick;
|
||||||
|
tokenRefreshTimer.Start();
|
||||||
|
|
||||||
|
// Ensure initial refresh occurs after UI is ready
|
||||||
|
this.Loaded += async (s, e) =>
|
||||||
|
{
|
||||||
|
// Small delay so UI visuals finish initializing
|
||||||
|
await Task.Delay(50);
|
||||||
|
await RefreshSystemInfoAsync();
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async void RunOsqueryQuery_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
OsqueryOutputBox.Text = "Running query...";
|
||||||
|
string sql = OsqueryQueryBox.Text.Trim();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var result = await Task.Run(() => OsqueryService.Query(sql));
|
||||||
|
|
||||||
|
string prettyJson = System.Text.Json.JsonSerializer.Serialize(result,
|
||||||
|
new System.Text.Json.JsonSerializerOptions { WriteIndented = true });
|
||||||
|
|
||||||
|
OsqueryOutputBox.Text = prettyJson;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
OsqueryOutputBox.Text = $"❌ Error running query:\n{ex}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void LoadConfig()
|
private void LoadConfig()
|
||||||
{
|
{
|
||||||
@@ -87,7 +148,7 @@ namespace LD_SysInfo
|
|||||||
//System.Windows.MessageBox.Show($"DEBUG: AppContext.BaseDirectory = {AppContext.BaseDirectory}");
|
//System.Windows.MessageBox.Show($"DEBUG: AppContext.BaseDirectory = {AppContext.BaseDirectory}");
|
||||||
//System.Windows.MessageBox.Show($"DEBUG: ConfigPath = {ConfigPath}");
|
//System.Windows.MessageBox.Show($"DEBUG: ConfigPath = {ConfigPath}");
|
||||||
|
|
||||||
if (!File.Exists((string?)ConfigPath))
|
if (!File.Exists(ConfigPath))
|
||||||
{
|
{
|
||||||
System.Windows.MessageBox.Show("❌ config.json not found at resolved path!");
|
System.Windows.MessageBox.Show("❌ config.json not found at resolved path!");
|
||||||
}
|
}
|
||||||
@@ -193,7 +254,7 @@ namespace LD_SysInfo
|
|||||||
string logDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "LD_SysInfo", "Logs");
|
string logDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "LD_SysInfo", "Logs");
|
||||||
Directory.CreateDirectory(logDir); // Ensure directory exists
|
Directory.CreateDirectory(logDir); // Ensure directory exists
|
||||||
|
|
||||||
string logFile = Path.Combine(logDir, $"log_{DateTime.Now:yyyyMMdd_HHmmss}.txt");
|
string logFile = Path.Combine(logDir, $"log_{DateTime.Now:yyyyMMdd_HHmms}.txt");
|
||||||
File.WriteAllText(logFile, "=== LD SysInfo Diagnostic Log ===\n");
|
File.WriteAllText(logFile, "=== LD SysInfo Diagnostic Log ===\n");
|
||||||
|
|
||||||
File.AppendAllText(logFile, $"Timestamp: {DateTime.Now}\n");
|
File.AppendAllText(logFile, $"Timestamp: {DateTime.Now}\n");
|
||||||
@@ -211,21 +272,15 @@ namespace LD_SysInfo
|
|||||||
|
|
||||||
private void DisplaySystemInfo()
|
private void DisplaySystemInfo()
|
||||||
{
|
{
|
||||||
var sysInfo = SystemInfo.GetSystemInfo();
|
_cachedSystemInfo = SystemInfo.GetSystemInfo();
|
||||||
OSNameTextBlock.Text = $"OS Name: {sysInfo.OSName}";
|
UpdateSysInfoUI(_cachedSystemInfo);
|
||||||
OSVersionTextBlock.Text = $"OS Version: {sysInfo.OSVersion}";
|
|
||||||
WindowsVersionTextBlock.Text = $"Windows Version: {sysInfo.WindowsVersion}";
|
|
||||||
WindowsBuildTextBlock.Text = $"Windows Build: {sysInfo.WindowsBuild}";
|
|
||||||
OSArchitectureTextBlock.Text = $"OS Architecture: {sysInfo.OSArchitecture}";
|
|
||||||
ProcessorNameTextBlock.Text = $"Processor Name: {sysInfo.ProcessorName}";
|
|
||||||
ProcessorArchitectureTextBlock.Text = $"Processor Architecture: {sysInfo.ProcessorArchitecture}";
|
|
||||||
HostnameTextBlock.Text = $"Hostname: {sysInfo.Hostname}";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadInstalledAppsButton_Click(object sender, RoutedEventArgs e)
|
private void LoadInstalledAppsButton_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
var applications = SystemInfo.GetInstalledApplicationsFromRegistry();
|
var sysInfo = SystemInfo.GetSystemInfo();
|
||||||
InstalledAppsListBox.ItemsSource = applications;
|
InstalledAppsListBox.ItemsSource = sysInfo.InstalledApplications;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void StoreSystemInfoButton_Click(object sender, RoutedEventArgs e)
|
private async void StoreSystemInfoButton_Click(object sender, RoutedEventArgs e)
|
||||||
@@ -239,7 +294,7 @@ namespace LD_SysInfo
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var sysInfo = SystemInfo.GetSystemInfo();
|
var sysInfo = SystemInfo.GetSystemInfo();
|
||||||
var applications = SystemInfo.GetInstalledApplicationsFromRegistry();
|
var applications = sysInfo.InstalledApplications;
|
||||||
|
|
||||||
var formattedApplications = new List<object>();
|
var formattedApplications = new List<object>();
|
||||||
foreach (var app in applications)
|
foreach (var app in applications)
|
||||||
@@ -252,6 +307,41 @@ namespace LD_SysInfo
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var formattedUserApplications = new List<object>();
|
||||||
|
foreach (var app in sysInfo.UserInstalledApplications)
|
||||||
|
{
|
||||||
|
formattedUserApplications.Add(new
|
||||||
|
{
|
||||||
|
app_name = app.Name,
|
||||||
|
app_version = app.Version,
|
||||||
|
publisher = app.Publisher
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
var formattedWindowsUpdates = new List<object>();
|
||||||
|
foreach (var update in sysInfo.WindowsUpdates)
|
||||||
|
{
|
||||||
|
formattedWindowsUpdates.Add(new
|
||||||
|
{
|
||||||
|
hotFixID = update.HotFixID,
|
||||||
|
description = update.Description,
|
||||||
|
installedOn = update.InstalledOn,
|
||||||
|
installedBy = update.InstalledBy
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
var formattedAppXPackages = new List<object>();
|
||||||
|
foreach (var pkg in sysInfo.AppXPackages)
|
||||||
|
{
|
||||||
|
formattedAppXPackages.Add(new
|
||||||
|
{
|
||||||
|
name = pkg.Name,
|
||||||
|
version = pkg.Version,
|
||||||
|
publisher = pkg.Publisher,
|
||||||
|
packageFullName = pkg.PackageFullName
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
var payload = new
|
var payload = new
|
||||||
{
|
{
|
||||||
clientIdentifier = _config.ClientIdentifier,
|
clientIdentifier = _config.ClientIdentifier,
|
||||||
@@ -268,7 +358,9 @@ namespace LD_SysInfo
|
|||||||
ipAddresses = sysInfo.IpAddresses,
|
ipAddresses = sysInfo.IpAddresses,
|
||||||
lastBootTime = sysInfo.LastBootTime,
|
lastBootTime = sysInfo.LastBootTime,
|
||||||
drives = sysInfo.Drives,
|
drives = sysInfo.Drives,
|
||||||
installedApplications = formattedApplications
|
installedApplications = formattedApplications,
|
||||||
|
windowsUpdates = formattedWindowsUpdates,
|
||||||
|
appXPackages = formattedAppXPackages
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -399,7 +491,7 @@ namespace LD_SysInfo
|
|||||||
writer.WriteLine("Installed Applications:");
|
writer.WriteLine("Installed Applications:");
|
||||||
writer.WriteLine("Name,Version,Publisher");
|
writer.WriteLine("Name,Version,Publisher");
|
||||||
|
|
||||||
var applications = SystemInfo.GetInstalledApplicationsFromRegistry();
|
var applications = sysInfo.InstalledApplications;
|
||||||
foreach (var app in applications)
|
foreach (var app in applications)
|
||||||
{
|
{
|
||||||
writer.WriteLine($"{app.Name},{app.Version},{app.Publisher}");
|
writer.WriteLine($"{app.Name},{app.Version},{app.Publisher}");
|
||||||
@@ -495,7 +587,16 @@ namespace LD_SysInfo
|
|||||||
messageClearTimer.Stop();
|
messageClearTimer.Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void PostTimer_Tick(object sender, EventArgs e)
|
private void OpenOsqueryConsole_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
var console = new OsqueryConsole
|
||||||
|
{
|
||||||
|
Owner = this
|
||||||
|
};
|
||||||
|
console.ShowDialog();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void PostTimer_Tick(object? sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(ApiClient.GetJwtToken())) // Ensure authentication is active
|
if (string.IsNullOrEmpty(ApiClient.GetJwtToken())) // Ensure authentication is active
|
||||||
{
|
{
|
||||||
@@ -505,8 +606,9 @@ namespace LD_SysInfo
|
|||||||
|
|
||||||
var apiClient = new ApiClient(_config); // Create an instance of ApiClient
|
var apiClient = new ApiClient(_config); // Create an instance of ApiClient
|
||||||
|
|
||||||
var sysInfo = SystemInfo.GetSystemInfo();
|
_cachedSystemInfo = SystemInfo.GetSystemInfo();
|
||||||
var applications = SystemInfo.GetInstalledApplicationsFromRegistry();
|
var sysInfo = _cachedSystemInfo;
|
||||||
|
var applications = sysInfo.InstalledApplications;
|
||||||
|
|
||||||
var formattedApplications = new List<object>();
|
var formattedApplications = new List<object>();
|
||||||
foreach (var app in applications)
|
foreach (var app in applications)
|
||||||
@@ -519,6 +621,41 @@ namespace LD_SysInfo
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var formattedUserApplications = new List<object>();
|
||||||
|
foreach (var app in sysInfo.UserInstalledApplications)
|
||||||
|
{
|
||||||
|
formattedUserApplications.Add(new
|
||||||
|
{
|
||||||
|
app_name = app.Name,
|
||||||
|
app_version = app.Version,
|
||||||
|
publisher = app.Publisher
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
var formattedWindowsUpdates = new List<object>();
|
||||||
|
foreach (var update in sysInfo.WindowsUpdates)
|
||||||
|
{
|
||||||
|
formattedWindowsUpdates.Add(new
|
||||||
|
{
|
||||||
|
hotFixID = update.HotFixID,
|
||||||
|
description = update.Description,
|
||||||
|
installedOn = update.InstalledOn,
|
||||||
|
installedBy = update.InstalledBy
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
var formattedAppXPackages = new List<object>();
|
||||||
|
foreach (var pkg in sysInfo.AppXPackages)
|
||||||
|
{
|
||||||
|
formattedAppXPackages.Add(new
|
||||||
|
{
|
||||||
|
name = pkg.Name,
|
||||||
|
version = pkg.Version,
|
||||||
|
publisher = pkg.Publisher,
|
||||||
|
packageFullName = pkg.PackageFullName
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
var payload = new
|
var payload = new
|
||||||
{
|
{
|
||||||
clientIdentifier = _config.ClientIdentifier,
|
clientIdentifier = _config.ClientIdentifier,
|
||||||
@@ -535,7 +672,10 @@ namespace LD_SysInfo
|
|||||||
ipAddresses = sysInfo.IpAddresses,
|
ipAddresses = sysInfo.IpAddresses,
|
||||||
lastBootTime = sysInfo.LastBootTime,
|
lastBootTime = sysInfo.LastBootTime,
|
||||||
drives = sysInfo.Drives,
|
drives = sysInfo.Drives,
|
||||||
installedApplications = formattedApplications
|
installedApplications = formattedApplications,
|
||||||
|
userInstalledApplications = formattedUserApplications,
|
||||||
|
windowsUpdates = formattedWindowsUpdates,
|
||||||
|
appXPackages = formattedAppXPackages
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -562,7 +702,7 @@ namespace LD_SysInfo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void KeepAliveTimer_Tick(object sender, EventArgs e)
|
private async void KeepAliveTimer_Tick(object? sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var apiClient = new ApiClient(_config);
|
var apiClient = new ApiClient(_config);
|
||||||
bool isConnected = await apiClient.CheckConnectivity();
|
bool isConnected = await apiClient.CheckConnectivity();
|
||||||
@@ -585,11 +725,32 @@ namespace LD_SysInfo
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void MessageClearTimer_Tick(object sender, EventArgs e)
|
private void MessageClearTimer_Tick(object? sender, EventArgs e)
|
||||||
{
|
{
|
||||||
FadeOutStatusMessage(); // Trigger the fade-out effect
|
FadeOutStatusMessage(); // Trigger the fade-out effect
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async void TokenRefreshTimer_Tick(object? sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(ApiClient.GetJwtToken()))
|
||||||
|
{
|
||||||
|
Console.WriteLine("⚠️ No token to refresh - skipping proactive refresh.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var apiClient = new ApiClient(_config);
|
||||||
|
bool refreshed = await apiClient.RefreshTokenAsync();
|
||||||
|
|
||||||
|
if (refreshed)
|
||||||
|
{
|
||||||
|
Console.WriteLine("✅ Proactive token refresh successful.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine("⚠️ Proactive token refresh failed - will retry on next request.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void TrayIcon_DoubleClick(object sender, RoutedEventArgs e)
|
private void TrayIcon_DoubleClick(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
ShowWindow();
|
ShowWindow();
|
||||||
@@ -622,5 +783,101 @@ namespace LD_SysInfo
|
|||||||
base.OnStateChanged(e);
|
base.OnStateChanged(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void UpdateSysInfoUI(SystemInfo sysInfo)
|
||||||
|
{
|
||||||
|
if (sysInfo == null) return;
|
||||||
|
|
||||||
|
HostnameTextBlock.Text = $"Hostname: {(string.IsNullOrEmpty(sysInfo.Hostname) ? "N/A" : sysInfo.Hostname)}";
|
||||||
|
OSNameTextBlock.Text = $"OS Name: {(string.IsNullOrEmpty(sysInfo.OSName) ? "N/A" : sysInfo.OSName)}";
|
||||||
|
OSVersionTextBlock.Text = $"OS Version: {(string.IsNullOrEmpty(sysInfo.OSVersion) ? "N/A" : sysInfo.OSVersion)}";
|
||||||
|
WindowsVersionTextBlock.Text = $"Windows Version: {(string.IsNullOrEmpty(sysInfo.WindowsVersion) ? "N/A" : sysInfo.WindowsVersion)}";
|
||||||
|
WindowsBuildTextBlock.Text = $"Windows Build: {(string.IsNullOrEmpty(sysInfo.WindowsBuild) ? "N/A" : sysInfo.WindowsBuild)}";
|
||||||
|
OSArchitectureTextBlock.Text = $"OS Architecture: {(string.IsNullOrEmpty(sysInfo.OSArchitecture) ? "N/A" : sysInfo.OSArchitecture)}";
|
||||||
|
ProcessorNameTextBlock.Text = $"Processor Name: {(string.IsNullOrEmpty(sysInfo.ProcessorName) ? "N/A" : sysInfo.ProcessorName)}";
|
||||||
|
ProcessorArchitectureTextBlock.Text = $"Processor Architecture: {(string.IsNullOrEmpty(sysInfo.ProcessorArchitecture) ? "N/A" : sysInfo.ProcessorArchitecture)}";
|
||||||
|
|
||||||
|
// Memory
|
||||||
|
MemoryTextBlock.Text = $"Total Memory: {(string.IsNullOrEmpty(sysInfo.TotalMemory) ? "N/A" : sysInfo.TotalMemory)}";
|
||||||
|
|
||||||
|
// GPUs (join multiple models)
|
||||||
|
GpuTextBlock.Text = (sysInfo.GpuNames == null || sysInfo.GpuNames.Count == 0)
|
||||||
|
? "GPU(s): N/A"
|
||||||
|
: $"GPU(s): {string.Join(", ", sysInfo.GpuNames)}";
|
||||||
|
|
||||||
|
// IP addresses - format each on its own line for readability
|
||||||
|
if (sysInfo.IpAddresses == null || sysInfo.IpAddresses.Count == 0)
|
||||||
|
{
|
||||||
|
IpTextBlock.Text = "IP Addresses: N/A";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var parts = new List<string>();
|
||||||
|
foreach (var ni in sysInfo.IpAddresses)
|
||||||
|
{
|
||||||
|
var ip = string.IsNullOrEmpty(ni.IpAddress) ? "N/A" : ni.IpAddress;
|
||||||
|
parts.Add($" • {ip}");
|
||||||
|
}
|
||||||
|
IpTextBlock.Text = $"IP Addresses:\n{string.Join("\n", parts)}";
|
||||||
|
}
|
||||||
|
|
||||||
|
// CollectedAt / Last updated
|
||||||
|
CollectedAtTextBlock.Text = !string.IsNullOrEmpty(sysInfo.CollectedAt)
|
||||||
|
? $"Last updated: {sysInfo.CollectedAt}"
|
||||||
|
: $"Last updated: {DateTimeOffset.Now:g}";
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task RefreshSystemInfoAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Show immediate feedback
|
||||||
|
Dispatcher.Invoke(() =>
|
||||||
|
{
|
||||||
|
StatusTextBlock.Text = "Collecting system info...";
|
||||||
|
try { StatusTextBlock.Foreground = (SolidColorBrush)FindResource("StatusConnectedBrush"); } catch { StatusTextBlock.Foreground = new SolidColorBrush(Colors.Black); }
|
||||||
|
});
|
||||||
|
|
||||||
|
// Run osquery work off the UI thread
|
||||||
|
var info = await Task.Run(() => SystemInfo.GetSystemInfo());
|
||||||
|
_cachedSystemInfo = info;
|
||||||
|
|
||||||
|
// Update UI on UI thread
|
||||||
|
Dispatcher.Invoke(() =>
|
||||||
|
{
|
||||||
|
UpdateSysInfoUI(info);
|
||||||
|
CollectedAtTextBlock.Text = !string.IsNullOrEmpty(info.CollectedAt)
|
||||||
|
? $"Last updated: {info.CollectedAt}"
|
||||||
|
: $"Last updated: {DateTimeOffset.Now:g}";
|
||||||
|
|
||||||
|
StatusTextBlock.Text = "✅ System info refreshed";
|
||||||
|
try { StatusTextBlock.Foreground = (SolidColorBrush)FindResource("StatusConnectedBrush"); } catch { StatusTextBlock.Foreground = new SolidColorBrush(Colors.Green); }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Dispatcher.Invoke(() =>
|
||||||
|
{
|
||||||
|
StatusTextBlock.Text = $"❌ Refresh failed: {ex.Message}";
|
||||||
|
StatusTextBlock.Foreground = new SolidColorBrush(Colors.Red);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void RefreshButton_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
// Disable the button while running (UI lookup)
|
||||||
|
if (sender is System.Windows.Controls.Button b)
|
||||||
|
{
|
||||||
|
b.IsEnabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
await RefreshSystemInfoAsync();
|
||||||
|
|
||||||
|
if (sender is System.Windows.Controls.Button b2)
|
||||||
|
{
|
||||||
|
b2.IsEnabled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
50
LD-SysInfo/OsqueryConsole.xaml
Normal file
50
LD-SysInfo/OsqueryConsole.xaml
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
<Window x:Class="LD_SysInfo.OsqueryConsole"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
Title="Osquery Console" Height="600" Width="800"
|
||||||
|
Background="#1e1e1e" Foreground="White"
|
||||||
|
WindowStartupLocation="CenterOwner">
|
||||||
|
|
||||||
|
<Grid Margin="10">
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
<RowDefinition Height="*"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
|
<TextBlock Text="Enter Osquery SQL:" FontWeight="Bold" Margin="0,0,0,4"/>
|
||||||
|
<TextBox x:Name="QueryBox"
|
||||||
|
Grid.Row="1"
|
||||||
|
Height="60"
|
||||||
|
TextWrapping="Wrap"
|
||||||
|
VerticalScrollBarVisibility="Auto"
|
||||||
|
Background="#252526"
|
||||||
|
Foreground="White"
|
||||||
|
FontFamily="Consolas"
|
||||||
|
FontSize="14"
|
||||||
|
AcceptsReturn="True"
|
||||||
|
Text="SELECT * FROM system_info;" />
|
||||||
|
|
||||||
|
<Button Grid.Row="1"
|
||||||
|
Content="Run Query"
|
||||||
|
HorizontalAlignment="Right"
|
||||||
|
VerticalAlignment="Top"
|
||||||
|
Width="120"
|
||||||
|
Margin="0,4,0,0"
|
||||||
|
Click="RunQuery_Click"/>
|
||||||
|
|
||||||
|
<TextBox x:Name="OutputBox"
|
||||||
|
Grid.Row="2"
|
||||||
|
Margin="0,10,0,0"
|
||||||
|
TextWrapping="Wrap"
|
||||||
|
VerticalScrollBarVisibility="Auto"
|
||||||
|
HorizontalScrollBarVisibility="Auto"
|
||||||
|
Background="#1e1e1e"
|
||||||
|
Foreground="#dcdcdc"
|
||||||
|
FontFamily="Consolas"
|
||||||
|
FontSize="13"
|
||||||
|
AcceptsReturn="True"
|
||||||
|
IsReadOnly="True"
|
||||||
|
Text="Results will appear here..." />
|
||||||
|
</Grid>
|
||||||
|
</Window>
|
||||||
37
LD-SysInfo/OsqueryConsole.xaml.cs
Normal file
37
LD-SysInfo/OsqueryConsole.xaml.cs
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
using System;
|
||||||
|
using System.Text.Json;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows;
|
||||||
|
|
||||||
|
using LD_SysInfo.Services;
|
||||||
|
|
||||||
|
namespace LD_SysInfo
|
||||||
|
{
|
||||||
|
public partial class OsqueryConsole : Window
|
||||||
|
{
|
||||||
|
public OsqueryConsole()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void RunQuery_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
OutputBox.Text = "Running query...";
|
||||||
|
string sql = QueryBox.Text.Trim();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var result = await Task.Run(() => OsqueryService.Query(sql));
|
||||||
|
|
||||||
|
string prettyJson = JsonSerializer.Serialize(result,
|
||||||
|
new JsonSerializerOptions { WriteIndented = true });
|
||||||
|
|
||||||
|
OutputBox.Text = prettyJson;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
OutputBox.Text = $"❌ Error running query:\n{ex}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -177,7 +177,54 @@ namespace LD_SysInfo.Services
|
|||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sends the collected data to the server.
|
/// Refreshes the current JWT token without requiring username/password.
|
||||||
|
/// </summary>
|
||||||
|
public async Task<bool> RefreshTokenAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(jwtToken))
|
||||||
|
{
|
||||||
|
Console.WriteLine("⚠️ No token to refresh.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
HttpResponseMessage response = await httpClient.PostAsync(BuildUrl("/api/auth/refresh"), null);
|
||||||
|
string rawResponse = await response.Content.ReadAsStringAsync();
|
||||||
|
|
||||||
|
if (!response.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"❌ Token refresh failed: {response.StatusCode} - {rawResponse}");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parse the response to get the new token if provided in body
|
||||||
|
// Note: Your server sets it via cookie, but may also return it in response
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var refreshResponse = JsonConvert.DeserializeObject<Dictionary<string, string>>(rawResponse);
|
||||||
|
if (refreshResponse?.ContainsKey("token") == true)
|
||||||
|
{
|
||||||
|
SetJwtToken(refreshResponse["token"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// Token might only be in cookie, which is fine
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine("✅ Token refreshed successfully.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"❌ Exception during token refresh: {ex.Message}");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sends the collected data to the server with automatic token refresh and re-auth.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private async Task<HttpResponseMessage> SendWithAutoReauthAsync(Func<Task<HttpResponseMessage>> requestFunc)
|
private async Task<HttpResponseMessage> SendWithAutoReauthAsync(Func<Task<HttpResponseMessage>> requestFunc)
|
||||||
{
|
{
|
||||||
@@ -185,8 +232,24 @@ namespace LD_SysInfo.Services
|
|||||||
|
|
||||||
if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized)
|
if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized)
|
||||||
{
|
{
|
||||||
Console.WriteLine("⚠️ Token expired or invalid. Attempting re-auth...");
|
Console.WriteLine("⚠️ Token expired or invalid. Attempting token refresh...");
|
||||||
|
|
||||||
|
// Try refreshing the token first (faster than full re-auth)
|
||||||
|
bool refreshed = await RefreshTokenAsync();
|
||||||
|
|
||||||
|
if (refreshed)
|
||||||
|
{
|
||||||
|
// Retry original request after refresh
|
||||||
|
response = await requestFunc();
|
||||||
|
|
||||||
|
if (response.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If refresh failed or didn't work, fall back to full re-authentication
|
||||||
|
Console.WriteLine("⚠️ Token refresh failed. Attempting full re-auth...");
|
||||||
var loginResponse = await AuthenticateAsync(_config.Auth.Username, _config.Auth.Password);
|
var loginResponse = await AuthenticateAsync(_config.Auth.Username, _config.Auth.Password);
|
||||||
if (loginResponse == null || string.IsNullOrEmpty(loginResponse.Token))
|
if (loginResponse == null || string.IsNullOrEmpty(loginResponse.Token))
|
||||||
{
|
{
|
||||||
|
|||||||
78
LD-SysInfo/Services/OsqueryService.cs
Normal file
78
LD-SysInfo/Services/OsqueryService.cs
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
|
namespace LD_SysInfo.Services
|
||||||
|
{
|
||||||
|
public static class OsqueryService
|
||||||
|
{
|
||||||
|
private static string GetOsqueryPath()
|
||||||
|
{
|
||||||
|
var baseDir = AppContext.BaseDirectory;
|
||||||
|
var path = Path.Combine(baseDir, "Assets", "osqueryi.exe");
|
||||||
|
|
||||||
|
if (!File.Exists(path))
|
||||||
|
{
|
||||||
|
File.AppendAllText("osquery_error.log", $"[{DateTime.Now}] ❌ osqueryi.exe not found at {path}\n");
|
||||||
|
throw new FileNotFoundException("osqueryi.exe not found", path);
|
||||||
|
}
|
||||||
|
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string RunQuery(string sql)
|
||||||
|
{
|
||||||
|
var processInfo = new ProcessStartInfo
|
||||||
|
{
|
||||||
|
FileName = GetOsqueryPath(),
|
||||||
|
Arguments = $"--json \"{sql}\"",
|
||||||
|
RedirectStandardOutput = true,
|
||||||
|
UseShellExecute = false,
|
||||||
|
CreateNoWindow = true
|
||||||
|
};
|
||||||
|
|
||||||
|
using var process = Process.Start(processInfo); // ✅ FIXED — actually start the process
|
||||||
|
if (process == null)
|
||||||
|
throw new Exception("Failed to start osquery process");
|
||||||
|
|
||||||
|
string output = process.StandardOutput.ReadToEnd();
|
||||||
|
process.WaitForExit();
|
||||||
|
|
||||||
|
// Optional debug logging
|
||||||
|
File.AppendAllText("osquery_debug.log",
|
||||||
|
$"[{DateTime.Now}] Ran query: {sql}\nOutput length: {output.Length}\n");
|
||||||
|
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<Dictionary<string, string>> Query(string sql)
|
||||||
|
{
|
||||||
|
string json = RunQuery(sql);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var jArray = JArray.Parse(json);
|
||||||
|
var results = new List<Dictionary<string, string>>();
|
||||||
|
|
||||||
|
foreach (var obj in jArray)
|
||||||
|
{
|
||||||
|
var dict = new Dictionary<string, string>();
|
||||||
|
foreach (var prop in (JObject)obj)
|
||||||
|
dict[prop.Key] = prop.Value?.ToString() ?? "";
|
||||||
|
results.Add(dict);
|
||||||
|
}
|
||||||
|
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
File.AppendAllText("osquery_error.log",
|
||||||
|
$"[{DateTime.Now}] ⚠️ JSON parse failed for query '{sql}': {ex.Message}\n");
|
||||||
|
return new List<Dictionary<string, string>>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,345 +1,228 @@
|
|||||||
using Microsoft.Win32;
|
#nullable disable
|
||||||
using System.IO;
|
|
||||||
using System.Management;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Net.NetworkInformation;
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System.Windows;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
using LD_SysInfo.Services;
|
||||||
|
|
||||||
namespace LD_SysInfo
|
namespace LD_SysInfo
|
||||||
{
|
{
|
||||||
public class AppConfig
|
// Extension method for safe dictionary access
|
||||||
|
public static class DictionaryExtensions
|
||||||
{
|
{
|
||||||
[JsonProperty("ServerUrl")]
|
public static string GetValueOrDefault(this Dictionary<string, string> dict, string key)
|
||||||
public string ServerUrl { get; set; } = "https://yourserver.com/api/status";
|
|
||||||
|
|
||||||
[JsonProperty("EnableLogging")]
|
|
||||||
public bool EnableLogging { get; set; } = true;
|
|
||||||
|
|
||||||
[JsonProperty("KeepAlivePeriod")]
|
|
||||||
public int KeepAlivePeriod { get; set; } = 30; // Ping/heartbeat every 30 seconds
|
|
||||||
|
|
||||||
[JsonProperty("SystemInfoInterval")]
|
|
||||||
public int SystemInfoInterval { get; set; } = 60; // Full system info POST every 60 seconds
|
|
||||||
|
|
||||||
[JsonProperty("ClientIdentifier")]
|
|
||||||
public string ClientIdentifier { get; set; } = "your-default-client-id";
|
|
||||||
|
|
||||||
[JsonProperty("Auth")]
|
|
||||||
public AuthConfig Auth { get; set; } = new AuthConfig();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public class AuthConfig
|
|
||||||
{
|
{
|
||||||
[JsonProperty("Username")]
|
return dict.ContainsKey(key) ? dict[key] : "";
|
||||||
public string Username { get; set; } = "testuser";
|
|
||||||
|
|
||||||
[JsonProperty("Password")]
|
|
||||||
public string Password { get; set; } = "testpassword";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static class ConfigManager
|
|
||||||
{
|
|
||||||
private static readonly string ConfigPath =
|
|
||||||
Path.Combine(AppContext.BaseDirectory, "config.json");
|
|
||||||
|
|
||||||
public static AppConfig LoadConfig(string configPath)
|
|
||||||
{
|
|
||||||
//System.Windows.MessageBox.Show($"[DEBUG] Calling LoadConfig from:\n{ConfigPath}");
|
|
||||||
|
|
||||||
if (File.Exists(ConfigPath))
|
|
||||||
{
|
|
||||||
string json = File.ReadAllText(ConfigPath);
|
|
||||||
return JsonConvert.DeserializeObject<AppConfig>(json);
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new FileNotFoundException("❌ Config file not found at:\n" + ConfigPath);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public class InstalledApplication
|
public class InstalledApplication
|
||||||
{
|
{
|
||||||
public string Name { get; set; }
|
[JsonProperty("name")] public string Name { get; set; }
|
||||||
public string Version { get; set; }
|
[JsonProperty("version")] public string Version { get; set; }
|
||||||
public string Publisher { get; set; }
|
[JsonProperty("publisher")] public string Publisher { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class WindowsUpdate
|
||||||
|
{
|
||||||
|
[JsonProperty("hotFixID")] public string HotFixID { get; set; }
|
||||||
|
[JsonProperty("description")] public string Description { get; set; }
|
||||||
|
[JsonProperty("installedOn")] public string InstalledOn { get; set; }
|
||||||
|
[JsonProperty("installedBy")] public string InstalledBy { get; set; } // 🔹 added back for compatibility
|
||||||
|
}
|
||||||
|
|
||||||
|
public class AppXPackage
|
||||||
|
{
|
||||||
|
[JsonProperty("name")] public string Name { get; set; }
|
||||||
|
[JsonProperty("version")] public string Version { get; set; }
|
||||||
|
[JsonProperty("publisher")] public string Publisher { get; set; }
|
||||||
|
[JsonProperty("packageFullName")] public string PackageFullName { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class DriveInfoSummary
|
public class DriveInfoSummary
|
||||||
{
|
{
|
||||||
[JsonProperty("name")]
|
[JsonProperty("name")] public string Name { get; set; }
|
||||||
public string Name { get; set; }
|
[JsonProperty("totalSizeGB")] public double TotalSizeGB { get; set; }
|
||||||
|
[JsonProperty("freeSpaceGB")] public double FreeSpaceGB { get; set; }
|
||||||
[JsonProperty("totalSizeGB")]
|
[JsonProperty("driveType")] public string DriveType { get; set; }
|
||||||
public double TotalSizeGB { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("freeSpaceGB")]
|
|
||||||
public double FreeSpaceGB { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("driveType")]
|
|
||||||
public string DriveType { get; set; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class NetworkInterfaceInfo
|
public class NetworkInterfaceInfo
|
||||||
{
|
{
|
||||||
[JsonProperty("interfaceName")]
|
[JsonProperty("interfaceName")] public string InterfaceName { get; set; }
|
||||||
public string InterfaceName { get; set; }
|
[JsonProperty("ipAddress")] public string IpAddress { get; set; }
|
||||||
|
[JsonProperty("macAddress")] public string MacAddress { get; set; }
|
||||||
[JsonProperty("ipAddress")]
|
|
||||||
public string IpAddress { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("macAddress")]
|
|
||||||
public string MacAddress { get; set; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public class SystemInfo
|
public class SystemInfo
|
||||||
{
|
{
|
||||||
[JsonProperty("osName")]
|
[JsonProperty("hostname")] public string Hostname { get; set; }
|
||||||
public string OSName { get; set; }
|
[JsonProperty("osName")] public string OSName { get; set; }
|
||||||
|
[JsonProperty("osVersion")] public string OSVersion { get; set; }
|
||||||
|
[JsonProperty("windowsVersion")] public string WindowsVersion { get; set; }
|
||||||
|
[JsonProperty("windowsBuild")] public string WindowsBuild { get; set; }
|
||||||
|
[JsonProperty("osArchitecture")] public string OSArchitecture { get; set; }
|
||||||
|
[JsonProperty("processorName")] public string ProcessorName { get; set; }
|
||||||
|
[JsonProperty("processorArchitecture")] public string ProcessorArchitecture { get; set; }
|
||||||
|
[JsonProperty("gpuNames")] public List<string> GpuNames { get; set; } = new();
|
||||||
|
[JsonProperty("totalMemory")] public string TotalMemory { get; set; }
|
||||||
|
[JsonProperty("ipAddresses")] public List<NetworkInterfaceInfo> IpAddresses { get; set; } = new();
|
||||||
|
[JsonProperty("lastBootTime")] public string LastBootTime { get; set; }
|
||||||
|
[JsonProperty("collectedAt")] public string CollectedAt { get; set; }
|
||||||
|
|
||||||
[JsonProperty("osVersion")]
|
[JsonProperty("installedApplications")] public List<InstalledApplication> InstalledApplications { get; set; } = new();
|
||||||
public string OSVersion { get; set; }
|
[JsonProperty("userInstalledApplications")] public List<InstalledApplication> UserInstalledApplications { get; set; } = new();
|
||||||
|
[JsonProperty("windowsUpdates")] public List<WindowsUpdate> WindowsUpdates { get; set; } = new();
|
||||||
[JsonProperty("windowsVersion")]
|
[JsonProperty("appXPackages")] public List<AppXPackage> AppXPackages { get; set; } = new();
|
||||||
public string WindowsVersion { get; set; }
|
[JsonProperty("drives")] public List<DriveInfoSummary> Drives { get; set; } = new();
|
||||||
|
|
||||||
[JsonProperty("windowsBuild")]
|
|
||||||
public string WindowsBuild { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("osArchitecture")]
|
|
||||||
public string OSArchitecture { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("processorName")]
|
|
||||||
public string ProcessorName { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("processorArchitecture")]
|
|
||||||
public string ProcessorArchitecture { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("hostname")]
|
|
||||||
public string Hostname { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("gpuNames")]
|
|
||||||
public List<string> GpuNames { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("totalMemory")]
|
|
||||||
public string TotalMemory { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("ipAddresses")]
|
|
||||||
public List<NetworkInterfaceInfo> IpAddresses { get; set; } = new();
|
|
||||||
|
|
||||||
[JsonProperty("lastBootTime")]
|
|
||||||
public string LastBootTime { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("installedApplications")]
|
|
||||||
public List<InstalledApplication> InstalledApplications { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("drives")]
|
|
||||||
public List<DriveInfoSummary> Drives { get; set; } = new();
|
|
||||||
|
|
||||||
|
|
||||||
private const string WindowsCurrentVersionKey = @"SOFTWARE\Microsoft\Windows NT\CurrentVersion";
|
|
||||||
|
|
||||||
public static SystemInfo GetSystemInfo()
|
public static SystemInfo GetSystemInfo()
|
||||||
{
|
{
|
||||||
var sysInfo = new SystemInfo();
|
var info = new SystemInfo { CollectedAt = DateTime.Now.ToString("MMM dd, yyyy h:mm tt") };
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
sysInfo.Hostname = Environment.MachineName;
|
// ✅ Base system info - using correct osquery column names
|
||||||
sysInfo.OSName = GetOSFriendlyName();
|
var sys = OsqueryService.Query("SELECT * FROM system_info;").FirstOrDefault();
|
||||||
sysInfo.OSVersion = Environment.OSVersion.Version.ToString();
|
if (sys != null)
|
||||||
sysInfo.WindowsVersion = GetRegistryValue(WindowsCurrentVersionKey, "DisplayVersion");
|
{
|
||||||
sysInfo.WindowsBuild = GetRegistryValue(WindowsCurrentVersionKey, "CurrentBuild");
|
info.Hostname = sys.GetValueOrDefault("hostname");
|
||||||
sysInfo.OSArchitecture = Environment.Is64BitOperatingSystem ? "x64" : "x86";
|
// OSName removed - was redundant with hostname
|
||||||
sysInfo.ProcessorName = GetProcessorName();
|
|
||||||
sysInfo.ProcessorArchitecture = Environment.Is64BitProcess ? "x64" : "x86";
|
// Windows version info from os_version table
|
||||||
sysInfo.GpuNames = GetGpuNames();
|
var osVer = OsqueryService.Query("SELECT * FROM os_version;").FirstOrDefault();
|
||||||
sysInfo.TotalMemory = GetTotalMemory();
|
if (osVer != null)
|
||||||
var allInterfaces = GetNetworkInterfaces();
|
{
|
||||||
sysInfo.IpAddresses = allInterfaces
|
info.OSVersion = osVer.GetValueOrDefault("version");
|
||||||
.Where(i => !string.IsNullOrWhiteSpace(i.InterfaceName))
|
info.WindowsVersion = osVer.GetValueOrDefault("name");
|
||||||
|
info.WindowsBuild = osVer.GetValueOrDefault("build");
|
||||||
|
|
||||||
|
// Get proper OS name from os_version
|
||||||
|
info.OSName = osVer.GetValueOrDefault("name"); // e.g., "Windows 10 Pro"
|
||||||
|
}
|
||||||
|
|
||||||
|
info.ProcessorName = sys.GetValueOrDefault("cpu_brand");
|
||||||
|
info.ProcessorArchitecture = sys.GetValueOrDefault("cpu_type");
|
||||||
|
|
||||||
|
// Fix OS Architecture - should be x64, x86, etc.
|
||||||
|
info.OSArchitecture = sys.GetValueOrDefault("cpu_subtype");
|
||||||
|
if (string.IsNullOrEmpty(info.OSArchitecture) || info.OSArchitecture == "-1")
|
||||||
|
{
|
||||||
|
// Fallback: determine from cpu_type or use platform info
|
||||||
|
var platform = sys.GetValueOrDefault("cpu_type");
|
||||||
|
info.OSArchitecture = platform.Contains("64") ? "x64" : "x86";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ✅ Memory - query physical_memory table and sum up total
|
||||||
|
var memResults = OsqueryService.Query("SELECT SUM(size) as total_bytes FROM physical_memory;").FirstOrDefault();
|
||||||
|
if (memResults != null && memResults.ContainsKey("total_bytes"))
|
||||||
|
{
|
||||||
|
if (long.TryParse(memResults["total_bytes"], out long memBytes))
|
||||||
|
{
|
||||||
|
double memGB = Math.Round(memBytes / (1024.0 * 1024.0 * 1024.0), 2);
|
||||||
|
info.TotalMemory = $"{memGB} GB";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fallback: try WMI-based system_info table
|
||||||
|
if (string.IsNullOrEmpty(info.TotalMemory))
|
||||||
|
{
|
||||||
|
var sysInfo = OsqueryService.Query("SELECT physical_memory FROM system_info;").FirstOrDefault();
|
||||||
|
if (sysInfo != null && sysInfo.ContainsKey("physical_memory"))
|
||||||
|
{
|
||||||
|
if (long.TryParse(sysInfo["physical_memory"], out long memBytes))
|
||||||
|
{
|
||||||
|
double memGB = Math.Round(memBytes / (1024.0 * 1024.0 * 1024.0), 2);
|
||||||
|
info.TotalMemory = $"{memGB} GB";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ✅ Drives
|
||||||
|
info.Drives = OsqueryService.Query("SELECT device, size, free_space, type FROM logical_drives;")
|
||||||
|
.Select(d => new DriveInfoSummary
|
||||||
|
{
|
||||||
|
Name = d.GetValueOrDefault("device"),
|
||||||
|
TotalSizeGB = d.ContainsKey("size") && double.TryParse(d["size"], out double size)
|
||||||
|
? Math.Round(size / (1024.0 * 1024.0 * 1024.0), 2) : 0,
|
||||||
|
FreeSpaceGB = d.ContainsKey("free_space") && double.TryParse(d["free_space"], out double free)
|
||||||
|
? Math.Round(free / (1024.0 * 1024.0 * 1024.0), 2) : 0,
|
||||||
|
DriveType = d.GetValueOrDefault("type")
|
||||||
|
}).ToList();
|
||||||
|
|
||||||
|
// ✅ GPU info - query registry for all GPUs
|
||||||
|
var gpuQuery = OsqueryService.Query(@"
|
||||||
|
SELECT data
|
||||||
|
FROM registry
|
||||||
|
WHERE path LIKE 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4d36e968-e325-11ce-bfc1-08002be10318}\%\DriverDesc';");
|
||||||
|
|
||||||
|
info.GpuNames = gpuQuery
|
||||||
|
.Select(g => g.GetValueOrDefault("data"))
|
||||||
|
.Where(s => !string.IsNullOrEmpty(s))
|
||||||
|
.Distinct() // Remove duplicates
|
||||||
.ToList();
|
.ToList();
|
||||||
sysInfo.LastBootTime = GetLastBootTime();
|
|
||||||
|
|
||||||
PopulateDriveInfo(sysInfo);
|
// ✅ Network interfaces - IPv4 only, with better formatting
|
||||||
|
var ipResults = OsqueryService.Query(
|
||||||
|
"SELECT interface, address FROM interface_addresses WHERE address NOT LIKE '127.%' AND address NOT LIKE '%:%';");
|
||||||
|
|
||||||
|
info.IpAddresses = ipResults
|
||||||
|
.Select(i => new NetworkInterfaceInfo
|
||||||
|
{
|
||||||
|
InterfaceName = i.GetValueOrDefault("interface"),
|
||||||
|
IpAddress = i.GetValueOrDefault("address"),
|
||||||
|
MacAddress = ""
|
||||||
|
})
|
||||||
|
.Where(ni => !string.IsNullOrEmpty(ni.IpAddress))
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
// ✅ Last boot time
|
||||||
|
info.LastBootTime = OsqueryService.Query("SELECT datetime(boot_time, 'unixepoch') AS last_boot FROM uptime;")
|
||||||
|
.FirstOrDefault()?.GetValueOrDefault("last_boot");
|
||||||
|
|
||||||
|
// ✅ Installed apps (user + system)
|
||||||
|
info.InstalledApplications = OsqueryService.Query("SELECT name, version, publisher FROM programs;")
|
||||||
|
.Select(a => new InstalledApplication
|
||||||
|
{
|
||||||
|
Name = a["name"],
|
||||||
|
Version = a["version"],
|
||||||
|
Publisher = a["publisher"]
|
||||||
|
}).ToList();
|
||||||
|
|
||||||
|
info.UserInstalledApplications = info.InstalledApplications
|
||||||
|
.Where(a => !string.IsNullOrEmpty(a.Publisher))
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
// ✅ AppX packages (Windows Store)
|
||||||
|
info.AppXPackages = OsqueryService.Query("SELECT name, version, publisher, package_id FROM appx_packages;")
|
||||||
|
.Select(p => new AppXPackage
|
||||||
|
{
|
||||||
|
Name = p["name"],
|
||||||
|
Version = p["version"],
|
||||||
|
Publisher = p["publisher"],
|
||||||
|
PackageFullName = p["package_id"]
|
||||||
|
}).ToList();
|
||||||
|
|
||||||
|
// ✅ Windows Updates (patches)
|
||||||
|
info.WindowsUpdates = OsqueryService.Query("SELECT hotfix_id, description, installed_on FROM patches;")
|
||||||
|
.Select(p => new WindowsUpdate
|
||||||
|
{
|
||||||
|
HotFixID = p["hotfix_id"],
|
||||||
|
Description = p["description"],
|
||||||
|
InstalledOn = p["installed_on"],
|
||||||
|
InstalledBy = Environment.UserName
|
||||||
|
}).ToList();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
string logPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "LD_SysInfo", "SysInfo_ErrorLog.txt");
|
File.AppendAllText("osquery_error.log", $"[{DateTime.Now}] {ex}\n");
|
||||||
Directory.CreateDirectory(Path.GetDirectoryName(logPath));
|
|
||||||
File.AppendAllText(logPath, $"[{DateTime.Now}] ERROR: {ex.Message}\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return sysInfo;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void PopulateDriveInfo(SystemInfo info)
|
|
||||||
{
|
|
||||||
foreach (var drive in DriveInfo.GetDrives())
|
|
||||||
{
|
|
||||||
if (!drive.IsReady) continue;
|
|
||||||
|
|
||||||
info.Drives.Add(new DriveInfoSummary
|
|
||||||
{
|
|
||||||
Name = drive.Name,
|
|
||||||
TotalSizeGB = Math.Round(drive.TotalSize / (1024.0 * 1024 * 1024), 2),
|
|
||||||
FreeSpaceGB = Math.Round(drive.AvailableFreeSpace / (1024.0 * 1024 * 1024), 2),
|
|
||||||
DriveType = drive.DriveType.ToString()
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static string GetRegistryValue(string key, string valueName)
|
|
||||||
{
|
|
||||||
using RegistryKey rk = Registry.LocalMachine.OpenSubKey(key);
|
|
||||||
return rk?.GetValue(valueName)?.ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static string GetOSFriendlyName()
|
|
||||||
{
|
|
||||||
string productName = GetRegistryValue(WindowsCurrentVersionKey, "ProductName");
|
|
||||||
string build = GetRegistryValue(WindowsCurrentVersionKey, "CurrentBuild");
|
|
||||||
|
|
||||||
if (int.TryParse(build, out int buildNumber) && buildNumber >= 22000)
|
|
||||||
return "Windows 11 Pro";
|
|
||||||
|
|
||||||
return productName ?? "Unknown OS";
|
|
||||||
}
|
|
||||||
|
|
||||||
private static string GetProcessorName()
|
|
||||||
{
|
|
||||||
const string key = @"HARDWARE\DESCRIPTION\System\CentralProcessor\0";
|
|
||||||
return GetRegistryValue(key, "ProcessorNameString");
|
|
||||||
}
|
|
||||||
|
|
||||||
private static List<string> GetGpuNames()
|
|
||||||
{
|
|
||||||
var gpuNames = new List<string>();
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var searcher = new ManagementObjectSearcher("SELECT Name FROM Win32_VideoController");
|
|
||||||
|
|
||||||
foreach (var obj in searcher.Get())
|
|
||||||
{
|
|
||||||
string name = obj["Name"]?.ToString();
|
|
||||||
if (!string.IsNullOrEmpty(name))
|
|
||||||
{
|
|
||||||
gpuNames.Add(name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
gpuNames.Add($"Error: {ex.Message}");
|
|
||||||
}
|
|
||||||
|
|
||||||
return gpuNames;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private static string GetTotalMemory()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var searcher = new ManagementObjectSearcher("SELECT TotalPhysicalMemory FROM Win32_ComputerSystem");
|
|
||||||
foreach (var obj in searcher.Get())
|
|
||||||
{
|
|
||||||
long bytes = Convert.ToInt64(obj["TotalPhysicalMemory"]);
|
|
||||||
return $"{bytes / (1024 * 1024)} MB";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch { }
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static List<NetworkInterfaceInfo> GetNetworkInterfaces()
|
|
||||||
{
|
|
||||||
var interfaces = new List<NetworkInterfaceInfo>();
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
foreach (var adapter in NetworkInterface.GetAllNetworkInterfaces())
|
|
||||||
{
|
|
||||||
if (adapter.OperationalStatus != OperationalStatus.Up) continue;
|
|
||||||
|
|
||||||
var ip = adapter.GetIPProperties().UnicastAddresses
|
|
||||||
.FirstOrDefault(a => a.Address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork);
|
|
||||||
|
|
||||||
var mac = adapter.GetPhysicalAddress();
|
|
||||||
var macAddress = mac?.GetAddressBytes().Length > 0
|
|
||||||
? string.Join(":", mac.GetAddressBytes().Select(b => b.ToString("X2")))
|
|
||||||
: null;
|
|
||||||
|
|
||||||
if (ip != null || macAddress != null)
|
|
||||||
{
|
|
||||||
interfaces.Add(new NetworkInterfaceInfo
|
|
||||||
{
|
|
||||||
InterfaceName = adapter.Name,
|
|
||||||
IpAddress = ip?.Address.ToString(),
|
|
||||||
MacAddress = macAddress
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Console.WriteLine($"❌ Failed to gather network interfaces: {ex.Message}");
|
|
||||||
}
|
|
||||||
|
|
||||||
return interfaces;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private static string GetLastBootTime()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var searcher = new ManagementObjectSearcher("SELECT LastBootUpTime FROM Win32_OperatingSystem WHERE Primary='true'");
|
|
||||||
foreach (var obj in searcher.Get())
|
|
||||||
{
|
|
||||||
string lastBoot = obj["LastBootUpTime"]?.ToString();
|
|
||||||
return ManagementDateTimeConverter.ToDateTime(lastBoot).ToString("o");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch { }
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<InstalledApplication> GetInstalledApplicationsFromRegistry()
|
|
||||||
{
|
|
||||||
var applications = new List<InstalledApplication>();
|
|
||||||
string[] registryKeys = {
|
|
||||||
@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall",
|
|
||||||
@"SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall"
|
|
||||||
};
|
|
||||||
|
|
||||||
foreach (string key in registryKeys)
|
|
||||||
{
|
|
||||||
using var regKey = Registry.LocalMachine.OpenSubKey(key);
|
|
||||||
if (regKey == null) continue;
|
|
||||||
|
|
||||||
foreach (string subKeyName in regKey.GetSubKeyNames())
|
|
||||||
{
|
|
||||||
using var subKey = regKey.OpenSubKey(subKeyName);
|
|
||||||
string name = subKey?.GetValue("DisplayName")?.ToString();
|
|
||||||
if (!string.IsNullOrWhiteSpace(name))
|
|
||||||
{
|
|
||||||
applications.Add(new InstalledApplication
|
|
||||||
{
|
|
||||||
Name = name,
|
|
||||||
Version = subKey?.GetValue("DisplayVersion")?.ToString(),
|
|
||||||
Publisher = subKey?.GetValue("Publisher")?.ToString()
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return applications;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"ServerUrl": "https://sys.psg.net.au:8443",
|
"ServerUrl": "https://sys.psg.net.au:11443",
|
||||||
"EnableLogging": true,
|
"EnableLogging": true,
|
||||||
"KeepAlivePeriod": 30,
|
"KeepAlivePeriod": 30,
|
||||||
"SystemInfoInterval": 600,
|
"SystemInfoInterval": 600,
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LD_SysInfo", "LD-SysInfo\LD
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{B7DD6F7E-DEF8-4E67-B5B7-07EF123DB6F0}") = "OversightInstaller", "OversightInstaller\OversightInstaller.wixproj", "{99BFBED9-D563-375C-FBD6-E11D0770B009}"
|
Project("{B7DD6F7E-DEF8-4E67-B5B7-07EF123DB6F0}") = "OversightInstaller", "OversightInstaller\OversightInstaller.wixproj", "{99BFBED9-D563-375C-FBD6-E11D0770B009}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OversightService", "OversightService\OversightService.csproj", "{A8149609-CF69-4268-B985-B68444319344}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@@ -72,6 +74,22 @@ Global
|
|||||||
{99BFBED9-D563-375C-FBD6-E11D0770B009}.Release|x64.Build.0 = Release|x64
|
{99BFBED9-D563-375C-FBD6-E11D0770B009}.Release|x64.Build.0 = Release|x64
|
||||||
{99BFBED9-D563-375C-FBD6-E11D0770B009}.Release|x86.ActiveCfg = Release|x86
|
{99BFBED9-D563-375C-FBD6-E11D0770B009}.Release|x86.ActiveCfg = Release|x86
|
||||||
{99BFBED9-D563-375C-FBD6-E11D0770B009}.Release|x86.Build.0 = Release|x86
|
{99BFBED9-D563-375C-FBD6-E11D0770B009}.Release|x86.Build.0 = Release|x86
|
||||||
|
{A8149609-CF69-4268-B985-B68444319344}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{A8149609-CF69-4268-B985-B68444319344}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{A8149609-CF69-4268-B985-B68444319344}.Debug|ARM64.ActiveCfg = Debug|Any CPU
|
||||||
|
{A8149609-CF69-4268-B985-B68444319344}.Debug|ARM64.Build.0 = Debug|Any CPU
|
||||||
|
{A8149609-CF69-4268-B985-B68444319344}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||||
|
{A8149609-CF69-4268-B985-B68444319344}.Debug|x64.Build.0 = Debug|Any CPU
|
||||||
|
{A8149609-CF69-4268-B985-B68444319344}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
|
{A8149609-CF69-4268-B985-B68444319344}.Debug|x86.Build.0 = Debug|Any CPU
|
||||||
|
{A8149609-CF69-4268-B985-B68444319344}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{A8149609-CF69-4268-B985-B68444319344}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{A8149609-CF69-4268-B985-B68444319344}.Release|ARM64.ActiveCfg = Release|Any CPU
|
||||||
|
{A8149609-CF69-4268-B985-B68444319344}.Release|ARM64.Build.0 = Release|Any CPU
|
||||||
|
{A8149609-CF69-4268-B985-B68444319344}.Release|x64.ActiveCfg = Release|Any CPU
|
||||||
|
{A8149609-CF69-4268-B985-B68444319344}.Release|x64.Build.0 = Release|Any CPU
|
||||||
|
{A8149609-CF69-4268-B985-B68444319344}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
|
{A8149609-CF69-4268-B985-B68444319344}.Release|x86.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|||||||
@@ -1,34 +1,56 @@
|
|||||||
<Project Sdk="WixToolset.Sdk/6.0.0">
|
<Project Sdk="WixToolset.Sdk/6.0.0">
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="WixToolset.UI.wixext" />
|
<!-- ✅ Defaults -->
|
||||||
</ItemGroup>
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<!-- Force embedding files into the MSI (no external .cab file) -->
|
<Version>0.0.0</Version>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
<InstallerPlatform>x64</InstallerPlatform>
|
||||||
<EmbedCab>true</EmbedCab>
|
<EmbedCab>true</EmbedCab>
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup>
|
|
||||||
<WixExtensionInclude>WixToolset.UI.wixext</WixExtensionInclude>
|
<WixExtensionInclude>WixToolset.UI.wixext</WixExtensionInclude>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
|
||||||
<DefineConstants>PublishDir=C:\Users\Sonder\source\repos\psg-oversight-app\PublishDir</DefineConstants>
|
<!-- ✅ STEP 1: Run Git BEFORE WiX compilation -->
|
||||||
|
<Target Name="SetVersionFromGit" BeforeTargets="BeforeBuild">
|
||||||
|
<Exec Command="git describe --tags --abbrev=0" ConsoleToMSBuild="true" IgnoreExitCode="true">
|
||||||
|
<Output TaskParameter="ConsoleOutput" PropertyName="GitTag" />
|
||||||
|
</Exec>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$(GitTag)' != ''">
|
||||||
|
<GitTagTrimmed>$([System.Text.RegularExpressions.Regex]::Replace('$(GitTag)', '\s', ''))</GitTagTrimmed>
|
||||||
|
<GitVersion>$([System.Text.RegularExpressions.Regex]::Replace('$(GitTagTrimmed)', '^v', ''))</GitVersion>
|
||||||
|
<Version>$(GitVersion)</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<DefineConstants>
|
||||||
|
Version=$(Version);
|
||||||
|
PublishDir=C:\Users\Sonder\source\repos\psg-oversight-app\PublishDir
|
||||||
|
</DefineConstants>
|
||||||
|
<OutputName>OversightInstaller_$(Version)_$(Platform)</OutputName>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<Message Text="📦 Building OversightInstaller version $(Version)" Importance="high" />
|
||||||
|
<Message Text="📦 WiX DefineConstants=$(DefineConstants)" Importance="high" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<!-- ✅ STEP 2: Rename the MSI after build -->
|
||||||
|
<Target Name="RenameMsi" AfterTargets="Build">
|
||||||
|
<PropertyGroup>
|
||||||
|
<BuiltMsi>$(OutputPath)OversightInstaller_$(Version)_$(Platform).msi</BuiltMsi>
|
||||||
|
<ActualMsi>$(OutputPath)OversightInstaller.msi</ActualMsi>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<Message Text="📦 Renaming $(ActualMsi) → $(BuiltMsi)" Importance="high" />
|
||||||
|
<Exec Command="move /Y "$(ActualMsi)" "$(BuiltMsi)"" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="Assets\DLShortcut.ico">
|
<PackageReference Include="WixToolset.UI.wixext" />
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
|
||||||
</Content>
|
|
||||||
<Content Include="Assets\trayicon.ico">
|
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
|
||||||
</Content>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<WixSource Include="HarvestedFiles.wxs" />
|
<WixSource Include="HarvestedFiles.wxs" />
|
||||||
</ItemGroup>
|
<Content Include="Assets\DLShortcut.ico" CopyToOutputDirectory="Always" />
|
||||||
<ItemGroup>
|
<Content Include="Assets\trayicon.ico" CopyToOutputDirectory="Always" />
|
||||||
<Content Include="bpl.rtf">
|
<Content Include="bpl.rtf" CopyToOutputDirectory="Always" />
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
|
||||||
</Content>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<None Include="Assets\windowsdesktop-runtime-8.0.13-win-x64.exe" />
|
<None Include="Assets\windowsdesktop-runtime-8.0.13-win-x64.exe" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
@@ -1,18 +1,34 @@
|
|||||||
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"
|
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"
|
||||||
xmlns:ui="http://wixtoolset.org/schemas/v4/wxs/ui">
|
xmlns:ui="http://wixtoolset.org/schemas/v4/wxs/ui">
|
||||||
|
|
||||||
<Package Name="Oversight" Manufacturer="Paragon Systems Group" Version="1.0.0.0" UpgradeCode="e0e26d46-ed26-425e-a1bb-9bc76523ae6b">
|
<!-- ✅ Safe default in case $(var.Version) is undefined -->
|
||||||
|
<?ifndef Version?>
|
||||||
|
<?define Version="0.0.0"?>
|
||||||
|
<?endif?>
|
||||||
|
|
||||||
|
<Package
|
||||||
|
Name="Oversight"
|
||||||
|
Manufacturer="Paragon Systems Group"
|
||||||
|
Version="$(var.Version)"
|
||||||
|
UpgradeCode="e0e26d46-ed26-425e-a1bb-9bc76523ae6b">
|
||||||
|
|
||||||
|
<Property Id="DisplayVersion" Value="$(var.Version)" />
|
||||||
|
|
||||||
|
<!-- 🔁 Automatic major-upgrade behavior -->
|
||||||
<MajorUpgrade DowngradeErrorMessage="A newer version of this application is already installed." />
|
<MajorUpgrade DowngradeErrorMessage="A newer version of this application is already installed." />
|
||||||
|
|
||||||
<WixVariable
|
<!-- ✅ Only define custom ARP metadata that isn’t built-in -->
|
||||||
Id="WixUILicenseRtf"
|
|
||||||
Value="bpl.rtf"
|
|
||||||
/>
|
|
||||||
<!-- 🔍 Properties -->
|
|
||||||
<Property Id="ARPPRODUCTICON" Value="DLShortcutIcon" />
|
<Property Id="ARPPRODUCTICON" Value="DLShortcutIcon" />
|
||||||
|
<Property Id="ARPHELPLINK" Value="https://psg.net.au/" />
|
||||||
|
<Property Id="ARPCONTACT" Value="support@psg.net.au" />
|
||||||
|
<Property Id="ARPINSTALLLOCATION" Value="[INSTALLFOLDER]" />
|
||||||
|
|
||||||
|
<!-- Optional custom properties -->
|
||||||
<Property Id="SERVER_URL" Value="http://your-default-server/api/register" />
|
<Property Id="SERVER_URL" Value="http://your-default-server/api/register" />
|
||||||
<Property Id="APP_EXECUTABLE" Value="PSG-Oversight.exe" />
|
<Property Id="APP_EXECUTABLE" Value="PSG-Oversight.exe" />
|
||||||
|
|
||||||
|
<!-- 💬 EULA -->
|
||||||
|
<WixVariable Id="WixUILicenseRtf" Value="bpl.rtf" />
|
||||||
|
|
||||||
<!-- 🔧 UI -->
|
<!-- 🔧 UI -->
|
||||||
<ui:WixUI Id="WixUI_InstallDir" InstallDirectory="INSTALLFOLDER" />
|
<ui:WixUI Id="WixUI_InstallDir" InstallDirectory="INSTALLFOLDER" />
|
||||||
@@ -22,15 +38,14 @@
|
|||||||
|
|
||||||
<!-- 📂 Installation Directory -->
|
<!-- 📂 Installation Directory -->
|
||||||
<StandardDirectory Id="ProgramFiles64Folder">
|
<StandardDirectory Id="ProgramFiles64Folder">
|
||||||
|
<Directory Id="PSGROOT" Name="PSG">
|
||||||
<Directory Id="INSTALLFOLDER" Name="Oversight">
|
<Directory Id="INSTALLFOLDER" Name="Oversight">
|
||||||
|
<!-- Your files and harvested components go here -->
|
||||||
|
</Directory>
|
||||||
|
|
||||||
|
|
||||||
<!-- 📁 Assets Folder -->
|
|
||||||
|
|
||||||
</Directory>
|
</Directory>
|
||||||
</StandardDirectory>
|
</StandardDirectory>
|
||||||
|
|
||||||
|
<!-- 📦 Application Files -->
|
||||||
<ComponentGroupRef Id="AppFiles" />
|
<ComponentGroupRef Id="AppFiles" />
|
||||||
|
|
||||||
<!-- 📁 Start Menu Shortcut -->
|
<!-- 📁 Start Menu Shortcut -->
|
||||||
@@ -46,17 +61,37 @@
|
|||||||
IconIndex="0" />
|
IconIndex="0" />
|
||||||
<RemoveFile Id="RemoveStartMenuShortcut" Name="Oversight.lnk" On="uninstall" />
|
<RemoveFile Id="RemoveStartMenuShortcut" Name="Oversight.lnk" On="uninstall" />
|
||||||
<RemoveFolder Id="RemoveStartMenuFolder" On="uninstall" />
|
<RemoveFolder Id="RemoveStartMenuFolder" On="uninstall" />
|
||||||
<RegistryValue Root="HKCU" Key="Software\Oversight" Name="StartMenuShortcut" Type="integer" Value="1" KeyPath="yes"/>
|
<RegistryValue Root="HKCU" Key="Software\Oversight"
|
||||||
|
Name="StartMenuShortcut" Type="integer" Value="1" KeyPath="yes"/>
|
||||||
</Component>
|
</Component>
|
||||||
</Directory>
|
</Directory>
|
||||||
</StandardDirectory>
|
</StandardDirectory>
|
||||||
|
|
||||||
|
|
||||||
<!-- 📦 Feature References -->
|
<!-- 64-bit component so ARP keys go to HKLM\Software (not Wow6432Node) -->
|
||||||
|
<Component Id="AppMetadata" Guid="E62354E8-3C7B-4B13-AFE2-A1E65A7F2E77" Bitness="always64">
|
||||||
|
<RegistryKey
|
||||||
|
Root="HKLM"
|
||||||
|
Key="Software\Microsoft\Windows\CurrentVersion\Uninstall\[ProductCode]">
|
||||||
|
<!-- Nice, branded ARP entry -->
|
||||||
|
<RegistryValue Name="DisplayName" Value="Oversight" Type="string" />
|
||||||
|
<RegistryValue Name="Publisher" Value="Paragon Systems Group" Type="string" />
|
||||||
|
<!-- Make version show in Control Panel; compile-time value from your wixproj -->
|
||||||
|
<RegistryValue Name="DisplayVersion" Value="$(var.Version)" Type="string" KeyPath="yes" />
|
||||||
|
</RegistryKey>
|
||||||
|
</Component>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- 🧱 Primary Feature -->
|
||||||
<Feature Id="Main" Title="DL SysInfo" Level="1">
|
<Feature Id="Main" Title="DL SysInfo" Level="1">
|
||||||
<ComponentGroupRef Id="AppFiles" />
|
<ComponentGroupRef Id="AppFiles" />
|
||||||
<ComponentRef Id="StartMenuShortcutComponent" />
|
<ComponentRef Id="StartMenuShortcutComponent" />
|
||||||
|
<ComponentRef Id="AppMetadata" />
|
||||||
</Feature>
|
</Feature>
|
||||||
|
|
||||||
<!-- 💿 Media -->
|
<!-- 💿 Media -->
|
||||||
<Media Id="1" Cabinet="embedded.cab" EmbedCab="yes" />
|
<Media Id="1" Cabinet="embedded.cab" EmbedCab="yes" />
|
||||||
|
|
||||||
|
|||||||
13
OversightService/OversightService.csproj
Normal file
13
OversightService/OversightService.csproj
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk.Worker">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<UserSecretsId>dotnet-OversightService-9352272b-722c-4a12-acc2-8c9b146e5292</UserSecretsId>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Hosting" />
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
||||||
7
OversightService/Program.cs
Normal file
7
OversightService/Program.cs
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
using OversightService;
|
||||||
|
|
||||||
|
var builder = Host.CreateApplicationBuilder(args);
|
||||||
|
builder.Services.AddHostedService<Worker>();
|
||||||
|
|
||||||
|
var host = builder.Build();
|
||||||
|
host.Run();
|
||||||
12
OversightService/Properties/launchSettings.json
Normal file
12
OversightService/Properties/launchSettings.json
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||||
|
"profiles": {
|
||||||
|
"OversightService": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"dotnetRunMessages": true,
|
||||||
|
"environmentVariables": {
|
||||||
|
"DOTNET_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
24
OversightService/Worker.cs
Normal file
24
OversightService/Worker.cs
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
namespace OversightService
|
||||||
|
{
|
||||||
|
public class Worker : BackgroundService
|
||||||
|
{
|
||||||
|
private readonly ILogger<Worker> _logger;
|
||||||
|
|
||||||
|
public Worker(ILogger<Worker> logger)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||||
|
{
|
||||||
|
while (!stoppingToken.IsCancellationRequested)
|
||||||
|
{
|
||||||
|
if (_logger.IsEnabled(LogLevel.Information))
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now);
|
||||||
|
}
|
||||||
|
await Task.Delay(1000, stoppingToken);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
8
OversightService/appsettings.Development.json
Normal file
8
OversightService/appsettings.Development.json
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"Logging": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Information",
|
||||||
|
"Microsoft.Hosting.Lifetime": "Information"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
8
OversightService/appsettings.json
Normal file
8
OversightService/appsettings.json
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"Logging": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Information",
|
||||||
|
"Microsoft.Hosting.Lifetime": "Information"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
1
deps/osquery
vendored
Submodule
1
deps/osquery
vendored
Submodule
Submodule deps/osquery added at e8f154ef31
Reference in New Issue
Block a user