# arirang ruby script example 
# by pilot
#
#
class Arirang

#@ari_port = 80
#@ari_recvsize = 1024
#@ari_recvflag = 3

    def baedal
        ari_title  = "microsoft iis server version list to file \n"
        ari_desc   = "iisver.rb will grab iis server version and make a file such as iis5.txt iis6.txt\n" 
        ari_desc  += "you can find out each iis server version on network\n"
        ari_desc  += "usage) arirang -R iisver.rb -h yournetwork/23 -P 60 \n"
        ari_author = "pilot <pilot@monkey.org>\n"
        ari_license = "BSD\n"

        puts "title: #{ari_title}"
        puts "desc: #{ari_desc}"
        puts "author: #{ari_author}"
        puts "license: #{ari_license}"
    end

    def iis_ver(list, host)
        File.open(list, "a") do |fd|
        fd.write(host)
        fd.write("\n")
        end
    end

    def asadal
        ariconnect
        buf  = "GET / HTTP/1.1\r\n"
        buf += "Host: #{$ari_host}\r\n\r\n"
        resp = arisend(buf)

        # buf = $ari_recv.split("\r\n")[0..10].join("\r\n")
        resp.each_line do |line|
        x = line.match(/^Server\: Microsoft-IIS\/(.+)/)
        if x != nil
            y = x[1].chomp#gsub(/\r\n/,"")
            if y == "3.0"
                z = "#{$ari_host} - IIS " + "#{y}\n"
                ariprint(z)
                iis_ver("iis3.0.txt", z)
            elsif y == "4.0"
                z = "#{$ari_host} - IIS " + "#{y}\n"
                ariprint(z)
                iis_ver("iis4.0.txt", z)
            elsif y == "5.0"
                z = "#{$ari_host} - IIS #{y}\n"
                ariprint(z)
                iis_ver("iis5.0.txt", z)
            elsif y == "5.1"
                z = "#{$ari_host} - IIS " + "#{y}\n"
                ariprint(z)
                iis_ver("iis5.1.txt", z)
            elsif y == "6.0"
                z = "#{$ari_host} - IIS " + "#{y}\n"
                ariprint(z)
                iis_ver("iis6.0.txt", z)
            elsif y == "7.0"
                z = "#{$ari_host} - IIS " + "#{y}\n"
                ariprint(z)
                iis_ver("iis7.0.txt", z)
            elsif y == "7.5"
                z = "#{$ari_host} - IIS " + "#{y}\n"
                ariprint(z)
                iis_ver("iis7.5.txt", z)
            end

            end
        end
    end


end




