我使用C来使用,但是对于Lua来说是新的。有没有办法创建一个可以读取example.exe并给我十六进制程序代码的lua程序?是否有可能在Lua代码中执行hexdump
0
A
回答
3
直到的Lua 5.1,此示例程序xd.lua
被列入分布:
-- hex dump
-- usage: lua xd.lua < file
local offset=0
while true do
local s=io.read(16)
if s==nil then return end
io.write(string.format("%08X ",offset))
string.gsub(s,"(.)",
function (c) io.write(string.format("%02X ",string.byte(c))) end)
io.write(string.rep(" ",3*(16-string.len(s))))
io.write(" ",string.gsub(s,"%c","."),"\n")
offset=offset+16
end
1
另一种可能性:
local filename = arg[1]
if filename == nil then
print [=[
Usage: dump <filename> [bytes_per_line(16)]]=]
return
end
local f = assert(io.open(filename, 'rb'))
local block = tonumber(arg[2]) or 16
while true do
local bytes = f:read(block)
if not bytes then return end
for b in bytes:gmatch('.') do
io.write(('%02X '):format(b:byte()))
end
io.write((' '):rep(block - bytes:len() + 1))
io.write(bytes:gsub('%c', '.'), '\n')
end
+0
'xd.lua'是在引入通用'for'和'gmatch'之前编写的。感谢这个现代版本的'xd.lua'。 – lhf
相关问题
- 1. 是否有可能body onload执行中留下未读代码?
- 2. 是否有可能从Lua代码加载.net dll?
- 3. 是否有可能停止当前执行的Javascript代码?
- 4. 是否有可能在.NET中运行时编译和执行新代码?
- 5. 是否有可能在执行客户端代码之前执行服务器端代码在ASP.Net
- 6. 是否有可能在C++中的return语句之后执行代码?
- 7. 是否有可能在GPU中运行一块纯C++代码
- 8. 是否可以在C#中运行时创建/执行代码?
- 9. 如何检查文件在Lua中是否可执行?
- 10. 在PHP中使用Lua是否可行?
- 11. 是否有可能在Lua中创建迭代器来迭代字典?
- 12. 是否有可能知道源代码的哪一行被执行?
- 13. AspectJ - 是否有可能执行建议?
- 14. 有没有办法检查代码是否在TransactionScope中执行?
- 15. 是否可以在.net框架中执行JavaScript代码?
- 16. 是否有可能在所有测试在MStest中执行完毕后运行代码
- 17. 是否有可能直接在代码中有错误描述?
- 18. 在Javascript中,是否有一种技术可以在返回后执行代码?
- 19. VBA执行存储在单元中的代码 - 有可能吗?
- 20. 是否有可能使用SonarQube为python执行静态代码分析?
- 21. 是否有可能在JavaScript中执行JavaScript include标签?
- 22. 是否有可能在F#中执行函数重载?
- 23. 是否有可能在芹菜的tasks.py中执行查询
- 24. 是否有可能在Delphi 6 BDE TUpdateSQL中执行SQL过程?
- 25. 是否有可能在CakePHP的app_controller.php中执行aftersave()?
- 26. MvcContrib GridModel:是否有可能在GridModel中执行ActionSyntax
- 27. 是否有可能直接在视图中执行
- 28. 是否有可能在Ansible中执行其他检查?
- 29. 是否有可能在Sequel中执行自我加入?
- 30. 是否有可能在Robotframework中执行钩子后,像Ruby/Cucumber
'io.open( '的file.exe', 'RB')' ? – hjpotter92
@ hjpotter92从某种意义上说,它与ifstream命令类似吗? –
是.............. – hjpotter92