Created
September 19, 2020 20:11
-
-
Save ExtReMLapin/4d9cba48cd7958b4a8a3cffb3d00cd72 to your computer and use it in GitHub Desktop.
extract png from Qt exes (or any other one)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local pnghead = "\x89\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00" | |
local pngend = "\x49\x45\x4e\x44\xae\x42\x60\x82" | |
local file = io.open("exe.exe", "rb") | |
local filedata = file:read("*all") | |
file:close() | |
local searchpos1 = 1 | |
local searchpos2 = 1 | |
local count = 1 | |
while true do | |
searchpos1 = string.find(filedata, pnghead, searchpos2) | |
if not searchpos1 then break end | |
searchpos2 = string.find(filedata, pngend, searchpos1) | |
local fHandle = io.open(tostring(count) .. ".png", "wb") | |
fHandle:write(filedata:sub(searchpos1,searchpos2 + #pngend)) | |
assert(searchpos2, "no end") | |
count = count + 1 | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment