]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
updating file names and superficial snort2lua structure
authorJosh <jrosenba@cisco.com>
Fri, 13 Jun 2014 19:22:04 +0000 (15:22 -0400)
committerJosh <jrosenba@cisco.com>
Fri, 13 Jun 2014 19:26:26 +0000 (15:26 -0400)
38 files changed:
tools/snort2lua/CMakeLists.txt
tools/snort2lua/converter.h
tools/snort2lua/data/CMakeLists.txt
tools/snort2lua/data/cv_data.cc [moved from tools/snort2lua/data/conv_data.cc with 97% similarity]
tools/snort2lua/data/cv_data.h [moved from tools/snort2lua/data/conv_data.h with 93% similarity]
tools/snort2lua/data/cv_option.cc [moved from tools/snort2lua/data/conv_option.cc with 96% similarity]
tools/snort2lua/data/cv_option.h [moved from tools/snort2lua/data/conv_option.h with 96% similarity]
tools/snort2lua/data/cv_table.cc [moved from tools/snort2lua/data/conv_table.cc with 96% similarity]
tools/snort2lua/data/cv_table.h [moved from tools/snort2lua/data/conv_table.h with 94% similarity]
tools/snort2lua/data/cv_var.cc [moved from tools/snort2lua/data/conv_var.cc with 97% similarity]
tools/snort2lua/data/cv_var.h [moved from tools/snort2lua/data/conv_var.h with 96% similarity]
tools/snort2lua/init_state.cc
tools/snort2lua/keyword_states/CMakeLists.txt [new file with mode: 0644]
tools/snort2lua/keyword_states/keywords_api.cc [moved from tools/snort2lua/keywords/keywords_api.cc with 97% similarity]
tools/snort2lua/keyword_states/keywords_api.h [moved from tools/snort2lua/keywords/keywords_api.h with 100% similarity]
tools/snort2lua/keyword_states/kws_config.cc [moved from tools/snort2lua/keywords/config.cc with 98% similarity]
tools/snort2lua/keyword_states/kws_include.cc [moved from tools/snort2lua/keywords/include.cc with 100% similarity]
tools/snort2lua/keyword_states/kws_output.cc [moved from tools/snort2lua/keywords/output.cc with 98% similarity]
tools/snort2lua/keyword_states/kws_preprocessor.cc [moved from tools/snort2lua/keywords/preprocessor.cc with 97% similarity]
tools/snort2lua/keyword_states/kws_suppress.cc [moved from tools/snort2lua/keywords/suppress.cc with 95% similarity]
tools/snort2lua/keyword_states/kws_var.cc [moved from tools/snort2lua/keywords/var.cc with 100% similarity]
tools/snort2lua/keywords/CMakeLists.txt [deleted file]
tools/snort2lua/output_states/CMakeLists.txt [moved from tools/snort2lua/output/CMakeLists.txt with 59% similarity]
tools/snort2lua/output_states/output_api.cc [moved from tools/snort2lua/output/output_api.cc with 80% similarity]
tools/snort2lua/output_states/output_api.h [moved from tools/snort2lua/output/output_api.h with 100% similarity]
tools/snort2lua/preprocessor/CMakeLists.txt [deleted file]
tools/snort2lua/preprocessor_states/CMakeLists.txt [new file with mode: 0644]
tools/snort2lua/preprocessor_states/pps_arpspoof.cc [moved from tools/snort2lua/preprocessor/arpspoof.cc with 100% similarity]
tools/snort2lua/preprocessor_states/pps_ftp_telnet.cc [new file with mode: 0644]
tools/snort2lua/preprocessor_states/pps_http_inspect.cc [moved from tools/snort2lua/preprocessor/http_inspect.cc with 100% similarity]
tools/snort2lua/preprocessor_states/pps_http_inspect_server.cc [moved from tools/snort2lua/preprocessor/http_inspect_server.cc with 100% similarity]
tools/snort2lua/preprocessor_states/pps_normalizers.cc [moved from tools/snort2lua/preprocessor/normalizers.cc with 100% similarity]
tools/snort2lua/preprocessor_states/pps_sfportscan.cc [moved from tools/snort2lua/preprocessor/sfportscan.cc with 99% similarity]
tools/snort2lua/preprocessor_states/pps_smtp.cc [moved from tools/snort2lua/preprocessor/smtp.cc with 100% similarity]
tools/snort2lua/preprocessor_states/preprocessor_api.cc [moved from tools/snort2lua/preprocessor/preprocessor_api.cc with 93% similarity]
tools/snort2lua/preprocessor_states/preprocessor_api.h [moved from tools/snort2lua/preprocessor/preprocessor_api.h with 100% similarity]
tools/snort2lua/snort2lua.cc
tools/snort2lua/state_template.cc

index 59deba8e768cb91e87244a0c9e0fd8332db5e8db..6de08dc00a952fd67edf425bc75aaa228d46d909 100644 (file)
@@ -3,9 +3,9 @@
 include_directories("${CMAKE_CURRENT_SOURCE_DIR}")
 
 add_subdirectory(data)
-add_subdirectory(keywords)
-add_subdirectory(preprocessor)
-add_subdirectory(output)
+add_subdirectory(keyword_states)
+add_subdirectory(preprocessor_states)
+add_subdirectory(output_states)
 
 add_executable(snort2lua
     snort2lua.cc
@@ -18,10 +18,10 @@ add_executable(snort2lua
 )
 
 target_link_libraries( snort2lua
-    data
-    keywords
-    output
-    preprocessor
+    converrsion_data
+    keyword_states
+    output_states
+    preprocessor_states
 )
 
 
index 7edc36bfc01c62932c4aa212c1bbd8a93d6fdfdd..0af3e149bd133057467d18d6d6d30be71e275fa9 100644 (file)
@@ -27,8 +27,8 @@
 #include <sstream>
 #include <stack>
 
-#include "data/conv_data.h"
-#include "data/conv_var.h"
+#include "data/cv_data.h"
+#include "data/cv_var.h"
 
 class ConversionState;
 
@@ -38,12 +38,17 @@ class Converter
 public:
     Converter();
     virtual ~Converter() {};
-    void reset_state();
+    // convert the following line from a snort.conf into a lua.conf
     bool convert_line(std::stringstream& data);
+    // set the next parsing state.
     void set_state(ConversionState* c);
+    // reset the current parsing state
+    void reset_state();
+    // prints the entire lua configuration to the output file.
+    friend std::ostream &operator<<( std::ostream& out, const Converter &cv) { return out << cv.data; }
     
+    // add a variable to the new lua configuration. For example, --> HOME_NET = 'any'
     bool inline add_variable(std::string name, std::string v){ return data.add_variable(name, v); };
-    friend std::ostream &operator<<( std::ostream& out, const Converter &cv) { return out << cv.data; }
 
     // open a table that does not contain a name --> NOT 'name = {...}' ONLY {...})
     bool open_table();
@@ -53,26 +58,33 @@ public:
     bool close_table();
 
     // add a string option to the table --> table = { name = 'val', }
+    // corresponds to Parameter::PT_STRING, Parameter::PT_SELECT
     bool add_option_to_table(std::string name, std::string val);
 
     // add an int option to the table --> table = { name = val, }
+    // corresponds to Parameter::PT_INT, Parametere::PT_PORT, Parametere::PT_REAL, etc
     bool add_option_to_table(std::string name, int val);
     
     // add a bool option to the table --> table = { name = true|false, }
+    // corresponds to Parameter::PT_BOOL
     bool add_option_to_table(std::string name, bool val);
     
     // add an option with a list of variables -->  table = { name = 'elem1 elem2 ...' }
+    // corresponds to Parameter::PT_MULTI
     bool add_list_to_table(std::string list_name, std::string next_elem);
     
     // add a commment to be printed in the table --> table = { -- comment \n ... }
     void add_comment_to_table(std::string comment);
 
+    // comment will appear immediately below the lua configuration
     void add_comment_to_file(std::string comment);
+    // add the entire stream as a comment in the new lua file
     void add_comment_to_file(std::string comment, std::stringstream& stream);
     // attach a comment about a deprecated option to a file or table
     void add_deprecated_comment(std::string dep_var);
-    // deprecated option ... use the new option instead
+    // add a comment with the formate 'deprecated option ... use the new option instead'
     void add_deprecated_comment(std::string dep_var, std::string new_var);
+    // log an error in the new lua file
     void log_error(std::string);
 
     void print_line(std::stringstream& in);
@@ -80,11 +92,12 @@ public:
     void print_line(std::string& in);
 
 private:
+    // the current parsing state.
     ConversionState* state;
+    // the data which will be printed into the new lua file
     ConversionData data;
+    // keeps track of the current tables
     std::stack<Table*> open_tables;
-
-
 };
 
 
index c63d9125e9928c381662a30d70a0fcc099c40a55..41137f19447f3ea47aa027b6539a7c5047e5134a 100644 (file)
@@ -1,11 +1,11 @@
 
-add_library(data
-    conv_data.h
-    conv_data.cc
-    conv_var.h
-    conv_var.cc
-    conv_table.h
-    conv_table.cc
-    conv_option.h
-    conv_option.cc
+add_library(converrsion_data
+    cv_data.h
+    cv_data.cc
+    cv_var.h
+    cv_var.cc
+    cv_table.h
+    cv_table.cc
+    cv_option.h
+    cv_option.cc
 )
similarity index 97%
rename from tools/snort2lua/data/conv_data.cc
rename to tools/snort2lua/data/cv_data.cc
index 1c0a27e82fe2968303d00f2fe6df513c140e4579..0123bb89aad9845c12379edb32c4787ecf166e72 100644 (file)
@@ -17,9 +17,9 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
-// conv_data.cc author Josh Rosenbaum <jorosenba@cisco.com>
+// cv_data.cc author Josh Rosenbaum <jorosenba@cisco.com>
 
-#include "conv_data.h"
+#include "cv_data.h"
 #include "snort2lua_util.h"
 
 #if 0
similarity index 93%
rename from tools/snort2lua/data/conv_data.h
rename to tools/snort2lua/data/cv_data.h
index 6c220d673afdacd5592980574c41296a3d82da77..5328ce47e28f5da6d2abdc39d4004c17691cbebc 100644 (file)
@@ -17,7 +17,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
-// conversion_data.h author Josh Rosenbaum <jorosenba@cisco.com>
+// cv_data.h author Josh Rosenbaum <jorosenba@cisco.com>
 
 #ifndef CONV_DATA_H
 #define CONV_DATA_H
@@ -26,8 +26,8 @@
 #include <iostream>
 #include <vector>
 
-#include "data/conv_table.h"
-#include "data/conv_var.h"
+#include "data/cv_table.h"
+#include "data/cv_var.h"
 
 class ConversionData
 {
similarity index 96%
rename from tools/snort2lua/data/conv_option.cc
rename to tools/snort2lua/data/cv_option.cc
index 90cbb51606cf59836a91843e2a5bd43255510bf7..bcbe88a4f5a1f6dbc15f3e256488f7c4ad26de29 100644 (file)
@@ -17,9 +17,9 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
-// conv_option.cc author Josh Rosenbaum <jorosenba@cisco.com>
+// cv_option.cc author Josh Rosenbaum <jorosenba@cisco.com>
 
-#include "data/conv_option.h"
+#include "data/cv_option.h"
 
 
 Option::Option(std::string name, int val, int depth)
similarity index 96%
rename from tools/snort2lua/data/conv_option.h
rename to tools/snort2lua/data/cv_option.h
index bcc004cbe6e8aded0d36c162af992173ace0b43c..18bd671ad362cd3cb9642f665213de1898b85641 100644 (file)
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
-// conv_var.h author Josh Rosenbaum <jorosenba@cisco.com>
+// cv_option.h author Josh Rosenbaum <jorosenba@cisco.com>
 
 #ifndef CONV_OPTIONS_H
 #define CONV_OPTIONS_H
 
-
 #include <string>
 #include <vector>
 #include <iostream>
similarity index 96%
rename from tools/snort2lua/data/conv_table.cc
rename to tools/snort2lua/data/cv_table.cc
index 63788588a0a33cc2ad382984c127265b6382ab71..6a7b837a365635c05d91b938544afef630e1383b 100644 (file)
@@ -17,9 +17,9 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
-// conv_table.cc author Josh Rosenbaum <jorosenba@cisco.com>
+// cv_table.cc author Josh Rosenbaum <jorosenba@cisco.com>
 
-#include "data/conv_table.h"
+#include "data/cv_table.h"
 
 static inline Table* find_table(std::vector<Table*> vec, std::string name)
 {
@@ -171,8 +171,8 @@ std::ostream &operator<<( std::ostream& out, const Table &t)
     for (Variable* v : t.lists)
         out << (*v) << ',' << std::endl;
 
-    for (Table* t : t.tables)
-        out << (*t) << ',' << std::endl;
+    for (Table* sub_t : t.tables)
+        out << (*sub_t) << ',' << std::endl;
 
     // don't add a comma if the depth is zero
     if(t.depth == 0)
similarity index 94%
rename from tools/snort2lua/data/conv_table.h
rename to tools/snort2lua/data/cv_table.h
index 0c9dd93a71d0033d9d86debff256e5c0658e448e..b258457d5d8e34c69aa7ebd1864770bd76933dea 100644 (file)
@@ -17,7 +17,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
-// conv_var.h author Josh Rosenbaum <jorosenba@cisco.com>
+// cv_table.h author Josh Rosenbaum <jorosenba@cisco.com>
 
 #ifndef CONV_TABLE_H
 #define CONV_TABLE_H
@@ -27,8 +27,8 @@
 #include <vector>
 #include <iostream>
 
-#include "conv_option.h"
-#include "conv_var.h"
+#include "cv_option.h"
+#include "cv_var.h"
 
 class Table
 {
similarity index 97%
rename from tools/snort2lua/data/conv_var.cc
rename to tools/snort2lua/data/cv_var.cc
index 46509c8e8bc7d59f94cc38f7abe45174de565be2..394da5defaa37ce954e831241cd6fa15829083f0 100644 (file)
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
-// conv_var.cc author Josh Rosenbaum <jorosenba@cisco.com>
+// cv_var.cc author Josh Rosenbaum <jorosenba@cisco.com>
 
-#include "data/conv_var.h"
+#include "data/cv_var.h"
 
 
+#if 0
 static inline bool var_exists(std::vector<std::string> vec, std::string name)
 {
     for( auto str : vec)
@@ -30,6 +31,7 @@ static inline bool var_exists(std::vector<std::string> vec, std::string name)
 
     return true;
 }
+#endif
 
 Variable::Variable(std::string name, int depth)
 {
similarity index 96%
rename from tools/snort2lua/data/conv_var.h
rename to tools/snort2lua/data/cv_var.h
index 72255b86ed48dc47d656e046b9978af7aabf6e33..353eec6ffdc9664b425b721a54f47ba7bc4084d1 100644 (file)
@@ -17,7 +17,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
-// conv_var.h author Josh Rosenbaum <jorosenba@cisco.com>
+// cv_var.h author Josh Rosenbaum <jorosenba@cisco.com>
 
 #include <string>
 #include <vector>
index b5e05b72889215c199207ad03d207aa880ace3a1..74c337caf274f1d773a9a587ea58c431cc41f0a9 100644 (file)
@@ -25,7 +25,7 @@
 #include <iostream>
 #include "init_state.h"
 #include "snort2lua_util.h"
-#include "keywords/keywords_api.h"
+#include "keyword_states/keywords_api.h"
 
 
 InitState::InitState(Converter* cv) : ConversionState(cv) {}
@@ -40,10 +40,8 @@ bool InitState::convert(std::stringstream& data_stream)
 
         if( keyword.front() == '#')
         {
+            std::cout << "THIS SHOULD NEVER OCCUR" << std::endl;
             keyword.erase(keyword.begin());
-//            std::ostringstream oss;
-//            oss << data_stream.rdbuf();
-//            out << "--" << keyword << oss.str() << std::endl;
             converter->add_comment_to_file(keyword, data_stream);
             data_stream.setstate(std::basic_ios<char>::eofbit);
             return true;
diff --git a/tools/snort2lua/keyword_states/CMakeLists.txt b/tools/snort2lua/keyword_states/CMakeLists.txt
new file mode 100644 (file)
index 0000000..65b7c93
--- /dev/null
@@ -0,0 +1,15 @@
+
+add_library( keyword_states
+    kws_config.cc
+    kws_output.cc
+    kws_var.cc
+    kws_preprocessor.cc
+    kws_include.cc
+    keywords_api.h
+    keywords_api.cc
+)
+
+target_link_libraries( keyword_states
+    output_states
+    preprocessor_states
+)
\ No newline at end of file
similarity index 97%
rename from tools/snort2lua/keywords/keywords_api.cc
rename to tools/snort2lua/keyword_states/keywords_api.cc
index a22ae0aa8039de28525bb044e009853f7a81d537..833ac2fad4e6049dbfd1725153587c1afcd80e4b 100644 (file)
@@ -19,7 +19,7 @@
  */
 // keywords_api.cc author Josh Rosenbaum <jorosenba@cisco.com>
 
-#include "keywords/keywords_api.h"
+#include "keyword_states/keywords_api.h"
 
 
 extern const ConvertMap *portvar_map;
similarity index 98%
rename from tools/snort2lua/keywords/config.cc
rename to tools/snort2lua/keyword_states/kws_config.cc
index 8dcebf937458cfe547907b9cbd04c994ff84dcb7..7babe5ff0d71a0d35d9187bae82d476ca93a296e 100644 (file)
@@ -26,8 +26,6 @@
 #include "conversion_state.h"
 #include "converter.h"
 #include "snort2lua_util.h"
-#include "output/output_api.h"
-
 
 
 namespace {
similarity index 98%
rename from tools/snort2lua/keywords/output.cc
rename to tools/snort2lua/keyword_states/kws_output.cc
index af672d524415142945019c9328f9a3b890e4ce00..d60ae751d76059be3c8e9b77dd6c264f272e52b3 100644 (file)
@@ -25,7 +25,7 @@
 #include "conversion_state.h"
 #include "converter.h"
 #include "snort2lua_util.h"
-#include "output/output_api.h"
+#include "output_states/output_api.h"
 
 
 
similarity index 97%
rename from tools/snort2lua/keywords/preprocessor.cc
rename to tools/snort2lua/keyword_states/kws_preprocessor.cc
index 36426defb76a1dbfb54e64ba1595985a89133429..203bdf4755f1fb07c84a1f02f0d0c707bd516046 100644 (file)
@@ -26,7 +26,7 @@
 #include "conversion_state.h"
 #include "converter.h"
 #include "snort2lua_util.h"
-#include "preprocessor/preprocessor_api.h"
+#include "preprocessor_states/preprocessor_api.h"
 
 namespace {
 
similarity index 95%
rename from tools/snort2lua/keywords/suppress.cc
rename to tools/snort2lua/keyword_states/kws_suppress.cc
index acaee91a40a75a897ba5b8492017c35f8fede932..043463fa0f87f9de022f0147ffeb0a2df7255d5f 100644 (file)
@@ -17,7 +17,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
-// config.cc author Josh Rosenbaum <jorosenba@cisco.com>
+// suppress.cc author Josh Rosenbaum <jorosenba@cisco.com>
 
 #include <sstream>
 #include <vector>
@@ -26,6 +26,7 @@
 #include "conversion_state.h"
 #include "converter.h"
 #include "snort2lua_util.h"
+//#include "suppress_states/suppress_api.h"
 
 namespace {
 
diff --git a/tools/snort2lua/keywords/CMakeLists.txt b/tools/snort2lua/keywords/CMakeLists.txt
deleted file mode 100644 (file)
index e530b16..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-
-add_library( keywords
-    config.cc
-    output.cc
-    var.cc
-    preprocessor.cc
-    include.cc
-    keywords_api.h
-    keywords_api.cc
-)
-
-target_link_libraries( keywords
-    output
-    preprocessor
-)
\ No newline at end of file
similarity index 59%
rename from tools/snort2lua/output/CMakeLists.txt
rename to tools/snort2lua/output_states/CMakeLists.txt
index 5998ea0d0bd55031cb918e690dce870b7526f505..c12bb65dc3aa0c087e9a166a47abc63b10d35b27 100644 (file)
@@ -1,6 +1,6 @@
 
 
-add_library(output
+add_library(output_states
     output_api.h
     output_api.cc
 )
\ No newline at end of file
similarity index 80%
rename from tools/snort2lua/output/output_api.cc
rename to tools/snort2lua/output_states/output_api.cc
index c3637005e00a9ec107f510890b6c936ffc13f6ce..f96b55552e0c2e0f14836e9b6c6628cf11f1e900 100644 (file)
  */
 // output_api.cc author Josh Rosenbaum <jorosenba@cisco.com>
 
-#include "output/output_api.h"
-
-
-extern const ConvertMap *portvar_map;
-extern const ConvertMap *ipvar_map;
-extern const ConvertMap *var_map;
-extern const ConvertMap *output_map;
+#include "output_states/output_api.h"
 
 const std::vector<const ConvertMap*> output_api = 
 {
-    portvar_map,
-    ipvar_map,
-    var_map,
-    output_map,
-//    nullptr,
+    nullptr,
 };
diff --git a/tools/snort2lua/preprocessor/CMakeLists.txt b/tools/snort2lua/preprocessor/CMakeLists.txt
deleted file mode 100644 (file)
index 57a1229..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-
-add_library(preprocessor
-    arpspoof.cc
-    http_inspect.cc
-    smtp.cc
-    normalizers.cc
-    sfportscan.cc
-    preprocessor_api.h
-    preprocessor_api.cc
-)
\ No newline at end of file
diff --git a/tools/snort2lua/preprocessor_states/CMakeLists.txt b/tools/snort2lua/preprocessor_states/CMakeLists.txt
new file mode 100644 (file)
index 0000000..0fa357d
--- /dev/null
@@ -0,0 +1,11 @@
+
+add_library(preprocessor_states
+    pps_arpspoof.cc
+    pps_http_inspect.cc
+    pps_smtp.cc
+    pps_normalizers.cc
+    pps_sfportscan.cc
+    pps_ftp_telnet.cc
+    preprocessor_api.h
+    preprocessor_api.cc
+)
diff --git a/tools/snort2lua/preprocessor_states/pps_ftp_telnet.cc b/tools/snort2lua/preprocessor_states/pps_ftp_telnet.cc
new file mode 100644 (file)
index 0000000..f1c6335
--- /dev/null
@@ -0,0 +1,115 @@
+/*
+** Copyright (C) 2014 Cisco and/or its affiliates. All rights reserved.
+ * Copyright (C) 2002-2013 Sourcefire, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License Version 2 as
+ * published by the Free Software Foundation.  You may not use, modify or
+ * distribute this program under any other version of the GNU General
+ * Public License.
+ *
+ * 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.
+ */
+// config.cc author Josh Rosenbaum <jorosenba@cisco.com>
+
+#include <sstream>
+#include <vector>
+#include <iomanip>
+
+#include "conversion_state.h"
+#include "converter.h"
+#include "snort2lua_util.h"
+
+namespace {
+
+class FtpTelnet : public ConversionState
+{
+public:
+    FtpTelnet(Converter* cv)  : ConversionState(cv) {};
+    virtual ~FtpTelnet() {};
+    virtual bool convert(std::stringstream& data_stream);
+};
+
+} // namespace
+
+
+bool FtpTelnet::convert(std::stringstream& data_stream)
+{
+#if 0
+# FTP / Telnet normalization and anomaly detection.  For more information, see README.ftptelnet
+preprocessor ftp_telnet: global inspection_type stateful encrypted_traffic no check_encrypted
+preprocessor ftp_telnet_protocol: telnet \
+    ayt_attack_thresh 20 \
+    normalize ports { 23 } \
+    detect_anomalies
+preprocessor ftp_telnet_protocol: ftp server default \
+    def_max_param_len 100 \
+    ports { 21 2100 3535 } \
+    telnet_cmds yes \
+    ignore_telnet_erase_cmds yes \
+    ftp_cmds { ABOR ACCT ADAT ALLO APPE AUTH CCC CDUP } \
+    ftp_cmds { CEL CLNT CMD CONF CWD DELE ENC EPRT } \
+    ftp_cmds { EPSV ESTA ESTP FEAT HELP LANG LIST LPRT } \
+    ftp_cmds { LPSV MACB MAIL MDTM MIC MKD MLSD MLST } \
+    ftp_cmds { MODE NLST NOOP OPTS PASS PASV PBSZ PORT } \
+    ftp_cmds { PROT PWD QUIT REIN REST RETR RMD RNFR } \
+    ftp_cmds { RNTO SDUP SITE SIZE SMNT STAT STOR STOU } \
+    ftp_cmds { STRU SYST TEST TYPE USER XCUP XCRC XCWD } \
+    ftp_cmds { XMAS XMD5 XMKD XPWD XRCP XRMD XRSQ XSEM } \
+    ftp_cmds { XSEN XSHA1 XSHA256 } \
+    alt_max_param_len 0 { ABOR CCC CDUP ESTA FEAT LPSV NOOP PASV PWD QUIT REIN STOU SYST XCUP XPWD } \
+    alt_max_param_len 200 { ALLO APPE CMD HELP NLST RETR RNFR STOR STOU XMKD } \
+    alt_max_param_len 256 { CWD RNTO } \
+    alt_max_param_len 400 { PORT } \
+    alt_max_param_len 512 { SIZE } \
+    chk_str_fmt { ACCT ADAT ALLO APPE AUTH CEL CLNT CMD } \
+    chk_str_fmt { CONF CWD DELE ENC EPRT EPSV ESTP HELP } \
+    chk_str_fmt { LANG LIST LPRT MACB MAIL MDTM MIC MKD } \
+    chk_str_fmt { MLSD MLST MODE NLST OPTS PASS PBSZ PORT } \
+    chk_str_fmt { PROT REST RETR RMD RNFR RNTO SDUP SITE } \
+    chk_str_fmt { SIZE SMNT STAT STOR STRU TEST TYPE USER } \
+    chk_str_fmt { XCRC XCWD XMAS XMD5 XMKD XRCP XRMD XRSQ } \
+    chk_str_fmt { XSEM XSEN XSHA1 XSHA256 } \
+    cmd_validity ALLO < int [ char R int ] > \
+    cmd_validity EPSV < [ { char 12 | char A char L char L } ] > \
+    cmd_validity MACB < string > \
+    cmd_validity MDTM < [ date nnnnnnnnnnnnnn[.n[n[n]]] ] string > \
+    cmd_validity MODE < char ASBCZ > \
+    cmd_validity PORT < host_port > \
+    cmd_validity PROT < char CSEP > \
+    cmd_validity STRU < char FRPO [ string ] > \
+    cmd_validity TYPE < { char AE [ char NTC ] | char I | char L [ number ] } >
+preprocessor ftp_telnet_protocol: ftp client default \
+    max_resp_len 256 \
+    bounce yes \
+    ignore_telnet_erase_cmds yes \
+    telnet_cmds yes
+#endif
+
+    data_stream.setstate(std::basic_ios<char>::eofbit);
+    return true;    
+}
+
+/**************************
+ *******  A P I ***********
+ **************************/
+
+static ConversionState* ctor(Converter* cv)
+{
+    return new FtpTelnet(cv);
+}
+
+static const ConvertMap keyword_preprocessor = 
+{
+    "ftp_telnet",
+    ctor,
+};
+
+const ConvertMap* preprocessor_map = &keyword_preprocessor;
similarity index 99%
rename from tools/snort2lua/preprocessor/sfportscan.cc
rename to tools/snort2lua/preprocessor_states/pps_sfportscan.cc
index 56fa31987b274c6f7ab337d31508ade54c1fd9d0..4ca07758c8283f2a59b514bf42215cb53a7decf8 100644 (file)
@@ -49,7 +49,6 @@ private:
 
 bool PortScan::parse_ip_list(std::string list_name, std::stringstream& data_stream)
 {
-    bool retval;
     std::string prev;
     std::string elem;
 
similarity index 93%
rename from tools/snort2lua/preprocessor/preprocessor_api.cc
rename to tools/snort2lua/preprocessor_states/preprocessor_api.cc
index 1c9c91bff16278d2229cea1c1d5c0ff5b84d2e6e..78ea8c46a15a330e6b4eba500fe8096a4763ec2e 100644 (file)
@@ -17,9 +17,9 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
-// keywords_api.cc author Josh Rosenbaum <jorosenba@cisco.com>
+// preprocessor_api.cc author Josh Rosenbaum <jorosenba@cisco.com>
 
-#include "preprocessor/preprocessor_api.h"
+#include "preprocessor_states/preprocessor_api.h"
 
 
 extern const ConvertMap *arpspoof_map;
index fba1364beedc7c8f0767783f2942033bff43949f..5eb76b5776becebd760834c53db9913e9d093900 100644 (file)
@@ -38,7 +38,7 @@ static bool convert(std::ifstream& in, std::ofstream& out)
         std::getline(in, tmp);
         util::ltrim(tmp);
         orig_text += ' ' + tmp;
-        util::rtrim(orig_text);
+        util::trim(orig_text);
 
         if (orig_text.empty())
         {
@@ -48,6 +48,7 @@ static bool convert(std::ifstream& in, std::ofstream& out)
         {
             orig_text.erase(orig_text.begin());
             cv.add_comment_to_file(orig_text);
+            orig_text.clear();
         }
         else if ( orig_text.back() == '\\')
         {
index 573eb00b5111cc2909b199779e2b767f1cb7d4e7..715f3b54d98464d213531d1015d4b589b084b437 100644 (file)
@@ -43,19 +43,6 @@ public:
 bool Suppress::convert(std::stringstream& data_stream)
 {
 #if 0
-    std::string keyword;
-
-    if(data_stream >> keyword)
-    {
-        const ConvertMap* map = util::find_map(output_api, keyword);
-        if (map)
-        {
-            converter->set_state(map->ctor(converter));
-            return true;
-        }
-    }
-
-    return false;    
 #endif
 
     data_stream.setstate(std::basic_ios<char>::eofbit);