0
点赞
收藏
分享

微信扫一扫

搜索子域名的Shell脚本

醉东枫 2022-02-14 阅读 43

以www.megacorpone.com网站为例:

首先用wget www.megacorpone.com下载网站的首页文件

用grep "href" index.html 过滤超链接关键字

命令行输入

grep "href" index.html |grep "\.megacorpone" |grep "www\.megacorpone\.com" |awk -F "http://" {'print $2'} | cut -d "/" -f 1 >list.txt # >list.txt 将过滤的结果保存的list.txt文件中

还是命令行输入

for url in $(cat list.txt);do host $url;done} |grep "has address" |cut -d " " -f 1,4

这是直接在命令行环境下写的

下面是用shell脚本写

[^/]*\.megacorpone\.com是正则表达式,用来匹配想要的字段

#!/bin/bash
grep -o '[^/]*\.megacorpone\.com' index.html |sort -u > list.txt
for ip in $(cat list.txt)
do
host $ip
done

可以看到效果是一样的 

举报

相关推荐

0 条评论