<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:output method="html" indent="yes" encoding="UTF-8" />
<!--
==============================================================================
	nmap-ng.xsl stylesheet version 0.1 (2008-02-12)
	Brad Geesaman, brad 'at' bradgeesaman [dot] com

nmap-ng.xsl is based very heavily off of nmap.xsl (0.9b) by Benjamin Erb.  I
just wanted to change the layout slightly.

Modified WITHOUT the original author's permission, and I kept the copyright
statement below intact.  Note that the majority of OS detection items are
not shown in the result due to the verbosity and "noise" factor.  The only
items shown are the "osmatch" elements where Nmap really thinks that is the
correct guess.  Also note that certain results are not displayed (mostly
due to my lack of source data with all options on).

Copyright (c) 2008 Brad Geesaman
All rights reserved.

In terms of copyright terms, I'm reusing Benjamin's terms below in the
same manner for this version.  Same thing for the disclaimer.

==============================================================================
-->
<!-- =========================================================================
            nmap.xsl stylesheet version 0.9b 
	    last change: 2006-03-04
	    Benjamin Erb, http://www.benjamin-erb.de
==============================================================================
    Copyright (c) 2004-2006 Benjamin Erb
    All rights reserved.
    
    Redistribution and use in source and binary forms, with or without
    modification, are permitted provided that the following conditions
    are met:
    1. Redistributions of source code must retain the above copyright
    notice, this list of conditions and the following disclaimer.
    2. Redistributions in binary form must reproduce the above copyright
    notice, this list of conditions and the following disclaimer in the
    documentation and/or other materials provided with the distribution.
    3. The name of the author may not be used to endorse or promote products
    derived from this software without specific prior written permission.
	
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
========================================================================== -->



<!-- global variables      -->
<!-- ............................................................ -->
<xsl:variable name="nmap_xsl_version">0.9a</xsl:variable>
<!-- ............................................................ -->
<xsl:variable name="start"><xsl:value-of select="/nmaprun/@start" /></xsl:variable>
<xsl:variable name="end"><xsl:value-of select="/nmaprun/runstats/finished/@time" /> </xsl:variable>
<xsl:variable name="totaltime"><xsl:value-of select="/nmaprun/runstats/finished/@time -/nmaprun/@start" /></xsl:variable>
<!-- ............................................................ -->


<xsl:template match="/">
	<xsl:apply-templates/>
</xsl:template>


<!-- root -->
<!-- ............................................................ -->
<xsl:template match="/nmaprun">
<html>
<head>
<xsl:comment>generated with nmap-ng.xsl - version <xsl:value-of select="$nmap_xsl_version" /> which was heavily based on Benjamin Erb's nmap.xsl without permission by Brad Geesaman, brad 'at' bradgeesaman [dot] com </xsl:comment>
<style type="text/css">
  body {
    background-color: white;
  }
  .title {
    margin: 0em 1em 0em 1em;
    padding: .25em;
    font: bold 1.5em arial;
  }
  .headerfooter {
    margin: 0em 1em 0em 1em;
    background-color: #D1D1D1;
    padding: .25em;
    color: #434343;
    font: bold 1em arial;
    border-left: 1px solid #7C7C7C;
    border-right: 1px solid #7C7C7C;
  }
  .headerfooter a:hover{
    text-decoration: underline;
    font: .75em arial;
  }
  .headerfooter a {
    text-decoration: none;
    font: .75em arial;
    color: #434343;
  }
  .links {
    padding: .25em 0em .25em 0em;
    background-color: #414141;
    margin: 0em 1em 0em 1em;
    border: 1px solid #414141;
    text-align: center;
  }
  .links ul {
    list-style-type: none;
    margin: 0;
  }
  .links li {
    margin: 0;
    font: bold 1em arial;
    padding: .25em 0em .25em 0em;
    display: inline;
  }
  .links li a:hover{
    text-decoration: underline;
  }
  .links li a {
    margin: 0;
    padding: .25em 2em .25em 2em;
    text-decoration: none;
    color: #EFEFEF;
    background-color: none;
  }
  .links li#active{
    text-decoration: none;
  }
  .host {
    margin: 0;
    background-color: #EFEFEF;
    padding: .25em;
    font: bold 1em arial;
    border-top: 1px solid #7C7C7C;
    border-bottom: 1px solid #7C7C7C;
    color: #434343;
  }
  .host_sub {
    margin: 0em 0em 0em 1em;
    padding: .25em;
    color: #434343;
    font: .75em arial;
  }
  .gen_sub {
    margin: 0em 1em 0em 1em;
    padding: 0;
    font: 1em arial;
    border: 1px solid #7C7C7C;
  }
  .in_sub {
    color: #434343;
    margin: 0em 0em 0em 0em;
    padding: .25em;
    font: .75em verdana;
  }
  .infotable {
    color: #434343;
    margin: .25em;
    padding: .25em;
    Vertical-align: top;
    font: 1em verdana;
  }
  .infotabledata {
    color: #434343;
    Vertical-align: top;
    font: 1em verdana;
  }
  .porttable {
    color: #434343;
    margin: .25em;
    padding: .25em;
    Vertical-align: top;
    font: 1em verdana;
    border: 1px solid #EFEFEF;
    border-collapse:collapse;
  }
  .porttableheader {
    padding: .25em .5em .25em .5em;
    background-color: #EFEFEF;
  }
  .porttablefooter {
    padding: .25em .5em .25em .5em;
    background-color: #EFEFEF;
    font: .75em verdana;
  }
  .portopen_row {
    border: 1px solid #FF9E9E;
    color: #434343;
    margin: .25em;
    padding: .25em;
    Vertical-align: top;
    font: 1em verdana;
  }
  .portnotopen_row {
    color: #434343;
    margin: .25em;
    padding: .25em;
    Vertical-align: top;
    font: 1em verdana;
  }
  .portopen {
    background-color: #FFDBDB;
    color: #434343;
    margin: .25em;
    padding: .25em .5em .25em .5em;
    Vertical-align: top;
    font: .75em courier;
  }
  .portnotopen {
    color: #434343;
    margin: .25em;
    padding: .25em .5em .25em .5em;
    Vertical-align: top;
    font: .75em courier;
  }
  .cmd {
    color: #434343;
    Vertical-align: top;
    font: 1em courier;
  }
  .online {
    color: #01680C;
    text-align: right;
    Vertical-align: top;
    font: bold 1em arial;
  }
  .offline {
    color: #830100;
    text-align: right;
    Vertical-align: top;
    font: bold 1em arial;
  }
  .copyright {
    padding: .5em;
    text-align: center;
    font: bold .5em verdana;
    color: #434343;
  }
</style>
<title>Nmap Scan Results - <xsl:value-of select="/nmaprun/runstats/finished/@timestr" /></title>
</head>

<body>
 <A NAME="top" />
 <DIV CLASS="title">
 Nmap Scan Results - <xsl:value-of select="/nmaprun/runstats/finished/@timestr" />
 </DIV>
 <UL CLASS="links">
  <LI><A HREF="#ScanInfo">Scan Information</A></LI>
  <LI><A HREF="#HostsScanned">Hosts Scanned</A></LI>
  <LI><A HREF="#ScanStats">Scan Stats</A></LI>
 </UL>
 <DIV CLASS="headerfooter">
 <A NAME="ScanInfo" />Scan Information <A HREF="#top">(Top)</A>
 </DIV>
 <DIV CLASS="gen_sub">
  <DIV CLASS="in_sub">
   <TABLE CLASS="infotable">
    <TR>
     <TD CLASS="infotabledata">Start:</TD><TD CLASS="cmd"><xsl:value-of select="@startstr" />
     </TD>
    </TR>
    <TR>
     <TD CLASS="infotabledata">End:</TD><TD CLASS="cmd"><xsl:value-of select="runstats/finished/@timestr" />
     </TD>
    </TR>
    <TR>
     <TD CLASS="infotabledata">Duration:</TD><TD CLASS="cmd"><xsl:value-of select="$totaltime" /> sec</TD>
    </TR>
    <TR>
     <TD CLASS="infotabledata">Command:</TD><TD CLASS="cmd"><xsl:value-of select="@args" /></TD>
    </TR>
    <TR>
     <TD CLASS="infotabledata">Debugging:</TD><TD CLASS="cmd">
      <xsl:choose>
       <xsl:when test="debugging/@level = '0'">Disabled</xsl:when>
       <xsl:otherwise>Enabled at level <xsl:value-of select="verbose/@level" /></xsl:otherwise>
      </xsl:choose>
     </TD>
    </TR>
    <TR>
     <TD CLASS="infotabledata">Scan Type:</TD><TD CLASS="cmd"><xsl:value-of select="/nmaprun/scaninfo/@type" />-scan</TD>
    </TR>
    <TR>
     <TD CLASS="infotabledata">Scanned:</TD><TD CLASS="cmd"><xsl:value-of select="/nmaprun/scaninfo/@numservices" /><xsl:text> </xsl:text><xsl:value-of select="/nmaprun/scaninfo/@protocol" /> services</TD>
    </TR>
   </TABLE>
  </DIV>
 </DIV>
 <DIV CLASS="headerfooter">
  <A NAME="HostsScanned" />Hosts Scanned  <A HREF="#top">(Top)</A>
 </DIV>
 <DIV CLASS="gen_sub">
 <xsl:apply-templates>
<xsl:sort select="substring ( address/@addr, 1, string-length ( substring-before ( address/@addr, '.' ) ) )* (256*256*256) + substring ( substring-after ( address/@addr, '.' ), 1, string-length ( substring-before ( substring-after ( address/@addr, '.' ), '.' ) ) )* (256*256) + substring ( substring-after ( substring-after ( address/@addr, '.' ), '.' ), 1, string-length ( substring-before ( substring-after ( substring-after ( address/@addr, '.' ), '.' ), '.' ) ) ) * 256 + substring ( substring-after ( substring-after ( substring-after ( address/@addr, '.' ), '.' ), '.' ), 1 )" order="ascending" data-type="number"/>
 </xsl:apply-templates>
 </DIV>
 <DIV CLASS="headerfooter">
 <A NAME="ScanStats" />Scan Stats  <A HREF="#top">(Top)</A>
 </DIV>
 <DIV CLASS="gen_sub">
  <DIV CLASS="in_sub">
   <TABLE CLASS="infotable">
    <TR>
     <TD CLASS="infotabledata">Hosts Scanned:</TD><TD CLASS="cmd"><xsl:value-of select="/nmaprun/runstats/hosts/@total" /></TD>
    </TR>
    <TR>
     <TD CLASS="infotabledata">Hosts Online:</TD><TD CLASS="cmd"><xsl:value-of select="/nmaprun/runstats/hosts/@up" /></TD>
    </TR>
    <TR>
     <TD CLASS="infotabledata">Hosts Offline:</TD><TD CLASS="cmd"><xsl:value-of select="/nmaprun/runstats/hosts/@down" /></TD>
    </TR>
   </TABLE>
  </DIV>
 </DIV>
 <UL CLASS="links">
  <LI><A HREF="#ScanInfo">Scan Information</A></LI>
  <LI><A HREF="#HostsScanned">Hosts Scanned</A></LI>
  <LI><A HREF="#ScanStats">Scan Stats</A></LI>
 </UL>
 <DIV CLASS="copyright"> 
 Copyright (c) 2004-2006 Benjamin Erb All rights reserved. Modified without the author's permission by Brad Geesaman Copyright (c) 2008.
 </DIV>
</body>
</html>
</xsl:template>



<!-- host -->
<!-- ............................................................ -->
<xsl:template match="host">
  <DIV CLASS="host">
    <xsl:value-of select="address/@addr"/>
     <xsl:if test="hostname/@name != ''"> - <xsl:value-of select="hostname/@name" /></xsl:if>
     <xsl:choose>
       <xsl:when test="status/@state = 'up'"> (<SPAN CLASS="online">Online</SPAN>)</xsl:when>
       <xsl:otherwise> (<SPAN CLASS="offline">Offline</SPAN>)</xsl:otherwise>
     </xsl:choose>
   </DIV>
   <DIV CLASS="host_sub">
   <xsl:apply-templates/>
   <TABLE CLASS="infotable">
   <xsl:if test="os/osmatch/@name != ''">
    <TR>
     <TD CLASS="infotabledata">OS Guess:</TD><TD CLASS="cmd">
       <xsl:for-each select="os/osmatch">
         <xsl:value-of select="@name" />,  
       </xsl:for-each>
     </TD>
    </TR>
   </xsl:if>
   <xsl:if test="uptime/@lastboot != ''">
    <TR>
     <TD CLASS="infotabledata">Up Since:</TD><TD CLASS="cmd">
       <xsl:value-of select="uptime/@lastboot" /></TD>
    </TR>
   </xsl:if>
   </TABLE>
   </DIV>
</xsl:template>
<!-- ............................................................ -->

<!-- ports -->
<!-- ............................................................ -->
<xsl:template match="ports">
  <TABLE CLASS="porttable">
    <TH CLASS="porttableheader" COLSPAN="2">Port</TH>
    <TH CLASS="porttableheader">State</TH>
    <TH CLASS="porttableheader">Service</TH>
    <TH CLASS="porttableheader">Product</TH>
    <TH CLASS="porttableheader">Version</TH>
    <TH CLASS="porttableheader">Additional Info</TH>
    <xsl:apply-templates/>
    <xsl:for-each select="extraports">
     <xsl:if test="@count > 0">
      <TH CLASS="porttablefooter" COLSPAN="7"><xsl:value-of select="@count" /> ports scanned but not shown below are in state: <xsl:value-of select="@state" /></TH>
     </xsl:if>
    </xsl:for-each>
  </TABLE>
</xsl:template>
<!-- ............................................................ -->

<!-- port -->
<!-- ............................................................ -->
<xsl:template match="port">
  <xsl:choose>
   <xsl:when test="state/@state = 'open'">
    <TR CLASS="portopen_row">
     <TD CLASS="portopen"><xsl:value-of select="@portid" /></TD>
     <TD CLASS="portopen"><xsl:value-of select="@protocol" /></TD>
     <TD CLASS="portopen"><xsl:value-of select="state/@state" /></TD>
     <TD CLASS="portopen"><xsl:value-of select="service/@name" /></TD>
     <TD CLASS="portopen"><xsl:value-of select="service/@product" /></TD>
     <TD CLASS="portopen"><xsl:value-of select="service/@version" /></TD>
     <TD CLASS="portopen"><xsl:value-of select="service/@extrainfo" /></TD>
    </TR>
   </xsl:when>
   <xsl:otherwise>
    <TR CLASS="portnotopen_row">
     <TD CLASS="portnotopen"><xsl:value-of select="@portid" /></TD>
     <TD CLASS="portnotopen"><xsl:value-of select="@protocol" /></TD>
     <TD CLASS="portnotopen"><xsl:value-of select="state/@state" /></TD>
     <TD CLASS="portnotopen"><xsl:value-of select="service/@name" /></TD>
     <TD CLASS="portnotopen"><xsl:value-of select="service/@product" /></TD>
     <TD CLASS="portnotopen"><xsl:value-of select="service/@version" /></TD>
     <TD CLASS="portnotopen"><xsl:value-of select="service/@extrainfo" /></TD>
    </TR>
   </xsl:otherwise>
  </xsl:choose>
</xsl:template>
<!-- ............................................................ -->

</xsl:stylesheet>
