私は Wireshark を実行してスニッフィングを開始するビルド アプリケーションです。Wireshark には、引数 (インターフェイス番号、出力ファイルなど) を受け取ってスニッフィングを開始する dumpcap.exe ファイルがあり、その間、cmd ウィンドウでパケットの数とこの数がすべて増加していることを確認できます。時間。私の質問は、アプリケーション ウィンドウにこの番号を表示するために、この番号を数秒ごとに取得するにはどうすればよいかということです。
これは、このスニッフィングを開始する私のクラスです:
public class DumpPcap
{
public int _interfaceNumber;
public string _pcapPath;
public string _dumPcapPath = @"C:\Program Files\Wireshark\dumpcap.exe";
public DumpPcap(int interfaceNumber, string pcapPath)
{
_interfaceNumber = interfaceNumber;
_pcapPath = pcapPath;
}
public void startTheCapture()
{
List<string> stList = new List<string>();
ProcessStartInfo process = new ProcessStartInfo(_dumPcapPath);
process.Arguments = string.Format("-i " + _interfaceNumber + " -s 65535 -w " + _pcapPath);
process.WindowStyle = ProcessWindowStyle.Hidden;
process.RedirectStandardOutput = true;
process.RedirectStandardError = true;
process.CreateNoWindow = true;
process.UseShellExecute = false;
process.ErrorDialog = false;
Process dumpcap = Process.Start(process);
StreamReader reader = dumpcap.StandardOutput;
//dumpcap.WaitForExit(100000);
while (!reader.EndOfStream)
{
stList.Add(reader.ReadLine());
}
}
}
これはスクリーンショットで、アプリケーションに表示したいフィールドを赤でマークしました: