-2

I am working on a tool a little like xARP. It simply detects changes in ARP tables to find out whether a man in the middle attack is taking place. Anyway, I ran into a problem. I managed to read the ARP table from my machine and load them into a string.

The problem now is that I am unable to seperate the MAC addresses from the other text the windows ARP-command outputs. How would one go about seperating only the MAC addresses and filtering out all the irrelevant text?

Kara
  • 6,115
  • 16
  • 50
  • 57
Dar56
  • 125
  • 1
  • 1
  • 5
  • 1
    You could start by reading about: http://en.wikipedia.org/wiki/Regular_expression – Martin Thurau May 17 '11 at 20:02
  • 1
    no sample of the data, no code sample of what you have tried/what didn't work... – Mat May 17 '11 at 20:03
  • @Martin Thanks I'm looking it up just now! Seems to be what I was looking for. – Dar56 May 17 '11 at 20:14
  • use [Rubular](http://www.rubular.com) to test your regexs it is written Ruby but the regexs work just as well in Java. I use it all the time to post links to regex solutions here. –  May 17 '11 at 20:17

1 Answers1

0

Two options: using regular expression (best!) or just using substring on every line. The output of windows ARP is correctly spaced to allow for substring.

Edit: For substring, you could first split the entire output into single lines, and then process each line sequentially. That way the indexes for substring stay the same for every line.

Edit: http://www.regular-expressions.info/ has great information on learning regular expressions.

Mr47
  • 2,655
  • 1
  • 19
  • 25
  • Thanks for your replies guys! I think I will try to see if i can figure out regular expressions.. I already have experimented a bit with substring but since there are multiple MACs it gets a bit confusing for me to figure out how to program it. – Dar56 May 17 '11 at 20:10
  • I accidently pressed enter when going to a new line :-) – Dar56 May 17 '11 at 20:12
  • @Mr47 - Is it possible (in Java) to make the regular expression look for a pattern instead of specific characters? – Dar56 May 17 '11 at 20:13
  • @Dar56 - That is exactly what regular expressions are used for. See http://www.regular-expressions.info/ for a great tutorial. – Mr47 May 17 '11 at 20:14