the string to split up looks like this:
192.168.1.254445.... 0000 0000 0010 = Flags: 0x002 (SYN)
There are three bits of information in this string that need to be pulled to different variables which are:
ip - 192.168.1.254
port - 445
flag - SYN
The ip is an ip address so it will need to capture the full range of addresses. Port can be from 1-4 digits long. and the flag can contain three, three letter characters e.g. SYN or SYN,ACK or SYN,ACK,URG etc (e.g. different combinations of packet flags.
I have tried using Split with ( : ' ' as the splits but whenever I put in [1] as the output it creates an
error - Index was outside the bounds of the array.
I then created this code out of looking at C# RegEx string extraction :
Regex pattern = new Regex(@"(<?ip>\d+)(<?port>\d+).... \d{4} \d{4} \d{4} \d{4} = Flags: \d{1}x\d{3} ((<?flag>\w+))");
Match match = pattern.Match(dst1);
string ip = (match.Groups["ip"].Value);
string port = (match.Groups["port"].Value);
string flag = (match.Groups["flag"].Value);
string dst = ip + port + flag;
listBox1.Items.Add(dst);
But this returns no values in the listBox1.
If the string is changed to:
192.168.1.254.... 0000 0000 0010 = Flags: 0x002 (SYN)445
Would that make it easier?
Any suggestions would be great,
Thanks.