| Author |
Best way to parse http response body |
Larika
Member

Posts: 318
Location: Italy
Joined: 17.01.06 Rank: God |
|
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 expresblockedsion 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 scblockedript that save the http response headers in a array then im using a regular expresblockedsion 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.

Vivi come se dovessi morire il giorno dopo
Pensa come se non dovessi morire mai
|
|
| Author |
RE: Best way to parse http response body |
mido
Member
Posts: 613
Location: Cairo, Egypt
Joined: 27.01.07 Rank: God |
|
You can use :
substr and indexOf if youre using javascblockedript...
|
|
| Author |
RE: Best way to parse http response body |
Larika
Member

Posts: 318
Location: Italy
Joined: 17.01.06 Rank: God |
|
Well im tring to set up a php/cURL scblockedript 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.

Vivi come se dovessi morire il giorno dopo
Pensa come se non dovessi morire mai
|
|
| Author |
RE: Best way to parse http response body |
mikispag
Member

Posts: 43
Location: Italy
Joined: 14.11.06 Rank: God |
|
Hi,
with cURL/PHP do like this:
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL,"http://www.hellboundhackers.org/challenges/timed/timed3/index.php");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_VERBOSE, 1);
curl_setopt($curl, CURLOPT_COOKIE,"PHPSESSID=5b1sXXXXo5niv5p0t24ntbh56X;fusion_user=13XXX.cXXX282138afbe9066b8be1cb426841d");
curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/5.0 (X11; U; Linux i686; it; rv:1.8.1.5) Gecko/20070713 Firefox/2.0.0.5");
$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!
Code is written, future is not
Edited by mikispag on 29-07-07 17:09 |
|
| Author |
RE: Best way to parse http response body |
mido
Member
Posts: 613
Location: Cairo, Egypt
Joined: 27.01.07 Rank: God |
|
Well, to be honest, i forgot to thank mikispag 
he who helped me ...
|
|
| Author |
RE: Best way to parse http response body |
LanceUppercut
Member

Posts: 7
Location: Your Mom's Box
Joined: 25.01.06 Rank: God |
|
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" 
Don't Just Stare At It...Eat It!!!
 |
|
| Author |
RE: Best way to parse http response body |
The_Cell
Member

Posts: 306
Location: Belgium
Joined: 07.04.05 Rank: God |
|
I did 1,2 and 3 using PHP, cURL and regexes. If you use those 3 technologies, you'll beat them within an hour 

Made by Monster
Hacking is creativity. - The_Cell
|
|
| Author |
RE: Best way to parse http response body |
contmp
Member

Posts: 36
Location: behind shadows of proxy servers and redirectors
Joined: 27.01.07 Rank: Newbie Warn Level: 5
|
|
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.
Edited by contmp on 20-09-07 15:10 |
|
| Author |
RE: Best way to parse http response body |
darksun
Member

Posts: 254
Location: the netherlands
Joined: 15.08.06 Rank: God Warn Level: 10
|
|
i did a few with cURL and php.not even using regex(),just explode()
and substr() 
c12h17n2o4p -> c12h16Nn2o -> O_O
When you make the campfire bigger, more darkness is revealed.
I found more questions then answers in my search.

You recognize but you ain't seen nothing. Experience is the best teacher. |
|
| Author |
RE: Best way to parse http response body |
mido
Member
Posts: 613
Location: Cairo, Egypt
Joined: 27.01.07 Rank: God |
|
There are many ways, ereg(), preg_matches(), etc etc...
|
|
| Author |
RE: Best way to parse http response body |
WhiteAcid
Member

Posts: 123
Location: UK
Joined: 08.05.05 Rank: Elite |
|
heh. I did them all with only greasemonkey scblockedripts 
-Sid |
|
| Author |
RE: Best way to parse http response body |
SySTeM
-=[TheOutlaw]=-
Posts: 1524
Location: England, UK
Joined: 27.07.05 Rank: The Overlord |
|
I used PHP and cURL, didn't take too long to do.
|
|
| Author |
RE: Best way to parse http response body |
mr noob
Member
Posts: 553
Location:
Joined: 22.01.06 Rank: HBH Guru Warn Level: 1
|
|
darksun wrote:
i did a few with cURL and php.not even using regex(),just explode()
and substr() 
<3 explode, i dont have to learn regex b*llocks 
as DigitalFire kindly pointed out, he is a grammar nazi  |
|
| Author |
RE: Best way to parse http response body |
The_Gman
Member
Posts: 30
Location:
Joined: 02.09.08 Rank: Mad User |
|
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>', '' |
|
| Author |
RE: Best way to parse http response body |
Zephyr_Pure
Member

Posts: 2402
Location:
Joined: 15.09.06 Rank: God |
|
Don't bump YEAR OLD THREADS, asshat.
I still check PMs from time to time.


Our responses were moronic, why shouldn't he follow suit? - Futility |
|
| Author |
RE: Best way to parse http response body |
The_Gman
Member
Posts: 30
Location:
Joined: 02.09.08 Rank: Mad User |
|
|
It was still on the front page, shithead |
|
| Author |
RE: Best way to parse http response body |
spyware
Member

Posts: 4190
Location: The Netherlands
Joined: 14.04.07 Rank: God Warn Level: 90
|
|
|
The_Gman wrote:
It was still on the front page, shithead
No it wasn't.

"The chowner of property." - Zeph Widespread intellectual and moral docility may be convenient for leaders in the short term,
but it is suicidal for nations in the long term. - Carl Sagan Since the grid is inescapable, what were the earlier lasers about? Does the corridor have a sense of humor? - Ebert |
|
| Author |
RE: Best way to parse http response body |
Zephyr_Pure
Member

Posts: 2402
Location:
Joined: 15.09.06 Rank: God |
|
|
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.
I still check PMs from time to time.


Our responses were moronic, why shouldn't he follow suit? - Futility |
|
| Author |
RE: Best way to parse http response body |
The_Gman
Member
Posts: 30
Location:
Joined: 02.09.08 Rank: Mad User |
|
Zephyr_Pure wrote:
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.
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  |
|
| Author |
RE: Best way to parse http response body |
Zephyr_Pure
Member

Posts: 2402
Location:
Joined: 15.09.06 Rank: God |
|
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.
I still check PMs from time to time.


Our responses were moronic, why shouldn't he follow suit? - Futility |
|