Adds checks for the NO_LOGS definition and improved the vars resolution time

This commit is contained in:
Felipe Zimmerle
2015-09-17 17:41:38 -03:00
parent 3e067e7409
commit ed86c24df6
46 changed files with 294 additions and 62 deletions

View File

@@ -35,14 +35,18 @@ bool DetectSQLi::evaluate(Assay *assay, const std::string &input) {
if (issqli) {
// set_match_to_tx(msr, capture, fingerprint, 0);
if (assay) {
#ifndef NO_LOGS
assay->debug(4, "detected SQLi using libinjection with " \
"fingerprint '" + std::string(fingerprint) + "' at: '" +
input + "'");
#endif
}
} else {
if (assay) {
#ifndef NO_LOGS
assay->debug(9, "detected SQLi: not able to find an inject on '" +
input + "'");
#endif
}
}

View File

@@ -32,12 +32,16 @@ bool DetectXSS::evaluate(Assay *assay, const std::string &input) {
if (is_xss) {
if (assay) {
#ifndef NO_LOGS
assay->debug(5, "detected XSS using libinjection.");
#endif
}
} else {
if (assay) {
#ifndef NO_LOGS
assay->debug(9, "libinjection was not able to " \
"find any XSS in: " + input);
#endif
}
}

View File

@@ -67,18 +67,24 @@ namespace operators {
bool Operator::debug(Assay *assay, int x, std::string a) {
#ifndef NO_LOGS
assay->debug(x, a);
#endif
return true;
}
bool Operator::evaluate(Assay *assay) {
if (assay) {
#ifndef NO_LOGS
assay->debug(2, "Operator: " + this->op + \
" is not implemented or malfunctioning.");
#endif
} else {
#ifndef NO_LOGS
std::cerr << "Operator: " + this->op + \
" is not implemented or malfunctioning.";
#endif
}
return true;
}
@@ -86,11 +92,15 @@ bool Operator::evaluate(Assay *assay) {
bool Operator::evaluate(Assay *assay, const std::string& a) {
if (assay) {
#ifndef NO_LOGS
assay->debug(2, "Operator: " + this->op + \
" is not implemented or malfunctioning.");
#endif
} else {
#ifndef NO_LOGS
std::cerr << "Operator: " + this->op + \
" is not implemented or malfunctioning.";
#endif
}
return true;

View File

@@ -77,29 +77,37 @@ bool ValidateUrlEncoding::evaluate(Assay *assay, const std::string &input) {
case 1 :
/* Encoding is valid */
if (assay) {
#ifndef NO_LOGS
assay->debug(7, "Valid URL Encoding at '" +input + "'");
#endif
}
res = false;
break;
case -2 :
if (assay) {
#ifndef NO_LOGS
assay->debug(7, "Invalid URL Encoding: Non-hexadecimal "
"digits used at '" + input + "'");
#endif
}
res = true; /* Invalid match. */
break;
case -3 :
if (assay) {
#ifndef NO_LOGS
assay->debug(7, "Invalid URL Encoding: Not enough characters "
"at the end of input at '" + input + "'");
#endif
}
res = true; /* Invalid match. */
break;
case -1 :
default :
if (assay) {
#ifndef NO_LOGS
assay->debug(7, "Invalid URL Encoding: Internal Error (rc = " +
std::to_string(rc) + ") at '" + input + "'");
#endif
}
res = true;
break;

View File

@@ -125,45 +125,55 @@ bool ValidateUtf8Encoding::evaluate(Assay *assay, const std::string &str) {
switch (rc) {
case UNICODE_ERROR_CHARACTERS_MISSING :
if (assay) {
#ifndef NO_LOGS
assay->debug(8, "Invalid UTF-8 encoding: "
"not enough bytes in character "
"at " + str + ". [offset \"" +
std::to_string(i) + "\"]");
#endif
}
return true;
break;
case UNICODE_ERROR_INVALID_ENCODING :
if (assay) {
#ifndef NO_LOGS
assay->debug(8, "Invalid UTF-8 encoding: "
"invalid byte value in character "
"at " + str + ". [offset \"" +
std::to_string(i) + "\"]");
#endif
}
return true;
break;
case UNICODE_ERROR_OVERLONG_CHARACTER :
if (assay) {
#ifndef NO_LOGS
assay->debug(8, "Invalid UTF-8 encoding: "
"overlong character detected "
"at " + str + ". [offset \"" +
std::to_string(i) + "\"]");
#endif
}
return true;
break;
case UNICODE_ERROR_RESTRICTED_CHARACTER :
if (assay) {
#ifndef NO_LOGS
assay->debug(8, "Invalid UTF-8 encoding: "
"use of restricted character "
"at " + str + ". [offset \"" +
std::to_string(i) + "\"]");
#endif
}
return true;
break;
case UNICODE_ERROR_DECODING_ERROR :
if (assay) {
#ifndef NO_LOGS
assay->debug(8, "Error validating UTF-8 decoding "
"at " + str + ". [offset \"" +
std::to_string(i) + "\"]");
#endif
}
return true;
break;
@@ -171,9 +181,11 @@ bool ValidateUtf8Encoding::evaluate(Assay *assay, const std::string &str) {
if (rc <= 0) {
if (assay) {
#ifndef NO_LOGS
assay->debug(8, "Internal error during UTF-8 validation "
"at " + str + ". [offset \"" +
std::to_string(i) + "\"]");
#endif
}
return true;
}

View File

@@ -79,9 +79,11 @@ bool VerifyCC::evaluate(Assay *assay, const std::string &i) {
is_cc = luhnVerify(match.c_str(), match.size());
if (is_cc) {
if (assay) {
#ifndef NO_LOGS
assay->debug(9, "CC# match \"" + param +
"\" at " + i + ". [offset " +
std::to_string(offset) + "]");
#endif
}
return true;
}