Ejemplo n.º 1
0
 def qrLogin(self, headers):
     sys_name = "BE-Team"
     transport = THttpClient(self.lineServer + '/api/v4/TalkService.do')
     transport.setCustomHeaders(headers)
     protocol = TCompactProtocol(transport)
     talk = TalkService.Client(protocol)
     qr_code = talk.getAuthQrcode(keepLoggedIn=True,
                                  systemName=sys_name,
                                  returnCallbackUrl=True)
     transport.close()
     print(qr_code.callbackUrl)
     headers["X-Line-Access"] = qr_code.verifier
     transport = THttpClient(self.lineServer + '/api/v4p/rs')
     transport.setCustomHeaders(headers)
     protocol = TCompactProtocol(transport)
     auth = TalkService.Client(protocol)
     get_access = json.loads(
         requests.get(self.lineServer + '/Q', headers=headers).text)
     login_request = LoginRequest()
     login_request.type = 1
     login_request.identityProvider = 1
     login_request.keepLoggedIn = True
     login_request.systemName = sys_name
     login_request.verifier = get_access['result']['verifier']
     result = auth.loginZ(login_request)
     transport.close()
     return result.authToken
Ejemplo n.º 2
0
    def create(
            cls, host, port=DEFAULT_AURORA_PORT, encoding='json'):
        """
           Parses a host name and sets up Torando and Thrift client
        """
        # To recieve and send binary thrift to the Aurora master we need to set
        # headers appropriately.
        transport = THttpClient('http://%s:%s/api' % (host, str(port)))

        # Set aurora credentials in transport header if the environment
        # variables have been set
        if os.getenv('AURORA_USERNAME') and os.getenv('AURORA_PASSWORD'):
            username = os.getenv('AURORA_USERNAME')
            password = os.getenv('AURORA_PASSWORD')
            credentials = base64.encodestring(
                '%s:%s' % (username, password)).replace('\n', '')
            auth_header = "Basic %s" % credentials
            transport.setCustomHeaders({'Authorization': auth_header})

        if encoding == 'binary':
            transport.setCustomHeaders({
                'Content-Type': 'application/vnd.apache.thrift.binary',
                'Accept': 'application/vnd.apache.thrift.binary',
            })
            protocol = TBinaryProtocol(transport)
        elif encoding == 'json':
            protocol = TJSONProtocol(transport)
        else:
            raise Exception('Unknown encoding %s' % encoding)

        client = Client(protocol)
        return client
Ejemplo n.º 3
0
def qrLogin():
    headers= {
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.79 Safari/537.36",
        "X-Line-Application": "CHROMEOS\t2.3.2\tChrome OS\t1",
        "x-lal": "en_ID",
        "X-Line-Carrier": "51010,1-0"
    }
    sys_name = "BE-Team"
    transport = THttpClient("https://ga2.line.naver.jp" + '/api/v4/TalkService.do')
    transport.setCustomHeaders(headers)
    protocol = TCompactProtocol(transport)
    talk = BoteaterService.Client(protocol)
    qr_code = talk.getAuthQrcode(keepLoggedIn=True, systemName=sys_name, returnCallbackUrl=True)
    transport.close()
    print(qr_code.callbackUrl)
    headers["X-Line-Access"] = qr_code.verifier
    transport = THttpClient("https://ga2.line.naver.jp" + '/api/v4p/rs')
    transport.setCustomHeaders(headers)
    protocol = TCompactProtocol(transport)
    auth = BoteaterService.Client(protocol)
    get_access = json.loads(requests.get("https://ga2.line.naver.jp" + '/Q', headers=headers).text)
    login_request = LoginRequestStruct()
    login_request.type = 1
    login_request.identityProvider = 1
    login_request.keepLoggedIn = True
    login_request.systemName = sys_name
    login_request.verifier = get_access['result']['verifier']
    result = auth.loginZ(login_request)
    transport.close()
    return result.authToken
Ejemplo n.º 4
0
    def create(cls, host, port=DEFAULT_AURORA_PORT, encoding="json"):
        """
           Parses a host name and sets up Torando and Thrift client
        """
        # To recieve and send binary thrift to the Aurora master we need to set
        # headers appropriately.
        transport = THttpClient("http://%s:%s/api" % (host, str(port)))

        # Set aurora credentials in transport header if the environment
        # variables have been set
        if os.getenv("AURORA_USERNAME") and os.getenv("AURORA_PASSWORD"):
            username = os.getenv("AURORA_USERNAME")
            password = os.getenv("AURORA_PASSWORD")
            credentials = base64.encodestring(
                "%s:%s" % (username, password)
            ).replace("\n", "")
            auth_header = "Basic %s" % credentials
            transport.setCustomHeaders({"Authorization": auth_header})

        if encoding == "binary":
            transport.setCustomHeaders(
                {
                    "Content-Type": "application/vnd.apache.thrift.binary",
                    "Accept": "application/vnd.apache.thrift.binary",
                }
            )
            protocol = TBinaryProtocol(transport)
        elif encoding == "json":
            protocol = TJSONProtocol(transport)
        else:
            raise Exception("Unknown encoding %s" % encoding)

        client = Client(protocol)
        return client
Ejemplo n.º 5
0
def get_http_transport(host, port, http_path, timeout=None, use_ssl=False,
                       ca_cert=None, auth_mechanism='NOSASL', user=None,
                       password=None):
    # TODO: support timeout
    if timeout is not None:
        log.error('get_http_transport does not support a timeout')
    if use_ssl:
        url = 'https://%s:%s/%s' % (host, port, http_path)
        log.debug('get_http_transport url=%s', url)
        # TODO(#362): Add server authentication with thrift 0.12.
        transport = THttpClient(url)
    else:
        url = 'http://%s:%s/%s' % (host, port, http_path)
        log.debug('get_http_transport url=%s', url)
        transport = THttpClient(url)

    # Set defaults for PLAIN SASL / LDAP connections.
    if auth_mechanism in ['PLAIN', 'LDAP']:
        if user is None:
            user = getpass.getuser()
            log.debug('get_http_transport: user=%s', user)
        if password is None:
            if auth_mechanism == 'LDAP':
                password = ''
            else:
                # PLAIN always requires a password for HS2.
                password = '******'
        log.debug('get_http_transport: password=%s', password)
        auth_mechanism = 'PLAIN'  # sasl doesn't know mechanism LDAP
        # Set the BASIC auth header
        auth = base64.encodestring('%s:%s' % (user, password)).strip('\n')
        transport.setCustomHeaders({'Authorization': 'Basic %s' % auth})

    return transport
Ejemplo n.º 6
0
 def openTransport(self, endPoint, pool=False):
     if pool:
         #transport = THttpClientPool(self.lineServer + endPoint)
         transport = THttpClient(self.lineServer + endPoint)
     else:
         transport = THttpClient(self.lineServer + endPoint)
     transport.setCustomHeaders(self.thisHeaders)
     protocol = TCompactProtocol(transport)
     return BEService.Client(protocol)
Ejemplo n.º 7
0
def add_http_mode_support(username=user,
                          password=password,
                          port=port,
                          httpPath="/cliservice",
                          host=hostname,
                          transportMode="http"):
    ap = "%s:%s" % (username, password)
    _transport = THttpClient(host, port=port, path=httpPath)
    _transport.setCustomHeaders(
        {"Authorization": "Basic " + base64.b64encode(ap).strip()})
    return _transport
Ejemplo n.º 8
0
def getMid(my_token):
    headers= {
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.79 Safari/537.36",
        "X-Line-Application": "CHROMEOS\t2.3.2\tChrome OS\t1",
        "x-lal": "en_ID",
        "X-Line-Carrier": "51010,1-0"
    }
    headers["X-Line-Access"] = my_token
    transport = THttpClient("https://ga2.line.naver.jp" + '/api/v4/TalkService.do')
    transport.setCustomHeaders(headers)
    protocol = TCompactProtocol(transport)
    talk = BoteaterService.Client(protocol)
    mid = talk.getProfile().mid
    transport.close()
    return mid
Ejemplo n.º 9
0
 def createService(self, path, serviceFunc, headers=None):
     transport = THttpClient(f"https://gd2.line.naver.jp{path}")
     if headers is None:
         headers = {
             "X-Line-Application": self.account.getLineApplication(),
             "User-Agent": self.account.getUserAgent(),
             "X-Line-Access": self.account.getAuthToken(),
         }
     # setting the headers for the transport
     transport.setCustomHeaders(headers)
     # initiating the factory for CompactProtocol
     factory = TCompactProtocolFactory()
     # getting the CompactProtocol
     protocol = factory.getProtocol(transport)
     # initiating a new client using the protocol provided
     return serviceFunc.Client(protocol)
Ejemplo n.º 10
0
 def openTransport(self, endPoint):
     transport = THttpClient(self.lineServer + endPoint)
     transport.setCustomHeaders(self.thisHeaders)
     protocol = TCompactProtocol(transport)
     return TalkService.Client(protocol)
Ejemplo n.º 11
0
    def __init__(self, my_app, my_token=None):
        self.lineServer = "https://ga2.line.naver.jp"
        self.lineOBS = "https://obs-sg.line-apps.com"
        self.boteaterApi = "https://api.boteater.us"
        self.liffServer = "https://api.line.me/message/v3/share"
        self.stickerLink = "https://stickershop.line-scdn.net/stickershop/v1/sticker/{}/iPhone/[email protected]"
        self.stickerLinkAnimation = "https://stickershop.line-scdn.net/stickershop/v1/sticker/{}/iPhone/[email protected]"
        self.dataHeaders = {
            "android_lite": {
                "User-Agent": "LLA/2.11.1 samsung 5.1.1",
                "X-Line-Application": "ANDROIDLITE\t2.11.1\tAndroid OS\t5.1.1",
                "x-lal": "en_ID",
                "X-Line-Carrier": "51010,1-0"
            },
            "android": {
                "User-Agent": "Line/10.1.1",
                "X-Line-Application": "ANDROID\t10.1.1\tAndroid OS\t5.1.1",
                "x-lal": "en_ID",
                "X-Line-Carrier": "51010,1-0"
            },
            "ios_ipad": {
                "User-Agent": "Line/10.1.1",
                "X-Line-Application": "IOSIPAD\t10.1.1\tiPhone 8\t11.2.5",
                "x-lal": "en_ID",
                "X-Line-Carrier": "51010,1-0"
            },
            "ios": {
                "User-Agent": "Line/10.1.1",
                "X-Line-Application": "IOS\t10.1.1\tiPhone 8\t11.2.5",
                "x-lal": "en_ID",
                "X-Line-Carrier": "51010,1-0"
            },
            "chrome": {
                "User-Agent":
                "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.79 Safari/537.36",
                "X-Line-Application": "CHROMEOS\t2.3.2\tChrome OS\t1",
                "x-lal": "en_ID",
                "X-Line-Carrier": "51010,1-0"
            },
            "desktopwin": {
                "User-Agent": "Line/5.12.3",
                "X-Line-Application": "DESKTOPWIN\t5.21.3\tWindows\t10",
                "x-lal": "en_ID",
                "X-Line-Carrier": "51010,1-0"
            },
            "desktopmac": {
                "User-Agent": "Line/5.12.3",
                "X-Line-Application": "DESKTOPMAC\t5.21.3\tMAC\t10.15",
                "x-lal": "en_ID",
                "X-Line-Carrier": "51010,1-0"
            }
        }
        if my_app in self.dataHeaders:
            self.headers = self.dataHeaders[my_app]
            if my_token != None:
                self.headers["X-Line-Access"] = my_token
            else:
                self.headers["X-Line-Access"] = self.qrLogin(self.headers)
        else:
            raise Exception('APP not found!!!')

        ### CONNECT TO POOL ###
        transport = THttpClient(self.lineServer + '/P4')
        transport.setCustomHeaders(self.headers)
        transport.open()
        protocol = TCompactProtocol(transport)
        self.pool = OperationService.Client(protocol)

        ### CONNECT TO TALK ###
        transport = THttpClient(self.lineServer + '/api/v4/TalkService.do')
        transport.setCustomHeaders(self.headers)
        transport.open()
        protocol = TCompactProtocol(transport)
        self.talk = TalkService.Client(protocol)

        ### CONNECT TO CHANNEL ###
        transport = THttpClient(self.lineServer + '/CH4')
        transport.setCustomHeaders(self.headers)
        transport.open()
        protocol = TCompactProtocol(transport)
        self.channel = ChannelService.Client(protocol)

        ### CONNECT TO CALL ###
        transport = THttpClient(self.lineServer + '/V4')
        transport.setCustomHeaders(self.headers)
        transport.open()
        protocol = TCompactProtocol(transport)
        self.call = CallService.Client(protocol)

        ### CONNECT TO SHOP ###
        transport = THttpClient(self.lineServer + '/TSHOP4')
        transport.setCustomHeaders(self.headers)
        transport.open()
        protocol = TCompactProtocol(transport)
        self.shop = ShopService.Client(protocol)

        ### CONNECT TO LIFF ###
        transport = THttpClient(self.lineServer + '/LIFF1')
        transport.setCustomHeaders(self.headers)
        transport.open()
        protocol = TCompactProtocol(transport)
        self.liff = LiffService.Client(protocol)

        self.profile = self.getProfile()
        self.lastOP = self.getLastOpRevision()
        self.liffPermision()
        self.tokenOBS = self.acquireEncryptedAccessToken()
        print("[ Login ] Display Name: " + self.profile.displayName)
        print("[ Login ] Auth Token: " + self.headers["X-Line-Access"])

        ### TIMELINE HEADERS ###
        self.tl_headers = copy.deepcopy(self.headers)
        self.tl_headers["X-Line-ChannelToken"] = self.issueChannelToken(
            '1341209950').channelAccessToken
        self.tl_headers["X-Line-Mid"] = self.profile.mid
        self.tl_headers["X-Line-AcceptLanguage"] = 'en'
        self.tl_headers[
            "X-Requested-With"] = 'jp.naver.line.android.LineApplication'
        self.tl_headers["Content-Type"] = 'application/json'
Ejemplo n.º 12
0
    def __init__(self, my_app, my_token=None, server=None):
        if server == "japan":
            self.line_server = "https://ga2.line.naver.jp"  #Japan
        elif server == "sg":
            self.line_server = "https://ga2s.line.naver.jp"  #Indo/Singapure
        else:
            self.line_server = "https://gd2.line.naver.jp"  #Japan
        self.line_obs = "https://obs-sg.line-apps.com"
        self.boteater_api = "https://api.boteater.us"
        self.liff_url = "https://api.line.me/message/v3/share"
        self.sticker_link = "https://stickershop.line-scdn.net/stickershop/v1/sticker/{}/iPhone/[email protected]"
        self.sticker_link_animation = "https://stickershop.line-scdn.net/stickershop/v1/sticker/{}/iPhone/[email protected]"
        self.data_headers = self.read_json("headers.json")
        if my_app in self.data_headers:
            self.headers = self.data_headers[my_app]
            if my_token != None:
                self.headers["X-Line-Access"] = my_token
            else:
                del self.headers["X-Line-Access"]
                self.headers["X-Line-Access"] = self.qr_login(self.headers)
        else:
            raise Exception('APP not found!!!')

        ### CONNECT TO POOL ###
        transport = THttpClient(self.line_server + '/P4')
        transport.setCustomHeaders(self.headers)
        transport.open()
        protocol = TCompactProtocol(transport)
        self.pool = BoteaterService.Client(protocol)

        ### CONNECT TO TALK ###
        transport = THttpClient(self.line_server + '/api/v4/TalkService.do')
        transport.setCustomHeaders(self.headers)
        transport.open()
        protocol = TCompactProtocol(transport)
        self.talk = BoteaterService.Client(protocol)

        ### CONNECT TO CHANNEL ###
        transport = THttpClient(self.line_server + '/CH4')
        transport.setCustomHeaders(self.headers)
        transport.open()
        protocol = TCompactProtocol(transport)
        self.channel = BoteaterService.Client(protocol)

        ### CONNECT TO CALL ###
        transport = THttpClient(self.line_server + '/V4')
        transport.setCustomHeaders(self.headers)
        transport.open()
        protocol = TCompactProtocol(transport)
        self.call = BoteaterService.Client(protocol)

        ### CONNECT TO SHOP ###
        transport = THttpClient(self.line_server + '/TSHOP4')
        transport.setCustomHeaders(self.headers)
        transport.open()
        protocol = TCompactProtocol(transport)
        self.shop = BoteaterService.Client(protocol)

        ### CONNECT TO LIFF ###
        transport = THttpClient(self.line_server + '/LIFF1')
        transport.setCustomHeaders(self.headers)
        transport.open()
        protocol = TCompactProtocol(transport)
        self.liff = BoteaterService.Client(protocol)

        self.profile_data = self.talk.getProfile()
        self.my_mid = self.profile_data.mid
        self.last_op = self.pool.getLastOpRevision()
        self.issue_liff_view()
        self.tl_channel = self.issue_channel_token(
            '1341209950').channelAccessToken
        self.tl_headers = copy.deepcopy(self.headers)
        self.tl_headers["X-Line-ChannelToken"] = self.tl_channel
        self.tl_headers["X-Line-Mid"] = self.my_mid
        self.tl_headers["X-Line-AcceptLanguage"] = 'en'
        self.tl_headers[
            "X-Requested-With"] = 'jp.naver.line.android.LineApplication'
        self.tl_headers["Content-Type"] = 'application/json'

        self.my_OBStoken = self.gen_obs_token()
        print("[ Login ] Display Name: " + self.profile_data.displayName)
        self.temp_data = self.read_json("tmp.json")
Ejemplo n.º 13
0
    def __init__(self, my_app, my_token=None):
        self.lineServer = "https://ga2.line.naver.jp"
        self.lineOBS = "https://obs-sg.line-apps.com"
        self.boteaterApi = "https://api.boteater.us"
        self.liffServer = "https://api.line.me/message/v3/share"
        self.stickerLink = "https://stickershop.line-scdn.net/stickershop/v1/sticker/{}/iPhone/[email protected]"
        self.stickerLinkAnimation = "https://stickershop.line-scdn.net/stickershop/v1/sticker/{}/iPhone/[email protected]"
        self.dataHeaders = self.readJson("headers.json")
        if my_app in self.dataHeaders:
            self.headers = self.dataHeaders[my_app]
            if my_token != None:
                self.headers["X-Line-Access"] = my_token
            else:
                del self.headers["X-Line-Access"]
                self.headers["X-Line-Access"] = self.qrLogin(self.headers)
                #self.headers["X-Line-Access"] = self.qrLoginRotate("ios_ipad")
        else:
            raise Exception('APP not found!!!')

        ### CONNECT TO POOL ###
        transport = THttpClient(self.lineServer + '/P4')
        transport.setCustomHeaders(self.headers)
        transport.open()
        protocol = TCompactProtocol(transport)
        self.pool = BoteaterService.Client(protocol)
        
        ### CONNECT TO TALK ###
        transport = THttpClient(self.lineServer + '/api/v4/TalkService.do')
        transport.setCustomHeaders(self.headers)
        transport.open()
        protocol = TCompactProtocol(transport)
        self.talk = BoteaterService.Client(protocol)

        ### CONNECT TO CHANNEL ###
        transport = THttpClient(self.lineServer + '/CH4')
        transport.setCustomHeaders(self.headers)
        transport.open()
        protocol = TCompactProtocol(transport)
        self.channel = BoteaterService.Client(protocol)

        ### CONNECT TO CALL ###
        transport = THttpClient(self.lineServer + '/V4')
        transport.setCustomHeaders(self.headers)
        transport.open()
        protocol = TCompactProtocol(transport)
        self.call = BoteaterService.Client(protocol)

        ### CONNECT TO SHOP ###
        transport = THttpClient(self.lineServer + '/TSHOP4')
        transport.setCustomHeaders(self.headers)
        transport.open()
        protocol = TCompactProtocol(transport)
        self.shop = BoteaterService.Client(protocol)

        ### CONNECT TO LIFF ###
        transport = THttpClient(self.lineServer + '/LIFF1')
        transport.setCustomHeaders(self.headers)
        transport.open()
        protocol = TCompactProtocol(transport)
        self.liff = BoteaterService.Client(protocol)

        self.profile = self.getProfile()
        self.lastOP = self.getLastOpRevision()
        self.liffPermision()
        self.tokenOBS = self.acquireEncryptedAccessToken()
        print("[ Login ] Display Name: " + self.profile.displayName)

        ### TIMELINE HEADERS ###
        self.tl_headers= copy.deepcopy(self.headers)
        self.tl_headers["X-Line-ChannelToken"] = self.issueChannelToken('1341209950').channelAccessToken
        self.tl_headers["X-Line-Mid"] = self.profile.mid
        self.tl_headers["X-Line-AcceptLanguage"] = 'en'
        self.tl_headers["X-Requested-With"] = 'jp.naver.line.android.LineApplication'
        self.tl_headers["Content-Type"] = 'application/json'
Ejemplo n.º 14
0
 def get_protocol(host, endpoint, headers={}):
     transport = THttpClient(host + endpoint)
     transport.setCustomHeaders(headers)
     protocol = TCompactProtocol(transport)
     return protocol