steam动态令牌源码(python版本) 您所在的位置:网站首页 steam绑定sda steam动态令牌源码(python版本)

steam动态令牌源码(python版本)

2023-11-27 22:40| 来源: 网络整理| 查看: 265

steam动态令牌源码分享(python版本)

由于去年做了一个小项目,需要自动化的程序,所以研究起来steam的东西,steam游戏大家都不陌生,当你绑定手机之后,手机会有一个steam动态令牌,动态令牌是根据时间戳和你账号的SharedSecret参数进行加密的,一般绑定手机之后,他们会在你的手机上存放一个文件,里面就是保存你的SharedSecret参数的值,国外有个大神给搞出来令牌管理器,并且开源了,供大家使用,但是由于我做的项目需要实现steam自动登录自动发货,自动扫货,自动对比价等一些列功能,所以拿国外大神的源码研究一番,大神是用c#写的,但是我用的语言是python,所以我就打算把他的源码给转成python,供自己好实现项目功能,所以需要用的到朋友可以直接拿就好了。不用自己在研究c#代码再自己转换成python浪费时间。

下面放代码:

import base64 import hmac import json from hashlib import sha1 import aiohttp from aiohttp import ClientSession async def get_steam_server_time(): url = "https://api.steampowered.com/ITwoFactorService/QueryTime/v0001" headers = { "Host": "api.steampowered.com", "Content-Length": "9", "Expect": "100-continue", "Connection": "Keep-Alive" } data ={ "steamid": "0" } conn = aiohttp.TCPConnector(verify_ssl=False) async with ClientSession(connector=conn) as session: async with session.post(url=url, headers=headers, data=data, allow_redirects=False, timeout=10) as response: response = await response.read() response = response.decode() response = json.loads(response) server_time = response["response"]["server_time"] return server_time async def GenerateSteamGuardCodeForTime(time, SharedSecret): time = int(time) time = int(time / 30) token_code = "" steamGuardCodeTranslations = [50, 51, 52, 53, 54, 55, 56, 57, 66, 67, 68, 70, 71, 72, 74, 75, 77, 78, 80, 81, 82, 84, 86, 87, 88, 89] key_byte = base64.standard_b64decode(SharedSecret) code_byte = int(time).to_bytes(length=8, byteorder='big') hmac_code_tmp = hmac.new(key_byte, code_byte, sha1) hmac_code = hmac_code_tmp.digest() b = hmac_code[19] & 0xF codePoint = (hmac_code[b] & 0x7F)


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有