aboutsummaryrefslogtreecommitdiffstats
path: root/bruiser
diff options
context:
space:
mode:
authorbloodstalker <thabogre@gmail.com>2018-02-11 20:29:49 +0000
committerbloodstalker <thabogre@gmail.com>2018-02-11 20:29:49 +0000
commit26859306a2affd060fb4ebebed7525a5d88e967c (patch)
tree7f0e83bbcf8e9ccff43814fc53649a61de00cc23 /bruiser
parentmakefile update or they kinda do what they were supposed to do (diff)
downloadmutator-26859306a2affd060fb4ebebed7525a5d88e967c.tar.gz
mutator-26859306a2affd060fb4ebebed7525a5d88e967c.zip
2 major bug fixed for bruiser, a lot of little improvements and bug fixed here and there
Diffstat (limited to 'bruiser')
-rw-r--r--bruiser/bruiser.cpp80
-rw-r--r--bruiser/bruiserffi.c36
-rw-r--r--bruiser/bruiserffi.h1
-rw-r--r--bruiser/compile_commands.json8
-rw-r--r--bruiser/lua-scripts/demo1.lua28
-rw-r--r--bruiser/lua-scripts/smoketest.lua9
-rw-r--r--bruiser/makefile2
-rwxr-xr-xbruiser/run.sh3
8 files changed, 95 insertions, 72 deletions
diff --git a/bruiser/bruiser.cpp b/bruiser/bruiser.cpp
index e75b173..053bffc 100644
--- a/bruiser/bruiser.cpp
+++ b/bruiser/bruiser.cpp
@@ -104,6 +104,7 @@ cl::opt<bool> CheckSystemHeader("SysHeader", cl::desc("bruiser will run through
cl::opt<bool> MainFileOnly("MainOnly", cl::desc("bruiser will only report the results that reside in the main file"), cl::init(false), cl::cat(BruiserCategory), cl::ZeroOrMore);
cl::opt<std::string> M0XMLPath("xmlpath", cl::desc("tells bruiser where to find the XML file containing the Mutator-LVL0 report."), cl::init(bruiser::M0REP), cl::cat(BruiserCategory), cl::ZeroOrMore);
cl::opt<bool> LuaJIT("jit", cl::desc("should bruiser use luajit or not."), cl::init(true), cl::cat(BruiserCategory), cl::ZeroOrMore);
+cl::opt<bool> Verbose("verbose", cl::desc("verbosity"), cl::init(false), cl::cat(BruiserCategory), cl::ZeroOrMore);
cl::opt<std::string> NonCLILuaScript("lua", cl::desc("specifies a lua script for bruiser to run in non-interactive mode"), cl::init(""), cl::cat(BruiserCategory), cl::Optional);
/**********************************************************************************************************************/
class LuaEngine
@@ -209,16 +210,16 @@ class PyExec {
if (pModule != nullptr) {
pFunc = PyObject_GetAttrString(pModule, py_func_name.c_str());
if (pFunc && PyCallable_Check(pFunc)) {
- std::cout << GREEN << "function is callable." << NORMAL << "\n";
+ if (Verbose) std::cout << GREEN << "function is callable." << NORMAL << "\n";
pArgs = PyTuple_New(1);
pValue = PyUnicode_FromString(obj_path.c_str());
PyTuple_SetItem(pArgs, 0, pValue);
pArgs = nullptr;
- std::cout << BLUE << "calling python function..." << NORMAL << "\n";
+ if (Verbose) std::cout << BLUE << "calling python function..." << NORMAL << "\n";
pValue = PyObject_CallObject(pFunc, pArgs);
//Py_DECREF(pArgs);
if (pValue != nullptr) {
- std::cout << GREEN << "call finished successfully." << NORMAL << "\n";
+ if (Verbose) std::cout << GREEN << "call finished successfully." << NORMAL << "\n";
//printf("Result of call: %ld\n", PyLong_AsLong(pValue));
//Py_DECREF(pValue);
} else {
@@ -247,11 +248,11 @@ class PyExec {
}
int getAsCppStringVec(void) {
- PRINT_WITH_COLOR_LB(BLUE, "processing return result...");
+ if (Verbose) PRINT_WITH_COLOR_LB(BLUE, "processing return result...");
if (PyList_Check(pValue)) {
- std::cout << GREEN << "got a python list\n" << NORMAL;
+ if (Verbose) std::cout << GREEN << "got a python list\n" << NORMAL;
int list_length = PyList_Size(pValue);
- std::cout << BLUE << "length of list: " << list_length << NORMAL <<"\n";
+ if (Verbose) std::cout << BLUE << "length of list: " << list_length << NORMAL <<"\n";
for (int i = 0; i < list_length; ++i) {
PyObject* pybytes = PyList_GetItem(pValue, i);
PyObject* pyrepr = PyObject_Repr(pybytes);
@@ -265,11 +266,11 @@ class PyExec {
}
int getAsCppByte(void) {
- PRINT_WITH_COLOR_LB(BLUE, "processing return result...");
+ if (Verbose) PRINT_WITH_COLOR_LB(BLUE, "processing return result...");
std::vector<uint8_t> tempvec;
if(PyList_Check(pValue)) {
int list_length = PyList_Size(pValue);
- std::cout << BLUE << "length of list: " << list_length << NORMAL << "\n";
+ if (Verbose) std::cout << BLUE << "length of list: " << list_length << NORMAL << "\n";
for(int i = 0; i < list_length; ++i) {
PyObject* pybytes = PyList_GetItem(pValue, i);
if(PyList_Check(pybytes)) {
@@ -1161,7 +1162,7 @@ class LuaWrapper
std::string action;
if (numargs == 3) {
- std::cout << CYAN << "got args." << NORMAL << "\n";
+ if (Verbose) std::cout << CYAN << "got args." << NORMAL << "\n";
funcname = lua_tostring(__ls, 1);
objjpath = lua_tostring(__ls, 2);
action = lua_tostring(__ls, 3);
@@ -1172,10 +1173,10 @@ class LuaWrapper
return EXIT_FAILURE;
}
- std::cout << CYAN << "initing the py embed class...\n" << NORMAL;
+ if (Verbose) std::cout << CYAN << "initing the py embed class...\n" << NORMAL;
PyExec py(filename.c_str(), funcname.c_str(), objjpath.c_str());
- std::cout << BLUE << "running load.py: " << NORMAL << "\n";
+ if (Verbose) std::cout << BLUE << "running load.py: " << NORMAL << "\n";
py.run();
if (action == "code_list") {
py.getAsCppByte();
@@ -1185,8 +1186,7 @@ class LuaWrapper
int tableindex2 = 1;
// the return type to lua is a table of tables
lua_newtable(__ls);
- // @devi-FIXME-probably reserving way too much stack space
- if (!lua_checkstack(__ls, py.exportObjs().size() * 2)) {
+ if (!lua_checkstack(__ls, py.exportObjs().size())) {
PRINT_WITH_COLOR_LB(RED, "cant grow lua stack. current size is too small.");
}
for (auto& iter : py.exportObjs()) {
@@ -1208,8 +1208,7 @@ class LuaWrapper
int tableindex = 1 ;
// the return type to lua is a table
lua_newtable(__ls);
- // @devi-FIXME-probably reserving way too much stack space
- if (!lua_checkstack(__ls, py.exportStrings().size() * 2)) {
+ if (!lua_checkstack(__ls, py.exportStrings().size())) {
PRINT_WITH_COLOR_LB(RED, "cant grow lua stack. current size is too small.");
}
for (auto& iter : py.exportStrings()) {
@@ -1220,7 +1219,7 @@ class LuaWrapper
}
}
- PRINT_WITH_COLOR_LB(GREEN, "done.");
+ if (Verbose) PRINT_WITH_COLOR_LB(GREEN, "done.");
return 1;
}
@@ -1235,20 +1234,27 @@ class LuaWrapper
if (lua_type(__ls, 1) != LUA_TTABLE) {
PRINT_WITH_COLOR_LB(RED, "the stack value is not a table but is being accessed as such.");
} else {
- PRINT_WITH_COLOR_LB(GREEN, "stack index 1 is a table.");
+ if (Verbose) PRINT_WITH_COLOR_LB(GREEN, "stack index 1 is a table.");
+ }
+ if (Verbose) std::cout << CYAN << "table_length: " << table_length << NORMAL << "\n";
+ if (!lua_checkstack(__ls, table_length)) {
+ PRINT_WITH_COLOR_LB(RED, "cant grow lua stack. current size is too small.");
}
- std::cout << CYAN << "table_length: " << table_length << NORMAL << "\n";
for (int i = 1; i <= table_length; ++i) {
lua_rawgeti(__ls, 1, i);
xobj_code_.push_back(int(lua_tonumber(__ls, i + 2)));
}
- std::cout << BLUE << "function code: ";
- for (auto& iter : xobj_code_) {std::cout << NORMAL << int(iter) << " ";}
- std::cout << NORMAL <<"\n";
+ if (Verbose) {
+ std::cout << BLUE << "function code: ";
+ for (auto& iter : xobj_code_) {std::cout << NORMAL << int(iter) << " ";}
+ std::cout << NORMAL <<"\n";
+ }
xobj_name = lua_tostring(__ls, 2);
std::pair<void*, size_t> xobj = executioner.loadObjsInXMem(xobj_code_);
- std::cout << "xobj will be registered as " << YELLOW << xobj_name << NORMAL << ". " << "it is recommended to use a post- or pre-fix for the xobj names to avoid namespace pollution." "\n";
- std::cout << GREEN << "pointer: " << BLUE << xobj.first << " " << GREEN << "size: " << BLUE << xobj.second << NORMAL << "\n";
+ if (Verbose) {
+ std::cout << "xobj will be registered as " << YELLOW << xobj_name << NORMAL << ". " << "it is recommended to use a post- or pre-fix for the xobj names to avoid namespace pollution." "\n";
+ std::cout << GREEN << "pointer: " << BLUE << xobj.first << " " << GREEN << "size: " << BLUE << xobj.second << NORMAL << "\n";
+ }
executioner.pushvptr(xobj.first, xobj_name);
return 0;
}
@@ -1297,9 +1303,9 @@ class LuaWrapper
PRINT_WITH_COLOR_LB(RED, "xcall: the stack value is not a table but is being accessed as such.");
return 0;
} else {
- PRINT_WITH_COLOR_LB(GREEN, "xcall: stack index 2 is a table.");
+ if (Verbose) PRINT_WITH_COLOR_LB(GREEN, "xcall: stack index 2 is a table.");
}
- std::cout << CYAN << "table_length: " << table_length_2 << NORMAL << "\n";
+ if (Verbose) std::cout << CYAN << "table_length: " << table_length_2 << NORMAL << "\n";
for (int i = 1; i <= table_length_2; ++i) {
lua_rawgeti(__ls, 2, i);
args[i-1] = lua_tostring(__ls, i + numargs);
@@ -1323,10 +1329,10 @@ class LuaWrapper
PRINT_WITH_COLOR_LB(RED, "xcall: the stack value is not a table but is being accessed as such.");
return 0;
} else {
- PRINT_WITH_COLOR_LB(GREEN, "xcall: stack index 5 is a table.");
+ if (Verbose) PRINT_WITH_COLOR_LB(GREEN, "xcall: stack index 5 is a table.");
}
- std::cout << CYAN << "table_length: " << table_length_5 << NORMAL << "\n";
+ if (Verbose) std::cout << CYAN << "table_length: " << table_length_5 << NORMAL << "\n";
for (int i = 1; i <= table_length_5; ++i) {
lua_rawgeti(__ls, 5, i);
if (lua_type(__ls, i+numargs+argc) == LUA_TBOOLEAN) {}
@@ -1382,7 +1388,7 @@ class LuaWrapper
int BruiserLuaXObjGetList(lua_State* __ls) {
auto xlist = executioner.getvptrs();
lua_newtable(__ls);
- if (!lua_checkstack(__ls, xlist.size() * 2)) {
+ if (!lua_checkstack(__ls, xlist.size())) {
PRINT_WITH_COLOR_LB(RED, "cant grow lua stack. current size is too small.");
}
for (auto& iter : xlist) {
@@ -1552,6 +1558,7 @@ class LuaWrapper
return 0;
}
+ //@DEVI-FIXME-broken
int BruiserLuaShowSourcecode(lua_State* __ls)
{
unsigned int args = 0U;
@@ -1584,13 +1591,17 @@ class LuaWrapper
}
std::string line;
+ std::string dummy;
while(getline(targetfile, line))
{
- lua_pushstring(__ls, line.c_str());
+ dummy += line;
+ //lua_pushstring(__ls, line.c_str());
}
+ lua_pushstring(__ls , dummy.c_str());
targetfile.close();
- return lineend - linebegin + 1U;
+ //return lineend - linebegin + 1U;
+ return 1;
}
int BruiserLuaMutagenExtraction(lua_State* __ls)
@@ -2022,14 +2033,7 @@ int main(int argc, const char **argv) {
/*The non-cli execution loop*/
if (NonCLILuaScript != "") {
- std::ifstream lua_script_noncli;
- lua_script_noncli.open(NonCLILuaScript);
- std::string line;
- while(std::getline(lua_script_noncli, line)) {
- BruiserLog.PrintToLog("running in non-cli mode...");
- BruiserLog.PrintToLog(line + "\n");
- LE.RunChunk((char*)line.c_str());
- }
+ luaL_dofile(LE.GetLuaState(), NonCLILuaScript.c_str());
dostring(LE.GetLuaState(), "os.exit()", "test");
return 0;
}
diff --git a/bruiser/bruiserffi.c b/bruiser/bruiserffi.c
index 409d755..1972c8c 100644
--- a/bruiser/bruiserffi.c
+++ b/bruiser/bruiserffi.c
@@ -21,13 +21,15 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.*
// @TODO-structs and unions not supported
// @TODO-vararg xobjs are not supported
/**********************************************************************************************************************/
+#include "bruiserffi.h"
+#include <capstone/capstone.h>
+#include <errno.h>
#include <ffi.h>
+#include <inttypes.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
-//#include <capstone/capstone.h>
-#include "bruiserffi.h"
/**********************************************************************************************************************/
#define VOIDIFY(X) (void*)X
/**********************************************************************************************************************/
@@ -167,6 +169,32 @@ void* ffi_callX(int argc, const char** arg_string, ffi_type rtype, void* x_ptr,
void* ffi_callX_var(int argc, const char** arg_string, ffi_type rtype, void* x_ptr, void** values) {return NULL;}
/**********************************************************************************************************************/
+#define CODE_1 "\x55\x48\x89\xe5\x48\x83\xec\x20\x89\x7d\xfc\x89\x75\xf8\x89\x55\xf4\x89\x4d\xf0\x8b\x7d\xfc\x8b\x75\xf8\xe8\xd1\xfd\xff\xff\x8b\x7d\xf4\x8b\x75\xf0\x89\x45\xec\xe8\xc3\xfd\xff\xff\x8b\x4d\xec\x1\xc1\x89\xc8\x48\x83\xc4\x20\x5d\xc3"
+int capstone_test(void) {
+ csh handle;
+ cs_insn* insn;
+ size_t count;
+ if (cs_open(CS_ARCH_X86, CS_MODE_64, &handle) != CS_ERR_OK) return -1;
+ count = cs_disasm(handle, CODE_1, sizeof(CODE_1) - 1, 0x0, 0, &insn);
+ if (count > 0) {
+ size_t j;
+ for (j = 0; j <count; ++j) {
+ if (strcmp(insn[j].mnemonic, "call") == 0) {
+ printf("0x%"PRIx64":\t%s\t\t%s\n", insn[j].address, insn[j].mnemonic, insn[j].op_str);
+ char* endptr;
+ intmax_t address = strtoimax(insn[j].op_str, &endptr, 0);
+ uintmax_t uaddress = strtoumax(insn[j].op_str, &endptr, 0);
+ printf("address: %ld\n", address);
+ printf("uaddress: %ld\n", uaddress);
+ }
+ }
+ cs_free(insn, count);
+ } else {
+ printf("ERROR!!!\n");
+ }
+ cs_close(&handle);
+ return 0;
+}
/**********************************************************************************************************************/
// @DEVI-the following lines are only meant for testing.
uint32_t add2(uint32_t a, uint32_t b) {return a+b;}
@@ -206,6 +234,10 @@ int main(int argc, char** argv) {
result = ffi_callX(1, args3, ffi_type_pointer, pstring, values3);
fprintf(stdout, "result of calling passthrough is %s\n", ffi_reinterpret_string(result));
+ /*capstone tests*/
+ printf("\n");
+ capstone_test();
+
return 0;
}
/**********************************************************************************************************************/
diff --git a/bruiser/bruiserffi.h b/bruiser/bruiserffi.h
index c7a2821..e3afda0 100644
--- a/bruiser/bruiserffi.h
+++ b/bruiser/bruiserffi.h
@@ -18,6 +18,7 @@ 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.*/
/**********************************************************************************************************************/
+#include <capstone/capstone.h>
#include <ffi.h>
#include <stdint.h>
/**********************************************************************************************************************/
diff --git a/bruiser/compile_commands.json b/bruiser/compile_commands.json
index 48605af..51d9b0f 100644
--- a/bruiser/compile_commands.json
+++ b/bruiser/compile_commands.json
@@ -1,6 +1,6 @@
[
{
- "command": "c++ -c -I/home/bloodstalker/extra/llvm-clang-4/llvm/include -I/home/bloodstalker/extra/llvm-clang-4/build/include -fPIC -fvisibility-inlines-hidden -Werror=date-time -std=c++11 -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wno-maybe-uninitialized -Wdelete-non-virtual-dtor -Wno-comment -ffunction-sections -fdata-sections -O2 -fno-exceptions -D_GNU_SOURCE -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/bloodstalker/extra/llvm-clang-4/llvm/tools/clang/include -I/home/bloodstalker/extra/llvm-clang-4/build/tools/clang/include -std=c++1z -stdlib=libstdc++ -UNDEBUG -fexceptions -I/usr/include -I/usr/include/python3.5m -I/usr/include/python3.5m -o bruiser.o bruiser.cpp",
+ "command": "c++ -c -I/home/bloodstalker/extra/llvm-6/llvm/include -I/home/bloodstalker/extra/llvm-6/build/include -fPIC -fvisibility-inlines-hidden -Werror=date-time -std=c++11 -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wno-maybe-uninitialized -Wdelete-non-virtual-dtor -Wno-comment -ffunction-sections -fdata-sections -O2 -fno-exceptions -D_GNU_SOURCE -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/bloodstalker/extra/llvm-6/llvm/tools/clang/include -I/home/bloodstalker/extra/llvm-6/build/tools/clang/include -std=c++1z -stdlib=libstdc++ -UNDEBUG -fexceptions -I/usr/include -I/usr/include/python3.6m -I/usr/include/python3.6m -o bruiser.o bruiser.cpp",
"directory": "/home/bloodstalker/devi/hell2/bruiser",
"file": "/home/bloodstalker/devi/hell2/bruiser/bruiser.cpp"
},
@@ -10,17 +10,17 @@
"file": "/home/bloodstalker/devi/hell2/bruiser/linenoise/linenoise.c"
},
{
- "command": "c++ -c -I/home/bloodstalker/extra/llvm-clang-4/llvm/include -I/home/bloodstalker/extra/llvm-clang-4/build/include -fPIC -fvisibility-inlines-hidden -Werror=date-time -std=c++11 -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wno-maybe-uninitialized -Wdelete-non-virtual-dtor -Wno-comment -ffunction-sections -fdata-sections -O2 -fno-exceptions -D_GNU_SOURCE -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/bloodstalker/extra/llvm-clang-4/llvm/tools/clang/include -I/home/bloodstalker/extra/llvm-clang-4/build/tools/clang/include -std=c++1z -stdlib=libstdc++ -UNDEBUG -fexceptions -I/usr/include -I/usr/include/python3.5m -I/usr/include/python3.5m -o CompletionHints.o CompletionHints.cpp",
+ "command": "c++ -c -I/home/bloodstalker/extra/llvm-6/llvm/include -I/home/bloodstalker/extra/llvm-6/build/include -fPIC -fvisibility-inlines-hidden -Werror=date-time -std=c++11 -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wno-maybe-uninitialized -Wdelete-non-virtual-dtor -Wno-comment -ffunction-sections -fdata-sections -O2 -fno-exceptions -D_GNU_SOURCE -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/bloodstalker/extra/llvm-6/llvm/tools/clang/include -I/home/bloodstalker/extra/llvm-6/build/tools/clang/include -std=c++1z -stdlib=libstdc++ -UNDEBUG -fexceptions -I/usr/include -I/usr/include/python3.6m -I/usr/include/python3.6m -o CompletionHints.o CompletionHints.cpp",
"directory": "/home/bloodstalker/devi/hell2/bruiser",
"file": "/home/bloodstalker/devi/hell2/bruiser/CompletionHints.cpp"
},
{
- "command": "c++ -c -I/home/bloodstalker/extra/llvm-clang-4/llvm/include -I/home/bloodstalker/extra/llvm-clang-4/build/include -fPIC -fvisibility-inlines-hidden -Werror=date-time -std=c++11 -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wno-maybe-uninitialized -Wdelete-non-virtual-dtor -Wno-comment -ffunction-sections -fdata-sections -O2 -fno-exceptions -D_GNU_SOURCE -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/bloodstalker/extra/llvm-clang-4/llvm/tools/clang/include -I/home/bloodstalker/extra/llvm-clang-4/build/tools/clang/include -std=c++1z -stdlib=libstdc++ -UNDEBUG -fexceptions -I/usr/include -I/usr/include/python3.5m -I/usr/include/python3.5m -o mutagen.o mutagen.cpp",
+ "command": "c++ -c -I/home/bloodstalker/extra/llvm-6/llvm/include -I/home/bloodstalker/extra/llvm-6/build/include -fPIC -fvisibility-inlines-hidden -Werror=date-time -std=c++11 -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wno-maybe-uninitialized -Wdelete-non-virtual-dtor -Wno-comment -ffunction-sections -fdata-sections -O2 -fno-exceptions -D_GNU_SOURCE -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/bloodstalker/extra/llvm-6/llvm/tools/clang/include -I/home/bloodstalker/extra/llvm-6/build/tools/clang/include -std=c++1z -stdlib=libstdc++ -UNDEBUG -fexceptions -I/usr/include -I/usr/include/python3.6m -I/usr/include/python3.6m -o mutagen.o mutagen.cpp",
"directory": "/home/bloodstalker/devi/hell2/bruiser",
"file": "/home/bloodstalker/devi/hell2/bruiser/mutagen.cpp"
},
{
- "command": "c++ -c -I/home/bloodstalker/extra/llvm-clang-4/llvm/include -I/home/bloodstalker/extra/llvm-clang-4/build/include -fPIC -fvisibility-inlines-hidden -Werror=date-time -std=c++11 -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wno-maybe-uninitialized -Wdelete-non-virtual-dtor -Wno-comment -ffunction-sections -fdata-sections -O2 -fno-exceptions -D_GNU_SOURCE -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/bloodstalker/extra/llvm-clang-4/llvm/tools/clang/include -I/home/bloodstalker/extra/llvm-clang-4/build/tools/clang/include -std=c++1z -stdlib=libstdc++ -UNDEBUG -fexceptions -I/usr/include -I/usr/include/python3.5m -I/usr/include/python3.5m -o ORCmutation.o ORCmutation.cpp",
+ "command": "c++ -c -I/home/bloodstalker/extra/llvm-6/llvm/include -I/home/bloodstalker/extra/llvm-6/build/include -fPIC -fvisibility-inlines-hidden -Werror=date-time -std=c++11 -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wno-maybe-uninitialized -Wdelete-non-virtual-dtor -Wno-comment -ffunction-sections -fdata-sections -O2 -fno-exceptions -D_GNU_SOURCE -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/bloodstalker/extra/llvm-6/llvm/tools/clang/include -I/home/bloodstalker/extra/llvm-6/build/tools/clang/include -std=c++1z -stdlib=libstdc++ -UNDEBUG -fexceptions -I/usr/include -I/usr/include/python3.6m -I/usr/include/python3.6m -o ORCmutation.o ORCmutation.cpp",
"directory": "/home/bloodstalker/devi/hell2/bruiser",
"file": "/home/bloodstalker/devi/hell2/bruiser/ORCmutation.cpp"
},
diff --git a/bruiser/lua-scripts/demo1.lua b/bruiser/lua-scripts/demo1.lua
index 2e9cd56..6645098 100644
--- a/bruiser/lua-scripts/demo1.lua
+++ b/bruiser/lua-scripts/demo1.lua
@@ -13,6 +13,7 @@
--
--------------------------------------------------------------------------------------------------------------
elf_file = "../bfd/test/test.so"
+--elf_file = "/home/bloodstalker/devi/hell2/bfd/test/test.so"
--elf_file = "../bfd/test/test"
function getGlobalTable()
@@ -120,24 +121,8 @@ function printFuncSizes()
end
end
--- start of @placeholder
-function xobjRegister(code_table, registration_name)
- -- lightuserdata
- local Xobjpointer
- return Xobjpointer
-end
--- should be varargs
--- registration_name()
--- end of @placeholder
-
--- start of @placeholder
--- C--args = argc, arg_string, ffi_type, xptr, the_actual_args
--- lua--args = number, table, string, xptr, args
--- end of @placeholder
-function callX(n_argc, t_string, str, index, t_values)
-end
-
function main()
+ pwd()
printObjNames()
printObjSizes()
printFuncNames()
@@ -167,7 +152,6 @@ function main()
printFuncSizes()
- pwd()
xobjregister(add2_code, "add2")
xobjregister(sub2_code, "sub2")
xobjregister(adddouble_code, "adddouble")
@@ -189,20 +173,20 @@ function main()
if a ~= -100 then print("test failed") end
a=xcall(2,{"double", "double"},"double",2, {333.333,222.222})
print("xcall returned:",a)
- -- FIXME
- if tostring(a) ~= tostring(555.555) then print("test failed") end
+ if tostring(a) ~= tostring(555.555) then print("test failed"); os.exit(1) end
a=xcall(2,{"double", "double"},"double",3, {333.333,222.222})
print("xcall returned:",a)
- if tostring(a) ~= tostring(111.111) then print("test failed") end
+ if tostring(a) ~= tostring(111.111) then print("test failed"); os.exit(1) end
a=xcall(3,{"double", "double", "double"},"double",4, {333.333,222.222,111.111})
print("xcall returned:",a)
a=xcall(3,{"double", "double", "double"},"double","triple", {333.333,222.222,111.111})
print("xcall returned:",a)
- if tostring(a) ~= tostring(666.666) then print("test failed") end
+ if tostring(a) ~= tostring(666.666) then print("test failed"); os.exit(1) end
a=xcall(1,{"string"},"string","passthrough", {"i live!"})
print("xcall returned:",a)
+ if (a ~= "i live!") then print("test failed"); os.exit(1) end
--a=xcall(4,{"sint32", "sint32", "sint32", "sint32"},"sint32",5, {10,20,30,40})
--print("xcall returned:",a)
diff --git a/bruiser/lua-scripts/smoketest.lua b/bruiser/lua-scripts/smoketest.lua
index f278365..c53fd9a 100644
--- a/bruiser/lua-scripts/smoketest.lua
+++ b/bruiser/lua-scripts/smoketest.lua
@@ -1,5 +1,5 @@
help()
---hijackmain()
+hijackmain()
clear()
history()
Vars()
@@ -8,9 +8,10 @@ Classes()
Structs()
Arrays()
Unions()
-historysize(150)
-showsource(1,5,"test.cpp")
---extractmutagen()
+historysize(1500)
+a=showsource(1,5,"test.cpp")
+print(a)
+extractmutagen()
setmakepath("./test/bruisertest")
setbinpath("./test/bruisertest")
make("clean")
diff --git a/bruiser/makefile b/bruiser/makefile
index 81d4923..7bf3bf5 100644
--- a/bruiser/makefile
+++ b/bruiser/makefile
@@ -13,7 +13,7 @@ SRCS=$(wildcard *.cpp)
C_SRCS=$(wildcard *.c)
#for some reason without ld the build fails on ubuntu trusty on travis
#EXTRA_LD_FLAGS+=-lpthread -ldl -lutil -lm -Xlinker -lpython3
-EXTRA_LD_FLAGS+=$(shell $(PY_CONF) --ldflags) -lffi
+EXTRA_LD_FLAGS+=$(shell $(PY_CONF) --ldflags) -lffi -lcapstone
######################################RULES####################################
.DEFAULT: all
diff --git a/bruiser/run.sh b/bruiser/run.sh
index 912fcf2..226271b 100755
--- a/bruiser/run.sh
+++ b/bruiser/run.sh
@@ -1,3 +1,4 @@
#!/bin/bash
-./bruiser ../test/bruisertest/test.cpp
+cd $(dirname $0)
+"./bruiser" ../test/bruisertest/test.cpp