Need help with HTTPS authentication/login

Just starting out? Need help? Post your questions and find answers here.
Bonne_den_kule
Addict
Addict
Posts: 841
Joined: Mon Jun 07, 2004 7:10 pm

Need help with HTTPS authentication/login

Post 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.
Padde
New User
New User
Posts: 5
Joined: Wed Apr 11, 2007 2:56 am

Post by Padde »

https://login:pw@lms.hfk.no should do the trick

greets padde
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Post 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?
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
User avatar
Rescator
Addict
Addict
Posts: 1769
Joined: Sat Feb 19, 2005 5:05 pm
Location: Norway

Post 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.)
Bonne_den_kule
Addict
Addict
Posts: 841
Joined: Mon Jun 07, 2004 7:10 pm

Post 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....
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post 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 )
Bonne_den_kule
Addict
Addict
Posts: 841
Joined: Mon Jun 07, 2004 7:10 pm

Post by Bonne_den_kule »

@Num3: Very nice, solid work. Works perfect. I love this forum :D
Pantcho!!
Enthusiast
Enthusiast
Posts: 538
Joined: Tue Feb 24, 2004 3:43 am
Location: Israel
Contact:

Post by Pantcho!! »

Thanks i need a code like this!

:)
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Post by Psychophanta »

Nice Num3 :)
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
Post Reply