用于搜索内部文件的ssh命令

mak*_*our 2 ssh search grep

几周前,我的2个网站可能被ftp暴力破坏攻击破坏了我的网站文件.我发现他们通常在js或php文件中插入以下代码:

[Trojan code removed as irrelevant to this question.]

我想通过ssh登录并运行grep命令搜索所有文件,并仅为包含此代码的文件提供输出.

有帮助吗?

Bdw*_*wey 11

我使用此命令查找包含指定字符串的所有文件:

find /path/ -name "*.ext" -exec grep -l "sting" {} \;
Run Code Online (Sandbox Code Playgroud)


Dmi*_*tri 5

登录后,只需运行:

find /path/to/fies -type f -name "*.js" -exec grep -il 'string' {}\; > output.txt
Run Code Online (Sandbox Code Playgroud)

当然,适当地替换"/ path/to/files"和"string".