?
An den symlinks kanns net liegen - habs gecheckt, da sind gar keine symlinks in dem Verz.
Gut, dann dachte ich mir nehmen wir doch den Bash Befehl find. und passen den Code mit popen() an:
char* pipe_ (char *command)
{
char* buf = new char [10000];
char* lese = new char [10000];
/* lets open a pipe */
FILE *p = popen(command, "r");
/* Do some error checking */
if(p==NULL)
{
perror ("Could not create pipe");
exit(1);
}
/* Read until there is nothing more to read */
while(feof(p) == 0)
{
memset(buf, '\0', sizeof(buf));
fgets(buf, 10000, p);
strcat(lese, buf);
}
/* close the pipe */
pclose(p);
return lese;
}
void print_rec_dir(const char *path, string scan_pattern[], int scan_pattern_elements)
{
char* back = new char [10000];
char command [10000];
int mail = 0;
for (int i = 0; i <= scan_pattern_elements-1; i++)
{
strcpy (command, "find ");
strcat (command, path);
strcat (command, " -type f -exec grep -l \"");
strcat (command, scan_pattern[i].c_str());
strcat (command, "\" {} \\;");
back = pipe_ (command);
/* Let's check the result */
for (int i = 0; i <= 10000; i++)
{
if (back[i] != NULL)
{
if (mail == 0)
{
cout << "Found a file: " <<endl;
/* We did find something */
mail_raw ("alexander@localhost", "File was detected:", "We found a file, check: /tmp/found-log");
if (mail_web("fendalex@vol.at", "Found", "A.file.was.found,.check:./tmp/found-log") == false)
{
cout << "Could not send web-email. Check HTTP Connection" << endl;
system ("logger 'Could not send web-email. Check HTTP Connection'");
}
system ("logger Found a suspicious file");
mail = 1;
}
ofstream outf ("/tmp/found-log", ios::app);
outf << back[i];
outf.close();
}
}
}
}
Wie schon gehabt:
path: /home
scam_pattern[]: Hat 3 Werte: [0]: c99shell [1]: r57shell [2]:eval
scan_pattern_elements: Entspricht der Anzahl der Elemente von scan_pattern. Also 3 in meinem Fall
Führe ich das Programm z.B. gegen /tmp aus, so funktioniert dies einwandfrei.
Wenn ich das Programm jetzt aber gegen Verz. laufen lasse, welche größer sind, passiert folgendes:
./main
Segmentation fault
alexander@sysadm:~/Desktop/sis$ find: Der Prozeß grep wurde durch das Signal 13 abgebrochen.
find: Der Prozeß grep wurde durch das Signal 13 abgebrochen.
find: Der Prozeß grep wurde durch das Signal 13 abgebrochen.
find: Der Prozeß grep wurde durch das Signal 13 abgebrochen.
find: Der Prozeß grep wurde durch das Signal 13 abgebrochen.
find: Der Prozeß grep wurde durch das Signal 13 abgebrochen.
find: Der Prozeß grep wurde durch das Signal 13 abgebrochen.
find: Der Prozeß grep wurde durch das Signal 13 abgebrochen.
find: Der Prozeß grep wurde durch das Signal 13 abgebrochen.
find: Der Prozeß grep wurde durch das Signal 13 abgebrochen.
find: Der Prozeß grep wurde durch das Signal 13 abgebrochen.
[quote]
Für Hilfen, wär ich Euch sehr dankbar