02 Jul 09 Parsing ifconfig output in PHP
I recently wrote a class to parse the output of ifcofig (on a debian-based system) and turn the list of interfaces and their attributes into a usable data structure.
(more...)
I recently wrote a class to parse the output of ifcofig (on a debian-based system) and turn the list of interfaces and their attributes into a usable data structure.
(more...)
The impetus for this solution was to eliminate the duplication of functions a javascript source file. The concepts could be applied with little modification to any language with c-like syntax. I chose to implement in PHP because that's what I happen to be working with these days though I do make use of a grep trick which means it would be easiest to run this on some type of posix system with grep & php.
(more...)
I use this handy-dandy Regular Expression:
preg_match_all("/href=[\'|\"]http:\/\/([a-zA-Z0-9\.\/\?\-\_\:\=]*)[\'|\"]/i", $haystack, $links_array);
This fills an array ($links_array) with any URLs found in $haystack. No more complex than that, though as you can see, regular expressions can be complex in their own right - they're powerful!
This is a solved problem, yet the volume of applications that are exposed to vulnerabilities due to improperly filtered input is staggering.