diff options
Diffstat (limited to '')
| -rw-r--r-- | bruiser/bruiser.cpp | 31 | ||||
| -rw-r--r-- | bruiser/bruisercapstone.c | 2 | ||||
| -rw-r--r-- | bruiser/lua-scripts/df-demo.lua | 4 | ||||
| -rwxr-xr-x | bruiser/run.sh | 3 | 
4 files changed, 24 insertions, 16 deletions
| diff --git a/bruiser/bruiser.cpp b/bruiser/bruiser.cpp index cdb4ef4..1cebe3f 100644 --- a/bruiser/bruiser.cpp +++ b/bruiser/bruiser.cpp @@ -90,6 +90,7 @@ namespace { // start of anonymous namespace      std::string MAKEPATH;      std::string BINPATH;      unsigned int HISTORY_SIZE = SHELL_HISTORY_SIZE; +    bool droptocli;    };    struct ShellCache { @@ -172,7 +173,8 @@ std::vector<T> getLuaTableInt(lua_State* __ls, int numargs, int argnum) {    }    for (int i = 1; i <= table_length; ++i) {      lua_rawgeti(__ls, argnum, i); -    ret.push_back(lua_tointeger(__ls, i + numargs)); +    ret.push_back(lua_tointeger(__ls, 1 + numargs)); +    lua_pop(__ls, 1);    }    return ret;  } @@ -186,7 +188,8 @@ std::vector<std::string> getLuaTableString(lua_State* __ls, int numargs, int arg    }    for (int i = 1; i <= table_length; ++i) {      lua_rawgeti(__ls, argnum, i); -    ret.push_back(lua_tostring(__ls, i + numargs)); +    ret.push_back(lua_tostring(__ls, 1 + numargs)); +    lua_pop(__ls, 1);    }    return ret;  } @@ -201,7 +204,8 @@ std::vector<T> getLuaTableNumber(lua_State* __ls, int numargs, int argnum) {    }    for (int i = 1; i <= table_length; ++i) {      lua_rawgeti(__ls, argnum, i); -    ret.push_back(lua_tonumber(__ls, i + numargs)); +    ret.push_back(lua_tonumber(__ls, 1 + numargs)); +    lua_pop(__ls, 1);    }    return ret;  } @@ -1613,7 +1617,9 @@ class LuaWrapper        int numargs = lua_gettop(__ls);        if (numargs != 2) {PRINT_WITH_COLOR_LB(RED, "expected exactly two args. did not get that.");return 0;}        uint64_t size = lua_tointeger(__ls, 1); +      PRINT_WITH_COLOR_LB(CYAN, "cpp:calling getluatableint...");        std::vector<uint8_t> code_v = getLuaTableInt<uint8_t>(__ls, 2, 2); +      PRINT_WITH_COLOR_LB(GREEN, "cpp:called getluatableint...");        if (Verbose) PRINT_WITH_COLOR_LB(BLUE, "making jump table...");        auto head = makejmptable(size, code_v.data(), Verbose, __ls);        if (Verbose) PRINT_WITH_COLOR_LB(GREEN, "finished makejmptable call."); @@ -1881,6 +1887,15 @@ class LuaWrapper        return 1;      } +    int BruiserLuaDropToCLI(lua_State* __ls) { +      int numargs = lua_gettop(__ls); +      if (numargs != 0) { +        PRINT_WITH_COLOR_LB(RED, "wrong number of args. should be called with no arguments."); +        return 0; +      } +      ShellGlobalInstance.droptocli = true; +    } +      int BruiserLuaStrainRecognition(lua_State* __ls)      {        unsigned int numthreads = std::thread::hardware_concurrency(); @@ -2273,16 +2288,6 @@ int main(int argc, const char **argv) {      while((command = linenoise(">>>")) != NULL) {        linenoiseHistoryAdd(command);        linenoiseHistorySave(SHELL_HISTORY_FILE); -#if 0 -      if (std::string(command).find("!", 0) == 0) { -        std::string histnumber_str = std::string(command).substr(1, std::string::npos); -        unsigned int history_num = std::stoi(histnumber_str, 0, 10); -        if (history_num >= ShellGlobalInstance.HISTORY_SIZE) { -          PRINT_WITH_COLOR_LB(RED, "invalid history number passed."); -          continue; -        } else {} -      } -#endif        LE.RunChunk(command);        linenoiseFree(command);      } diff --git a/bruiser/bruisercapstone.c b/bruiser/bruisercapstone.c index abb21aa..39e274a 100644 --- a/bruiser/bruisercapstone.c +++ b/bruiser/bruisercapstone.c @@ -317,7 +317,7 @@ JMP_S_T* makejmptable(size_t size, uint8_t* obj, bool Verbose, lua_State* __ls)      cs_free(insn, count);    } else { -    printf("ERROR!!!\n"); +    printf("capstone ERROR!!!\n");    }    cs_close(&handle);    tail->next = NULL; diff --git a/bruiser/lua-scripts/df-demo.lua b/bruiser/lua-scripts/df-demo.lua index 35a6b7a..d393988 100644 --- a/bruiser/lua-scripts/df-demo.lua +++ b/bruiser/lua-scripts/df-demo.lua @@ -26,11 +26,13 @@ function pretty_dump()  end  function jmp_table_test() +  io.write(colors("%{cyan}".."lua:getting text section...\n"))    local text_section = xobj.getTextSection(df_exe) +  io.write(colors("%{green}".."lua:got text section.\n"))    local head = jmp_s_t()    -- messes up the stack. I could fix it but not sure why i would want to keep this in    --local head2 = jmp_s_t:new() -  io.write("lua:calling getjmptable\n") +  io.write(colors("%{cyan}".."lua:calling getjmptable\n"))    head = getjmptable(#text_section, text_section)    while head:inext() ~= nil do diff --git a/bruiser/run.sh b/bruiser/run.sh index 955fc70..8271e35 100755 --- a/bruiser/run.sh +++ b/bruiser/run.sh @@ -1,4 +1,5 @@  #!/bin/bash  cd $(dirname $0) -"./bruiser"  ../test/bruisertest/test.cpp --verbose +#"./bruiser"  ../test/bruisertest/test.cpp --verbose +"./bruiser"  ../test/bruisertest/test.cpp | 
