retdec
Classes | Functions
getsig.cpp File Reference

Generate signatures from binary files. More...

#include <cctype>
#include <vector>
#include "retdec/fileformat/format_factory.h"
#include "retdec/utils/conversion.h"
#include "retdec/utils/string.h"
#include "retdec/utils/io/log.h"

Classes

struct  Options
 

Functions

void printUsage ()
 
int printError (const std::string &message)
 
void printWarning (const std::string &message)
 
std::string getParamOrDie (std::vector< std::string > &argv, std::size_t &i)
 
bool doParams (int argc, char **_argv, Options &options)
 
std::size_t getShortestLength (const std::vector< std::string > &inputs)
 
std::string createSignature (const std::vector< std::string > &contents)
 
std::string formatToCondition (const Format &format)
 
std::string getYaraRule (const std::string &pattern, const Format &fileFormat, const Options &options)
 
int main (int argc, char **argv)
 

Detailed Description

Generate signatures from binary files.

Function Documentation

◆ createSignature()

std::string createSignature ( const std::vector< std::string > &  contents)

Creates signature pattern from vector of strings

Parameters
contentsVector of bytes from files
Returns
created signature

◆ doParams()

bool doParams ( int  argc,
char **  _argv,
Options options 
)

Process parameters

Parameters
argcnumber of program parameters
_argvarray of program parameters
optionsstructure for storing information
Returns
true if processing was completed successfully, false otherwise

◆ formatToCondition()

std::string formatToCondition ( const Format format)

Form entry point condition from format.

Parameters
formatfile format
Returns
condition as string

◆ getParamOrDie()

std::string getParamOrDie ( std::vector< std::string > &  argv,
std::size_t &  i 
)

Fetch parameter value or die with error message.

Parameters
argvvector with arguments
iindex of argument
Returns
argument value

◆ getShortestLength()

std::size_t getShortestLength ( const std::vector< std::string > &  inputs)

Get length of shortest string in given vector.

Parameters
inputsvector of strings
Returns
length of shortest string or 0

If input vector is empty, function returns 0.

◆ getYaraRule()

std::string getYaraRule ( const std::string &  pattern,
const Format fileFormat,
const Options options 
)

Create YARA rule from pattern.

Parameters
patterninput pattern
fileFormatfile format
optionsapplication options
Returns
YARA rule as string

◆ main()

int main ( int  argc,
char **  argv 
)

◆ printError()

int printError ( const std::string &  message)

Print error message and return non-zero value.

Parameters
messageerror message
Returns
non-zero value

◆ printUsage()

void printUsage ( )

Print usage.

◆ printWarning()

void printWarning ( const std::string &  message)

Print warning message.

Parameters
messagewarning message