The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. February 12, 2012, 12:24:49 AM

Login with username, password and session length


Pages: [1]
  Print  
Author Topic: curl login problem with ashx page  (Read 1020 times)
zarek
n00b
*
Offline Offline

Posts: 5


View Profile
« on: July 03, 2010, 02:37:40 PM »

hi,

i am trying to login an ashx page with curl. Following data from livehttpheaders:

Code:
http://www.milliyetemlak.com/ajaxpro/ArapSabunu,App_Code.nunp_6_w.ashx

POST /ajaxpro/ArapSabunu,App_Code.nunp_6_w.ashx HTTP/1.1
Host: www.milliyetemlak.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; tr; rv:1.9.2.6) Gecko/20100625 Firefox/3.6.6 ( )
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: tr-tr,tr;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-9,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Content-Type: text/plain; charset=utf-8
X-AjaxPro-Method: Login
Referer: http://www.milliyetemlak.com/Default.aspx?aType=UyeGiris
Content-Length: 204
Cookie: IlanOnPlan=FlashIlan=9; KategoriyeGoreIlanlar=12,13,=12; FirmaOnplan=FirmaVitriniEmlakci=0&FirmaVitrinInsaat=0&FirmaVitrinYapiDekorasyon=0&NakliyeciVitrini=0; __utma=183063866.786731720.1278014512.1278164210.1278174821.6; __utmz=183063866.1278014512.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); FirmaOnplan1=FirmaVitriniEmlakci1=0&FirmaVitrinInsaat1=0&FirmaVitrinYapiDekorasyon1=0&NakliyeciVitrini1=0; ASP.NET_SessionId=kt33i5yukc1pvu55gf5jnojl; NSC_fnmblnjmmjzfu=ffffffffd6fb026745525d5f4f58455e445a4a423660; __utmc=183063866; bttest__=123; LoginInfo=email=&password=; __utmb=183063866.3.10.1278174821
Pragma: no-cache
Cache-Control: no-cache
{"username":"mirzazeyrek@gmail.com","password":"mypassword","rememberMe":true,"userip":"213.243.28.145","useragent":"Mozilla/5.0 (Windows; U; Windows NT 6.0; tr; rv:1.9.2.6) Gecko/20100625 Firefox/3.6.6 ( )"}
HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Content-Length: 41
Content-Type: text/plain; charset=utf-8
Expires: -1
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
Set-Cookie: LoginInfo=email=17CC6ABA347F6FC659FD9DF4BE522553A0C2C1FEAF4021F5DF611A33FB6DAD440F34DD64B16A84DBD2F6AC246FC474DC3DF2B616F6A7BD4CFF429F47ABF7607C69D2E92A577D709D666A115F9739E0EB31D05A7DFFF9ECBCD21202ED28BFB153B0831864878BC8D447F7F390F1653BA9&password=337AAE4F702987DC86AF42DB5E26974E166B019F19819207A07029BF3C3DA46CBF3654DA4C03F4ECC41A26150810A6CF18DAB880624EC8930005F3FC7B56B433313728E095025F6B573396D8D03C72E6; expires=Fri, 01-Oct-2010 16:35:18 GMT; path=/
Set-Cookie: NSC_fnmblnjmmjzfu=ffffffffd6fb026745525d5f4f58455e445a4a423660;expires=Sat, 03-Jul-2010 20:28:20 GMT;path=/;httponly
Date: Sat, 03 Jul 2010 16:35:17 GMT

and this is my php code for it:

<?php

$loginurl 
"http://www.milliyetemlak.com/ajaxpro/ArapSabunu,App_Code.nunp_6_w.ashx";

echo 
curl_login($loginurl,$data,'','off');
echo 
"<br><hr><br>";
// loginning
echo curl_grab_page('http://www.milliyetemlak.com/','','off');
echo 
"<br><hr><br>";

// ilan gönderiyoruz

function curl_login($url,$data,$proxy,$proxystatus){
    
$fp fopen("cookie.txt""w");
    
fclose($fp);
    
$login curl_init();
    
curl_setopt($loginCURLOPT_COOKIEJAR"cookie.txt");
    
curl_setopt($loginCURLOPT_COOKIEFILE"cookie.txt");
    
curl_setopt($loginCURLOPT_USERAGENT"Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
    
curl_setopt($loginCURLOPT_TIMEOUT40);
    
curl_setopt($loginCURLOPT_RETURNTRANSFERTRUE);
    if (
$proxystatus == 'on') {
        
curl_setopt($loginCURLOPT_SSL_VERIFYHOSTFALSE);
        
curl_setopt($loginCURLOPT_HTTPPROXYTUNNELTRUE);
        
curl_setopt($loginCURLOPT_PROXY$proxy);
    }
    
curl_setopt($loginCURLOPT_URL$url);
    
curl_setopt($loginCURLOPT_HEADERTRUE);
    
curl_setopt($loginCURLOPT_USERAGENT$_SERVER['HTTP_USER_AGENT']);
    
curl_setopt($loginCURLOPT_FOLLOWLOCATIONTRUE);
    
curl_setopt($loginCURLOPT_POSTTRUE);
    
curl_setopt($loginCURLOPT_POSTFIELDS'{"username":"mirzazeyrek@gmail.com","password":"mypassword","rememberMe":true,"userip":"213.243.28.145","useragent":"Mozilla/5.0 (Windows; U; Windows NT 6.0; tr; rv:1.9.2.6) Gecko/20100625 Firefox/3.6.6 ( )"}');
    
ob_start();      // prevent any output
    
return curl_exec ($login); // execute the curl command
    
ob_end_clean();  // stop preventing output
    
curl_close ($login);
    unset(
$login);    
}               

function 
curl_grab_page($site,$proxy,$proxystatus){
    
$ch curl_init();
    
curl_setopt($chCURLOPT_RETURNTRANSFERTRUE);
    if (
$proxystatus == 'on') {
        
curl_setopt($chCURLOPT_SSL_VERIFYHOSTFALSE);
        
curl_setopt($chCURLOPT_HTTPPROXYTUNNELTRUE);
        
curl_setopt($chCURLOPT_PROXY$proxy);
    }
    
curl_setopt($chCURLOPT_COOKIEFILE"cookie.txt");
    
curl_setopt($chCURLOPT_URL$site);
    
ob_start();      // prevent any output
    
return curl_exec ($ch); // execute the curl command
    
ob_end_clean();  // stop preventing output
    
curl_close ($ch);
}

?>

and following code is here:

http://www.sozluklerinefendisi.com/mitest.php

it isn't working.

created cookie.txt is here:

# Netscape HTTP Cookie File
# http://www.netscape.com/newsref/std/cookie_spec.html
# This file was generated by libcurl! Edit at your own risk.

www.milliyetemlak.com
	
FALSE
	
/
	
FALSE
	
1278188457
	
NSC_fnmblnjmmjzfu
	
ffffffffd6fb026745525d5f4f58455e445a4a423660


any idea ?

thanks for looking anyway : )
Logged

No links in signatures please
isthisthingon
Global Moderator
Lifer
*****
Offline Offline

Posts: 2868



View Profile
« Reply #1 on: July 03, 2010, 08:42:52 PM »

Honk if you're not spam...
Logged

I would love to change the world, but they won't give me the source code.
nutballs
Administrator
Lifer
*****
Online Online

Posts: 5604


Back in my day we had 9 planets


View Profile
« Reply #2 on: July 03, 2010, 09:15:49 PM »

yea i thought the same thing because of the urls. Would be a great way to get links into sites... hmmmmmm.....
Logged

I could eat a bowl of Alphabet Soup and shit a better argument than that.
perkiset
Olde World Hacker
Administrator
Lifer
*****
Online Online

Posts: 9792



View Profile
« Reply #3 on: July 04, 2010, 12:36:51 AM »

Well the auto highlighting code here won't make them links, but the clever spider would regex the patterns and then perhaps crawl what it found ... A new way to influence spider scan rate... ? 
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
zarek
n00b
*
Offline Offline

Posts: 5


View Profile
« Reply #4 on: July 05, 2010, 10:48:55 PM »

it's not spam. but looks like no one knows about asp.net in this section of forum.
Logged

No links in signatures please
isthisthingon
Global Moderator
Lifer
*****
Offline Offline

Posts: 2868



View Profile
« Reply #5 on: July 05, 2010, 11:13:08 PM »

  to the Cache.
Logged

I would love to change the world, but they won't give me the source code.
perkiset
Olde World Hacker
Administrator
Lifer
*****
Online Online

Posts: 9792



View Profile
« Reply #6 on: July 06, 2010, 07:06:37 AM »

Not a lot of folks here doing asp.net anymore zarek. Someone might pop by.
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
zarek
n00b
*
Offline Offline

Posts: 5


View Profile
« Reply #7 on: July 06, 2010, 07:14:27 AM »

may be it's better to move this topic asp.net section.
Logged

No links in signatures please
perkiset
Olde World Hacker
Administrator
Lifer
*****
Online Online

Posts: 9792



View Profile
« Reply #8 on: July 06, 2010, 07:48:52 AM »

LOL but the code you posted above is PHP mate ... wtf?

People here are more likely to assist *you* in finding the answer than debugging that ... for people to take their time out to assist you you'll need to add more information about what's going on because there's not a lot of free time for people here to just load up your code and see why it breaks.
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
zarek
n00b
*
Offline Offline

Posts: 5


View Profile
« Reply #9 on: July 06, 2010, 03:57:02 PM »

code is php of course but if you look at the source of the problem, it's about understanding what this asp.net and ashx page do.

there is a function, which called "Login: function" in http://www.milliyetemlak.com/ajaxpro/ArapSabunu,App_Code.nunp_6_w.ashx adress.

it's kind of tricky too, because login form shows for post adress Member.aspx?Action=Login...

Then comes to my mind, there is a thing, should be about ashx and asp.net, that i cant discover.

May be an asp.net expert can see it easily.

Am i make myself clear enough ?

Before jumping into a conclusion, try to review problem.
Logged

No links in signatures please
perkiset
Olde World Hacker
Administrator
Lifer
*****
Online Online

Posts: 9792



View Profile
« Reply #10 on: July 06, 2010, 04:30:35 PM »

Am i make myself clear enough ?

Before jumping into a conclusion, try to review problem.
Um oh, ok. Let see: if you didn't write the asp code nor are in control of it, then it's not an ASP problem, is it? Would it be fair to say that any number of browsers can all log in to that site without knowing anything about ASP? I'd say yes. So the problem must be with your PHP code, not ASP because the serving language has nothing to do with browsing unless you've got dotNyet components involved. Actually it's not really even PHP per se, it looks to be a cURL problem. In fact, looking at the headers it looks like probably a cookie trick to keep you out of doing just what you're trying to do.

Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
zarek
n00b
*
Offline Offline

Posts: 5


View Profile
« Reply #11 on: July 07, 2010, 12:04:37 AM »

Am i make myself clear enough ?

Before jumping into a conclusion, try to review problem.
Um oh, ok. Let see: if you didn't write the asp code nor are in control of it, then it's not an ASP problem, is it? Would it be fair to say that any number of browsers can all log in to that site without knowing anything about ASP? I'd say yes. So the problem must be with your PHP code, not ASP because the serving language has nothing to do with browsing unless you've got dotNyet components involved. Actually it's not really even PHP per se, it looks to be a cURL problem. In fact, looking at the headers it looks like probably a cookie trick to keep you out of doing just what you're trying to do.



I am not sure what causes the problem.

Normally posted data should be seen under the content-length section but in this circumstance it's under the cache-control.

By the way, in firefox even i delete all cookies, i can login.

And in livehttpheaders, when i choose replay a message shown after logged "{"value":"Default.aspx?aType=Yenilikler"}"

But when i run php file, content-length value is 0. If i delete curl_opt POST commands, then it's shows adress as current view.
Logged

No links in signatures please
serialnoob
Journeyman
***
Offline Offline

Posts: 86


View Profile
« Reply #12 on: August 10, 2010, 04:06:28 PM »

Guess:

Any reason why you would use different use 2 diff user agents in the same process ?
Logged

Success consists of going from failure to failure without loss of enthusiasm - Winston Churchill
Pages: [1]
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!