Follow us on Twitter!
The measure of a mans life is not how well he dies, but how well he lives.
Friday, April 18, 2014
Navigation
Home
HellBoundHackers Main:
HellBoundHackers Find:
HellBoundHackers Information:
Learn
Communicate
Submit
Shop
Challenges
HellBoundHackers Exploit:
HellBoundHackers Programming:
HellBoundHackers Think:
HellBoundHackers Track:
HellBoundHackers Patch:
HellBoundHackers Other:
HellBoundHackers Need Help?
Other
Members Online
Total Online: 27
Guests Online: 22
Members Online: 5

Registered Members: 82825
Newest Member: bulmers
Latest Articles
View Thread

HellBound Hackers | Computer General | Programming

Author

PHP, cURL and header();

clone4
Member



Posts: 586
Location: He is back and he's bad!
Joined: 25.11.07
Rank:
Mad User
Posted on 10-09-08 23:18
ok I've been stuck on this whole day, and googling my ass off :( Anyway here is the problem: I've got a curl script to open a page
Code

$curl = curl_init( );
curl_setopt($curl, CURLOPT_URL, "$1");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

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




$1 includes obviously the url. Now the php script in $1 will include headers function
Code

header ('Location:http://google.com')




And what I need to do is either follow the redirection and return the page, or somehow grab the header passed in the file, return it, and store it into variable. I haven't find any function elegible for either of these tasks, and also I'm really weak with cURL, so I'd really appreciate any help...


[img][/img]img164.imageshack.us/img164/5713/perlvl0.jpg

clone4.freehostia.com/ubuntu_3.png
spyware - "They see me trollin'..."
<yaragn> ever seen that movie? The Matrix?
<yaragn> with those green lines of flying text?
<yaragn> *THAT'S* Perl

clone_4@hotmail.com
Author

RE: PHP, cURL and header();


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 10-09-08 23:37
I don't know how to use curl, but I would recommend to use raw sockets. Then you just need to split the response at Location:.
Author

RE: PHP, cURL and header();

Mr_Cheese




Posts: 2468
Location: Brighton, UK
Joined: 30.11.04
Rank:
Uber Elite
Posted on 11-09-08 00:03
use the curl operator "return_headers" or something like that.

it will return all the headers so you can use it for further processing.

all you do is check for the Location string, and then send another cURL post over to the Location url.

also, i dont think variables cant start with a number.

php.net/curl has a list of all the curl operators you can use.
http://www.hellboundhackers.org/
Author

RE: PHP, cURL and header();

clone4
Member



Posts: 586
Location: He is back and he's bad!
Joined: 25.11.07
Rank:
Mad User
Posted on 11-09-08 12:28
Mr_Cheese wrote:
use the curl operator "return_headers" or something like that.

it will return all the headers so you can use it for further processing.

all you do is check for the Location string, and then send another cURL post over to the Location url.

also, i dont think variables cant start with a number.

php.net/curl has a list of all the curl operators you can use.


ok thx, finally found the right thing. to the variable, I thought that if you use preg_match('/(.*?)/',$something) you can use the $1 as a independent variable outside the regex, as in perl, but that doesn't seems to work, so now the last problem is how to extract string from preg_match like:
Code

if (preg_match('/(.*?)/',$aaa)){
$string = what is included in the (.*?);
}






[img][/img]img164.imageshack.us/img164/5713/perlvl0.jpg

clone4.freehostia.com/ubuntu_3.png
spyware - "They see me trollin'..."
<yaragn> ever seen that movie? The Matrix?
<yaragn> with those green lines of flying text?
<yaragn> *THAT'S* Perl

clone_4@hotmail.com
Author

RE: PHP, cURL and header();

yours31f
Member



Posts: 1678
Location: Dallas Texas
Joined: 27.04.07
Rank:
Elite
Posted on 11-09-08 12:40
you cannot run a variable with a number because anything other than IE5 + will not accept or use it.


Debugging is what programmers do to beta software to make it take up more room on your hard drive if it is running too efficiently.


img259.imageshack.us/img259/3713/sigr.png

yours31f@live.com yours31f@yahoo.com rpwd.info
Author

RE: PHP, cURL and header();


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 11-09-08 13:33
clone4 wrote:...so now the last problem is how to extract string from preg_match like:
Code

if (preg_match('/(.*?)/',$aaa)){
$string = what is included in the (.*?);
}





Assign the preg_match bit to a variable, then conditional the variable, not the preg_match.

Code

$match = preg_match('/(.*?)/',$aaa);
if ($match){
echo 'Found a match!  It was '.$match.'.';
}






Author

RE: PHP, cURL and header();

clone4
Member



Posts: 586
Location: He is back and he's bad!
Joined: 25.11.07
Rank:
Mad User
Posted on 11-09-08 16:47
Zephyr_Pure wrote:
Assign the preg_match bit to a variable, then conditional the variable, not the preg_match.

Code

$match = preg_match('/(.*?)/',$aaa);
if ($match){
echo 'Found a match!  It was '.$match.'.';
}





Don't know whether I'm doing something wrong, but preg_match always returns only true/false, so if I print this out, it looks like Found a match! It was 1, but I need to work with the string matched in the parenthesis... In perl I would just do if($match) { $url = $1 .....} but in php it seems that you can use that only within the preg functions, like preg_replace('/(something)/','$1 sucks',$something)


[img][/img]img164.imageshack.us/img164/5713/perlvl0.jpg

clone4.freehostia.com/ubuntu_3.png
spyware - "They see me trollin'..."
<yaragn> ever seen that movie? The Matrix?
<yaragn> with those green lines of flying text?
<yaragn> *THAT'S* Perl

clone_4@hotmail.com
Author

RE: PHP, cURL and header();


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 11-09-08 16:58
clone4 wrote:Don't know whether I'm doing something wrong, but preg_match always returns only true/false, so if I print this out, it looks like Found a match! It was 1, but I need to work with the string matched in the parenthesis... In perl I would just do if($match) { $url = $1 .....} but in php it seems that you can use that only within the preg functions, like preg_replace('/(something)/','$1 sucks',$something)


Well, yeah, but I also responded before I had coffee this morning (doesn't usually work for me). Anyways, preg_match only returns the number of matches (which, in your case, was 1 match only); for you to get the actual matches, put a variable name as a third argument and that will be the array of results.

Reference: http://us3.php.ne. . .


Author

RE: PHP, cURL and header();

clone4
Member



Posts: 586
Location: He is back and he's bad!
Joined: 25.11.07
Rank:
Mad User
Posted on 11-09-08 17:07
Zephyr_Pure wrote:
Well, yeah, but I also responded before I had coffee this morning (doesn't usually work for me).


Yeah same for me Grin


Anyways, preg_match only returns the number of matches (which, in your case, was 1 match only); for you to get the actual matches, put a variable name as a third argument and that will be the array of results.

Reference: http://us3.php.ne. . .


I feel like complete idiot, not checking php.net is just plain stupid... Of course now everything works fine... So thanks alot !




[img][/img]img164.imageshack.us/img164/5713/perlvl0.jpg

clone4.freehostia.com/ubuntu_3.png
spyware - "They see me trollin'..."
<yaragn> ever seen that movie? The Matrix?
<yaragn> with those green lines of flying text?
<yaragn> *THAT'S* Perl

clone_4@hotmail.com
Author

RE: PHP, cURL and header();


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 11-09-08 17:16
No prob... and everyone gets at least one chance to be an idiot. Smile

Yeah, I live by php.net... I'm constantly looking up order for args for functions. One day, I'll find me a handy-dandy PHP quicklist for string functions that will list the arguments, not what the functions actually do.

Anyways, glad it helped.