2013년 9월 21일 토요일

LINE(라인) protocol analysis [4] : Registration


* 2014.08.02 update *

If you need a python code right away, then please keep in touch with https://github.com/carpedm20/LINE



* This post is composed of a collection of data that I got from the analysis of LINE registration
* I will beautify this post, later...


* There are two kinds of registration, one is for mobile phone and the other for tablet

* 1. For mobile phone : use SMS registration
* 2. For tablet : login with e-mail and password authentication

Links
====

https://gd2.line.naver.jp/authct/v1/keys/naver
http://t.line.naver.jp/authct/v1/keys # not working

# t stands for tablet ( maybe..? )
# t.line.naver.jp/authct is used when 'RegisterWithNaverIdOrEmailPageVM.SetIdentityCredential()' is called

https://t.line.naver.jp/authct/v1/keys/naver
https://t.line.naver.jp/authct/v1/keys/line



Wireshark Filter
============

ip.addr == 119.235.235.0/24 

.Net Reflector
===========



1. Tablet authentication
===================


  1. # from 'https://t.line.naver.jp/authct/v1/keys/line'
  2. {
  3.   "session_key":"jvhk3Vl3A1KJ8nK0",
  4.   "rsa_key":
  5.     "1696, # key name
  6.    DBAE063DBDC04244CD0D6669AC6545CD0E7337C1E6ABC74E4C939D3958AADB2EF5B51013D46C0BFD1C9AFFEAA72F771DA4D450347606EFBD082625920202EF848204E783456F59AD953EA3E5872A38CF6415C97B818DB6AD2C6C9AF84676DFFB358EA41F08A4B81D8F3A653F7D68C449F5650B5894323D0B3C0A1A12FEB9E6EBBDEB6F69B2AA1136741D3ACC504048AFAEBDB52C034F, # e
  7.    010001" # n
  8. }
  9. # personal information
  10. string password = String.fromCharCode (session_key.length) + session_key  
  11.                 + String.fromCharCode (email.length) + email  
  12.                 + String.fromCharCode (password.length) + password;  
  13. # generate encrypted password
  14. var rsa =  new  RSAKey ();  
  15. rsa.setPublic (evalue, nvalue);  
  16. password = rsa.encrypt (password);  
  17. # send POST request to http://gd2.line.naver.jp/rest/v1/login
  18. {
  19.   id : keyname  // In this case, '1696'
  20.   password : password  // encrypted password
  21.   persistent : 0  //  
  22.   provider : 1  //
  23. }

2. Mobile registration
=================

1. gm.line.naver.jp/api/v3/TalkService.do

   # request : [startverification] country_code + phone_number + druid + device_name + ???
   # response: auth_key(?)

2. gm.line.naver.jp/api/v3/TalkService.do

   # request : [verifyphone] auth_key + druid
   # response: verifyphone


3. gm.line.naver.jp/api/v3/TalkService.do

   # request : [registerDevice] auth_key
   # response : encrypted_key -> this is used to make X-Line-Access ( by using bellow C# code)



  # This code will make X-Line-Access key from auth_key

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace ConsoleApplication1
  6. {
  7.    
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             String issuedTo = "1" ;
  13.             DateTime l = DateTime .UtcNow;
  14.             long timestamp = (long )((- new DateTime(1970110001)).TotalMilliseconds);
  15.             String authToken = "????"; // auth_key
  16.             string[] strArray = authToken.Split(new char[] { ':' });
  17.             string issueTo = strArray[0];
  18.             string encodedSecretKey = strArray[1];
  19.             string str2 = string .Format("iat: {1}\n", issuedTo, timestamp);
  20.             string str3 = Convert .ToBase64String(Encoding.UTF8.GetBytes(str2));
  21.             string str4 = string .Empty;
  22.             string str5 = str3 + "." + str4;
  23.             byte[] key = Convert .FromBase64String(str3);
  24.             string str6 = Convert.ToBase64String(LINE.Service.YamlWebToken .HmacAlgorithm.CreateInstance(LINE.Service.YamlWebToken.DEFAULT_ALOGORITHM.Name, key).ComputeHash(Encoding.UTF8.GetBytes(str5)));
  25.             String str = str5 + "." + str6 // base64(issuedTo) + '..' + Hmac(SecretKey)
  26.         }
  27.     }
  28. }



In my view point, the analysis of LINE protocol was much easier than LOCO protocol which uses their own protocol.

Now, what...? :)

댓글 4개:

  1. have you considered making library or plugin to allow other chat programs to connect to LINE network?

    답글삭제
    답글
    1. No, I've never considered about that, but I think it is a great idea :) It might be fun if I could send and receive messages from other messenger program to LINE.

      삭제