Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

Best way to parse http response body


ghost's Avatar
0 0

Hello all, in each timed challenge we need to keep the http response body, serach a string on it, do some operations and do a new request with the result value. Now i already did real 11 and i had no problems parsing the response to find the number between the two tags <h1></h1>. Now the challenge is a bit different so we have to use regular expression to find the right string. Im here to ask suggestions on the better/easy way to parse the response body and search that string: Im using a curl php script that save the http response headers in a array then im using a regular expression in a preg match that find the string. Im having a lot of problems parsing the response body and finding the needed string.

Any help/suggestion will be appreciated, thanks.


mido's Avatar
Member
0 0

You can use : substr and indexOf if youre using javascript…


ghost's Avatar
0 0

Well im tring to set up a php/cURL script that is able to store the response body and then make operations on it, so i can use it as a base for all the challenges. My problem is that i cant store the body of the response to a string or in a array.


mikispag's Avatar
=> Penguin in black <=
0 0

Hi,

with cURL/PHP do like this:

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL,&quot;http://www.hellboundhackers.org/challenges/timed/timed3/index.php&quot;);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_VERBOSE, 1);
curl_setopt($curl, CURLOPT_COOKIE,&quot;PHPSESSID=5b1sXXXXo5niv5p0t24ntbh56X;fusion_user=13XXX.cXXX282138afbe9066b8be1cb426841d&quot;);
curl_setopt($curl, CURLOPT_USERAGENT, &quot;Mozilla/5.0 (X11; U; Linux i686; it; rv:1.8.1.5) Gecko/20070713 Firefox/2.0.0.5&quot;);

$result = curl_exec ($curl);
curl_close ($curl);
print $result;

The variable $result will have the HTML body of the page. Remember, you must spoof the Useragent because HBH doesn't allow cURL traffic!


mido's Avatar
Member
0 0

Well, to be honest, i forgot to thank mikispag :) he who helped me …


ghost's Avatar
0 0

Hey Larika, I've knocked out two of these fuckers so far using perl and some regexes. PM if you need help on the first one…I've got just the regex you're looking for to parse the b64 string that is in between "string: " and " and" :p


ghost's Avatar
0 0

I did 1,2 and 3 using PHP, cURL and regexes. If you use those 3 technologies, you'll beat them within an hour ;)


ghost's Avatar
0 0

you can use python (the way I do it)

url = 'http://www.hellboundhackers.org/challenges/timed/timed4/index.php' footer = 'Your word is: <strong>' trailer = '</strong><br /><br /><form action='

… some urllib code here….

f = data.find(footer) t = data.find(trailer) data = data[f:t] data = data.split(':') data = data[1].replace(' ', '') data = data.replace('<strong>', '')

simple, not very elegant, but it works! :-)

please feel free to PM me.


ghost's Avatar
0 0

i did a few with cURL and php.not even using regex(),just explode() and substr() :happy:


mido's Avatar
Member
0 0

There are many ways, ereg(), preg_matches(), etc etc…


ghost's Avatar
0 0

heh. I did them all with only greasemonkey scripts :D


SySTeM's Avatar
-=[TheOutlaw]=-
20 0

I used PHP and cURL, didn't take too long to do.


ghost's Avatar
0 0

darksun wrote: i did a few with cURL and php.not even using regex(),just explode() and substr() :happy:

<3 explode, i dont have to learn regex b*llocks :)


ghost's Avatar
0 0

contmp wrote: you can use python (the way I do it)

url = 'http://www.hellboundhackers.org/challenges/timed/timed4/index.php' footer = 'Your word is: <strong>' trailer = '</strong><br /><br /><form action='

… some urllib code here….

f = data.find(footer) t = data.find(trailer) data = data[f:t] data = data.split(':') data = data[1].replace(' ', '') data = data.replace('<strong>', '')

simple, not very elegant, but it works! :-)

please feel free to PM me.

word = re.findall('\<strong\>[A-Za-z0-9 ]+</strong>', html)[0].replace('<strong>','').replace('</strong>', '')


ghost's Avatar
0 0

Don't bump YEAR OLD THREADS, asshat.


ghost's Avatar
0 0

It was still on the front page, shithead


spyware's Avatar
Banned
0 0

The_Gman wrote: It was still on the front page, shithead

No it wasn't.


ghost's Avatar
0 0

The_Gman wrote: It was still on the front page, shithead

The post before yours was from a year ago, fucktard. Pay attention and shut the hell up if you don't know what you're talking about.


ghost's Avatar
0 0

Zephyr_Pure wrote: [quote]The_Gman wrote: It was still on the front page, shithead

The post before yours was from a year ago, fucktard. Pay attention and shut the hell up if you don't know what you're talking about.[/quote] I wasn't denying that it was a year old, I was saying it was on the front page. Does it really bother you that a topic was moved up twenty lines?

Especially when I contributed something that can benefit others.

I'm glad you wasted your time posting :angry:


ghost's Avatar
0 0

Dude, SHUT UP. You bumped a year-old thread… that's a no-no. Doesn't matter if what you said would help, because the OP has already forgotten about the topic. When the topic is long dead, the OP obviously isn't interested anymore. When the OP leaves a thread for dead, leave it dead. It's not fucking rocket science.