我使用Sysinternals Strings输出内存转储中的所有字符串。我需要从*到*。
中提取所有字符串两者之间*是域名或域名元素(特洛伊木马的目标列表)。
*/cmserver/*
*/pub/html/*
*arabi-online.net/efs/servlet/efs/*
*ibanking.*.com.au/InternetBanking/*
我尝试了这个...但是我对$字符有问题:
cat strings.txt | grep -o '\*[^"]*' | egrep "[a-zA-Z0-9\-\.\/]{4}\*$" | sort -u
答案 0 :(得分:1)
如果你的grep支持PCRE,这应该很简单:
grep -Po "(?<=\*)(.*)(?=\*)" strings.txt
<强>输入:强>
$ cat strings.txt
*/cmserver/*
*/pub/html/*
*arabi-online.net/efs/servlet/efs/*
*ibanking.*.com.au/InternetBanking/*
<强>输出:强>
$ grep -Po "(?<=\*)(.*)(?=\*)" strings.txt
/cmserver/
/pub/html/
arabi-online.net/efs/servlet/efs/
ibanking.*.com.au/InternetBanking/
答案 1 :(得分:1)
使用sed更容易:
sed 's/^\*\|\*$//g' strings.txt
答案 2 :(得分:0)
cat strings.txt | grep "^\*" | grep "[A-Za-z0-9\-\+\.\/]\{4\}\*.$" | sort -u works the best for me!