Skip to content

Commit

Permalink
Merge pull request #11 from odedshimon/add-file-extracting
Browse files Browse the repository at this point in the history
Add file extracting
  • Loading branch information
odedshimon authored May 22, 2020
2 parents 5023a2c + 0720c6d commit 8554c12
Show file tree
Hide file tree
Showing 32 changed files with 1,004 additions and 126 deletions.
18 changes: 18 additions & 0 deletions BruteShark/BruteSharkDesktop/BruteSharkDesktop.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,18 @@
<Compile Include="Casting.cs" />
<Compile Include="Objects\TcpPacket.cs" />
<Compile Include="Objects\TcpSession.cs" />
<Compile Include="UserControls\FilesControl\FilePreviewUserControl.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="UserControls\FilesControl\FilePreviewUserControl.Designer.cs">
<DependentUpon>FilePreviewUserControl.cs</DependentUpon>
</Compile>
<Compile Include="UserControls\FilesControl\FilesUserControl.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="UserControls\FilesControl\FilesUserControl.Designer.cs">
<DependentUpon>FilesUserControl.cs</DependentUpon>
</Compile>
<Compile Include="UserControls\NetworkMapControl\NetworkMapEdge.cs" />
<Compile Include="UserControls\SessionsControl\SessionsExplorerUserControl.cs">
<SubType>UserControl</SubType>
Expand Down Expand Up @@ -96,6 +108,12 @@
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="UserControls\FilesControl\FilePreviewUserControl.resx">
<DependentUpon>FilePreviewUserControl.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UserControls\FilesControl\FilesUserControl.resx">
<DependentUpon>FilesUserControl.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UserControls\SessionsControl\SessionsExplorerUserControl.resx">
<DependentUpon>SessionsExplorerUserControl.cs</DependentUpon>
</EmbeddedResource>
Expand Down
92 changes: 68 additions & 24 deletions BruteShark/BruteSharkDesktop/MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 38 additions & 3 deletions BruteShark/BruteSharkDesktop/MainForm.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using BruteSharkDesktop;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
Expand All @@ -22,6 +23,7 @@ public partial class MainForm : Form
private HashesUserControl _hashesUserControl;
private NetworkMapUserControl _networkMapUserControl;
private SessionsExplorerUserControl _sessionsExplorerUserControl;
private FilesUserControl _filesUserControl;


public MainForm()
Expand All @@ -44,6 +46,8 @@ public MainForm()
_hashesUserControl.Dock = DockStyle.Fill;
_passwordsUserControl = new GenericTableUserControl();
_passwordsUserControl.Dock = DockStyle.Fill;
_filesUserControl = new FilesUserControl();
_filesUserControl.Dock = DockStyle.Fill;

// Contract the events.
_processor.UdpPacketArived += (s, e) => _analyzer.Analyze(Casting.CastProcessorUdpPacketToAnalyzerUdpPacket(e.Packet));
Expand All @@ -57,9 +61,18 @@ public MainForm()
_processor.ProcessingFinished += (s, e) => SwitchToMainThreadContext(() => OnProcessingFinished(s, e));

InitilizeFilesIconsList();
InitilizeModulesCheckedListBox();
this.modulesTreeView.ExpandAll();
}

private void InitilizeModulesCheckedListBox()
{
foreach (var module_name in _analyzer.AvailableModulesNames)
{
this.modulesCheckedListBox.Items.Add(module_name, isChecked: false);
}
}

private void OnProcessingFinished(object sender, EventArgs e)
{
this.progressBar.Value = this.progressBar.Maximum;
Expand Down Expand Up @@ -164,10 +177,14 @@ private void OnParsedItemDetected(object sender, PcapAnalyzer.ParsedItemDetected
_networkMapUserControl.AddEdge(connection.Source, connection.Destination);
this.modulesTreeView.Nodes["NetworkNode"].Nodes["NetworkMapNode"].Text = $"Network Map ({_networkMapUserControl.NodesCount})";
}
else if (e.ParsedItem is PcapAnalyzer.NetworkFile)
{
var fileObject = e.ParsedItem as PcapAnalyzer.NetworkFile;
_filesUserControl.AddFile(fileObject);
this.modulesTreeView.Nodes["DataNode"].Nodes["FilesNode"].Text = $"Files ({_filesUserControl.FilesCount})";
}
}



private void addFilesButton_Click(object sender, EventArgs e)
{
var openFileDialog = new OpenFileDialog();
Expand Down Expand Up @@ -223,6 +240,9 @@ private void modulesTreeView_AfterSelect(object sender, TreeViewEventArgs e)
case "SessionsNode":
this.modulesSplitContainer.Panel2.Controls.Add(_sessionsExplorerUserControl);
break;
case "FilesNode":
this.modulesSplitContainer.Panel2.Controls.Add(_filesUserControl);
break;
default:
break;
}
Expand All @@ -236,6 +256,21 @@ private void removeFilesButton_Click(object sender, EventArgs e)
item.Remove();
}
}

private void modulesCheckedListBox_ItemCheck(object sender, ItemCheckEventArgs e)
{
var module_name = ((CheckedListBox)sender).Text;

if (e.NewValue == CheckState.Checked)
{
_analyzer.AddModule(module_name);
}
else
{
_analyzer.RemoveModule(module_name);
}
}

}
}

Loading

0 comments on commit 8554c12

Please sign in to comment.