Skip to content

Commit

Permalink
Removed compiler yara rules generating a lot of false positives.
Browse files Browse the repository at this point in the history
Replace all header guardians with #pragma once.
Slightly altered the summary so it displays exploit mitigation techniques
used by the binary.
Added more unit tests.
  • Loading branch information
JusticeRage committed Jan 18, 2016
1 parent 4696759 commit 4fa827f
Show file tree
Hide file tree
Showing 25 changed files with 309 additions and 142 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ before_script:
script:
- make
- bin/manalyze --version
- python bin/yara_rules/update_clamav_signatures.py
- bin/manalyze-tests
after_success:
- coveralls --exclude external/yara --exclude test --gcov gcov-4.8
37 changes: 0 additions & 37 deletions bin/yara_rules/compilers.yara
Original file line number Diff line number Diff line change
Expand Up @@ -229,18 +229,6 @@ condition:
}


rule Free_Pascal_1_06
{
meta:
description = "Free Pascal 1.06"
strings:
$a0 = { C6 05 ?? ?? 40 00 ?? E8 ?? ?? 00 00 }
condition:
$a0
}


rule InstallAnywhere_6_1___Zero_G_Software_Inc
{
meta:
Expand Down Expand Up @@ -999,19 +987,6 @@ condition:
}


rule MASM_TASM___sig4__h_
{
meta:
description = "MASM/TASM - sig4 (h)"
strings:
$a0 = { FF 25 ?? ?? ?? 00 FF 25 ?? ?? ?? 00 FF 25 ?? ?? ?? 00 FF 25 ?? ?? ?? 00 FF 25 ?? ?? ?? 00 FF 25 ?? ?? ?? 00 FF 25 ?? ?? ?? 00 FF 25 ?? ?? ?? 00 FF 25 ?? ?? ?? 00 FF 25 ?? ?? ?? 00 FF 25 ?? ?? ?? 00 }
$a1 = { C3 FF 25 ?? ?? ?? 00 FF 25 ?? ?? ?? 00 FF 25 ?? ?? ?? 00 FF 25 ?? ?? ?? 00 FF 25 ?? ?? ?? 00 FF 25 ?? ?? ?? 00 FF 25 ?? ?? ?? 00 FF 25 ?? ?? ?? 00 FF 25 ?? ?? ?? 00 FF 25 ?? ?? ?? 00 FF 25 ?? ?? ?? 00 }
condition:
$a0 or $a1
}


rule Microsoft_Visual_C___6_0_DLL__Debug_
{
meta:
Expand Down Expand Up @@ -2427,18 +2402,6 @@ condition:
}


rule Free_Pascal_v1_06
{
meta:
description = "Free Pascal v1.06"
strings:
$a0 = { C6 05 ?? ?? 40 00 ?? E8 ?? ?? 00 00 }
condition:
$a0
}


rule Microsoft_C
{
meta:
Expand Down
2 changes: 1 addition & 1 deletion docs/before-contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ All code contributions should make every effort to match Manalyze's coding style
* Code structure
* All your code should reside in a meaningful namespace.
* Declare class and functions in header (".h") files.
* Protect header files against multiple inclusions.
* Protect header files against multiple inclusions with ``#pragma once``.
* Inclusion of system headers should precede inclusion of user-defined headers. Boost headers are considered system headers.
* Put function implementations in .cpp files.
* Function declarations must be documented following the `Doxygen <https://www.stack.nl/~dimitri/doxygen/manual/docblocks.html>`_ convention.
Expand Down
5 changes: 1 addition & 4 deletions include/config_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
along with Manalyze. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef _CONFIG_PARSER_H_
#define _CONFIG_PARSER_H_
#pragma once

#include <string>
#include <map>
Expand Down Expand Up @@ -49,5 +48,3 @@ typedef std::map<std::string, std::map<std::string, std::string> > config;
* @return The parsed data.
*/
config parse_config(const std::string& config_file);

#endif // !_CONFIG_PARSER_H_
5 changes: 1 addition & 4 deletions include/dump.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ You should have received a copy of the GNU General Public License
along with Manalyze. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef _DUMP_H_
#define _DUMP_H_
#pragma once

#include <set>
#include <vector>
Expand Down Expand Up @@ -46,5 +45,3 @@ void dump_summary(const mana::PE& pe, io::OutputFormatter& formatter);
void dump_hashes(const mana::PE& pe, io::OutputFormatter& formatter);

} // !namespace sg

#endif // !_DUMP_H_
5 changes: 1 addition & 4 deletions include/manacommons/color.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
along with Manalyze. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef _COLOR_H_
#define _COLOR_H_
#pragma once

#include <iostream>
#include <string>
Expand Down Expand Up @@ -84,5 +83,3 @@ void set_color(Color c);
#endif

} //namespace utils

#endif // !_COLOR_H_
5 changes: 1 addition & 4 deletions include/manacommons/output_tree_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ You should have received a copy of the GNU General Public License
along with Manalyze. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef _OUTPUT_TREE_NODE_
#define _OUTPUT_TREE_NODE_
#pragma once

#include <vector>
#include <string>
Expand Down Expand Up @@ -292,5 +291,3 @@ typedef boost::shared_ptr<nodes> pNodes;
DECLSPEC_MANACOMMONS unsigned int determine_max_width(pNode node);

} // !namespace io

#endif // !_OUTPUT_TREE_NODE_
5 changes: 1 addition & 4 deletions include/manape/imports.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
along with Manalyze. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef _IMPORTS_H_
#define _IMPORTS_H_
#pragma once

#include <string>
#include <algorithm>
Expand All @@ -42,5 +41,3 @@ namespace hash {
DECLSPEC pString hash_imports(const mana::PE& pe);

} //namespace hash

#endif
5 changes: 1 addition & 4 deletions include/manape/nt_values.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
along with Manalyze. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef _NT_VALUES_H_
# define _NT_VALUES_H_
#pragma once

#include <string>
#include <map>
Expand Down Expand Up @@ -106,5 +105,3 @@ DECLSPEC const_shared_strings translate_to_flags(int value, const flag_dict& dic
DECLSPEC pString translate_to_flag(int value, const flag_dict& dict);

} // !namespace nt

#endif
5 changes: 1 addition & 4 deletions include/manape/pe.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
along with Manalyze. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef _PE_H_
#define _PE_H_
#pragma once

#include <stdio.h>
#include <string.h>
Expand Down Expand Up @@ -406,5 +405,3 @@ class PE


} /* !namespace sg */

#endif /* !_PE_H_ */
5 changes: 1 addition & 4 deletions include/manape/pe_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
along with Manalyze. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef _PE_STRUCTS_H_
#define _PE_STRUCTS_H_
#pragma once

#include <vector>
#include <string>
Expand Down Expand Up @@ -358,5 +357,3 @@ typedef struct win_certificate_t
typedef boost::shared_ptr<win_certificate> pwin_certificate;

} // !namespace sg

#endif // !_PE_STRUCTS_H_
5 changes: 1 addition & 4 deletions include/manape/resources.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
along with Manalyze. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef _RESOURCES_H_
#define _RESOURCES_H_
#pragma once

#include <string>
#include <vector>
Expand Down Expand Up @@ -178,5 +177,3 @@ std::vector<boost::uint8_t> reconstruct_icon(pgroup_icon_directory directory, co
bool parse_version_info_header(vs_version_info_header& header, FILE* f);

} // !namespace sg

#endif // !_RESOURCES_H_
5 changes: 1 addition & 4 deletions include/manape/section.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
along with Manalyze. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef _SECTION_H_
#define _SECTION_H_
#pragma once

#include <stdio.h>
#include <boost/make_shared.hpp>
Expand Down Expand Up @@ -127,5 +126,3 @@ bool DECLSPEC is_address_in_section(boost::uint64_t rva, mana::pSection section,
mana::pSection DECLSPEC find_section(unsigned int rva, const std::vector<mana::pSection>& section_list);

} // !namespace sg

#endif // !_SECTION_H_
7 changes: 1 addition & 6 deletions include/manape/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@
along with Manalyze. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef _UTILS_H_
#define _UTILS_H_

#define BOOST_SPIRIT_USE_PHOENIX_V3
#pragma once

#include <stdio.h>
#include <stdlib.h>
Expand Down Expand Up @@ -116,5 +113,3 @@ bool read_string_at_offset(FILE* f, unsigned int offset, std::string& out, bool
double DECLSPEC shannon_entropy(const std::vector<boost::uint8_t>& bytes);

}

#endif
5 changes: 1 addition & 4 deletions include/output_formatter.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ You should have received a copy of the GNU General Public License
along with Manalyze. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef _OUTPUT_FORMATTER_H_
#define _OUTPUT_FORMATTER_H_
#pragma once

#include <sstream>
#include <ostream>
Expand Down Expand Up @@ -249,5 +248,3 @@ std::string timestamp_to_string(boost::uint64_t epoch_timestamp);
std::string escape(const std::string& s);

} // !namespace io

#endif // !_OUTPUT_FORMATTER_H_
5 changes: 1 addition & 4 deletions include/plugin_framework/auto_register.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
along with Manalyze. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef _AUTO_REGISTER_H_
#define _AUTO_REGISTER_H_
#pragma once

#include "plugin_manager.h"
#include "plugin.h"
Expand Down Expand Up @@ -45,5 +44,3 @@ class AutoRegister
};

} // !namespace plugin

#endif // !_AUTO_REGISTER_H_
5 changes: 1 addition & 4 deletions include/plugin_framework/dynamic_library.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
along with Manalyze. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef _DYNAMIC_LIBRARY_H_
#define _DYNAMIC_LIBRARY_H_
#pragma once

#include <string>
#include <sstream>
Expand Down Expand Up @@ -81,5 +80,3 @@ class SharedLibrary
typedef boost::shared_ptr<SharedLibrary> pSharedLibrary;

} //!namespace plugin

#endif // ! _DYNAMIC_LIBRARY_H_
5 changes: 1 addition & 4 deletions include/plugin_framework/plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
along with Manalyze. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef _PLUGIN_H_
#define _PLUGIN_H_
#pragma once

#include "plugin_interface.h"

Expand Down Expand Up @@ -94,5 +93,3 @@ class StaticPlugin : public Plugin
};

} // !namespace plugin

#endif // !_PLUGIN_H_
5 changes: 1 addition & 4 deletions include/plugin_framework/plugin_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
along with Manalyze. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef _PLUGIN_INTERFACE_H_
#define _PLUGIN_INTERFACE_H_
#pragma once

#include <string>
#include <map>
Expand Down Expand Up @@ -102,5 +101,3 @@ class IPlugin
typedef boost::shared_ptr<IPlugin> pIPlugin;

} // !namespace plugin

#endif // !_PLUGIN_INTERFACE_H_
5 changes: 1 addition & 4 deletions include/plugin_framework/plugin_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
along with Manalyze. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef _PLUGIN_MANAGER_H_
#define _PLUGIN_MANAGER_H_
#pragma once

#include <vector>
#include <iostream>
Expand Down Expand Up @@ -174,5 +173,3 @@ class PluginManager
bool name_matches(const std::string& s, pIPlugin p);

} // !namespace plugin

#endif // !_PLUGIN_MANAGER_H_
5 changes: 1 addition & 4 deletions include/plugin_framework/result.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
along with Manalyze. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef _RESULT_H_
#define _RESULT_H_
#pragma once

#include <vector>
#include <string>
Expand Down Expand Up @@ -123,5 +122,3 @@ template<>
DECLSPEC_MANACOMMONS void Result::add_information(io::pNode node);

} // !namespace plugin

#endif // !_RESULT_H_
4 changes: 1 addition & 3 deletions include/plugin_framework/threat_level.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@ You should have received a copy of the GNU General Public License
along with Manalyze. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef _THREAT_LEVEL_H_
#define _THREAT_LEVEL_H_
#pragma once

namespace plugin {

enum LEVEL { SAFE, NO_OPINION, SUSPICIOUS, MALICIOUS };

}

#endif // !_THREAT_LEVEL_H_
2 changes: 1 addition & 1 deletion manape/imports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ std::vector<pimage_library_descriptor> PE::_find_imported_dlls(const std::string
// ----------------------------------------------------------------------------

const_shared_strings PE::find_imports(const std::string& function_name_regexp,
const std::string& dll_name_regexp) const
const std::string& dll_name_regexp) const
{
auto destination = boost::make_shared<std::vector<std::string> >();
if (!_initialized) {
Expand Down

0 comments on commit 4fa827f

Please sign in to comment.