Question

I created a Perl script that would use an online website to crack MD5 hashes after the user inputs the hashes. I am partially successful as I am able to get the response from the website, though I need to parse the HTML and display the hash, and corresponding password in clear text to the user. The following is the output snippet I get now:

<strong>21232f297a57a5a743894a0e4a801fc3</strong>: admin</p>

Using regex buddy, I was able to use the following expression [a-z0-9]{32} to match the hash part alone. I need the final output in the following format:

21232f297a57a5a743894a0e4a801fc3: admin

Any help would be appreciated. Thank you!

Was it helpful?

Solution

I think you'd be much better off using HTML::Parser to simply/reliably parse that HTML. Otherwise you're into the nightmare of parsing HTML with regexps, and you'll find that doesn't work reliably.

OTHER TIPS

There are a few tools that can handle both fetching and parsing the page for you available on CPAN. One of them is Web::Scraper. Tell it what page to fetch and which nodes (in xpath or CSS syntax) you want, and it will get them for you. I'll not give an example as I don't know your URL.

There is a good blogpost about this on blogs.perl.org by stas that uses a different module that might also be helpful.

Here it is:

$str = q{<strong>21232f297a57a5a743894a0e4a801fc3</strong>: admin</p>};
@arr = $str =~ m{<strong>(.+)</strong>(.+)</p>};
print(join("", @arr), "\n");
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top