Browse Source

add small cpp programm to debug pcap processor WIP

Jens Keim 5 years ago
parent
commit
f8c53f67ba
2 changed files with 39 additions and 0 deletions
  1. 6 0
      code_boost/src/CMakeLists.txt
  2. 33 0
      code_boost/src/cxx/main.cpp

+ 6 - 0
code_boost/src/CMakeLists.txt

@@ -28,6 +28,9 @@ SET(SOURCE_FILES cxx/pcap_processor.cpp cxx/pcap_processor.h cxx/statistics.cpp
 # Add botnet comm processor source files
 SET(BOT_COMM_PROC_SOURCE cxx/botnet_comm_processor.h cxx/botnet_comm_processor.cpp)
 
+# Add the debugging source files
+SET(DEBUG_FILES cxx/main.cpp cxx/pcap_processor.cpp cxx/pcap_processor.h cxx/statistics.cpp cxx/statistics.h cxx/statistics_db.cpp cxx/statistics_db.h cxx/utilities.h cxx/utilities.cpp)
+
 # Include SQLiteCpp library and build it
 option(SQLITECPP_RUN_CPPLINT OFF)
 include_directories(SQLiteCpp/include)
@@ -62,6 +65,9 @@ TARGET_LINK_LIBRARIES(pcapreader "${TINS_LIBRARY}" ${PYTHON_LIBRARIES} SQLiteCpp
 ADD_LIBRARY(botnetcomm SHARED ${BOT_COMM_PROC_SOURCE})
 TARGET_LINK_LIBRARIES(botnetcomm ${PYTHON_LIBRARIES})
 
+ADD_EXECUTABLE(main ${DEBUG_FILES})
+TARGET_LINK_LIBRARIES(main pcapreader ${PYTHON_LIBRARIES})
+
 IF (APPLE)
   SET(CMAKE_SHARED_LIBRARY_SUFFIX ".so")
 ENDIF ()

+ 33 - 0
code_boost/src/cxx/main.cpp

@@ -0,0 +1,33 @@
+#include "pcap_processor.h"
+#include <pybind11/pybind11.h>
+
+namespace py = pybind11;
+
+int main(){
+    // pcap/2min.dump, True, /home/pepper-jk/code/ID2T-toolkit/code/ID2TLib/../../resources/, /home/pepper-jk/.cache/id2t/db/73/45/dbdec9ab5040.sqlite3
+    std::string pcap_path = "pcap/2min.dump";
+    std::string extra_tests = "True";
+    std::string resource_path = "/home/pepper-jk/code/ID2T-toolkit/code/ID2TLib/../../resources/";
+    std::string db_path = "/home/pepper-jk/.cache/id2t/db/73/45/dbdec9ab5040.sqlite3";
+
+    std::cout << "start" << std::endl;
+    pcap_processor* pp = new pcap_processor(pcap_path, extra_tests, resource_path, db_path);
+    std::cout << "pp" << std::endl;
+
+    // [10.0]
+    py::list* intervals = new py::list();
+    std::cout << "py::list" << std::endl;
+    intervals->append(10.0);
+    std::cout << "py::list" << std::endl;
+
+    pp->collect_statistics(*intervals);
+    std::cout << "collect_statistics" << std::endl;
+
+    // /home/pepper-jk/.cache/id2t/db/73/45/dbdec9ab5040.sqlite3, [10.0], True
+    bool del = true;
+
+    pp->write_to_database(db_path, *intervals, del);
+    std::cout << "write_to_database" << std::endl;
+
+    return 0;
+}