#!/usr/bin/perl -w

#####################################################################################
# All information, data, source code, compiled binaries, information, documentation #
# contained within this document is the sole property of "WhiteHat Security, Inc"   #     
# and may not be sold, reused or distributed.                                       #
# Copyright 2002 WhiteHat Security, Inc.                                            #
#####################################################################################

use strict;
use XML::Simple;
require "./Subs.pm";



### Global Variables ###############################################################
my $Debug = 0;			# Debug Variable (0 = OFF | 1 = ON)
$|++;				# Flush Output	

# WHArsenal Directories
my $doc_root = $ENV{'DOCUMENT_ROOT'} || "/home/apache/htdocs";	# Document Root Directory
my $session_dir = $doc_root . "/" . "wharsenal/sessions/";	# Session Directory

####################################################################################

### MAIN ###########################################################################
print "Content-Type: text/html\n\n";

# Start HTML 

print <<EOF;
<HTML>
<HEAD>

<TITLE>WhiteHat Arsenal 1.07 Beta Menubar</TITLE>

<script type="text/javascript" language="JavaScript" src="/wharsenal/scripts/encode_encrypt.js"></script>
<script type="text/javascript" language="JavaScript" src="/wharsenal/scripts/Convert.js"></script>


<SCRIPT TYPE="text/javascript">
<!--

function Save(TheAction) { // Store Conversion Action
	document.SaveIt.Action.value = TheAction;
} // End SubRoutine


//-->
</SCRIPT>


<!-- Top Left Corner Map -->
<MAP NAME="topleftcorner">
  <AREA SHAPE="RECT" COORDS="11,6,40,26" HREF="http://www.whitehatsec.com" TARGET="_BLANK">
  <AREA SHAPE="RECT" COORDS="41,6,105,34" HREF="http://community.whitehatsec.com/index.pl?section=wharsenal" TARGET="_BLANK">
  <AREA SHAPE="RECT" COORDS="17,43,99,56" HREF="/cgi-bin/wharsenalcgi/session.pl" TARGET="body">
</MAP>
<!-- End Top Left Corner Map -->

<!-- DAU Map -->
<MAP NAME="dau">
  <AREA SHAPE="RECT" COORDS="17,27,102,38" HREF="/wharsenal/html/future_release.html" TARGET="body">
  <AREA SHAPE="RECT" COORDS="17,41,101,50" HREF="/wharsenal/html/forcedbrowse.html" TARGET="body">
  <AREA SHAPE="RECT" COORDS="16,54,103,65" HREF="/wharsenal/html/code_snippets.html" TARGET="body">
  <AREA SHAPE="RECT" COORDS="16,89,103,100" HREF="/wharsenal/html/future_release.html" TARGET="body">
  <AREA SHAPE="RECT" COORDS="17,103,103,115" HREF="/wharsenal/html/future_release.html" TARGET="body">
  <AREA SHAPE="RECT" COORDS="17,122,103,152" HREF="/wharsenal/html/string.html" TARGET="body">
</MAP>
<!-- End DAU Map -->

<!-- Bottom Edge Map -->
<MAP NAME="bottomedge">
  <AREA SHAPE="RECT" COORDS="17,111,101,132" HREF="http://www.wiretrip.net" TARGET="_BLANK">
  <AREA SHAPE="RECT" COORDS="16,25,106,38" HREF="http://community.whitehatsec.com/Arsenal/bugs.html" TARGET="body">
  <AREA SHAPE="RECT" COORDS="15,41,103,51" HREF="http://community.whitehatsec.com/Arsenal/feedback.html" TARGET="body">
  <AREA SHAPE="RECT" COORDS="16,54,104,66" HREF="http://community.whitehatsec.com" TARGET="_BLANK">
  <AREA SHAPE="RECT" COORDS="17,68,102,80" HREF="/wharsenal/html/future_release.html" TARGET="body">
  <AREA SHAPE="RECT" COORDS="18,83,105,94" HREF="/wharsenal/html/body.html" TARGET="body">
  <AREA SHAPE="RECT" COORDS="17,1,106,19" HREF="http://www.whitehatsec.com" TARGET="_BLANK">
</MAP>
<!-- End Bottom Edge Map -->
</HEAD>

<BODY BGCOLOR="#7B92AD" BACKGROUND="/wharsenal/images/menubg.jpg" BGCOLOR="FFFFFF" LINK="FF3300" VLINK="3300FF">


<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">

<TR>
<TD HEIGHT="62" WIDTH="127" ALIGN="LEFT" VALIGN="MIDDLE"><IMG SRC="/wharsenal/images/topleftcorner.jpg" HEIGHT="62" WIDTH="127" BORDER="0" USEMAP="#topleftcorner"></TD>
</TR>


<FORM NAME="SESSIONS">
<TR>
<TD ALIGN="LEFT" VALIGN="MIDDLE">

	<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0"><TR>
		<TD WIDTH="17" ALIGN="LEFT" VALIGN="MIDDLE"><IMG SRC="/wharsenal/images/leftbar.jpg" HEIGHT="21" WIDTH="17" BORDER="0"></TD>

		<TD WIDTH="88" ALIGN="LEFT" VALIGN="MIDDLE">
EOF
listSessionMenu();
print <<EOF;
		</TD>

		<TD WIDTH="28" ALIGN="LEFT" VALIGN="MIDDLE"><IMG SRC="/wharsenal/images/rightbar.jpg" HEIGHT="21" WIDTH="28" BORDER="0"></TD>
	</TR></TABLE>



</TD>
</TR>
</FORM>


<TR>
<TD HEIGHT="153" WIDTH="135" ALIGN="LEFT" VALIGN="MIDDLE"><IMG SRC="/wharsenal/images/dau.jpg" HEIGHT="153" WIDTH="135" BORDER="0" USEMAP="#dau"></TD>
</TR>



<FORM NAME="EncodeForm">
<TR>
<TD ALIGN="LEFT" VALIGN="MIDDLE">

	<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0"><TR>
		<TD WIDTH="17" ALIGN="LEFT" VALIGN="MIDDLE"><IMG SRC="/wharsenal/images/leftbar.jpg" HEIGHT="21" WIDTH="17" BORDER="0"></TD>

		<TD WIDTH="88" ALIGN="LEFT" VALIGN="MIDDLE">
		<SELECT NAME="Encoding" OnChange="document.SaveIt.Action.value=this.value;" style="WIDTH: 83px; font-size: 9px; font-family:verdana, arial,sans-serif" BORDER=0>
		<OPTION>-</OPTION>
		<OPTION VALUE="URLENCODE">URLEncode</OPTION>
		<OPTION VALUE="URLDECODE">URLDecode</OPTION>
		<OPTION VALUE="BASE64ENCODE">Base 64 Encode</OPTION>
		<OPTION VALUE="BASE64DECODE">Base 64 Decode</OPTION>
		<OPTION VALUE="MD4">MD4</OPTION>
		<OPTION VALUE="MD5">MD5</OPTION>
		<OPTION VALUE="SHA1">SHA-1</OPTION>
		<OPTION VALUE="ROT13">ROT 13</OPTION>
		</SELECT>
		</TD>

		<TD WIDTH="28" ALIGN="LEFT" VALIGN="MIDDLE"><IMG SRC="/wharsenal/images/rightbar.jpg" HEIGHT="21" WIDTH="28" BORDER="0"></TD>
	</TR></TABLE>



</TD>
</TR>

</FORM>


<TR>
<TD HEIGHT="153" WIDTH="135" ALIGN="LEFT" VALIGN="MIDDLE"><IMG SRC="/wharsenal/images/bottomedge.jpg" HEIGHT="153" WIDTH="135" BORDER="0" USEMAP="#bottomedge"></TD>
</TR>


</TABLE>

<FORM NAME="SaveIt">
<INPUT TYPE=HIDDEN NAME="Action" VALUE="">
</FORM>


EOF

print "</BODY></HTML>\n"; # End HTML

####################################################################################

### Sub Routines ###################################################################

			

##########################
### List Sessions Menu ###
##########################
# List out existing sessions in HTML pull-down menu
sub listSessionMenu {
	my $sname = shift || "";
	my %sessions; # Create Session Array

	# Load in Session files and information
	print "Session Directory: $session_dir\n" if ($Debug == 1);
	opendir(DIR, "$session_dir") || die "can't opendir $session_dir: $!"; # Open Session Directory
	print "OPEN DIR: $session_dir<BR>\n" if ($Debug == 1);
	my @session_list = readdir(DIR); # Read in a store session names
	closedir(DIR); # Close Session Directory

	my $description_path = "";	# Description Path
	my $description = "";		# Description String
	print "<SELECT NAME=\"SESSION\" style=\"WIDTH: 83px; font-size: 9px; font-family:verdana, arial,sans-serif\">\n";
	
		
	foreach my $lin (@session_list) { # Step thru session names
		print "LIST: $lin<BR>\n" if ($Debug == 1);
		my $s_dir = $session_dir . "/" . $lin;
		unless (($lin =~ /(^\.)/) || (!-d $s_dir)) { # Ignore Hidden Files
			print "Session: $lin<BR>\n" if ($Debug == 1); # Print Session Name
			if ($sname ne "") {
				if ($lin eq $sname) {
					print "<OPTION VALUE=\"$lin\" SELECTED>$lin</OPTION>\n";
				} else {
					print "<OPTION VALUE=\"$lin\">$lin</OPTION>\n";
				}
			} else {
				print "<OPTION VALUE=\"$lin\">$lin</OPTION>\n";
			}
		} # End Unless
	} # End Foreach
	
	print "</SELECT>\n";
	
} # End List Session Menu Subroutine


