Yuri Slobodyanyuk Blog on Information Security 2024年09月12日
PTR bulk DNS resolver in Perl to see what is in the name
index_new5.html
../../../zaker_core/zaker_tpl_static/wap/tpl_guoji1.html

 

介绍一种批量进行 PTR 解析的方法,虽不自称最快最好,但确实有效。文章还提到了该方法的一些具体操作和运行情况。

🎯该方法通过特定的脚本和代码实现批量PTR解析。首先创建Net::DNS::Resolver的新实例,然后通过正则表达式获取输入的IP地址范围,并进行多层循环遍历每个IP地址,对其进行查询和解析。若有答案,则提取并打印相关信息。

📋在解析过程中,只有有答案的情况才会被打印出来,无答案则不显示。通过多个foreach循环遍历IP地址的各个部分,确保对范围内的每个IP都进行处理。

⏱️文章还记录了脚本开始和完成运行的时间,以及提供了一个运行示例,展示了如何使用该脚本并给出了具体的命令和参数。

There are many ways to do PTR resolving in bulk, and this is just one of them. It doesn't pretend to be the fastest/coolest/best, the only thing I can claim - it works.

    # Yuri    # 19.02.2013    # this script accepts range of IP addresses to do PTr resolving for    # the range has to be in this format: startIp-endIp.startIp-endIp.startIp-endIp.startIp-endIp.    # Only answers are printed, i.e. if there is no answer  nothing is printed    use warnings;    use strict;    use Net::DNS ;    my $res = Net::DNS::Resolver->new();      my $input = shift ;         $input =~ /(.+)-(.+)\.(.+)-(.+)\.(.+)-(.+)\.(.+)-(.+)/ ;         print "Resolving ptrs for the following range: $input\n" ;         print "Started working at: " . scalar gmtime . "\n" ;         my ($oct1_start,$oct1_end,$oct2_start,$oct2_end,$oct3_start,$oct3_end,$oct4_start,$oct4_end) = ($1,$2,$3,$4,$5,$6,$7,$8) ;     foreach my $oct1 ($oct1_start..$oct1_end) {       foreach my $oct2 ($oct2_start..$oct2_end) {         foreach my $oct3 ($oct3_start..$oct3_end) {           foreach my $oct4 ($oct4_start..$oct4_end) {       my $answer = $res->query("${oct1}.${oct2}.${oct3}.${oct4}") ;     if (defined $answer) {    my @ptr = $answer->answer;    foreach my $record_ptr (@ptr) {    #print " NEw " . $record_ptr->print ;     my $str = substr($record_ptr->string,rindex($record_ptr->string,'R')+1) ;     print "$oct1.$oct2.$oct3.$oct4  "  . $str . "\n";    }    }    } } }}      print "Run completed at: " . scalar gmtime . "\n" ;

Example run: ** #perl script.pl 194-194.90-90.33-33.0-255**

Follow me on https://www.linkedin.com/in/yurislobodyanyuk/ not to miss what I publish on Linkedin, Github, blog, and more.

Fish AI Reader

Fish AI Reader

AI辅助创作,多种专业模板,深度分析,高质量内容生成。从观点提取到深度思考,FishAI为您提供全方位的创作支持。新版本引入自定义参数,让您的创作更加个性化和精准。

FishAI

FishAI

鱼阅,AI 时代的下一个智能信息助手,助你摆脱信息焦虑

联系邮箱 441953276@qq.com

相关标签

PTR解析 Net::DNS IP地址 脚本运行
相关文章