0% found this document useful (0 votes)
189 views2 pages

Steam Ticket - Py

This Python script is a Steam App Ticket Dumper that allows users to log into their Steam account and retrieve encrypted app tickets for owned games. It utilizes the Steam API to fetch game details and handles user authentication, including two-factor authentication if necessary. The retrieved tickets are saved as base64-encoded text files for further use.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
189 views2 pages

Steam Ticket - Py

This Python script is a Steam App Ticket Dumper that allows users to log into their Steam account and retrieve encrypted app tickets for owned games. It utilizes the Steam API to fetch game details and handles user authentication, including two-factor authentication if necessary. The retrieved tickets are saved as base64-encoded text files for further use.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

#!

/usr/bin/env python
import base64, binascii, requests
from pathlib import Path
from steam.client import SteamClient
from steam.enums import EResult

API_KEY = "ENTER_API_KEY_HERE"
CACHE = {}

def name(a):
if a in CACHE: return CACHE[a]
try:
j = requests.get(f"https://store.steampowered.com/api/appdetails?
appids={a}", timeout=10).json()
if j.get(str(a), {}).get("success"):
CACHE[a] = j[str(a)]["data"]["name"]; return CACHE[a]
except: pass

def games(sid):
if not API_KEY: return
try:
j =
requests.get(f"https://api.steampowered.com/IPlayerService/GetOwnedGames/v0001/?
key={API_KEY}&steamid={sid}&format=json&include_appinfo=1", timeout=15).json()
g = j.get("response", {}).get("games", [])
for x in g:
if not x.get("name"): x["name"] = name(x["appid"]) or f"Unknown
({x['appid']})"
return sorted(g, key=lambda x: x.get("name", ""))
except: pass

def pick(g):
if not g: return
print(f"\nFound {len(g)} games:")
for i,x in enumerate(g,1): print(f"{i}. {x['name']} (AppID: {x['appid']})")
print(f"{len(g)+1}. Enter different AppID")
try:
s=int(input("Select: "))
if 1<=s<=len(g): return g[s-1]["appid"]
if s==len(g)+1: return int(input("Enter AppID: "))
except: pass

def vi(n):
b=bytearray()
while n>=0x80: b.append((n&0x7F)|0x80); n>>=7
b.append(n); return bytes(b)

def ticket(c,a,u=b""):
r=c.get_encrypted_app_ticket(app_id=a,userdata=u)
if r and r.eresult==EResult.OK and r.encrypted_app_ticket:
t=r.encrypted_app_ticket
return b"\x08\x02"+b"\x10"+vi(t.crc_encryptedticket)+b"\x18\x00"+b"\
x20"+vi(t.cb_encrypted_appownershipticket)+b"\x2A"+vi(len(t.encrypted_ticket))
+t.encrypted_ticket

def save(a,d):
txt=base64.b64encode(d).decode()
Path(f"token_{a}.txt").write_text(txt)
print(f"Token saved as token_{a}.txt\n{txt}")
def main():
print("Steam App Ticket Dumper\n")
c=SteamClient(); p=Path.home()/".steamticket"; p.mkdir(exist_ok=True);
c.set_credential_location(str(p))

u=input("Steam username: ")


pw=input("Steam password: ")
res=c.login(username=u,password=pw)

if res==EResult.AccountLoginDeniedNeedTwoFactor:
res=c.login(username=u,password=pw,two_factor_code=input("Enter Steam Guard
mobile code: "))
elif res==EResult.AccountLogonDenied:
res=c.login(username=u,password=pw,auth_code=input("Enter Steam Guard e-
mail code: "))

if res!=EResult.OK:
print("Login failed:", res); return
print("Login successful\n")

a=None
if c.steam_id:
g=games(c.steam_id)
if g: a=pick(g)
if not a:
try: a=int(input("Enter AppID: "))
except: print("Invalid AppID"); return

ui=input("Userdata (optional, hex or text): ").strip()


ud=b""
if ui:
try: ud=binascii.unhexlify(ui)
except: ud=ui.encode()

tok=ticket(c,a,ud)
if tok: save(a,tok)
else: print("Ticket retrieval failed")

c.disconnect()

if __name__=="__main__":
main()

You might also like