Alterserv

ThunderCache 3.1.x => Plugins para ThunderCache 3.1.2 => Plugins de Antivirus => Mensaje publicado por: Zero en Febrero 02, 2013, 03:02:21 PM

Título: Plugin Avast Actualizado
Publicado por: Zero en Febrero 02, 2013, 03:02:21 PM
Hola todos, espero que se encuentren bien.

Soy nuevo por estos lares, hace poco tuve problemas con el plugin de avast con mi bfwcache (algo asi como un primo-medio-hermano) del thunder3, así que tuve que actualizar el code y aquí está el resultado:
Código (cpp) [Seleccionar]
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include "../utils.cpp"

using namespace std;

// use this line to compile
// g++ -I. -fPIC -shared -g -o avast.com.so avast.com.cpp
// http.*\.avast\.com.*(\.def|\.vpu|\.vpaa|\.stamp|\.vpx)
// By Lelouch

bool in_array(const string &needle, const vector< string > &haystack) {
int max = haystack.size();

if (max == 0) return false;
 
for (int iii = 0; iii < max; iii++) {
  if (regex_match(haystack[iii], needle) != "") {
  return true;
}
}
return false;
}

string get_filename(string url) {
vector<string> resultado;
if (url.find("?") != string::npos) {
stringexplode(url, "?", &resultado);
stringexplode(resultado.at(resultado.size()-2), "/", &resultado);
return resultado.at(resultado.size()-1);          
} else {
stringexplode(url, "/", &resultado);
return resultado.at(resultado.size()-1);
}
}

extern "C" resposta get_match(const string url) {
resposta r;
vector<string> black_list;
black_list.push_back ("servers.def.vpx");
black_list.push_back ("prod-ais.vpx");
if ((url.find(".avast.com/") != string::npos) or
(url.find(".avast.com/iavs5x/") != string::npos) and
(in_array(url, black_list) == false)) {
r.file = get_filename(url);
if (!r.file.empty()) {
r.match = true;
r.domain = "avast";
} else {
r.match = false;
}
} else {
r.match = false;
}
return r;
}