Nhờ tóm tắt cơ chế hoạt động tool auto game trên ví điện tử ViettelPay

Chào mọi người ! Nhờ mọi người giải thích giúp cơ chế hoạt động của tool auto “game lắc Mana” này và nó dùng API nào của Viettel ạ ? Tại sao ví điện tử mà lại có tool auto như này
Link gốc:

Nội dung file python :

    import requests, json
BASE_URL = 'https://vtpay9.viettel.vn'

class ViettelPay:
    def __init__(self, phone, token = None):
        self.phone = phone
        
        s = requests.session()
        
        s.headers = {
            'Password': 'digital@2020',
            'Channel': 'APP',
            'Content-Type': 'application/json',
            'User-Id': self.phone,
            'User-Agent': 'ViettelPay/3.3.1 (iPhone; iOS 13.3; Scale/3.00)',
            'Authorization': token
        }
        
        self.s = s
    
    def requestLogin(self, phone):
        return self.s.get(BASE_URL + '/shake-2020/user/request-login').json()

    def login(self, otp):
        data = {'otp': otp}
        
        r = self.s.post(BASE_URL + '/shake-2020/user/login', data=json.dumps(data)).json()
        
        if (r['status']['code'] != '00'):
            return [False, r]

        self.s.headers['Authorization'] = r['data']['token']
        
        return [True, r]

    def getProfile(self):
        return self.s.get(BASE_URL + '/shake-2020/user/profile').json()

    def play(self):
        return self.s.post(BASE_URL + '/shake-2020/game/play').json()

if __name__ == '__main__':
    print('ViettelPay auto roll 2019 - By T-Rekt - J2TEAM\n')

    print('Please input your phone number: ')
    phone = input()
    if (phone[0] == '0'):
        phone = phone[1:]

    vtp = ViettelPay(phone)
    sendOtp = vtp.requestLogin(phone)

    if (sendOtp['status']['code'] != '00'):
        print('Send OTP failed')
        exit(0)

    print('Please input your OTP: ')
    otp = input()
    if (vtp.login(otp)[1]['status']['code'] != '00'):
        print('Login failed')
        exit(0)

    profile = vtp.getProfile()
    turnsLeft = profile['data']['totalTurnLeft']

    while (turnsLeft):
        rollResult = vtp.play()
        reward = ''
        if (rollResult['data']):
            reward = rollResult['data']['name']
        print(f"Turns left: {turnsLeft}. Rolled: {rollResult['status']['message']}. {reward}")
        # print(rollResult)
        turnsLeft -= 1

    print('Out of turn')

Cảm ơn ạ

Tại vì trò này được ứng dụng Ví kia “lắc” thông qua giao thức htttp:// (trả về JSON) nên bị mấy ông J2TEAM bắt thóp được và làm ứng dụng giúp “lắc” siêu nhanh cho đỡ mỏi tay mà.

5 Likes

cái ứng dụng ví kia sử dụng các API kia để giao tiếp với server của VT khi lắc. Các anh bên đội kia trích xuất ra được nên viết script tự động thay cho việc lắc điện thoại thôi mà.
Các API kia cũng k cần giấu kĩ quá làm gì nên bị trích ra dễ thôi vì cái chính vẫn là server có nhả cho user trúng quà hay không

5 Likes

Cho em hỏi làm sao xem được request với response khi dùng những app trên mobile ạ?

1 Like

em thấy python có cái module requests.
Xong lúc khởi tạo thì kiểu tạo mới 1 đối tượng session()
Nhờ đó mà lúc gửi request sendOtp với đăng nhập đều dùng chung 1 phiên làm việc được.
Nếu chuyển sang ngôn ngữ khác ví dụ Java thì em dùng HttpUrlConnection chỉ gửi đc
get request yêu cầu gửi otp còn đến lúc post login nó báo 403.

Ngôn ngữ nào cũng hỗ trợ thao tác với web API có yêu cầu session hết. Bạn nghiên cứu về cookies jar trong java nhé

4 Likes
83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?