aboutsummaryrefslogtreecommitdiffstats
path: root/bruiser/lua-scripts
diff options
context:
space:
mode:
authorbloodstalker <thabogre@gmail.com>2018-02-24 09:01:00 +0000
committerbloodstalker <thabogre@gmail.com>2018-02-24 09:01:00 +0000
commit65db9c78c26456ac3c9b58b3e74b6e8f0e3da201 (patch)
treeacad61f4a4979c8c96b144c3c984ff5687b71326 /bruiser/lua-scripts
parentremoved lua docs [ci skip] (diff)
downloadmutator-65db9c78c26456ac3c9b58b3e74b6e8f0e3da201.tar.gz
mutator-65db9c78c26456ac3c9b58b3e74b6e8f0e3da201.zip
bruiser will now run a lua script before startup so now you can easily use your lua rocks from inside bruiser. added a new demo using bruisers xobj module. added a new bruiser option for the default lua script to run prior to bruiser startup. updated the readme for bruiser.
Diffstat (limited to 'bruiser/lua-scripts')
-rw-r--r--bruiser/lua-scripts/demo2.lua35
-rw-r--r--bruiser/lua-scripts/xobj.lua34
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
--------------------------------------------------------------------------------------------------------------