Skip to content

Instantly share code, notes, and snippets.

@Raltyro
Created April 2, 2023 03:08
Show Gist options
  • Select an option

  • Save Raltyro/64f84c7b618ae83866a0edfa346cb9a8 to your computer and use it in GitHub Desktop.

Select an option

Save Raltyro/64f84c7b618ae83866a0edfa346cb9a8 to your computer and use it in GitHub Desktop.
// script by raltyro
// just click the py file and it will decode all of roblox temporary assets that used to load user created images, audios, etc.
// note: it does not obtain the AssetID of the file
import sys
import os
import shutil
temp = os.getenv("TEMP")
results = "rblxtemptousable-results"
sndrs = results + "/Audios"
unkrs = results + "/Unknown"
mshrs = results + "/Meshes"
anirs = results + "/Animations"
mdlrs = results + "/Models"
imgrs = results + "/Images"
othrs = results + "/Others"
audiotype = {
"audio/mpeg" : "mp3",
"audio/ogg" : "ogg"
}
imagetype = {
"image/png" : "png",
"imag/png" : "png", # a fucking roblox staff went drunk and misstyped image/png to this like wtf
"application/octet-stream" : "png"
}
def setup():
#if (os.path.exists(results)): shutil.rmtree(results)
if not (os.path.exists(results)): os.mkdir(results)
if not (os.path.exists(sndrs)): os.mkdir(sndrs)
if not (os.path.exists(unkrs)): os.mkdir(unkrs)
if not (os.path.exists(imgrs)): os.mkdir(imgrs)
if not (os.path.exists(othrs)): os.mkdir(othrs)
if not (os.path.exists(mdlrs)): os.mkdir(mdlrs)
if not (os.path.exists(anirs)): os.mkdir(anirs)
#os.mkdir(mshrs)
def typeToCool(v=None):
if (not isinstance(v,str) or v == "dat"): return "Unknown"
return "Audios" if v == "ogg" or v == "mp3" or v == "wav" else "Meshes" if v == "obj" or v == "fbx" else "Models" if v == "rbxm" or v == "rbxmx" else "Images" if v == "png" or v == "jpg" else "Others"
def decodehashtemp(file):
bin = open(file,"rb").read()
isAnim = None
saveDir = None
content_type = None
result_type = None
data = None
length = len(bin)
forceStop = False
for i in range(0,length):
if (forceStop): break
if (isinstance(content_type,str)):
if (bin[i:i+30] == b"Access-Control-Allow-Origin: *" and bin[i+32:i+54] != b"Timing-Allow-Origin: *"):
data = bin[i+32:]
break
if (bin[i:i+22] == b"Timing-Allow-Origin: *"):
data = bin[i+24:]
break
else:
if (bin[i:i+14] == b"Content-Type: "):
i = i + 14
content_type = ""
for i2 in range(i,i+128):
if (bin[i2:i2+1] == b"\r"):
i = i + 1
break
if (i2 == 128): forceStop = True
else:
content_type = content_type + bin[i2:i2+1].decode()
i = i + 1
content_type = content_type.lower()
result_type = audiotype[content_type] if (content_type in audiotype) else imagetype[content_type] if (content_type in imagetype) else None
forceStop = None
if (isinstance(data,bytes)):
#if (not(isinstance(result_type,str))):
if (data[0:1] == b"<" and data[-1:0] == b">"): result_type = "xml"
elif (data[1:4] == b"KTX"): result_type = "ktx"
elif (data[0:4] == b"OggS"): result_type = "ogg"
elif (data[0:8] == b"<roblox!"): result_type = "rbxm"
elif (data[0:3] == b"ID3"): result_type = "ogg"
elif (data[1:4] == b"PNG"): result_type = "png"
elif (data[0:4] == b"RIFF" or data[0:4] == b"WAVE"): result_type = "wav"
elif (data[0:1] == b"{"): result_type = "json"
elif (data[0:11] == b"<roblox xml"): result_type = "rbxmx"
elif (data[-128:-125] == b"TAG"): result_type = "mp3"
#elif (data[0:2] == b"ÿû"): result_type = "mp3"
elif (data[0:7] == b"version"): result_type = "dat"
print(str(os.path.basename(file)) + (" - " + result_type if isinstance(result_type,str) else ""))
saveDir = typeToCool(result_type)
isAnim = False
if (saveDir == "Models"):
isAnim = data.find(b"KeyframeSequence") != -1
result = open(results + "/" + ("Animations" if isAnim else saveDir) + "/" + str(os.path.basename(file)) + ("." + result_type if isinstance(result_type,str) else ".dat"),'wb')
result.write(data)
result.close()
bin = None
isAnim = None
saveDir = None
content_type = None
result_type = None
data = None
length = None
i = None
file = None
return None
def soundfiletemp(file):
data = open(file,"rb").read()
result_type = "ogg"
if (data[0:4] == b"OggS"): result_type = "ogg"
elif (data[0:3] == b"ID3"): result_type = "ogg"
elif (data[0:4] == b"RIFF"): result_type = "wav"
elif (data[-128:-125] == b"TAG"): result_type = "mp3"
#elif (data[0:2] == b"ÿû"): result_type = "mp3"
result = open(results + "/" + typeToCool(result_type) + "/" + str(os.path.basename(file)) + ("." + result_type if isinstance(result_type,str) else ".dat"),'wb')
result.write(data)
result.close()
result_type = None
data = None
return None
def start():
httpdir = temp + "/Roblox/http"
for file in os.listdir(httpdir):
try:
decodehashtemp(httpdir + "/" + file)
except:
print("Something went wrong while trying to decoding " + file)
soundsdir = temp + "/Roblox/sounds"
for file in os.listdir(soundsdir):
try:
soundfiletemp(soundsdir + "/" + file)
except:
print("Something went wrong while trying to decoding " + file)
def main():
setup()
if (os.path.exists(temp + "/Roblox") and os.path.exists(temp + "/Roblox/http")): start()
input("its done nyaa~")
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment