Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jlucansky committed Jul 26, 2020
1 parent 6385aad commit d91a097
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 9 deletions.
25 changes: 19 additions & 6 deletions Source/Swiddler/Channels/SnifferChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public override int GetHashCode()
private class Mediator : Channel
{
public ConnectionKey EP { get; set; }
public bool IsServer { get; set; }
public bool IsServer { get; set; } // local EP is server
public Mediator(Session session) : base(session) { }
protected override void OnReceiveNotification(Packet packet) => throw new NotImplementedException();
public void Send(Packet packet) => NotifyObservers(packet); // write to session UI
Expand Down Expand Up @@ -133,7 +133,10 @@ void StartAsAdmin()
{
if (MessageBox.Show(
"You don’t have permission to create raw sockets.\n\nDo you want to launch Swiddler as Administrator?",
"Access Denied", MessageBoxButton.YesNo, MessageBoxImage.Exclamation) == MessageBoxResult.Yes) Session.StartAsAdmin();
"Access Denied", MessageBoxButton.YesNo, MessageBoxImage.Exclamation) == MessageBoxResult.Yes)
{
try { Session.StartAsAdmin(); } catch { }
}
}));
}
}
Expand Down Expand Up @@ -207,20 +210,30 @@ Mediator GetChild(RawPacket raw)
{
var child = Session.NewChildSession();

Session.Storage.Write(new MessageData() { Text = $"New connection observed {raw.Source} -> :{raw.Destination}", Type = MessageType.Connecting });
Session.Storage.Write(new MessageData() { Text = $"New connection observed {raw.Source} -> {raw.Destination}", Type = MessageType.Connecting });

mediator = new Mediator(child) { EP = ep };

string protoStr = raw.Protocol.ToString().ToUpperInvariant();

if (raw.Destination.Address.Equals(LocalAddress))
var source = raw.Source;
var destination = raw.Destination;

// can happen that SYN|ACK sniffed as a reply from server before SYN
if (raw.Flags.HasFlag(TCPFlags.SYN) && raw.Flags.HasFlag(TCPFlags.ACK))
{
destination = raw.Source;
source = raw.Destination;
}

if (destination.Address.Equals(LocalAddress))
{
child.Name = $"{raw.Source} > :{raw.Destination.Port} - {protoStr}";
child.Name = $"{source} > :{destination.Port} ({protoStr})";
mediator.IsServer = true; // when first packet is directed toward local IP, then local EP is probably server
}
else
{
child.Name = $":{raw.Source.Port} > {raw.Destination} - {protoStr}";
child.Name = $":{source.Port} > {destination} ({protoStr})";
}

mediator.Observe(child.SessionChannel); // received packets write to session Log
Expand Down
2 changes: 1 addition & 1 deletion Source/Swiddler/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

[assembly: AssemblyInformationalVersion("1.0.3")]
[assembly: AssemblyInformationalVersion("1.0.4")]
9 changes: 7 additions & 2 deletions Source/Swiddler/Views/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,13 @@ private void Window_SourceInitialized(object sender, EventArgs e)

private void SessionTree_ItemAdded(object sender, int index)
{
sessionListView.SelectedIndex = index;
sessionListView.ScrollIntoView(sessionListView.SelectedItem);
var item = (SessionListItem)sessionListView.Items[index];

if (!item.Session.IsChildSession || item.Session.Parent.Children.Count == 1)
{
sessionListView.SelectedIndex = index;
sessionListView.ScrollIntoView(sessionListView.SelectedItem);
}
}

private void SessionListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
Expand Down

0 comments on commit d91a097

Please sign in to comment.