Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class DumpPcap
- {
- public int _interfaceNumber;
- public string _pcapPath;
- public string _dumPcapPath = @"C:Program FilesWiresharkdumpcap.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());
- }
- }
- }
- List<string> stList = new List<string>();
- var process = new Process();
- process.StartInfo.FileName = _dumPcapPath;
- process.StartInfo.Arguments =
- string.Format("-i " + _interfaceNumber + " -s 65535 -w " + _pcapPath);
- process.Startinfo.WindowStyle = ProcessWindowStyle.Hidden;
- process.Startinfo.RedirectStandardOutput = true;
- process.Startinfo.RedirectStandardError = true;
- process.Startinfo.CreateNoWindow = true;
- process.Startinfo.UseShellExecute = false;
- process.Startinfo.ErrorDialog = false;
- // capture the data received event here...
- process.OutputDataReceived +=
- new DataReceivedEventHandler(process_OutputDataReceived);
- process.Start();
- process.BeginOutputReadLine();
- private void process_OutputDataReceived(object sender, DataReceivedEventArgs arg)
- {
- // arg.Data contains the output data from the process...
- }
Add Comment
Please, Sign In to add comment