Page 1 of 1

Need help with HTTPS authentication/login

Posted: Tue May 08, 2007 9:38 pm
by Bonne_den_kule
Hi!

How can I login to this site (and download the webpage) using WinAPI?
Link: https://lms.hfk.no/
The site is using some kind of IE login thing similar to a FTP login.

Posted: Tue May 08, 2007 10:17 pm
by Padde
https://login:pw@lms.hfk.no should do the trick

greets padde

Posted: Wed May 09, 2007 3:30 am
by Rook Zimbabwe
http:\\lms.hfk.no\user

But you will still need an active password.

Why don't you ask our Chinese fiends... err.... friends?

Posted: Fri May 11, 2007 3:27 am
by Rescator
That is a standard HTTP authentication, and the response headers tell me it's using the NTLM method.

A quick search on google for: http authentication ntlm
Came up with this: http://www.innovation.ch/personal/ronald/ntlm.html

Hopefully that should get you started at making the necessary handshake code for login. (you still need a valid user and pass from whomever run that site which I assume you have?)

And the fact it uses https:// do not really matter as you can try with http:// as well, but for proper support you might want to do https support too. (poke around these forums for info on https downloads etc.)

Posted: Fri May 11, 2007 2:54 pm
by Bonne_den_kule
Rescator wrote:That is a standard HTTP authentication, and the response headers tell me it's using the NTLM method.

A quick search on google for: http authentication ntlm
Came up with this: http://www.innovation.ch/personal/ronald/ntlm.html

Hopefully that should get you started at making the necessary handshake code for login. (you still need a valid user and pass from whomever run that site which I assume you have?)

And the fact it uses https:// do not really matter as you can try with http:// as well, but for proper support you might want to do https support too. (poke around these forums for info on https downloads etc.)
Ærlig talt, hvorfor tror alle at jeg er en hacker/haxxor? :P
Selvfølgelig har jeg passord og brukernavn.
Translation to english: bla, bla, bla....

Posted: Fri May 11, 2007 5:20 pm
by Num3
I did this code to post to Blogger with https...

It just connects to it for now, but maybe it gives you some pointers!

Code: Select all

; All stuff for the WinInet lib.
#INTERNET_OPEN_TYPE_DIRECT              = 1
#INTERNET_OPEN_TYPE_PRECONFIG           = 0
#HTTP_ADDREQ_FLAG_ADD                   = $20000000
#HTTP_ADDREQ_FLAG_REPLACE               = $80000000
#INTERNET_FLAG_SECURE                   = $800000
#INTERNET_FLAG_RELOAD                   = $80000000
#INTERNET_FLAG_PRAGMA_NOCACHE           = $100
#INTERNET_FLAG_KEEP_CONNECTION          = $400000
#INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTP  = $8000
#INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTPS = $4000
#INTERNET_FLAG_IGNORE_CERT_CN_INVALID   = $1000
#INTERNET_FLAG_IGNORE_CERT_DATE_INVALID = $2000
#INTERNET_FLAG_EXISTING_CONNECT         = $20000000
 
; Type of connection (could be FTP Gopher etc). HTTPS is done as HTTP too.
#INTERNET_SERVICE_HTTP = 3

; custom
#INTERNET_HTTP_PORT=80
#INTERNET_HTTPS_PORT=443

;#INTERNET_FLAG_SECURE


; open_handle = InternetOpen_("User Agent Info Goes Here",#INTERNET_OPEN_TYPE_DIRECT,"","",0)
; url.l=InternetOpenUrl_(open_handle)



Procedure.s do_post (host.s, url.s, login.s , Password.s, port, secureflag)
  
  result.s = ""
  
  ; All from the wininet DLL
  open_handle = InternetOpen_("User Agent Info Goes Here",#INTERNET_OPEN_TYPE_DIRECT,"","",0) 
  connect_handle = InternetConnect_(open_handle,host,#INTERNET_HTTPS_PORT,login,Password,#INTERNET_SERVICE_HTTP,0,0) 
  request_handle = HttpOpenRequest_(connect_handle,0,url,"HTTP/1.1","",0,#INTERNET_FLAG_SECURE,0)
  
  headers.s = "";"Content-Type: application/x-www-form-urlencoded"+Chr(13)+Chr(10)  
  
  post_data.s = login +":" + Password
  auth_pass.s=Space(512)
  Base64Encoder(@post_data,Len(post_data),@auth_pass,512)
  headers.s+"Authorization: BASIC "+ Trim(auth_pass) +Chr(13)+Chr(10) 
  
  
  ;HttpAddRequestHeaders_(request_handle,headers,Len(headers), #HTTP_ADDREQ_FLAG_REPLACE | #HTTP_ADDREQ_FLAG_ADD)
  
  send_handle = HttpSendRequest_(request_handle,"",0,headers,Len(headers))
  
  Buffer.s = Space(10240)
  bytes_read.l = 0
  total_read.l = 0
  
  ; Read until we can't read anymore..
  ct=0
  Repeat
    z=InternetReadFile_(request_handle,@Buffer,10240,@bytes_read)
    result + Left(Buffer,bytes_read)
    Buffer = Space(10240)
    
    ct+1
  Until bytes_read=0
  
  ProcedureReturn result
EndProcedure 


Debug do_post("www.blogger.com","/atom/xxxxxx","username","password",#INTERNET_HTTPS_PORT,#INTERNET_FLAG_SECURE )

Posted: Sat May 12, 2007 1:16 am
by Bonne_den_kule
@Num3: Very nice, solid work. Works perfect. I love this forum :D

Posted: Sat May 12, 2007 2:46 pm
by Pantcho!!
Thanks i need a code like this!

:)

Posted: Sat May 12, 2007 5:58 pm
by Psychophanta
Nice Num3 :)