diff options
Diffstat (limited to '')
-rw-r--r-- | bruiser/lua-scripts/demo2.lua | 35 | ||||
-rw-r--r-- | bruiser/lua-scripts/xobj.lua | 34 |
2 files changed, 58 insertions, 11 deletions
diff --git a/bruiser/lua-scripts/demo2.lua b/bruiser/lua-scripts/demo2.lua new file mode 100644 index 0000000..3b6007a --- /dev/null +++ b/bruiser/lua-scripts/demo2.lua @@ -0,0 +1,35 @@ + +xobj = require("lua-scripts.xobj") +colors = require("ansicolors") +elf_file = "../bfd/test/test.so" +elf_exe = "../bfd/test/test" + +function main() + xobj.getSO(elf_file) + local add2_code = xobj.codeTableByName_number("'add2'") + local sub2_code = xobj.codeTableByName_number("'sub2'") + local adddouble_code = xobj.codeTableByName_number("'adddouble'") + local subdouble_code = xobj.codeTableByName_number("'subdouble'") + local triple_code = xobj.codeTableByName_number("'triple'") + local quad_code = xobj.codeTableByName_number("'quad'") + local passthrough_code = xobj.codeTableByName_number("'passthrough'") + + --xobj.printFuncSizes() + + xobjregister(add2_code, "add2") + xobjregister(sub2_code, "sub2") + xobjregister(adddouble_code, "adddouble") + xobjregister(subdouble_code, "subdouble") + xobjregister(triple_code, "triple") + xobjregister(quad_code, "quad") + xobjregister(passthrough_code, "passthrough") +end + +function asm_rewriter() + local text_section = xobj.getTextSection() + for k,v in pairs(text_section) do io.write(colors("%{blue}"..string.format("%02x",k)),":",colors("%{green}"..string.format("%02x",v)),"\t") end + io.write("\n") +end + +--main() +asm_rewriter() diff --git a/bruiser/lua-scripts/xobj.lua b/bruiser/lua-scripts/xobj.lua index b69f0e5..880730a 100644 --- a/bruiser/lua-scripts/xobj.lua +++ b/bruiser/lua-scripts/xobj.lua @@ -1,4 +1,5 @@ ------------------------------------------------Project Mutator----------------------------------------------- +--bruiser's xobj module --Copyright (C) 2018 Farzad Sadeghi --This program is free software; you can redistribute it and/or @@ -15,11 +16,15 @@ --along with this program; if not, write to the Free Software --Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.*/ -------------------------------------------------------------------------------------------------------------- -function getSO(so_path) +--start of xobj module +local xobj = {} + +local elf_file = "" +function xobj.getSO(so_path) elf_file = so_path end -function getGlobalTable() +function xobj.getGlobalTable() local return_table = {} local names = objload("elf_get_obj_names", elf_file, "symbol_list") local sizes = objload("elf_get_obj_sizes", elf_file, "symbol_list") @@ -29,28 +34,28 @@ function getGlobalTable() return return_table end -function printObjNames() +function xobj.printObjNames() local c = objload("elf_get_obj_names", elf_file, "symbol_list") for k,v in ipairs(c) do print(k,v) end end -function printObjSizes() +function xobj.printObjSizes() local c = objload("elf_get_obj_sizes", elf_file, "symbol_list") for k,v in ipairs(c) do print(k,v) end end -function printFuncNames() +function xobj.printFuncNames() local c = objload("elf_get_func_names", elf_file, "symbol_list") for k,v in ipairs(c) do print(k,v) end end -function printFuncCode() +function xobj.printFuncCode() local c = objload("elf_get_func_code", elf_file, "code_list") for k,v in ipairs(c) do print(k,v) @@ -63,7 +68,7 @@ function printFuncCode() end end -function findMain() +function xobj.findMain() local c = objload("elf_get_func_names", elf_file, "symbol_list") for k,v in ipairs(c) do if v == "'main'" then @@ -73,7 +78,7 @@ function findMain() end end -function codeTables() +function xobj.codeTables() local return_table = {} local func_name_table = objload("elf_get_func_names", elf_file, "symbol_list") local code_table = objload("elf_get_func_code", elf_file, "code_list") @@ -83,7 +88,7 @@ function codeTables() return return_table end -function codeTableByName(name) +function xobj.codeTableByName(name) local return_table = {} local func_name_table = objload("elf_get_func_names", elf_file, "symbol_list") local code_table = objload("elf_get_func_code", elf_file, "code_list") @@ -98,7 +103,7 @@ function codeTableByName(name) return nil end -function codeTableByName_number(name) +function xobj.codeTableByName_number(name) local return_table = {} local func_name_table = objload("elf_get_func_names", elf_file, "symbol_list") local code_table = objload("elf_get_func_code", elf_file, "code_list") @@ -113,7 +118,7 @@ function codeTableByName_number(name) return nil end -function printFuncSizes() +function xobj.printFuncSizes() local func_name_table = objload("elf_get_func_names", elf_file, "symbol_list") local code_table = objload("elf_get_func_code", elf_file, "code_list") local counter = 1 @@ -123,5 +128,12 @@ function printFuncSizes() counter = counter + 1 end end + +function xobj.getTextSection() + return objload("elf_get_text_section", elf_exe, "bytes") +end + +--end of xobj module +return xobj -------------------------------------------------------------------------------------------------------------- |