Perl 导入nmap端口信息
平台有个需求要导入信息到MYSQL..
分析了下,写了个脚本,几分钟搞定。。。
while(<>){ @tmp=split(/\t/,$_); @xieyi=split(/\//,$tmp[1]); if($xieyi[1] eq 'tcp'){ if($tmp[3]=~m/^\#(.*)/){ print "portname:$tmp[0] port_number:$xieyi[0] port_text:$1 \n"; } } } sub db_insert{ my $name=shift; my $text=shift; my $port=shift; my $in=DBI->connect("DBI:mysql:database=w3a_system;host=localhost","root","") or die "NO :$!"; my $insert=$in->do("insert into w3a_net_scan_service(service_name,service_text,service_port)values('$name','$text',$port)"); $in->disconnect(); }