Posted: Tue Apr 16, 2019 10:00 pm Post subject: how do i read all bytes exe file? [help]
How do i read all bytes exe file?
cuz i tried to io.open("file.exe","r") when i print it out it only shows "MZ?"
and i replace the \0 to blank its only get 2030 lengths
i want to read all the byte of the exe until below the assembly
any solution?
maybe later i must search google up first then asking
this is the solution for sharing
Code:
local fileName = 'filename.exe'
local file = assert(io.open(fileName, 'rb'))
local t = {}
repeat
local str = file:read(4*1024)
print(str) -- read the whole file
for c in (str or ''):gmatch'.' do
t[#t+1] = c:byte()
end
until not str
file:close()
print(#t) --string lengths
Joined: 25 Jan 2006 Posts: 8517 Location: 127.0.0.1
Posted: Fri Apr 19, 2019 4:44 pm Post subject:
You can't print the raw data and expect it to print everything. The print call is going to handle the data as a normal string, meaning the first 00 byte it hits, the string will be terminated and cut off. You are only seeing the MZ because a typical PE header will have a ton of 00's in it for most of the data.
If you want to print everything, convert the data to hex bytes and print that instead. _________________
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum