Skip to content

Commit db7c79a

Browse files
committed
Initial code import.
1 parent ffffd0d commit db7c79a

28 files changed

Lines changed: 2990 additions & 25 deletions

App.config

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
5+
</startup>
6+
<runtime>
7+
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
8+
<dependentAssembly>
9+
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
10+
<bindingRedirect oldVersion="0.0.0.0-4.0.6.0" newVersion="4.0.6.0" />
11+
</dependentAssembly>
12+
</assemblyBinding>
13+
</runtime>
14+
</configuration>

App.xaml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<!-- Copyright (c) 2020 Vadim Zhukov <zhuk@openbsd.org>
2+
3+
Permission to use, copy, modify, and distribute this software for any
4+
purpose with or without fee is hereby granted, provided that the above
5+
copyright notice and this permission notice appear in all copies.
6+
7+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
13+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -->
14+
15+
<Application x:Class="PipeExplorer.App"
16+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
17+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
18+
xmlns:local="clr-namespace:PipeExplorer"
19+
xmlns:vm="clr-namespace:PipeExplorer.ViewModels"
20+
StartupUri="PipeExplorerMainWindow.xaml">
21+
<Application.Resources>
22+
<ResourceDictionary>
23+
<ResourceDictionary.MergedDictionaries>
24+
<!-- MahApps.Metro resource dictionaries. Make sure that all file names are Case Sensitive! -->
25+
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
26+
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
27+
<!-- Theme setting -->
28+
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Themes/Light.Blue.xaml" />
29+
</ResourceDictionary.MergedDictionaries>
30+
31+
<vm:AdvancedBooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
32+
<vm:AdvancedBooleanToVisibilityConverter x:Key="InvertedBooleanToVisibilityConverter" InvertedLogic="True" />
33+
34+
<DrawingImage x:Key="AppIcon">
35+
<DrawingImage.Drawing>
36+
<GeometryDrawing Brush="Gray">
37+
<GeometryDrawing.Pen>
38+
<Pen Brush="DarkSlateGray" Thickness="1"/>
39+
</GeometryDrawing.Pen>
40+
<GeometryDrawing.Geometry>
41+
<PathGeometry>
42+
M22,14H20V16H14V13H16V11H14V6A2,2 0 0,0 12,4H4V2H2V10H4V8H10V11H8V13H10V18A2,2 0 0,0 12,20H20V22H22
43+
</PathGeometry>
44+
</GeometryDrawing.Geometry>
45+
</GeometryDrawing>
46+
</DrawingImage.Drawing>
47+
</DrawingImage>
48+
49+
<DrawingImage x:Key="AppIconActive">
50+
<DrawingImage.Drawing>
51+
<GeometryDrawing Brush="MediumAquamarine">
52+
<GeometryDrawing.Pen>
53+
<Pen Brush="DarkSlateGray" Thickness="1"/>
54+
</GeometryDrawing.Pen>
55+
<GeometryDrawing.Geometry>
56+
<PathGeometry>
57+
M22,14H20V16H14V13H16V11H14V6A2,2 0 0,0 12,4H4V2H2V10H4V8H10V11H8V13H10V18A2,2 0 0,0 12,20H20V22H22
58+
</PathGeometry>
59+
</GeometryDrawing.Geometry>
60+
</GeometryDrawing>
61+
</DrawingImage.Drawing>
62+
</DrawingImage>
63+
</ResourceDictionary>
64+
</Application.Resources>
65+
</Application>

App.xaml.cs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#region Licensing information
2+
/*
3+
* Copyright(c) 2020 Vadim Zhukov<zhuk@openbsd.org>
4+
*
5+
* Permission to use, copy, modify, and distribute this software for any
6+
* purpose with or without fee is hereby granted, provided that the above
7+
* copyright notice and this permission notice appear in all copies.
8+
*
9+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10+
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11+
* MERCHANTABILITY AND FITNESS.IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12+
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13+
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14+
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15+
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16+
*/
17+
#endregion
18+
19+
using System.Windows;
20+
using PipeExplorer.Services;
21+
using Splat;
22+
23+
namespace PipeExplorer
24+
{
25+
/// <summary>
26+
/// Interaction logic for App.xaml
27+
/// </summary>
28+
public partial class App : Application
29+
{
30+
//protected override void OnStartup(StartupEventArgs e)
31+
//{
32+
// Locator.CurrentMutable.Register<IPipeWatcher>(() => new PipeWatcher());
33+
// Locator.CurrentMutable.RegisterConstant<ISettings>(new Settings());
34+
35+
// base.OnStartup(e);
36+
//}
37+
}
38+
}

FodyWeavers.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
2+
<ReactiveUI />
3+
</Weavers>

LICENSE

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,13 @@
1-
BSD 2-Clause License
2-
3-
Copyright (c) 2020, Vadim Zhukov
4-
All rights reserved.
5-
6-
Redistribution and use in source and binary forms, with or without
7-
modification, are permitted provided that the following conditions are met:
8-
9-
1. Redistributions of source code must retain the above copyright notice, this
10-
list of conditions and the following disclaimer.
11-
12-
2. Redistributions in binary form must reproduce the above copyright notice,
13-
this list of conditions and the following disclaimer in the documentation
14-
and/or other materials provided with the distribution.
15-
16-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17-
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18-
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19-
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
20-
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21-
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22-
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23-
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24-
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1+
Copyright (c) 2020 Vadim Zhukov <zhuk@openbsd.org>
2+
3+
Permission to use, copy, modify, and distribute this software for any
4+
purpose with or without fee is hereby granted, provided that the above
5+
copyright notice and this permission notice appear in all copies.
6+
7+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
13+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

Models/PipeModel.cs

Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
1+
#region Licensing information
2+
/*
3+
* Copyright(c) 2020 Vadim Zhukov<zhuk@openbsd.org>
4+
*
5+
* Permission to use, copy, modify, and distribute this software for any
6+
* purpose with or without fee is hereby granted, provided that the above
7+
* copyright notice and this permission notice appear in all copies.
8+
*
9+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10+
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11+
* MERCHANTABILITY AND FITNESS.IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12+
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13+
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14+
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15+
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16+
*/
17+
#endregion
18+
19+
using System;
20+
using System.Collections.Generic;
21+
using System.IO.Pipes;
22+
using System.Linq;
23+
using System.Security.Principal;
24+
25+
namespace PipeExplorer.Models
26+
{
27+
readonly struct PipeModel : IEquatable<PipeModel>
28+
{
29+
public string Host { get; }
30+
public string Name { get; }
31+
public string Hint { get; }
32+
public int MaxConnections { get; }
33+
public PipeSecurity Acl { get; }
34+
public uint ActiveConnections { get; }
35+
36+
public string Path => $@"\\{Host}\{Name}";
37+
38+
public PipeModel(string host, string name, int maxConn, uint activeConn, PipeSecurity acl)
39+
{
40+
Host = host ?? throw new ArgumentNullException(nameof(host));
41+
Name = name ?? throw new ArgumentNullException(nameof(name));
42+
MaxConnections = maxConn;
43+
ActiveConnections = activeConn;
44+
Hint = GetHintFor(name);
45+
Acl = acl ?? new PipeSecurity();
46+
}
47+
48+
public static string GetHintFor(string pipeName)
49+
{
50+
switch (pipeName)
51+
{
52+
// Source: https://l.wzm.me/_security/internet/_internet/WinServices/ch04s05s03.html
53+
54+
case "atsvc": return "Scheduler service";
55+
case "AudioSrv": return "Windows Audio service";
56+
case "browser": return "Computer Browser (ntsvcs alias)";
57+
case "cert": return "Certificate services";
58+
case "Ctx_Winstation_API_Service": return "Terminal Services remote management";
59+
case "DAV RPC SERVICE": return "WebDAV client";
60+
case "dnsserver": return "DNS Server";
61+
case "epmapper": return "RPC endpoint mapper";
62+
case "eventlog": return "Eventlog service (ntsvcs alias)";
63+
case "HydraLsPipe": return "Terminal Server Licensing";
64+
case "InitShutdown": return "(Remote) system shutdown";
65+
case "keysvc": return "Cryptographic services";
66+
case "locator": return "RPC Locator service";
67+
case "llsrpc": return "Licensing Logging service";
68+
case "lsarpc": return "LSA access (lsass alias)";
69+
case "msgsvc": return "Messenger service (ntsvcs alias)";
70+
case "netdfs": return "Distributed File System service";
71+
case "netlogon": return "Net Logon service (lsass alias)";
72+
case "ntsvcs": return "Plug and Play service";
73+
case "policyagent": return "IPSEC Policy Agent (Windows 2000)";
74+
case "ipsec": return "IPsec Services";
75+
case "ProfMapApi": return "Userenv";
76+
case "protected_storage": return "Protected Storage";
77+
case "ROUTER": return "Remote Access";
78+
case "samr": return "SAM access (lsass alias)";
79+
case "scerpc": return "Security Configuration Editor (SCE)";
80+
case "SECLOGON": return "Secondary logon service";
81+
case "SfcApi": return "Windows File Protection";
82+
case "spoolss": return "Spooler service";
83+
case "srvsvc": return "Server service (ntsvcs alias)";
84+
case "ssdpsrv": return "SSDP service";
85+
case "svcctl": return "Services control manager (ntsvcs alias)";
86+
case "tapsrv": return "Telephony service";
87+
case "trkwks": return "Distributed Link Tracking Client";
88+
case "W32TIME (ntsvcs alias)": return "Windows Time (Windows 2000 and XP)";
89+
case "W32TIME_ALT": return "Windows Time (Windows Server 2003)";
90+
case "winlogonrpc": return "Winlogon";
91+
case "winreg": return "Remote registry service";
92+
case "winspipe": return "WINS service";
93+
case "wkssvc": return "Workstation service (ntsvcs alias)";
94+
default: return "";
95+
}
96+
}
97+
98+
public override bool Equals(object obj)
99+
{
100+
return obj is PipeModel model && Equals(model);
101+
}
102+
103+
public bool Equals(PipeModel other)
104+
{
105+
return Host == other.Host &&
106+
Name == other.Name &&
107+
ActiveConnections == other.ActiveConnections &&
108+
MaxConnections == other.MaxConnections &&
109+
AreAclsEqual(Acl, other.Acl) &&
110+
Hint == other.Hint;
111+
}
112+
113+
public override int GetHashCode()
114+
{
115+
int hashCode = -824410345;
116+
hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(Host);
117+
hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(Name);
118+
hashCode = hashCode * -1521134295 + ActiveConnections.GetHashCode();
119+
hashCode = hashCode * -1521134295 + MaxConnections.GetHashCode();
120+
hashCode = hashCode * -1521134295 + GetAclHashCode(Acl);
121+
hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(Hint);
122+
return hashCode;
123+
}
124+
125+
public static bool operator ==(PipeModel left, PipeModel right)
126+
{
127+
return left.Equals(right);
128+
}
129+
130+
public static bool operator !=(PipeModel left, PipeModel right)
131+
{
132+
return !(left == right);
133+
}
134+
135+
private static bool AreAclsEqual(PipeSecurity acl1, PipeSecurity acl2)
136+
{
137+
var list1 = acl1.GetAccessRules(true, true, typeof(SecurityIdentifier)).OfType<PipeAccessRule>().OrderBy(r => r, aclRuleComparer).ToList();
138+
var list2 = acl2.GetAccessRules(true, true, typeof(SecurityIdentifier)).OfType<PipeAccessRule>().OrderBy(r => r, aclRuleComparer).ToList();
139+
return list1.SequenceEqual(list2, aclRuleEqualityComparer);
140+
}
141+
142+
private static int GetAclHashCode(PipeSecurity acl)
143+
{
144+
int hashCode = -1622615647;
145+
foreach (var rule in acl.GetAccessRules(true, true, typeof(SecurityIdentifier)).OfType<PipeAccessRule>().OrderBy(r => r, aclRuleComparer))
146+
{
147+
hashCode = hashCode * -1521134295 + aclRuleEqualityComparer.GetHashCode();
148+
}
149+
return hashCode;
150+
}
151+
152+
private static readonly IEqualityComparer<PipeAccessRule> aclRuleEqualityComparer = new AclRuleEqualityComparer();
153+
private static readonly IComparer<PipeAccessRule> aclRuleComparer = Comparer<PipeAccessRule>.Create(PipeAcccessRuleComparision);
154+
155+
private class AclRuleEqualityComparer : IEqualityComparer<PipeAccessRule>
156+
{
157+
public bool Equals(PipeAccessRule x, PipeAccessRule y)
158+
{
159+
return x.IdentityReference == y.IdentityReference &&
160+
x.IsInherited == y.IsInherited &&
161+
x.InheritanceFlags == y.InheritanceFlags &&
162+
x.PropagationFlags == y.PropagationFlags &&
163+
x.AccessControlType == y.AccessControlType &&
164+
x.PipeAccessRights == y.PipeAccessRights;
165+
}
166+
167+
public int GetHashCode(PipeAccessRule rule)
168+
{
169+
int hashCode = -228291695;
170+
hashCode = hashCode * -1521134295 + rule.IdentityReference.GetHashCode();
171+
hashCode = hashCode * -1521134295 + rule.IsInherited.GetHashCode();
172+
hashCode = hashCode * -1521134295 + rule.InheritanceFlags.GetHashCode();
173+
hashCode = hashCode * -1521134295 + rule.PropagationFlags.GetHashCode();
174+
hashCode = hashCode * -1521134295 + rule.AccessControlType.GetHashCode();
175+
hashCode = hashCode * -1521134295 + rule.PipeAccessRights.GetHashCode();
176+
return hashCode;
177+
}
178+
}
179+
180+
private static int PipeAcccessRuleComparision(PipeAccessRule x, PipeAccessRule y)
181+
{
182+
int delta;
183+
if ((delta = x.IdentityReference.Value.CompareTo(y.IdentityReference.Value)) != 0)
184+
return delta;
185+
if ((delta = x.PipeAccessRights.CompareTo(y.PipeAccessRights)) != 0)
186+
return delta;
187+
if ((delta = x.AccessControlType.CompareTo(y.AccessControlType)) != 0)
188+
return delta;
189+
if ((delta = x.IsInherited.CompareTo(y.IsInherited)) != 0)
190+
return delta;
191+
if ((delta = x.InheritanceFlags.CompareTo(y.InheritanceFlags)) != 0)
192+
return delta;
193+
if ((delta = x.PropagationFlags.CompareTo(y.PropagationFlags)) != 0)
194+
return delta;
195+
return 0;
196+
}
197+
}
198+
}

0 commit comments

Comments
 (0)