├── .gitattributes ├── .gitignore ├── Images ├── logo.png └── screen.gif ├── LICENSE ├── README.md ├── Source └── Swiddler │ ├── App.manifest │ ├── App.xaml │ ├── App.xaml.cs │ ├── AppIcon.ico │ ├── AppResources.cs │ ├── Behaviors │ ├── Button.cs │ ├── FrameworkElement.cs │ ├── TextBox.cs │ └── Window.cs │ ├── Channels │ ├── Channel.cs │ ├── MonitorChannel.cs │ ├── RemoteChildChannel.cs │ ├── RewriteChannel.cs │ ├── SessionChannel.cs │ ├── SnifferChannel.cs │ ├── SslChannel.cs │ ├── SslListenerChannel.cs │ ├── TcpChannel.cs │ ├── TcpListenerChannel.cs │ └── UdpChannel.cs │ ├── ChunkViews │ ├── ChunkViewItem.cs │ ├── Message.cs │ ├── RawData.cs │ └── Selection.cs │ ├── Commands │ ├── CertificateCommands.cs │ └── MiscCommands.cs │ ├── Common │ ├── BindableBase.cs │ ├── ConnectionBanner.cs │ ├── DeferredDataObject.cs │ ├── DelayedInvoker.cs │ ├── Injector.cs │ ├── Monitor.cs │ ├── ObservableRangeCollection.cs │ ├── ReloadableCollection.cs │ ├── Session.cs │ ├── TrafficFlow.cs │ └── ValueException.cs │ ├── Controls │ ├── ChunkView.cs │ ├── ChunkView.xaml │ ├── ComboBoxEx.cs │ ├── CrispImage.cs │ ├── CrispImage.xaml │ ├── LockableToggleButton.cs │ ├── SearchTextBox.cs │ ├── SearchTextBox.xaml │ ├── SessionListView.cs │ ├── SessionListView.xaml │ ├── TileButton.cs │ ├── TileButton.xaml │ ├── TreeToggleButton.cs │ └── TreeToggleButton.xaml │ ├── Converters │ ├── AssignableTypeConverter.cs │ ├── CertificateNameConverter.cs │ ├── CertificateThumbprintConverter.cs │ ├── CertificateValidityConverter.cs │ ├── CrispImageConverter.cs │ ├── EmptyStringConverter.cs │ ├── FormatConverter.cs │ ├── IntEnumConverter.cs │ ├── InvertBoolConverter.cs │ ├── LazyBindingConverter.cs │ ├── ScrollBarVisibility.cs │ ├── SslVersionStringConverter.cs │ └── TreeIndentConverter.cs │ ├── DataChunks │ ├── MessageData.cs │ └── Packet.cs │ ├── IO │ ├── BlockReader.cs │ ├── BlockWriter.cs │ ├── CachedBlockIterator.cs │ ├── ChunkDictionary.cs │ ├── ChunkWriter.cs │ ├── Constants.cs │ ├── DataTransfer.cs │ ├── IDataChunk.cs │ ├── StorageHandle.cs │ ├── SyncedFileStream.cs │ └── Test.cs │ ├── Images │ ├── Adapter.xaml │ ├── Binary.xaml │ ├── Certificate.xaml │ ├── Close.xaml │ ├── Connect.xaml │ ├── Connect_16x.png │ ├── Connect_20x.png │ ├── Connect_32x.png │ ├── Connecting.xaml │ ├── Delete.xaml │ ├── Disconnect.xaml │ ├── Disconnected.xaml │ ├── Disconnected_32x.png │ ├── Edit_16x.png │ ├── Edit_20x.png │ ├── Error.xaml │ ├── ExportShark.xaml │ ├── Eye.xaml │ ├── Forward.xaml │ ├── Gear.xaml │ ├── GearBlack.xaml │ ├── Gear_32x.png │ ├── Go.xaml │ ├── Help_16x.png │ ├── Help_24x.png │ ├── HintIcon.xaml │ ├── Info.xaml │ ├── Invalid.xaml │ ├── LockInvalid.xaml │ ├── LockValid.xaml │ ├── OpenFolder.xaml │ ├── OpenFolder_16x.png │ ├── Port.xaml │ ├── Port_20x.png │ ├── Port_32x.png │ ├── Process.xaml │ ├── Process_20x.png │ ├── Process_32x.png │ ├── Run.xaml │ ├── Save.xaml │ ├── Search.xaml │ ├── Search_20x.png │ ├── Star.xaml │ ├── Stop.xaml │ ├── Trash.xaml │ ├── Tunnel.xaml │ ├── Tunnel_32x.png │ ├── Valid.xaml │ ├── Watermark.png │ └── Watermark.xaml │ ├── MarkupExtensions │ ├── CertificateSource.cs │ ├── DpiExtensions.cs │ ├── GroupedIPAddresses.cs │ ├── ShadowGlassFrameThickness.cs │ └── SslProtocolSupport.cs │ ├── NetworkSniffer │ ├── IPFragment.cs │ ├── IPParser.cs │ ├── PacketFilter.cs │ ├── PacketReassembly.cs │ ├── RawPacket.cs │ ├── TCPParser.cs │ ├── TCPState.cs │ └── UDPParser.cs │ ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ └── Resources.resx │ ├── Rendering │ ├── ConnectionFragment.cs │ ├── DrawingFragment.cs │ ├── FilledFragment.cs │ ├── Fragment.cs │ ├── FragmentLayer.cs │ ├── FragmentView.cs │ ├── FragmentViewContent.cs │ ├── FragmentViewMetrics.cs │ ├── MessageFragment.cs │ ├── PolygonFigure.cs │ ├── SelectionLayer.cs │ ├── SslHandshakeFragment.cs │ ├── TextFragment.cs │ └── VisualPool.cs │ ├── Resources │ ├── Brushes.xaml │ ├── CustomStyles.xaml │ ├── Misc.xaml │ ├── SocketToggles.xaml │ ├── netprobe32.dll │ ├── netprobe64.dll │ └── port_numbers.csv │ ├── Security │ ├── CertProvider.cs │ ├── SslAlert.cs │ ├── SslCiphers.cs │ ├── SslClientHello.cs │ ├── SslExtension.cs │ ├── SslHelloBase.cs │ ├── SslServerHello.cs │ ├── SslStreamExt.cs │ ├── StreamExtensions.cs │ └── X509.cs │ ├── Serialization │ ├── FileHeaderXml.cs │ ├── IPBuilder.cs │ ├── Pcap │ │ ├── Disposable.cs │ │ ├── LinkType.cs │ │ ├── PcapPacket.cs │ │ ├── PcapWriter.cs │ │ ├── ReverseByteOrderExtension.cs │ │ └── SectionHeader.cs │ ├── Rtf │ │ ├── RtfAbstract.cs │ │ ├── RtfBasics.cs │ │ ├── RtfBlockList.cs │ │ ├── RtfCharFormat.cs │ │ ├── RtfDocument.cs │ │ ├── RtfParagraph.cs │ │ └── RtfUtility.cs │ ├── SessionXml.cs │ ├── SslHandshake.cs │ └── UserSettings.cs │ ├── SocketSettings │ ├── ClientSettingsBase.cs │ ├── RewriteSettings.cs │ ├── ServerSettingsBase.cs │ ├── SettingsBase.cs │ ├── SnifferSettings.cs │ ├── TCPClientSettings.cs │ ├── TCPServerSettings.cs │ ├── UDPClientSettings.cs │ └── UDPServerSettings.cs │ ├── Swiddler.csproj │ ├── Themes │ └── Generic.xaml │ ├── Utils │ ├── AssemblyExtensions.cs │ ├── ChannelExtensions.cs │ ├── ControlExtensions.cs │ ├── DateTimeExtensions.cs │ ├── DependencyObjectExtensions.cs │ ├── Firewall.cs │ ├── ImagingExtensions.cs │ ├── MiscExtensions.cs │ ├── Net.cs │ ├── Shell │ │ ├── IImageList.cs │ │ ├── IMAGEINFO.cs │ │ ├── IMAGELISTDRAWPARAMS.cs │ │ ├── POINT.cs │ │ ├── RECT.cs │ │ └── SHFILEINFO.cs │ ├── ShellApi.cs │ ├── TaskbarProgress.cs │ ├── VisualExtensions.cs │ └── WindowExtensions.cs │ ├── ViewModels │ ├── Certificate.cs │ ├── ConnectionSettings.cs │ ├── IPAdapterHeader.cs │ ├── IPAddressItem.cs │ ├── ImageButton.cs │ ├── ProcessInfo.cs │ ├── QuickActionItem.cs │ ├── RecentlyUsedItem.cs │ ├── SessionListItem.cs │ └── SessionTree.cs │ └── Views │ ├── Fragments │ ├── ConnectionView.xaml │ ├── ConnectionView.xaml.cs │ ├── MessageView.xaml │ ├── MessageView.xaml.cs │ ├── SslHandshakeView.xaml │ └── SslHandshakeView.xaml.cs │ ├── MainWindow.xaml │ ├── MainWindow.xaml.cs │ ├── NewCertificate.xaml │ ├── NewCertificate.xaml.cs │ ├── NewConnection.xaml │ ├── NewConnection.xaml.cs │ ├── NewSessionExpress.xaml │ ├── NewSessionExpress.xaml.cs │ ├── SocketSettings │ ├── Client.xaml │ ├── Client.xaml.cs │ ├── Listener.xaml │ ├── Listener.xaml.cs │ ├── Rewrite.xaml │ ├── Rewrite.xaml.cs │ ├── Sniffer.xaml │ ├── Sniffer.xaml.cs │ ├── UDPClient.xaml │ ├── UDPClient.xaml.cs │ ├── UDPServer.xaml │ └── UDPServer.xaml.cs │ ├── SslHandshakeDetails.xaml │ └── SslHandshakeDetails.xaml.cs └── Swiddler.sln /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /Images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jlucansky/Swiddler/5ff34a126c481f8757c7e40acd8507ac55359895/Images/logo.png -------------------------------------------------------------------------------- /Images/screen.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jlucansky/Swiddler/5ff34a126c481f8757c7e40acd8507ac55359895/Images/screen.gif -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 |

4 | 5 | # TCP/UDP debugging tool 6 | 7 | ![](https://raw.githubusercontent.com/jlucansky/Swiddler/master/Images/screen.gif) 8 | 9 | # Features 10 | ### Capture & Inspect 11 | - Capture virtually unlimited amount of data 12 | - Export captured raw data (drag selection to file) 13 | 14 | ### Create TCP/UDP server 15 | - Bind to any local IP 16 | - Supported IPv4/IPv6 dual stack 17 | - Allow reuse same address & port 18 | 19 | ### Connect to remote host 20 | - Specify source address 21 | - Broadcast or join multicast groups 22 | 23 | ### Rewrite traffic 24 | - Replace matched content 25 | - Match arbitrary data in binary mode 26 | 27 | ### SSL/TLS client & server 28 | - Supported SSL/3.0, TLS/1.0, TLS/1.1, TLS/1.2 29 | - Send custom Server Name Indication (SNI) 30 | - Create certificates and self-signed CA 31 | - Auto generate server certificates based on SNI 32 | - Export negotiated certificate chain 33 | - Observe SSL/TLS client & server hello messages 34 | - Request or send client certificate 35 | 36 | 37 | # Minimum requirements 38 | - .NET Framework 4.5 39 | - Windows 7 SP1 or higher 40 | - Windows Server 2008 SP2 or higher 41 | 42 | # License 43 | This project is made available under the Apache License 2.0 44 | 45 | See [LICENSE](LICENSE) for details. 46 | -------------------------------------------------------------------------------- /Source/Swiddler/App.xaml: -------------------------------------------------------------------------------- 1 |  8 | 9 | 10 | 11 | 12 | 13 | 14 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /Source/Swiddler/AppIcon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jlucansky/Swiddler/5ff34a126c481f8757c7e40acd8507ac55359895/Source/Swiddler/AppIcon.ico -------------------------------------------------------------------------------- /Source/Swiddler/Behaviors/Button.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using System.Windows.Controls; 3 | using System.Windows.Controls.Primitives; 4 | 5 | namespace Swiddler.Behaviors 6 | { 7 | public static class Button 8 | { 9 | private static readonly DependencyProperty ClickOpensContextMenuProperty = 10 | DependencyProperty.RegisterAttached("ClickOpensContextMenu", typeof(bool), typeof(Button), 11 | new PropertyMetadata(false, new PropertyChangedCallback(HandlePropertyChanged))); 12 | 13 | public static bool GetClickOpensContextMenu(DependencyObject obj) => (bool)obj.GetValue(ClickOpensContextMenuProperty); 14 | 15 | public static void SetClickOpensContextMenu(DependencyObject obj, bool value) => obj.SetValue(ClickOpensContextMenuProperty, value); 16 | 17 | private static void HandlePropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args) 18 | { 19 | if (obj is ButtonBase btn) 20 | { 21 | btn.Click -= ExecuteClick; 22 | btn.Click += ExecuteClick; 23 | } 24 | } 25 | 26 | private static void ExecuteClick(object sender, RoutedEventArgs args) 27 | { 28 | if (sender is ButtonBase btn && GetClickOpensContextMenu(btn)) 29 | { 30 | if (btn.ContextMenu != null) 31 | { 32 | btn.ContextMenu.PlacementTarget = btn; 33 | btn.ContextMenu.Placement = ContextMenuService.GetPlacement(btn); 34 | btn.ContextMenu.IsOpen = true; 35 | } 36 | } 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Source/Swiddler/Behaviors/FrameworkElement.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | namespace Swiddler.Behaviors 4 | { 5 | public static class FrameworkElement 6 | { 7 | public static bool GetSetDpi(System.Windows.FrameworkElement element) => (bool)element.GetValue(SetDpiProperty); 8 | public static void SetSetDpi(System.Windows.FrameworkElement element, bool value) => element.SetValue(SetDpiProperty, value); 9 | 10 | public static readonly DependencyProperty SetDpiProperty = 11 | DependencyProperty.RegisterAttached("SetDpi", 12 | typeof(bool), typeof(FrameworkElement), 13 | new UIPropertyMetadata(false, OnSetDpiChanged)); 14 | 15 | private static void OnSetDpiChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) 16 | { 17 | if (d is System.Windows.FrameworkElement elm && e.NewValue is bool == true) 18 | App.Current?.Res.AttachDpiProperties(elm); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Source/Swiddler/Behaviors/Window.cs: -------------------------------------------------------------------------------- 1 | using Swiddler.Utils; 2 | using System.Windows; 3 | 4 | namespace Swiddler.Behaviors 5 | { 6 | public static class Window 7 | { 8 | public static bool GetDisableControls(System.Windows.Window wnd) => (bool)wnd.GetValue(DisableControlsProperty); 9 | public static void SetDisableControls(System.Windows.Window wnd, bool value) => wnd.SetValue(DisableControlsProperty, value); 10 | 11 | public static readonly DependencyProperty DisableControlsProperty = 12 | DependencyProperty.RegisterAttached("DisableControls", 13 | typeof(bool), typeof(Window), 14 | new UIPropertyMetadata(false, OnDisableControlsChanged)); 15 | 16 | private static void OnDisableControlsChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) 17 | { 18 | if (d is System.Windows.Window wnd && e.NewValue is bool == true) 19 | wnd.SourceInitialized += (_, __) => wnd.DisableWindowControls(); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Source/Swiddler/Channels/RemoteChildChannel.cs: -------------------------------------------------------------------------------- 1 | using Swiddler.Common; 2 | using Swiddler.DataChunks; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Net; 6 | 7 | namespace Swiddler.Channels 8 | { 9 | /// 10 | /// For every remote EndPoint creates a new child Session 11 | /// 12 | public class RemoteChildChannel : Channel 13 | { 14 | readonly Dictionary ChildrenSessions = new Dictionary(); 15 | 16 | private class Mediator : Channel, IDisposable 17 | { 18 | readonly Action ownerNotify; 19 | readonly IPEndPoint ep; 20 | Action disposed; 21 | public Mediator(Session session, Action ownerNotify, IPEndPoint ep, Action disposed) : base(session) 22 | { 23 | this.ownerNotify = ownerNotify; 24 | this.disposed = disposed; 25 | this.ep = ep; 26 | } 27 | 28 | protected override void OnReceiveNotification(Packet packet) // send to UdpChannel from session editor 29 | { 30 | packet.Destination = ep; 31 | ownerNotify(packet); 32 | } 33 | 34 | public void Send(Packet packet) 35 | { 36 | if (DefaultFlow != TrafficFlow.Undefined) 37 | packet.Flow = DefaultFlow; 38 | NotifyObservers(packet); 39 | } 40 | 41 | public void Dispose() 42 | { 43 | Observers.Clear(); 44 | var disposedCopy = disposed; 45 | disposed = null; 46 | disposedCopy?.Invoke(ep); 47 | } 48 | } 49 | 50 | public RemoteChildChannel(Session session) : base(session) { } 51 | protected override void OnReceiveNotification(Packet packet) => GetChild(packet.Source).Send(packet); 52 | 53 | private Mediator GetChild(IPEndPoint ep) 54 | { 55 | lock (ChildrenSessions) 56 | { 57 | if (ChildrenSessions.TryGetValue(ep, out var item) == false) 58 | { 59 | var child = Session.NewChildSession("Received from " + ep, 60 | s => item = new Mediator(s, NotifyObservers, ep, RemoveChild)); 61 | 62 | child.Name = $"{ep}"; 63 | child.Start(); 64 | ChildrenSessions.Add(ep, item); 65 | } 66 | return item; 67 | } 68 | } 69 | 70 | private void RemoveChild(IPEndPoint ep) 71 | { 72 | lock (ChildrenSessions) 73 | ChildrenSessions.Remove(ep); 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /Source/Swiddler/Channels/SessionChannel.cs: -------------------------------------------------------------------------------- 1 | using Swiddler.Common; 2 | using Swiddler.DataChunks; 3 | 4 | namespace Swiddler.Channels 5 | { 6 | public class SessionChannel : Channel 7 | { 8 | public bool IsActive => Observers.Count > 0; 9 | 10 | public SessionChannel(Session session) : base(session) 11 | { 12 | DefaultFlow = TrafficFlow.Outbound; 13 | } 14 | 15 | /// 16 | /// Append packet to session log 17 | /// 18 | protected override void OnReceiveNotification(Packet packet) 19 | { 20 | Session.WriteChunk(packet); 21 | } 22 | 23 | /// 24 | /// User can send packet interactively 25 | /// 26 | public void Submit(byte[] data) 27 | { 28 | if (IsActive) 29 | { 30 | var packet = new Packet() { Payload = data }; 31 | NotifyObservers(packet); 32 | } 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Source/Swiddler/Channels/SslListenerChannel.cs: -------------------------------------------------------------------------------- 1 | using Swiddler.Common; 2 | using System.Net.Sockets; 3 | using System.Security.Authentication; 4 | using System.Security.Cryptography.X509Certificates; 5 | 6 | namespace Swiddler.Channels 7 | { 8 | public class SslListenerChannel : TcpListenerChannel 9 | { 10 | public SslProtocols SslProtocols { get; set; } 11 | public bool RequireClientCertificate { get; set; } 12 | public bool IgnoreInvalidClientCertificate { get; set; } 13 | public X509Certificate2 ServerCertificate { get; set; } 14 | public X509Certificate2 CertificateAuthority { get; set; } 15 | public bool AutoGenerateServerCertificate { get; set; } 16 | public string GeneratedServerCertificatePrefix { get; set; } 17 | 18 | 19 | public SslListenerChannel(Session session, TcpListener listener) : base(session, listener) { } 20 | 21 | protected override Channel CreateChildChannel(Session childSession, TcpClient acceptedClient) 22 | { 23 | var sslChannel = (SslChannel)childSession.CreateTcpChannel(acceptedClient, ssl: true); 24 | 25 | sslChannel.AuthenticateAsServer = true; 26 | sslChannel.SslProtocols = SslProtocols; 27 | sslChannel.RequireClientCertificate = RequireClientCertificate; 28 | sslChannel.IgnoreInvalidClientCertificate = IgnoreInvalidClientCertificate; 29 | sslChannel.ServerCertificate = ServerCertificate; 30 | sslChannel.CertificateAuthority = CertificateAuthority; 31 | sslChannel.AutoGenerateServerCertificate = AutoGenerateServerCertificate; 32 | sslChannel.GeneratedServerCertificatePrefix = GeneratedServerCertificatePrefix; 33 | 34 | return sslChannel; 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Source/Swiddler/Channels/TcpListenerChannel.cs: -------------------------------------------------------------------------------- 1 | using Swiddler.Common; 2 | using Swiddler.DataChunks; 3 | using System; 4 | using System.Net; 5 | using System.Net.Sockets; 6 | 7 | namespace Swiddler.Channels 8 | { 9 | public class TcpListenerChannel : Channel, IDisposable 10 | { 11 | public TcpListener Listener { get; } 12 | 13 | public TcpListenerChannel(Session session, TcpListener listener) : base(session) 14 | { 15 | Listener = listener; 16 | } 17 | 18 | protected override void OnReceiveNotification(Packet packet) 19 | { 20 | throw new NotImplementedException(); // channel is not intended to send packets into 21 | } 22 | 23 | protected override void StartOverride() 24 | { 25 | BeginAcceptTcpClient(); 26 | } 27 | 28 | void BeginAcceptTcpClient() 29 | { 30 | Listener.BeginAcceptTcpClient(AcceptTcpClientCallback, null); 31 | } 32 | 33 | private void AcceptTcpClientCallback(IAsyncResult result) 34 | { 35 | TcpClient client = null; 36 | try 37 | { 38 | client = Listener.EndAcceptTcpClient(result); 39 | var remoteEP = (IPEndPoint)client.Client.RemoteEndPoint; 40 | var child = Session.NewChildSession("Accepted connection from " + remoteEP, newSession => CreateChildChannel(newSession, client)); 41 | var tcpChannel = (TcpChannel)child.ServerChannel; 42 | tcpChannel.IsServerChannel = true; 43 | child.Name = $"{remoteEP}"; 44 | child.ResolveProcessIdAsync(remoteEP); 45 | child.StartAsync(); 46 | } 47 | catch (Exception ex) 48 | { 49 | HandleError(ex); 50 | } 51 | finally 52 | { 53 | if (client != null) BeginAcceptTcpClient(); // accept another one 54 | } 55 | } 56 | 57 | protected virtual Channel CreateChildChannel(Session childSession, TcpClient acceptedClient) 58 | { 59 | return childSession.CreateTcpChannel(acceptedClient); 60 | } 61 | 62 | public void Dispose() 63 | { 64 | Listener.Stop(); 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /Source/Swiddler/Channels/UdpChannel.cs: -------------------------------------------------------------------------------- 1 | using Swiddler.Common; 2 | using Swiddler.DataChunks; 3 | using System; 4 | using System.Net; 5 | using System.Net.Sockets; 6 | 7 | namespace Swiddler.Channels 8 | { 9 | public class UdpChannel : Channel, IDisposable 10 | { 11 | public UdpClient Client { get; } 12 | public IPEndPoint RemoteEndpoint { get; set; } 13 | public IPEndPoint LocalEndPoint { get; set; } 14 | 15 | bool connected; 16 | 17 | public UdpChannel(Session session, UdpClient client) : base(session) 18 | { 19 | Client = client; 20 | DefaultFlow = TrafficFlow.Inbound; 21 | } 22 | 23 | protected override void StartOverride() 24 | { 25 | connected = Client.Client.Connected; 26 | if (connected) RemoteEndpoint = (IPEndPoint)Client.Client.RemoteEndPoint; 27 | LocalEndPoint = (IPEndPoint)Client.Client.LocalEndPoint; 28 | BeginRead(); 29 | } 30 | 31 | void BeginRead() 32 | { 33 | try 34 | { 35 | Client.BeginReceive(ReceiveCallback, null); 36 | } 37 | catch (Exception ex) 38 | { 39 | HandleError(ex); 40 | } 41 | } 42 | 43 | private void ReceiveCallback(IAsyncResult result) 44 | { 45 | try 46 | { 47 | IPEndPoint remote = null; 48 | byte[] data = Client.EndReceive(result, ref remote); 49 | 50 | var packet = new Packet() 51 | { 52 | Payload = data, 53 | Source = remote, 54 | Destination = LocalEndPoint, 55 | }; 56 | 57 | NotifyObservers(packet); 58 | 59 | BeginRead(); 60 | } 61 | catch (Exception ex) 62 | { 63 | HandleError(ex); 64 | } 65 | } 66 | 67 | protected override void OnReceiveNotification(Packet packet) 68 | { 69 | try 70 | { 71 | if (packet.Source == null) packet.Source = LocalEndPoint; 72 | if (packet.Destination == null) packet.Destination = RemoteEndpoint; 73 | 74 | if (connected) 75 | { 76 | packet.Destination = RemoteEndpoint; 77 | Client.Send(packet.Payload, packet.Payload.Length); 78 | } 79 | else 80 | { 81 | Client.Send(packet.Payload, packet.Payload.Length, packet.Destination); 82 | } 83 | } 84 | catch (Exception ex) 85 | { 86 | HandleError(ex); 87 | } 88 | } 89 | 90 | public void Dispose() 91 | { 92 | Client.Close(); 93 | } 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /Source/Swiddler/ChunkViews/ChunkViewItem.cs: -------------------------------------------------------------------------------- 1 | using Swiddler.IO; 2 | using Swiddler.Rendering; 3 | using System; 4 | using System.Windows; 5 | 6 | namespace Swiddler.ChunkViews 7 | { 8 | public abstract class ChunkViewItem 9 | { 10 | public int FirstFragmentIndex { get; set; } = -1; 11 | public int LastFragmentIndex { get; set; } = -1; 12 | 13 | public Point Location { get; set; } 14 | 15 | public long BlockIndex { get; set; } 16 | 17 | public FragmentViewContent ViewContent { get; set; } 18 | 19 | public abstract IDataChunk BaseChunk { get; } 20 | 21 | /// 22 | /// Append fragments to 23 | /// 24 | public abstract void Build(); 25 | 26 | /// 27 | /// Method should resolve missing properties or and update . 28 | /// 29 | public virtual void PrepareSelectionAnchor(SelectionAnchorCaret caret) => throw new NotImplementedException(); 30 | } 31 | 32 | public abstract class ChunkViewItem : ChunkViewItem 33 | where TDataChunk : IDataChunk 34 | { 35 | public sealed override IDataChunk BaseChunk => Chunk; 36 | 37 | public TDataChunk Chunk { get; set; } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Source/Swiddler/ChunkViews/Selection.cs: -------------------------------------------------------------------------------- 1 | using Swiddler.DataChunks; 2 | using Swiddler.IO; 3 | using Swiddler.Rendering; 4 | using System; 5 | using System.Windows; 6 | 7 | namespace Swiddler.ChunkViews 8 | { 9 | public class SelectionAnchorCaret 10 | { 11 | public Rect Bounds { get; set; } 12 | public Fragment Fragment { get; set; } 13 | public SelectionAnchor Anchor { get; set; } 14 | 15 | public bool IsResolved => Fragment != null && Anchor != null; 16 | 17 | public override bool Equals(object obj) 18 | { 19 | var other = obj as SelectionAnchorCaret; 20 | var fragEquals = (Fragment == null && other?.Fragment == null ) || (Fragment?.Equals(other?.Fragment) ?? false); 21 | 22 | return 23 | Bounds.Equals(other?.Bounds) && 24 | Anchor.Equals(other?.Anchor) && 25 | fragEquals; 26 | } 27 | 28 | public override int GetHashCode() 29 | { 30 | return Bounds.GetHashCode() ^ Anchor.GetHashCode() ^ (Fragment?.GetHashCode() ?? 0); 31 | } 32 | } 33 | 34 | public class SelectionAnchor : IComparable 35 | { 36 | public IDataChunk Chunk { get; set; } 37 | /// 38 | /// Exact offset within chunk 39 | /// 40 | public int Offset { get; set; } 41 | 42 | public int CompareTo(SelectionAnchor other) 43 | { 44 | var seqCmp = Chunk.SequenceNumber.CompareTo(other.Chunk.SequenceNumber); 45 | return seqCmp == 0 ? Offset.CompareTo(other.Offset) : seqCmp; 46 | } 47 | 48 | public override bool Equals(object obj) 49 | { 50 | var other = obj as SelectionAnchor; 51 | return 52 | Chunk.SequenceNumber.Equals(other?.Chunk.SequenceNumber) && 53 | Offset.Equals(other?.Offset); 54 | } 55 | 56 | public override int GetHashCode() 57 | { 58 | return Chunk.SequenceNumber.GetHashCode() ^ Offset.GetHashCode(); 59 | } 60 | 61 | public override string ToString() 62 | { 63 | return $"Seq = {Chunk.SequenceNumber}; Offset = {Offset}"; 64 | } 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /Source/Swiddler/Commands/MiscCommands.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Input; 2 | 3 | namespace Swiddler.Commands 4 | { 5 | public static class MiscCommands 6 | { 7 | public static RoutedCommand QuickConnect { get; } = new RoutedCommand(nameof(QuickConnect), typeof(MiscCommands)); 8 | public static RoutedCommand Send { get; } = new RoutedCommand(nameof(Send), typeof(MiscCommands)); 9 | public static RoutedCommand Disconnect { get; } = new RoutedCommand(nameof(Disconnect), typeof(MiscCommands)); 10 | public static RoutedCommand Search { get; } = new RoutedCommand(nameof(Search), typeof(MiscCommands)); 11 | public static RoutedCommand SelectAll { get; } = new RoutedCommand(nameof(SelectAll), typeof(MiscCommands)); 12 | public static RoutedCommand GoToStart { get; } = new RoutedCommand(nameof(GoToStart), typeof(MiscCommands)); 13 | public static RoutedCommand GoToEnd { get; } = new RoutedCommand(nameof(GoToEnd), typeof(MiscCommands)); 14 | public static RoutedCommand ToggleHex { get; } = new RoutedCommand(nameof(ToggleHex), typeof(MiscCommands)); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Source/Swiddler/Common/BindableBase.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | using System.Runtime.CompilerServices; 3 | 4 | namespace Swiddler.Common 5 | { 6 | /// 7 | /// Implementation of to simplify models. 8 | /// 9 | public abstract class BindableBase : INotifyPropertyChanged 10 | { 11 | // source: https://www.danrigby.com/2015/09/12/inotifypropertychanged-the-net-4-6-way/ 12 | 13 | /// 14 | /// Multicast event for property change notifications. 15 | /// 16 | public event PropertyChangedEventHandler PropertyChanged; 17 | 18 | /// 19 | /// Checks if a property already matches a desired value. Sets the property and 20 | /// notifies listeners only when necessary. 21 | /// 22 | /// Type of the property. 23 | /// Reference to a property with both getter and setter. 24 | /// Desired value for the property. 25 | /// 26 | /// Name of the property used to notify listeners. This 27 | /// value is optional and can be provided automatically when invoked from compilers that 28 | /// support CallerMemberName. 29 | /// 30 | /// 31 | /// True if the value was changed, false if the existing value matched the 32 | /// desired value. 33 | /// 34 | protected bool SetProperty(ref T storage, T value, [CallerMemberName] string propertyName = null) 35 | { 36 | if (Equals(storage, value)) 37 | { 38 | return false; 39 | } 40 | 41 | storage = value; 42 | OnPropertyChanged(propertyName); 43 | return true; 44 | } 45 | 46 | /// 47 | /// Notifies listeners that a property value has changed. 48 | /// 49 | /// 50 | /// Name of the property used to notify listeners. This 51 | /// value is optional and can be provided automatically when invoked from compilers 52 | /// that support . 53 | /// 54 | protected void OnPropertyChanged([CallerMemberName] string propertyName = null) 55 | { 56 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /Source/Swiddler/Common/DeferredDataObject.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | 4 | namespace Swiddler.Common 5 | { 6 | public class DeferredDataObject : IDataObject 7 | { 8 | readonly DataObject _innerDataObject = new DataObject(); 9 | 10 | public object GetData(string format, bool autoConvert) 11 | { 12 | var data = _innerDataObject.GetData(format, autoConvert); 13 | 14 | if (data is Func func) 15 | data = func(); 16 | 17 | return data; 18 | } 19 | 20 | public void SetData(string format, Func data) => _innerDataObject.SetData(format, data); 21 | public void SetData(string format, Func data, bool autoConvert) => _innerDataObject.SetData(format, data, autoConvert); 22 | 23 | 24 | 25 | public object GetData(string format) => _innerDataObject.GetData(format); 26 | public object GetData(Type format) => _innerDataObject.GetData(format); 27 | public bool GetDataPresent(string format) => _innerDataObject.GetDataPresent(format); 28 | public bool GetDataPresent(Type format) => _innerDataObject.GetDataPresent(format); 29 | public bool GetDataPresent(string format, bool autoConvert) => _innerDataObject.GetDataPresent(format, autoConvert); 30 | public string[] GetFormats() => _innerDataObject.GetFormats(); 31 | public string[] GetFormats(bool autoConvert) => _innerDataObject.GetFormats(autoConvert); 32 | public void SetData(object data) => _innerDataObject.SetData(data); 33 | public void SetData(string format, object data) => _innerDataObject.SetData(format, data); 34 | public void SetData(Type format, object data) => _innerDataObject.SetData(format, data); 35 | public void SetData(string format, object data, bool autoConvert) => _innerDataObject.SetData(format, data, autoConvert); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Source/Swiddler/Common/DelayedInvoker.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Threading.Tasks; 4 | 5 | namespace Swiddler.Common 6 | { 7 | public class DelayedInvoker : IDisposable 8 | { 9 | public int Delay { get; set; } = 100; // milliseconds 10 | 11 | readonly object syncObj = new object(); 12 | readonly Stopwatch stopwatch = Stopwatch.StartNew(); 13 | 14 | Action action = null; 15 | Task delayedTask = null; 16 | bool disposed; 17 | 18 | public void Queue(Action action) 19 | { 20 | lock (syncObj) 21 | { 22 | if (disposed) return; // disposed 23 | this.action = action; 24 | if (delayedTask != null) return; // no need to call Flush 25 | } 26 | Flush(null); 27 | } 28 | 29 | void Flush(Task task) 30 | { 31 | if (stopwatch.ElapsedMilliseconds < Delay) 32 | { 33 | lock (syncObj) 34 | { 35 | if (delayedTask == null) 36 | delayedTask = Task.Delay(Delay).ContinueWith(Flush); 37 | } 38 | return; 39 | } 40 | 41 | while (stopwatch.ElapsedMilliseconds >= Delay) 42 | { 43 | stopwatch.Restart(); 44 | 45 | Action oldAction; 46 | lock (syncObj) 47 | { 48 | if (disposed) return; // disposed 49 | delayedTask = null; 50 | oldAction = action; 51 | action = null; 52 | } 53 | 54 | oldAction?.Invoke(); 55 | } 56 | } 57 | 58 | public void Dispose() 59 | { 60 | lock (syncObj) 61 | { 62 | disposed = true; 63 | action = null; 64 | } 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /Source/Swiddler/Common/ReloadableCollection.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Collections.ObjectModel; 4 | using System.Collections.Specialized; 5 | 6 | namespace Swiddler.Common 7 | { 8 | public interface IHasReload 9 | { 10 | void Reload(); 11 | } 12 | 13 | public class ReloadableCollection : ObservableCollection, IHasReload 14 | { 15 | readonly Func> itemsFactory; 16 | 17 | public ReloadableCollection(Func> itemsFactory) : base(itemsFactory()) 18 | { 19 | this.itemsFactory = itemsFactory; 20 | } 21 | 22 | public void Reload() 23 | { 24 | var list = (List)Items; 25 | var newItems = itemsFactory(); 26 | 27 | list.Clear(); 28 | list.AddRange(newItems); 29 | 30 | OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Source/Swiddler/Common/TrafficFlow.cs: -------------------------------------------------------------------------------- 1 | namespace Swiddler.Common 2 | { 3 | public enum TrafficFlow 4 | { 5 | Undefined, 6 | 7 | /// 8 | /// Reads 9 | /// 10 | Inbound, 11 | 12 | /// 13 | /// Writes 14 | /// 15 | Outbound, 16 | }; 17 | } 18 | -------------------------------------------------------------------------------- /Source/Swiddler/Common/ValueException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Swiddler.Common 4 | { 5 | public class ValueException : Exception 6 | { 7 | public ValueException(string propertyName, string message) : base(message) 8 | { 9 | PropertyName = propertyName; 10 | } 11 | 12 | public string PropertyName { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Source/Swiddler/Controls/ChunkView.xaml: -------------------------------------------------------------------------------- 1 |  5 | 6 | 33 | 34 | -------------------------------------------------------------------------------- /Source/Swiddler/Controls/ComboBoxEx.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Specialized; 2 | using System.Windows.Controls; 3 | 4 | namespace Swiddler.Controls 5 | { 6 | public class ComboBoxEx : ComboBox 7 | { 8 | private bool ignore = false; 9 | protected override void OnSelectionChanged(SelectionChangedEventArgs e) 10 | { 11 | if (!ignore) 12 | { 13 | base.OnSelectionChanged(e); 14 | } 15 | } 16 | 17 | protected override void OnItemsChanged(NotifyCollectionChangedEventArgs e) 18 | { 19 | if (IsEditable) 20 | ignore = true; 21 | 22 | try 23 | { 24 | base.OnItemsChanged(e); 25 | 26 | if (IsEditable) 27 | { 28 | var oldText = Text; 29 | Text = null; 30 | Text = oldText; // forces to update selection 31 | } 32 | } 33 | finally 34 | { 35 | ignore = false; 36 | } 37 | } 38 | 39 | 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Source/Swiddler/Controls/CrispImage.xaml: -------------------------------------------------------------------------------- 1 |  5 | 6 | 7 | 8 | 20 | 21 | -------------------------------------------------------------------------------- /Source/Swiddler/Controls/LockableToggleButton.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using System.Windows.Controls.Primitives; 3 | 4 | namespace Swiddler.Controls 5 | { 6 | public class LockableToggleButton : ToggleButton 7 | { 8 | protected override void OnToggle() 9 | { 10 | if (!LockToggle) 11 | { 12 | base.OnToggle(); 13 | } 14 | } 15 | 16 | public bool LockToggle 17 | { 18 | get { return (bool)GetValue(LockToggleProperty); } 19 | set { SetValue(LockToggleProperty, value); } 20 | } 21 | 22 | // Using a DependencyProperty as the backing store for LockToggle. This enables animation, styling, binding, etc... 23 | public static readonly DependencyProperty LockToggleProperty = 24 | DependencyProperty.Register(nameof(LockToggle), typeof(bool), typeof(LockableToggleButton), new UIPropertyMetadata(false)); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Source/Swiddler/Controls/SearchTextBox.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using System.Windows.Controls; 3 | 4 | namespace Swiddler.Controls 5 | { 6 | public class SearchTextBox : TextBox 7 | { 8 | static SearchTextBox() 9 | { 10 | // this is needed when style is defined in themes/generic.xaml 11 | DefaultStyleKeyProperty.OverrideMetadata(typeof(SearchTextBox), new FrameworkPropertyMetadata(typeof(SearchTextBox))); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Source/Swiddler/Controls/SessionListView.xaml: -------------------------------------------------------------------------------- 1 |  4 | 5 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /Source/Swiddler/Controls/TileButton.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using System.Windows.Controls; 3 | 4 | namespace Swiddler.Controls 5 | { 6 | public class TileButton : Button 7 | { 8 | static TileButton() 9 | { 10 | // this is needed when style is defined in themes/generic.xaml 11 | DefaultStyleKeyProperty.OverrideMetadata(typeof(TileButton), new FrameworkPropertyMetadata(typeof(TileButton))); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Source/Swiddler/Controls/TileButton.xaml: -------------------------------------------------------------------------------- 1 |  4 | 5 | 21 | 22 | -------------------------------------------------------------------------------- /Source/Swiddler/Controls/TreeToggleButton.cs: -------------------------------------------------------------------------------- 1 | using Swiddler.ViewModels; 2 | using System; 3 | using System.Windows; 4 | using System.Windows.Controls.Primitives; 5 | 6 | namespace Swiddler.Controls 7 | { 8 | public class TreeToggleButton : ToggleButton 9 | { 10 | static TreeToggleButton() 11 | { 12 | // this is needed when style is defined in themes/generic.xaml 13 | DefaultStyleKeyProperty.OverrideMetadata(typeof(TreeToggleButton), new FrameworkPropertyMetadata(typeof(TreeToggleButton))); 14 | } 15 | 16 | public static readonly RoutedEvent TreeToggleEvent = 17 | EventManager.RegisterRoutedEvent(nameof(TreeToggle), RoutingStrategy.Bubble, typeof(EventHandler), typeof(TreeToggleButton)); 18 | 19 | public event RoutedEventHandler TreeToggle 20 | { 21 | add { AddHandler(TreeToggleEvent, value); } 22 | remove { RemoveHandler(TreeToggleEvent, value); } 23 | } 24 | 25 | protected virtual void RaiseTreeToggleEvent() 26 | { 27 | RoutedEventArgs args = new RoutedEventArgs(TreeToggleEvent); 28 | RaiseEvent(args); 29 | } 30 | 31 | public TreeToggleButton() 32 | { 33 | Click += TreeToggleButton_Click; 34 | } 35 | 36 | private void TreeToggleButton_Click(object sender, RoutedEventArgs e) 37 | { 38 | RaiseEvent(new TreeToggleRoutedEventArgs(TreeToggleEvent, (SessionListItem)DataContext)); 39 | } 40 | } 41 | 42 | public class TreeToggleRoutedEventArgs : RoutedEventArgs 43 | { 44 | public SessionListItem Item { get; set; } 45 | 46 | public TreeToggleRoutedEventArgs(RoutedEvent routedEvent, SessionListItem item) 47 | :base(routedEvent) 48 | { 49 | Item = item; 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Source/Swiddler/Converters/AssignableTypeConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows.Data; 4 | using System.Windows.Markup; 5 | 6 | namespace Swiddler.Converters 7 | { 8 | public class AssignableTypeConverter : MarkupExtension, IValueConverter 9 | { 10 | public Type Type { get; set; } 11 | 12 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 13 | { 14 | if (value == null || Type == null) return false; 15 | return Type.IsAssignableFrom(value.GetType()); 16 | } 17 | 18 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 19 | { 20 | throw new NotImplementedException(); 21 | } 22 | 23 | public override object ProvideValue(IServiceProvider serviceProvider) 24 | { 25 | return this; 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Source/Swiddler/Converters/CertificateNameConverter.cs: -------------------------------------------------------------------------------- 1 | using Swiddler.Security; 2 | using System; 3 | using System.Globalization; 4 | using System.Security.Cryptography.X509Certificates; 5 | using System.Windows.Data; 6 | using System.Windows.Markup; 7 | 8 | namespace Swiddler.Converters 9 | { 10 | public class CertificateNameConverter : MarkupExtension, IValueConverter 11 | { 12 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 13 | { 14 | if (value is X509Certificate2 cert) 15 | { 16 | return cert.GetCertDisplayName(); 17 | } 18 | return null; 19 | } 20 | 21 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 22 | { 23 | throw new NotImplementedException(); 24 | } 25 | 26 | public override object ProvideValue(IServiceProvider serviceProvider) 27 | { 28 | return this; 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Source/Swiddler/Converters/CertificateThumbprintConverter.cs: -------------------------------------------------------------------------------- 1 | using Swiddler.MarkupExtensions; 2 | using Swiddler.Security; 3 | using System; 4 | using System.Globalization; 5 | using System.Linq; 6 | using System.Security.Cryptography.X509Certificates; 7 | using System.Windows.Data; 8 | using System.Windows.Markup; 9 | 10 | namespace Swiddler.Converters 11 | { 12 | public class CertificateThumbprintConverter : MarkupExtension, IValueConverter 13 | { 14 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 15 | { 16 | if (value is string thumbprint && !string.IsNullOrEmpty(thumbprint)) 17 | { 18 | var cert = X509.MyCurrentUserX509Store.Certificates 19 | .Find(X509FindType.FindByThumbprint, thumbprint, false) 20 | .OfType() 21 | .Where(c => c.HasPrivateKey).FirstOrDefault(); 22 | 23 | return (object)cert ?? thumbprint; 24 | } 25 | 26 | return null; 27 | } 28 | 29 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 30 | { 31 | if (value is string str) 32 | return str; 33 | if (value is X509Certificate2 cert) 34 | return cert.Thumbprint; 35 | 36 | return null; 37 | } 38 | 39 | public override object ProvideValue(IServiceProvider serviceProvider) 40 | { 41 | return this; 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Source/Swiddler/Converters/CertificateValidityConverter.cs: -------------------------------------------------------------------------------- 1 | using Swiddler.Security; 2 | using System; 3 | using System.Globalization; 4 | using System.Security.Cryptography.X509Certificates; 5 | using System.Windows.Data; 6 | using System.Windows.Input; 7 | using System.Windows.Markup; 8 | 9 | namespace Swiddler.Converters 10 | { 11 | public class CertificateValidityConverter : MarkupExtension, IValueConverter 12 | { 13 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 14 | { 15 | if (value is X509Certificate2 cert) 16 | { 17 | try 18 | { 19 | Mouse.OverrideCursor = Cursors.Wait; 20 | return cert.ValidateChain() ? "Valid" : "Invalid"; ; 21 | } 22 | finally 23 | { 24 | Mouse.OverrideCursor = null; 25 | } 26 | } 27 | 28 | return null; 29 | } 30 | 31 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 32 | { 33 | throw new NotImplementedException(); 34 | } 35 | 36 | public override object ProvideValue(IServiceProvider serviceProvider) 37 | { 38 | return this; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Source/Swiddler/Converters/EmptyStringConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows.Data; 4 | using System.Windows.Markup; 5 | 6 | namespace Swiddler.Converters 7 | { 8 | public class EmptyStringConverter : MarkupExtension, IValueConverter 9 | { 10 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 11 | { 12 | return string.IsNullOrEmpty(value as string); 13 | } 14 | 15 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 16 | { 17 | throw new NotImplementedException(); 18 | } 19 | 20 | public override object ProvideValue(IServiceProvider serviceProvider) 21 | { 22 | return this; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Source/Swiddler/Converters/FormatConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows.Data; 4 | using System.Windows.Markup; 5 | 6 | namespace Swiddler.Converters 7 | { 8 | public class FormatConverter : MarkupExtension, IValueConverter 9 | { 10 | public string Format { get; set; } 11 | 12 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 13 | { 14 | return string.Format(CultureInfo.CurrentCulture, Format, value); 15 | } 16 | 17 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 18 | { 19 | throw new NotImplementedException(); 20 | } 21 | 22 | public override object ProvideValue(IServiceProvider serviceProvider) 23 | { 24 | return this; 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Source/Swiddler/Converters/IntEnumConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Globalization; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows.Data; 8 | using System.Windows.Markup; 9 | 10 | namespace Swiddler.Converters 11 | { 12 | public class IntEnumConverter : MarkupExtension, IValueConverter 13 | { 14 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 15 | { 16 | return (int)value; 17 | } 18 | 19 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 20 | { 21 | return Enum.ToObject(targetType, value); 22 | } 23 | 24 | public override object ProvideValue(IServiceProvider serviceProvider) 25 | { 26 | return this; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Source/Swiddler/Converters/InvertBoolConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows.Data; 4 | using System.Windows.Markup; 5 | 6 | namespace Swiddler.Converters 7 | { 8 | public class InvertBoolConverter : MarkupExtension, IValueConverter 9 | { 10 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 11 | { 12 | return !(bool)value; 13 | } 14 | 15 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 16 | { 17 | throw new NotImplementedException(); 18 | } 19 | 20 | public override object ProvideValue(IServiceProvider serviceProvider) 21 | { 22 | return this; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Source/Swiddler/Converters/LazyBindingConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows.Data; 4 | using System.Windows.Markup; 5 | 6 | namespace Swiddler.Converters 7 | { 8 | public class LazyBindingConverter : MarkupExtension, IMultiValueConverter 9 | { 10 | object cachedValue; 11 | bool success; 12 | 13 | // params (bool, Lazy) 14 | public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) 15 | { 16 | if (success) return cachedValue; 17 | 18 | if (values.Length == 2 && values[0] as bool? == true) 19 | { 20 | success = true; 21 | return cachedValue = (values[1] as Lazy)?.Value; 22 | } 23 | 24 | return null; 25 | } 26 | 27 | public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) 28 | { 29 | throw new NotImplementedException(); 30 | } 31 | 32 | public override object ProvideValue(IServiceProvider serviceProvider) 33 | { 34 | return this; 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Source/Swiddler/Converters/ScrollBarVisibility.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows; 4 | using System.Windows.Data; 5 | using System.Windows.Markup; 6 | 7 | namespace Swiddler.Converters 8 | { 9 | public class ScrollBarVisibility : MarkupExtension, IMultiValueConverter 10 | { 11 | public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) 12 | { 13 | if (values.Length == 2 && values[0] is Visibility visibility) 14 | { 15 | if (visibility == Visibility.Visible) 16 | return visibility; 17 | else 18 | return values[1]; 19 | } 20 | 21 | return null; 22 | } 23 | 24 | public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) 25 | { 26 | throw new NotImplementedException(); 27 | } 28 | 29 | public override object ProvideValue(IServiceProvider serviceProvider) 30 | { 31 | return this; 32 | } 33 | 34 | 35 | public static readonly DependencyProperty NonVisibleValueProperty = 36 | DependencyProperty.RegisterAttached("NonVisibleValue", typeof(Visibility), typeof(ScrollBarVisibility), 37 | new FrameworkPropertyMetadata(Visibility.Collapsed, FrameworkPropertyMetadataOptions.Inherits)); 38 | 39 | public static Visibility GetNonVisibleValue(DependencyObject depo) => (Visibility)depo.GetValue(NonVisibleValueProperty); 40 | 41 | public static void SetNonVisibleValue(DependencyObject depo, Visibility value) => depo.SetValue(NonVisibleValueProperty, value); 42 | 43 | 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Source/Swiddler/Converters/SslVersionStringConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Globalization; 4 | using System.Linq; 5 | using System.Windows.Data; 6 | using System.Windows.Markup; 7 | 8 | namespace Swiddler.Converters 9 | { 10 | public class SslVersionStringConverter : MarkupExtension, IMultiValueConverter 11 | { 12 | static readonly string[] versionNames = new[] { "SSL 3.0", "TLS 1.0", "TLS 1.1", "TLS 1.2", "TLS 1.3" }; 13 | 14 | public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) 15 | { 16 | if (values.Length == versionNames.Length) 17 | { 18 | var states = values.Select(x => x as bool?).ToArray(); 19 | var list = new List(); 20 | 21 | for (int i = 0; i < states.Length; i++) 22 | if (states[i] == true) list.Add(versionNames[i]); 23 | 24 | if (list.Count == 0) 25 | return "No protocol version selected"; 26 | else 27 | return string.Join(", ", list); 28 | } 29 | 30 | return null; 31 | } 32 | 33 | public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) 34 | { 35 | throw new NotImplementedException(); 36 | } 37 | 38 | public override object ProvideValue(IServiceProvider serviceProvider) 39 | { 40 | return this; 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Source/Swiddler/Converters/TreeIndentConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows; 4 | using System.Windows.Data; 5 | 6 | namespace Swiddler.Converters 7 | { 8 | public class TreeIndentConverter : IValueConverter 9 | { 10 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 11 | { 12 | return new Thickness() 13 | { 14 | Left = (int)value * (int)parameter 15 | }; 16 | } 17 | 18 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 19 | { 20 | throw new NotImplementedException(); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Source/Swiddler/DataChunks/MessageData.cs: -------------------------------------------------------------------------------- 1 | using Swiddler.IO; 2 | using Swiddler.Serialization; 3 | using System; 4 | using System.IO; 5 | using System.Text; 6 | using System.Xml; 7 | using System.Xml.Serialization; 8 | 9 | namespace Swiddler.DataChunks 10 | { 11 | public enum MessageType : byte 12 | { 13 | Information, 14 | Error, 15 | SocketError, 16 | Connecting, 17 | ConnectionBanner, 18 | 19 | SerializedObject = 200, 20 | SslHandshake, 21 | } 22 | 23 | public class MessageData : IDataChunk 24 | { 25 | public DateTimeOffset Timestamp { get; set; } = DateTimeOffset.Now; 26 | public long ActualOffset { get; set; } 27 | public int ActualLength { get; set; } 28 | public long SequenceNumber { get; set; } 29 | 30 | public string Text { get; set; } 31 | public MessageType Type { get; set; } 32 | 33 | public MessageData() { } 34 | public MessageData(SslHandshake obj) { SetSerializedObject(obj); } 35 | 36 | private static readonly XmlWriterSettings writerSettings = new XmlWriterSettings { OmitXmlDeclaration = true, Indent = false, Encoding = new UTF8Encoding(false) }; 37 | private static readonly XmlSerializerNamespaces emptyNamespaces = new XmlSerializerNamespaces(new[] { new XmlQualifiedName("", "") }); 38 | 39 | /// 40 | /// When called, will contains XML serialized object. 41 | /// 42 | public MessageData SetSerializedObject(T obj) 43 | { 44 | if (obj is SslHandshake) 45 | Type = MessageType.SslHandshake; 46 | else 47 | throw new InvalidOperationException("Invalid type: " + obj.GetType()); 48 | 49 | var serializer = new XmlSerializer(typeof(T)); 50 | using (var strWriter = new StringWriter()) 51 | { 52 | using (var writer = XmlWriter.Create(strWriter, writerSettings)) 53 | serializer.Serialize(writer, obj, emptyNamespaces); 54 | 55 | Text = strWriter.ToString(); 56 | } 57 | 58 | return this; 59 | } 60 | 61 | public object GetSerializedObject() 62 | { 63 | switch (Type) 64 | { 65 | case MessageType.SslHandshake: 66 | return GetSerializedObject(); 67 | default: 68 | throw new InvalidOperationException("Invalid MessageType: " + Type); 69 | } 70 | } 71 | 72 | private T GetSerializedObject() 73 | { 74 | var serializer = new XmlSerializer(typeof(T)); 75 | using (var reader = new StringReader(Text)) 76 | { 77 | return (T)serializer.Deserialize(reader); 78 | } 79 | } 80 | 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /Source/Swiddler/DataChunks/Packet.cs: -------------------------------------------------------------------------------- 1 | using Swiddler.Common; 2 | using Swiddler.IO; 3 | using System; 4 | using System.Net; 5 | 6 | namespace Swiddler.DataChunks 7 | { 8 | public class Packet : IDataChunk 9 | { 10 | public DateTimeOffset Timestamp { get; set; } = DateTimeOffset.Now; 11 | public long ActualOffset { get; set; } 12 | public int ActualLength { get; set; } 13 | public long SequenceNumber { get; set; } 14 | 15 | public byte[] Payload { get; set; } 16 | 17 | public IPEndPoint Source { get; set; } 18 | public IPEndPoint Destination { get; set; } 19 | 20 | public TrafficFlow Flow { get; set; } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Source/Swiddler/IO/ChunkDictionary.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Swiddler.IO 4 | { 5 | /// 6 | /// Block of chunks. Sequence number is the key. 7 | /// 8 | public class ChunkDictionary : Dictionary 9 | { 10 | public long BlockIndex { get; set; } 11 | public bool IsValid { get; set; } 12 | 13 | public bool IsDirty { get; set; } // when data was written in currrent block 14 | 15 | public long FirstSequenceNumber { get; set; } 16 | public long LastSequenceNumber { get; set; } 17 | 18 | public IDataChunk FirstChunk => this[FirstSequenceNumber]; 19 | public IDataChunk LastChunk => this[LastSequenceNumber]; 20 | 21 | /// 22 | /// Find coresponding chunk where file offset belongs to. 23 | /// 24 | public long FindSequenceNumber(long offset) 25 | { 26 | long lower = FirstSequenceNumber, upper = LastSequenceNumber, middle; 27 | int comparisonResult; 28 | while (lower <= upper) // binary search 29 | { 30 | middle = lower + (upper - lower) / 2; 31 | comparisonResult = offset.CompareTo(this[middle].ActualOffset); 32 | if (comparisonResult < 0) 33 | upper = middle - 1; 34 | else if (comparisonResult > 0) 35 | lower = middle + 1; 36 | else 37 | return middle; 38 | } 39 | 40 | if (lower == FirstSequenceNumber) 41 | return lower; 42 | 43 | return lower - 1; // align to lower offset 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Source/Swiddler/IO/Constants.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text; 3 | 4 | namespace Swiddler.IO 5 | { 6 | public static class Constants 7 | { 8 | public static readonly UTF8Encoding UTF8Encoding = new UTF8Encoding(false, true); // UTF-8 without BOM header 9 | 10 | public const int BlockSize = 0x8000; // 32kB (best trade-off between fast random vs sequential access) 11 | 12 | 13 | /* Record Types */ 14 | public const byte UnusedData = 0; // jump to the next block 15 | 16 | public const byte InboundPacket = 1; // reads 17 | public const byte OutboundPacket = 2; // writes 18 | public const byte IPv6_Src = 4; 19 | public const byte IPv6_Dst = 8; 20 | 21 | public const byte MessageData = 100; 22 | 23 | 24 | 25 | /* Record Headers */ 26 | public const int PacketBaseHeaderSize = 27 | sizeof(byte) + // type : byte (1) 28 | sizeof(UInt16) + // block count : uint16 (2) 29 | sizeof(UInt32) + // length : uint32 (4) 30 | sizeof(UInt64) + // sequence number : uint64 (8) 31 | sizeof(Int64) + // time ticks utc : int64 (8) 32 | // src ip : byte (4/16) 33 | sizeof(UInt16) + // src port : uint16 (2) 34 | // dst ip : byte (4/16) 35 | sizeof(UInt16) ; // dst port : uint16 (2) 36 | 37 | public const int MessageHeaderSize = 38 | sizeof(byte) + // type : byte (1) 39 | sizeof(UInt16) + // block count : uint16 (2) 40 | sizeof(UInt32) + // length : uint32 (4) 41 | sizeof(UInt64) + // sequence number : uint64 (8) 42 | sizeof(Int64) + // time ticks utc : int64 (8) 43 | sizeof(byte) ; // message type : byte (1) 44 | 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Source/Swiddler/IO/IDataChunk.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Swiddler.IO 4 | { 5 | public interface IDataChunk 6 | { 7 | /// 8 | /// Time when data was captured. 9 | /// 10 | DateTimeOffset Timestamp { get; set; } 11 | 12 | /// 13 | /// Actual position of the data chunk in file including headers 14 | /// 15 | long ActualOffset { get; set; } 16 | /// 17 | /// Real length including headers 18 | /// 19 | int ActualLength { get; set; } 20 | 21 | /// 22 | /// Unique index of the chunk. 23 | /// 24 | long SequenceNumber { get; set; } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Source/Swiddler/IO/SyncedFileStream.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Security.Cryptography; 4 | using System.Text; 5 | using System.Threading; 6 | 7 | namespace Swiddler.IO 8 | { 9 | /// 10 | /// FileStream with cross-process locking mechanism 11 | /// 12 | public class SyncedFileStream : FileStream 13 | { 14 | public string PathHash { get; private set; } 15 | public Mutex Mutex { get; private set; } 16 | 17 | public bool DataAvailable => Position < Length; 18 | 19 | public event Action LastClosed; // notify handler when this is the last disposing stream for file 20 | 21 | readonly string mutexName; 22 | 23 | public SyncedFileStream(string path) : base(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite) 24 | { 25 | using (var hashAlgorithm = SHA1.Create()) 26 | PathHash = ByteToHexBitFiddle(hashAlgorithm.ComputeHash(Encoding.UTF8.GetBytes(Name.ToLower())), 10); 27 | 28 | mutexName = "1F6B1B5E9B734F76881." + PathHash; 29 | Mutex = new Mutex(false, mutexName); 30 | } 31 | 32 | public void Lock() 33 | { 34 | try 35 | { 36 | Mutex.WaitOne(); 37 | } 38 | catch (AbandonedMutexException) { } 39 | } 40 | 41 | public void Unlock() 42 | { 43 | Mutex.ReleaseMutex(); 44 | } 45 | 46 | protected override void Dispose(bool disposing) 47 | { 48 | if (disposing) 49 | { 50 | var mutexCopy = Mutex; 51 | Mutex = null; 52 | 53 | if (mutexCopy != null) 54 | { 55 | mutexCopy.Dispose(); 56 | } 57 | } 58 | 59 | base.Dispose(disposing); 60 | 61 | 62 | if (disposing && LastClosed != null) 63 | { 64 | if (Mutex.TryOpenExisting(mutexName, out Mutex tmp)) 65 | tmp.Dispose(); 66 | else 67 | LastClosed(); // raise event after stream was closed 68 | } 69 | } 70 | 71 | static string ByteToHexBitFiddle(byte[] bytes, int count) 72 | { 73 | char[] c = new char[count * 2]; 74 | int b; 75 | for (int i = 0; i < count; i++) 76 | { 77 | b = bytes[i] >> 4; 78 | c[i * 2] = (char)(55 + b + (((b - 10) >> 31) & -7)); 79 | b = bytes[i] & 0xF; 80 | c[i * 2 + 1] = (char)(55 + b + (((b - 10) >> 31) & -7)); 81 | } 82 | return new string(c); 83 | } 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /Source/Swiddler/Images/Adapter.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /Source/Swiddler/Images/Binary.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /Source/Swiddler/Images/Close.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /Source/Swiddler/Images/Connect.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /Source/Swiddler/Images/Connect_16x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jlucansky/Swiddler/5ff34a126c481f8757c7e40acd8507ac55359895/Source/Swiddler/Images/Connect_16x.png -------------------------------------------------------------------------------- /Source/Swiddler/Images/Connect_20x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jlucansky/Swiddler/5ff34a126c481f8757c7e40acd8507ac55359895/Source/Swiddler/Images/Connect_20x.png -------------------------------------------------------------------------------- /Source/Swiddler/Images/Connect_32x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jlucansky/Swiddler/5ff34a126c481f8757c7e40acd8507ac55359895/Source/Swiddler/Images/Connect_32x.png -------------------------------------------------------------------------------- /Source/Swiddler/Images/Connecting.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /Source/Swiddler/Images/Delete.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /Source/Swiddler/Images/Disconnect.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /Source/Swiddler/Images/Disconnected.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /Source/Swiddler/Images/Disconnected_32x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jlucansky/Swiddler/5ff34a126c481f8757c7e40acd8507ac55359895/Source/Swiddler/Images/Disconnected_32x.png -------------------------------------------------------------------------------- /Source/Swiddler/Images/Edit_16x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jlucansky/Swiddler/5ff34a126c481f8757c7e40acd8507ac55359895/Source/Swiddler/Images/Edit_16x.png -------------------------------------------------------------------------------- /Source/Swiddler/Images/Edit_20x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jlucansky/Swiddler/5ff34a126c481f8757c7e40acd8507ac55359895/Source/Swiddler/Images/Edit_20x.png -------------------------------------------------------------------------------- /Source/Swiddler/Images/Error.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /Source/Swiddler/Images/Eye.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /Source/Swiddler/Images/Forward.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /Source/Swiddler/Images/GearBlack.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /Source/Swiddler/Images/Gear_32x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jlucansky/Swiddler/5ff34a126c481f8757c7e40acd8507ac55359895/Source/Swiddler/Images/Gear_32x.png -------------------------------------------------------------------------------- /Source/Swiddler/Images/Go.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /Source/Swiddler/Images/Help_16x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jlucansky/Swiddler/5ff34a126c481f8757c7e40acd8507ac55359895/Source/Swiddler/Images/Help_16x.png -------------------------------------------------------------------------------- /Source/Swiddler/Images/Help_24x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jlucansky/Swiddler/5ff34a126c481f8757c7e40acd8507ac55359895/Source/Swiddler/Images/Help_24x.png -------------------------------------------------------------------------------- /Source/Swiddler/Images/HintIcon.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Source/Swiddler/Images/Info.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /Source/Swiddler/Images/Invalid.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Source/Swiddler/Images/LockInvalid.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /Source/Swiddler/Images/LockValid.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /Source/Swiddler/Images/OpenFolder.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /Source/Swiddler/Images/OpenFolder_16x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jlucansky/Swiddler/5ff34a126c481f8757c7e40acd8507ac55359895/Source/Swiddler/Images/OpenFolder_16x.png -------------------------------------------------------------------------------- /Source/Swiddler/Images/Port.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /Source/Swiddler/Images/Port_20x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jlucansky/Swiddler/5ff34a126c481f8757c7e40acd8507ac55359895/Source/Swiddler/Images/Port_20x.png -------------------------------------------------------------------------------- /Source/Swiddler/Images/Port_32x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jlucansky/Swiddler/5ff34a126c481f8757c7e40acd8507ac55359895/Source/Swiddler/Images/Port_32x.png -------------------------------------------------------------------------------- /Source/Swiddler/Images/Process.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /Source/Swiddler/Images/Process_20x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jlucansky/Swiddler/5ff34a126c481f8757c7e40acd8507ac55359895/Source/Swiddler/Images/Process_20x.png -------------------------------------------------------------------------------- /Source/Swiddler/Images/Process_32x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jlucansky/Swiddler/5ff34a126c481f8757c7e40acd8507ac55359895/Source/Swiddler/Images/Process_32x.png -------------------------------------------------------------------------------- /Source/Swiddler/Images/Run.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /Source/Swiddler/Images/Save.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /Source/Swiddler/Images/Search.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /Source/Swiddler/Images/Search_20x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jlucansky/Swiddler/5ff34a126c481f8757c7e40acd8507ac55359895/Source/Swiddler/Images/Search_20x.png -------------------------------------------------------------------------------- /Source/Swiddler/Images/Star.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Source/Swiddler/Images/Stop.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /Source/Swiddler/Images/Trash.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /Source/Swiddler/Images/Tunnel.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /Source/Swiddler/Images/Tunnel_32x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jlucansky/Swiddler/5ff34a126c481f8757c7e40acd8507ac55359895/Source/Swiddler/Images/Tunnel_32x.png -------------------------------------------------------------------------------- /Source/Swiddler/Images/Valid.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Source/Swiddler/Images/Watermark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jlucansky/Swiddler/5ff34a126c481f8757c7e40acd8507ac55359895/Source/Swiddler/Images/Watermark.png -------------------------------------------------------------------------------- /Source/Swiddler/Images/Watermark.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /Source/Swiddler/MarkupExtensions/CertificateSource.cs: -------------------------------------------------------------------------------- 1 | using Swiddler.Common; 2 | using Swiddler.Security; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Security.Cryptography.X509Certificates; 7 | using System.Windows.Markup; 8 | 9 | namespace Swiddler.MarkupExtensions 10 | { 11 | public class CertificateSource : MarkupExtension 12 | { 13 | public static readonly object EmptyItem = new object(); 14 | 15 | static readonly object[] arrayWithEmptyItem = new[] { EmptyItem }; 16 | 17 | public bool NoneAsFirstItem { get; set; } = true; 18 | public bool FilterKeyCertSign { get; set; } // only CAs 19 | public bool Lazy { get; set; } = true; 20 | 21 | public override object ProvideValue(IServiceProvider serviceProvider) 22 | { 23 | if (Lazy) 24 | return new Lazy(() => new ReloadableCollection(() => GetItems())); 25 | else 26 | return new ReloadableCollection(() => GetItems()); 27 | } 28 | 29 | public List GetItems() 30 | { 31 | var list = GetCollection().OfType().Where(x => x.HasPrivateKey); 32 | 33 | if (NoneAsFirstItem) 34 | return arrayWithEmptyItem.Concat(list).ToList(); 35 | 36 | return list.ToList(); 37 | } 38 | 39 | X509Certificate2Collection GetCollection() 40 | { 41 | var list = X509.MyCurrentUserX509Store.Certificates; 42 | 43 | if (FilterKeyCertSign) 44 | list = list.Find(X509FindType.FindByKeyUsage, "KeyCertSign", false); 45 | 46 | return list; 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Source/Swiddler/MarkupExtensions/DpiExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | using System.Windows.Markup; 4 | 5 | namespace Swiddler.MarkupExtensions 6 | { 7 | public class Dpi : MarkupExtension 8 | { 9 | public override object ProvideValue(IServiceProvider serviceProvider) => App.Current?.Res.Dpi ?? 96; 10 | } 11 | 12 | public class DpiScale : MarkupExtension 13 | { 14 | public override object ProvideValue(IServiceProvider serviceProvider) => App.Current?.Res.DpiScale ?? 1; 15 | } 16 | 17 | public class OneByDpiScale : MarkupExtension 18 | { 19 | public bool AsThickness { get; set; } 20 | 21 | public override object ProvideValue(IServiceProvider serviceProvider) 22 | { 23 | var val = App.Current?.Res.OneByDpiScale ?? 1; 24 | 25 | if (AsThickness) 26 | return new Thickness(val); 27 | return val; 28 | } 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /Source/Swiddler/MarkupExtensions/GroupedIPAddresses.cs: -------------------------------------------------------------------------------- 1 | using Swiddler.ViewModels; 2 | using System; 3 | using System.ComponentModel; 4 | using System.Globalization; 5 | using System.Net.Sockets; 6 | using System.Windows.Data; 7 | using System.Windows.Markup; 8 | 9 | namespace Swiddler.MarkupExtensions 10 | { 11 | public class GroupedIPAddresses : MarkupExtension 12 | { 13 | public AddressFamily? AddressFamily { get; set; } 14 | public bool Loopback { get; set; } = true; 15 | 16 | class IPAddressGroupDescription : GroupDescription 17 | { 18 | public override object GroupNameFromItem(object item, int level, CultureInfo culture) 19 | { 20 | var addr = (IPAddressItem)item; 21 | if (addr.IsAny || addr.IsLoopback) return IPAdapterEmptyHeader.Default; 22 | return new IPAdapterHeader(addr); 23 | } 24 | } 25 | 26 | public override object ProvideValue(IServiceProvider serviceProvider) 27 | { 28 | var addrViewSource = new CollectionViewSource(); 29 | addrViewSource.GroupDescriptions.Add(new IPAddressGroupDescription()); 30 | addrViewSource.Source = AddressFamily.HasValue ? IPAddressItem.GetAll(AddressFamily.Value, Loopback) : IPAddressItem.GetAll(); 31 | return addrViewSource.View; 32 | } 33 | 34 | public static object Value => new GroupedIPAddresses().ProvideValue(null); 35 | public static object Value_v4 => new GroupedIPAddresses() { AddressFamily = System.Net.Sockets.AddressFamily.InterNetwork }.ProvideValue(null); 36 | public static object Value_v6 => new GroupedIPAddresses() { AddressFamily = System.Net.Sockets.AddressFamily.InterNetworkV6 }.ProvideValue(null); 37 | 38 | public static object LazyValue => new Lazy(() => Value); 39 | public static object LazyValue_v4 => new Lazy(() => Value_v4); 40 | public static object LazyValue_v6 => new Lazy(() => Value_v6); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Source/Swiddler/MarkupExtensions/ShadowGlassFrameThickness.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | using System.Windows.Markup; 4 | 5 | namespace Swiddler.MarkupExtensions 6 | { 7 | public class ShadowGlassFrameThickness : MarkupExtension 8 | { 9 | static readonly Version shadowFromWinVer = new Version(6, 1); // 6.1 = Win7 10 | public override object ProvideValue(IServiceProvider serviceProvider) => GetThickness(); 11 | 12 | public static Thickness GetThickness() 13 | { 14 | if (Environment.OSVersion.Version > shadowFromWinVer) 15 | { 16 | // TODO: on windows 10 there is white line at the bottom :( 17 | return new Thickness(0) { Bottom = App.Current?.Res.OneByDpiScale ?? 1 }; 18 | } 19 | 20 | return new Thickness(0); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Source/Swiddler/MarkupExtensions/SslProtocolSupport.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Security.Authentication; 3 | using System.Windows.Markup; 4 | 5 | namespace Swiddler.MarkupExtensions 6 | { 7 | public class SslProtocolSupport : MarkupExtension 8 | { 9 | public string Name { get; set; } 10 | 11 | public override object ProvideValue(IServiceProvider serviceProvider) 12 | { 13 | if (string.IsNullOrEmpty(Name)) return null; 14 | return Enum.TryParse(Name, out _); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Source/Swiddler/NetworkSniffer/PacketFilter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Net; 4 | using System.Net.Sockets; 5 | 6 | namespace Swiddler.NetworkSniffer 7 | { 8 | class CaptureFilterItem 9 | { 10 | public IPEndPoint EP; 11 | public ProtocolType Protocol; 12 | } 13 | 14 | public class PacketFilter 15 | { 16 | readonly List rules = new List(); 17 | 18 | public void Add(IPEndPoint ep, ProtocolType protocol = ProtocolType.Unspecified) 19 | { 20 | if (ep.AddressFamily != AddressFamily.InterNetwork) 21 | throw new Exception("Only IPv4 is supported."); 22 | 23 | rules.Add(new CaptureFilterItem() { EP = ep, Protocol = protocol }); 24 | } 25 | 26 | public bool ShouldCapture(IPAddress source, IPAddress destination) 27 | { 28 | if (rules.Count == 0) 29 | return true; 30 | 31 | foreach (var filter in rules) 32 | { 33 | var addr = filter.EP.Address; 34 | if (addr.Equals(IPAddress.Any) || 35 | addr.Equals(source) || 36 | addr.Equals(destination)) 37 | return true; 38 | } 39 | 40 | return false; 41 | } 42 | 43 | public bool ShouldCapture(RawPacket packet) 44 | { 45 | if (rules.Count == 0) 46 | return true; 47 | 48 | foreach (var filter in rules) 49 | { 50 | if (filter.Protocol == ProtocolType.Unspecified || 51 | filter.Protocol == packet.Protocol) 52 | { 53 | var addr = filter.EP.Address; 54 | if (addr.Equals(IPAddress.Any) || 55 | addr.Equals(packet.Source.Address) || 56 | addr.Equals(packet.Destination.Address)) 57 | { 58 | var port = filter.EP.Port; 59 | if (port == 0 || 60 | port == packet.Source.Port || 61 | port == packet.Destination.Port) 62 | return true; 63 | } 64 | } 65 | } 66 | 67 | return false; 68 | } 69 | 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /Source/Swiddler/NetworkSniffer/RawPacket.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Net; 3 | using System.Net.Sockets; 4 | 5 | namespace Swiddler.NetworkSniffer 6 | { 7 | public class RawPacket 8 | { 9 | public IPVersion Version; 10 | 11 | public IPEndPoint Source, Destination; 12 | 13 | public ProtocolType Protocol = ProtocolType.Unspecified; 14 | 15 | public int HeaderLength; // = dataOffset 16 | public int DataLength; 17 | 18 | /// 19 | /// TCP/UDP checksum 20 | /// 21 | public int Checksum; 22 | 23 | public TCPFlags Flags; 24 | public uint Sequence, Acknowledgment; 25 | 26 | public uint Dropped; 27 | 28 | public byte[] Buffer; // includes full copy of IP headers + data 29 | 30 | 31 | internal bool Contains(long seq) 32 | { 33 | if (DataLength == 0) return Sequence == (uint)seq; 34 | return Sequence <= seq && seq < Sequence + DataLength; 35 | } 36 | 37 | public override string ToString() 38 | { 39 | return $"{Flags} | {Source} -> {Destination}, Len={DataLength}, Seq={Sequence}, Ack={Acknowledgment}"; 40 | } 41 | } 42 | 43 | public enum IPVersion 44 | { 45 | IPv4 = 4, 46 | IPv6 = 6, 47 | } 48 | 49 | [Flags] 50 | public enum TCPFlags 51 | { 52 | /// 53 | /// No more data from sender 54 | /// 55 | FIN = 0x1, 56 | 57 | /// 58 | /// Synchronize sequence numbers 59 | /// 60 | SYN = 0x2, 61 | 62 | /// 63 | /// Reset the connection 64 | /// 65 | RST = 0x4, 66 | 67 | /// 68 | /// Push data immediately to receiver 69 | /// 70 | PSH = 0x8, 71 | 72 | /// 73 | /// Acknowledgment field is significant 74 | /// 75 | ACK = 0x10, 76 | 77 | /// 78 | /// Urgent pointer is significant 79 | /// 80 | URG = 0x20, 81 | 82 | /// 83 | /// ECN-Echo [RFC3168] 84 | /// 85 | ECE = 0x40, 86 | 87 | /// 88 | /// Congestion Window Reduced [RFC3168] 89 | /// 90 | CWR = 0x80, 91 | 92 | /// 93 | /// Nonce sum [RFC3540, RFC3168] 94 | /// 95 | NS = 0x100 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /Source/Swiddler/NetworkSniffer/TCPParser.cs: -------------------------------------------------------------------------------- 1 | namespace Swiddler.NetworkSniffer 2 | { 3 | class TCPParser : PacketParserBase 4 | { 5 | public override bool ParseHeader(RawPacket packet) 6 | { 7 | var raw = packet.Buffer; 8 | var p = packet.HeaderLength; // IP header 9 | 10 | if (packet.DataLength < 20) 11 | return false; // too small 12 | 13 | packet.Source.Port = (raw[p++] << 8) | raw[p++]; 14 | packet.Destination.Port = (raw[p++] << 8) | raw[p++]; 15 | 16 | packet.Sequence = GetUInt32(raw, p); p += 4; 17 | packet.Acknowledgment = GetUInt32(raw, p); p += 4; 18 | 19 | var dataOffset = (raw[p] & 0xF0) >> 4; 20 | 21 | if (dataOffset < 5 || dataOffset > 15) 22 | return false; 23 | 24 | if ((raw[p++] & 0x01) != 0) packet.Flags |= TCPFlags.NS; 25 | 26 | if ((raw[p] & 0x80) != 0) packet.Flags |= TCPFlags.CWR; 27 | if ((raw[p] & 0x40) != 0) packet.Flags |= TCPFlags.ECE; 28 | if ((raw[p] & 0x20) != 0) packet.Flags |= TCPFlags.URG; 29 | if ((raw[p] & 0x10) != 0) packet.Flags |= TCPFlags.ACK; 30 | if ((raw[p] & 0x08) != 0) packet.Flags |= TCPFlags.PSH; 31 | if ((raw[p] & 0x04) != 0) packet.Flags |= TCPFlags.RST; 32 | if ((raw[p] & 0x02) != 0) packet.Flags |= TCPFlags.SYN; 33 | if ((raw[p] & 0x01) != 0) packet.Flags |= TCPFlags.FIN; 34 | 35 | p += 2; // ignore window size 36 | packet.Checksum = (raw[p++] << 8) + raw[p++]; 37 | 38 | var dataByteOffset = dataOffset * 4; 39 | packet.HeaderLength += dataByteOffset; 40 | packet.DataLength -= dataByteOffset; 41 | 42 | return true; 43 | } 44 | 45 | uint GetUInt32(byte[] buffer, int index) 46 | { 47 | return (uint)( 48 | (buffer[index++] << 24) | 49 | (buffer[index++] << 16) | 50 | (buffer[index++] << 8) | 51 | buffer[index]); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Source/Swiddler/NetworkSniffer/UDPParser.cs: -------------------------------------------------------------------------------- 1 | namespace Swiddler.NetworkSniffer 2 | { 3 | class UDPParser : PacketParserBase 4 | { 5 | public override bool ParseHeader(RawPacket packet) 6 | { 7 | if (packet.DataLength < 8) 8 | return false; // too small 9 | 10 | var raw = packet.Buffer; 11 | var p = packet.HeaderLength; // IP header 12 | 13 | packet.Source.Port = (raw[p++] << 8) | raw[p++]; 14 | packet.Destination.Port = (raw[p++] << 8) | raw[p++]; 15 | 16 | p += 2; // ignore Length field 17 | 18 | packet.Checksum = (raw[p++] << 8) + raw[p++]; 19 | 20 | packet.HeaderLength += 8; 21 | packet.DataLength -= 8; 22 | 23 | return true; 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Source/Swiddler/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Resources; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | using System.Windows; 6 | using System.Windows.Markup; 7 | 8 | // General Information about an assembly is controlled through the following 9 | // set of attributes. Change these attribute values to modify the information 10 | // associated with an assembly. 11 | [assembly: AssemblyTitle("Swiddler")] 12 | [assembly: AssemblyDescription("TCP/UDP debugging tool")] 13 | [assembly: AssemblyCompany("Jan Lucansky")] 14 | [assembly: AssemblyProduct("Swiddler")] 15 | [assembly: AssemblyCopyright("Copyright © 2018-2020 Jan Lucansky")] 16 | 17 | #if DEBUG 18 | [assembly: AssemblyConfiguration("Debug")] 19 | #else 20 | [assembly: AssemblyConfiguration("Release")] 21 | #endif 22 | 23 | // Setting ComVisible to false makes the types in this assembly not visible 24 | // to COM components. If you need to access a type in this assembly from 25 | // COM, set the ComVisible attribute to true on that type. 26 | [assembly: ComVisible(false)] 27 | 28 | //In order to begin building localizable applications, set 29 | //CultureYouAreCodingWith in your .csproj file 30 | //inside a . For example, if you are using US english 31 | //in your source files, set the to en-US. Then uncomment 32 | //the NeutralResourceLanguage attribute below. Update the "en-US" in 33 | //the line below to match the UICulture setting in the project file. 34 | 35 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] 36 | 37 | 38 | [assembly: ThemeInfo( 39 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 40 | //(used if a resource is not found in the page, 41 | // or application resource dictionaries) 42 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 43 | //(used if a resource is not found in the page, 44 | // app, or any theme specific resource dictionaries) 45 | )] 46 | 47 | 48 | // Version information for an assembly consists of the following four values: 49 | // 50 | // Major Version 51 | // Minor Version 52 | // Build Number 53 | // Revision 54 | // 55 | [assembly: AssemblyVersion("1.0.0.0")] 56 | [assembly: AssemblyFileVersion("1.0.6.2012")] 57 | 58 | [assembly: AssemblyInformationalVersion("1.0.6")] 59 | -------------------------------------------------------------------------------- /Source/Swiddler/Rendering/ConnectionFragment.cs: -------------------------------------------------------------------------------- 1 | using Swiddler.Common; 2 | using Swiddler.Views.Fragments; 3 | using System; 4 | 5 | namespace Swiddler.Rendering 6 | { 7 | public class ConnectionFragment : Fragment 8 | { 9 | public override Type VisualType => typeof(ConnectionView); 10 | 11 | public ConnectionBanner Model { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Source/Swiddler/Rendering/DrawingFragment.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | using System.Windows.Media; 4 | 5 | namespace Swiddler.Rendering 6 | { 7 | public abstract class DrawingFragment : Fragment 8 | { 9 | public override Type VisualType => typeof(DrawingVisual); 10 | 11 | protected override void Refresh() 12 | { 13 | var drawingVisual = (DrawingVisual)Visual; 14 | 15 | using (var context = drawingVisual.RenderOpen()) 16 | { 17 | OnRender(context, Bounds); 18 | } 19 | } 20 | 21 | public abstract void OnRender(DrawingContext drawingContext, Rect bounds); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Source/Swiddler/Rendering/FragmentViewMetrics.cs: -------------------------------------------------------------------------------- 1 | using System.Text; 2 | using System.Windows; 3 | using System.Windows.Media; 4 | 5 | namespace Swiddler.Rendering 6 | { 7 | public class FragmentViewMetrics 8 | { 9 | public double CurrentLineIndex { get; set; } // VerticalOffset 10 | public double LinesCountApprox { get; set; } // update after append 11 | public long StartFileOffset { get; set; } 12 | public long CurrentFileOffset { get; set; } // set with SetVerticalOffset/SetFileOffset 13 | public long MaxFileLength { get; set; } // update after Append 14 | public double LinesPerPage { get; set; } // set on MeasureOverride 15 | public double OverExtentLines { get; set; } 16 | public Size Viewport { get; set; } 17 | public Encoding Encoding { get; set; } 18 | public Typeface Typeface { get; set; } 19 | public double FontSize { get; set; } 20 | 21 | public long UsableFileLength => MaxFileLength - StartFileOffset; 22 | 23 | public double GetLineFromOffset (long fileOffset) => (fileOffset - StartFileOffset) / (double)UsableFileLength * LinesCountApprox; 24 | public long GetOffsetFromLine(double lineIndex) => (long)(lineIndex / LinesCountApprox * UsableFileLength) + StartFileOffset; 25 | 26 | public bool InViewport(Point point) => point.X >= 0 && point.Y >= 0 && point.X < Viewport.Width && point.Y < Viewport.Height; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Source/Swiddler/Rendering/MessageFragment.cs: -------------------------------------------------------------------------------- 1 | using Swiddler.Views.Fragments; 2 | using System; 3 | 4 | namespace Swiddler.Rendering 5 | { 6 | public class MessageFragment : Fragment 7 | { 8 | public override Type VisualType => typeof(MessageView); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Source/Swiddler/Rendering/PolygonFigure.cs: -------------------------------------------------------------------------------- 1 |  2 | using System.Windows; 3 | using System.Linq; 4 | 5 | namespace Swiddler.Rendering 6 | { 7 | public class PolygonFigure 8 | { 9 | public Point StartPoint; 10 | public Point[] Points; 11 | 12 | public Rect[] HitRects { get; set; } 13 | 14 | public PolygonFigure(Point startPoint, params Point[] points) 15 | { 16 | StartPoint = startPoint; 17 | Points = points; 18 | } 19 | 20 | public static PolygonFigure operator +(PolygonFigure polygon, Vector vector) 21 | { 22 | var oldPoints = polygon.Points; 23 | var len = oldPoints.Length; 24 | var newPoints = new Point[len]; 25 | 26 | for (int i = 0; i < len; i++) 27 | newPoints[i] = oldPoints[i] + vector; 28 | 29 | return new PolygonFigure(polygon.StartPoint + vector, newPoints); 30 | } 31 | 32 | public static PolygonFigure operator -(PolygonFigure polygon, Vector vector) 33 | { 34 | var oldPoints = polygon.Points; 35 | var len = oldPoints.Length; 36 | var newPoints = new Point[len]; 37 | 38 | for (int i = 0; i < len; i++) 39 | newPoints[i] = oldPoints[i] - vector; 40 | 41 | return new PolygonFigure(polygon.StartPoint - vector, newPoints); 42 | } 43 | 44 | public bool Contains(Point point) 45 | { 46 | return HitRects?.Any(x => x.Contains(point)) == true; 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Source/Swiddler/Rendering/SslHandshakeFragment.cs: -------------------------------------------------------------------------------- 1 | using Swiddler.Security; 2 | using Swiddler.Serialization; 3 | using Swiddler.Views.Fragments; 4 | using System; 5 | using System.Linq; 6 | 7 | namespace Swiddler.Rendering 8 | { 9 | public class SslHandshakeFragment : Fragment 10 | { 11 | public override Type VisualType => typeof(SslHandshakeView); 12 | 13 | public SslHandshake Model { get; set; } 14 | 15 | public string IconName => Model.IsValid() ? "LockValid" : "LockInvalid"; 16 | 17 | public string ToolTip 18 | { 19 | get 20 | { 21 | var chain = Model.GetPrimaryCertificateChain(); 22 | if (chain?.Any() != true) return null; 23 | string result = ""; 24 | int level = 0; 25 | foreach (var crt in chain.Reverse()) 26 | { 27 | if (level > 0) result += $"{Environment.NewLine}{new string(' ', (level - 1) * 4)}▶ "; 28 | result += crt.GetCertDisplayName(); 29 | level++; 30 | } 31 | return result; 32 | } 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Source/Swiddler/Rendering/TextFragment.cs: -------------------------------------------------------------------------------- 1 | using System.Text; 2 | using System.Windows; 3 | using System.Windows.Media; 4 | 5 | namespace Swiddler.Rendering 6 | { 7 | public class TextFragment : DrawingFragment 8 | { 9 | public byte[] Data { get; set; } 10 | 11 | public int Offset { get; set; } 12 | public int Length { get; set; } 13 | 14 | public Brush Brush { get; set; } = Brushes.Black; 15 | 16 | public Encoding Encoding { get; set; } 17 | 18 | public override void OnRender(DrawingContext drawingContext, Rect bounds) 19 | { 20 | if (Length == 0) 21 | return; 22 | 23 | GlyphTypeface glyphTypeface = View.Content.GlyphTypeface; 24 | 25 | var advanceWidths = new double[Length]; 26 | var glyphIndices = View.Content.GetGlyphIndices(Data, Offset, Length); 27 | 28 | double charWidth = View.Content.CharWidth; 29 | double fontSize = View.Content.LineHeight - 2; // keep padding 30 | 31 | for (int n = 0; n < Length; n++) advanceWidths[n] = charWidth; 32 | 33 | var baseline = new Point(0, View.Content.SnapToPixelsY(glyphTypeface.Baseline * fontSize + 1.5, ceiling: true)); 34 | 35 | GlyphRun run = new GlyphRun(glyphTypeface, 36 | bidiLevel: 0, 37 | isSideways: false, 38 | renderingEmSize: fontSize, 39 | glyphIndices: glyphIndices, 40 | baselineOrigin: baseline, 41 | advanceWidths: advanceWidths, 42 | glyphOffsets: null, 43 | characters: null, 44 | deviceFontName: null, 45 | clusterMap: null, 46 | caretStops: null, 47 | language: null); 48 | 49 | drawingContext.PushTransform(new TranslateTransform(bounds.X, bounds.Y)); 50 | drawingContext.DrawGlyphRun(Brush, run); 51 | drawingContext.Pop(); 52 | } 53 | 54 | public override string ToString() 55 | { 56 | return Encoding.GetString(Data, Offset, Length); 57 | } 58 | 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /Source/Swiddler/Rendering/VisualPool.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq.Expressions; 4 | using System.Windows.Media; 5 | 6 | namespace Swiddler.Rendering 7 | { 8 | public class VisualPool : IDisposable 9 | { 10 | readonly Func CreateVisual; 11 | readonly Stack items = new Stack(); 12 | 13 | static readonly Type[] emptyTypes = new Type[0]; 14 | 15 | public VisualPool(Type visualType) 16 | { 17 | // faster instantiation 18 | CreateVisual = Expression.Lambda>(Expression.New(visualType.GetConstructor(emptyTypes))).Compile(); 19 | } 20 | 21 | public Visual GetFresh() 22 | { 23 | if (items.Count == 0) 24 | return CreateVisual(); 25 | 26 | return items.Pop(); 27 | } 28 | 29 | public void Recycle(Visual visual) 30 | { 31 | items.Push(visual); 32 | } 33 | 34 | public void Dispose() 35 | { 36 | foreach (var item in items) 37 | (item as IDisposable)?.Dispose(); 38 | items.Clear(); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Source/Swiddler/Resources/Brushes.xaml: -------------------------------------------------------------------------------- 1 |  3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 56 | -------------------------------------------------------------------------------- /Source/Swiddler/Resources/Misc.xaml: -------------------------------------------------------------------------------- 1 |  5 | 6 | 7 | M12.7,3.3l-9.4,9.4 M3.3,3.3l9.4,9.4 8 | 9 | 10 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /Source/Swiddler/Resources/netprobe32.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jlucansky/Swiddler/5ff34a126c481f8757c7e40acd8507ac55359895/Source/Swiddler/Resources/netprobe32.dll -------------------------------------------------------------------------------- /Source/Swiddler/Resources/netprobe64.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jlucansky/Swiddler/5ff34a126c481f8757c7e40acd8507ac55359895/Source/Swiddler/Resources/netprobe64.dll -------------------------------------------------------------------------------- /Source/Swiddler/Security/SslAlert.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Swiddler.Security 4 | { 5 | public class SslAlertException : Exception 6 | { 7 | public int MajorVersion { get; set; } 8 | public int MinorVersion { get; set; } 9 | public int Level { get; set; } // warning(1), fatal(2) 10 | public SslAlertDescription Description { get; set; } 11 | 12 | public override string Message => GetMessage(); 13 | 14 | string GetMessage() 15 | { 16 | string sLevel = null; 17 | 18 | if (Level == 1) 19 | sLevel = "warning"; 20 | else if (Level == 2) 21 | sLevel = "fatal"; 22 | 23 | if (sLevel != null) 24 | return $"SSL/TLS Alert: 0x{((int)Description):X2}, {Description} ({sLevel})"; 25 | else 26 | return "Unknown SSL/TLS Alert"; 27 | } 28 | } 29 | 30 | //https://tools.ietf.org/html/rfc5246#section-7.2 31 | public enum SslAlertDescription : byte 32 | { 33 | CLOSE_NOTIFY = 0, 34 | UNEXPECTED_MESSAGE = 10, 35 | BAD_RECORD_MAC = 20, 36 | DECRYPTION_FAILED_RESERVED = 21, 37 | RECORD_OVERFLOW = 22, 38 | DECOMPRESSION_FAILURE = 30, 39 | HANDSHAKE_FAILURE = 40, 40 | NO_CERTIFICATE_RESERVED = 41, 41 | BAD_CERTIFICATE = 42, 42 | UNSUPPORTED_CERTIFICATE = 43, 43 | CERTIFICATE_REVOKED = 44, 44 | CERTIFICATE_EXPIRED = 45, 45 | CERTIFICATE_UNKNOWN = 46, 46 | ILLEGAL_PARAMETER = 47, 47 | UNKNOWN_CA = 48, 48 | ACCESS_DENIED = 49, 49 | DECODE_ERROR = 50, 50 | DECRYPT_ERROR = 51, 51 | EXPORT_RESTRICTION_RESERVED = 60, 52 | PROTOCOL_VERSION = 70, 53 | INSUFFICIENT_SECURITY = 71, 54 | INTERNAL_ERROR = 80, 55 | INAPPROPRIATE_FALLBACK = 86, 56 | USER_CANCELED = 90, 57 | MISSING_EXTENSION = 109, 58 | NO_RENEGOTIATION = 100, 59 | UNSUPPORTED_EXTENSION = 110, 60 | UNRECOGNIZED_NAME = 112, 61 | BAD_CERTIFICATE_STATUS_RESPONSE = 113, 62 | UNKNOWN_PSK_IDENTITY = 115, 63 | CERTIFICATE_REQUIRED = 116, 64 | NO_APPLICATION_PROTOCOL = 120, 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /Source/Swiddler/Security/SslClientHello.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Xml.Serialization; 4 | 5 | namespace Swiddler.Security 6 | { 7 | /// 8 | /// Wraps up the client SSL hello information. 9 | /// 10 | public class SslClientHello : SslHelloBase 11 | { 12 | public int[] Ciphers { get; set; } 13 | 14 | [XmlIgnore] public byte[] CompressionData { get; set; } 15 | [XmlElement(nameof(CompressionData))] public string CompressionDataEncoded { get => CompressionData == null ? null : Convert.ToBase64String(CompressionData); set => CompressionData = value == null ? null : Convert.FromBase64String(value); } 16 | 17 | 18 | public string[] GetCipherSuites() 19 | { 20 | return Ciphers?.Select(x => SslCiphers.GetName(x)).ToArray(); 21 | } 22 | 23 | public string GetServerNameIndication() 24 | { 25 | if (Extensions != null && 26 | Extensions.TryGetValue("server_name", out var sslExtension) && 27 | sslExtension?.GetExtensionData() is string[] data) 28 | { 29 | return data.FirstOrDefault(); 30 | } 31 | 32 | return null; 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Source/Swiddler/Security/SslHelloBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Collections.Generic; 4 | using System.Xml.Serialization; 5 | 6 | namespace Swiddler.Security 7 | { 8 | public abstract class SslHelloBase 9 | { 10 | [XmlAttribute] public int HandshakeVersion { get; set; } 11 | 12 | [XmlAttribute] public int MajorVersion { get; set; } 13 | [XmlAttribute] public int MinorVersion { get; set; } 14 | 15 | [XmlIgnore] public byte[] Random { get; set; } 16 | [XmlElement(nameof(Random))] public string RandomEncoded { get => Convert.ToBase64String(Random); set => Random = Convert.FromBase64String(value); } 17 | 18 | [XmlIgnore] public byte[] SessionId { get; set; } 19 | [XmlElement(nameof(SessionId))] public string SessionIdEncoded { get => Convert.ToBase64String(SessionId); set => SessionId = Convert.FromBase64String(value); } 20 | 21 | [XmlIgnore] public Dictionary Extensions { get; set; } 22 | [XmlElement("Extension")] 23 | public SslExtension[] ExtensionsList { get => Extensions?.Values.ToArray(); set => Extensions = value?.ToDictionary(x => x.Name); } 24 | 25 | private string SslVersionToString() 26 | { 27 | int major = MajorVersion, minor = MinorVersion; 28 | 29 | string str = "Unknown"; 30 | if (major == 3 && minor == 4) 31 | str = "TLS/1.3"; 32 | else if (major == 3 && minor == 3) 33 | str = "TLS/1.2"; 34 | else if (major == 3 && minor == 2) 35 | str = "TLS/1.1"; 36 | else if (major == 3 && minor == 1) 37 | str = "TLS/1.0"; 38 | else if (major == 3 && minor == 0) 39 | str = "SSL/3.0"; 40 | else if (major == 2 && minor == 0) 41 | str = "SSL/2.0"; 42 | 43 | return str; 44 | } 45 | 46 | public override string ToString() => SslVersionToString(); 47 | 48 | public string ProtocolVersion => SslVersionToString(); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Source/Swiddler/Security/SslServerHello.cs: -------------------------------------------------------------------------------- 1 | namespace Swiddler.Security 2 | { 3 | /// 4 | /// Wraps up the server SSL hello information. 5 | /// 6 | public class SslServerHello : SslHelloBase 7 | { 8 | public int CipherSuite { get; set; } 9 | public string CipherSuiteName => SslCiphers.GetName(CipherSuite); 10 | 11 | public byte CompressionMethod { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Source/Swiddler/Serialization/Pcap/PcapPacket.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics.Contracts; 3 | 4 | 5 | namespace Swiddler.Serialization.Pcap 6 | { 7 | public class PcapPacket 8 | { 9 | /// 10 | /// ts_sec: the date and time when this packet was captured. This value is in seconds since January 1, 1970 00:00:00 GMT; 11 | /// this is also known as a UN*X time_t. You can use the ANSI C time() function from time.h to get this value, but you might use 12 | /// a more optimized way to get this timestamp value. If this timestamp isn't based on GMT (UTC), use thiszone from the global header 13 | /// for adjustments. 14 | /// 15 | public UInt64 Seconds 16 | { 17 | get; 18 | set; 19 | } 20 | 21 | /// 22 | /// ts_usec: in regular pcap files, the microseconds when this packet was captured, as an offset to ts_sec. 23 | /// In nanosecond-resolution files, this is, instead, the nanoseconds when the packet was captured, as an offset to ts_sec /!\ 24 | /// Beware: this value shouldn't reach 1 second (in regular pcap files 1 000 000; in nanosecond-resolution files, 1 000 000 000); 25 | /// in this case ts_sec must be increased instead! 26 | /// 27 | public UInt64 Microseconds 28 | { 29 | get; 30 | set; 31 | } 32 | 33 | /// 34 | /// packet data 35 | /// 36 | public byte[] Data 37 | { 38 | get; 39 | set; 40 | } 41 | 42 | /// 43 | /// packet position in the stream (set when reading from the stream. ) 44 | /// 45 | public long PositionInStream 46 | { 47 | get; 48 | set; 49 | } 50 | public PcapPacket(UInt64 secs, UInt64 usecs, byte[] data, long positionInStream = 0) 51 | { 52 | this.Seconds = secs; 53 | this.Microseconds = usecs; 54 | this.Data = data; 55 | this.PositionInStream = positionInStream; 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /Source/Swiddler/Serialization/Pcap/ReverseByteOrderExtension.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Swiddler.Serialization.Pcap 4 | { 5 | public static class ReverseByteOrderExtension 6 | { 7 | #region Extenstion method 8 | public static UInt32 ReverseByteOrder(this UInt32 value,bool reverseByteOrder) 9 | { 10 | if (!reverseByteOrder) 11 | return value; 12 | else 13 | { 14 | byte[] bytes = BitConverter.GetBytes(value); 15 | Array.Reverse(bytes); 16 | return BitConverter.ToUInt32(bytes, 0); 17 | } 18 | } 19 | 20 | public static Int32 ReverseByteOrder(this Int32 value, bool reverseByteOrder) 21 | { 22 | if (!reverseByteOrder) 23 | return value; 24 | else 25 | { 26 | byte[] bytes = BitConverter.GetBytes(value); 27 | Array.Reverse(bytes); 28 | return BitConverter.ToInt32(bytes, 0); 29 | } 30 | } 31 | 32 | public static UInt16 ReverseByteOrder(this UInt16 value, bool reverseByteOrder) 33 | { 34 | if (!reverseByteOrder) 35 | return value; 36 | else 37 | { 38 | byte[] bytes = BitConverter.GetBytes(value); 39 | Array.Reverse(bytes); 40 | return BitConverter.ToUInt16(bytes, 0); 41 | } 42 | } 43 | 44 | public static Int16 ReverseByteOrder(this Int16 value, bool reverseByteOrder) 45 | { 46 | if (!reverseByteOrder) 47 | return value; 48 | else 49 | { 50 | byte[] bytes = BitConverter.GetBytes(value); 51 | Array.Reverse(bytes); 52 | return BitConverter.ToInt16(bytes, 0); 53 | } 54 | } 55 | 56 | public static UInt64 ReverseByteOrder(this UInt64 value, bool reverseByteOrder) 57 | { 58 | if (!reverseByteOrder) 59 | return value; 60 | else 61 | { 62 | byte[] bytes = BitConverter.GetBytes(value); 63 | Array.Reverse(bytes); 64 | return BitConverter.ToUInt64(bytes, 0); 65 | } 66 | } 67 | 68 | public static Int64 ReverseByteOrder(this Int64 value, bool reverseByteOrder) 69 | { 70 | if (!reverseByteOrder) 71 | return value; 72 | else 73 | { 74 | byte[] bytes = BitConverter.GetBytes(value); 75 | Array.Reverse(bytes); 76 | return BitConverter.ToInt64(bytes, 0); 77 | } 78 | } 79 | #endregion 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /Source/Swiddler/Serialization/Rtf/RtfAbstract.cs: -------------------------------------------------------------------------------- 1 | namespace Swiddler.Serialization.Rtf 2 | { 3 | /// 4 | /// Internal use only. 5 | /// Objects that are renderable can emit RTF code. 6 | /// 7 | abstract public class RtfRenderable 8 | { 9 | /// 10 | /// Internal use only. 11 | /// Emit RTF code. 12 | /// 13 | /// RTF code 14 | abstract public string render(); 15 | } 16 | 17 | /// 18 | /// Internal use only. 19 | /// RtfBlock is a content block that cannot contain other blocks. 20 | /// For example, an image is an RtfBlock because it cannot contain 21 | /// other content block such as another image, a paragraph, a table, 22 | /// etc. 23 | /// 24 | abstract public class RtfBlock : RtfRenderable 25 | { 26 | /// 27 | /// How this block is aligned in its containing block. 28 | /// 29 | abstract public Align Alignment { get; set; } 30 | /// 31 | /// Default character formats. 32 | /// 33 | abstract public RtfCharFormat DefaultCharFormat { get; } 34 | /// 35 | /// When set to true, this block will be arranged in the beginning 36 | /// of a new page. 37 | /// 38 | abstract public bool StartNewPage { get; set; } 39 | 40 | protected string AlignmentCode() 41 | { 42 | switch (Alignment) 43 | { 44 | case Align.Left: 45 | return @"\ql"; 46 | case Align.Right: 47 | return @"\qr"; 48 | case Align.Center: 49 | return @"\qc"; 50 | case Align.FullyJustify: 51 | return @"\qj"; 52 | default: 53 | return @"\qd"; 54 | } 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /Source/Swiddler/Serialization/SessionXml.cs: -------------------------------------------------------------------------------- 1 | using Swiddler.Common; 2 | using System; 3 | 4 | namespace Swiddler.Serialization 5 | { 6 | public class SessionXml 7 | { 8 | public DateTime StartTime { get; set; } = DateTime.UtcNow; 9 | 10 | public long LowestOffset { get; set; } 11 | public long HighestOffset { get; set; } 12 | 13 | public long ChunkCount { get; set; } 14 | 15 | public long LinesCountApprox { get; set; } 16 | 17 | public ConnectionBanner ConnectionBanner { get; set; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Source/Swiddler/Serialization/UserSettings.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.IO; 3 | using System.Text; 4 | using System.Windows; 5 | using System.Xml; 6 | using System.Xml.Serialization; 7 | 8 | namespace Swiddler.Serialization 9 | { 10 | public class UserSettings 11 | { 12 | public Rect MainWindowBounds { get; set; } 13 | public WindowState MainWindowState { get; set; } 14 | public double MainWindowLeftColumn { get; set; } 15 | public double MainWindowBottomRow { get; set; } 16 | 17 | public Rect NewConnectionWindowBounds { get; set; } 18 | public double NewConnectionLeftColumn { get; set; } 19 | public double NewConnectionRightColumn { get; set; } 20 | 21 | public bool PcapSelectionExport { get; set; } = true; 22 | 23 | public List QuickMRU { get; set; } 24 | 25 | #region IO 26 | 27 | public static string FileName => Path.Combine(App.Current.AppDataPath, nameof(UserSettings) + ".xml"); 28 | 29 | public static UserSettings Load() 30 | { 31 | if (File.Exists(FileName)) 32 | using (var file = File.OpenRead(FileName)) return Deserialize(file); 33 | else 34 | return new UserSettings(); 35 | } 36 | 37 | public void Save() 38 | { 39 | using (var file = File.Open(FileName, FileMode.OpenOrCreate)) Serialize(file); 40 | } 41 | 42 | private static readonly XmlWriterSettings writerSettings = new XmlWriterSettings { OmitXmlDeclaration = true, Indent = true, Encoding = new UTF8Encoding(false) }; 43 | private static readonly XmlSerializerNamespaces emptyNamespaces = new XmlSerializerNamespaces(new[] { new XmlQualifiedName("", "") }); 44 | private static readonly XmlSerializer serializer = new XmlSerializer(typeof(UserSettings)); 45 | 46 | void Serialize(Stream stream) 47 | { 48 | stream.SetLength(0); 49 | using (var writer = XmlWriter.Create(stream, writerSettings)) 50 | { 51 | serializer.Serialize(writer, this, emptyNamespaces); 52 | } 53 | } 54 | 55 | static UserSettings Deserialize(Stream stream) 56 | { 57 | using (var reader = XmlReader.Create(stream)) 58 | { 59 | return (UserSettings)serializer.Deserialize(reader); 60 | } 61 | } 62 | #endregion 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /Source/Swiddler/SocketSettings/ClientSettingsBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Swiddler.SocketSettings 4 | { 5 | public abstract class ClientSettingsBase : SettingsBase 6 | { 7 | public event EventHandler DualModeChanged; 8 | 9 | protected string _TargetHost; 10 | public string TargetHost { get => _TargetHost; set => SetProperty(ref _TargetHost, value); } 11 | 12 | protected int? _TargetPort; 13 | public int? TargetPort { get => _TargetPort; set => SetProperty(ref _TargetPort, value); } 14 | 15 | protected string _LocalAddress = "0.0.0.0"; 16 | public string LocalAddress { get => _LocalAddress; set => SetProperty(ref _LocalAddress, value); } 17 | 18 | protected int? _LocalPort = 0; 19 | public int? LocalPort { get => _LocalPort; set => SetProperty(ref _LocalPort, value); } 20 | 21 | protected bool _LocalBinding; 22 | public bool LocalBinding { get => _LocalBinding; set { SetProperty(ref _LocalBinding, value); } } 23 | 24 | protected bool _DualMode; 25 | public bool DualMode { get => _DualMode; set { if (SetProperty(ref _DualMode, value)) DualModeChanged?.Invoke(this, value); } } 26 | 27 | 28 | [System.Xml.Serialization.XmlIgnore] public System.Net.Sockets.ProtocolType Protocol { get; protected set; } = System.Net.Sockets.ProtocolType.Unknown; 29 | public override string ToString() => TargetHost + ":" + TargetPort; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Source/Swiddler/SocketSettings/ServerSettingsBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Swiddler.SocketSettings 4 | { 5 | public abstract class ServerSettingsBase : SettingsBase 6 | { 7 | public event EventHandler DualModeChanged; 8 | 9 | string _IPAddress = "0.0.0.0"; 10 | public string IPAddress { get => _IPAddress; set => SetProperty(ref _IPAddress, value); } 11 | 12 | int? _Port = 1337; 13 | public int? Port { get => _Port; set => SetProperty(ref _Port, value); } 14 | 15 | bool _ReuseAddress; 16 | public bool ReuseAddress { get => _ReuseAddress; set => SetProperty(ref _ReuseAddress, value); } 17 | 18 | bool _DualMode; 19 | public bool DualMode { get => _DualMode; set { if (SetProperty(ref _DualMode, value)) DualModeChanged?.Invoke(this, value); } } 20 | 21 | 22 | [System.Xml.Serialization.XmlIgnore] public System.Net.Sockets.ProtocolType Protocol { get; protected set; } = System.Net.Sockets.ProtocolType.Unknown; 23 | public override string ToString() => IPAddress + ":" + Port; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Source/Swiddler/SocketSettings/SettingsBase.cs: -------------------------------------------------------------------------------- 1 | using Swiddler.Common; 2 | using System; 3 | using System.Xml.Serialization; 4 | 5 | namespace Swiddler.SocketSettings 6 | { 7 | public abstract class SettingsBase : BindableBase, ICloneable 8 | { 9 | string _ImageName; 10 | [XmlIgnore] public string ImageName { get => _ImageName; set => SetProperty(ref _ImageName, value); } 11 | 12 | string _Caption; 13 | [XmlIgnore] public string Caption { get => _Caption; set => SetProperty(ref _Caption, value); } 14 | 15 | public object Clone() 16 | { 17 | var obj = Activator.CreateInstance(GetType()); 18 | 19 | foreach (var prop in GetType().GetProperties()) 20 | { 21 | if (prop.SetMethod?.IsPublic == true) // copy public properties 22 | { 23 | prop.SetValue(obj, prop.GetValue(this)); 24 | } 25 | } 26 | 27 | return obj; 28 | } 29 | 30 | public static bool Equals(SettingsBase obj1, SettingsBase obj2) 31 | { 32 | if (obj1.GetType() == obj2.GetType()) 33 | { 34 | foreach (var prop in obj1.GetType().GetProperties()) 35 | { 36 | if (prop.SetMethod?.IsPublic == true) // compare public properties 37 | { 38 | var val1 = prop.GetValue(obj1); 39 | var val2 = prop.GetValue(obj2); 40 | 41 | if (val1 == null && val2 == null) 42 | continue; 43 | 44 | if (val1?.Equals(val2) != true) 45 | return false; 46 | } 47 | } 48 | } 49 | return false; 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Source/Swiddler/SocketSettings/SnifferSettings.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Collections.ObjectModel; 4 | using System.Net; 5 | using System.Net.Sockets; 6 | 7 | namespace Swiddler.SocketSettings 8 | { 9 | public class SnifferSettings : SettingsBase 10 | { 11 | public SnifferSettings() 12 | { 13 | Caption = "Network sniffer"; 14 | ImageName = "Eye"; 15 | 16 | CaptureFilter.CollectionChanged += (s, e) => CaptureFilterChanges++; 17 | } 18 | 19 | string _InterfaceAddress; 20 | public string InterfaceAddress { get => _InterfaceAddress; set => SetProperty(ref _InterfaceAddress, value); } 21 | 22 | bool _PromiscuousMode; 23 | public bool PromiscuousMode { get => _PromiscuousMode; set => SetProperty(ref _PromiscuousMode, value); } 24 | 25 | 26 | public ObservableCollection CaptureFilter { get; set; } = new ObservableCollection(); 27 | 28 | public static CaptureProtocol[] CaptureProtocols { get; } = new[] { CaptureProtocol.Both, CaptureProtocol.TCP, CaptureProtocol.UDP }; 29 | 30 | public class CaptureFilterItem 31 | { 32 | public CaptureProtocol Protocol { get; set; } 33 | public string IPAddress { get; set; } 34 | public int? Port { get; set; } 35 | 36 | public Tuple ToTuple() 37 | { 38 | var ep = new IPEndPoint(System.Net.IPAddress.Any, 0); 39 | var proto = ProtocolType.Unspecified; 40 | 41 | if (!string.IsNullOrEmpty(IPAddress)) 42 | ep.Address = System.Net.IPAddress.Parse(IPAddress); 43 | if (Port != null) 44 | ep.Port = Port.Value; 45 | 46 | if (Protocol == CaptureProtocol.TCP) 47 | proto = ProtocolType.Tcp; 48 | if (Protocol == CaptureProtocol.UDP) 49 | proto = ProtocolType.Udp; 50 | 51 | return Tuple.Create(ep, proto); 52 | } 53 | } 54 | 55 | public enum CaptureProtocol 56 | { 57 | Both = 0, 58 | TCP, 59 | UDP 60 | } 61 | 62 | int _CaptureFilterChanges; 63 | [System.Xml.Serialization.XmlIgnore] public int CaptureFilterChanges { get => _CaptureFilterChanges; set => SetProperty(ref _CaptureFilterChanges, value); } 64 | 65 | public static SnifferSettings DesignInstance => new SnifferSettings(); 66 | 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /Source/Swiddler/SocketSettings/TCPClientSettings.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Security.Authentication; 3 | 4 | namespace Swiddler.SocketSettings 5 | { 6 | public class TCPClientSettings : ClientSettingsBase 7 | { 8 | public event EventHandler EnableSSLChanged; 9 | 10 | public TCPClientSettings() 11 | { 12 | Protocol = System.Net.Sockets.ProtocolType.Tcp; 13 | Caption = "Client"; 14 | ImageName = "Connect"; 15 | _TargetHost = "example.org"; 16 | _TargetPort = 80; 17 | } 18 | 19 | 20 | bool _EnableSSL; 21 | public bool EnableSSL { get => _EnableSSL; set { if (SetProperty(ref _EnableSSL, value)) EnableSSLChanged?.Invoke(this, value); } } 22 | 23 | protected bool _ValidateCertificate = true; 24 | public bool ValidateCertificate { get => _ValidateCertificate; set { SetProperty(ref _ValidateCertificate, value); } } 25 | 26 | protected string _SNI; 27 | public string SNI { get => _SNI; set => SetProperty(ref _SNI, value); } 28 | 29 | protected string _ClientCertificate; 30 | public string ClientCertificate { get => _ClientCertificate; set => SetProperty(ref _ClientCertificate, value); } 31 | 32 | 33 | protected bool _Ssl30, _Tls10, _Tls11 = true, _Tls12 = true, _Tls13; 34 | public bool EnableProtocolSsl30 { get => _Ssl30; set { SetProperty(ref _Ssl30, value); } } 35 | public bool EnableProtocolTls10 { get => _Tls10; set { SetProperty(ref _Tls10, value); } } 36 | public bool EnableProtocolTls11 { get => _Tls11; set { SetProperty(ref _Tls11, value); } } 37 | public bool EnableProtocolTls12 { get => _Tls12; set { SetProperty(ref _Tls12, value); } } 38 | public bool EnableProtocolTls13 { get => _Tls13; set { SetProperty(ref _Tls13, value); } } 39 | 40 | 41 | public SslProtocols GetSslProtocols() 42 | { 43 | const int Ssl30 = 48; 44 | const int Tls10 = 192; 45 | const int Tls11 = 768; 46 | const int Tls12 = 3072; 47 | const int Tls13 = 12288; 48 | 49 | int protocols = 0; 50 | 51 | if (EnableProtocolSsl30) protocols |= Ssl30; 52 | if (EnableProtocolTls10) protocols |= Tls10; 53 | if (EnableProtocolTls11) protocols |= Tls11; 54 | if (EnableProtocolTls12) protocols |= Tls12; 55 | if (EnableProtocolTls13) protocols |= Tls13; 56 | 57 | return (SslProtocols)protocols; 58 | } 59 | 60 | public static TCPClientSettings DesignInstance => new TCPClientSettings() { LocalBinding = true, EnableSSL = true }; 61 | 62 | public override string ToString() => $"{GetScheme()}://{base.ToString()}"; 63 | 64 | string GetScheme() 65 | { 66 | if (TargetPort == 80) return "http"; 67 | if (TargetPort == 443) return "https"; 68 | return "tcp"; 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /Source/Swiddler/SocketSettings/UDPClientSettings.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Swiddler.SocketSettings 4 | { 5 | public class UDPClientSettings : ClientSettingsBase 6 | { 7 | public event EventHandler IsBroadcastChanged; 8 | public event EventHandler IsMulticastChanged; 9 | 10 | public UDPClientSettings() 11 | { 12 | Protocol = System.Net.Sockets.ProtocolType.Udp; 13 | Caption = "Connect"; 14 | ImageName = "Connect"; 15 | _TargetHost = "8.8.8.8"; 16 | _TargetPort = 53; 17 | } 18 | 19 | bool _IsBroadcast, _IsMulticast; 20 | public bool IsBroadcast { get => _IsBroadcast; set { if (SetProperty(ref _IsBroadcast, value)) IsBroadcastChanged?.Invoke(this, value); } } 21 | public bool IsMulticast { get => _IsMulticast; set { if (SetProperty(ref _IsMulticast, value)) IsMulticastChanged?.Invoke(this, value); } } 22 | 23 | 24 | public static UDPClientSettings DesignInstance => new UDPClientSettings() { LocalBinding = true }; 25 | 26 | public override string ToString() => "udp://" + base.ToString(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Source/Swiddler/SocketSettings/UDPServerSettings.cs: -------------------------------------------------------------------------------- 1 | namespace Swiddler.SocketSettings 2 | { 3 | public class UDPServerSettings : ServerSettingsBase 4 | { 5 | public UDPServerSettings() 6 | { 7 | Protocol = System.Net.Sockets.ProtocolType.Udp; 8 | Caption = "Bind"; 9 | ImageName = "Port"; 10 | } 11 | 12 | 13 | public static UDPServerSettings DesignInstance => new UDPServerSettings(); 14 | 15 | public override string ToString() => "udp://" + base.ToString(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Source/Swiddler/Themes/Generic.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /Source/Swiddler/Utils/AssemblyExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | 4 | namespace Swiddler.Utils 5 | { 6 | public static class AssemblyExtensions 7 | { 8 | public static string GetLocalPath(this Assembly assembly) 9 | { 10 | return new Uri(Assembly.GetEntryAssembly().GetName().CodeBase).LocalPath; 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Source/Swiddler/Utils/ChannelExtensions.cs: -------------------------------------------------------------------------------- 1 | using Swiddler.Channels; 2 | using System.Collections.Generic; 3 | 4 | namespace Swiddler.Utils 5 | { 6 | public static class ChannelExtensions 7 | { 8 | public static ICollection FindAllChannels(this IEnumerable channels) 9 | { 10 | var knownChannels = new HashSet(); 11 | foreach (var channel in channels) 12 | VisitRecipients(channel, knownChannels); 13 | return knownChannels; 14 | } 15 | 16 | public static ICollection FindAllChannels(this Channel channel) 17 | { 18 | var knownChannels = new HashSet(); 19 | VisitRecipients(channel, knownChannels); 20 | return knownChannels; 21 | } 22 | 23 | static void VisitRecipients(Channel channel, HashSet knownChannels ) 24 | { 25 | if (channel == null) return; 26 | 27 | knownChannels.Add(channel); 28 | foreach (var item in channel.Observers) 29 | { 30 | if (!knownChannels.Contains(item)) 31 | VisitRecipients(item, knownChannels); 32 | } 33 | } 34 | 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Source/Swiddler/Utils/ControlExtensions.cs: -------------------------------------------------------------------------------- 1 | using Swiddler.Common; 2 | using System; 3 | using System.Windows.Controls.Primitives; 4 | 5 | namespace Swiddler.Utils 6 | { 7 | public static class ControlExtensions 8 | { 9 | public static void ReloadCertificateItems(this Selector control) 10 | { 11 | (control.ItemsSource as IHasReload).Reload(); 12 | control.SelectedIndex = Math.Max(control.SelectedIndex, 0); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Source/Swiddler/Utils/DateTimeExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Swiddler.Utils 4 | { 5 | public static class DateTimeExtensions 6 | { 7 | public static DateTime LastDayOfWeek(this DateTime date, DayOfWeek dayofweek) 8 | { 9 | int adjustment = (int)date.DayOfWeek < (int)dayofweek ? 7 : 0; 10 | return date.Date.AddDays(0 - ((int)date.DayOfWeek + adjustment - (int)dayofweek)); 11 | } 12 | 13 | public static DateTime NextDayOfWeek(this DateTime date, DayOfWeek dayofweek) 14 | { 15 | return date.LastDayOfWeek(dayofweek).AddDays(7).Date; 16 | } 17 | 18 | public static long GetUnixTimeSeconds(this DateTime utcDate) 19 | { 20 | const long UnixEpochSeconds = 62_135_596_800; 21 | 22 | long seconds = utcDate.Ticks / TimeSpan.TicksPerSecond; 23 | return seconds - UnixEpochSeconds; 24 | } 25 | 26 | public static ulong GetUnixMicroSeconds(this DateTime utcDate) 27 | { 28 | const decimal UnixEpochMicroSeconds = 62_135_596_800_000_000; 29 | 30 | decimal us = utcDate.Ticks / (decimal)(TimeSpan.TicksPerMillisecond / 1000.0); 31 | return (ulong)(us - UnixEpochMicroSeconds); 32 | } 33 | 34 | public static int GetMicroSeconds(this DateTime utcDate) 35 | { 36 | return utcDate.Millisecond * 1_000; 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Source/Swiddler/Utils/DependencyObjectExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using System.Windows.Controls; 3 | using System.Windows.Data; 4 | using System.Windows.Media; 5 | 6 | namespace Swiddler.Utils 7 | { 8 | public static class DependencyObjectExtensions 9 | { 10 | public static DependencyObject FindBinding(this DependencyObject parent, string bindingPath) 11 | { 12 | if (parent == null) return null; 13 | 14 | int childrenCount = VisualTreeHelper.GetChildrenCount(parent); 15 | for (int i = 0; i < childrenCount; i++) 16 | { 17 | var child = VisualTreeHelper.GetChild(parent, i); 18 | 19 | if (child is UIElement elm && elm.Visibility != Visibility.Visible) 20 | continue; // skip hidden elements 21 | 22 | if (child is TextBox) 23 | { 24 | if (FindBoundProperty(child, bindingPath, TextBox.TextProperty) != null) return child; 25 | } 26 | else if (child is ComboBox) 27 | { 28 | if (FindBoundProperty(child, bindingPath, ComboBox.TextProperty, ComboBox.SelectedValueProperty, ComboBox.SelectedItemProperty) != null) return child; 29 | } 30 | 31 | var foundChild = FindBinding(child, bindingPath); 32 | if (foundChild != null) 33 | return foundChild; 34 | } 35 | 36 | return null; 37 | } 38 | 39 | public static Binding FindBoundProperty(this DependencyObject obj, string bindingPath, params DependencyProperty[] properties) 40 | { 41 | foreach (var prop in properties) 42 | { 43 | var binding = BindingOperations.GetBinding(obj, prop); 44 | 45 | if (binding?.Path?.Path == bindingPath) 46 | { 47 | return binding; 48 | } 49 | } 50 | 51 | return null; 52 | } 53 | 54 | public static void Focus(this DependencyObject parent, string bindingPath) 55 | { 56 | if (string.IsNullOrEmpty(bindingPath)) return; 57 | 58 | var elm = FindBinding(parent, bindingPath) as UIElement; 59 | elm?.Focus(); 60 | } 61 | 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Source/Swiddler/Utils/ImagingExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Drawing; 3 | using System.Runtime.InteropServices; 4 | using System.Windows; 5 | using System.Windows.Interop; 6 | using System.Windows.Media; 7 | using System.Windows.Media.Imaging; 8 | 9 | namespace Swiddler.Utils 10 | { 11 | public static class ImagingExtensions 12 | { 13 | 14 | [DllImport("gdi32.dll")] [return: MarshalAs(UnmanagedType.Bool)] static extern bool DeleteObject([In] IntPtr hObject); 15 | 16 | public static ImageSource ImageSourceForBitmap(this Bitmap bmp) // call from UI thread ! 17 | { 18 | var handle = bmp.GetHbitmap(); 19 | try 20 | { 21 | return Imaging.CreateBitmapSourceFromHBitmap(handle, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); 22 | } 23 | finally 24 | { 25 | DeleteObject(handle); 26 | } 27 | } 28 | 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Source/Swiddler/Utils/Shell/IImageList.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace Swiddler.Utils.Shell 5 | { 6 | [ComImportAttribute()] 7 | [GuidAttribute("46EB5926-582E-4017-9FDF-E8998DAA0950")] 8 | [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] 9 | public interface IImageList 10 | { 11 | [PreserveSig] 12 | int Add( 13 | IntPtr hbmImage, 14 | IntPtr hbmMask, 15 | ref int pi); 16 | 17 | [PreserveSig] 18 | int ReplaceIcon( 19 | int i, 20 | IntPtr hicon, 21 | ref int pi); 22 | 23 | [PreserveSig] 24 | int SetOverlayImage( 25 | int iImage, 26 | int iOverlay); 27 | 28 | [PreserveSig] 29 | int Replace( 30 | int i, 31 | IntPtr hbmImage, 32 | IntPtr hbmMask); 33 | 34 | [PreserveSig] 35 | int AddMasked( 36 | IntPtr hbmImage, 37 | int crMask, 38 | ref int pi); 39 | 40 | [PreserveSig] 41 | int Draw( 42 | ref Shell.IMAGELISTDRAWPARAMS pimldp); 43 | 44 | [PreserveSig] 45 | int Remove( 46 | int i); 47 | 48 | [PreserveSig] 49 | int GetIcon( 50 | int i, 51 | int flags, 52 | ref IntPtr picon); 53 | }; 54 | } 55 | -------------------------------------------------------------------------------- /Source/Swiddler/Utils/Shell/IMAGEINFO.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace Swiddler.Utils.Shell 5 | { 6 | [StructLayout(LayoutKind.Sequential)] 7 | public struct IMAGEINFO 8 | { 9 | public IntPtr hbmImage; 10 | public IntPtr hbmMask; 11 | public int Unused1; 12 | public int Unused2; 13 | public Shell.RECT rcImage; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Source/Swiddler/Utils/Shell/IMAGELISTDRAWPARAMS.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Swiddler.Utils.Shell 4 | { 5 | public struct IMAGELISTDRAWPARAMS 6 | { 7 | public int cbSize; 8 | public IntPtr himl; 9 | public int i; 10 | public IntPtr hdcDst; 11 | public int x; 12 | public int y; 13 | public int cx; 14 | public int cy; 15 | public int xBitmap; 16 | public int yBitmap; 17 | public int rgbBk; 18 | public int rgbFg; 19 | public int fStyle; 20 | public int dwRop; 21 | public int fState; 22 | public int Frame; 23 | public int crEffect; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Source/Swiddler/Utils/Shell/POINT.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | 3 | namespace Swiddler.Utils.Shell 4 | { 5 | [StructLayout(LayoutKind.Sequential)] 6 | public struct POINT 7 | { 8 | public int X; 9 | public int Y; 10 | 11 | public POINT(int x, int y) 12 | { 13 | this.X = x; 14 | this.Y = y; 15 | } 16 | 17 | public POINT(System.Drawing.Point pt) : this(pt.X, pt.Y) { } 18 | 19 | public static implicit operator System.Drawing.Point(POINT p) 20 | { 21 | return new System.Drawing.Point(p.X, p.Y); 22 | } 23 | 24 | public static implicit operator POINT(System.Drawing.Point p) 25 | { 26 | return new POINT(p.X, p.Y); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Source/Swiddler/Utils/Shell/RECT.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | 3 | namespace Swiddler.Utils.Shell 4 | { 5 | [StructLayout(LayoutKind.Sequential)] 6 | public struct RECT 7 | { 8 | public int Left; 9 | public int Top; 10 | public int Right; 11 | public int Bottom; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Source/Swiddler/Utils/Shell/SHFILEINFO.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace Swiddler.Utils.Shell 5 | { 6 | public struct SHFILEINFO 7 | { 8 | public IntPtr hIcon; 9 | public int iIcon; 10 | public uint dwAttributes; 11 | [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 254)] 12 | public string szDisplayName; 13 | [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)] 14 | public string szTypeName; 15 | }; 16 | } 17 | -------------------------------------------------------------------------------- /Source/Swiddler/Utils/VisualExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using System.Windows.Media; 3 | 4 | namespace Swiddler.Utils 5 | { 6 | public static class VisualExtensions 7 | { 8 | internal static void SetDataContext(this Visual visual, object dataContext) 9 | { 10 | var element = visual as FrameworkElement; 11 | if (element != null) 12 | element.DataContext = dataContext; 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Source/Swiddler/ViewModels/IPAdapterHeader.cs: -------------------------------------------------------------------------------- 1 |  2 | namespace Swiddler.ViewModels 3 | { 4 | public class IPAdapterEmptyHeader 5 | { 6 | public static IPAdapterEmptyHeader Default { get; } = new IPAdapterEmptyHeader(); 7 | private IPAdapterEmptyHeader() { } 8 | } 9 | 10 | public class IPAdapterHeader 11 | { 12 | public string Id { get; set; } 13 | public string Name { get; set; } 14 | public string Description { get; set; } 15 | public bool IsUp { get; set; } 16 | 17 | public override bool Equals(object obj) => Id.Equals((obj as IPAdapterHeader)?.Id); 18 | 19 | public override int GetHashCode() => Id.GetHashCode(); 20 | 21 | public IPAdapterHeader(IPAddressItem item) 22 | { 23 | Id = item.InterfaceId; 24 | Name = item.InterfaceName; 25 | Description = item.InterfaceDescription; 26 | IsUp = item.IsUp; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Source/Swiddler/ViewModels/ImageButton.cs: -------------------------------------------------------------------------------- 1 | using Swiddler.Common; 2 | using System.Windows.Media; 3 | 4 | namespace Swiddler.ViewModels 5 | { 6 | public class ImageButton : BindableBase 7 | { 8 | string _Text; 9 | public string Text { get => _Text; set => SetProperty(ref _Text, value); } 10 | 11 | 12 | ImageSource _Image; 13 | public ImageSource Image { get => _Image; set => SetProperty(ref _Image, value); } 14 | 15 | 16 | string _ImageName; 17 | public string ImageName { get => _ImageName; set => SetProperty(ref _ImageName, value); } 18 | 19 | public override string ToString() => _Text; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Source/Swiddler/ViewModels/ProcessInfo.cs: -------------------------------------------------------------------------------- 1 | using Swiddler.Utils; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Management; 6 | using System.Windows; 7 | using System.Windows.Media; 8 | using System.Windows.Threading; 9 | using static Swiddler.Utils.ShellApi; 10 | 11 | namespace Swiddler.ViewModels 12 | { 13 | public class ProcessInfo 14 | { 15 | public static IconSizeEnum DefaultIconSize { get; set; } = IconSizeEnum.Small16; 16 | 17 | 18 | public int ProcessId { get; private set; } 19 | public string Name { get; private set; } 20 | public string Path { get; private set; } 21 | public ImageSource Icon { get; private set; } 22 | 23 | 24 | static readonly Dictionary IconCache = new Dictionary(StringComparer.OrdinalIgnoreCase); 25 | static readonly string DefaultExePath = ResolvePath("smss.exe"); 26 | 27 | private ProcessInfo() 28 | { 29 | } 30 | 31 | public static ProcessInfo Get(int? processId) 32 | { 33 | if ((processId ?? 0) == 0) 34 | return null; 35 | 36 | using (var searcher = new ManagementObjectSearcher($"Select * From Win32_Process Where ProcessID={processId}")) 37 | { 38 | var obj = searcher.Get().Cast().SingleOrDefault(); 39 | 40 | if (obj == null) 41 | return null; 42 | 43 | var pi = new ProcessInfo() 44 | { 45 | ProcessId = processId.Value, 46 | Name = (string)obj["Name"], 47 | Path = (string)obj["ExecutablePath"], 48 | }; 49 | 50 | pi.ResolveIcon(); 51 | 52 | return pi; 53 | } 54 | } 55 | 56 | static readonly Dispatcher Dispatcher = Application.Current.Dispatcher; 57 | 58 | private void ResolveIcon() 59 | { 60 | string iconKey = Path; 61 | 62 | if (string.IsNullOrEmpty(iconKey)) 63 | iconKey = DefaultExePath; 64 | 65 | lock (IconCache) 66 | { 67 | if (IconCache.TryGetValue(iconKey, out var img)) 68 | { 69 | Icon = img; 70 | return; 71 | } 72 | else 73 | { 74 | using (var bitmap = GetBitmapFromFilePath(iconKey, DefaultIconSize)) 75 | { 76 | Dispatcher.Invoke(new Action(() => 77 | { 78 | Icon = bitmap.ImageSourceForBitmap(); 79 | IconCache[iconKey] = Icon; 80 | })); 81 | } 82 | } 83 | } 84 | } 85 | 86 | public override string ToString() 87 | { 88 | return Name; 89 | } 90 | 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /Source/Swiddler/ViewModels/RecentlyUsedItem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Swiddler.ViewModels 4 | { 5 | public class RecentlyUsedItem : QuickActionItem 6 | { 7 | public ConnectionSettings ConnectionSettings { get; set; } 8 | public string DateTime { get; set; } 9 | 10 | public RecentlyUsedItem(ConnectionSettings connectionSettings) : base(QuickActionTemplate.Undefined) 11 | { 12 | var cs = ConnectionSettings = connectionSettings; 13 | 14 | DateTime = cs.CreatedAt.ToString("g"); 15 | 16 | if (cs.ClientChecked && !cs.ServerChecked) 17 | { 18 | Icon = "Connect"; 19 | if (cs.TCPChecked) 20 | Caption = "TCP Client"; 21 | else if (cs.UDPChecked) 22 | Caption = "UDP Client"; 23 | Description = cs.ClientSettings.TargetHost + ":" + cs.ClientSettings.TargetPort; 24 | } 25 | else if (cs.ServerChecked && !cs.ClientChecked) 26 | { 27 | Icon = "Port"; 28 | if (cs.TCPChecked) 29 | Caption = "TCP Server"; 30 | else if (cs.UDPChecked) 31 | Caption = "UDP Server"; 32 | Description = cs.ServerSettings.IPAddress + ":" + cs.ServerSettings.Port; 33 | } 34 | else if (cs.ClientChecked && cs.ServerChecked) 35 | { 36 | Icon = "Tunnel"; 37 | Caption = "Tunnel"; 38 | Description = 39 | ":" + cs.ServerSettings.Port + " > " + 40 | cs.ClientSettings.TargetHost + ":" + cs.ClientSettings.TargetPort; 41 | } 42 | else if (cs.SnifferChecked) 43 | { 44 | Icon = "Eye"; 45 | Caption = "Network sniffer"; 46 | Description = cs.Sniffer.InterfaceAddress; 47 | } 48 | else 49 | { 50 | throw new NotImplementedException(); 51 | } 52 | 53 | } 54 | 55 | public override ConnectionSettings GetConnectionSettings(ConnectionSettings recent) 56 | { 57 | return recent.Copy(ConnectionSettings); 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /Source/Swiddler/Views/Fragments/ConnectionView.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | using System.Windows; 3 | using System.Windows.Controls; 4 | 5 | namespace Swiddler.Views.Fragments 6 | { 7 | /// 8 | /// Interaction logic for MessageFragment.xaml 9 | /// 10 | public partial class ConnectionView : UserControl 11 | { 12 | public ConnectionView() 13 | { 14 | InitializeComponent(); 15 | } 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Source/Swiddler/Views/Fragments/MessageView.xaml: -------------------------------------------------------------------------------- 1 |  12 | 13 | 14 | 15 | 16 | 17 | 18 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Source/Swiddler/Views/Fragments/MessageView.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | using System.Windows; 3 | using System.Windows.Controls; 4 | 5 | namespace Swiddler.Views.Fragments 6 | { 7 | /// 8 | /// Interaction logic for MessageFragment.xaml 9 | /// 10 | public partial class MessageView : UserControl 11 | { 12 | public MessageView() 13 | { 14 | InitializeComponent(); 15 | } 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Source/Swiddler/Views/Fragments/SslHandshakeView.xaml.cs: -------------------------------------------------------------------------------- 1 | using Swiddler.Rendering; 2 | using Swiddler.Security; 3 | using Swiddler.Serialization; 4 | using System.Linq; 5 | using System.Windows; 6 | using System.Windows.Controls; 7 | using System.Windows.Input; 8 | 9 | namespace Swiddler.Views.Fragments 10 | { 11 | /// 12 | /// Interaction logic for SslHandshakeView.xaml 13 | /// 14 | public partial class SslHandshakeView : UserControl 15 | { 16 | public SslHandshake Model => ((SslHandshakeFragment)DataContext).Model; 17 | 18 | public SslHandshakeView() 19 | { 20 | InitializeComponent(); 21 | } 22 | 23 | private void Details_Click(object sender, RoutedEventArgs e) 24 | { 25 | var dlg = new SslHandshakeDetails(Model) { Owner = Window.GetWindow(this) }; 26 | dlg.ShowDialog(); 27 | } 28 | 29 | private void Cert_Click(object sender, System.Windows.RoutedEventArgs e) 30 | { 31 | var chain = Model.GetPrimaryCertificateChain(); 32 | if (chain?.Any() == true) 33 | chain.ShowCertificateChain(this, new Point(4, btnCert.Height + 4)); 34 | } 35 | 36 | private void Border_MouseDown(object sender, MouseButtonEventArgs e) 37 | { 38 | e.Handled = true; 39 | if (e.ClickCount == 2 && e.LeftButton == MouseButtonState.Pressed) Details_Click(sender, e); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Source/Swiddler/Views/NewSessionExpress.xaml: -------------------------------------------------------------------------------- 1 |  9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /Source/Swiddler/Views/NewSessionExpress.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | using System.Windows.Data; 9 | using System.Windows.Documents; 10 | using System.Windows.Input; 11 | using System.Windows.Media; 12 | using System.Windows.Media.Imaging; 13 | using System.Windows.Navigation; 14 | using System.Windows.Shapes; 15 | 16 | namespace Swiddler.Views 17 | { 18 | /// 19 | /// Interaction logic for NewSessionSimple.xaml 20 | /// 21 | public partial class NewSessionExpress : UserControl 22 | { 23 | public NewSessionExpress() 24 | { 25 | InitializeComponent(); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Source/Swiddler/Views/SocketSettings/Client.xaml.cs: -------------------------------------------------------------------------------- 1 | using Swiddler.Commands; 2 | using Swiddler.Utils; 3 | using Swiddler.ViewModels; 4 | using System.Windows.Controls; 5 | using System.Windows.Input; 6 | 7 | namespace Swiddler.Views.SocketSettings 8 | { 9 | /// 10 | /// Interaction logic for Client.xaml 11 | /// 12 | public partial class Client : UserControl 13 | { 14 | public Client() 15 | { 16 | InitializeComponent(); 17 | 18 | btnClientCertMenu.CommandBindings.HandleCertificateCommands(certificateType: CertificateType.ClientCertificate); 19 | CommandBindings.HandleCertificateChangedNotification(CertificateChangedNotification); 20 | } 21 | 22 | void CertificateChangedNotification(ExecutedRoutedEventArgs e) 23 | { 24 | cmbClientCert.ReloadCertificateItems(); 25 | if (e.Parameter is Certificate crt && crt.SignByCertificateAuthority && crt.CertificateType == CertificateType.ClientCertificate) 26 | cmbClientCert.SelectedValue = crt.Value; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Source/Swiddler/Views/SocketSettings/Listener.xaml.cs: -------------------------------------------------------------------------------- 1 | using Swiddler.Commands; 2 | using Swiddler.Utils; 3 | using Swiddler.ViewModels; 4 | using System.Windows.Controls; 5 | using System.Windows.Input; 6 | 7 | namespace Swiddler.Views.SocketSettings 8 | { 9 | /// 10 | /// Interaction logic for Listener.xaml 11 | /// 12 | public partial class Listener : UserControl 13 | { 14 | public Listener() 15 | { 16 | InitializeComponent(); 17 | 18 | btnServerCertMenu.CommandBindings.HandleCertificateCommands(certificateType: CertificateType.ServerCertificate); 19 | btnCAMenu.CommandBindings.HandleCertificateCommands(certificateType: CertificateType.ServerCertificate); 20 | CommandBindings.HandleCertificateChangedNotification(CertificateChangedNotification); 21 | } 22 | 23 | void CertificateChangedNotification(ExecutedRoutedEventArgs e) 24 | { 25 | cmbServerCert.ReloadCertificateItems(); 26 | cmbCA.ReloadCertificateItems(); 27 | 28 | if (e.Parameter is Certificate crt) 29 | { 30 | if (e.OriginalSource == btnServerCertMenu && crt.SignByCertificateAuthority && crt.CertificateType == CertificateType.ServerCertificate) 31 | cmbServerCert.SelectedValue = crt.Value.Thumbprint; 32 | 33 | if (e.OriginalSource == btnCAMenu && !crt.SignByCertificateAuthority) 34 | cmbCA.SelectedValue = crt.Value.Thumbprint; 35 | } 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Source/Swiddler/Views/SocketSettings/Rewrite.xaml: -------------------------------------------------------------------------------- 1 |  14 | 15 | 16 | 20 | 26 | 27 | 28 | 29 | 30 | 32 | 33 | 34 | 36 | 37 | 38 | 39 | Binary 40 | 41 | 42 | 43 | 44 | Inbound (received) 45 | Outbound (sent) 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /Source/Swiddler/Views/SocketSettings/Rewrite.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Controls; 2 | 3 | namespace Swiddler.Views.SocketSettings 4 | { 5 | /// 6 | /// Interaction logic for Rewrite.xaml 7 | /// 8 | public partial class Rewrite : UserControl 9 | { 10 | public Rewrite() 11 | { 12 | InitializeComponent(); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Source/Swiddler/Views/SocketSettings/Sniffer.xaml.cs: -------------------------------------------------------------------------------- 1 | using Swiddler.SocketSettings; 2 | using System.Windows.Controls; 3 | 4 | namespace Swiddler.Views.SocketSettings 5 | { 6 | /// 7 | /// Interaction logic for Rewrite.xaml 8 | /// 9 | public partial class Sniffer : UserControl 10 | { 11 | public Sniffer() 12 | { 13 | InitializeComponent(); 14 | 15 | gridFilter.CellEditEnding += (s, e) => CaptureFilterChanged(); 16 | } 17 | 18 | void CaptureFilterChanged() 19 | { 20 | var model = (SnifferSettings)DataContext; 21 | model.CaptureFilterChanges++; // this forces property change notification to make settings dirty 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Source/Swiddler/Views/SocketSettings/UDPClient.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Controls; 2 | 3 | namespace Swiddler.Views.SocketSettings 4 | { 5 | /// 6 | /// Interaction logic for UDPClient.xaml 7 | /// 8 | public partial class UDPClient : UserControl 9 | { 10 | public UDPClient() 11 | { 12 | InitializeComponent(); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Source/Swiddler/Views/SocketSettings/UDPServer.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Controls; 2 | 3 | namespace Swiddler.Views.SocketSettings 4 | { 5 | /// 6 | /// Interaction logic for UDPServer.xaml 7 | /// 8 | public partial class UDPServer : UserControl 9 | { 10 | public UDPServer() 11 | { 12 | InitializeComponent(); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Swiddler.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.28803.352 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Swiddler", "Source\Swiddler\Swiddler.csproj", "{F0CF9694-8294-468F-9DBD-5F253FFB44D5}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {F0CF9694-8294-468F-9DBD-5F253FFB44D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {F0CF9694-8294-468F-9DBD-5F253FFB44D5}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {F0CF9694-8294-468F-9DBD-5F253FFB44D5}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {F0CF9694-8294-468F-9DBD-5F253FFB44D5}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {002AD00D-0F0B-4BB5-AA97-0D7536D7E514} 24 | EndGlobalSection 25 | EndGlobal 26 | --------------------------------------------------------------------------------