aboutsummaryrefslogtreecommitdiffstats
path: root/bruiser/lua-scripts/asmrw.lua
diff options
context:
space:
mode:
authorbloodstalker <thabogre@gmail.com>2018-03-12 13:00:46 +0000
committerbloodstalker <thabogre@gmail.com>2018-03-12 13:00:46 +0000
commitab8c8bf7f6d5fec080cfae5155ae891af214674f (patch)
tree97c01489d3b17cf7e6ed5e6913ef5594c849a88a /bruiser/lua-scripts/asmrw.lua
parentthe jmp table is working now. you get member set and get methods, and an iter... (diff)
downloadmutator-ab8c8bf7f6d5fec080cfae5155ae891af214674f.tar.gz
mutator-ab8c8bf7f6d5fec080cfae5155ae891af214674f.zip
added a lua module for asmrewriter, will soon add docs. you can try the new module by running asmtest.lua or demo2.lua did some cosmetic fixes to load bfd so it doesnt suck as hard when you get dumps
Diffstat (limited to '')
-rw-r--r--bruiser/lua-scripts/asmrw.lua53
1 files changed, 53 insertions, 0 deletions
diff --git a/bruiser/lua-scripts/asmrw.lua b/bruiser/lua-scripts/asmrw.lua
new file mode 100644
index 0000000..2f68d2b
--- /dev/null
+++ b/bruiser/lua-scripts/asmrw.lua
@@ -0,0 +1,53 @@
+------------------------------------------------Project Mutator-----------------------------------------------
+--bruiser's asmrw module
+--Copyright (C) 2018 Farzad Sadeghi
+
+--This program is free software; you can redistribute it and/or
+--modify it under the terms of the GNU General Public License
+--as published by the Free Software Foundation; either version 2
+--of the License, or (at your option) any later version.
+
+--This program is distributed in the hope that it will be useful,
+--but WITHOUT ANY WARRANTY; without even the implied warranty of
+--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+--GNU General Public License for more details.
+
+--You should have received a copy of the GNU General Public License
+--along with this program; if not, write to the Free Software
+--Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.*/
+--------------------------------------------------------------------------------------------------------------
+--start of asmrewriter module
+local asmrw = {}
+xobj = require("lua-scripts.xobj")
+
+setmetatable(jmp_s_t, {__call =
+ function(self, arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12)
+ local t = self.new(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12)
+ print("created", t)
+ return t
+ end
+ }
+)
+
+function jmp_s_t:dump(msg)
+ print(msg, self:custom())
+ return self
+end
+
+function asmrw.get_head(elf_exe)
+ local text_section = xobj.getTextSection(elf_exe)
+ local head = getjmptable(#text_section, text_section)
+ return head
+end
+
+function asmrw.get_jmp(location)
+ while head:inext() ~= nil do
+ if head:location() == location then return head end
+ head = head:inext()
+ end
+end
+
+--end of asmrewriter module
+return asmrw
+--------------------------------------------------------------------------------------------------------------
+