Last active
May 21, 2021 22:38
-
-
Save ii64/e32dfd5bd501da3836ee4960f2620f68 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const unirest = require('unirest') | |
headers = { | |
'Accept': 'application/x-thrift', | |
'Content-Type': 'application/x-thrift', | |
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36', | |
'X-Line-Application': 'ANDROIDLITE\t8.2.4\tAndroid\tOS\t6.0', | |
'X-LE': "18", | |
'X-LST': 1e3 * 1, | |
'X-LAL': "en", | |
'X-LHM': 'POST', | |
'X-LCS': "0005fF9u99g+fCJaX0CiyHrj+/nhwDV2k72si+qxjA9ZNcR/zlgE4W1i1DQL3/zhNBC4UDFlwGz5K+TN9iB0L3AhBJ8+FA9OrY9P/4CHtkrqvJmubO37mXmlXnNCyYk2vbb864it3sxbcl5B1HahIh9SkfHgZUvKek6hcobn/c3+GG033xuYvjBt/DzgfrkPcj4Gu3SFxKSGppTobvtkT/YZocTz+U9Hm0DalRsQr1DadjreZgUdSBlAv2DLd59SqEbsx8fIXIvkHZ8s/84ujTEIeA6t9mv2YA0GFobqejP0PSlNvlW5rN+EN/XVdfbF9YKyNxJIzjjFkPpy/F/1D3T13A==", | |
} | |
unirest | |
.post("https://gf.line.naver.jp/enc") | |
.encoding("latin1") | |
.headers(headers) | |
.send(Buffer.from([106, 204, 139, 83, 126, 106, 65, 96, 38, 202, 93, 211, 200, 152, 32, 20, 244, 204, 205, 230, 148, 131, 53, 220, 206, 144, 100, 11, 173, 82, 161, 230, 225, 166, 91, 215, 34, 78, 211, 88, 149, 111, 42, 6, 176, 239, 98, 100, 77, 158, 167, 94, 114, 197, 173, 160, 21, 2, 152, 212, 186, 134, 35, 166, 20, 95, 128, 59, 230, 149, 82, 59, 234, 80, 0, 241, 165, 53, 90, 231, 34, 163, 145, 90, 175, 184, 201, 133, 21, 138, 158, 73, 244, 181, 48, 49, 20, 237, 54, 122, 159, 94, 5, 62, 239, 221, 100, 234, 110, 106, 250, 188, 80, 209, 119, 255, 68, 227, 207, 17, 84, 13, 210, 1, 37, 67, 2, 13, 65, 1, 44, 155, 218, 247, 157, 190, 168, 111, 89, 182, 40, 105, 189, 90, 193, 67, 251, 218])) | |
.end(function(r){ | |
console.log("raw response w/o decrypt:", JSON.stringify((Buffer.from(r.body, 'latin1')))) | |
console.log("status code:", r.status, r.code) | |
console.log("response header:", r.headers) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package http | |
import ( | |
"io" | |
"net/http" | |
"io/ioutil" | |
) | |
const ( | |
GET = "GET" | |
POST = "POST" | |
PUT = "PUT" | |
DELETE = "DELET" | |
) | |
type OBSHttpClient struct { | |
url string | |
headers map[string]string | |
body io.Reader | |
client *http.Client | |
req *http.Request | |
} | |
type Options struct { | |
Url string | |
Headers map[string]string | |
Body io.Reader | |
} | |
func NewOBSHttpClient(opt Options) *OBSHttpClient { | |
o := &OBSHttpClient{ | |
url: opt.Url, | |
headers: opt.Headers, | |
body: opt.Body, | |
client: &http.Client{}, | |
} | |
return o | |
} | |
type ResponseReader struct { | |
Response *http.Response | |
} | |
func (self *ResponseReader) Content() (body []byte, err error) { | |
defer self.Response.Body.Close() | |
body, err = ioutil.ReadAll(self.Response.Body) | |
return | |
} | |
func (self *ResponseReader) Text() (body string, err error) { | |
t, err := self.Content() | |
body = string(t) | |
return | |
} | |
func (self *OBSHttpClient) New() (*OBSHttpClient) { | |
self.client = &http.Client{} | |
return self | |
} | |
func (self *OBSHttpClient) setupHeaders() { | |
for k, v := range self.headers { | |
self.req.Header.Add(k, v) | |
} | |
} | |
func (self *OBSHttpClient) Get() (*OBSHttpClient) { | |
self.req, _ = http.NewRequest(GET, self.url, self.body) | |
self.setupHeaders() | |
return self | |
} | |
func (self *OBSHttpClient) Post() (*OBSHttpClient) { | |
self.req, _ = http.NewRequest(POST, self.url, self.body) | |
self.setupHeaders() | |
return self | |
} | |
func (self *OBSHttpClient) Put() (*OBSHttpClient) { | |
self.req, _ = http.NewRequest(PUT, self.url, self.body) | |
self.setupHeaders() | |
return self | |
} | |
func (self *OBSHttpClient) Delete() (*OBSHttpClient) { | |
self.req, _ = http.NewRequest(DELETE, self.url, self.body) | |
self.setupHeaders() | |
return self | |
} | |
func (self *OBSHttpClient) Exec() (r *ResponseReader, e error) { | |
o, e := self.client.Do(self.req) | |
r = &ResponseReader{o} | |
return | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"../http" | |
"bytes" | |
) | |
func main() { | |
cl := http.NewOBSHttpClient(http.Options{ | |
Url: "https://gfs.line.naver.jp/enc", | |
Headers: map[string]string{ | |
"content-type": "application/x-thrift", | |
"accept": "application/x-thrift; charset=latin1", | |
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36", | |
"x-line-application": "ANDROIDLITE\t8.2.4\tAndroid\tOS\t6.0", | |
"x-le": "18", | |
"x-lst": "1000", | |
"x-lal": "en", | |
"x-lcs": "0005fF9u99g+fCJaX0CiyHrj+/nhwDV2k72si+qxjA9ZNcR/zlgE4W1i1DQL3/zhNBC4UDFlwGz5K+TN9iB0L3AhBJ8+FA9OrY9P/4CHtkrqvJmubO37mXmlXnNCyYk2vbb864it3sxbcl5B1HahIh9SkfHgZUvKek6hcobn/c3+GG033xuYvjBt/DzgfrkPcj4Gu3SFxKSGppTobvtkT/YZocTz+U9Hm0DalRsQr1DadjreZgUdSBlAv2DLd59SqEbsx8fIXIvkHZ8s/84ujTEIeA6t9mv2YA0GFobqejP0PSlNvlW5rN+EN/XVdfbF9YKyNxJIzjjFkPpy/F/1D3T13A==", | |
"x-lhm": "POST", | |
}, | |
Body: bytes.NewReader([]byte{106, 204, 139, 83, 126, 106, 65, 96, 38, 202, 93, 211, 200, 152, 32, 20, 244, 204, 205, 230, 148, 131, 53, 220, 206, 144, 100, 11, 173, 82, 161, 230, 225, 166, 91, 215, 34, 78, 211, 88, 149, 111, 42, 6, 176, 239, 98, 100, 77, 158, 167, 94, 114, 197, 173, 160, 21, 2, 152, 212, 186, 134, 35, 166, 20, 95, 128, 59, 230, 149, 82, 59, 234, 80, 0, 241, 165, 53, 90, 231, 34, 163, 145, 90, 175, 184, 201, 133, 21, 138, 158, 73, 244, 181, 48, 49, 20, 237, 54, 122, 159, 94, 5, 62, 239, 221, 100, 234, 110, 106, 250, 188, 80, 209, 119, 255, 68, 227, 207, 17, 84, 13, 210, 1, 37, 67, 2, 13, 65, 1, 44, 155, 218, 247, 157, 190, 168, 111, 89, 182, 40, 105, 189, 90, 193, 67, 251, 218}), | |
}) | |
r, e := cl.Post().Exec() | |
if e != nil { | |
panic(e) | |
} | |
fmt.Printf("%#+v\n", r.Response.StatusCode) | |
fmt.Printf("%#+v\n", r.Response.Proto) | |
fmt.Printf("%#+v\n", r.Response.Header) | |
cp, _ := r.Content() | |
fmt.Println("resp: ", cp) | |
} |
54, 39, 91, 233, 140, 239, 160, 195, 158, 211, 0
is missing from the golang's response body
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Golang response: [1, 138, 85, 127, 229, 133, 219, 167, 11, 33, 236, 243, 64, 40, 38, 87, 21, 106, 138, 133, 123, 248, 47, 3, 142, 241, 185, 181, 84, 224, 210, 106, 9, 115, 251, 134, 72, 57, 201, 193, 181, 148, 130, 55, 195, 114, 96, 225, 182, 219, 199, 18, 58, 11, 54, 115, 152, 236, 51, 132, 83, 20, 194, 55, 247, 168, 42, 226, 185, 91, 35, 224, 155, 226, 234, 170, 178, 112, 40, 62, 103, 228, 174, 222, 83, 119, 248, 69, 190]
Nodejs response: [1,138,85,127,229,133,219,167,11,33,236,243,64,40,38,87,21,106,138,133,123,248,47,3,142,241,185,181,84,224,210,106,9,115,251,134,72,57,201,193,181,148,130,55,195,114,96,225,182,219,199,18,58,11,54,115,152,236,51,132,83,20,194,55,247,168,42,226,185,91,35,224,155,226,234,170,178,112,40,62,103,228,174,222,83,119,248,69,190,54,39,91,233,140,239,160,195,158,211,0]