summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-07-24 11:29:03 -0500
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-07-24 11:29:03 -0500
commit066bae76e94c21604fe4132c4ca26e5b2f0c6375 (patch)
tree64cd6638d6f513ef8ddb094f9437467c0a810d86 /src
downloadknmap-066bae76e94c21604fe4132c4ca26e5b2f0c6375.tar.gz
knmap-066bae76e94c21604fe4132c4ca26e5b2f0c6375.zip
Initial import of knmap 2.1 sources
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am46
-rw-r--r--src/commonwidget.cpp655
-rw-r--r--src/commonwidget.h140
-rw-r--r--src/compoundwidget.cpp682
-rw-r--r--src/compoundwidget.h192
-rw-r--r--src/global.h60
-rw-r--r--src/hi16-app-knmap.pngbin0 -> 750 bytes
-rw-r--r--src/hi16-app-knmapman.pngbin0 -> 641 bytes
-rw-r--r--src/hi16-app-localman.pngbin0 -> 640 bytes
-rw-r--r--src/hi16-app-manpage.pngbin0 -> 649 bytes
-rw-r--r--src/hi16-app-manstylesheet.pngbin0 -> 539 bytes
-rw-r--r--src/hi16-app-profilecopy.pngbin0 -> 537 bytes
-rw-r--r--src/hi16-app-profiledelete.pngbin0 -> 541 bytes
-rw-r--r--src/hi16-app-profileload.pngbin0 -> 705 bytes
-rw-r--r--src/hi16-app-profilerename.pngbin0 -> 755 bytes
-rw-r--r--src/hi16-app-profilesave.pngbin0 -> 617 bytes
-rw-r--r--src/hi16-app-profilesaveas.pngbin0 -> 664 bytes
-rw-r--r--src/hi16-app-scanclose.pngbin0 -> 577 bytes
-rw-r--r--src/hi16-app-scanduplicate.pngbin0 -> 532 bytes
-rw-r--r--src/hi16-app-scannew.pngbin0 -> 395 bytes
-rw-r--r--src/hi16-app-scanrename.pngbin0 -> 647 bytes
-rw-r--r--src/hi16-app-zoomcustom.pngbin0 -> 705 bytes
-rw-r--r--src/hi16-app-zoomin.pngbin0 -> 794 bytes
-rw-r--r--src/hi16-app-zoomout.pngbin0 -> 748 bytes
-rw-r--r--src/hi32-app-knmap.pngbin0 -> 1775 bytes
-rw-r--r--src/hi32-app-knmapman.pngbin0 -> 1424 bytes
-rw-r--r--src/hi32-app-localman.pngbin0 -> 1439 bytes
-rw-r--r--src/hi32-app-manpage.pngbin0 -> 1123 bytes
-rw-r--r--src/hi32-app-manstylesheet.pngbin0 -> 1084 bytes
-rw-r--r--src/hi32-app-profilecopy.pngbin0 -> 881 bytes
-rw-r--r--src/hi32-app-profiledelete.pngbin0 -> 1076 bytes
-rw-r--r--src/hi32-app-profileload.pngbin0 -> 1510 bytes
-rw-r--r--src/hi32-app-profilerename.pngbin0 -> 1633 bytes
-rw-r--r--src/hi32-app-profilesave.pngbin0 -> 1536 bytes
-rw-r--r--src/hi32-app-profilesaveas.pngbin0 -> 1553 bytes
-rw-r--r--src/hi32-app-scanclose.pngbin0 -> 1115 bytes
-rw-r--r--src/hi32-app-scanduplicate.pngbin0 -> 820 bytes
-rw-r--r--src/hi32-app-scannew.pngbin0 -> 620 bytes
-rw-r--r--src/hi32-app-scanrename.pngbin0 -> 1368 bytes
-rw-r--r--src/hi32-app-zoomcustom.pngbin0 -> 1659 bytes
-rw-r--r--src/hi32-app-zoomin.pngbin0 -> 1895 bytes
-rw-r--r--src/hi32-app-zoomout.pngbin0 -> 1776 bytes
-rw-r--r--src/htmlwidget.cpp366
-rw-r--r--src/htmlwidget.h95
-rw-r--r--src/indexwidget.cpp273
-rw-r--r--src/indexwidget.h75
-rw-r--r--src/knmap.cpp405
-rw-r--r--src/knmap.desktop42
-rw-r--r--src/knmap.h81
-rw-r--r--src/knmapui.rc38
-rw-r--r--src/loggingoptions.cpp460
-rw-r--r--src/loggingoptions.h141
-rw-r--r--src/main.cpp78
-rw-r--r--src/mainwidget.cpp463
-rw-r--r--src/mainwidget.h111
-rw-r--r--src/nmap_manpage.html1176
-rw-r--r--src/nmap_manpage.html.diff557
-rw-r--r--src/nmapoutputbuffer.cpp41
-rw-r--r--src/nmapoutputbuffer.h50
-rw-r--r--src/outputwidget.cpp174
-rw-r--r--src/outputwidget.h79
-rw-r--r--src/pandsoptions.cpp415
-rw-r--r--src/pandsoptions.h153
-rw-r--r--src/profiledialog.cpp325
-rw-r--r--src/profiledialog.h90
-rw-r--r--src/scanmonitor.cpp139
-rw-r--r--src/scanmonitor.h68
-rw-r--r--src/scanmonitorevent.cpp32
-rw-r--r--src/scanmonitorevent.h42
-rw-r--r--src/scannamedialog.cpp102
-rw-r--r--src/scannamedialog.h65
-rw-r--r--src/scanstack.cpp194
-rw-r--r--src/scanstack.h76
-rw-r--r--src/scanwidget.cpp1061
-rw-r--r--src/scanwidget.h172
-rw-r--r--src/simpleoptions.cpp247
-rw-r--r--src/simpleoptions.h113
-rw-r--r--src/stylesheetdialog.cpp128
-rw-r--r--src/stylesheetdialog.h70
-rw-r--r--src/tabwidgetdata.cpp39
-rw-r--r--src/tabwidgetdata.h49
-rw-r--r--src/tabwidgetptrlist.cpp47
-rw-r--r--src/tabwidgetptrlist.h49
-rw-r--r--src/timingwidget.cpp664
-rw-r--r--src/timingwidget.h190
-rw-r--r--src/whatsthis.cpp42
-rw-r--r--src/whatsthis.h53
87 files changed, 11105 insertions, 0 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644
index 0000000..6a38c98
--- /dev/null
+++ b/src/Makefile.am
@@ -0,0 +1,46 @@
+# set the include path for X, qt and KDE
+INCLUDES = $(all_includes)
+
+# these are the headers for your project
+noinst_HEADERS = knmap.h global.h mainwidget.h outputwidget.h commonwidget.h \
+ timingwidget.h compoundwidget.h htmlwidget.h stylesheetdialog.h profiledialog.h \
+ loggingoptions.h simpleoptions.h pandsoptions.h whatsthis.h tabwidgetptrlist.h \
+ tabwidgetdata.h scanwidget.h indexwidget.h scannamedialog.h scanstack.h scanmonitor.h \
+ scanmonitorevent.h nmapoutputbuffer.h
+
+# let automoc handle all of the meta source files (moc)
+METASOURCES = AUTO
+
+messages: rc.cpp
+ $(EXTRACTRC) `find . -name \*.ui -o -name \*.rc` > rc.cpp
+ $(XGETTEXT) *.cpp -o $(podir)/knmap.pot
+
+KDE_ICON = AUTO
+
+#########################################################################
+# APPLICATION SECTION
+#########################################################################
+# this is the program that gets installed. it's name is used for all
+# of the other Makefile.am variables
+bin_PROGRAMS = knmap
+
+# the application source, library search path, and link libraries
+knmap_SOURCES = main.cpp knmap.cpp mainwidget.cpp outputwidget.cpp \
+ commonwidget.cpp timingwidget.cpp compoundwidget.cpp htmlwidget.cpp stylesheetdialog.cpp \
+ profiledialog.cpp loggingoptions.cpp simpleoptions.cpp pandsoptions.cpp whatsthis.cpp \
+ tabwidgetptrlist.cpp tabwidgetdata.cpp scanwidget.cpp indexwidget.cpp scannamedialog.cpp \
+ scanstack.cpp scanmonitor.cpp scanmonitorevent.cpp nmapoutputbuffer.cpp
+knmap_LDFLAGS = $(KDE_RPATH) $(all_libraries)
+knmap_LDADD = $(LIB_KIO) $(LIB_KHTML)
+
+# this is where the desktop file will go
+shelldesktopdir = $(kde_appsdir)/Utilities
+shelldesktop_DATA = knmap.desktop
+
+# this is where the shell's XML-GUI resource file goes
+shellrcdir = $(kde_datadir)/knmap
+shellrc_DATA = knmapui.rc nmap_manpage.html nmap_manpage.html.diff
+
+kde_icon_KDEICON = hi16-app-scanclose.png hi32-app-scanclose.png \
+ hi16-app-scannew.png hi32-app-scannew.png hi16-app-scanrename.png hi32-app-scanrename.png \
+ hi16-app-scanduplicate.png hi32-app-scanduplicate.png hi16-app-manpage.png hi32-app-manpage.png
diff --git a/src/commonwidget.cpp b/src/commonwidget.cpp
new file mode 100644
index 0000000..e9dbe12
--- /dev/null
+++ b/src/commonwidget.cpp
@@ -0,0 +1,655 @@
+/***************************************************************************
+ * *
+ * Copyright (C) 2005, 2006 by Kevin Gilbert *
+ * kev.gilbert@cdu.edu.au *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ * *
+ ***************************************************************************/
+
+#include <qbuttongroup.h>
+#include <qcheckbox.h>
+#include <qcombobox.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qlineedit.h>
+#include <qlistbox.h>
+#include <qpushbutton.h>
+#include <qradiobutton.h>
+#include <qstringlist.h>
+#include <qvalidator.h>
+
+#include <kconfig.h>
+#include <kdebug.h>
+#include <kglobal.h>
+#include <kiconloader.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+
+#include "commonwidget.h"
+#include "whatsthis.h"
+
+// constructor
+// ===========
+
+CommonWidget::CommonWidget( QWidget* parent, const char* name )
+: QWidget( parent, name ),
+ m_hosts( NULL ),
+ m_portRangeIgnoreChange( false ),
+ m_portRanges( NULL )
+{ createLayout( );
+ m_portRangeAddButton->setEnabled( false );
+ m_portRangeDeleteButton->setEnabled( false );
+}
+
+// destructor
+// ==========
+
+CommonWidget::~CommonWidget( )
+{ if( m_hosts != NULL )
+ delete m_hosts;
+
+ if( m_portRanges != NULL )
+ delete m_portRanges;
+}
+
+// buildPortRangesTables
+// =====================
+
+bool CommonWidget::buildPortRangesTables( const boolPtr tcpPorts, const boolPtr udpPorts )
+{ memset( tcpPorts, 0, 64 * 1024 );
+ memset( udpPorts, 0, 64 * 1024 );
+
+ QStringList portRanges;
+ getPortRanges( &portRanges );
+
+ for( QStringList::Iterator it = portRanges.begin( ); it != portRanges.end( ); ++it )
+ { QString portRange = *it;
+ bool tcp = false;
+ bool udp = false;
+
+ if( portRange[ 0 ].isDigit( ))
+ { tcp = true;
+ udp = true;
+ }
+ else
+ if( portRange[ 0 ].lower( ) == 't' )
+ { tcp = true;
+ portRange = portRange.right( portRange.length( ) - 2 );
+ }
+ else
+ if( portRange[ 0 ].lower( ) == 'u' )
+ { udp = true;
+ portRange = portRange.right( portRange.length( ) - 2 );
+ }
+ else
+ { KMessageBox::error( this, i18n( QString( "Internal error - Unknown Port Range protocol '%1'" ).arg( portRange[ 0 ])), i18n( "Internal error" ));
+ return false;
+ }
+
+ QStringList ports = QStringList::split( "-", portRange );
+
+ if( ports.count( ) > 2 )
+ { KMessageBox::error( this, i18n( "Internal error - Illegal Port Range encountered" ), i18n( "Internal error" ));
+ return false;
+ }
+
+ ushort portFirst = ports.front( ).toUShort( );
+ ushort portLast = portFirst;
+
+ if( ports.count( ) > 1 )
+ portLast = ports.back( ).toUShort( );
+
+ for( uint port = portFirst; port <= portLast; port++ )
+ { if( tcp )
+ tcpPorts[ port ] = true;
+
+ if( udp )
+ udpPorts[ port ] = true;
+ }
+ }
+
+ return true;
+}
+
+// createLayout
+// ============
+
+void CommonWidget::createLayout( )
+{ QGridLayout* gridLayout = new QGridLayout( this );
+ KIconLoader* iconLoader = KGlobal::iconLoader( );
+ QIconSet clearRightIconSet = iconLoader->loadIconSet( "locationbar_erase", KIcon::Small );
+
+ byte row = 1;
+ m_hostButton = new QPushButton( clearRightIconSet, NULL, this, "host button" );
+ m_hostComboBox = new QComboBox( true, this, "target hosts combobox" );
+ QHBoxLayout* hostLayout = new QHBoxLayout( );
+
+ byte col = 0;
+ hostLayout->insertStretch( col++, 0 );
+ hostLayout->insertWidget( col++, new QLabel( i18n( "Target host(s)" ), this, "target hosts label" ), 0 );
+ hostLayout->insertStretch( col++, 1 );
+ hostLayout->insertWidget( col++, m_hostButton, 0 );
+ hostLayout->insertStretch( col++, 1 );
+ hostLayout->insertWidget( col++, m_hostComboBox, 100 );
+ hostLayout->insertStretch( col++, 0 );
+ gridLayout->addMultiCellLayout( hostLayout, row, row, 1, 5 );
+
+ QButtonGroup* resloveGroup = new QButtonGroup( 3, Qt::Vertical, i18n( "Resolve names" ), this, "resolve names group" );
+ m_resovleDefaultRadio = new QRadioButton( i18n( "Default" ), resloveGroup, "default resolve radio" );
+ m_resovleAlwaysRadio = new QRadioButton( i18n( "Always (-R)" ), resloveGroup, "always resolve radio" );
+ m_resovleNeverRadio = new QRadioButton( i18n( "Never (-n)" ), resloveGroup, "never resolve radio" );
+
+ row = 4;
+ gridLayout->addMultiCellWidget( resloveGroup, row, row + 3, 1, 1 );
+ byte rowBlock1 = ++row;
+
+ m_portRangeAddButton = new QPushButton( i18n( "Add" ), this, "add port range button" );
+ m_portRangeDeleteButton = new QPushButton( i18n( "Delete" ), this, "delete port range button" );
+ m_portRangeComboBox = new QComboBox( this, "port range combobox" );
+ m_portRangeLineEdit = new QLineEdit( this, "port range line edit" );
+ m_portRangeListBox = new QListBox( this, "port range listbox" );
+ m_portRangesCheckBox = new QCheckBox( i18n( "Port ranges (-p <port ranges>)" ), this, "port ranges checkbox" );
+
+ m_portRangeComboBox->insertItem( i18n( "Both" ), BothProtocol );
+ m_portRangeComboBox->insertItem( i18n( "TCP" ), TCPProtocol );
+ m_portRangeComboBox->insertItem( i18n( "UDP" ), UDPProtocol );
+
+ m_portRangeLineEdit->setValidator( new QRegExpValidator( QRegExp( "^\\d{1,5}-{1}\\d{1,5}$" ), this, "port range regx" ));
+
+ row = 3;
+ gridLayout->addMultiCellWidget( m_portRangesCheckBox, row, row, 3, 5, Qt::AlignCenter );
+ row++;
+
+ m_portRangeButton = new QPushButton( clearRightIconSet, NULL, this, "host button" );
+ QHBoxLayout* portRangeLayout = new QHBoxLayout( );
+
+ col = 0;
+ portRangeLayout->insertStretch( col++, 0 );
+ portRangeLayout->insertWidget( col++, new QLabel( i18n( "New range data: " ), this, "new range data label" ), 0 );
+ portRangeLayout->insertStretch( col++, 1 );
+ portRangeLayout->insertWidget( col++, m_portRangeButton, 0 );
+ portRangeLayout->insertStretch( col++, 1 );
+ portRangeLayout->insertWidget( col++, m_portRangeLineEdit, 100 );
+ portRangeLayout->insertStretch( col++, 0 );
+ gridLayout->addMultiCellLayout( portRangeLayout, row, row, 3, 5 );
+
+ gridLayout->addWidget( new QLabel( i18n( "Protocol" ), this, "protocol label" ), row + 1, 3 );
+ gridLayout->addWidget( m_portRangeComboBox, row + 2, 3 );
+ gridLayout->addWidget( m_portRangeAddButton, row + 4, 3 );
+ gridLayout->addWidget( m_portRangeDeleteButton, row + 5, 3 );
+ byte rowBlock2 = _max_( row + 5, rowBlock1 );
+ gridLayout->addMultiCellWidget( m_portRangeListBox, row + 1, rowBlock2, 5, 5 );
+
+ gridLayout->setColStretch( 0, 4 );
+ gridLayout->setColStretch( 2, 2 );
+ gridLayout->setColStretch( 5, 10 );
+ gridLayout->setColStretch( 6, 4 );
+
+ gridLayout->setRowStretch( 0, 10 );
+ gridLayout->setRowStretch( 2, 10 );
+ gridLayout->setRowStretch( rowBlock2 + 1, 10 );
+}
+
+// enablePortRangeWidgets
+// ======================
+
+void CommonWidget::enablePortRangeWidgets( )
+{ bool portRangesState = m_portRangesCheckBox->isChecked( );
+
+ m_portRangeAddButton->setEnabled( false );
+ m_portRangeDeleteButton->setEnabled( false );
+ m_portRangeButton->setEnabled( portRangesState );
+ m_portRangeLineEdit->setEnabled( portRangesState );
+ m_portRangeLineEdit->clear( );
+ m_portRangeComboBox->setEnabled( portRangesState );
+ m_portRangeListBox->setEnabled( portRangesState );
+
+ if( portRangesState )
+ emit( disableFastScan( ));
+}
+
+// finaliseInitialisation
+// ======================
+
+void CommonWidget::finaliseInitialisation( )
+{ WhatsThis* whatsThis = new WhatsThis( this );
+
+ connect( m_hostButton, SIGNAL( clicked( )), SLOT( slotHostButtonClicked( )));
+ connect( m_hostComboBox, SIGNAL( activated( int )), SLOT( slotHostActivated( int )));
+ connect( m_hostComboBox, SIGNAL( textChanged( const QString& )), SLOT( slotHostTextChanged( const QString& )));
+ connect( m_portRangeAddButton, SIGNAL( clicked( )), SLOT( slotPortRangeAddClicked( )));
+ connect( m_portRangeButton, SIGNAL( clicked( )), SLOT( slotPortRangeButtonClicked( )));
+ connect( m_portRangeDeleteButton, SIGNAL( clicked( )), SLOT( slotPortRangeDeleteClicked( )));
+ connect( m_portRangeComboBox, SIGNAL( activated( int )), SLOT( slotPortRangeActivated( int )));
+ connect( m_portRangeLineEdit, SIGNAL( textChanged( const QString& )), SLOT( slotPortRangeTextChanged( const QString& )));
+ connect( m_portRangeListBox, SIGNAL( doubleClicked( QListBoxItem* )), SLOT( slotPortRangeDoubleClicked( QListBoxItem* )));
+ connect( m_portRangeListBox, SIGNAL( highlighted( int )), SLOT( slotPortRangeHighlighted( )));
+ connect( m_portRangesCheckBox, SIGNAL( clicked( )), SLOT( slotPortRangesClicked( )));
+ connect( whatsThis, SIGNAL( clicked( )), SLOT( slotWhatsThisClicked( )));
+
+ connect( m_hostButton, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_hostComboBox, SIGNAL( activated ( int )), SIGNAL( optionsDirty( )));
+ connect( m_hostComboBox, SIGNAL( textChanged( const QString& )), SIGNAL( optionsDirty( )));
+ connect( m_portRangeAddButton, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_portRangeButton, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_portRangeComboBox, SIGNAL( activated( int )), SIGNAL( optionsDirty( )));
+ connect( m_portRangeDeleteButton, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_portRangeLineEdit, SIGNAL( textChanged( const QString& )), SIGNAL( optionsDirty( )));
+ connect( m_portRangeListBox, SIGNAL( doubleClicked( QListBoxItem* )), SIGNAL( optionsDirty( )));
+ connect( m_portRangeListBox, SIGNAL( highlighted ( int )), SIGNAL( optionsDirty( )));
+ connect( m_portRangesCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_resovleAlwaysRadio, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_resovleDefaultRadio, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_resovleNeverRadio, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+
+ emit( targetChanged( m_hostComboBox->currentText( )));
+}
+QString CommonWidget::getHostName( ) const
+{ return m_hostComboBox->currentText( );
+}
+
+// getHosts
+// ========
+
+void CommonWidget::getHosts( QStringList* hosts )
+{ hosts->clear( );
+
+ for( ushort i = 0; i < m_hostComboBox->count( ); i++ )
+ hosts->append( m_hostComboBox->text( i ));
+}
+
+// getOptions
+// ==========
+
+bool CommonWidget::getOptions( )
+{ QStringList portRanges;
+ getPortRanges( &portRanges );
+
+ bool portRangesState = m_portRangesCheckBox->isChecked( );
+
+ if( portRangesState && portRanges.isEmpty( ))
+ { KMessageBox::error( this, i18n( QString( "Port ranges not specified" )), i18n( "Port ranges error" ));
+ return false;
+ }
+
+ m_host = m_hostComboBox->currentText( );
+ m_hostCurrentItem = m_hostComboBox->currentItem( );
+ m_portRangeCurrentItem = m_portRangeComboBox->currentItem( );
+ m_portRangesState = portRangesState;
+ m_resovleAlwaysState = m_resovleAlwaysRadio->isChecked( );
+ m_resovleDefaultState = m_resovleDefaultRadio->isChecked( );
+ m_resovleNeverState = m_resovleNeverRadio->isChecked( );
+
+ if( m_portRanges != NULL )
+ delete m_portRanges;
+
+ m_portRanges = new QStringList( portRanges );
+ getHosts( m_hosts );
+
+ disconnect( m_hostComboBox, SIGNAL( activated( int )), this, SLOT( slotHostActivated( int )));
+ disconnect( m_hostComboBox, SIGNAL( textChanged( const QString& )), this, SLOT( slotHostTextChanged( const QString& )));
+
+ disconnect( m_hostComboBox, SIGNAL( activated ( int )), this, SIGNAL( optionsDirty( )));
+ disconnect( m_hostComboBox, SIGNAL( textChanged( const QString& )), this, SIGNAL( optionsDirty( )));
+
+ byte i;
+ QStringList::Iterator it;
+
+ for( i = 0, it = m_hosts->begin( ); it != m_hosts->end( ); i++, ++it )
+ if( *it == m_host )
+ break;
+
+ if( it != m_hosts->end( ))
+ { m_hostComboBox->removeItem( i );
+ m_hosts->remove( it );
+ }
+ else
+ while( m_hostComboBox->count( ) > MAX_HOST_HISTORY - 1 )
+ { m_hostComboBox->removeItem( MAX_HOST_HISTORY - 1 );
+ m_hosts->pop_back( );
+ }
+
+ m_hostComboBox->insertItem( m_host, 0 );
+ m_hostComboBox->setCurrentItem( 0 );
+ m_hosts->prepend( m_host );
+
+ connect( m_hostComboBox, SIGNAL( activated( int )), SLOT( slotHostActivated( int )));
+ connect( m_hostComboBox, SIGNAL( textChanged( const QString& )), SLOT( slotHostTextChanged( const QString& )));
+
+ connect( m_hostComboBox, SIGNAL( activated ( int )), SIGNAL( optionsDirty( )));
+ connect( m_hostComboBox, SIGNAL( textChanged( const QString& )), SIGNAL( optionsDirty( )));
+
+ return true;
+}
+
+// getPortRanges
+// =============
+
+void CommonWidget::getPortRanges( QStringList* portRanges )
+{ portRanges->clear( );
+
+ for( ushort i = 0; i < m_portRangeListBox->count( ); i++ )
+ portRanges->append( m_portRangeListBox->text( i ));
+}
+
+// portRangesOverlapping
+// =====================
+
+bool CommonWidget::portRangesOverlapping( const ushort portFirst, const ushort portLast )
+{ boolPtr tcpPorts = new bool[ 64 * 1024 ];
+ boolPtr udpPorts = new bool[ 64 * 1024 ];
+
+ if( !buildPortRangesTables( tcpPorts, udpPorts ))
+ { delete [] tcpPorts;
+ delete [] udpPorts;
+ return false;
+ }
+
+ bool tcp = false;
+ bool udp = false;
+
+ switch( m_portRangeComboBox->currentItem( ))
+ { case 0: tcp = udp = true; break;
+ case 1: tcp = true; break;
+ case 2: udp = true; break;
+
+ default:
+ kdDebug( ) << i18n( "unknown value in Port Range Protocol combo box" ) << endl;
+ ASSERT( false );
+ delete [] tcpPorts;
+ delete [] udpPorts;
+ return false;
+ }
+
+ uint port;
+ QString protocol;
+
+ for( port = portFirst; port <= portLast; port++ )
+ { if( tcp && tcpPorts[ port ])
+ { protocol = "TCP";
+ break;
+ }
+
+ if( udp && udpPorts[ port ])
+ { protocol = "UDP";
+ break;
+ }
+ }
+
+ if( port <= portLast )
+ { KMessageBox::sorry( this, i18n( "Overlapping Port Range - %1 port %2" ).arg( protocol ).arg( QString::number( port )), i18n( "Overlapping Port Range" ));
+ delete [] tcpPorts;
+ delete [] udpPorts;
+ return false;
+ }
+
+ delete [] tcpPorts;
+ delete [] udpPorts;
+ return true;
+}
+
+// readProfile
+// ===========
+
+void CommonWidget::readProfile( KConfig* config )
+{ m_hostCurrentItem = config->readNumEntry( "hostCurrentItem" );
+ m_portRangeCurrentItem = config->readNumEntry( "portRangeCurrentItem" );
+ m_portRangesState = config->readBoolEntry( "portRangesState" );
+ m_resovleAlwaysState = config->readBoolEntry( "resovleAlwaysState" );
+ m_resovleDefaultState = config->readBoolEntry( "resovleDefaultState" );
+ m_resovleNeverState = config->readBoolEntry( "resovleNeverState" );
+
+ m_hosts = new QStringList( config->readListEntry( "hosts" ));
+ m_portRanges = new QStringList( config->readListEntry( "portRanges" ));
+}
+
+// saveProfile
+// ===========
+
+void CommonWidget::saveProfile( KConfig* config )
+{ config->writeEntry( "hostCurrentItem", m_hostCurrentItem );
+ config->writeEntry( "hosts", *m_hosts );
+ config->writeEntry( "portRanges", *m_portRanges );
+ config->writeEntry( "portRangeCurrentItem", m_portRangeCurrentItem );
+ config->writeEntry( "portRangesState", m_portRangesState );
+ config->writeEntry( "resovleAlwaysState", m_resovleAlwaysState );
+ config->writeEntry( "resovleDefaultState", m_resovleDefaultState );
+ config->writeEntry( "resovleNeverState", m_resovleNeverState );
+}
+
+// setInitialValues
+// ================
+
+void CommonWidget::setInitialValues( )
+{ m_hostComboBox->clear( );
+ m_hostComboBox->insertStringList( *m_hosts );
+ m_portRangeListBox->insertStringList( *m_portRanges );
+ m_portRangeComboBox->setCurrentItem( m_portRangeCurrentItem );
+ m_portRangesCheckBox->setChecked( m_portRangesState );
+ m_resovleAlwaysRadio->setChecked( m_resovleAlwaysState );
+ m_resovleDefaultRadio->setChecked( m_resovleDefaultState );
+ m_resovleNeverRadio->setChecked( m_resovleNeverState );
+
+ if( m_hostComboBox->count( ))
+ m_hostComboBox->setCurrentItem( m_hostCurrentItem );
+
+ enablePortRangeWidgets( );
+}
+
+// slotDisablePortRanges
+// =====================
+
+void CommonWidget::slotDisablePortRanges( )
+{ m_portRangesCheckBox->setChecked( false );
+ slotPortRangesClicked( );
+}
+
+// slotHostActivated
+// =================
+
+void CommonWidget::slotHostActivated( int /* index */)
+{ emit( targetChanged( m_hostComboBox->currentText( )));
+}
+
+// slotHostButtonClicked
+// =====================
+
+void CommonWidget::slotHostButtonClicked( )
+{ m_hostComboBox->clearEdit( );
+}
+
+// slotHostTextChanged
+// ===================
+
+void CommonWidget::slotHostTextChanged( const QString& text )
+{ emit( targetChanged( text ));
+}
+
+// slotPortRangeAddClicked
+// =======================
+
+void CommonWidget::slotPortRangeAddClicked( )
+{ QString text;
+
+ if( !validatePortRange( text ))
+ return;
+
+ switch( m_portRangeComboBox->currentItem( ))
+ { case BothProtocol: break;
+ case TCPProtocol: text = "T:" + text; break;
+ case UDPProtocol: text = "U:" + text; break;
+
+ default:
+ kdDebug( ) << i18n( "unknown value in Port Range Protocol combo box" ) << endl;
+ ASSERT( false );
+ }
+
+ m_portRangeAddButton->setEnabled( false );
+ emit( optionsDirty( ));
+ m_portRangeLineEdit->clear( );
+ m_portRangeListBox->insertItem( text );
+}
+
+// slotPortRangeDeleteClicked
+// ==========================
+
+void CommonWidget::slotPortRangeDeleteClicked( )
+{ m_portRangeIgnoreChange = true;
+ m_portRangeListBox->removeItem( m_portRangeListBox->currentItem( ));
+ m_portRangeAddButton->setEnabled( true );
+ m_portRangeDeleteButton->setEnabled( false );
+ emit( optionsDirty( ));
+}
+
+// slotPortRangeActivated
+// ======================
+
+void CommonWidget::slotPortRangeActivated( int /* index */)
+{ m_portRangeAddButton->setEnabled( true );
+}
+
+// slotPortRangeActivated
+// ======================
+
+void CommonWidget::slotPortRangeButtonClicked( )
+{ m_portRangeAddButton->setEnabled( false );
+ m_portRangeDeleteButton->setEnabled( false );
+ m_portRangeLineEdit->clear( );
+}
+
+// slotPortRangeDoubleClicked
+// ==========================
+
+void CommonWidget::slotPortRangeDoubleClicked( QListBoxItem* item )
+{ if( item == NULL )
+ return;
+
+ QString text = item->text( );
+
+ if( text[ 0 ].isDigit( ))
+ m_portRangeComboBox->setCurrentItem( BothProtocol );
+ else
+ { switch( text[ 0 ].latin1( ))
+ { case 'T': m_portRangeComboBox->setCurrentItem( TCPProtocol ); break;
+ case 'U': m_portRangeComboBox->setCurrentItem( UDPProtocol ); break;
+
+ default:
+ kdDebug( ) << i18n( "unknown value in Port Range Protocol" ) << endl;
+ ASSERT( false );
+ m_portRangeComboBox->setCurrentItem( BothProtocol );
+ }
+
+ text = text.right( text.length( ) - 2 );
+ }
+
+ m_portRangeIgnoreChange = true;
+ m_portRangeLineEdit->setText( text );
+ m_portRangeDeleteButton->setEnabled( true );
+}
+
+// slotPortRangeHighlighted
+// ========================
+
+void CommonWidget::slotPortRangeHighlighted( )
+{ if( m_portRangeIgnoreChange )
+ m_portRangeIgnoreChange = false;
+ else
+ { m_portRangeAddButton->setEnabled( false );
+ m_portRangeDeleteButton->setEnabled( false );
+ m_portRangeLineEdit->clear( );
+ }
+}
+
+// slotPortRangesClicked
+// =====================
+
+void CommonWidget::slotPortRangesClicked( )
+{ enablePortRangeWidgets( );
+}
+
+// slotPortRangeTextChanged
+// ========================
+
+void CommonWidget::slotPortRangeTextChanged( const QString& /* text */)
+{ if( m_portRangeIgnoreChange )
+ m_portRangeIgnoreChange = false;
+ else
+ m_portRangeAddButton->setEnabled( m_portRangeLineEdit->text( ).length( ));
+}
+
+// slotWhatsThisClicked
+// ====================
+
+void CommonWidget::slotWhatsThisClicked( )
+{ if( m_hostButton->hasMouse( )) emit( displayHelp( "target" ));
+ else if( m_hostComboBox->hasMouse( )) emit( displayHelp( "target" ));
+ else if( m_portRangeAddButton->hasMouse( )) emit( displayDocBook( "common_options" ));
+ else if( m_portRangeButton->hasMouse( )) emit( displayDocBook( "common_options" ));
+ else if( m_portRangeComboBox->hasMouse( )) emit( displayDocBook( "common_options" ));
+ else if( m_portRangeDeleteButton->hasMouse( )) emit( displayDocBook( "common_options" ));
+ else if( m_portRangeLineEdit->hasMouse( )) emit( displayDocBook( "common_options" ));
+ else if( m_portRangeListBox->hasMouse( )) emit( displayDocBook( "common_options" ));
+ else if( m_portRangesCheckBox->hasMouse( )) emit( displayHelp( "-p" ));
+ else if( m_resovleAlwaysRadio->hasMouse( )) emit( displayHelp( "-R" ));
+ else if( m_resovleDefaultRadio->hasMouse( )) emit( displayDocBook( "common_options" ));
+ else if( m_resovleNeverRadio->hasMouse( )) emit( displayHelp( "-n" ));
+ else emit( displayUnknown( ));
+}
+
+// validatePortRange
+// =================
+
+bool CommonWidget::validatePortRange( QString& text )
+{ uint portFirst;
+ uint portLast;
+
+ if( !validatePortRangeText( text, portFirst, portLast ))
+ return false;
+
+ if( !portRangesOverlapping( portFirst, portLast ))
+ return false;
+
+ return true;
+}
+
+// validatePortRangeText
+// =====================
+
+bool CommonWidget::validatePortRangeText( QString& text, uint& portFirst, uint& portLast )
+{ text = m_portRangeLineEdit->text( );
+ QStringList ports = QStringList::split( "-", text );
+
+ if( ports.count( ) > 2 )
+ { KMessageBox::error( this, i18n( "Internal error - you seem to have been allowed to entered an illegal Port Range" ), i18n( "Internal error" ));
+ return false;
+ }
+
+ portFirst = ports.front( ).toUInt( );
+ portLast = portFirst;
+
+ if( ports.count( ) > 1 )
+ portLast = ports.back( ).toUInt( );
+
+ if( !portFirst || portFirst > 65535 || !portLast || portLast > 65535 || portFirst > portLast )
+ { KMessageBox::sorry( this,
+ i18n( "Ports must be in the range 1 to 65,535 and ranges must be in ascending order" ),
+ i18n( "Invalid Port Range" ));
+ return false;
+ }
+
+ return true;
+}
diff --git a/src/commonwidget.h b/src/commonwidget.h
new file mode 100644
index 0000000..30e2a78
--- /dev/null
+++ b/src/commonwidget.h
@@ -0,0 +1,140 @@
+/***************************************************************************
+ * *
+ * Copyright (C) 2005, 2006 by Kevin Gilbert *
+ * kev.gilbert@cdu.edu.au *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ * *
+ ***************************************************************************/
+
+#ifndef _COMMONWIDGET_H_
+#define _COMMONWIDGET_H_
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <qwidget.h>
+#include "global.h"
+
+// forward class definitions
+// =========================
+
+class KConfig;
+class QCheckBox;
+class QComboBox;
+class QLineEdit;
+class QListBox;
+class QListBoxItem;
+class QPushButton;
+class QRadioButton;
+class QStringList;
+
+// CommonWidget class definition
+// =============================
+
+class CommonWidget : public QWidget
+{ Q_OBJECT
+
+ public:
+ CommonWidget( QWidget* parent, const char* name = NULL );
+ virtual ~CommonWidget( );
+
+ void finaliseInitialisation( );
+ bool getOptions( );
+ void readProfile( KConfig* config );
+ void saveProfile( KConfig* config );
+ void setInitialValues( );
+
+ QString getHostName( ) const;
+ int hostCurrentItem( ) const { return m_hostCurrentItem; }
+ QString host( ) const { return m_host; }
+ int portRangeCurrentItem( ) const { return m_portRangeCurrentItem; }
+ QStringList* portRanges( ) const { return m_portRanges; }
+ bool portRangesState( ) const { return m_portRangesState; }
+ bool resovleAlwaysState( ) const { return m_resovleAlwaysState; }
+ bool resovleDefaultState( ) const { return m_resovleDefaultState; }
+ bool resovleNeverState( ) const { return m_resovleNeverState; }
+
+ signals:
+ void disableFastScan( );
+ void displayDocBook( const QString& );
+ void displayHelp( const QString& );
+ void displayUnknown( );
+ void optionsDirty( );
+ void targetChanged( const QString& );
+
+ public slots:
+ void slotDisablePortRanges( );
+
+ private slots:
+ void slotHostActivated( int index );
+ void slotHostButtonClicked( );
+ void slotHostTextChanged( const QString& text );
+ void slotPortRangeActivated( int index );
+ void slotPortRangeAddClicked( );
+ void slotPortRangeDeleteClicked( );
+ void slotPortRangeButtonClicked( );
+ void slotPortRangeDoubleClicked( QListBoxItem* item );
+ void slotPortRangeHighlighted( );
+ void slotPortRangesClicked( );
+ void slotPortRangeTextChanged( const QString& text );
+ void slotWhatsThisClicked( );
+
+ private:
+ bool buildPortRangesTables( const boolPtr tcpPorts, const boolPtr udpPorts );
+ void createLayout( );
+ void enablePortRangeWidgets( );
+ void getHosts( QStringList* hosts );
+ void getPortRanges( QStringList* portRanges );
+ bool portRangesOverlapping( const ushort portFirst, const ushort portLast );
+ bool validatePortRange( QString& text );
+ bool validatePortRangeText( QString& text, uint& portFirst, uint& portLast );
+
+ // protocol indices
+ // ================
+
+ enum Protocol
+ { BothProtocol,
+ TCPProtocol,
+ UDPProtocol
+ };
+
+ QString m_host;
+ QPushButton* m_hostButton;
+ QComboBox* m_hostComboBox;
+ int m_hostCurrentItem;
+ QStringList* m_hosts;
+ QPushButton* m_portRangeAddButton;
+ QPushButton* m_portRangeButton;
+ QComboBox* m_portRangeComboBox;
+ int m_portRangeCurrentItem;
+ QPushButton* m_portRangeDeleteButton;
+ bool m_portRangeIgnoreChange;
+ QLineEdit* m_portRangeLineEdit;
+ QListBox* m_portRangeListBox;
+ QStringList* m_portRanges;
+ QCheckBox* m_portRangesCheckBox;
+ bool m_portRangesState;
+ QRadioButton* m_resovleAlwaysRadio;
+ bool m_resovleAlwaysState;
+ QRadioButton* m_resovleDefaultRadio;
+ bool m_resovleDefaultState;
+ QRadioButton* m_resovleNeverRadio;
+ bool m_resovleNeverState;
+};
+
+#endif // _COMMONWIDGET_H_
diff --git a/src/compoundwidget.cpp b/src/compoundwidget.cpp
new file mode 100644
index 0000000..a0ee885
--- /dev/null
+++ b/src/compoundwidget.cpp
@@ -0,0 +1,682 @@
+/***************************************************************************
+ * *
+ * Copyright (C) 2005, 2006 by Kevin Gilbert *
+ * kev.gilbert@cdu.edu.au *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ * *
+ ***************************************************************************/
+
+#include <qcheckbox.h>
+#include <qiconset.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qlineedit.h>
+#include <qpushbutton.h>
+#include <qspinbox.h>
+
+#include <kconfig.h>
+#include <kdebug.h>
+#include <kglobal.h>
+#include <kiconloader.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+
+#include "compoundwidget.h"
+#include "knmap.h"
+#include "whatsthis.h"
+
+// constructor
+// ===========
+
+CompoundWidget::CompoundWidget( QWidget* parent, const char* name )
+: QWidget( parent, name )
+{ createLayout( );
+}
+
+// createLayout
+// ============
+
+void CompoundWidget::createLayout( )
+{ QGridLayout* gridLayout = new QGridLayout( this );
+ KIconLoader* iconLoader = KGlobal::iconLoader( );
+ QIconSet clearLeftIconSet = iconLoader->loadIconSet( "clear_left", KIcon::Small );
+ QIconSet fileOpenIconSet = iconLoader->loadIconSet( "fileopen", KIcon::Small );
+
+ m_decoyButton = new QPushButton( clearLeftIconSet, NULL, this, "target file button" );
+ m_excludeButton = new QPushButton( clearLeftIconSet, NULL, this, "target file button" );
+ m_interfaceButton = new QPushButton( clearLeftIconSet, NULL, this, "target file button" );
+ m_sourceIPButton = new QPushButton( clearLeftIconSet, NULL, this, "target file button" );
+ m_spoofMacButton = new QPushButton( clearLeftIconSet, NULL, this, "target file button" );
+
+ m_dataDirButton = new QPushButton( fileOpenIconSet, NULL, this, "datadir button" );
+ m_excludeFileButton = new QPushButton( fileOpenIconSet, NULL, this, "exclude file button" );
+ m_targetFileButton = new QPushButton( fileOpenIconSet, NULL, this, "target file button" );
+
+ m_dataDirCheckBox = new QCheckBox( i18n( "Data directory (--datadir <name>) " ), this, "datadir checkbox" );
+ m_dataLengthCheckBox = new QCheckBox( i18n( "Data length (--data_length <value>" ), this, "data length checkbox" );
+ m_debugLevelCheckBox = new QCheckBox( i18n( "Debug level (-d)" ), this, "debug checkbox" );
+ m_decoyCheckBox = new QCheckBox( i18n( "Decoy hosts (-D <host list>)" ), this, "decoy checkbox" );
+ m_excludeCheckBox = new QCheckBox( i18n( "Exclude hosts (--exclude <hosts>) " ), this, "exclude checkbox" );
+ m_excludeFileCheckBox = new QCheckBox( i18n( "Exclude file (--excludefile <path>) " ), this, "exclude checkbox" );
+ m_fragmentLevelCheckBox = new QCheckBox( i18n( "Fragment level (-f)" ), this, "fragment checkbox" );
+ m_interfaceCheckBox = new QCheckBox( i18n( "Interface (-e)" ), this, "interface checkbox" );
+ m_maxSocketsCheckBox = new QCheckBox( i18n( "Max sockets (-M <value>)" ), this, "max sockets checkbox" );
+ m_randomIPCheckBox = new QCheckBox( i18n( "Random IP scan (-iR <value>)" ), this, "random ip checkbox" );
+ m_sourceIPCheckBox = new QCheckBox( i18n( "Source IP addr (-S <value>)" ), this, "source ip checkbox" );
+ m_sourcePortCheckBox = new QCheckBox( i18n( "Source port (-g <value>)" ), this, "source port checkbox" );
+ m_spoofMacCheckBox = new QCheckBox( i18n( "Spoof MAC addr (--spoof_mac <value>)" ), this, "spoof mac checkbox" );
+ m_targetFileCheckBox = new QCheckBox( i18n( "Target hosts file (-iL <path>) " ), this, "target checkbox" );
+ m_ttlCheckBox = new QCheckBox( i18n( "TTL (--ttl <value>)" ), this, "ttl checkbox" );
+
+ m_dataDirLineEdit = new QLineEdit( this, "datadir line edit" );
+ m_decoyLineEdit = new QLineEdit( this, "decoy edit" );
+ m_excludeLineEdit = new QLineEdit( this, "exclude line edit" );
+ m_excludeFileLineEdit = new QLineEdit( this, "exclude file line edit" );
+ m_interfaceLineEdit = new QLineEdit( this, "interface edit" );
+ m_sourceIPLineEdit = new QLineEdit( this, "source ip edit" );
+ m_spoofMacLineEdit = new QLineEdit( this, "spoof mac edit" );
+ m_targetFileLineEdit = new QLineEdit( this, "target file line edit" );
+
+ m_dataLengthSpinBox = new QSpinBox( 1, 1460, 128, this, "data length spin box" );
+ m_debugLevelSpinBox = new QSpinBox( 1, 5, 1, this, "debug spin box" );
+ m_fragmentLevelSpinBox = new QSpinBox( 1, 2, 1, this, "fragment spin box" );
+ m_maxSocketsSpinBox = new QSpinBox( 1, 999, 10, this, "max sockets spin box" );
+ m_randomIPSpinBox = new QSpinBox( 1, 999, 10, this, "random ip spin box" );
+ m_sourcePortSpinBox = new QSpinBox( 1, 65535, 64, this, "source port spin box" );
+ m_ttlSpinBox = new QSpinBox( 1, 255, 32, this, "ttl spin box" );
+
+ byte row = 1;
+ gridLayout->addWidget( new QLabel( " ", this ), row, 1 );
+ gridLayout->addWidget( m_dataLengthCheckBox, row, 3 );
+ gridLayout->addWidget( m_dataLengthSpinBox, row++, 4 );
+
+ gridLayout->addWidget( new QLabel( " ", this ), row, 1 );
+ gridLayout->addWidget( m_debugLevelCheckBox, row, 3 );
+ gridLayout->addWidget( m_debugLevelSpinBox, row++, 4 );
+
+ gridLayout->addWidget( new QLabel( "#", this ), row, 1 );
+ gridLayout->addWidget( m_fragmentLevelCheckBox, row, 3 );
+ gridLayout->addWidget( m_fragmentLevelSpinBox, row++, 4 );
+
+ gridLayout->addWidget( new QLabel( " ", this ), row, 1 );
+ gridLayout->addWidget( m_maxSocketsCheckBox, row, 3 );
+ gridLayout->addWidget( m_maxSocketsSpinBox, row++, 4 );
+
+ gridLayout->addWidget( new QLabel( " ", this ), row, 1 );
+ gridLayout->addWidget( m_randomIPCheckBox, row, 3 );
+ gridLayout->addWidget( m_randomIPSpinBox, row++, 4 );
+
+ gridLayout->addWidget( new QLabel( " ", this ), row, 1 );
+ gridLayout->addWidget( m_sourcePortCheckBox, row, 3 );
+ gridLayout->addWidget( m_sourcePortSpinBox, row++, 4 );
+
+ gridLayout->addWidget( new QLabel( " ", this ), row, 1 );
+ gridLayout->addWidget( m_ttlCheckBox, row, 3 );
+ gridLayout->addWidget( m_ttlSpinBox, row++, 4 );
+ byte rowBlock1 = row;
+
+ row = 1;
+ gridLayout->addWidget( new QLabel( "#", this ), row, 6 );
+ gridLayout->addWidget( m_decoyCheckBox, row, 8 );
+ gridLayout->addWidget( m_decoyLineEdit, row, 9 );
+ gridLayout->addWidget( m_decoyButton, row++, 10 );
+
+ gridLayout->addWidget( new QLabel( " ", this ), row, 6 );
+ gridLayout->addWidget( m_excludeCheckBox, row, 8 );
+ gridLayout->addWidget( m_excludeLineEdit, row, 9 );
+ gridLayout->addWidget( m_excludeButton, row++, 10 );
+
+ gridLayout->addWidget( new QLabel( " ", this ), row, 6 );
+ gridLayout->addWidget( m_interfaceCheckBox, row, 8 );
+ gridLayout->addWidget( m_interfaceLineEdit, row, 9 );
+ gridLayout->addWidget( m_interfaceButton, row++, 10 );
+
+ gridLayout->addWidget( new QLabel( " ", this ), row, 6 );
+ gridLayout->addWidget( m_sourceIPCheckBox, row, 8 );
+ gridLayout->addWidget( m_sourceIPLineEdit, row, 9 );
+ gridLayout->addWidget( m_sourceIPButton, row++, 10 );
+
+ gridLayout->addWidget( new QLabel( " ", this ), row, 6 );
+ gridLayout->addWidget( m_spoofMacCheckBox, row, 8 );
+ gridLayout->addWidget( m_spoofMacLineEdit, row, 9 );
+ gridLayout->addWidget( m_spoofMacButton, row++, 10 );
+
+ row++;
+ gridLayout->addWidget( new QLabel( " ", this ), row, 6 );
+ gridLayout->addWidget( m_excludeFileCheckBox, row, 8 );
+ gridLayout->addWidget( m_excludeFileLineEdit, row, 9 );
+ gridLayout->addWidget( m_excludeFileButton, row++, 10 );
+
+ gridLayout->addWidget( new QLabel( " ", this ), row, 6 );
+ gridLayout->addWidget( m_dataDirCheckBox, row, 8 );
+ gridLayout->addWidget( m_dataDirLineEdit, row, 9 );
+ gridLayout->addWidget( m_dataDirButton, row++, 10 );
+
+ gridLayout->addWidget( new QLabel( " ", this ), row, 6 );
+ gridLayout->addWidget( m_targetFileCheckBox, row, 8 );
+ gridLayout->addWidget( m_targetFileLineEdit, row, 9 );
+ gridLayout->addWidget( m_targetFileButton, row++, 10 );
+ byte rowBlock2 = row;
+
+ gridLayout->setColStretch( 0, 4 );
+ gridLayout->setColStretch( 2, 1 );
+ gridLayout->setColStretch( 4, 20 );
+ gridLayout->setColStretch( 5, 4 );
+ gridLayout->setColStretch( 7, 1 );
+ gridLayout->setColStretch( 9, 20 );
+ gridLayout->setColStretch( 11, 4 );
+
+ gridLayout->setRowStretch( 0, 1 );
+ gridLayout->setRowStretch( _max_( rowBlock1, rowBlock2 ), 1 );
+}
+
+// finaliseInitialisation
+// ======================
+
+void CompoundWidget::finaliseInitialisation( )
+{ WhatsThis* whatsThis = new WhatsThis( this );
+
+ connect( m_dataDirButton, SIGNAL( clicked( )), SLOT( slotDataDirButtonClicked( )));
+ connect( m_dataDirCheckBox, SIGNAL( clicked( )), SLOT( slotDataDirCheckBoxClicked( )));
+ connect( m_dataLengthCheckBox, SIGNAL( clicked( )), SLOT( slotDataLengthCheckBoxClicked( )));
+ connect( m_debugLevelCheckBox, SIGNAL( clicked( )), SLOT( slotDebugLevelCheckBoxClicked( )));
+ connect( m_decoyButton, SIGNAL( clicked( )), SLOT( slotDecoyButtonClicked( )));
+ connect( m_decoyCheckBox, SIGNAL( clicked( )), SLOT( slotDecoyCheckBoxClicked( )));
+ connect( m_excludeButton, SIGNAL( clicked( )), SLOT( slotExcludeButtonClicked( )));
+ connect( m_excludeCheckBox, SIGNAL( clicked( )), SLOT( slotExcludeCheckBoxClicked( )));
+ connect( m_excludeFileButton, SIGNAL( clicked( )), SLOT( slotExcludeFileButtonClicked( )));
+ connect( m_excludeFileCheckBox, SIGNAL( clicked( )), SLOT( slotExcludeFileCheckBoxClicked( )));
+ connect( m_fragmentLevelCheckBox, SIGNAL( clicked( )), SLOT( slotFragmentLevelCheckBoxClicked( )));
+ connect( m_interfaceButton, SIGNAL( clicked( )), SLOT( slotInterfaceButtonClicked( )));
+ connect( m_interfaceCheckBox, SIGNAL( clicked( )), SLOT( slotInterfaceCheckBoxClicked( )));
+ connect( m_maxSocketsCheckBox, SIGNAL( clicked( )), SLOT( slotMaxSocketsCheckBoxClicked( )));
+ connect( m_randomIPCheckBox, SIGNAL( clicked( )), SLOT( slotRandomIPCheckBoxClicked( )));
+ connect( m_sourceIPButton, SIGNAL( clicked( )), SLOT( slotSourceIPButtonClicked( )));
+ connect( m_sourceIPCheckBox, SIGNAL( clicked( )), SLOT( slotSourceIPCheckBoxClicked( )));
+ connect( m_sourcePortCheckBox, SIGNAL( clicked( )), SLOT( slotSourcePortCheckBoxClicked( )));
+ connect( m_spoofMacButton, SIGNAL( clicked( )), SLOT( slotSpoofMACButtonClicked( )));
+ connect( m_spoofMacCheckBox, SIGNAL( clicked( )), SLOT( slotSpoofMacCheckBoxClicked( )));
+ connect( m_targetFileButton, SIGNAL( clicked( )), SLOT( slotTargetFileButtonClicked( )));
+ connect( m_targetFileCheckBox, SIGNAL( clicked( )), SLOT( slotTargetFileCheckBoxClicked( )));
+ connect( m_ttlCheckBox, SIGNAL( clicked( )), SLOT( slotTTLCheckBoxClicked( )));
+ connect( whatsThis, SIGNAL( clicked( )), SLOT( slotWhatsThisClicked( )));
+
+ connect( m_dataDirCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_dataDirLineEdit, SIGNAL( textChanged( const QString& )), SIGNAL( optionsDirty( )));
+ connect( m_dataLengthCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_dataLengthSpinBox, SIGNAL( valueChanged( int )), SIGNAL( optionsDirty( )));
+ connect( m_debugLevelCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_debugLevelSpinBox, SIGNAL( valueChanged( int )), SIGNAL( optionsDirty( )));
+ connect( m_decoyCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_decoyLineEdit, SIGNAL( textChanged( const QString& )), SIGNAL( optionsDirty( )));
+ connect( m_excludeCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_excludeLineEdit, SIGNAL( textChanged( const QString& )), SIGNAL( optionsDirty( )));
+ connect( m_excludeFileCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_excludeFileLineEdit, SIGNAL( textChanged( const QString& )), SIGNAL( optionsDirty( )));
+ connect( m_fragmentLevelCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_fragmentLevelSpinBox, SIGNAL( valueChanged( int )), SIGNAL( optionsDirty( )));
+ connect( m_interfaceCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_interfaceLineEdit, SIGNAL( textChanged( const QString& )), SIGNAL( optionsDirty( )));
+ connect( m_maxSocketsCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_maxSocketsSpinBox, SIGNAL( valueChanged( int )), SIGNAL( optionsDirty( )));
+ connect( m_randomIPCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_randomIPSpinBox, SIGNAL( valueChanged( int )), SIGNAL( optionsDirty( )));
+ connect( m_sourceIPCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_sourceIPLineEdit, SIGNAL( textChanged( const QString& )), SIGNAL( optionsDirty( )));
+ connect( m_sourcePortCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_sourcePortSpinBox, SIGNAL( valueChanged( int )), SIGNAL( optionsDirty( )));
+ connect( m_spoofMacCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_spoofMacLineEdit, SIGNAL( textChanged( const QString& )), SIGNAL( optionsDirty( )));
+ connect( m_targetFileCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_targetFileLineEdit, SIGNAL( textChanged( const QString& )), SIGNAL( optionsDirty( )));
+ connect( m_ttlCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_ttlSpinBox, SIGNAL( valueChanged( int )), SIGNAL( optionsDirty( )));
+}
+
+// getOptions
+// ==========
+
+bool CompoundWidget::getOptions( bool& needRoot )
+{ bool dataDirState = m_dataDirCheckBox->isChecked( );
+ QString dataDirValue = m_dataDirLineEdit->text( );
+ bool decoyState = m_decoyCheckBox->isChecked( );
+ QString decoyValue = m_decoyLineEdit->text( );
+ bool excludeState = m_excludeCheckBox->isChecked( );
+ QString excludeValue = m_excludeLineEdit->text( );
+ bool excludeFileState = m_excludeFileCheckBox->isChecked( );
+ QString excludeFileValue = m_excludeFileLineEdit->text( );
+ bool interfaceState = m_interfaceCheckBox->isChecked( );
+ QString interfaceValue = m_interfaceLineEdit->text( );
+ bool sourceIPState = m_sourceIPCheckBox->isChecked( );
+ QString sourceIPValue = m_sourceIPLineEdit->text( );
+ bool spoofMacState = m_spoofMacCheckBox->isChecked( );
+ QString spoofMacValue = m_spoofMacLineEdit->text( );
+ bool targetFileState = m_targetFileCheckBox->isChecked( );
+ QString targetFileValue = m_targetFileLineEdit->text( );
+
+ if( dataDirState && dataDirValue.isEmpty( ))
+ { KMessageBox::error( this, i18n( QString( "Data directory name not specified" )), i18n( "Data directory name error" ));
+ return false;
+ }
+
+ if( decoyState && decoyValue.isEmpty( ))
+ { KMessageBox::error( this, i18n( QString( "Decoy host list not specified" )), i18n( "Decoy hosts error" ));
+ return false;
+ }
+
+ if( excludeState && excludeValue.isEmpty( ))
+ { KMessageBox::error( this, i18n( QString( "Exclude hosts not specified" )), i18n( "Exclude hosts error" ));
+ return false;
+ }
+
+ if( excludeFileState && excludeFileValue.isEmpty( ))
+ { KMessageBox::error( this, i18n( QString( "Exclude hosts file name not specified" )), i18n( "Exclude hosts file name error" ));
+ return false;
+ }
+
+ if( interfaceState && interfaceValue.isEmpty( ))
+ { KMessageBox::error( this, i18n( QString( "Interface name not specified" )), i18n( "Interface name error" ));
+ return false;
+ }
+
+ if( sourceIPState && sourceIPValue.isEmpty( ))
+ { KMessageBox::error( this, i18n( QString( "Source IP address not specified" )), i18n( "Source IP address error" ));
+ return false;
+ }
+
+ if( spoofMacState && spoofMacValue.isEmpty( ))
+ { KMessageBox::error( this, i18n( QString( "Spoof MAC address not specified" )), i18n( "Spoof MAC address error" ));
+ return false;
+ }
+
+ if( targetFileState && targetFileValue.isEmpty( ))
+ { KMessageBox::error( this, i18n( QString( "Target hosts file name not specified" )), i18n( "Target hosts file name error" ));
+ return false;
+ }
+
+ m_dataDirState = dataDirState;
+ m_dataDirValue = dataDirValue;
+ m_dataLengthState = m_dataLengthCheckBox->isChecked( );
+ m_dataLengthValue = m_dataLengthSpinBox->value( );
+ m_debugLevelState = m_debugLevelCheckBox->isChecked( );
+ m_debugLevelValue = m_debugLevelSpinBox->value( );
+ m_decoyState = decoyState;
+ m_decoyValue = decoyValue;
+ m_excludeState = excludeState;
+ m_excludeValue = excludeValue;
+ m_excludeFileState = excludeFileState;
+ m_excludeFileValue = excludeFileValue;
+ m_fragmentLevelState = m_fragmentLevelCheckBox->isChecked( );
+ m_fragmentLevelValue = m_fragmentLevelSpinBox->value( );
+ m_interfaceState = interfaceState;
+ m_interfaceValue = interfaceValue;
+ m_maxSocketsState = m_maxSocketsCheckBox->isChecked( );
+ m_maxSocketsValue = m_maxSocketsSpinBox->value( );
+ m_randomIPState = m_randomIPCheckBox->isChecked( );
+ m_randomIPValue = m_randomIPSpinBox->value( );
+ m_sourceIPState = sourceIPState;
+ m_sourceIPValue = sourceIPValue;
+ m_sourcePortState = m_sourcePortCheckBox->isChecked( );
+ m_sourcePortValue = m_sourcePortSpinBox->value( );
+ m_spoofMacState = spoofMacState;
+ m_spoofMacValue = spoofMacValue;
+ m_targetFileState = targetFileState;
+ m_targetFileValue = targetFileValue;
+ m_ttlState = m_ttlCheckBox->isChecked( );
+ m_ttlValue = m_ttlSpinBox->value( );
+
+ needRoot = needRoot || m_decoyState || m_fragmentLevelState;
+ return true;
+}
+
+// readProfile
+// ===========
+
+void CompoundWidget::readProfile( KConfig* config )
+{ m_dataDirState = config->readBoolEntry( "dataDirState" );
+ m_dataDirValue = config->readEntry( "dataDirValue" );
+ m_dataLengthState = config->readBoolEntry( "dataLengthState" );
+ m_dataLengthValue = config->readNumEntry( "dataLengthValue", 40 );
+ m_debugLevelState = config->readBoolEntry( "debugLevelState" );
+ m_debugLevelValue = config->readNumEntry( "debugLevelValue" );
+ m_decoyState = config->readBoolEntry( "decoyState" );
+ m_decoyValue = config->readEntry( "decoyValue" );
+ m_excludeState = config->readBoolEntry( "excludeState" );
+ m_excludeValue = config->readEntry( "excludeValue" );
+ m_excludeFileState = config->readBoolEntry( "excludeFileState" );
+ m_excludeFileValue = config->readEntry( "excludeFileValue" );
+ m_fragmentLevelState = config->readBoolEntry( "fragmentLevelState" );
+ m_fragmentLevelValue = config->readNumEntry( "fragmentLevelValue" );
+ m_interfaceState = config->readBoolEntry( "interfaceState" );
+ m_interfaceValue = config->readEntry( "interfaceValue" );
+ m_maxSocketsState = config->readBoolEntry( "maxSocketsState" );
+ m_maxSocketsValue = config->readNumEntry( "maxSocketsValue" );
+ m_randomIPState = config->readBoolEntry( "randomIPState" );
+ m_randomIPValue = config->readNumEntry( "randomIPValue" );
+ m_sourceIPState = config->readBoolEntry( "sourceIPState" );
+ m_sourceIPValue = config->readEntry( "sourceIPValue" );
+ m_sourcePortState = config->readBoolEntry( "sourcePortState" );
+ m_sourcePortValue = config->readNumEntry( "sourcePortValue" );
+ m_spoofMacState = config->readBoolEntry( "spoofMacState" );
+ m_spoofMacValue = config->readEntry( "spoofMacValue" );
+ m_targetFileState = config->readBoolEntry( "targetFileState" );
+ m_targetFileValue = config->readEntry( "targetFileValue" );
+ m_ttlState = config->readBoolEntry( "ttlState" );
+ m_ttlValue = config->readNumEntry( "ttlValue" );
+}
+
+// saveProfile
+// ===========
+
+void CompoundWidget::saveProfile( KConfig* config )
+{ config->writeEntry( "dataDirState", m_dataDirState );
+ config->writeEntry( "dataDirValue", m_dataDirValue );
+ config->writeEntry( "dataLengthState", m_dataLengthState );
+ config->writeEntry( "dataLengthValue", m_dataLengthValue );
+ config->writeEntry( "debugLevelState", m_debugLevelState );
+ config->writeEntry( "debugLevelValue", m_debugLevelValue );
+ config->writeEntry( "decoyState", m_decoyState );
+ config->writeEntry( "decoyValue", m_decoyValue );
+ config->writeEntry( "excludeState", m_excludeState );
+ config->writeEntry( "excludeValue", m_excludeValue );
+ config->writeEntry( "excludeFileState", m_excludeFileState );
+ config->writeEntry( "excludeFileValue", m_excludeFileValue );
+ config->writeEntry( "fragmentLevelState", m_fragmentLevelState );
+ config->writeEntry( "fragmentLevelValue", m_fragmentLevelValue );
+ config->writeEntry( "interfaceState", m_interfaceState );
+ config->writeEntry( "interfaceValue", m_interfaceValue );
+ config->writeEntry( "maxSocketsState", m_maxSocketsState );
+ config->writeEntry( "maxSocketsValue", m_maxSocketsValue );
+ config->writeEntry( "randomIPState", m_randomIPState );
+ config->writeEntry( "randomIPValue", m_randomIPValue );
+ config->writeEntry( "sourceIPState", m_sourceIPState );
+ config->writeEntry( "sourceIPValue", m_sourceIPValue );
+ config->writeEntry( "sourcePortState", m_sourcePortState );
+ config->writeEntry( "sourcePortValue", m_sourcePortValue );
+ config->writeEntry( "spoofMacState", m_spoofMacState );
+ config->writeEntry( "spoofMacValue", m_spoofMacValue );
+ config->writeEntry( "targetFileState", m_targetFileState );
+ config->writeEntry( "targetFileValue", m_targetFileValue );
+ config->writeEntry( "ttlState", m_ttlState );
+ config->writeEntry( "ttlValue", m_ttlValue );
+}
+
+// setInitialValues
+// ================
+
+void CompoundWidget::setInitialValues( )
+{ m_dataDirCheckBox->setChecked( m_dataDirState );
+ m_dataDirLineEdit->setText( m_dataDirValue );
+ m_dataLengthCheckBox->setChecked( m_dataLengthState );
+ m_dataLengthSpinBox->setValue( m_dataLengthValue );
+ m_debugLevelCheckBox->setChecked( m_debugLevelState );
+ m_debugLevelSpinBox->setValue( m_debugLevelValue );
+ m_decoyCheckBox->setChecked( m_decoyState );
+ m_decoyLineEdit->setText( m_decoyValue );
+ m_excludeCheckBox->setChecked( m_excludeState );
+ m_excludeLineEdit->setText( m_excludeValue );
+ m_excludeFileCheckBox->setChecked( m_excludeFileState );
+ m_excludeFileLineEdit->setText( m_excludeFileValue );
+ m_fragmentLevelCheckBox->setChecked( m_fragmentLevelState );
+ m_fragmentLevelSpinBox->setValue( m_fragmentLevelValue );
+ m_interfaceCheckBox->setChecked( m_interfaceState );
+ m_interfaceLineEdit->setText( m_interfaceValue );
+ m_maxSocketsCheckBox->setChecked( m_maxSocketsState );
+ m_maxSocketsSpinBox->setValue( m_maxSocketsValue );
+ m_randomIPCheckBox->setChecked( m_randomIPState );
+ m_randomIPSpinBox->setValue( m_randomIPValue );
+ m_sourceIPCheckBox->setChecked( m_sourceIPState );
+ m_sourceIPLineEdit->setText( m_sourceIPValue );
+ m_sourcePortCheckBox->setChecked( m_sourcePortState );
+ m_sourcePortSpinBox->setValue( m_sourcePortValue );
+ m_spoofMacCheckBox->setChecked( m_spoofMacState );
+ m_spoofMacLineEdit->setText( m_spoofMacValue );
+ m_targetFileCheckBox->setChecked( m_targetFileState );
+ m_targetFileLineEdit->setText( m_targetFileValue );
+ m_ttlCheckBox->setChecked( m_ttlState );
+ m_ttlSpinBox->setValue( m_ttlValue );
+
+ slotDataDirCheckBoxClicked( );
+ slotDataLengthCheckBoxClicked( );
+ slotDebugLevelCheckBoxClicked( );
+ slotDecoyCheckBoxClicked( );
+ slotExcludeCheckBoxClicked( );
+ slotExcludeFileCheckBoxClicked( );
+ slotFragmentLevelCheckBoxClicked( );
+ slotInterfaceCheckBoxClicked( );
+ slotMaxSocketsCheckBoxClicked( );
+ slotRandomIPCheckBoxClicked( );
+ slotSourceIPCheckBoxClicked( );
+ slotSourcePortCheckBoxClicked( );
+ slotSpoofMacCheckBoxClicked( );
+ slotTargetFileCheckBoxClicked( );
+ slotTTLCheckBoxClicked( );
+}
+
+// slotDataDirButtonClicked
+// ========================
+
+void CompoundWidget::slotDataDirButtonClicked( )
+{ Knmap::getDirPath( "Data directory", m_dataDirValue, m_dataDirLineEdit );
+}
+
+// slotDataDirCheckBoxClicked
+// ==========================
+
+void CompoundWidget::slotDataDirCheckBoxClicked( )
+{ m_dataDirButton->setEnabled( m_dataDirCheckBox->isChecked( ));
+ m_dataDirLineEdit->setEnabled( m_dataDirCheckBox->isChecked( ));
+}
+
+// slotDataLengthCheckBoxClicked
+// =============================
+
+void CompoundWidget::slotDataLengthCheckBoxClicked( )
+{ m_dataLengthSpinBox->setEnabled( m_dataLengthCheckBox->isChecked( ));
+}
+
+// slotDebugLevelCheckBoxClicked
+// =============================
+
+void CompoundWidget::slotDebugLevelCheckBoxClicked( )
+{ m_debugLevelSpinBox->setEnabled( m_debugLevelCheckBox->isChecked( ));
+}
+
+// slotDecoyButtonClicked
+// ======================
+
+void CompoundWidget::slotDecoyButtonClicked( )
+{ m_decoyLineEdit->clear( );
+}
+
+// slotDecoyCheckBoxClicked
+// ========================
+
+void CompoundWidget::slotDecoyCheckBoxClicked( )
+{ m_decoyButton->setEnabled( m_decoyCheckBox->isChecked( ));
+ m_decoyLineEdit->setEnabled( m_decoyCheckBox->isChecked( ));
+}
+
+// slotExcludeButtonClicked
+// ========================
+
+void CompoundWidget::slotExcludeButtonClicked( )
+{ m_excludeLineEdit->clear( );
+}
+
+// slotExcludeCheckBoxClicked
+// ==========================
+
+void CompoundWidget::slotExcludeCheckBoxClicked( )
+{ m_excludeButton->setEnabled( m_excludeCheckBox->isChecked( ));
+ m_excludeLineEdit->setEnabled( m_excludeCheckBox->isChecked( ));
+}
+
+// slotExcludeFileButtonClicked
+// ============================
+
+void CompoundWidget::slotExcludeFileButtonClicked( )
+{ Knmap::getFilePath( "Exclude hosts file", m_excludeFileValue, m_excludeFileLineEdit, false );
+}
+
+// slotExcludeFileCheckBoxClicked
+// ==============================
+
+void CompoundWidget::slotExcludeFileCheckBoxClicked( )
+{ m_excludeFileButton->setEnabled( m_excludeFileCheckBox->isChecked( ));
+ m_excludeFileLineEdit->setEnabled( m_excludeFileCheckBox->isChecked( ));
+}
+
+// slotFragmentLevelCheckBoxClicked
+// ================================
+
+void CompoundWidget::slotFragmentLevelCheckBoxClicked( )
+{ m_fragmentLevelSpinBox->setEnabled( m_fragmentLevelCheckBox->isChecked( ));
+}
+
+// slotInterfaceButtonClicked
+// ==========================
+
+void CompoundWidget::slotInterfaceButtonClicked( )
+{ m_interfaceLineEdit->clear( );
+}
+
+// slotInterfaceCheckBoxClicked
+// ============================
+
+void CompoundWidget::slotInterfaceCheckBoxClicked( )
+{ m_interfaceButton->setEnabled( m_interfaceCheckBox->isChecked( ));
+ m_interfaceLineEdit->setEnabled( m_interfaceCheckBox->isChecked( ));
+}
+
+// slotMaxSocketsCheckBoxClicked
+// =============================
+
+void CompoundWidget::slotMaxSocketsCheckBoxClicked( )
+{ m_maxSocketsSpinBox->setEnabled( m_maxSocketsCheckBox->isChecked( ));
+}
+
+// slotRandomIPCheckBoxClicked
+// ===========================
+
+void CompoundWidget::slotRandomIPCheckBoxClicked( )
+{ m_randomIPSpinBox->setEnabled( m_randomIPCheckBox->isChecked( ));
+}
+
+// slotSourceIPButtonClicked
+// =========================
+
+void CompoundWidget::slotSourceIPButtonClicked( )
+{ m_sourceIPLineEdit->clear( );
+}
+
+// slotSourceIPCheckBoxClicked
+// ===========================
+
+void CompoundWidget::slotSourceIPCheckBoxClicked( )
+{ m_sourceIPButton->setEnabled( m_sourceIPCheckBox->isChecked( ));
+ m_sourceIPLineEdit->setEnabled( m_sourceIPCheckBox->isChecked( ));
+}
+
+// slotSourcePortCheckBoxClicked
+// =============================
+
+void CompoundWidget::slotSourcePortCheckBoxClicked( )
+{ m_sourcePortSpinBox->setEnabled( m_sourcePortCheckBox->isChecked( ));
+}
+
+// slotSpoofMACButtonClicked
+// =========================
+
+void CompoundWidget::slotSpoofMACButtonClicked( )
+{ m_spoofMacLineEdit->clear( );
+}
+
+// slotSpoofMacCheckBoxClicked
+// ===========================
+
+void CompoundWidget::slotSpoofMacCheckBoxClicked( )
+{ m_spoofMacButton->setEnabled( m_spoofMacCheckBox->isChecked( ));
+ m_spoofMacLineEdit->setEnabled( m_spoofMacCheckBox->isChecked( ));
+}
+
+// slotTargetFileButtonClicked
+// ===========================
+
+void CompoundWidget::slotTargetFileButtonClicked( )
+{ Knmap::getFilePath( "Target hosts file", m_targetFileValue, m_targetFileLineEdit, false );
+}
+
+// slotTargetFileCheckBoxClicked
+// =============================
+
+void CompoundWidget::slotTargetFileCheckBoxClicked( )
+{ m_targetFileButton->setEnabled( m_targetFileCheckBox->isChecked( ));
+ m_targetFileLineEdit->setEnabled( m_targetFileCheckBox->isChecked( ));
+}
+
+// slotTTLCheckBoxClicked
+// ======================
+
+void CompoundWidget::slotTTLCheckBoxClicked( )
+{ m_ttlSpinBox->setEnabled( m_ttlCheckBox->isChecked( ));
+}
+
+// slotWhatsThisClicked
+// ====================
+
+void CompoundWidget::slotWhatsThisClicked( )
+{ if( m_dataDirButton->hasMouse( )) emit( displayHelp( "--datadir" ));
+ else if( m_dataDirCheckBox->hasMouse( )) emit( displayHelp( "--datadir" ));
+ else if( m_dataDirLineEdit->hasMouse( )) emit( displayHelp( "--datadir" ));
+ else if( m_dataLengthCheckBox->hasMouse( )) emit( displayHelp( "--data_length" ));
+ else if( m_dataLengthSpinBox->hasMouse( )) emit( displayHelp( "--data_length" ));
+ else if( m_decoyButton->hasMouse( )) emit( displayHelp( "-D" ));
+ else if( m_decoyCheckBox->hasMouse( )) emit( displayHelp( "-D" ));
+ else if( m_decoyLineEdit->hasMouse( )) emit( displayHelp( "-D" ));
+ else if( m_debugLevelCheckBox->hasMouse( )) emit( displayHelp( "-d" ));
+ else if( m_debugLevelSpinBox->hasMouse( )) emit( displayHelp( "-d" ));
+ else if( m_excludeButton->hasMouse( )) emit( displayHelp( "--exclude" ));
+ else if( m_excludeCheckBox->hasMouse( )) emit( displayHelp( "--exclude" ));
+ else if( m_excludeLineEdit->hasMouse( )) emit( displayHelp( "--exclude" ));
+ else if( m_excludeFileButton->hasMouse( )) emit( displayHelp( "--exclude" ));
+ else if( m_excludeFileCheckBox->hasMouse( )) emit( displayHelp( "--exclude" ));
+ else if( m_excludeFileLineEdit->hasMouse( )) emit( displayHelp( "--exclude" ));
+ else if( m_fragmentLevelCheckBox->hasMouse( )) emit( displayHelp( "-f" ));
+ else if( m_fragmentLevelSpinBox->hasMouse( )) emit( displayHelp( "-f" ));
+ else if( m_interfaceButton->hasMouse( )) emit( displayHelp( "-e" ));
+ else if( m_interfaceCheckBox->hasMouse( )) emit( displayHelp( "-e" ));
+ else if( m_interfaceLineEdit->hasMouse( )) emit( displayHelp( "-e" ));
+ else if( m_maxSocketsCheckBox->hasMouse( )) emit( displayHelp( "-M" ));
+ else if( m_maxSocketsSpinBox->hasMouse( )) emit( displayHelp( "-M" ));
+ else if( m_randomIPCheckBox->hasMouse( )) emit( displayHelp( "-iR" ));
+ else if( m_randomIPSpinBox->hasMouse( )) emit( displayHelp( "-iR" ));
+ else if( m_sourceIPButton->hasMouse( )) emit( displayHelp( "-S" ));
+ else if( m_sourceIPCheckBox->hasMouse( )) emit( displayHelp( "-S" ));
+ else if( m_sourceIPLineEdit->hasMouse( )) emit( displayHelp( "-S" ));
+ else if( m_sourcePortCheckBox->hasMouse( )) emit( displayHelp( "--source_port" ));
+ else if( m_sourcePortSpinBox->hasMouse( )) emit( displayHelp( "--source_port" ));
+ else if( m_spoofMacButton->hasMouse( )) emit( displayHelp( "--spoof_mac" ));
+ else if( m_spoofMacCheckBox->hasMouse( )) emit( displayHelp( "--spoof_mac" ));
+ else if( m_spoofMacLineEdit->hasMouse( )) emit( displayHelp( "--spoof_mac" ));
+ else if( m_targetFileButton->hasMouse( )) emit( displayHelp( "-iL" ));
+ else if( m_targetFileCheckBox->hasMouse( )) emit( displayHelp( "-iL" ));
+ else if( m_targetFileLineEdit->hasMouse( )) emit( displayHelp( "-iL" ));
+ else if( m_ttlCheckBox->hasMouse( )) emit( displayHelp( "--ttl" ));
+ else if( m_ttlSpinBox->hasMouse( )) emit( displayHelp( "--ttl" ));
+ else emit( displayUnknown( ));
+}
diff --git a/src/compoundwidget.h b/src/compoundwidget.h
new file mode 100644
index 0000000..0522c74
--- /dev/null
+++ b/src/compoundwidget.h
@@ -0,0 +1,192 @@
+/***************************************************************************
+ * *
+ * Copyright (C) 2005, 2006 by Kevin Gilbert *
+ * kev.gilbert@cdu.edu.au *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ * *
+ ***************************************************************************/
+#ifndef _COMPOUNDWIDGET_H_
+#define _COMPOUNDWIDGET_H_
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <qwidget.h>
+#include "global.h"
+
+// forward class definitions
+// =========================
+
+class KConfig;
+class QCheckBox;
+class QLineEdit;
+class QPushButton;
+class QSpinBox;
+
+// CompountWidget class definition
+// ===============================
+
+class CompoundWidget : public QWidget
+{ Q_OBJECT
+
+ public:
+ CompoundWidget( QWidget* parent, const char* name = NULL );
+
+ void finaliseInitialisation( );
+ bool getOptions( bool& needRoot );
+ void readProfile( KConfig* config );
+ void saveProfile( KConfig* config );
+ void setInitialValues( );
+
+ bool dataDirState( ) const { return m_dataDirState; }
+ QString dataDirValue( ) const { return m_dataDirValue; }
+ bool dataLengthState( ) const { return m_dataLengthState; }
+ int dataLengthValue( ) const { return m_dataLengthValue; }
+ bool decoyState( ) const { return m_decoyState; }
+ QString decoyValue( ) const { return m_decoyValue; }
+ bool debugLevelState( ) const { return m_debugLevelState; }
+ int debugLevelValue( ) const { return m_debugLevelValue; }
+ bool excludeState( ) const { return m_excludeState; }
+ QString excludeValue( ) const { return m_excludeValue; }
+ bool excludeFileState( ) const { return m_excludeFileState; }
+ QString excludeFileValue( ) const { return m_excludeFileValue; }
+ bool fragmentLevelState( ) const { return m_fragmentLevelState; }
+ int fragmentLevelValue( ) const { return m_fragmentLevelValue; }
+ bool interfaceState( ) const { return m_interfaceState; }
+ QString interfaceValue( ) const { return m_interfaceValue; }
+ bool maxSocketsState( ) const { return m_maxSocketsState; }
+ int maxSocketsValue( ) const { return m_maxSocketsValue; }
+ bool randomIPState( ) const { return m_randomIPState; }
+ int randomIPValue( ) const { return m_randomIPValue; }
+ bool sourceIPState( ) const { return m_sourceIPState; }
+ QString sourceIPValue( ) const { return m_sourceIPValue; }
+ bool sourcePortState( ) const { return m_sourcePortState; }
+ int sourcePortValue( ) const { return m_sourcePortValue; }
+ bool spoofMacState( ) const { return m_spoofMacState; }
+ QString spoofMacValue( ) const { return m_spoofMacValue; }
+ bool targetFileState( ) const { return m_targetFileState; }
+ QString targetFileValue( ) const { return m_targetFileValue; }
+ bool ttlState( ) const { return m_ttlState; }
+ int ttlValue( ) const { return m_ttlValue; }
+
+ signals:
+ void displayDocBook( const QString& );
+ void displayHelp( const QString& );
+ void displayUnknown( );
+ void optionsDirty( );
+
+ private slots:
+ void slotDataDirButtonClicked( );
+ void slotDataDirCheckBoxClicked( );
+ void slotDataLengthCheckBoxClicked( );
+ void slotDebugLevelCheckBoxClicked( );
+ void slotDecoyButtonClicked( );
+ void slotDecoyCheckBoxClicked( );
+ void slotExcludeButtonClicked( );
+ void slotExcludeCheckBoxClicked( );
+ void slotExcludeFileButtonClicked( );
+ void slotExcludeFileCheckBoxClicked( );
+ void slotFragmentLevelCheckBoxClicked( );
+ void slotInterfaceButtonClicked( );
+ void slotInterfaceCheckBoxClicked( );
+ void slotMaxSocketsCheckBoxClicked( );
+ void slotRandomIPCheckBoxClicked( );
+ void slotSourceIPButtonClicked( );
+ void slotSourceIPCheckBoxClicked( );
+ void slotSourcePortCheckBoxClicked( );
+ void slotSpoofMACButtonClicked( );
+ void slotSpoofMacCheckBoxClicked( );
+ void slotTargetFileButtonClicked( );
+ void slotTargetFileCheckBoxClicked( );
+ void slotTTLCheckBoxClicked( );
+ void slotWhatsThisClicked( );
+
+ private:
+ void createLayout( );
+
+ QPushButton* m_dataDirButton;
+ QCheckBox* m_dataDirCheckBox;
+ QLineEdit* m_dataDirLineEdit;
+ bool m_dataDirState;
+ QString m_dataDirValue;
+ QCheckBox* m_dataLengthCheckBox;
+ QSpinBox* m_dataLengthSpinBox;
+ bool m_dataLengthState;
+ int m_dataLengthValue;
+ QPushButton* m_decoyButton;
+ QCheckBox* m_decoyCheckBox;
+ QLineEdit* m_decoyLineEdit;
+ bool m_decoyState;
+ QString m_decoyValue;
+ QCheckBox* m_debugLevelCheckBox;
+ QSpinBox* m_debugLevelSpinBox;
+ bool m_debugLevelState;
+ int m_debugLevelValue;
+ QPushButton* m_excludeButton;
+ QCheckBox* m_excludeCheckBox;
+ QLineEdit* m_excludeLineEdit;
+ bool m_excludeState;
+ QString m_excludeValue;
+ QPushButton* m_excludeFileButton;
+ QCheckBox* m_excludeFileCheckBox;
+ QLineEdit* m_excludeFileLineEdit;
+ bool m_excludeFileState;
+ QString m_excludeFileValue;
+ QCheckBox* m_fragmentLevelCheckBox;
+ QSpinBox* m_fragmentLevelSpinBox;
+ bool m_fragmentLevelState;
+ int m_fragmentLevelValue;
+ QPushButton* m_interfaceButton;
+ QCheckBox* m_interfaceCheckBox;
+ QLineEdit* m_interfaceLineEdit;
+ bool m_interfaceState;
+ QString m_interfaceValue;
+ QCheckBox* m_maxSocketsCheckBox;
+ QSpinBox* m_maxSocketsSpinBox;
+ bool m_maxSocketsState;
+ int m_maxSocketsValue;
+ QCheckBox* m_randomIPCheckBox;
+ QSpinBox* m_randomIPSpinBox;
+ bool m_randomIPState;
+ int m_randomIPValue;
+ QPushButton* m_sourceIPButton;
+ QCheckBox* m_sourceIPCheckBox;
+ QLineEdit* m_sourceIPLineEdit;
+ bool m_sourceIPState;
+ QString m_sourceIPValue;
+ QCheckBox* m_sourcePortCheckBox;
+ QSpinBox* m_sourcePortSpinBox;
+ bool m_sourcePortState;
+ int m_sourcePortValue;
+ QPushButton* m_spoofMacButton;
+ QCheckBox* m_spoofMacCheckBox;
+ QLineEdit* m_spoofMacLineEdit;
+ bool m_spoofMacState;
+ QString m_spoofMacValue;
+ QPushButton* m_targetFileButton;
+ QCheckBox* m_targetFileCheckBox;
+ QLineEdit* m_targetFileLineEdit;
+ bool m_targetFileState;
+ QString m_targetFileValue;
+ QCheckBox* m_ttlCheckBox;
+ QSpinBox* m_ttlSpinBox;
+ bool m_ttlState;
+ int m_ttlValue;
+};
+
+#endif // _COMPOUNDWIDGET_H_
diff --git a/src/global.h b/src/global.h
new file mode 100644
index 0000000..df039df
--- /dev/null
+++ b/src/global.h
@@ -0,0 +1,60 @@
+/***************************************************************************
+ * *
+ * Copyright (C) 2005, 2006 by Kevin Gilbert *
+ * kev.gilbert@cdu.edu.au *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ * *
+ ***************************************************************************/
+
+#ifndef _GLOBAL_H_
+#define _GLOBAL_H_
+
+// forward class definitions
+// =========================
+
+class NmapOutputBuffer;
+class ScanMonitorEvent;
+
+// typedef's
+// =========
+
+typedef bool* boolPtr;
+typedef unsigned char byte;
+typedef NmapOutputBuffer* nobPtr;
+typedef ScanMonitorEvent* smePtr;
+typedef char* string;
+typedef unsigned short ushort;
+typedef unsigned int uint;
+
+// macros
+// ======
+
+#define _max_( a, b ) (a > b ? a : b)
+#define _min_( a, b ) (a < b ? a : b)
+
+// general shit
+// ============
+
+const char DEFAULT_PROFILE[] = "Knmap_Default"; // bloody obvious
+const char DEFAULT_SCAN_NAME[] = "Target host"; // used to auto-name scan widgets
+const char DOCBOOK[] = "docbook"; // used to determine if documentation exists in the nmap html widget
+const byte MAX_HOST_HISTORY = 10; // the maximum number of hosts that we will remember
+const char PROFILE_PREFIX[] = "Knmap_"; // wot's in the from of all our profile names
+const uint ZOOM_MAX_FACTOR = 300; // for the HTML page
+const uint ZOOM_MIN_FACTOR = 20; // for the HTML page
+
+#endif // _GLOBAL_H_
diff --git a/src/hi16-app-knmap.png b/src/hi16-app-knmap.png
new file mode 100644
index 0000000..aa02743
--- /dev/null
+++ b/src/hi16-app-knmap.png
Binary files differ
diff --git a/src/hi16-app-knmapman.png b/src/hi16-app-knmapman.png
new file mode 100644
index 0000000..8f837f5
--- /dev/null
+++ b/src/hi16-app-knmapman.png
Binary files differ
diff --git a/src/hi16-app-localman.png b/src/hi16-app-localman.png
new file mode 100644
index 0000000..dc630e5
--- /dev/null
+++ b/src/hi16-app-localman.png
Binary files differ
diff --git a/src/hi16-app-manpage.png b/src/hi16-app-manpage.png
new file mode 100644
index 0000000..ffae697
--- /dev/null
+++ b/src/hi16-app-manpage.png
Binary files differ
diff --git a/src/hi16-app-manstylesheet.png b/src/hi16-app-manstylesheet.png
new file mode 100644
index 0000000..1033ef6
--- /dev/null
+++ b/src/hi16-app-manstylesheet.png
Binary files differ
diff --git a/src/hi16-app-profilecopy.png b/src/hi16-app-profilecopy.png
new file mode 100644
index 0000000..df277b8
--- /dev/null
+++ b/src/hi16-app-profilecopy.png
Binary files differ
diff --git a/src/hi16-app-profiledelete.png b/src/hi16-app-profiledelete.png
new file mode 100644
index 0000000..d4edad5
--- /dev/null
+++ b/src/hi16-app-profiledelete.png
Binary files differ
diff --git a/src/hi16-app-profileload.png b/src/hi16-app-profileload.png
new file mode 100644
index 0000000..95b4d72
--- /dev/null
+++ b/src/hi16-app-profileload.png
Binary files differ
diff --git a/src/hi16-app-profilerename.png b/src/hi16-app-profilerename.png
new file mode 100644
index 0000000..1230120
--- /dev/null
+++ b/src/hi16-app-profilerename.png
Binary files differ
diff --git a/src/hi16-app-profilesave.png b/src/hi16-app-profilesave.png
new file mode 100644
index 0000000..ab04a11
--- /dev/null
+++ b/src/hi16-app-profilesave.png
Binary files differ
diff --git a/src/hi16-app-profilesaveas.png b/src/hi16-app-profilesaveas.png
new file mode 100644
index 0000000..42e9541
--- /dev/null
+++ b/src/hi16-app-profilesaveas.png
Binary files differ
diff --git a/src/hi16-app-scanclose.png b/src/hi16-app-scanclose.png
new file mode 100644
index 0000000..16f5ced
--- /dev/null
+++ b/src/hi16-app-scanclose.png
Binary files differ
diff --git a/src/hi16-app-scanduplicate.png b/src/hi16-app-scanduplicate.png
new file mode 100644
index 0000000..e8e2d2c
--- /dev/null
+++ b/src/hi16-app-scanduplicate.png
Binary files differ
diff --git a/src/hi16-app-scannew.png b/src/hi16-app-scannew.png
new file mode 100644
index 0000000..358192f
--- /dev/null
+++ b/src/hi16-app-scannew.png
Binary files differ
diff --git a/src/hi16-app-scanrename.png b/src/hi16-app-scanrename.png
new file mode 100644
index 0000000..94cc109
--- /dev/null
+++ b/src/hi16-app-scanrename.png
Binary files differ
diff --git a/src/hi16-app-zoomcustom.png b/src/hi16-app-zoomcustom.png
new file mode 100644
index 0000000..b78a6fd
--- /dev/null
+++ b/src/hi16-app-zoomcustom.png
Binary files differ
diff --git a/src/hi16-app-zoomin.png b/src/hi16-app-zoomin.png
new file mode 100644
index 0000000..1c8a729
--- /dev/null
+++ b/src/hi16-app-zoomin.png
Binary files differ
diff --git a/src/hi16-app-zoomout.png b/src/hi16-app-zoomout.png
new file mode 100644
index 0000000..1ca95a1
--- /dev/null
+++ b/src/hi16-app-zoomout.png
Binary files differ
diff --git a/src/hi32-app-knmap.png b/src/hi32-app-knmap.png
new file mode 100644
index 0000000..6f5f704
--- /dev/null
+++ b/src/hi32-app-knmap.png
Binary files differ
diff --git a/src/hi32-app-knmapman.png b/src/hi32-app-knmapman.png
new file mode 100644
index 0000000..6676bca
--- /dev/null
+++ b/src/hi32-app-knmapman.png
Binary files differ
diff --git a/src/hi32-app-localman.png b/src/hi32-app-localman.png
new file mode 100644
index 0000000..1880b42
--- /dev/null
+++ b/src/hi32-app-localman.png
Binary files differ
diff --git a/src/hi32-app-manpage.png b/src/hi32-app-manpage.png
new file mode 100644
index 0000000..136ad48
--- /dev/null
+++ b/src/hi32-app-manpage.png
Binary files differ
diff --git a/src/hi32-app-manstylesheet.png b/src/hi32-app-manstylesheet.png
new file mode 100644
index 0000000..6ab6e65
--- /dev/null
+++ b/src/hi32-app-manstylesheet.png
Binary files differ
diff --git a/src/hi32-app-profilecopy.png b/src/hi32-app-profilecopy.png
new file mode 100644
index 0000000..22924a0
--- /dev/null
+++ b/src/hi32-app-profilecopy.png
Binary files differ
diff --git a/src/hi32-app-profiledelete.png b/src/hi32-app-profiledelete.png
new file mode 100644
index 0000000..9cbf9b9
--- /dev/null
+++ b/src/hi32-app-profiledelete.png
Binary files differ
diff --git a/src/hi32-app-profileload.png b/src/hi32-app-profileload.png
new file mode 100644
index 0000000..0bccbc8
--- /dev/null
+++ b/src/hi32-app-profileload.png
Binary files differ
diff --git a/src/hi32-app-profilerename.png b/src/hi32-app-profilerename.png
new file mode 100644
index 0000000..9a2e404
--- /dev/null
+++ b/src/hi32-app-profilerename.png
Binary files differ
diff --git a/src/hi32-app-profilesave.png b/src/hi32-app-profilesave.png
new file mode 100644
index 0000000..9cee0cd
--- /dev/null
+++ b/src/hi32-app-profilesave.png
Binary files differ
diff --git a/src/hi32-app-profilesaveas.png b/src/hi32-app-profilesaveas.png
new file mode 100644
index 0000000..8cd6cd2
--- /dev/null
+++ b/src/hi32-app-profilesaveas.png
Binary files differ
diff --git a/src/hi32-app-scanclose.png b/src/hi32-app-scanclose.png
new file mode 100644
index 0000000..7b8106e
--- /dev/null
+++ b/src/hi32-app-scanclose.png
Binary files differ
diff --git a/src/hi32-app-scanduplicate.png b/src/hi32-app-scanduplicate.png
new file mode 100644
index 0000000..79deac9
--- /dev/null
+++ b/src/hi32-app-scanduplicate.png
Binary files differ
diff --git a/src/hi32-app-scannew.png b/src/hi32-app-scannew.png
new file mode 100644
index 0000000..ae84d87
--- /dev/null
+++ b/src/hi32-app-scannew.png
Binary files differ
diff --git a/src/hi32-app-scanrename.png b/src/hi32-app-scanrename.png
new file mode 100644
index 0000000..4a686ac
--- /dev/null
+++ b/src/hi32-app-scanrename.png
Binary files differ
diff --git a/src/hi32-app-zoomcustom.png b/src/hi32-app-zoomcustom.png
new file mode 100644
index 0000000..f96cf7e
--- /dev/null
+++ b/src/hi32-app-zoomcustom.png
Binary files differ
diff --git a/src/hi32-app-zoomin.png b/src/hi32-app-zoomin.png
new file mode 100644
index 0000000..3d11785
--- /dev/null
+++ b/src/hi32-app-zoomin.png
Binary files differ
diff --git a/src/hi32-app-zoomout.png b/src/hi32-app-zoomout.png
new file mode 100644
index 0000000..20d6b40
--- /dev/null
+++ b/src/hi32-app-zoomout.png
Binary files differ
diff --git a/src/htmlwidget.cpp b/src/htmlwidget.cpp
new file mode 100644
index 0000000..aea1ff7
--- /dev/null
+++ b/src/htmlwidget.cpp
@@ -0,0 +1,366 @@
+/***************************************************************************
+ * *
+ * Copyright (C) 2005, 2006 by Kevin Gilbert *
+ * kev.gilbert@cdu.edu.au *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ * *
+ ***************************************************************************/
+
+#include <qfile.h>
+#include <qtextstream.h>
+
+#include <kapplication.h>
+#include <kconfig.h>
+#include <kdebug.h>
+#include <khtml_part.h>
+#include <khtmlview.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+#include <kprocess.h>
+#include <kstandarddirs.h>
+
+#include "htmlwidget.h"
+#include "knmap.h"
+#include "stylesheetdialog.h"
+
+const float HTMLWidget::m_zoomIncrement = 25;
+
+// constructor
+// ===========
+
+HTMLWidget::HTMLWidget( QStringList* stylesheetURLs, QWidget* parent, const char* name )
+: QWidget( parent, name ),
+ m_dlg( NULL ),
+ m_process( NULL ),
+ m_stylesheetURLs( stylesheetURLs ),
+ m_zoomFactor( 100 )
+{ m_htmlPart = new KHTMLPart( this, "html part" );
+ m_htmlPart->setOnlyLocalReferences( true );
+}
+
+// destructor
+// ==========
+
+HTMLWidget::~HTMLWidget( )
+{ if( m_dlg != NULL )
+ delete m_dlg;
+
+ if( m_process != NULL )
+ delete m_process;
+}
+
+// gotoAnchor
+// ==========
+
+void HTMLWidget::gotoAnchor( const QString& anchor )
+{ if( !m_htmlPart->gotoAnchor( anchor ))
+ KMessageBox::sorry( this, i18n( "There does not appear to be ANY help available for the item you requested.\nSorry! Now piss off and stop bothering me.\nYou stink.\nYou've got bad breath.\nYour ugly.\nNobody loves you.\nNow for your bad points..." ), i18n( "No help available in Knmap page" ));
+}
+
+// loadKnmapManPage
+// ================
+
+void HTMLWidget::loadKnmapManPage( )
+{ if( !tryKnmapFile( ))
+ { m_htmlPart->begin( );
+ m_htmlPart->write( i18n( "<h1 align=center>Missing File</h1>" ));
+ m_htmlPart->write( i18n( "<p align=center>The file <b>knmap/nmap_manpage.html</b>, which is part of the <i>Knmap</i> package, could not be found." ));
+ m_htmlPart->write(i18n( "<p align=center>As a result, the prepackaged <code>man</code> page for <i>Knmap</i> is not available." ));
+ m_htmlPart->write( i18n( "<p align=center>You may be able to view your local <code>man</code> page for <i>nmap</i> by selecting <b>Settings / Use local man page</b>" ));
+ m_htmlPart->end( );
+ }
+
+ m_htmlPart->setUserStyleSheet( m_stylesheetURL );
+ m_htmlPart->setZoomFactor( int( m_zoomFactor ));
+}
+
+// loadLocalManPage
+// ================
+
+void HTMLWidget::loadLocalManPage( )
+{ m_process = new KProcess( );
+ *m_process << "man";
+ *m_process << "-w";
+ *m_process << "nmap";
+
+ connect( m_process, SIGNAL( processExited( KProcess* )), SLOT( slotManProcessExited( )));
+ connect( m_process, SIGNAL( receivedStdout( KProcess*, char*, int )), SLOT( slotManReceivedStdout( KProcess*, char*, int )));
+
+ m_manPagePath = QString::null;
+ m_process->start( KProcess::NotifyOnExit, KProcess::Stdout );
+}
+
+// loadManPage
+// ===========
+
+void HTMLWidget::loadManPage( const bool localManPage )
+{ if( localManPage )
+ loadLocalManPage( );
+ else
+ loadKnmapManPage( );
+}
+
+// readSettings
+// ============
+
+void HTMLWidget::readSettings( )
+{ KConfig* config = kapp->config( );
+ config->setGroup( "General" );
+ m_zoomFactor = config->readDoubleNumEntry( "zoomFactor", 100.0 );
+ m_stylesheetURL.setPath( config->readPathEntry( "stylesheetURL" ));
+}
+
+// resizeEvent
+// ===========
+
+void HTMLWidget::resizeEvent( QResizeEvent* event )
+{ QWidget::resizeEvent( event );
+ m_htmlPart->view( )->resize( width( ), height( ));
+}
+
+// saveSettings
+// ============
+
+void HTMLWidget::saveSettings( )
+{ KConfig* config = kapp->config( );
+ config->setGroup( "General" );
+ config->writeEntry( "stylesheetURL", m_stylesheetURL.path( ));
+ config->writeEntry( "zoomFactor", m_zoomFactor );
+}
+
+// setInitialValues
+// ================
+
+void HTMLWidget::setInitialValues( )
+{ m_htmlPart->setUserStyleSheet( m_stylesheetURL );
+ m_htmlPart->setZoomFactor( int( m_zoomFactor ));
+}
+
+// setStylesheet
+// =============
+
+void HTMLWidget::setStylesheet( )
+{ m_dlg = new StylesheetDialog( m_stylesheetURL.path( ), *m_stylesheetURLs, this, "man stylesheet dlg" );
+ connect( m_dlg, SIGNAL( stylesheetRemoved( )), SLOT( slotStylesheetRemoved( )));
+
+ if( m_dlg->exec( ) != QDialog::Accepted )
+ { delete m_dlg;
+ m_dlg = NULL;
+ return;
+ }
+
+ *m_stylesheetURLs = m_dlg->stylesheetURLs( );
+ m_stylesheetURL.setPath( m_stylesheetURLs->front( ));
+ m_htmlPart->setUserStyleSheet( m_stylesheetURL );
+
+ emit( optionsDirty( ));
+ delete m_dlg;
+ m_dlg = NULL;
+}
+
+// slotGunzipProcessExited
+// =======================
+
+void HTMLWidget::slotGunzipProcessExited( )
+{ if( !m_process->normalExit( ))
+ { delete m_process;
+ m_process = NULL;
+ emit( errorLoadingLocalManPage( i18n( "Could not load the local 'man' page - the 'gunzip' process failed." )));
+ return;
+ }
+
+ delete m_process;
+
+ m_process = new KProcess( );
+ *m_process << "man2html";
+ *m_process << "-";
+
+ connect( m_process, SIGNAL( processExited( KProcess* )), SLOT( slotMan2HTMLProcessExited( )));
+ connect( m_process, SIGNAL( receivedStdout( KProcess*, char*, int )), SLOT( slotMan2HTMLReceivedStdout( KProcess*, char*, int )));
+
+ m_htmlData = QString::null;
+ m_process->start( KProcess::NotifyOnExit, KProcess::Communication( KProcess::Stdin | KProcess::Stdout ));
+ m_process->writeStdin( m_manPageData, m_manPageData.length( ));
+ m_process->closeStdin( );
+}
+
+// slotGunzipReceivedStdout
+// ========================
+
+void HTMLWidget::slotGunzipReceivedStdout( KProcess* /* process */, char* buffer, int buflen )
+{ m_manPageData += QString::fromLatin1( buffer, buflen );
+}
+
+// slotMan2HTMLReceivedStdout
+// ==========================
+
+void HTMLWidget::slotMan2HTMLReceivedStdout( KProcess* /* process */, char* buffer, int buflen )
+{ m_htmlData += QString::fromLatin1( buffer, buflen );
+}
+
+// slotMan2HTMLProcessExited
+// =========================
+
+void HTMLWidget::slotMan2HTMLProcessExited( )
+{ if( !m_process->normalExit( ))
+ emit( errorLoadingLocalManPage( i18n( "Could not load the local 'man' page - the 'man2html' process failed." )));
+
+ delete m_process;
+ m_process = NULL;
+
+ m_htmlPart->begin( );
+ QTextStream textStream( &m_htmlData, IO_ReadOnly );
+
+ while( !textStream.atEnd( ))
+ { QString htmlLine = textStream.readLine( );
+
+ if( htmlLine.startsWith( "<H2>TARGET SPECIFICATION</H2>" ))
+ m_htmlPart->write( "<a id='target'>" );
+ else
+ if( htmlLine.startsWith( "<DT><B>-" ))
+ { QStringList nmapOptions = QStringList::split( " ", htmlLine.right( htmlLine.length( ) - 7 ));
+ QString anchors;
+
+ for( QStringList::Iterator it = nmapOptions.begin( ); it != nmapOptions.end( ); ++it )
+ { if( (*it)[ 0 ] != '-' )
+ break;
+
+ QStringList nmapOption = QStringList::split( "<", *it );
+ anchors += QString( "<a id='%1'>" ).arg( nmapOption.front( ));
+ }
+
+ m_htmlPart->write( anchors );
+ }
+
+ m_htmlPart->write( htmlLine + "\n" );
+ }
+
+ m_htmlPart->end( );
+
+ m_htmlPart->setUserStyleSheet( m_stylesheetURL );
+ m_htmlPart->setZoomFactor( int( m_zoomFactor ));
+}
+
+// slotManProcessExited
+// ====================
+
+void HTMLWidget::slotManProcessExited( )
+{
+ if( !m_process->normalExit( ))
+ { delete m_process;
+ m_process = NULL;
+ emit( errorLoadingLocalManPage( i18n( "Could not load the local 'man' page - the 'man -w' process failed." )));
+ return;
+ }
+
+ delete m_process;
+ ushort length = m_manPagePath.length( );
+
+ if( m_manPagePath[ length - 1 ] == '\n' )
+ m_manPagePath = m_manPagePath.left( length - 1 );
+
+ if( !m_manPagePath.endsWith( ".gz" ))
+ { m_process = NULL;
+ emit( errorLoadingLocalManPage( i18n( "Could not load the local 'man' page - it either was not found or it not a 'gz' file." )));
+ return;
+ }
+
+ m_process = new KProcess( );
+ *m_process << "gunzip";
+ *m_process << "-c";
+ *m_process << m_manPagePath;
+
+ connect( m_process, SIGNAL( processExited( KProcess* )), SLOT( slotGunzipProcessExited( )));
+ connect( m_process, SIGNAL( receivedStdout( KProcess*, char*, int )), SLOT( slotGunzipReceivedStdout( KProcess*, char*, int )));
+
+ m_manPageData = QString::null;
+ m_process->start( KProcess::NotifyOnExit, KProcess::Stdout );
+}
+
+// slotManReceivedStdout
+// =====================
+
+void HTMLWidget::slotManReceivedStdout( KProcess* /* process */, char* buffer, int buflen )
+{ m_manPagePath += QString::fromLatin1( buffer, buflen );
+}
+
+// slotStylesheetRemoved
+// =====================
+
+void HTMLWidget::slotStylesheetRemoved( )
+{ *m_stylesheetURLs = m_dlg->stylesheetURLs( );
+ emit( optionsDirty( ));
+}
+
+// tryKnmapFile
+// ============
+
+bool HTMLWidget::tryKnmapFile( )
+{
+#ifdef _DEBUG
+ QString path = "/home/c/knmap/src/nmap_manpage.html";
+#else
+ QString path = locate( "data", "knmap/nmap_manpage.html" );
+#endif
+
+ if( !QFile::exists( path ))
+ return false;
+
+ QFile manPageFile( path );
+
+ if( !manPageFile.open( IO_ReadOnly ))
+ return false;
+
+ QTextStream manPageStream( &manPageFile );
+ m_htmlPart->begin( );
+
+ while ( !manPageStream.atEnd( ))
+ { QString line = manPageStream.read( );
+ m_htmlPart->write( line );
+ }
+
+ m_htmlPart->end( );
+ manPageFile.close();
+
+ return true;
+}
+
+// zoomFactor
+// ==========
+
+void HTMLWidget::zoomFactor( const float factor )
+{ m_zoomFactor = factor;
+ m_htmlPart->setZoomFactor( int( m_zoomFactor ));
+ emit( optionsDirty( ));
+}
+// zoomIn
+// ======
+
+void HTMLWidget::zoomIn( )
+{ m_zoomFactor = _min_( ZOOM_MAX_FACTOR, m_zoomFactor + m_zoomIncrement );
+ m_htmlPart->setZoomFactor( int( m_zoomFactor ));
+ emit( optionsDirty( ));
+}
+
+// zoomOut
+// =======
+
+void HTMLWidget::zoomOut( )
+{ m_zoomFactor = _max_( ZOOM_MIN_FACTOR, m_zoomFactor - m_zoomIncrement );
+ m_htmlPart->setZoomFactor( int( m_zoomFactor ));
+ emit( optionsDirty( ));
+}
diff --git a/src/htmlwidget.h b/src/htmlwidget.h
new file mode 100644
index 0000000..996d63e
--- /dev/null
+++ b/src/htmlwidget.h
@@ -0,0 +1,95 @@
+/***************************************************************************
+ * *
+ * Copyright (C) 2005, 2006 by Kevin Gilbert *
+ * kev.gilbert@cdu.edu.au *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ * *
+ ***************************************************************************/
+
+#ifndef _HTMLWIDGET_H_
+#define _HTMLWIDGET_H_
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <qstringlist.h>
+#include <qwidget.h>
+#include <kurl.h>
+#include "global.h"
+
+// forward class definitions
+// =========================
+
+class KHTMLPart;
+class KProcess;
+class StylesheetDialog;
+
+// HTMLWidget class definition
+// ===========================
+
+
+class HTMLWidget : public QWidget
+{ Q_OBJECT
+
+ public:
+ HTMLWidget( QStringList* stylesheetURLs, QWidget* parent = NULL, const char* name = NULL );
+ virtual ~HTMLWidget( );
+
+ void gotoAnchor( const QString& anchor );
+ void loadManPage( const bool localManPage );
+ void readSettings( );
+ void saveSettings( );
+ void setInitialValues( );
+ void setStylesheet( );
+ float zoomFactor( ) const { return m_zoomFactor; }
+ void zoomFactor( const float factor );
+ void zoomIn( );
+ void zoomOut( );
+
+ signals:
+ void errorLoadingLocalManPage( const QString& );
+ void optionsDirty( );
+
+ private slots:
+ void slotGunzipProcessExited( );
+ void slotGunzipReceivedStdout( KProcess* process, char* buffer, int buflen );
+ void slotMan2HTMLProcessExited( );
+ void slotMan2HTMLReceivedStdout( KProcess* process, char* buffer, int buflen );
+ void slotManProcessExited( );
+ void slotManReceivedStdout( KProcess* process, char* buffer, int buflen );
+ void slotStylesheetRemoved( );
+
+ private:
+ void loadKnmapManPage( );
+ void loadLocalManPage( );
+ void resizeEvent( QResizeEvent* event );
+ bool tryKnmapFile( );
+
+ StylesheetDialog* m_dlg;
+ QString m_htmlData;
+ KHTMLPart* m_htmlPart;
+ QString m_manPageData;
+ QString m_manPagePath;
+ KProcess* m_process;
+ KURL m_stylesheetURL;
+ QStringList* m_stylesheetURLs;
+ float m_zoomFactor;
+ static const float m_zoomIncrement;
+};
+
+#endif // _HTMLWIDGET_H_
diff --git a/src/indexwidget.cpp b/src/indexwidget.cpp
new file mode 100644
index 0000000..9c2f8ff
--- /dev/null
+++ b/src/indexwidget.cpp
@@ -0,0 +1,273 @@
+/***************************************************************************
+ * *
+ * Copyright (C) 2005, 2006 by Kevin Gilbert *
+ * kev.gilbert@cdu.edu.au *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ * *
+ ***************************************************************************/
+
+#include <qdragobject.h>
+#include <qfontmetrics.h>
+#include <qpainter.h>
+#include <qpopupmenu.h>
+#include <qtimer.h>
+
+#include <kapplication.h>
+#include <kconfig.h>
+#include <kdebug.h>
+#include <kglobal.h>
+#include <kglobalsettings.h>
+#include <kiconloader.h>
+#include <klocale.h>
+
+#include "global.h"
+#include "indexwidget.h"
+#include "mainwidget.h"
+#include "scanstack.h"
+#include "scanwidget.h"
+
+// constructor
+// ===========
+
+IndexWidget::IndexWidget( ScanStack* scanStack, MainWidget* parent, const char* name )
+: QScrollView( parent, name ),
+ m_blinkTimer( NULL ),
+ m_scanCount( 0 ),
+ m_scanStack( scanStack )
+{ setDragAutoScroll( true );
+ viewport( )->setAcceptDrops( true );
+}
+
+// calculateIndex
+// ==============
+
+short IndexWidget::calculateIndex( const ushort y )
+{ QFontMetrics metrics = fontMetrics( );
+ byte height = metrics.height( );
+ ushort index = y / height;
+
+ return index > m_scanStack->count( ) - 1 ? -1 : index;
+}
+
+// contentsContextMenuEvent
+// ========================
+
+void IndexWidget::contentsContextMenuEvent( QContextMenuEvent* event )
+{ short index = calculateIndex( event->y( ));
+
+ if( index < 0 )
+ return;
+
+ ScanWidget* scanWidget = m_scanStack->makeScanWidgetVisible( index );
+ emit( visibleScanWidgetChanged( scanWidget ));
+
+ QPopupMenu* contextMenu = new QPopupMenu( this, "context menu" );
+ KIconLoader* iconLoader = KGlobal::iconLoader( );
+ QIconSet profileLoad = iconLoader->loadIconSet( "profileload", KIcon::Small );
+ QIconSet profileSave = iconLoader->loadIconSet( "profilesave", KIcon::Small );
+ QIconSet profileSaveAs = iconLoader->loadIconSet( "profilesaveas", KIcon::Small );
+ QIconSet scanClose = iconLoader->loadIconSet( "scanclose", KIcon::Small );
+ QIconSet scanDuplicate = iconLoader->loadIconSet( "scanduplicate", KIcon::Small );
+ QIconSet scanNew = iconLoader->loadIconSet( "scannew", KIcon::Small );
+ QIconSet scanRename = iconLoader->loadIconSet( "scanrename", KIcon::Small );
+
+ contextMenu->insertItem( scanClose, i18n( "&Close scan" ), parent( ), SLOT( slotScanClose( )), CTRL+Key_W );
+ contextMenu->insertItem( scanDuplicate, i18n( "&Duplicate scan" ), parent( ), SLOT( slotScanDuplicate( )), CTRL+Key_C );
+ contextMenu->insertItem( scanNew, i18n( "&New scan..." ), parent( ), SLOT( slotScanNew( )), CTRL+Key_N );
+ contextMenu->insertItem( scanRename, i18n( "&Rename scan..." ), parent( ), SLOT( slotScanRename( )), Key_F2 );
+ contextMenu->insertItem( i18n( "&Use target host name" ), parent( ), SLOT( slotUseTargetHost( )));
+ contextMenu->insertSeparator( );
+ contextMenu->insertItem( profileLoad, i18n( "&Load profile..." ), parent( ), SLOT( slotProfileLoad( )));
+ contextMenu->insertItem( profileSave, i18n( "&Save profile..." ), parent( ), SLOT( slotProfileSave( )));
+ contextMenu->insertItem( profileSaveAs, i18n( "&Save profile as..." ), parent( ), SLOT( slotProfileSaveAs( )));
+
+ contextMenu->exec( event->globalPos( ));
+}
+
+// contentsDragMoveEvent
+// =====================
+
+void IndexWidget::contentsDragMoveEvent( QDragMoveEvent* event )
+{ short index = calculateIndex( event->pos( ).y( ));
+ index = index < 0 ? m_scanStack->count( ) - 1 : index;
+
+ ScanWidget* scanWidget = m_scanStack->makeScanWidgetVisible( index );
+ emit( visibleScanWidgetChanged( scanWidget ));
+}
+
+// contentsMouseMoveEvent
+// ======================
+
+void IndexWidget::contentsMouseMoveEvent( QMouseEvent* event )
+{ if( event->stateAfter( ) != Qt::LeftButton )
+ return;
+
+ short index = calculateIndex( event->y( ));
+
+ if( index < 0 )
+ return;
+
+ QStoredDrag* drag = new QStoredDrag( "application/octet-stream", this );
+ drag->dragMove( );
+ ScanWidget* scanWidget = m_scanStack->moveScanWidget( index );
+
+ scanWidget->ignoreTabChanges( true );
+ m_scanStack->raiseWidget( scanWidget );
+ scanWidget->ignoreTabChanges( false );
+
+ emit( visibleScanWidgetChanged( scanWidget ));
+}
+
+// contentsMousePressEvent
+// =======================
+
+void IndexWidget::contentsMousePressEvent( QMouseEvent* event )
+{ if( event->stateAfter( ) != Qt::LeftButton )
+ return;
+
+ short index = calculateIndex( event->y( ));
+
+ if( index < 0 )
+ return;
+
+ ScanWidget* scanWidget = m_scanStack->makeScanWidgetVisible( index );
+ emit( visibleScanWidgetChanged( scanWidget ));
+
+ if( scanWidget->state( ) == ScanWidget::finished )
+ scanWidget->state( ScanWidget::dormant );
+}
+
+// drawContents
+// ============
+
+void IndexWidget::drawContents( QPainter* painter, int clipx, int clipy, int clipw, int cliph )
+{ painter->fillRect( clipx, clipy, clipw, cliph, KGlobalSettings::baseColor( ));
+ painter->setBackgroundMode( Qt::OpaqueMode );
+
+ QFontMetrics metrics = fontMetrics( );
+ byte height = metrics.height( );
+ byte aWidth2 = 2 * metrics.width( "*" );
+ ushort x = height / 2;
+ ushort xMax = 0;
+ ushort y = 0;
+ ushort i;
+
+ for( m_scanStack->resetScanWidgets( i ); m_scanStack->moreScanWidgets( i ); y += height, m_scanStack->nextScanWidget( i ))
+ { ScanWidget* scanWidget = m_scanStack->currentScanWidget( i );
+
+ switch( scanWidget->state( ))
+ { case ScanWidget::dormant:
+ if( m_scanStack->isVisibleWidget( scanWidget ))
+ { painter->fillRect( 0, y, visibleWidth( ), height, KGlobalSettings::alternateBackgroundColor( ));
+ painter->setBackgroundColor( KGlobalSettings::alternateBackgroundColor( ));
+ painter->setPen( KGlobalSettings::buttonTextColor( ));
+ break;
+ }
+
+ painter->setBackgroundColor( KGlobalSettings::baseColor( ));
+ painter->setPen( KGlobalSettings::buttonTextColor( ));
+ break;
+
+ case ScanWidget::finished:
+ painter->fillRect( 0, y, visibleWidth( ), height, KGlobalSettings::highlightColor( ));
+ painter->setBackgroundColor( KGlobalSettings::highlightColor( ));
+ painter->setPen( KGlobalSettings::activeTextColor( ));
+ break;
+
+ case ScanWidget::running:
+ if( m_highlight )
+ { painter->fillRect( 0, y, visibleWidth( ), height, KGlobalSettings::highlightColor( ));
+ painter->setBackgroundColor( KGlobalSettings::highlightColor( ));
+ painter->setPen( KGlobalSettings::activeTextColor( ));
+ break;
+ }
+
+ if( m_scanStack->isVisibleWidget( scanWidget ))
+ { painter->fillRect( 0, y, visibleWidth( ), height, KGlobalSettings::alternateBackgroundColor( ));
+ painter->setBackgroundColor( KGlobalSettings::alternateBackgroundColor( ));
+ painter->setPen( KGlobalSettings::buttonTextColor( ));
+ break;
+ }
+
+ painter->fillRect( 0, y, visibleWidth( ), height, KGlobalSettings::baseColor( ));
+ painter->setBackgroundColor( KGlobalSettings::baseColor( ));
+ painter->setPen( KGlobalSettings::buttonTextColor( ));
+ break;
+ }
+
+ if( scanWidget->useTargetHost( ))
+ painter->drawText( x, y + metrics.ascent( ), "*" );
+
+ painter->drawText( x + aWidth2, y + metrics.ascent( ), scanWidget->scanName( ));
+ xMax = _max_( xMax, x + aWidth2 + metrics.width( scanWidget->scanName( )));
+ }
+
+ if( m_scanCount )
+ m_highlight = !m_highlight;
+
+ resizeContents( xMax + height / 2, y );
+}
+
+// ensureCurrentVisible
+// ====================
+
+void IndexWidget::ensureCurrentVisible( )
+{ short index = m_scanStack->indexOfVisibleScanWidget( );
+
+ if( index < 0 )
+ return;
+
+ QFontMetrics metrics = fontMetrics( );
+ short y = index * metrics.height( ) - height( ) / 2;
+ setContentsPos( 0, y );
+ updateContents( );
+}
+
+// ensureCurrentVisible
+// ====================
+
+void IndexWidget::slotRepaint( )
+{ repaintContents( false );
+}
+
+// slotScanStarted
+// ===============
+
+void IndexWidget::slotScanStarted( )
+{ if( m_scanCount++ )
+ return;
+
+ ASSERT( m_blinkTimer == NULL );
+ m_blinkTimer = new QTimer( this );
+ connect( m_blinkTimer, SIGNAL( timeout( )), SLOT( slotRepaint( )));
+ m_blinkTimer->start( 500 );
+ m_highlight = true;
+}
+
+// slotScanStopped
+// ===============
+
+void IndexWidget::slotScanStopped( ScanWidget* scanWidget )
+{ scanWidget->state( scanWidget == m_scanStack->visibleWidget( ) ? ScanWidget::dormant : ScanWidget::finished );
+ updateContents( );
+
+ if( --m_scanCount )
+ return;
+
+ delete m_blinkTimer;
+ m_blinkTimer = NULL;
+}
diff --git a/src/indexwidget.h b/src/indexwidget.h
new file mode 100644
index 0000000..64692d7
--- /dev/null
+++ b/src/indexwidget.h
@@ -0,0 +1,75 @@
+/***************************************************************************
+ * *
+ * Copyright (C) 2005, 2006 by Kevin Gilbert *
+ * kev.gilbert@cdu.edu.au *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ * *
+ ***************************************************************************/
+
+#ifndef _INDEXWIDGET_H_
+#define _INDEXWIDGET_H_
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <qscrollview.h>
+
+// forward class definitions
+// =========================
+
+class KConfig;
+class MainWidget;
+class QPainter;
+class QTimer;
+class ScanStack;
+class ScanWidget;
+
+// IndexWidget class definition
+// ============================
+
+class IndexWidget : public QScrollView
+{ Q_OBJECT
+
+ public:
+ IndexWidget( ScanStack* scanStack, MainWidget* parent, const char* name = NULL );
+
+ void ensureCurrentVisible( );
+
+ signals:
+ void visibleScanWidgetChanged( ScanWidget* );
+
+ public slots:
+ void slotRepaint( );
+ void slotScanStarted( );
+ void slotScanStopped( ScanWidget* scanWidget );
+
+ private:
+ short calculateIndex( const ushort y );
+ void contentsContextMenuEvent( QContextMenuEvent* event );
+ void contentsDragMoveEvent( QDragMoveEvent* event );
+ void contentsMouseMoveEvent( QMouseEvent* event );
+ void contentsMousePressEvent( QMouseEvent* event );
+ void drawContents( QPainter* painter, int clipx, int clipy, int clipw, int cliph );
+
+ QTimer* m_blinkTimer;
+ bool m_highlight;
+ ushort m_scanCount;
+ ScanStack* m_scanStack;
+};
+
+#endif // _INDEXWIDGET_H_
diff --git a/src/knmap.cpp b/src/knmap.cpp
new file mode 100644
index 0000000..5bdd17e
--- /dev/null
+++ b/src/knmap.cpp
@@ -0,0 +1,405 @@
+/***************************************************************************
+ * *
+ * Copyright (C) 2005, 2006 by Kevin Gilbert *
+ * kev.gilbert@cdu.edu.au *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ * *
+ ***************************************************************************/
+
+#include <qdir.h>
+#include <qlineedit.h>
+
+#include <kaction.h>
+#include <kapplication.h>
+#include <kconfig.h>
+#include <kdebug.h>
+#include <kedittoolbar.h>
+#include <kfiledialog.h>
+#include <kglobalsettings.h>
+#include <kinputdialog.h>
+#include <kkeydialog.h>
+#include <klocale.h>
+#include <kmainwindow.h>
+#include <kmessagebox.h>
+#include <kstandarddirs.h>
+#include <kstatusbar.h>
+#include <kstdaction.h>
+
+#include "htmlwidget.h"
+#include "knmap.h"
+#include "mainwidget.h"
+#include "scanwidget.h"
+
+// constructor
+// ===========
+
+Knmap::Knmap( )
+: KMainWindow( NULL, "knmap" ),
+ m_mainWidget( new MainWidget( this, "main widget" ))
+{ findNmap( );
+ setCentralWidget( m_mainWidget );
+ readSettings( );
+ createMenu( );
+ setAutoSaveSettings( );
+
+ connect( m_mainWidget,
+ SIGNAL( outputAvailable( const bool, const bool )),
+ SLOT( slotOutputAvailable( const bool, const bool)));
+
+ connect( m_mainWidget,
+ SIGNAL( setManPageActionStuff( const bool )),
+ SLOT( slotSetManPageActionStuff( const bool )));
+
+ connect( m_mainWidget,
+ SIGNAL( setCaption( const QString& )),
+ SLOT( slotSetCaption( const QString& )));
+
+ connect( m_mainWidget,
+ SIGNAL( statusBarText( const QString& )), statusBar( ),
+ SLOT( message( const QString& )));
+
+ connect( m_mainWidget,
+ SIGNAL( visibleScanWidgetChanged( ScanWidget* )),
+ SLOT( slotVisibleScanWidgetChanged( ScanWidget* )));
+}
+
+// createMenu
+// ==========
+
+void Knmap::createMenu( )
+{ KStdAction::configureToolbars( this, SLOT( slotConfigureToolbars( )), actionCollection( ));
+ KStdAction::keyBindings( this, SLOT( slotConfigureShortcuts( )), actionCollection( ));
+ KStdAction::quit( kapp, SLOT( quit( )), actionCollection( ));
+
+ m_fileSaveAction = KStdAction::save( m_mainWidget,
+ SLOT( slotFileSave( )),
+ actionCollection( ));
+
+ m_fileSaveAsAction = KStdAction::saveAs( m_mainWidget,
+ SLOT( slotFileSaveAs( )),
+ actionCollection( ));
+
+ m_settingsManAction = new KAction( i18n( "&Use local man page" ),
+ "localman.png",
+ 0,
+ m_mainWidget,
+ SLOT( slotSwitchManPages( )),
+ actionCollection( ),
+ "settings_local" );
+
+ m_useTargetHostAction = new KToggleAction( i18n( "Use target host name" ),
+ NULL,
+ 0,
+ m_mainWidget,
+ SLOT( slotUseTargetHost( )),
+ actionCollection( ),
+ "scan_use" );
+
+ m_wrapTextAction = new KToggleAction( i18n( "Wrap text" ),
+ NULL,
+ 0,
+ m_mainWidget,
+ SLOT( slotWrapText( )),
+ actionCollection( ),
+ "settings_wrap_text" );
+
+ new KAction( i18n( "Close scan" ),
+ "scanclose",
+ CTRL+Key_W,
+ m_mainWidget,
+ SLOT( slotScanClose( )),
+ actionCollection( ),
+ "scan_close" );
+
+ new KAction( i18n( "Copy profile..." ),
+ "profilecopy",
+ 0,
+ m_mainWidget,
+ SLOT( slotProfileCopy( )),
+ actionCollection( ),
+ "profile_copy" );
+
+ new KAction( i18n( "Delete profile..." ),
+ "profiledelete",
+ 0,
+ m_mainWidget,
+ SLOT( slotProfileDelete( )),
+ actionCollection( ),
+ "profile_delete" );
+
+ new KAction( i18n( "Display nmap man page" ),
+ "manpage",
+ 0,
+ m_mainWidget,
+ SLOT( slotShowManPage( )),
+ actionCollection( ),
+ "help_man_page" );
+
+ new KAction( i18n( "Duplicate scan" ),
+ "scanduplicate",
+ CTRL+Key_C,
+ m_mainWidget,
+ SLOT( slotScanDuplicate( )),
+ actionCollection( ),
+ "scan_duplicate" );
+
+ new KAction( i18n( "Load profile..." ),
+ "profileload",
+ 0,
+ m_mainWidget,
+ SLOT( slotProfileLoad( )),
+ actionCollection( ),
+ "profile_load" );
+
+ new KAction( i18n( "man page stylesheet..." ),
+ "manstylesheet",
+ 0,
+ m_mainWidget,
+ SLOT( slotSetStylesheet( )),
+ actionCollection( ),
+ "settings_stylesheet" );
+
+ new KAction( i18n( "New scan..." ),
+ "scannew",
+ CTRL+Key_N,
+ m_mainWidget,
+ SLOT( slotScanNew( )),
+ actionCollection( ),
+ "scan_new" );
+
+ new KAction( i18n( "Rename profile..." ),
+ "profilerename",
+ 0,
+ m_mainWidget,
+ SLOT( slotProfileRename( )),
+ actionCollection( ),
+ "profile_rename" );
+
+ new KAction( i18n( "Rename scan..." ),
+ "scanrename",
+ Key_F2,
+ m_mainWidget,
+ SLOT( slotScanRename( )),
+ actionCollection( ),
+ "scan_rename" );
+
+ new KAction( i18n( "Save profile..." ),
+ "profilesave",
+ 0,
+ m_mainWidget,
+ SLOT( slotProfileSave( )),
+ actionCollection( ),
+ "profile_save" );
+
+ new KAction( i18n( "Save profile as..." ),
+ "profilesaveas",
+ 0,
+ m_mainWidget,
+ SLOT( slotProfileSaveAs( )),
+ actionCollection( ),
+ "profile_save_as" );
+
+ new KAction( i18n( "Zoom custom" ),
+ "zoomcustom",
+ 0,
+ m_mainWidget,
+ SLOT( slotZoomCustom( )),
+ actionCollection( ),
+ "settings_zoom_custom" );
+
+ new KAction( i18n( "Zoom in" ),
+ "zoomin",
+ 0,
+ m_mainWidget,
+ SLOT( slotZoomIn( )),
+ actionCollection( ),
+ "settings_zoom_in" );
+
+ new KAction( i18n( "Zoom out" ),
+ "zoomout",
+ 0,
+ m_mainWidget,
+ SLOT( slotZoomOut( )),
+ actionCollection( ),
+ "settings_zoom_out" );
+
+ m_fileSaveAction->setEnabled( false );
+ m_fileSaveAsAction->setEnabled( false );
+ m_wrapTextAction->setChecked( m_mainWidget->wrapText( ));
+
+ createStandardStatusBarAction( );
+ setStandardToolBarMenuEnabled( true );
+
+#ifdef _DEBUG
+ createGUI( QDir::homeDirPath( ) + "/.kde/share/apps/knmap/knmapui.rc" );
+#else
+ createGUI( );
+#endif
+}
+
+// findNmap
+// ========
+
+void Knmap::findNmap( )
+{ QString nmapPath = KStandardDirs::findExe( "nmap" );
+
+ if( nmapPath.isEmpty( ))
+ { KMessageBox::error( this,
+ i18n( "nmap is not installed on the computer - we cannot proceed without it. To download nmap go to \"http://www.insecure.org/nmap\"" ),
+ i18n( "nmap not found" ));
+ kapp->quit( );
+ }
+}
+
+// getDirPath
+// ==========
+
+bool Knmap::getDirPath( const QString& caption, QString& path )
+{ QString startDir = (path.isEmpty( )) ? KGlobalSettings::documentPath( ) : path;
+ QString tempPath = KFileDialog::getExistingDirectory( startDir, NULL, caption );
+
+ if( tempPath.isEmpty( ))
+ return false;
+
+ path = tempPath;
+ return true;
+}
+
+// getDirPath
+// ==========
+
+void Knmap::getDirPath( const QString& caption, QString& path, QLineEdit* lineEdit )
+{ if( getDirPath( caption, path ))
+ lineEdit->setText( path );
+}
+
+// getFilePath
+// ===========
+
+bool Knmap::getFilePath( const QString& caption, QString& path, const bool save )
+{ QString filter = "*.txt|Text files\n*.*|All files";
+ QString startDir = (path.isEmpty( )) ? KGlobalSettings::documentPath( ) : path;
+ QString tempPath = KFileDialog::getSaveFileName( startDir, filter, NULL, caption );
+
+ if( tempPath.isEmpty( ))
+ return false;
+
+ if( save && QFile::exists( tempPath ))
+ { if( KMessageBox::Yes != KMessageBox::questionYesNo( NULL, QString( i18n( "File \"%1\" exists.\nOverwrite?" )).arg( tempPath ), i18n( "File exists" )))
+ return false;
+ }
+
+ path = tempPath;
+ return true;
+}
+
+// getFilePath
+// ===========
+
+void Knmap::getFilePath( const QString& caption, QString& path, QLineEdit* lineEdit, const bool save )
+{ if( getFilePath( caption, path, save ))
+ lineEdit->setText( path );
+}
+
+// queryExit
+// =========
+
+bool Knmap::queryExit( )
+{ if( m_mainWidget->isDirty( ) && KMessageBox::Yes == KMessageBox::questionYesNo( this, i18n( "Some profiles has been updated - save them now?" ), i18n( "Profile data updated" )))
+ m_mainWidget->saveAllDirtyProfiles( );
+
+ saveSettings( );
+ return true;
+}
+
+// readSettings
+// ============
+
+void Knmap::readSettings( )
+{ m_mainWidget->readSettings( );
+}
+
+// saveSettings
+// ============
+
+void Knmap::saveSettings( )
+{ m_mainWidget->saveSettings( );
+}
+
+// slotConfigureShortcuts
+// ======================
+
+void Knmap::slotConfigureShortcuts( )
+{ KKeyDialog::configure( actionCollection( ), this);
+}
+
+// slotConfigureToolbars
+// =====================
+
+void Knmap::slotConfigureToolbars( )
+{ saveMainWindowSettings( KGlobal::config( ), autoSaveGroup( ));
+
+ KEditToolbar dlg( actionCollection( ));
+ connect( &dlg, SIGNAL( newToolbarConfig( )),this, SLOT( slotNewToolbarConfig( )));
+ dlg.exec( );
+}
+
+// slotNewToolbarConfig
+// ====================
+
+void Knmap::slotNewToolbarConfig( )
+{
+#ifdef _DEBUG
+ createGUI( QDir::homeDirPath( ) + "/.kde/share/apps/knmap/knmapui.rc" );
+#else
+ createGUI( );
+#endif
+
+ applyMainWindowSettings( KGlobal::config( ), autoSaveGroup( ));
+}
+
+// slotOutputAvailable
+// ===================
+
+void Knmap::slotOutputAvailable( const bool saveState, const bool saveAsState )
+{ m_fileSaveAction->setEnabled( saveState );
+ m_fileSaveAsAction->setEnabled( saveAsState );
+}
+
+// slotSetCaption
+// ==============
+
+void Knmap::slotSetCaption( const QString& caption )
+{ setCaption( caption );
+}
+
+// slotSetManPageActionStuff
+// =========================
+
+void Knmap::slotSetManPageActionStuff( const bool useLocalManPage )
+{ m_settingsManAction->setIcon( useLocalManPage ? "knmapman.png" : "localman.png" );
+ m_settingsManAction->setText( useLocalManPage ? i18n( "&Use Knmap man page" ) : i18n( "&Use local man page" ));
+}
+
+// slotVisibleScanWidgetChanged
+// ============================
+
+void Knmap::slotVisibleScanWidgetChanged( ScanWidget* scanWidget )
+{ m_useTargetHostAction->setChecked( scanWidget->useTargetHost( ));
+}
+
+#include "knmap.moc"
diff --git a/src/knmap.desktop b/src/knmap.desktop
new file mode 100644
index 0000000..38949f4
--- /dev/null
+++ b/src/knmap.desktop
@@ -0,0 +1,42 @@
+[Desktop Entry]
+Encoding=UTF-8
+Name=knmap
+Name[xx]=xxknmapxx
+Exec=knmap
+Icon=knmap
+Type=Application
+Comment=A simple KDE Application
+Comment[br]=Ur meziant eeun evit KDE
+Comment[ca]=Una aplicació KDE simple
+Comment[da]=Et simpelt KDE program
+Comment[de]=Eine einfache KDE-Anwendung
+Comment[el]=Μια απλή εφαρμογή του KDE
+Comment[es]=Una aplicación de KDE sencilla
+Comment[et]=Lihtne KDE rakendus
+Comment[eu]=KDE aplikazio simple bat
+Comment[fr]=Une application simple pour KDE
+Comment[ga]=Feidhmchlár Simplí KDE
+Comment[hi]=एक सादा केडीई अनुप्रयोग
+Comment[hu]=Egyszerű KDE-alkalmazás
+Comment[is]=Einfalt KDE forrit
+Comment[it]=Una semplice applicazione KDE
+Comment[ja]=シンプルな KDE アプリケーション
+Comment[nb]=Et enkelt KDE-program
+Comment[nl]=Een eenvoudige KDE-toepassing
+Comment[pl]=Prosty program KDE
+Comment[pt]=Uma aplicação simples do KDE
+Comment[pt_BR]=Um simples Aplicativo do KDE
+Comment[ru]=Простое приложение KDE
+Comment[sl]=Preprost program za KDE
+Comment[sr]=Једноставан KDE програм
+Comment[sr@Latn]=Jednostavan KDE program
+Comment[sv]=Ett enkelt KDE-program
+Comment[ta]=ஒரு சாதாரண கெடிஇ பயன்பாடு
+Comment[tg]=Гузориши оддиKDE
+Comment[tr]=Basit bir KDE Uygulaması
+Comment[uk]=Проста програма KDE
+Comment[xx]=xxA simple KDE Applicationxx
+Comment[zh_CN]=一个简单的 KDE 应用程序
+GenericName=nmap Graphical User Interface
+GenericName[fr]=Interface Graphique pour nmap
+Categories=Qt;KDE;Utility
diff --git a/src/knmap.h b/src/knmap.h
new file mode 100644
index 0000000..1bdb622
--- /dev/null
+++ b/src/knmap.h
@@ -0,0 +1,81 @@
+/***************************************************************************
+ * *
+ * Copyright (C) 2005, 2006 by Kevin Gilbert *
+ * kev.gilbert@cdu.edu.au *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ * *
+ ***************************************************************************/
+
+#ifndef _KNMAP_H_
+#define _KNMAP_H_
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <qstringlist.h>
+#include <kmainwindow.h>
+#include "global.h"
+
+// forward class definitions
+// =========================
+
+class KAction;
+class KToggleAction;
+class MainWidget;
+class ScanWidget;
+
+// Knmap class definition
+// ======================
+
+class Knmap : public KMainWindow
+{ Q_OBJECT
+
+ public:
+ Knmap( );
+
+ static bool getDirPath( const QString& caption, QString& path );
+ static void getDirPath( const QString& caption, QString& path, QLineEdit* lineEdit );
+ static bool getFilePath( const QString& caption, QString& path, const bool save );
+ static void getFilePath( const QString& caption, QString& path, QLineEdit* lineEdit, const bool save );
+
+ private slots:
+ void slotConfigureShortcuts( );
+ void slotConfigureToolbars( );
+ void slotSetCaption( const QString& caption );
+ void slotNewToolbarConfig( );
+ void slotOutputAvailable( const bool saveState, const bool saveAsState );
+ void slotSetManPageActionStuff( const bool useLocalManPage );
+ void slotVisibleScanWidgetChanged( ScanWidget* scanWidget );
+
+ private:
+ void createMenu( );
+ void findNmap( );
+ bool queryExit( );
+ void readSettings( );
+ void saveSettings( );
+ void switchManPages( );
+
+ KAction* m_fileSaveAction;
+ KAction* m_fileSaveAsAction;
+ MainWidget* m_mainWidget;
+ KAction* m_settingsManAction;
+ KToggleAction* m_useTargetHostAction;
+ KToggleAction* m_wrapTextAction;
+};
+
+#endif // _KNMAP_H_
diff --git a/src/knmapui.rc b/src/knmapui.rc
new file mode 100644
index 0000000..6635b1c
--- /dev/null
+++ b/src/knmapui.rc
@@ -0,0 +1,38 @@
+<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
+<kpartgui name="knmap" version="1">
+<MenuBar>
+ <Menu name="file" >
+ <Action name="scan_new" />
+ <Action name="scan_duplicate" />
+ <Action name="scan_rename" />
+ <Action name="scan_use" />
+ <Action name="scan_close" />
+ <Separator/>
+ </Menu>
+ <Menu name="help" >
+ <Action name="help_man_page" />
+ <Separator/>
+ </Menu>
+ <Menu name="profile" >
+ <text>&amp;Profiles</text>
+ <Action name="profile_load" />
+ <Action name="profile_save" />
+ <Action name="profile_save_as" />
+ <Separator/>
+ <Action name="profile_copy" />
+ <Action name="profile_delete" />
+ <Action name="profile_rename" />
+ </Menu>
+ <Menu name="settings" >
+ <text>&amp;Settings</text>
+ <Action name="settings_wrap_text" />
+ <Separator/>
+ <Action name="settings_stylesheet" />
+ <Action name="settings_local" />
+ <Separator/>
+ <Action name="settings_zoom_in" />
+ <Action name="settings_zoom_out" />
+ <Action name="settings_zoom_custom" />
+ </Menu>
+</MenuBar>
+</kpartgui>
diff --git a/src/loggingoptions.cpp b/src/loggingoptions.cpp
new file mode 100644
index 0000000..7a8d410
--- /dev/null
+++ b/src/loggingoptions.cpp
@@ -0,0 +1,460 @@
+/***************************************************************************
+ * *
+ * Copyright (C) 2005, 2006 by Kevin Gilbert *
+ * kev.gilbert@cdu.edu.au *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ * *
+ ***************************************************************************/
+
+#include <qbuttongroup.h>
+#include <qcheckbox.h>
+#include <qlayout.h>
+#include <qlineedit.h>
+#include <qpushbutton.h>
+
+#include <kconfig.h>
+#include <kdebug.h>
+#include <kglobal.h>
+#include <kiconloader.h>
+#include <kinputdialog.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+
+#include "knmap.h"
+#include "loggingoptions.h"
+#include "whatsthis.h"
+
+// constructor
+// ===========
+
+LoggingOptions::LoggingOptions( QWidget* parent, const char* name )
+: QWidget( parent, name )
+{ createLayout( );
+}
+
+// createLayout
+// ============
+
+void LoggingOptions::createLayout( )
+{ QGridLayout* gridLayout = new QGridLayout( this );
+ KIconLoader* iconLoader = KGlobal::iconLoader( );
+ QIconSet fileOpenIconSet = iconLoader->loadIconSet( "fileopen", KIcon::Small );
+
+ m_baseFileNameButton = new QPushButton( fileOpenIconSet, NULL, this, "base file name button" );
+ m_grepableLogButton = new QPushButton( fileOpenIconSet, NULL, this, "grepable log button" );
+ m_normalLogButton = new QPushButton( fileOpenIconSet, NULL, this, "normal log button" );
+ m_resumeButton = new QPushButton( fileOpenIconSet, NULL, this, "resume button" );
+ m_scriptKiddieButton = new QPushButton( fileOpenIconSet, NULL, this, "script kiddie button" );
+ m_stylesheetButton = new QPushButton( fileOpenIconSet, NULL, this, "stylesheet button" );
+ m_xmlLogButton = new QPushButton( fileOpenIconSet, NULL, this, "xml log button" );
+
+ m_appendOutputCheckBox = new QCheckBox( i18n( "Append output (--append_output)" ), this, "append output checkbox" );
+ m_baseFileNameCheckBox = new QCheckBox( i18n( "Base file name (-oA <name>) " ), this, "base name checkbox" );
+ m_grepableLogCheckBox = new QCheckBox( i18n( "grep'able log file (-oG <file>) " ), this, "grepable log checkbox" );
+ m_normalLogCheckBox = new QCheckBox( i18n( "Normal log file (-oN <file>) " ), this, "normal log checkbox" );
+ m_noStylesheetCheckBox = new QCheckBox( i18n( "No XSL stylesheet (--no_stylesheet)" ), this, "no stylesheet checkbox" );
+ m_resumeCheckBox = new QCheckBox( i18n( "Resume file (--resume <file>) " ), this, "resume checkbox" );
+ m_scriptKiddieCheckBox = new QCheckBox( i18n( "Script kiddie log file (-oS <file>) " ), this, "script kiddie checkbox" );
+ m_stylesheetCheckBox = new QCheckBox( i18n( "XSL stylesheet (--stylesheet <file>) " ), this, "stylesheet checkbox" );
+ m_xmlLogCheckBox = new QCheckBox( i18n( "XML log file (-oX <file>) " ), this, "xml log checkbox" );
+
+ m_baseFileNameLineEdit = new QLineEdit( this, "base file name line edit" );
+ m_grepableLogLineEdit = new QLineEdit( this, "grepable log line edit" );
+ m_normalLogLineEdit = new QLineEdit( this, "normal log line edit" );
+ m_resumeLineEdit = new QLineEdit( this, "resume line edit" );
+ m_scriptKiddieLineEdit = new QLineEdit( this, "script kiddie line edit" );
+ m_stylesheetLineEdit = new QLineEdit( this, "stylesheet line edit" );
+ m_xmlLogLineEdit = new QLineEdit( this, "xml log line edit" );
+
+ byte row = 1;
+ gridLayout->addWidget( m_appendOutputCheckBox, row++, 1 );
+ gridLayout->addWidget( m_noStylesheetCheckBox, row++, 1 );
+ byte rowBlock1 = row;
+
+ row = 1;
+ gridLayout->addWidget( m_baseFileNameCheckBox, row, 3 );
+ gridLayout->addWidget( m_baseFileNameLineEdit, row, 4 );
+ gridLayout->addWidget( m_baseFileNameButton, row++, 5 );
+
+ gridLayout->addWidget( m_grepableLogCheckBox, row, 3 );
+ gridLayout->addWidget( m_grepableLogLineEdit, row, 4 );
+ gridLayout->addWidget( m_grepableLogButton, row++, 5 );
+
+ gridLayout->addWidget( m_normalLogCheckBox, row, 3 );
+ gridLayout->addWidget( m_normalLogLineEdit, row, 4 );
+ gridLayout->addWidget( m_normalLogButton, row++, 5 );
+
+ gridLayout->addWidget( m_resumeCheckBox, row, 3 );
+ gridLayout->addWidget( m_resumeLineEdit, row, 4 );
+ gridLayout->addWidget( m_resumeButton, row++, 5 );
+
+ gridLayout->addWidget( m_scriptKiddieCheckBox, row, 3 );
+ gridLayout->addWidget( m_scriptKiddieLineEdit, row, 4 );
+ gridLayout->addWidget( m_scriptKiddieButton, row++, 5 );
+
+ gridLayout->addWidget( m_xmlLogCheckBox, row, 3 );
+ gridLayout->addWidget( m_xmlLogLineEdit, row, 4 );
+ gridLayout->addWidget( m_xmlLogButton, row++, 5 );
+
+ gridLayout->addWidget( m_stylesheetCheckBox, row, 3 );
+ gridLayout->addWidget( m_stylesheetLineEdit, row, 4 );
+ gridLayout->addWidget( m_stylesheetButton, row++, 5 );
+ byte rowBlock2 = row;
+
+ gridLayout->setColStretch( 0, 5 );
+ gridLayout->setColStretch( 2, 5 );
+ gridLayout->setColStretch( 4, 10 );
+ gridLayout->setColStretch( 6, 5 );
+
+ gridLayout->setRowStretch( 0, 10 );
+ gridLayout->setRowStretch( _max_( rowBlock1, rowBlock2 ), 10 );
+}
+
+// finaliseInitialisation
+// ======================
+
+void LoggingOptions::finaliseInitialisation( )
+{ WhatsThis* whatsThis = new WhatsThis( this );
+
+ connect( m_baseFileNameButton, SIGNAL( clicked( )), SLOT( slotBaseFileNameButtonClicked( )));
+ connect( m_baseFileNameCheckBox, SIGNAL( clicked( )), SLOT( slotBaseFileNameCheckBoxClicked( )));
+ connect( m_grepableLogButton, SIGNAL( clicked( )), SLOT( slotGrepableLogButtonClicked( )));
+ connect( m_grepableLogCheckBox, SIGNAL( clicked( )), SLOT( slotGrepableLogCheckBoxClicked( )));
+ connect( m_normalLogButton, SIGNAL( clicked( )), SLOT( slotNormalLogButtonClicked( )));
+ connect( m_normalLogCheckBox, SIGNAL( clicked( )), SLOT( slotNormalLogCheckBoxClicked( )));
+ connect( m_noStylesheetCheckBox, SIGNAL( clicked( )), SLOT( slotNoStylesheetCheckBoxClicked( )));
+ connect( m_resumeButton, SIGNAL( clicked( )), SLOT( slotResumeButtonClicked( )));
+ connect( m_resumeCheckBox, SIGNAL( clicked( )), SLOT( slotResumeCheckBoxClicked( )));
+ connect( m_scriptKiddieButton, SIGNAL( clicked( )), SLOT( slotScriptKiddieButtonClicked( )));
+ connect( m_scriptKiddieCheckBox, SIGNAL( clicked( )), SLOT( slotScriptKiddieCheckBoxClicked( )));
+ connect( m_stylesheetButton, SIGNAL( clicked( )), SLOT( slotStylesheetButtonClicked( )));
+ connect( m_stylesheetCheckBox, SIGNAL( clicked( )), SLOT( slotStylesheetCheckBoxClicked( )));
+ connect( whatsThis, SIGNAL( clicked( )), SLOT( slotWhatsThisClicked( )));
+ connect( m_xmlLogButton, SIGNAL( clicked( )), SLOT( slotXMLLogButtonClicked( )));
+ connect( m_xmlLogCheckBox, SIGNAL( clicked( )), SLOT( slotXMLLogCheckBoxClicked( )));
+
+ connect( m_appendOutputCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_baseFileNameCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_baseFileNameLineEdit, SIGNAL( textChanged( const QString& )), SIGNAL( optionsDirty( )));
+ connect( m_grepableLogCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_grepableLogLineEdit, SIGNAL( textChanged( const QString& )), SIGNAL( optionsDirty( )));
+ connect( m_normalLogCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_normalLogLineEdit, SIGNAL( textChanged( const QString& )), SIGNAL( optionsDirty( )));
+ connect( m_resumeCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_resumeLineEdit, SIGNAL( textChanged( const QString& )), SIGNAL( optionsDirty( )));
+ connect( m_scriptKiddieCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_scriptKiddieLineEdit, SIGNAL( textChanged( const QString& )), SIGNAL( optionsDirty( )));
+ connect( m_stylesheetCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_stylesheetLineEdit, SIGNAL( textChanged( const QString& )), SIGNAL( optionsDirty( )));
+ connect( m_xmlLogCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_xmlLogLineEdit, SIGNAL( textChanged( const QString& )), SIGNAL( optionsDirty( )));
+}
+
+// getOptions
+// ==========
+
+bool LoggingOptions::getOptions( )
+{ bool baseFileNameState = m_baseFileNameCheckBox->isChecked( );
+ QString baseFileNameValue = m_baseFileNameLineEdit->text( );
+ bool grepableLogState = m_grepableLogCheckBox->isChecked( );
+ QString grepableLogValue = m_grepableLogLineEdit->text( );
+ bool normalLogState = m_normalLogCheckBox->isChecked( );
+ QString normalLogValue = m_normalLogLineEdit->text( );
+ bool resumeState = m_resumeCheckBox->isChecked( );
+ QString resumeValue = m_resumeLineEdit->text( );
+ bool scriptKiddieState = m_scriptKiddieCheckBox->isChecked( );
+ QString scriptKiddieValue = m_scriptKiddieLineEdit->text( );
+ bool stylesheetState = m_stylesheetCheckBox->isChecked( );
+ QString stylesheetValue = m_stylesheetLineEdit->text( );
+ bool xmlLogState = m_xmlLogCheckBox->isChecked( );
+ QString xmlLogValue = m_xmlLogLineEdit->text( );
+
+ if( baseFileNameState && baseFileNameValue.isEmpty( ))
+ { KMessageBox::error( this, i18n( QString( "Base file name not specified" )), i18n( "Base file name error" ));
+ return false;
+ }
+
+ if( grepableLogState && grepableLogValue.isEmpty( ))
+ { KMessageBox::error( this, i18n( QString( "grep'able log file name not specified" )), i18n( "grep'able log file name error" ));
+ return false;
+ }
+
+ if( normalLogState && normalLogValue.isEmpty( ))
+ { KMessageBox::error( this, i18n( QString( "Normal log file name not specified" )), i18n( "Normal log file name error" ));
+ return false;
+ }
+
+ if( resumeState && scriptKiddieValue.isEmpty( ))
+ { KMessageBox::error( this, i18n( QString( "Resume file name not specified" )), i18n( "Resume file name error" ));
+ return false;
+ }
+
+ if( scriptKiddieState && scriptKiddieValue.isEmpty( ))
+ { KMessageBox::error( this, i18n( QString( "Script kiddie log file name not specified" )), i18n( "Script kiddie log file name error" ));
+ return false;
+ }
+
+ if( stylesheetState && stylesheetValue.isEmpty( ))
+ { KMessageBox::error( this, i18n( QString( "XSL stylesheet file name not specified" )), i18n( "XSL stylesheet file name error" ));
+ return false;
+ }
+
+ if( xmlLogState && xmlLogValue.isEmpty( ))
+ { KMessageBox::error( this, i18n( QString( "XML log file name not specified" )), i18n( "XML log file name error" ));
+ return false;
+ }
+
+ m_appendOutputState = m_appendOutputCheckBox->isChecked( );
+ m_baseFileNameState = baseFileNameState;
+ m_baseFileNameValue = baseFileNameValue;
+ m_grepableLogState = grepableLogState;
+ m_grepableLogValue = grepableLogValue;
+ m_normalLogState = normalLogState;
+ m_normalLogValue = normalLogValue;
+ m_noStylesheetState = m_noStylesheetCheckBox->isChecked( );
+ m_resumeValue = resumeValue;
+ m_scriptKiddieState = scriptKiddieState;
+ m_scriptKiddieValue = scriptKiddieValue;
+ m_stylesheetState = stylesheetState;
+ m_stylesheetValue = stylesheetValue;
+ m_xmlLogState = xmlLogState;
+ m_xmlLogValue = xmlLogValue;
+
+ return true;
+}
+
+// readProfile
+// ===========
+
+void LoggingOptions::readProfile( KConfig* config )
+{ m_appendOutputState = config->readBoolEntry( "appendOutputState" );
+ m_baseFileNameState = config->readBoolEntry( "baseFileNameState" );
+ m_baseFileNameValue = config->readEntry( "baseFileNameValue" );
+ m_grepableLogState = config->readBoolEntry( "grepableLogState" );
+ m_grepableLogValue = config->readEntry( "grepableLogValue" );
+ m_normalLogState = config->readBoolEntry( "normalLogState" );
+ m_normalLogValue = config->readEntry( "normalLogValue" );
+ m_noStylesheetState = config->readBoolEntry( "noStylesheetState" );
+ m_resumeState = config->readBoolEntry( "resumeState" );
+ m_resumeValue = config->readEntry( "resumeValue" );
+ m_scriptKiddieState = config->readBoolEntry( "scriptKiddieState" );
+ m_scriptKiddieValue = config->readEntry( "scriptKiddieValue" );
+ m_stylesheetState = config->readBoolEntry( "stylesheetState" );
+ m_stylesheetValue = config->readEntry( "stylesheetValue" );
+ m_xmlLogState = config->readBoolEntry( "xmlLogState" );
+ m_xmlLogValue = config->readEntry( "xmlLogValue" );
+}
+
+// saveProfile
+// ===========
+
+void LoggingOptions::saveProfile( KConfig* config )
+{ config->writeEntry( "appendOutputState", m_appendOutputState );
+ config->writeEntry( "baseFileNameState", m_baseFileNameState );
+ config->writeEntry( "baseFileNameValue", m_baseFileNameValue );
+ config->writeEntry( "grepableLogState", m_grepableLogState );
+ config->writeEntry( "grepableLogValue", m_grepableLogValue );
+ config->writeEntry( "normalLogState", m_normalLogState );
+ config->writeEntry( "normalLogValue", m_normalLogValue );
+ config->writeEntry( "noStylesheetState", m_noStylesheetState );
+ config->writeEntry( "resumeState", m_resumeState );
+ config->writeEntry( "resumeValue", m_resumeValue );
+ config->writeEntry( "scriptKiddieState", m_scriptKiddieState );
+ config->writeEntry( "scriptKiddieValue", m_scriptKiddieValue );
+ config->writeEntry( "stylesheetState", m_stylesheetState );
+ config->writeEntry( "stylesheetValue", m_stylesheetValue );
+ config->writeEntry( "xmlLogState", m_xmlLogState );
+ config->writeEntry( "xmlLogValue", m_xmlLogValue );
+}
+
+// setInitialValues
+// ================
+
+void LoggingOptions::setInitialValues( )
+{ m_appendOutputCheckBox->setChecked( m_appendOutputState );
+ m_baseFileNameCheckBox->setChecked( m_baseFileNameState );
+ m_baseFileNameLineEdit->setText( m_baseFileNameValue );
+ m_grepableLogCheckBox->setChecked( m_grepableLogState );
+ m_grepableLogLineEdit->setText( m_grepableLogValue );
+ m_normalLogCheckBox->setChecked( m_normalLogState );
+ m_normalLogLineEdit->setText( m_normalLogValue );
+ m_noStylesheetCheckBox->setChecked( m_noStylesheetState );
+ m_resumeCheckBox->setChecked( m_resumeState );
+ m_resumeLineEdit->setText( m_resumeValue );
+ m_scriptKiddieCheckBox->setChecked( m_scriptKiddieState );
+ m_scriptKiddieLineEdit->setText( m_scriptKiddieValue );
+ m_stylesheetCheckBox->setChecked( m_stylesheetState );
+ m_stylesheetLineEdit->setText( m_stylesheetValue );
+ m_xmlLogCheckBox->setChecked( m_xmlLogState );
+ m_xmlLogLineEdit->setText( m_xmlLogValue );
+
+ slotBaseFileNameCheckBoxClicked( );
+ slotGrepableLogCheckBoxClicked( );
+ slotNormalLogCheckBoxClicked( );
+ slotResumeCheckBoxClicked( );
+ slotScriptKiddieCheckBoxClicked( );
+ slotStylesheetCheckBoxClicked( );
+ slotXMLLogCheckBoxClicked( );
+}
+
+// slotBaseFileNameButtonClicked
+// =============================
+
+void LoggingOptions::slotBaseFileNameButtonClicked( )
+{ Knmap::getFilePath( "Base file name", m_baseFileNameValue, m_baseFileNameLineEdit, false );
+}
+
+// slotBaseFileNameCheckBoxClicked
+// ===============================
+
+void LoggingOptions::slotBaseFileNameCheckBoxClicked( )
+{ m_baseFileNameButton->setEnabled( m_baseFileNameCheckBox->isChecked( ));
+ m_baseFileNameLineEdit->setEnabled( m_baseFileNameCheckBox->isChecked( ));
+}
+
+// slotGrepableLogButtonClicked
+// ============================
+
+void LoggingOptions::slotGrepableLogButtonClicked( )
+{ Knmap::getFilePath( "grep'able log file", m_grepableLogValue, m_grepableLogLineEdit, true );
+}
+
+// slotGrepableLogCheckBoxClicked
+// ==============================
+
+void LoggingOptions::slotGrepableLogCheckBoxClicked( )
+{ m_grepableLogButton->setEnabled( m_grepableLogCheckBox->isChecked( ));
+ m_grepableLogLineEdit->setEnabled( m_grepableLogCheckBox->isChecked( ));
+}
+
+// slotNormalLogButtonClicked
+// ==========================
+
+void LoggingOptions::slotNormalLogButtonClicked( )
+{ Knmap::getFilePath( "Normal log file", m_normalLogValue, m_normalLogLineEdit, true );
+}
+
+// slotNormalLogCheckBoxClicked
+// ============================
+
+void LoggingOptions::slotNormalLogCheckBoxClicked( )
+{ m_normalLogButton->setEnabled( m_normalLogCheckBox->isChecked( ));
+ m_normalLogLineEdit->setEnabled( m_normalLogCheckBox->isChecked( ));
+}
+
+// slotNoStylesheetCheckBoxClicked
+// ===============================
+
+void LoggingOptions::slotNoStylesheetCheckBoxClicked( )
+{ if( m_noStylesheetCheckBox->isChecked( ))
+ { m_stylesheetCheckBox->setChecked( false );
+ slotStylesheetCheckBoxClicked( );
+ }
+}
+
+// slotResumeButtonClicked
+// =======================
+
+void LoggingOptions::slotResumeButtonClicked( )
+{ Knmap::getFilePath( "Resume file", m_resumeValue, m_resumeLineEdit, false );
+}
+
+// slotResumeCheckBoxClicked
+// =========================
+
+void LoggingOptions::slotResumeCheckBoxClicked( )
+{ m_resumeButton->setEnabled( m_resumeCheckBox->isChecked( ));
+ m_resumeLineEdit->setEnabled( m_resumeCheckBox->isChecked( ));
+}
+
+// slotScriptKiddieButtonClicked
+// =============================
+
+void LoggingOptions::slotScriptKiddieButtonClicked( )
+{ Knmap::getFilePath( "Script kiddie log file", m_scriptKiddieValue, m_scriptKiddieLineEdit, true );
+}
+
+// slotScriptKiddieCheckBoxClicked
+// ===============================
+
+void LoggingOptions::slotScriptKiddieCheckBoxClicked( )
+{ m_scriptKiddieButton->setEnabled( m_scriptKiddieCheckBox->isChecked( ));
+ m_scriptKiddieLineEdit->setEnabled( m_scriptKiddieCheckBox->isChecked( ));
+}
+
+// slotStylesheetButtonClicked
+// ===========================
+
+void LoggingOptions::slotStylesheetButtonClicked( )
+{ Knmap::getFilePath( "Stylesheet file", m_stylesheetValue, m_stylesheetLineEdit, false );
+}
+
+// slotStylesheetCheckBoxClicked
+// =============================
+
+void LoggingOptions::slotStylesheetCheckBoxClicked( )
+{ m_stylesheetButton->setEnabled( m_stylesheetCheckBox->isChecked( ));
+ m_stylesheetLineEdit->setEnabled( m_stylesheetCheckBox->isChecked( ));
+
+ if( m_stylesheetCheckBox->isChecked( ))
+ m_noStylesheetCheckBox->setChecked( false );
+}
+
+// slotWhatsThisClicked
+// ====================
+
+void LoggingOptions::slotWhatsThisClicked( )
+{ if( m_appendOutputCheckBox->hasMouse( )) emit( displayHelp( "--append_output" ));
+ else if( m_baseFileNameButton->hasMouse( )) emit( displayHelp( "-oA" ));
+ else if( m_baseFileNameCheckBox->hasMouse( )) emit( displayHelp( "-oA" ));
+ else if( m_baseFileNameLineEdit->hasMouse( )) emit( displayHelp( "-oA" ));
+ else if( m_grepableLogButton->hasMouse( )) emit( displayHelp( "-oG" ));
+ else if( m_grepableLogCheckBox->hasMouse( )) emit( displayHelp( "-oG" ));
+ else if( m_grepableLogLineEdit->hasMouse( )) emit( displayHelp( "-oG" ));
+ else if( m_normalLogButton->hasMouse( )) emit( displayHelp( "-oN" ));
+ else if( m_normalLogCheckBox->hasMouse( )) emit( displayHelp( "-oN" ));
+ else if( m_normalLogLineEdit->hasMouse( )) emit( displayHelp( "-oN" ));
+ else if( m_noStylesheetCheckBox->hasMouse( )) emit( displayHelp( "--no_stylesheet" ));
+ else if( m_resumeButton->hasMouse( )) emit( displayHelp( "--resume" ));
+ else if( m_resumeCheckBox->hasMouse( )) emit( displayHelp( "--resume" ));
+ else if( m_resumeLineEdit->hasMouse( )) emit( displayHelp( "--resume" ));
+ else if( m_scriptKiddieButton->hasMouse( )) emit( displayHelp( "-oS" ));
+ else if( m_scriptKiddieCheckBox->hasMouse( )) emit( displayHelp( "-oS" ));
+ else if( m_scriptKiddieLineEdit->hasMouse( )) emit( displayHelp( "-oS" ));
+ else if( m_stylesheetButton->hasMouse( )) emit( displayHelp( "--stylesheet" ));
+ else if( m_stylesheetCheckBox->hasMouse( )) emit( displayHelp( "--stylesheet" ));
+ else if( m_stylesheetLineEdit->hasMouse( )) emit( displayHelp( "--stylesheet" ));
+ else if( m_xmlLogButton->hasMouse( )) emit( displayHelp( "-oX" ));
+ else if( m_xmlLogCheckBox->hasMouse( )) emit( displayHelp( "-oX" ));
+ else if( m_xmlLogLineEdit->hasMouse( )) emit( displayHelp( "-oX" ));
+ else emit( displayUnknown( ));
+}
+
+// slotXMLLogButtonClicked
+// =======================
+
+void LoggingOptions::slotXMLLogButtonClicked( )
+{ Knmap::getFilePath( "XML log file", m_xmlLogValue, m_xmlLogLineEdit, true );
+}
+
+// slotXMLLogCheckBoxClicked
+// =========================
+
+void LoggingOptions::slotXMLLogCheckBoxClicked( )
+{ m_xmlLogButton->setEnabled( m_xmlLogCheckBox->isChecked( ));
+ m_xmlLogLineEdit->setEnabled( m_xmlLogCheckBox->isChecked( ));
+}
diff --git a/src/loggingoptions.h b/src/loggingoptions.h
new file mode 100644
index 0000000..3260df4
--- /dev/null
+++ b/src/loggingoptions.h
@@ -0,0 +1,141 @@
+/***************************************************************************
+ * *
+ * Copyright (C) 2005, 2006 by Kevin Gilbert *
+ * kev.gilbert@cdu.edu.au *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ * *
+ ***************************************************************************/
+
+#ifndef _LOGGINGOPTIONS_
+#define _LOGGINGOPTIONS_
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <qwidget.h>
+#include "global.h"
+
+// forward class definitions
+// =========================
+
+class QCheckBox;
+class QLineEdit;
+class QPushButton;
+class KConfig;
+
+// LoggingOptions class definition
+// ===============================
+
+class LoggingOptions : public QWidget
+{ Q_OBJECT
+
+ public:
+ LoggingOptions( QWidget* parent, const char* name = NULL );
+
+ void finaliseInitialisation( );
+ bool getOptions( );
+ void readProfile( KConfig* config );
+ void saveProfile( KConfig* config );
+ void setInitialValues( );
+
+ bool appendOutputState( ) const { return m_appendOutputState; }
+ bool baseFileNameState( ) const { return m_baseFileNameState; }
+ QString baseFileNameValue( ) const { return m_baseFileNameValue; }
+ bool grepableLogState( ) const { return m_grepableLogState; }
+ QString grepableLogValue( ) const { return m_grepableLogValue; }
+ bool normalLogState( ) const { return m_normalLogState; }
+ QString normalLogValue( ) const { return m_normalLogValue; }
+ bool noStylesheetState( ) const { return m_noStylesheetState; }
+ bool resumeState( ) const { return m_resumeState; }
+ QString resumeValue( ) const { return m_resumeValue; }
+ bool scriptKiddieState( ) const { return m_scriptKiddieState; }
+ QString scriptKiddieValue( ) const { return m_scriptKiddieValue; }
+ bool stylesheetState( ) const { return m_stylesheetState; }
+ QString stylesheetValue( ) const { return m_stylesheetValue; }
+ bool xmlLogState( ) const { return m_xmlLogState; }
+ QString xmlLogValue( ) const { return m_xmlLogValue; }
+
+ signals:
+ void displayDocBook( const QString& );
+ void displayHelp( const QString& );
+ void displayUnknown( );
+ void optionsDirty( );
+
+ private slots:
+ void slotBaseFileNameButtonClicked( );
+ void slotBaseFileNameCheckBoxClicked( );
+ void slotGrepableLogButtonClicked( );
+ void slotGrepableLogCheckBoxClicked( );
+ void slotNormalLogButtonClicked( );
+ void slotNormalLogCheckBoxClicked( );
+ void slotNoStylesheetCheckBoxClicked( );
+ void slotResumeButtonClicked( );
+ void slotResumeCheckBoxClicked( );
+ void slotScriptKiddieButtonClicked( );
+ void slotScriptKiddieCheckBoxClicked( );
+ void slotStylesheetButtonClicked( );
+ void slotStylesheetCheckBoxClicked( );
+ void slotWhatsThisClicked( );
+ void slotXMLLogButtonClicked( );
+ void slotXMLLogCheckBoxClicked( );
+
+ private:
+ void createLayout( );
+
+ QCheckBox* m_appendOutputCheckBox;
+ bool m_appendOutputState;
+ QPushButton* m_baseFileNameButton;
+ QCheckBox* m_baseFileNameCheckBox;
+ QLineEdit* m_baseFileNameLineEdit;
+ bool m_baseFileNameState;
+ QString m_baseFileNameValue;
+ QPushButton* m_grepableLogButton;
+ QCheckBox* m_grepableLogCheckBox;
+ QLineEdit* m_grepableLogLineEdit;
+ bool m_grepableLogState;
+ QString m_grepableLogValue;
+ QPushButton* m_normalLogButton;
+ QCheckBox* m_normalLogCheckBox;
+ QLineEdit* m_normalLogLineEdit;
+ bool m_normalLogState;
+ QString m_normalLogValue;
+ QCheckBox* m_noStylesheetCheckBox;
+ bool m_noStylesheetState;
+ QPushButton* m_resumeButton;
+ QCheckBox* m_resumeCheckBox;
+ QLineEdit* m_resumeLineEdit;
+ bool m_resumeState;
+ QString m_resumeValue;
+ QPushButton* m_scriptKiddieButton;
+ QCheckBox* m_scriptKiddieCheckBox;
+ QLineEdit* m_scriptKiddieLineEdit;
+ bool m_scriptKiddieState;
+ QString m_scriptKiddieValue;
+ QPushButton* m_stylesheetButton;
+ QCheckBox* m_stylesheetCheckBox;
+ QLineEdit* m_stylesheetLineEdit;
+ bool m_stylesheetState;
+ QString m_stylesheetValue;
+ QPushButton* m_xmlLogButton;
+ QCheckBox* m_xmlLogCheckBox;
+ QLineEdit* m_xmlLogLineEdit;
+ bool m_xmlLogState;
+ QString m_xmlLogValue;
+};
+
+#endif // _LOGGINGOPTIONS_
diff --git a/src/main.cpp b/src/main.cpp
new file mode 100644
index 0000000..8552d86
--- /dev/null
+++ b/src/main.cpp
@@ -0,0 +1,78 @@
+/***************************************************************************
+ * *
+ * Copyright (C) 2005, 2006 by Kevin Gilbert *
+ * kev.gilbert@cdu.edu.au *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ * *
+ ***************************************************************************/
+
+#include <kaboutdata.h>
+#include <kapplication.h>
+#include <kcmdlineargs.h>
+#include <kdebug.h>
+#include <klocale.h>
+
+#include "global.h"
+#include "knmap.h"
+
+static const char description[] = I18N_NOOP( "A KDE frontend for nmap" );
+static KCmdLineOptions options[] = { KCmdLineLastOption };
+
+// main
+// ====
+
+int main( int argc, string argv[])
+{ QString version = QString( "Version 2.1, %1 %2" ).arg( __TIME__ ).arg( __DATE__ );
+ KAboutData about( "knmap",
+ I18N_NOOP( "Knmap" ),
+ version,
+ description,
+ KAboutData::License_GPL,
+ "(C) 2005, 2006 Kevin Gilbert",
+ I18N_NOOP( "This program is a complete re-write of one by the same name written by Alexandre\n"
+ "Sagala. The last version of that program was 0.9 which was released on 2003-03-09\n"
+ "and targeted the KDE 2.2 and QT 2.3 environments. Unfortunately it does not compile\n"
+ "on today's KDE / QT environments.\n"
+ "\n"
+ "Not to mention that it did not cater for the full set of 'nmap' options. Or, perhaps,\n"
+ "'nmap' progressed whilst that version of Knmap languished.\n"
+ "\n"
+ "The icons used for this application are from the Open Clip Art Library. I am indebted\n"
+ "to those damn fine folk as my artistic ability is zero - which is marginally above\n"
+ "my programming ability. :-(" ),
+ "http://informatics.cdu.edu.au/staff/kgilbert" );
+ about.addAuthor( "Kevin Gilbert",
+ "Initial rewrite released as version 1.0\nVersions 2.0, 2.1",
+ "kev.gilbert@cdu.edu.au",
+ "http://informatics.cdu.edu.au/staff/kgilbert" );
+ KCmdLineArgs::init( argc, argv, &about );
+ KCmdLineArgs::addCmdLineOptions( options );
+ KApplication app;
+
+ if( app.isRestored( ))
+ { RESTORE( Knmap );
+ }
+ else
+ { KCmdLineArgs* args = KCmdLineArgs::parsedArgs( );
+ Knmap* mainWin = new Knmap;
+ app.setMainWidget( mainWin );
+ mainWin->show( );
+ args->clear( );
+ }
+
+ return app.exec( );
+}
diff --git a/src/mainwidget.cpp b/src/mainwidget.cpp
new file mode 100644
index 0000000..8cf44ba
--- /dev/null
+++ b/src/mainwidget.cpp
@@ -0,0 +1,463 @@
+/***************************************************************************
+ * *
+ * Copyright (C) 2005, 2006 by Kevin Gilbert *
+ * kev.gilbert@cdu.edu.au *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ * *
+ ***************************************************************************/
+
+#include <qtimer.h>
+
+#include <kapplication.h>
+#include <kconfig.h>
+#include <kdebug.h>
+#include <kinputdialog.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+
+#include "htmlwidget.h"
+#include "indexwidget.h"
+#include "knmap.h"
+#include "mainwidget.h"
+#include "scannamedialog.h"
+#include "scanstack.h"
+#include "scanwidget.h"
+
+// constructor
+// ===========
+
+MainWidget::MainWidget( QWidget* parent, const char* name )
+: QSplitter( parent, name ),
+ m_dirty( false ),
+ m_wrapText( false )
+{ m_scanStack = new ScanStack( this, "scan stack" );
+ m_htmlWidget = new HTMLWidget( &m_stylesheetURLs, this, "html widget" );
+ m_indexWidget = new IndexWidget( m_scanStack, this, "index widget" );
+
+ moveToFirst( m_indexWidget );
+ m_scanStack->appendHTMLWidget( m_htmlWidget );
+ setOpaqueResize( true );
+ QTimer::singleShot( 0, this, SLOT( slotFinaliseInitialisation( )));
+
+ connect( m_htmlWidget,
+ SIGNAL( errorLoadingLocalManPage( const QString& )),
+ SLOT( slotErrorLoadingLocalManPage( const QString& )));
+
+ connect( m_indexWidget,
+ SIGNAL( visibleScanWidgetChanged( ScanWidget* )),
+ SLOT( slotVisibleScanWidgetChanged( ScanWidget* )));
+}
+
+// createScan
+// ==========
+
+ScanWidget* MainWidget::createScan( const QString& scanName, const bool useTargetHost, const QString& profileName )
+{ ScanWidget* scanWidget = new ScanWidget( scanName, useTargetHost, this, "scan widget" );
+
+ m_scanStack->appendAndRaiseWidget( scanWidget );
+ m_scanStack->wrapText( m_wrapText );
+
+ if( profileName == QString::null )
+ scanWidget->readSettings( );
+ else
+ scanWidget->setProfileName( profileName );
+
+ connect( scanWidget,
+ SIGNAL( displayHelp( const QString& )),
+ SLOT( slotDisplayHelp( const QString& )));
+
+ connect( scanWidget,
+ SIGNAL( optionsDirty( )),
+ SLOT( slotOptionsDirty( )));
+
+ connect( scanWidget,
+ SIGNAL( outputAvailable( const bool, const bool )),
+ SIGNAL( outputAvailable( const bool, const bool )));
+
+ connect( scanWidget,
+ SIGNAL( scanRename( const QString& )),
+ SLOT( slotScanRename( const QString& )));
+
+ connect( scanWidget,
+ SIGNAL( scanStarted( )),
+ m_indexWidget,
+ SLOT( slotScanStarted( )));
+
+ connect( scanWidget,
+ SIGNAL( scanStopped( ScanWidget* )),
+ m_indexWidget,
+ SLOT( slotScanStopped( ScanWidget* )));
+
+ connect( scanWidget,
+ SIGNAL( statusBarText( const QString& )),
+ SIGNAL( statusBarText( const QString& )));
+
+ return scanWidget;
+}
+
+// loadManPage
+// ===========
+
+void MainWidget::loadManPage( )
+{ m_htmlWidget->loadManPage( m_useLocalManPage );
+}
+
+// readSettings
+// ============
+
+void MainWidget::readSettings( )
+{ m_htmlWidget->readSettings( );
+
+ KConfig* config = kapp->config( );
+ config->setGroup( "General" );
+
+ m_stylesheetURLs = config->readListEntry( "stylesheetURLs" );
+ m_useLocalManPage = config->readBoolEntry( "useLocalManPage", false );
+ m_wrapText = config->readBoolEntry( "wrapText", false );
+
+ QValueList<int> splitterSizes = config->readIntListEntry( "splitterSizes" );
+ setSizes( splitterSizes );
+ QStringList scanNames = config->readListEntry( "scanNames" );
+
+ if( !scanNames.count( ))
+ scanNames.append( "default" );
+
+ QString visibleScanName = config->readEntry( "visibleScan", QString::null );
+ ScanWidget* visibleScanWidget = NULL;
+
+ for( QStringList::Iterator it = scanNames.begin( ); it != scanNames.end(); ++it )
+ { ScanWidget* scanWidget = createScan( *it, false, QString::null );
+
+ if( visibleScanName == scanWidget->scanName( ))
+ visibleScanWidget = scanWidget;
+ }
+
+ if( visibleScanWidget == NULL )
+ { visibleScanWidget = m_scanStack->firstScanWidget( );
+
+ if( visibleScanWidget == NULL )
+ { KMessageBox::error( this, i18n( "Internal error - no ScanWidget to display!" ), i18n( "Internal error" ));
+ kapp->quit( );
+ }
+ }
+
+ m_scanStack->raiseWidget( visibleScanWidget );
+}
+
+// saveAllDirtyProfiles
+// ====================
+
+void MainWidget::saveAllDirtyProfiles( )
+{ ushort i;
+
+ for( m_scanStack->resetScanWidgets( i ); m_scanStack->moreScanWidgets( i ); m_scanStack->nextScanWidget( i ))
+ { ScanWidget* scanWidget = m_scanStack->currentScanWidget( i );
+
+ if( scanWidget->isDirty( ))
+ scanWidget->profileSave( );
+ }
+}
+
+// saveSettings
+// ============
+
+void MainWidget::saveSettings( )
+{ m_htmlWidget->saveSettings( );
+
+ ushort i;
+ QStringList scanNames;
+
+ for( m_scanStack->resetScanWidgets( i ); m_scanStack->moreScanWidgets( i ); m_scanStack->nextScanWidget( i ))
+ { ScanWidget* scanWidget = m_scanStack->currentScanWidget( i );
+ scanNames.append( scanWidget->scanName( ));
+ scanWidget->saveSettings( );
+ }
+
+ QValueList<int> splitterSizes = sizes( );
+ KConfig* config = kapp->config( );
+
+ config->setGroup( "General" );
+ config->writeEntry( "scanNames", scanNames );
+ config->writeEntry( "splitterSizes", splitterSizes );
+ config->writeEntry( "stylesheetURLs", m_stylesheetURLs );
+ config->writeEntry( "useLocalManPage", m_useLocalManPage );
+ config->writeEntry( "visibleScan", m_scanStack->visibleWidget( )->scanName( ));
+ config->writeEntry( "wrapText", m_wrapText );
+}
+
+// setCaption
+// ==========
+
+void MainWidget::setCaption( ScanWidget* scanWidget )
+{ QString profileName = scanWidget->profileName( );
+ profileName = profileName.right( profileName.length( ) - strlen( PROFILE_PREFIX ));
+ emit( setCaption( scanWidget->scanName( ) + " : " + profileName ));
+}
+
+// slotDisplayHelp
+// ===============
+
+void MainWidget::slotDisplayHelp( const QString& anchor )
+{ slotShowManPage( );
+ m_htmlWidget->gotoAnchor( anchor );
+}
+
+// slotErrorLoadingLocalManPage
+// ============================
+
+void MainWidget::slotErrorLoadingLocalManPage( const QString& errorText )
+{ KMessageBox::sorry( this, errorText + "\nLoading the Knmap version.", "Couldn't load local nmap 'man' page" );
+ slotSwitchManPages( );
+}
+
+// slotFileSave
+// ============
+
+void MainWidget::slotFileSave( )
+{ m_scanStack->visibleWidget( )->fileSave( );
+}
+
+// slotFileSaveAs
+// ==============
+
+void MainWidget::slotFileSaveAs( )
+{ m_scanStack->visibleWidget( )->fileSaveAs( );
+}
+
+// slotFinaliseInitialisation
+// ==========================
+
+void MainWidget::slotFinaliseInitialisation( )
+{ m_indexWidget->ensureCurrentVisible( );
+ slotVisibleScanWidgetChanged( m_scanStack->visibleWidget( ));
+ loadManPage( );
+ emit( setManPageActionStuff( m_useLocalManPage ));
+}
+
+// slotOptionsDirty
+// ================
+
+void MainWidget::slotOptionsDirty( )
+{ m_dirty = false;
+ ushort i;
+
+ for( m_scanStack->resetScanWidgets( i ); m_scanStack->moreScanWidgets( i ); m_scanStack->nextScanWidget( i ))
+ m_dirty |= m_scanStack->currentScanWidget( i )->isDirty( );
+}
+
+// slotProfileCopy
+// ===============
+
+void MainWidget::slotProfileCopy( )
+{ m_scanStack->visibleWidget( )->profileCopy( );
+}
+
+// slotProfileDelete
+// =================
+
+void MainWidget::slotProfileDelete( )
+{ m_scanStack->visibleWidget( )->profileDelete( );
+}
+
+// slotProfileLoad
+// ===============
+
+void MainWidget::slotProfileLoad( )
+{ ScanWidget* scanWidget = m_scanStack->visibleWidget( );
+ scanWidget->profileLoad( );
+ setCaption( scanWidget );
+}
+
+// slotProfileRename
+// =================
+
+void MainWidget::slotProfileRename( )
+{ m_scanStack->visibleWidget( )->profileRename( );
+}
+
+// slotProfileSave
+// ===============
+
+void MainWidget::slotProfileSave( )
+{ m_scanStack->visibleWidget( )->profileSave( );
+}
+
+// slotProfileSaveAs
+// =================
+
+void MainWidget::slotProfileSaveAs( )
+{ ScanWidget* scanWidget = m_scanStack->visibleWidget( );
+ scanWidget->profileSaveAs( );
+ setCaption( scanWidget );
+}
+
+// slotScanClose
+// =============
+
+void MainWidget::slotScanClose( )
+{ ScanWidget* scanWidget = m_scanStack->visibleWidget( );
+ scanWidget->profileAskAndSave( );
+ m_scanStack->removeScanWidget( scanWidget );
+ m_indexWidget->updateContents( );
+ slotOptionsDirty( );
+}
+
+// slotScanDuplicate
+// =================
+
+void MainWidget::slotScanDuplicate( )
+{ ScanWidget* scanWidget = m_scanStack->visibleWidget( );
+ scanWidget = createScan( scanWidget->scanName( ), scanWidget->useTargetHost( ), scanWidget->profileName( ));
+ slotVisibleScanWidgetChanged( scanWidget );
+}
+
+// slotScanNew
+// ===========
+
+void MainWidget::slotScanNew( )
+{ ScanNameDialog dlg( NULL, this, "scan name dlg" );
+
+ if( dlg.exec( ) != QDialog::Accepted )
+ return;
+
+ QString scanName;
+ bool useTargetHost;
+
+ if( dlg.useHostName( ))
+ { scanName = DEFAULT_SCAN_NAME;
+ useTargetHost = true;
+ }
+ else
+ { scanName = dlg.scanName( );
+ useTargetHost = false;
+ }
+
+ ScanWidget* scanWidget = createScan( scanName, useTargetHost, DEFAULT_PROFILE );
+ slotVisibleScanWidgetChanged( scanWidget );
+}
+
+// slotScanRename
+// ==============
+
+void MainWidget::slotScanRename( )
+{ ScanWidget* scanWidget = m_scanStack->visibleWidget( );
+ ScanNameDialog dlg( scanWidget, this, "scan name dlg" );
+
+ if( dlg.exec( ) != QDialog::Accepted )
+ return;
+
+ if( dlg.useHostName( ))
+ { slotScanRename( DEFAULT_SCAN_NAME );
+ scanWidget->useTargetHost( true );
+ }
+ else
+ { slotScanRename( dlg.scanName( ));
+ scanWidget->useTargetHost( false );
+ }
+}
+
+// slotScanRename
+// ==============
+
+void MainWidget::slotScanRename( const QString& scanName )
+{ ScanWidget* scanWidget = m_scanStack->visibleWidget( );
+
+ scanWidget->renameScan( scanName );
+ m_indexWidget->updateContents( );
+ setCaption( scanWidget );
+}
+
+// slotShowManPage
+// ===============
+
+void MainWidget::slotShowManPage( )
+{ m_scanStack->raiseWidget( m_htmlWidget );
+}
+
+// slotSetStylesheet
+// =================
+
+void MainWidget::slotSetStylesheet( )
+{ m_htmlWidget->setStylesheet( );
+}
+
+// slotSwitchManPages
+// ==================
+
+void MainWidget::slotSwitchManPages( )
+{ m_useLocalManPage = !m_useLocalManPage;
+ loadManPage( );
+ emit( setManPageActionStuff( m_useLocalManPage ));
+}
+
+// slotUseTargetHost
+// =================
+
+void MainWidget::slotUseTargetHost( )
+{ m_scanStack->visibleWidget( )->useTargetHost( true );
+}
+
+// slotVisibleScanWidgetChanged
+// ============================
+
+void MainWidget::slotVisibleScanWidgetChanged( ScanWidget* scanWidget )
+{ scanWidget->updateStatusBarText( );
+ setCaption( scanWidget );
+ m_indexWidget->updateContents( );
+ emit( visibleScanWidgetChanged( scanWidget ));
+}
+
+// slotWrapText
+// ============
+
+void MainWidget::slotWrapText( )
+{ m_wrapText = !m_wrapText;
+ m_scanStack->wrapText( m_wrapText );
+}
+
+// slotZoomCustom
+// ==============
+
+void MainWidget::slotZoomCustom( )
+{ bool ok;
+ int zoom = KInputDialog::getInteger( i18n( "Zoom percentage" ),
+ i18n( QString( "Enter zoom %'age (%1% - %2%)").arg( ZOOM_MIN_FACTOR ).arg( ZOOM_MAX_FACTOR)),
+ int( m_htmlWidget->zoomFactor( )),
+ ZOOM_MIN_FACTOR,
+ ZOOM_MAX_FACTOR,
+ 10,
+ &ok,
+ NULL,
+ "zoom" );
+
+ if( ok )
+ m_htmlWidget->zoomFactor( zoom );
+}
+
+// slotZoomIn
+// ==========
+
+void MainWidget::slotZoomIn( )
+{ m_htmlWidget->zoomIn( );
+}
+
+// slotZoomOut
+// ===========
+
+void MainWidget::slotZoomOut( )
+{ m_htmlWidget->zoomOut( );
+}
diff --git a/src/mainwidget.h b/src/mainwidget.h
new file mode 100644
index 0000000..985a46c
--- /dev/null
+++ b/src/mainwidget.h
@@ -0,0 +1,111 @@
+/***************************************************************************
+ * *
+ * Copyright (C) 2005, 2006 by Kevin Gilbert *
+ * kev.gilbert@cdu.edu.au *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ * *
+ ***************************************************************************/
+
+#ifndef _MAINWIDGET_H_
+#define _MAINWIDGET_H_
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <qsplitter.h>
+#include <qstringlist.h>
+
+#include "global.h"
+
+// forward class definitions
+// =========================
+
+class HTMLWidget;
+class IndexWidget;
+class KConfig;
+class ScanStack;
+class ScanWidget;
+
+// MainWidget class definition
+// ===========================
+
+class MainWidget : public QSplitter
+{ Q_OBJECT
+
+ public:
+ MainWidget( QWidget* parent = NULL, const char* name = NULL );
+
+ bool isDirty( ) const { return m_dirty; }
+ void readSettings( );
+ void saveAllDirtyProfiles( );
+ void saveSettings( );
+ bool wrapText( ) const { return m_wrapText; }
+
+ signals:
+ void displayHelp( const QString& );
+ void outputAvailable( const bool, const bool );
+ void setManPageActionStuff( const bool );
+ void setCaption( const QString& );
+ void statusBarText( const QString& );
+ void visibleScanWidgetChanged( ScanWidget* );
+
+ public slots:
+ void slotFileSave( );
+ void slotFileSaveAs( );
+ void slotProfileCopy( );
+ void slotProfileDelete( );
+ void slotProfileLoad( );
+ void slotProfileRename( );
+ void slotProfileSave( );
+ void slotProfileSaveAs( );
+ void slotScanClose( );
+ void slotScanDuplicate( );
+ void slotScanNew( );
+ void slotScanRename( );
+ void slotScanRename( const QString& scanName );
+ void slotShowManPage( );
+ void slotSwitchManPages( );
+ void slotSetStylesheet( );
+ void slotUseTargetHost( );
+ void slotWrapText( );
+ void slotZoomCustom( );
+ void slotZoomIn( );
+ void slotZoomOut( );
+
+ private slots:
+ void slotDisplayHelp( const QString& anchor );
+ void slotErrorLoadingLocalManPage( const QString& errorText );
+ void slotFinaliseInitialisation( );
+ void slotOptionsDirty( );
+ void slotVisibleScanWidgetChanged( ScanWidget* scanWidget );
+
+ private:
+ ScanWidget* createScan( const QString& scanName, const bool useTargetHost, const QString& profileName );
+ void loadManPage( );
+ void setCaption( ScanWidget* scanWidget );
+
+ bool m_dirty;
+ HTMLWidget* m_htmlWidget;
+ IndexWidget* m_indexWidget;
+ ScanStack* m_scanStack;
+ QStringList m_stylesheetURLs;
+ bool m_useLocalManPage;
+ bool m_wrapText;
+};
+
+#endif // _MAINWIDGET_H_
diff --git a/src/nmap_manpage.html b/src/nmap_manpage.html
new file mode 100644
index 0000000..9fa59cf
--- /dev/null
+++ b/src/nmap_manpage.html
@@ -0,0 +1,1176 @@
+<HTML>
+<HEAD>
+<TITLE>Nmap network security scanner man page</TITLE>
+</HEAD>
+<BODY>
+<H1>Nmap network security scanner man page</H1>
+<HR>
+<PRE>
+<!-- Manpage converted by man2html 3.0.1 -->
+<B>NMAP(1)</B> <B>NMAP(1)</B>
+
+
+
+
+</PRE>
+<H2>NAME</H2><PRE>
+ nmap - Network exploration tool and security scanner
+
+
+</PRE>
+<H2>SYNOPSIS</H2><PRE>
+ <B>nmap</B> [Scan Type(s)] [Options] &lt;host or net #1 ... [#N]&gt;
+
+
+</PRE>
+<H2>DESCRIPTION</H2><PRE>
+ <I>Nmap</I> is designed to allow system administrators and curious individuals
+ to scan large networks to determine which hosts are up and what ser-
+ vices they are offering. <I>nmap</I> supports a large number of scanning
+ techniques such as: UDP, TCP connect(), TCP SYN (half open), ftp proxy
+ (bounce attack), ICMP (ping sweep), FIN, ACK sweep, Xmas Tree, SYN
+ sweep, IP Protocol, and Null scan. See the <I>Scan</I> <I>Types</I> section for more
+ details. nmap also offers a number of advanced features such as remote
+ OS detection via TCP/IP fingerprinting, stealth scanning, dynamic delay
+ and retransmission calculations, parallel scanning, detection of down
+ hosts via parallel pings, decoy scanning, port filtering detection,
+ direct (non-portmapper) RPC scanning, fragmentation scanning, and flex-
+ ible target and port specification.
+
+ Significant effort has been put into decent nmap performance for non-
+ root users. Unfortunately, many critical kernel interfaces (such as
+ raw sockets) require root privileges. nmap should be run as root when-
+ ever possible (not setuid root, of course).
+
+ The result of running nmap is usually a list of interesting ports on
+ the machine(s) being scanned (if any). Nmap always gives the port’s
+ "well known" service name (if any), number, state, and protocol. The
+ state is either "open", "closed" "filtered", or "unfiltered". Open
+ means that the target machine will accept() connections on that port.
+ Closed ports are not listening for connections (they have no applica-
+ tion associated with them). Filtered means that a firewall, filter, or
+ other network obstacle is covering the port and preventing nmap from
+ determining whether the port is open. Unfiltered means that the port
+ is known by nmap to be closed and no firewall/filter seems to be inter-
+ fering with nmap’s attempts to determine this. Unfiltered ports are
+ the common case and are only shown when most of the scanned ports are
+ in the filtered state. In some cases, Nmap cannot distinguish between
+ filtered ports and those that are either open or closed. For example,
+ a port that does not respond to a FIN Scan could be either open or fil-
+ tered. In these cases, Nmap lists ports as "open|filtered" or
+ "closed|filtered".
+
+ Depending on options used, nmap may also report the following charac-
+ teristics of the remote host: OS in use, TCP sequentiality, usernames
+ running the programs which have bound to each port, the DNS name,
+ whether the host is a smurf address, and a few others.
+
+
+</PRE>
+<H2>OPTIONS</H2><PRE>
+ Options that make sense together can generally be combined. Some
+ options are specific to certain scan modes. <I>nmap</I> tries to catch and
+ warn the user about psychotic or unsupported option combinations.
+
+ If you are impatient, you can skip to the <I>examples</I> section at the end,
+ which demonstrates common usage. You can also run <B>nmap</B> <B>-h</B> for a quick
+ reference page listing all the options.
+
+ <B>SCAN</B> <B>TYPES</B>
+
+ <B id="-sS">-sS</B> TCP SYN scan: This technique is often referred to as "half-open"
+ scanning, because you don’t open a full TCP connection. You send
+ a SYN packet, as if you are going to open a real connection and
+ you wait for a response. A SYN|ACK indicates the port is listen-
+ ing. A RST is indicative of a non-listener. If a SYN|ACK is
+ received, a RST is immediately sent to tear down the connection
+ (actually our OS kernel does this for us). The primary advantage
+ to this scanning technique is that fewer sites will log it.
+ Unfortunately you need root privileges to build these custom SYN
+ packets. This is the default scan type for privileged users.
+
+ <B id="-sT">-sT</B> TCP connect() scan: This is the most basic form of TCP scanning.
+ The connect() system call provided by your operating system is
+ used to open a connection to every interesting port on the
+ machine. If the port is listening, connect() will succeed, oth-
+ erwise the port isn’t reachable. One strong advantage to this
+ technique is that you don’t need any special privileges. Any
+ user on most UNIX boxes is free to use this call.
+
+ This sort of scan is easily detectable as target host logs will
+ show a bunch of connection and error messages for the services
+ which accept() the connection just to have it immediately shut-
+ down. This is the default scan type for unprivileged users.
+
+ <B id="-sF">-sF</B> <B id="-sX">-sX</B> <B id="-sN">-sN</B>
+ Stealth FIN, Xmas Tree, or Null scan modes: There are times when
+ even SYN scanning isn’t clandestine enough. Some firewalls and
+ packet filters watch for SYNs to restricted ports, and programs
+ like Synlogger and Courtney are available to detect these scans.
+ These advanced scans, on the other hand, may be able to pass
+ through unmolested.
+
+ The idea is that closed ports are required to reply to your
+ probe packet with an RST, while open ports must ignore the pack-
+ ets in question (see RFC 793 pp 64). Filered ports also tend to
+ drop probes without a response, so Nmap considers ports
+ "open|filtered" when it fails to elicit any response. If you
+ add version detection (-sV), it will try to verify whether the
+ ports are actually open and change the state as appropriate.
+ The FIN scan uses a bare (surprise) FIN packet as the probe,
+ while the Xmas tree scan turns on the FIN, URG, and PUSH flags.
+ The Null scan turns off all flags. Unfortunately Microsoft
+ (like usual) decided to completely ignore the standard and do
+ things their own way. Thus this scan type will not work against
+ systems running Windows95/NT. On the positive side, this is a
+ good way to distinguish between the two platforms. If the scan
+ finds open ports, you know the machine is not a Windows box. If
+ a -sF,-sX,or -sN scan shows all ports closed, yet a SYN (-sS)
+ scan shows ports being opened, you are probably looking at a
+ Windows box. This is less useful now that nmap has proper OS
+ detection built in. There are also a few other systems that are
+ broken in the same way Windows is. They include Cisco, BSDI,
+ HP/UX, MVS, and IRIX. All of the above send resets from the
+ open ports when they should just drop the packet.
+
+ <B id="-sP">-sP</B> Ping scanning: Sometimes you only want to know which hosts on a
+ network are up. Nmap can do this by sending ICMP echo request
+ packets to every IP address on the networks you specify. Hosts
+ that respond are up. Unfortunately, some sites such as
+ microsoft.com block echo request packets. Thus nmap can also
+ send a TCP ack packet to (by default) port 80. If we get an RST
+ back, that machine is up. A third technique involves sending a
+ SYN packet and waiting for a RST or a SYN/ACK. For non-root
+ users, a connect() method is used.
+
+ By default (for root users), nmap uses both the ICMP and ACK
+ techniques in parallel. You can change these with the <B>-P</B>
+ options described later.
+
+ Note that pinging is done by default anyway, and only hosts that
+ respond are scanned. Only use this option if you wish to ping
+ sweep <B>without</B> doing any actual port scans.
+
+ <B id="-sV">-sV</B> Version detection: After TCP and/or UDP ports are discovered
+ using one of the other scan methods, version detection communi-
+ cates with those ports to try and determine more about what is
+ actually running. A file called nmap-service-probes is used to
+ determine the best probes for detecting various services and the
+ match strings to expect. Nmap tries to determine the service
+ protocol (e.g. ftp, ssh, telnet, http), the application name
+ (e.g. ISC Bind, Apache httpd, Solaris telnetd), the version num-
+ ber, and sometimes miscellaneous details like whether an X
+ server is open to connections or the SSH protocol version). If
+ Nmap was compiled with OpenSSL support, it will connect to SSL
+ servers to deduce the service listening behind the encryption.
+ When RPC services are discovered, the Nmap RPC grinder is used
+ to determine the RPC program and version numbers. Some UDP
+ ports are left in the "open|filtered" state after a UDP scan is
+ unable to determine whether the port is open or filtered. Ver-
+ sion detection will try to elicit a response from these ports
+ (just as it does with open ports), and change the state to open
+ if it succeeds. Note that the Nmap -A option also enables this
+ feature. For a much more detailed description of Nmap service
+ detection, read our paper at http://www.insecure.org/nmap/ver-
+ sionscan.html . There is a related --version_trace option which
+ causes Nmap to print out extensive debugging info about what
+ version scanning is doing (this is a subset of what you would
+ get with --packet_trace).
+
+ <B id="-sU">-sU</B> UDP scans: This method is used to determine which UDP (User
+ Datagram Protocol, RFC 768) ports are open on a host. The tech-
+ nique is to send 0 byte UDP packets to each port on the target
+ machine. If we receive an ICMP port unreachable message, then
+ the port is closed. If a UDP response is received to the probe
+ (unusual), the port is open. If we get no response at all, the
+ state is "open|filtered", meaning that the port is either open
+ or packet filters are blocking the communication. Versions scan
+ (-sV) can be used to help differentiate the truly open ports
+ from the filtered ones.
+
+ Some people think UDP scanning is pointless. I usually remind
+ them of the Solaris rpcbind hole. Rpcbind can be found hiding on
+ an undocumented UDP port somewhere above 32770. So it doesn’t
+ matter that 111 is blocked by the firewall. But can you find
+ which of the more than 30,000 high ports it is listening on?
+ With a UDP scanner you can! There is also the cDc Back Orifice
+ backdoor program which hides on a configurable UDP port on Win-
+ dows machines. Not to mention the many commonly vulnerable ser-
+ vices that utilize UDP such as snmp, tftp, NFS, etc.
+
+ Unfortunately UDP scanning is sometimes painfully slow since
+ most hosts implement a suggestion in RFC 1812 (section 4.3.2.8)
+ of limiting the ICMP error message rate. For example, the Linux
+ kernel (in net/ipv4/icmp.h) limits destination unreachable mes-
+ sage generation to 80 per 4 seconds, with a 1/4 second penalty
+ if that is exceeded. Solaris has much more strict limits (about
+ 2 messages per second) and thus takes even longer to scan. <I>nmap</I>
+ detects this rate limiting and slows down accordingly, rather
+ than flood the network with useless packets that will be ignored
+ by the target machine.
+
+ As is typical, Microsoft ignored the suggestion of the RFC and
+ does not seem to do any rate limiting at all on Win95 and NT
+ machines. Thus we can scan all 65K ports of a Windows machine
+ <B>very</B> quickly. Whoop!
+
+
+ <B id="-sO">-sO</B> IP protocol scans: This method is used to determine which IP
+ protocols are supported on a host. The technique is to send raw
+ IP packets without any further protocol header to each specified
+ protocol on the target machine. If we receive an ICMP protocol
+ unreachable message, then the protocol is not in use. Otherwise
+ we assume it is open. Note that some hosts (AIX, HP-UX, Digital
+ UNIX) and firewalls may not send protocol unreachable messages.
+ This causes all of the protocols to appear "open".
+
+ Because the implemented technique is very similar to UDP port
+ scanning, ICMP rate limit might apply too. But the IP protocol
+ field has only 8 bits, so at most 256 protocols can be probed
+ which should be possible in reasonable time anyway.
+
+ <B id="-sI">-sI</B> <B>&lt;zombie</B> <B>host[:probeport]&gt;</B>
+ Idlescan: This advanced scan method allows for a truly blind TCP
+ port scan of the target (meaning no packets are sent to the tar-
+ get from your real IP address). Instead, a unique side-channel
+ attack exploits predictable "IP fragmentation ID" sequence gen-
+ eration on the zombie host to glean information about the open
+ ports on the target. IDS systems will display the scan as com-
+ ing from the zombie machine you specify (which must be up and
+ meet certain criteria). I wrote an informal paper about this
+ technique at http://www.insecure.org/nmap/idlescan.html .
+
+ Besides being extraordinarily stealthy (due to its blind
+ nature), this scan type permits mapping out IP-based trust rela-
+ tionships between machines. The port listing shows open ports
+ <I>from</I> <I>the</I> <I>perspective</I> <I>of</I> <I>the</I> <I>zombie</I> <I>host.</I> So you can try scan-
+ ning a target using various zombies that you think might be
+ trusted (via router/packet filter rules). Obviously this is
+ crucial information when prioritizing attack targets. Other-
+ wise, you penetration testers might have to expend considerable
+ resources "owning" an intermediate system, only to find out that
+ its IP isn’t even trusted by the target host/network you are
+ ultimately after.
+
+ You can add a colon followed by a port number if you wish to
+ probe a particular port on the zombie host for IPID changes.
+ Otherwise Nmap will use the port it uses by default for "tcp
+ pings".
+
+ <B id="-sA">-sA</B> ACK scan: This advanced method is usually used to map out fire-
+ wall rulesets. In particular, it can help determine whether a
+ firewall is stateful or just a simple packet filter that blocks
+ incoming SYN packets.
+
+ This scan type sends an ACK packet (with random looking acknowl-
+ edgment/sequence numbers) to the ports specified. If a RST
+ comes back, the ports is classified as "unfiltered". If nothing
+ comes back (or if an ICMP unreachable is returned), the port is
+ classified as "filtered". Note that <I>nmap</I> usually doesn’t print
+ "unfiltered" ports, so getting <B>no</B> ports shown in the output is
+ usually a sign that all the probes got through (and returned
+ RSTs). This scan will obviously never show ports in the "open"
+ state.
+
+ <B id="-sW">-sW</B> Window scan: This advanced scan is very similar to the ACK scan,
+ except that it can sometimes detect open ports as well as fil-
+ tered/unfiltered due to an anomaly in the TCP window size
+ reporting by some operating systems. Systems vulnerable to this
+ include at least some versions of AIX, Amiga, BeOS, BSDI, Cray,
+ Tru64 UNIX, DG/UX, OpenVMS, Digital UNIX, FreeBSD, HP-UX, OS/2,
+ IRIX, MacOS, NetBSD, OpenBSD, OpenStep, QNX, Rhapsody, SunOS
+ 4.X, Ultrix, VAX, and VxWorks. See the nmap-hackers mailing
+ list archive for a full list.
+
+ <B id="-sR">-sR</B> RPC scan. This method works in combination with the various
+ port scan methods of Nmap. It takes all the TCP/UDP ports found
+ open and then floods them with SunRPC program NULL commands in
+ an attempt to determine whether they are RPC ports, and if so,
+ what program and version number they serve up. Thus you can
+ effectively obtain the same info as "rpcinfo -p" even if the
+ target’s portmapper is behind a firewall (or protected by TCP
+ wrappers). Decoys do not currently work with RPC scan, at some
+ point I may add decoy support for UDP RPC scans. This is auto-
+ matically enabled as part of version scan (-sV) if you request
+ that.
+
+ <B id="-sL">-sL</B> List scan. This method simply generates and prints a list of IP
+ addresses or hostnames without actually pinging or port scanning
+ them. DNS name resolution will be performed unless you use -n.
+
+ <B id="-b">-b</B> <B>&lt;ftp</B> <B>relay</B> <B>host&gt;</B>
+ FTP bounce attack: An interesting "feature" of the ftp protocol
+ (RFC 959) is support for "proxy" ftp connections. In other
+ words, I should be able to connect from evil.com to the FTP
+ server of target.com and request that the server send a file
+ ANYWHERE on the Internet! Now this may have worked well in 1985
+ when the RFC was written. But in today’s Internet, we can’t have
+ people hijacking ftp servers and requesting that data be spit
+ out to arbitrary points on the Internet. As *Hobbit* wrote back
+ in 1995, this protocol flaw "can be used to post virtually
+ untraceable mail and news, hammer on servers at various sites,
+ fill up disks, try to hop firewalls, and generally be annoying
+ and hard to track down at the same time." What we will exploit
+ this for is to (surprise, surprise) scan TCP ports from a
+ "proxy" ftp server. Thus you could connect to an ftp server
+ behind a firewall, and then scan ports that are more likely to
+ be blocked (139 is a good one). If the ftp server allows reading
+ from and writing to some directory (such as /incoming), you can
+ send arbitrary data to ports that you do find open (nmap doesn’t
+ do this for you though).
+
+ The argument passed to the "b" option is the host you want to
+ use as a proxy, in standard URL notation. The format is: <I>user-</I>
+ <I>name:password@server:port.</I> Everything but <I>server</I> is optional.
+ To determine what servers are vulnerable to this attack, you can
+ see my article in <I>Phrack</I> 51. An updated version is available at
+ the <I>nmap</I> URL (http://www.insecure.org/nmap).
+
+ <B>GENERAL</B> <B>OPTIONS</B>
+ None of these are required but some can be quite useful. Note
+ that the -P options can now be combined -- you can increase your
+ odds of penetrating strict firewalls by sending many probe types
+ using different TCP ports/flags and ICMP codes.
+
+ <B id="-P0">-P0</B> Do not try to ping hosts at all before scanning them. This
+ allows the scanning of networks that don’t allow ICMP echo
+ requests (or responses) through their firewall. microsoft.com
+ is an example of such a network, and thus you should always use
+ <B>-P0</B> or <B>-PS80</B> when portscanning microsoft.com. Note that "ping"
+ in this context may involve more than the traditional ICMP echo
+ request packet. Nmap supports many such probes, including arbi-
+ trary combinations of TCP, UDP, and ICMP probes. By default,
+ Nmap sends an ICMP echo request and a TCP ACK packet to port 80.
+
+ <B id="-PA">-PA</B> <B>[portlist]</B>
+ Use TCP ACK "ping" to determine what hosts are up. Instead of
+ sending ICMP echo request packets and waiting for a response, we
+ spew out TCP ACK packets throughout the target network (or to a
+ single machine) and then wait for responses to trickle back.
+ Hosts that are up should respond with a RST. This option pre-
+ serves the efficiency of only scanning hosts that are up while
+ still allowing you to scan networks/hosts that block ping pack-
+ ets. For non root UNIX users, we use connect() and thus a SYN
+ is actually being sent. To set the destination ports of the
+ probe packets use -PA&lt;port1&gt;[,port2][...]. The default port is
+ 80, since this port is often not filtered out. Note that this
+ option now accepts multiple, comma-separated port numbers.
+
+ <B id="-PS">-PS</B> <B>[portlist]</B>
+ This option uses SYN (connection request) packets instead of ACK
+ packets for root users. Hosts that are up should respond with a
+ RST (or, rarely, a SYN|ACK). You can set the destination ports
+ in the same manner as -PA above.
+
+ <B id="-PR">-PR</B> This option specifies a raw ethernet ARP ping. It cannot be
+ used in combination with any of the other ping types. When the
+ target machines are on the same network you are scanning from,
+ this is the fastest and most reliable (because it goes below IP-
+ level filters) ping method. Nmap sends an IPv4-to-Ethernet ARP
+ request for each target IP, and watches for any ARP response.
+ <B>-PU</B> <B>[portlist]</B> This option sends UDP probes to the specified
+ hosts, expecting an ICMP port unreachable packet (or possibly a
+ UDP response if the port is open) if the host is up. Since many
+ UDP services won’t reply to an empty packet, your best bet might
+ be to send this to expected-closed ports rather than open ones.
+
+ <B id="-PE">-PE</B> This option uses a true ping (ICMP echo request) packet. It
+ finds hosts that are up and also looks for subnet-directed
+ broadcast addresses on your network. These are IP addresses
+ which are externally reachable and translate to a broadcast of
+ incoming IP packets to a subnet of computers. These should be
+ eliminated if found as they allow for numerous denial of service
+ attacks (Smurf is the most common).
+
+ <B id="-PP">-PP</B> Uses an ICMP timestamp request (type 13) packet to find listen-
+ ing hosts.
+
+ <B id="-PM">-PM</B> Same as <B>-PE</B> and <B>-PP</B> except uses a netmask request (ICMP type
+ 17).
+
+ <B>-PB</B> This is the default ping type. It uses both the ACK ( <B>-PA</B> ) and
+ ICMP echo request ( <B>-PE</B> ) sweeps in parallel. This way you can
+ get firewalls that filter either one (but not both). The TCP
+ probe destination port can be set in the same manner as with -PA
+ above. Note that this flag is now deprecated as pingtype flags
+ can now be used in combination. So you should use both "PE" and
+ "PA" (or rely on the default behavior) to achieve this same
+ effect.
+
+ <B id="-O">-O</B> This option activates remote host identification via TCP/IP fin-
+ gerprinting. In other words, it uses a bunch of techniques to
+ detect subtleties in the underlying operating system network
+ stack of the computers you are scanning. It uses this informa-
+ tion to create a "fingerprint" which it compares with its
+ database of known OS fingerprints (the nmap-os-fingerprints
+ file) to decide what type of system you are scanning.
+
+ If Nmap is unable to guess the OS of a machine, and conditions
+ are good (e.g. at least one open port), Nmap will provide a URL
+ you can use to submit the fingerprint if you know (for sure) the
+ OS running on the machine. By doing this you contribute to the
+ pool of operating systems known to nmap and thus it will be more
+ accurate for everyone. Note that if you leave an IP address on
+ the form, the machine may be scanned when we add the fingerprint
+ (to validate that it works).
+
+ The -O option also enables several other tests. One is the
+ "Uptime" measurement, which uses the TCP timestamp option (RFC
+ 1323) to guess when a machine was last rebooted. This is only
+ reported for machines which provide this information.
+
+ Another test enabled by -O is TCP Sequence Predictability Clas-
+ sification. This is a measure that describes approximately how
+ hard it is to establish a forged TCP connection against the
+ remote host. This is useful for exploiting source-IP based
+ trust relationships (rlogin, firewall filters, etc) or for hid-
+ ing the source of an attack. The actual difficulty number is
+ based on statistical sampling and may fluctuate. It is gener-
+ ally better to use the English classification such as "worthy
+ challenge" or "trivial joke". This is only reported in normal
+ output with -v.
+
+ When verbose mode (-v) is on with -O, IPID Sequence Generation
+ is also reported. Most machines are in the "incremental" class,
+ which means that they increment the "ID" field in the IP header
+ for each packet they send. This makes them vulnerable to sev-
+ eral advanced information gathering and spoofing attacks.
+
+ <B id="--osscan_limit">--osscan_limit</B>
+ OS detection is far more effective if at least one open and one
+ closed TCP port are found. Set this option and Nmap will not
+ even try OS detection against hosts that do not meet this crite-
+ ria. This can save substantial time, particularly on -P0 scans
+ against many hosts. It only matters when OS detection is
+ requested (-O or -A options).
+
+ <B id="-A">-A</B> This option enables _a_dditional _a_dvanced and _a_ggressive
+ options. I haven’t decided exactly which it stands for yet :).
+ Presently this enables OS Detection (-O) and version scanning
+ (-sV). More features may be added in the future. The point is
+ to enable a comprehensive set of scan options without people
+ having to remember a large set of flags. This option only
+ enables features, and not timing options (such as -T4) or ver-
+ bosity options (-v) that you might wan’t as well.
+
+ <B id="-6">-6</B> This options enables IPv6 support. All targets must be IPv6 if
+ this option is used, and they can be specified via normal DNS
+ name (AAAA record) or as a literal IP address such as
+ 3ffe:501:4819:2000:210:f3ff:fe03:4d0 . Currently, connect() TCP
+ scan and TCP connect() Ping scan are supported. If you need UDP
+ or other scan types, have a look at http://nmap6.source-
+ forge.net/ .
+
+ <B id="--send_eth">--send_eth</B>
+ Asks Nmap to send packets at the raw ethernet (data link) layer
+ rather than the higher IP (network) layer. By default, Nmap
+ chooses the one which is generally best for the platform it is
+ running on. Raw sockets (IP layer) are generally most efficient
+ for UNIX machines, while ethernet frames work best on the many
+ Windows versions where Microsoft has disabled raw sockets sup-
+ port. Nmap still uses raw IP packets when there is no other
+ choice (such as non-ethernet connections).
+
+ <B id="--send_ip">--send_ip</B>
+ Asks Nmap to send packets via raw IP sockets rather than sending
+ lower level ethernet frames. It is the complement to the
+ --send-eth option.discussed previously.
+
+ <B id="--spoof_mac">--spoof_mac</B> <B>[mac,</B> <B>prefix,</B> <B>or</B> <B>vendor</B> <B>substring]</B>
+ Ask Nmap to use the given MAC address for all of the raw ether-
+ net frames it sends. The MAC given can take several formats.
+ If it is simply the string "0", Nmap chooses a completely random
+ MAC for the session. If the given string is an even number of
+ hex digits (with the pairs optionally separated by a colon),
+ Nmap will use those as the MAC. If less than 12 hex digits are
+ provided, Nmap fills in the remainder of the 6 bytes with random
+ values. If the argument isn’t a 0 or hex string, Nmap looks
+ through the nmap-mac-prefixes to find a vendor name containing
+ the given string (it is case insensitive). If a match is found,
+ Nmap uses the vendor’s OUI (3-byte prefix) and fills out the
+ remaining 3 bytes randomly. Valid --spoof_mac argument examples
+ are "Apple", "0", "01:02:03:04:05:06", "deadbeefcafe", "0020F2",
+ and "Cisco".
+
+ <B id="-f">-f</B> This option causes the requested scan (including ping scans) to
+ use tiny fragmented IP packets. The idea is to split up the TCP
+ header over several packets to make it harder for packet fil-
+ ters, intrusion detection systems, and other annoyances to
+ detect what you are doing. Be careful with this! Some programs
+ have trouble handling these tiny packets. The old-school sniffer
+ named Sniffit segmentation faulted immediately upon receiving
+ the first fragment. Specify this option once, and Nmap splits
+ the packets into 8 bytes or less after the IP header. So a
+ 20-byte TCP header would be split into 3 packets.
+ Two with eight bytes of the TCP header, and one with the final
+ four. Of course each fragment also has an IP header. Specify
+ -f again to use 16 bytes per fragment (reducing the number of
+ fragments). Or you can specify your own offset size with the
+ --mtu option. Don’t also specify -f if you use --mtu. The off-
+ set must be a multiple of 8. While fragmented packets won’t get
+ by packet filters and firewalls that queue all IP fragments,
+ such as the CONFIG_IP_ALWAYS_DEFRAG option in the Linux kernel,
+ some networks can’t afford the performance hit this causes and
+ thus leave it disabled. Some source systems defragment outgoing
+ packets in the kernel. Linux with the ip tables connection
+ tracking module is one such example. Do a scan with a sniffer
+ such as ethereal running to ensure that sent packets are frag-
+ mented.
+
+ Note that I do not yet have this option working on all systems.
+ It works fine for my Linux, FreeBSD, and OpenBSD boxes and some
+ people have reported success with other *NIX variants.
+
+ <B id="-v">-v</B> Verbose mode. This is a highly recommended option and it gives
+ out more information about what is going on. You can use it
+ twice for greater effect. You can also use <B>-d</B> a few times if
+ you really want to get crazy with scrolling the screen!
+
+ <B>-h</B> This handy option display a quick reference screen of nmap usage
+ options. As you may have noticed, this man page is not exactly
+ a "quick reference" :)
+
+ <B id="-oN">-oN</B> <B>&lt;logfilename&gt;</B>
+ This logs the results of your scans in a normal <B>human</B> <B>readable</B>
+ form into the file you specify as an argument.
+
+ <B id="-oX">-oX</B> <B>&lt;logfilename&gt;</B>
+ This logs the results of your scans in <B>XML</B> form into the file
+ you specify as an argument. This allows programs to easily cap-
+ ture and interpret Nmap results. You can give the argument "-"
+ (without quotes) to shoot output into stdout (for shell
+ pipelines, etc). In this case normal output will be suppressed.
+ Watch out for error messages if you use this (they will still go
+ to stderr). Also note that "-v" may cause some extra informa-
+ tion to be printed. The Document Type Definition (DTD) defining
+ the XML output structure is available at http://www.inse-
+ cure.org/nmap/data/nmap.dtd .
+
+ <B id="--stylesheet">--stylesheet</B> <B>&lt;filename&gt;</B>
+ Nmap ships with an XSL stylesheet named nmap.xsl for viewing or
+ translating XML output to HTML. The XML output includes an xml-
+ stylesheet directive which points to nmap.xml where it was ini-
+ tially installed by Nmap (or in the current working directory on
+ Windows). Simply load Nmap’s XML output in a modern web browser
+ and it should retrieve nmap.xsl from the filesystem and use it
+ to render results. If you wish to use a different stylesheet,
+ specify it as the argument to --stylesheet. You must pass the
+ full pathname or URL. One common invocation is --stylesheet
+ http://www.insecure.org/nmap/data/nmap.xsl . This tells a
+ browser to load the latest version of the stylesheet from Inse-
+ cure.Org. This makes it easier to view results on a machine
+ that doesn’t have Nmap (and thus nmap.xsl) installed. So the
+ URL is often more useful, but the local filesystem locaton of
+ nmap.xsl is used by default for privacy reasons.
+
+ <B id="--no_stylesheet">--no_stylesheet</B>
+ Specify this option to prevent Nmap from associating any XSL
+ stylesheet with its XML output. The xml-stylesheet directive is
+ omitted.
+
+ <B id="-oG">-oG</B> <B>&lt;logfilename&gt;</B>
+ This logs the results of your scans in a <B>grepable</B> form into the
+ file you specify as an argument. This simple format provides
+ all the information on one line (so you can easily grep for port
+ or OS information and see all the IPs. This used to be the pre-
+ ferred mechanism for programs to interact with Nmap, but now we
+ recommend XML output (-oX instead). This simple format may not
+ contain as much information as the other formats. You can give
+ the argument "-" (without quotes) to shoot output into stdout
+ (for shell pipelines, etc). In this case normal output will be
+ suppressed. Watch out for error messages if you use this (they
+ will still go to stderr). Also note that "-v" will cause some
+ extra information to be printed.
+
+ <B id="-oA">-oA</B> <B>&lt;basefilename&gt;</B>
+ This tells Nmap to log in ALL the major formats (normal,
+ grepable, and XML). You give a base for the filename, and the
+ output files will be base.nmap, base.gnmap, and base.xml.
+
+ <B id="-oS">-oS</B> <B>&lt;logfilename&gt;</B>
+ thIs l0gz th3 r3suLtS of YouR ScanZ iN a <B>s|&lt;ipT</B> <B>kiDd|3</B> f0rM iNto
+ THe fiL3 U sPecfy 4s an arGuMEnT! U kAn gIv3 the 4rgument "-"
+ (wItHOUt qUOteZ) to sh00t output iNT0 stDouT!@!!
+
+ <B id="--resume">--resume</B> <B>&lt;logfilename&gt;</B>
+ A network scan that is canceled due to control-C, network out-
+ age, etc. can be resumed using this option. The logfilename
+ must be either a normal (-oN) or grepable (-oG) log from the
+ aborted scan. No other options can be given (they will be the
+ same as the aborted scan). Nmap will start on the machine after
+ the last one successfully scanned in the log file.
+
+ <B id="--exclude">--exclude</B> <B>&lt;host1</B> <B>[,host2][,host3],..."&gt;</B>
+ Specifies a list of targets (hosts, ranges, netblocks) that
+ should be excluded from a scan. Useful to keep from scanning
+ yourself, your ISP, particularly sensitive hosts, etc.
+
+ <B>--excludefile</B> <B>&lt;exclude_file&gt;</B>
+ Same functionality as the --exclude option, only the excluded
+ targets are provided in an newline-delimited exclude_file rather
+ than on the command line.
+
+ <B id="--allports">--allports</B>
+ Causes version detection (-sV) to scan all open ports found,
+ including those excluded as dangerous (likely to cause crashes
+ or other problems) in nmap-service-probes.
+
+ <B id="--append_output">--append_output</B>
+ Tells Nmap to append scan results to any output files you have
+ specified rather than overwriting those files.
+
+ <B id="-iL">-iL</B> <B>&lt;inputfilename&gt;</B>
+ Reads target specifications from the file specified RATHER than
+ from the command line. The file should contain a list of host
+ or network expressions separated by spaces, tabs, or newlines.
+ Use a hyphen (-) as <I>inputfilename</I> if you want nmap to read host
+ expressions from stdin (like at the end of a pipe). See the
+ section <I>target</I> <I>specification</I> for more information on the expres-
+ sions you fill the file with.
+
+ <B id="-iR">-iR</B> <B>&lt;num</B> <B>hosts&gt;</B>
+ This option tells Nmap to generate its own hosts to scan by sim-
+ ply picking random numbers :). It will never end after the
+ given number of IPs has been scanned -- use 0 for a never-ending
+ scan. This option can be useful for statistical sampling of the
+ Internet to estimate various things. If you are ever really
+ bored, try <I>nmap</I> <I>-sS</I> <I>-PS80</I> <I>-iR</I> <I>0</I> <I>-p</I> <I>80</I> to find some web servers
+ to look at.
+
+ <B id="-p">-p</B> <B>&lt;port</B> <B>ranges&gt;</B>
+ This option specifies what ports you want to specify. For exam-
+ ple "-p 23" will only try port 23 of the target host(s). "-p
+ 20-30,139,60000-" scans ports between 20 and 30, port 139, and
+ all ports greater than 60000. The default is to scan all ports
+ between 1 and 1024 as well as any ports listed in the services
+ file which comes with nmap. For IP protocol scanning (-sO),
+ this specifies the protocol number you wish to scan for (0-255).
+
+ When scanning both TCP and UDP ports, you can specify a particu-
+ lar protocol by preceding the port numbers by "T:" or "U:". The
+ qualifier lasts until you specify another qualifier. For exam-
+ ple, the argument "-p U:53,111,137,T:21-25,80,139,8080" would
+ scan UDP ports 53,111,and 137, as well as the listed TCP ports.
+ Note that to scan both UDP &amp; TCP, you have to specify -sU and at
+ least one TCP scan type (such as -sS, -sF, or -sT). If no pro-
+ tocol qualifier is given, the port numbers are added to all pro-
+ tocol lists.
+
+ <B id="-F">-F</B> <B>Fast</B> <B>scan</B> <B>mode.</B>
+ Specifies that you only wish to scan for ports listed in the
+ services file which comes with nmap (or the protocols file for
+ -sO). This is obviously much faster than scanning all 65535
+ ports on a host.
+
+ <B id="-D">-D</B> <B>&lt;decoy1</B> <B>[,decoy2][,ME],...&gt;</B>
+ Causes a decoy scan to be performed which makes it appear to the
+ remote host that the host(s) you specify as decoys are scanning
+ the target network too. Thus their IDS might report 5-10 port
+ scans from unique IP addresses, but they won’t know which IP was
+ scanning them and which were innocent decoys. While this can be
+ defeated through router path tracing, response-dropping, and
+ other "active" mechanisms, it is generally an extremely effec-
+ tive technique for hiding your IP address.
+
+ Separate each decoy host with commas, and you can optionally use
+ "ME" as one of the decoys to represent the position you want
+ your IP address to be used. If you put "ME" in the 6th position
+ or later, some common port scan detectors (such as Solar
+ Designer’s excellent scanlogd) are unlikely to show your IP
+ address at all. If you don’t use "ME", nmap will put you in a
+ random position.
+
+ Note that the hosts you use as decoys should be up or you might
+ accidentally SYN flood your targets. Also it will be pretty
+ easy to determine which host is scanning if only one is actually
+ up on the network. You might want to use IP addresses instead
+ of names (so the decoy networks don’t see you in their name-
+ server logs).
+
+ Also note that some "port scan detectors" will firewall/deny
+ routing to hosts that attempt port scans. The problem is that
+ many scan types can be forged (as this option demonstrates). So
+ attackers can cause such a machine to sever connectivity with
+ important hosts such as its internet gateway, DNS TLD servers,
+ sites like Windows Update, etc. Most such software offers
+ whitelist capabilities, but you are unlikely to enumerate all of
+ the critical machines. For this reason we never recommend tak-
+ ing action against port scans that can be forged, including SYN
+ scans, UDP scans, etc. The machine you block could just be a
+ decoy.
+
+ Decoys are used both in the initial ping scan (using ICMP, SYN,
+ ACK, or whatever) and during the actual port scanning phase.
+ Decoys are also used during remote OS detection ( <B>-O</B> ).
+
+ It is worth noting that using too many decoys may slow your scan
+ and potentially even make it less accurate. Also, some ISPs
+ will filter out your spoofed packets, although many (currently
+ most) do not restrict spoofed IP packets at all.
+
+ <B id="-S">-S</B> <B>&lt;IP_Address&gt;</B>
+ In some circumstances, <I>nmap</I> may not be able to determine your
+ source address ( <I>nmap</I> will tell you if this is the case). In
+ this situation, use -S with your IP address (of the interface
+ you wish to send packets through).
+
+ Another possible use of this flag is to spoof the scan to make
+ the targets think that <B>someone</B> <B>else</B> is scanning them. Imagine a
+ company being repeatedly port scanned by a competitor! This is
+ not a supported usage (or the main purpose) of this flag. I
+ just think it raises an interesting possibility that people
+ should be aware of before they go accusing others of port scan-
+ ning them. <B>-e</B> would generally be required for this sort of
+ usage.
+
+ <B id="-e">-e</B> <B>&lt;interface&gt;</B>
+ Tells nmap what interface to send and receive packets on. Nmap
+ should be able to detect this but it will tell you if it cannot.
+
+ <B id="-g">--source_port</B> <B>&lt;portnumber&gt;</B>
+ Sets the source port number used in scans. Many naive firewall
+ and packet filter installations make an exception in their rule-
+ set to allow DNS (53) or FTP-DATA (20) packets to come through
+ and establish a connection. Obviously this completely subverts
+ the security advantages of the firewall since intruders can just
+ masquerade as FTP or DNS by modifying their source port. Obvi-
+ ously for a UDP scan you should try 53 first and TCP scans
+ should try 20 before 53. Note that this is only a request --
+ nmap will honor it only if and when it is able to. For example,
+ you can’t do TCP ISN sampling all from one host:port to one
+ host:port, so nmap changes the source port even if you used this
+ option. This is an alias for the shorter, but harder to remem-
+ ber, -g option.
+
+ Be aware that there is a small performance penalty on some scans
+ for using this option, because I sometimes store useful informa-
+ tion in the source port number.
+
+ <B id="--data_length">--data_length</B> <B>&lt;number&gt;</B>
+ Normally Nmap sends minimalistic packets that only contain a
+ header. So its TCP packets are generally 40 bytes and ICMP echo
+ requests are just 28. This option tells Nmap to append the
+ given number of random bytes to most of the packets it sends.
+ OS detection (-O) packets are not affected, but most pinging and
+ portscan packets are. This slows things down, but can be
+ slightly less conspicuous.
+
+ <B id="-n">-n</B> Tells Nmap to <B>NEVER</B> do reverse DNS resolution on the active IP
+ addresses it finds. Since DNS is often slow, this can help
+ speed things up.
+
+ <B id="-R">-R</B> Tells Nmap to <B>ALWAYS</B> do reverse DNS resolution on the target IP
+ addresses. Normally this is only done when a machine is found
+ to be alive.
+
+ <B id="-r">-r</B> Tells Nmap <B>NOT</B> to randomize the order in which ports are
+ scanned.
+
+ <B id="-ttl">--ttl</B> <B>&lt;value&gt;</B>
+ Sets the IPv4 time to live field in sent packets to the given
+ value.
+
+ <B id="--privileged">--privileged</B>
+ Tells Nmap to simply assume that it is privileged enough to per-
+ form raw socket sends, packet sniffing, and similar operations
+ that usually require root privileges on UNIX systems. By
+ default Nmap bails if such operations are requested but
+ geteuid() is not zero. --privileged is useful with Linux kernel
+ capabilities and similar systems that may be configured to allow
+ unprivileged users to perform raw-packet scans. Be sure to pro-
+ vide this option flag before any flags for options that require
+ privileges (SYN scan, OS detection, etc.). The NMAP_PRIVILEGED
+ variable may be set as an equivalent alternative --privileged.
+
+ <B>--interactive</B>
+ Starts Nmap in interactive mode, which offers an interactive
+ Nmap prompt allowing easy launching of multiple scans (either
+ synchronously or in the background). This is useful for people
+ who scan from multi-user systems -- they often want to test
+ their security without letting everyone else on the system know
+ exactly which systems they are scanning. Use --interactive to
+ activate this mode and then type usually more familiar and fea-
+ ture-complete.
+
+ <B id="--randomize_hosts">--randomize_hosts</B>
+ Tells Nmap to shuffle each group of up to 2048 hosts before it
+ scans them. This can make the scans less obvious to various
+ network monitoring systems, especially when you combine it with
+ slow timing options (see below).
+
+ <B id="-M">-M</B> <B>&lt;max</B> <B>sockets&gt;</B>
+ Sets the maximum number of sockets that will be used in parallel
+ for a TCP connect() scan (the default). This is useful to slow
+ down the scan a little bit and avoid crashing remote machines.
+ Another approach is to use -sS, which is generally easier for
+ machines to handle.
+
+ <B id="--packet_trace">--packet_trace</B>
+ Tells Nmap to show all the packets it sends and receives in a
+ tcpdump-like format. This can be tremendously useful for debug-
+ ging, and is also a good learning tool.
+
+ <B id="--datadir">--datadir</B> <B>[directoryname]</B>
+ Nmap obtains some special data at runtime in files named nmap-
+ service-probes, nmap-services, nmap-protocols, nmap-rpc, nmap-
+ mac-prefixes, and nmap-os-fingerprints. Nmap first searches
+ these files in the directory option to --datadir. Any files not
+ found there, are searched for in the directory specified by the
+ NMAPDIR environmental variable. Next comes ~/.nmap for real and
+ effective UIDs (POSIX systems only) or location of the Nmap exe-
+ cutable (Win32 only), and then a compiled-in location such as
+ /usr/local/share/nmap or /usr/share/nmap . As a last resort,
+ Nmap will look in the current directory.
+
+ <B>TIMING</B> <B>OPTIONS</B>
+ Generally Nmap does a good job at adjusting for Network charac-
+ teristics at runtime and scanning as fast as possible while min-
+ imizing that chances of hosts/ports going undetected. However,
+ there are same cases where Nmap’s default timing policy may not
+ meet your objectives. The following options provide a fine
+ level of control over the scan timing:
+
+ <B id="-T">-T</B> <B>&lt;Paranoid|Sneaky|Polite|Normal|Aggressive|Insane&gt;</B>
+ These are canned timing policies for conveniently expressing
+ your priorities to Nmap. <B>Paranoid</B> mode scans <B>very</B> slowly in the
+ hopes of avoiding detection by IDS systems. It serializes all
+ scans (no parallel scanning) and generally waits at least 5 min-
+ utes between sending packets. <B>Sneaky</B> is similar, except it only
+ waits 15 seconds between sending packets. <B>Polite</B> is meant to
+ ease load on the network and reduce the chances of crashing
+ machines. It serializes the probes and waits <B>at</B> <B>least</B> 0.4 sec-
+ onds between them. Note that this is generally at least an
+ order of magnitude slower than default scans, so only use it
+ when you need to. <B>Normal</B> is the default Nmap behavior, which
+ tries to run as quickly as possible without overloading the net-
+ work or missing hosts/ports. <B>Aggressive</B> This option can make
+ certain scans (especially SYN scans against heavily filtered
+ hosts) much faster. It is recommended for impatient folks with
+ a fast net connection. <B>Insane</B> is only suitable for very fast
+ networks or where you don’t mind losing some information. It
+ times out hosts in 15 minutes and won’t wait more than 0.3 sec-
+ onds for individual probes. It does allow for very quick net-
+ work sweeps though :).
+
+ You can also reference these by number (0-5). For example,
+ "-T0" gives you Paranoid mode and "-T5" is Insane mode. If you
+ wish to set specific timing values such as --max_rtt_timeout or
+ --host_timeout, place them after any -T option on the command
+ line. Otherwise the defaults for the selected timing mode will
+ override your choices.
+
+ <B id="--host_timeout">--host_timeout</B> <B>&lt;milliseconds&gt;</B>
+ Specifies the amount of time Nmap is allowed to spend scanning a
+ single host before giving up on that IP. The default timing
+ mode has no host timeout.
+
+ <B id="--max_rtt_timeout">--max_rtt_timeout</B> <B>&lt;milliseconds&gt;</B>
+ Specifies the maximum amount of time Nmap is allowed to wait for
+ a probe response before retransmitting or timing out that par-
+ ticular probe. The default mode sets this to about 9000.
+
+ <B id="--min_rtt_timeout">--min_rtt_timeout</B> <B>&lt;milliseconds&gt;</B>
+ When the target hosts start to establish a pattern of responding
+ very quickly, Nmap will shrink the amount of time given per
+ probe. This speeds up the scan, but can lead to missed packets
+ when a response takes longer than usual. With this parameter
+ you can guarantee that Nmap will wait at least the given amount
+ of time before giving up on a probe.
+
+ <B id="--initial_rtt_timeout">--initial_rtt_timeout</B> <B>&lt;milliseconds&gt;</B>
+ Specifies the initial probe timeout. This is generally only
+ useful when scanning firewalled hosts with -P0. Normally Nmap
+ can obtain good RTT estimates from the ping and the first few
+ probes. The default mode uses 6000.
+
+ <B id="--max_hostgroup">--max_hostgroup</B> <B>&lt;numhosts&gt;</B>
+ Specifies the maximum number of hosts that Nmap is allowed to
+ scan in parallel. Most of the port scan techniques support
+ multi-host operation, which makes them much quicker. Spreading
+ the load among multiple target hosts makes the scans gentler.
+ The downside is increased results latency. You need to wait for
+ all hosts in a group to finish, rather than having them pop up
+ one by one. Specify an argument of one for old-style (one host
+ at a time) Nmap behavior. Note that the ping scanner handles
+ its own grouping, and ignores this value.
+
+ <B id="--min_hostgroup">--min_hostgroup</B> <B>&lt;numhosts&gt;</B>
+ Specifies the minimum host group size (see previous entry).
+ Large values (such as 50) are often beneficial for unattended
+ scans, though they do take up more memory. Nmap may override
+ this preference when it needs to, because a group must all use
+ the same network interface, and some scan types can only handle
+ one host at a time.
+
+ <B id="--max_parallelism">--max_parallelism</B> <B>&lt;number&gt;</B>
+ Specifies the maximum number of scans Nmap is allowed to perform
+ in parallel. Setting this to one means Nmap will never try to
+ scan more than 1 port at a time. It also effects other parallel
+ scans such as ping sweep, RPC scan, etc.
+
+ <B id="--min_parallelism">--min_parallelism</B> <B>&lt;number&gt;</B>
+ Tells Nmap to scan at least the given number of ports in paral-
+ lel. This can speed up scans against certain firewalled hosts
+ by an order of magnitude. But be careful -- results will become
+ unreliable if you push it too far.
+
+ <B id="--scan_delay">--scan_delay</B> <B>&lt;milliseconds&gt;</B>
+ Specifies the <B>minimum</B> amount of time Nmap must wait between
+ probes. This is mostly useful to reduce network load or to slow
+ the scan way down to sneak under IDS thresholds. Nmap will
+ sometimes increase the delay itself when it detects many dropped
+ packets. For example, Solaris systems tend to respond with only
+ one ICMP port unreachable packet per second during a UDP scan.
+ So Nmap will try to detect this and lower its rate of UDP probes
+ to one per second.
+
+ <B id="--max_scan_delay">--max_scan_delay</B> <B>&lt;milliseconds&gt;</B>
+ As noted above, Nmap will sometimes enforce a special delay
+ between sending packets. This can provide more accurate results
+ while reducing network congestion, but it can slow the scans
+ down substantially. By default (with no -T options specified),
+ Nmap allows this delay to grow to one second per probe. This
+ option allows you to set a lower or higher maximum. Even if you
+ set it to zero, Nmap will have some delay between packet sends
+ so that it can wait for responses and avoid having too many out-
+ standing probes in parallel.
+
+
+
+</PRE>
+<H2 id="target">TARGET SPECIFICATION</H2><PRE>
+ Everything that isn’t an option (or option argument) in nmap is treated
+ as a target host specification. The simplest case is listing single
+ hostnames or IP addresses on the command line. If you want to scan a
+ subnet of IP addresses, you can append <B>/mask</B> to the hostname or IP
+ address. <B>mask</B> must be between 0 (scan the whole Internet) and 32 (scan
+ the single host specified). Use /24 to scan a class "C" address and
+ /16 for a class "B".
+
+ Nmap also has a more powerful notation which lets you specify an IP
+ address using lists/ranges for each element. Thus you can scan the
+ whole class "B" network 192.168.*.* by specifying "192.168.*.*" or
+ "192.168.0-255.0-255" or even "192.168.1-50,51-255.1,2,3,4,5-255". And
+ of course you can use the mask notation: "192.168.0.0/16". These are
+ all equivalent. If you use asterisks ("*"), remember that most shells
+ require you to escape them with back slashes or protect them with
+ quotes.
+
+ Another interesting thing to do is slice the Internet the other way.
+ Instead of scanning all the hosts in a class "B", scan "*.*.5.6-7" to
+ scan every IP address that ends in .5.6 or .5.7 Pick your own numbers.
+ For more information on specifying hosts to scan, see the <I>examples</I> sec-
+ tion.
+
+
+</PRE>
+<H2>EXAMPLES</H2><PRE>
+ Here are some examples of using nmap, from simple and normal to a lit-
+ tle more complex/esoteric. Note that actual numbers and some actual
+ domain names are used to make things more concrete. In their place you
+ should substitute addresses/names from <B>your</B> <B>own</B> <B>network.</B> I do not
+ think portscanning other networks is illegal; nor should portscans be
+ construed by others as an attack. I have scanned hundreds of thousands
+ of machines and have received only one complaint. But I am not a
+ lawyer and some (anal) people may be annoyed by <I>nmap</I> probes. Get
+ permission first or use at your own risk.
+
+ <B>nmap</B> <B>-v</B> <B>target.example.com</B>
+
+ This option scans all reserved TCP ports on the machine target.exam-
+ ple.com . The -v means turn on verbose mode.
+
+ <B>nmap</B> <B>-sS</B> <B>-O</B> <B>target.example.com/24</B>
+
+ Launches a stealth SYN scan against each machine that is up out of the
+ 255 machines on class "C" where target.example.com resides. It also
+ tries to determine what operating system is running on each host that
+ is up and running. This requires root privileges because of the SYN
+ scan and the OS detection.
+
+ <B>nmap</B> <B>-sX</B> <B>-p</B> <B>22,53,110,143,4564</B> <B>198.116.*.1-127</B>
+
+ Sends an Xmas tree scan to the first half of each of the 255 possible 8
+ bit subnets in the 198.116 class "B" address space. We are testing
+ whether the systems run sshd, DNS, pop3d, imapd, or port 4564. Note
+ that Xmas scan doesn’t work on Microsoft boxes due to their deficient
+ TCP stack. Same goes with CISCO, IRIX, HP/UX, and BSDI boxes.
+
+ <B>nmap</B> <B>-v</B> <B>--randomize_hosts</B> <B>-p</B> <B>80</B> <B>*.*.2.3-5</B>
+
+ Rather than focus on a specific IP range, it is sometimes interesting
+ to slice up the entire Internet and scan a small sample from each
+ slice. This command finds all web servers on machines with IP
+ addresses ending in .2.3, .2.4, or .2.5. If you are root you might as
+ well add -sS. Also you will find more interesting machines starting at
+ 127. so you might want to use "127-222" instead of the first asterisks
+ because that section has a greater density of interesting machines
+ (IMHO).
+
+ <B>host</B> <B>-l</B> <B>company.com</B> <B>|</B> <B>cut</B> <B>-d</B> <B>-f</B> <B>4</B> <B>|</B> <B>./nmap</B> <B>-v</B> <B>-iL</B> <B>-</B>
+
+ Do a DNS zone transfer to find the hosts in company.com and then feed
+ the IP addresses to <I>nmap.</I> The above commands are for my GNU/Linux box.
+ You may need different commands/options on other operating systems.
+
+
+</PRE>
+<H2>BUGS</H2><PRE>
+ Bugs? What bugs? Send me any that you find. Patches are nice too :)
+ Remember to also send in new OS fingerprints so we can grow the
+ database. Nmap will give you a submission URL when an appropriate fin-
+ gerprint is found.
+
+
+</PRE>
+<H2>AUTHOR</H2><PRE>
+ Fyodor <I>&lt;fyodor@insecure.org&gt;</I>
+
+
+</PRE>
+<H2>DISTRIBUTION</H2><PRE>
+ The newest version of <I>nmap</I> can be obtained from <I>http://www.inse-</I>
+ <I>cure.org/nmap/</I>
+
+ The Nmap Security Scanner is (C) 1996-2004 Insecure.Com LLC. Nmap is
+ also a registered trademark of Insecure.Com LLC. This program is free
+ software; you may redistribute and/or modify it under the terms of the
+ GNU General Public License as published by the Free Software Founda-
+ tion; Version 2. This guarantees your right to use, modify, and redis-
+ tribute this software under certain conditions. If you wish to embed
+ Nmap technology into proprietary software, we may be willing to sell
+ alternative licenses (contact sales@insecure.com). Many security scan-
+ ner vendors already license Nmap technology such as our remote OS fin-
+ gerprinting database and code, service/version detection system, and
+ port scanning code.
+
+ Note that the GPL places important restrictions on "derived works", yet
+ it does not provide a detailed definition of that term. To avoid mis-
+ understandings, we consider an application to constitute a "derivative
+ work" for the purpose of this license if it does any of the following:
+
+ o Integrates source code from Nmap
+
+ o Reads or includes Nmap copyrighted data files, such as nmap-os-fin-
+ gerprints or nmap-service-probes.
+
+ o Executes Nmap and parses the results (as opposed to typical shell or
+ execution-menu apps, which simply display raw Nmap output and so are
+ not derivative works.)
+
+ o Integrates/includes/aggregates Nmap into a proprietary executable
+ installer, such as those produced by InstallShield.
+
+ o Links to a library or executes a program that does any of the above
+
+ The term "Nmap" should be taken to also include any portions or derived
+ works of Nmap. This list is not exclusive, but is just meant to clar-
+ ify our interpretation of derived works with some common examples.
+ These restrictions only apply when you actually redistribute Nmap. For
+ example, nothing stops you from writing and selling a proprietary
+ front-end to Nmap. Just distribute it by itself, and point people to
+ http://www.insecure.org/nmap/ to download Nmap.
+
+ We don’t consider these to be added restrictions on top of the GPL, but
+ just a clarification of how we interpret "derived works" as it applies
+ to our GPL-licensed Nmap product. This is similar to the way Linus
+ Torvalds has announced his interpretation of how "derived works"
+ applies to Linux kernel modules. Our interpretation refers only to
+ Nmap - we don’t speak for any other GPL products.
+
+ If you have any questions about the GPL licensing restrictions on using
+ Nmap in non-GPL works, we would be happy to help. As mentioned above,
+ we also offer alternative license to integrate Nmap into proprietary
+ applications and appliances. These contracts have been sold to many
+ security vendors, and generally include a perpetual license as well as
+ providing for priority support and updates as well as helping to fund
+ the continued development of Nmap technology. Please email sales@inse-
+ cure.com for further information.
+
+ As a special exception to the GPL terms, Insecure.Com LLC grants per-
+ mission to link the code of this program with any version of the
+ OpenSSL library which is distributed under a license identical to that
+ listed in the included Copying.OpenSSL file, and distribute linked com-
+ binations including the two. You must obey the GNU GPL in all respects
+ for all of the code used other than OpenSSL. If you modify this file,
+ you may extend this exception to your version of the file, but you are
+ not obligated to do so.
+
+ If you received these files with a written license agreement or con-
+ tract stating terms other than the terms above, then that alternative
+ license agreement takes precedence over these comments.
+
+ Source is provided to this software because we believe users have a
+ right to know exactly what a program is going to do before they run it.
+ This also allows you to audit the software for security holes (none
+ have been found so far).
+
+ Source code also allows you to port Nmap to new platforms, fix bugs,
+ and add new features. You are highly encouraged to send your changes
+ to fyodor@insecure.org for possible incorporation into the main distri-
+ bution. By sending these changes to Fyodor or one the Insecure.Org
+ development mailing lists, it is assumed that you are offering Fyodor
+ and Insecure.Com LLC the unlimited, non-exclusive right to reuse, mod-
+ ify, and relicense the code. Nmap will always be available Open
+ Source, but this is important because the inability to relicense code
+ has caused devastating problems for other Free Software projects (such
+ as KDE and NASM). We also occasionally relicense the code to third
+ parties as discussed above. If you wish to specify special license
+ conditions of your contributions, just say so when you send them.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of MER-
+ CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+ Public License for more details at http://www.gnu.org/copyleft/gpl.html
+ , or in the COPYING file included with Nmap.
+
+ It should also be noted that Nmap has been known to crash certain
+ poorly written applications, TCP/IP stacks, and even operating systems.
+ <B>Nmap</B> <B>should</B> <B>never</B> <B>be</B> <B>run</B> <B>against</B> <B>mission</B> <B>critical</B> <B>systems</B> unless you
+ are prepared to suffer downtime. We acknowledge here that Nmap may
+ crash your systems or networks and we disclaim all liability for any
+ damage or problems Nmap could cause.
+
+ Because of the slight risk of crashes and because a few black hats like
+ to use Nmap for reconnaissance prior to attacking systems, there are
+ administrators who become upset and may complain when their system is
+ scanned. Thus, it is often advisable to request permission before
+ doing even a light scan of a network.
+
+ Nmap should never be installed with special privileges (eg suid root)
+ for security reasons.
+
+ This product includes software developed by the Apache Software Founda-
+ tion (http://www.apache.org/). The <I>Libpcap</I> portable packet capture
+ library is distributed along with nmap. Libpcap was originally copy-
+ righted by Van Jacobson, Craig Leres and Steven McCanne, all of the
+ Lawrence Berkeley National Laboratory, University of California, Berke-
+ ley, CA. It is now maintained by http://www.tcpdump.org .
+
+ Regular expression support is provided by the PCRE library package,
+ which is open source software, written by Philip Hazel, and copyright
+ by the University of Cambridge, England. See http://www.pcre.org/ .
+
+ Nmap can optionally link to the OpenSSL cryptography toolkit, which is
+ available from http://www.openssl.org/ .
+
+ US Export Control: Insecure.Com LLC believes that Nmap falls under US
+ ECCN (export control classification number) 5D992. This category is
+ called ’"Information Security" "software" not controlled by 5D002’.
+ The only restriction of this classification is AT (anti-terrorism),
+ which applies to almost all goods and denies export to a handful of
+ rogue nations such as Iran and North Korea. Thus exporting Nmap does
+ not require any special license, permit, or other governmental autho-
+ rization.
+
+
+
+ <B>NMAP(1)</B>
+</PRE>
+<HR>
+<ADDRESS>
+Man(1) output converted with
+<a href="http://www.oac.uci.edu/indiv/ehood/man2html.html">man2html</a>
+</ADDRESS>
+</BODY>
+</HTML>
diff --git a/src/nmap_manpage.html.diff b/src/nmap_manpage.html.diff
new file mode 100644
index 0000000..bcdf5a6
--- /dev/null
+++ b/src/nmap_manpage.html.diff
@@ -0,0 +1,557 @@
+--- /usr/share/doc/nmap-3.93/nmap_manpage.html 2005-09-12 20:11:41.000000000 +0930
++++ /home/c/knmap/src/nmap_manpage.html 2005-11-09 09:35:59.000000000 +0930
+@@ -78,7 +78,7 @@
+
+ <B>SCAN</B> <B>TYPES</B>
+
+- <B>-sS</B> TCP SYN scan: This technique is often referred to as "half-open"
++ <B id="-sS">-sS</B> TCP SYN scan: This technique is often referred to as "half-open"
+ scanning, because you don’t open a full TCP connection. You send
+ a SYN packet, as if you are going to open a real connection and
+ you wait for a response. A SYN|ACK indicates the port is listen-
+@@ -89,7 +89,7 @@
+ Unfortunately you need root privileges to build these custom SYN
+ packets. This is the default scan type for privileged users.
+
+- <B>-sT</B> TCP connect() scan: This is the most basic form of TCP scanning.
++ <B id="-sT">-sT</B> TCP connect() scan: This is the most basic form of TCP scanning.
+ The connect() system call provided by your operating system is
+ used to open a connection to every interesting port on the
+ machine. If the port is listening, connect() will succeed, oth-
+@@ -102,7 +102,7 @@
+ which accept() the connection just to have it immediately shut-
+ down. This is the default scan type for unprivileged users.
+
+- <B>-sF</B> <B>-sX</B> <B>-sN</B>
++ <B id="-sF">-sF</B> <B id="-sX">-sX</B> <B id="-sN">-sN</B>
+ Stealth FIN, Xmas Tree, or Null scan modes: There are times when
+ even SYN scanning isn’t clandestine enough. Some firewalls and
+ packet filters watch for SYNs to restricted ports, and programs
+@@ -133,7 +133,7 @@
+ HP/UX, MVS, and IRIX. All of the above send resets from the
+ open ports when they should just drop the packet.
+
+- <B>-sP</B> Ping scanning: Sometimes you only want to know which hosts on a
++ <B id="-sP">-sP</B> Ping scanning: Sometimes you only want to know which hosts on a
+ network are up. Nmap can do this by sending ICMP echo request
+ packets to every IP address on the networks you specify. Hosts
+ that respond are up. Unfortunately, some sites such as
+@@ -151,7 +151,7 @@
+ respond are scanned. Only use this option if you wish to ping
+ sweep <B>without</B> doing any actual port scans.
+
+- <B>-sV</B> Version detection: After TCP and/or UDP ports are discovered
++ <B id="-sV">-sV</B> Version detection: After TCP and/or UDP ports are discovered
+ using one of the other scan methods, version detection communi-
+ cates with those ports to try and determine more about what is
+ actually running. A file called nmap-service-probes is used to
+@@ -177,7 +177,7 @@
+ version scanning is doing (this is a subset of what you would
+ get with --packet_trace).
+
+- <B>-sU</B> UDP scans: This method is used to determine which UDP (User
++ <B id="-sU">-sU</B> UDP scans: This method is used to determine which UDP (User
+ Datagram Protocol, RFC 768) ports are open on a host. The tech-
+ nique is to send 0 byte UDP packets to each port on the target
+ machine. If we receive an ICMP port unreachable message, then
+@@ -215,7 +215,7 @@
+ <B>very</B> quickly. Whoop!
+
+
+- <B>-sO</B> IP protocol scans: This method is used to determine which IP
++ <B id="-sO">-sO</B> IP protocol scans: This method is used to determine which IP
+ protocols are supported on a host. The technique is to send raw
+ IP packets without any further protocol header to each specified
+ protocol on the target machine. If we receive an ICMP protocol
+@@ -229,7 +229,7 @@
+ field has only 8 bits, so at most 256 protocols can be probed
+ which should be possible in reasonable time anyway.
+
+- <B>-sI</B> <B>&lt;zombie</B> <B>host[:probeport]&gt;</B>
++ <B id="-sI">-sI</B> <B>&lt;zombie</B> <B>host[:probeport]&gt;</B>
+ Idlescan: This advanced scan method allows for a truly blind TCP
+ port scan of the target (meaning no packets are sent to the tar-
+ get from your real IP address). Instead, a unique side-channel
+@@ -257,7 +257,7 @@
+ Otherwise Nmap will use the port it uses by default for "tcp
+ pings".
+
+- <B>-sA</B> ACK scan: This advanced method is usually used to map out fire-
++ <B id="-sA">-sA</B> ACK scan: This advanced method is usually used to map out fire-
+ wall rulesets. In particular, it can help determine whether a
+ firewall is stateful or just a simple packet filter that blocks
+ incoming SYN packets.
+@@ -272,7 +272,7 @@
+ RSTs). This scan will obviously never show ports in the "open"
+ state.
+
+- <B>-sW</B> Window scan: This advanced scan is very similar to the ACK scan,
++ <B id="-sW">-sW</B> Window scan: This advanced scan is very similar to the ACK scan,
+ except that it can sometimes detect open ports as well as fil-
+ tered/unfiltered due to an anomaly in the TCP window size
+ reporting by some operating systems. Systems vulnerable to this
+@@ -282,7 +282,7 @@
+ 4.X, Ultrix, VAX, and VxWorks. See the nmap-hackers mailing
+ list archive for a full list.
+
+- <B>-sR</B> RPC scan. This method works in combination with the various
++ <B id="-sR">-sR</B> RPC scan. This method works in combination with the various
+ port scan methods of Nmap. It takes all the TCP/UDP ports found
+ open and then floods them with SunRPC program NULL commands in
+ an attempt to determine whether they are RPC ports, and if so,
+@@ -294,11 +294,11 @@
+ matically enabled as part of version scan (-sV) if you request
+ that.
+
+- <B>-sL</B> List scan. This method simply generates and prints a list of IP
++ <B id="-sL">-sL</B> List scan. This method simply generates and prints a list of IP
+ addresses or hostnames without actually pinging or port scanning
+ them. DNS name resolution will be performed unless you use -n.
+
+- <B>-b</B> <B>&lt;ftp</B> <B>relay</B> <B>host&gt;</B>
++ <B id="-b">-b</B> <B>&lt;ftp</B> <B>relay</B> <B>host&gt;</B>
+ FTP bounce attack: An interesting "feature" of the ftp protocol
+ (RFC 959) is support for "proxy" ftp connections. In other
+ words, I should be able to connect from evil.com to the FTP
+@@ -332,7 +332,7 @@
+ odds of penetrating strict firewalls by sending many probe types
+ using different TCP ports/flags and ICMP codes.
+
+- <B>-P0</B> Do not try to ping hosts at all before scanning them. This
++ <B id="-P0">-P0</B> Do not try to ping hosts at all before scanning them. This
+ allows the scanning of networks that don’t allow ICMP echo
+ requests (or responses) through their firewall. microsoft.com
+ is an example of such a network, and thus you should always use
+@@ -342,7 +342,7 @@
+ trary combinations of TCP, UDP, and ICMP probes. By default,
+ Nmap sends an ICMP echo request and a TCP ACK packet to port 80.
+
+- <B>-PA</B> <B>[portlist]</B>
++ <B id="-PA">-PA</B> <B>[portlist]</B>
+ Use TCP ACK "ping" to determine what hosts are up. Instead of
+ sending ICMP echo request packets and waiting for a response, we
+ spew out TCP ACK packets throughout the target network (or to a
+@@ -356,13 +356,13 @@
+ 80, since this port is often not filtered out. Note that this
+ option now accepts multiple, comma-separated port numbers.
+
+- <B>-PS</B> <B>[portlist]</B>
++ <B id="-PS">-PS</B> <B>[portlist]</B>
+ This option uses SYN (connection request) packets instead of ACK
+ packets for root users. Hosts that are up should respond with a
+ RST (or, rarely, a SYN|ACK). You can set the destination ports
+ in the same manner as -PA above.
+
+- <B>-PR</B> This option specifies a raw ethernet ARP ping. It cannot be
++ <B id="-PR">-PR</B> This option specifies a raw ethernet ARP ping. It cannot be
+ used in combination with any of the other ping types. When the
+ target machines are on the same network you are scanning from,
+ this is the fastest and most reliable (because it goes below IP-
+@@ -374,7 +374,7 @@
+ UDP services won’t reply to an empty packet, your best bet might
+ be to send this to expected-closed ports rather than open ones.
+
+- <B>-PE</B> This option uses a true ping (ICMP echo request) packet. It
++ <B id="-PE">-PE</B> This option uses a true ping (ICMP echo request) packet. It
+ finds hosts that are up and also looks for subnet-directed
+ broadcast addresses on your network. These are IP addresses
+ which are externally reachable and translate to a broadcast of
+@@ -382,10 +382,10 @@
+ eliminated if found as they allow for numerous denial of service
+ attacks (Smurf is the most common).
+
+- <B>-PP</B> Uses an ICMP timestamp request (type 13) packet to find listen-
++ <B id="-PP">-PP</B> Uses an ICMP timestamp request (type 13) packet to find listen-
+ ing hosts.
+
+- <B>-PM</B> Same as <B>-PE</B> and <B>-PP</B> except uses a netmask request (ICMP type
++ <B id="-PM">-PM</B> Same as <B>-PE</B> and <B>-PP</B> except uses a netmask request (ICMP type
+ 17).
+
+ <B>-PB</B> This is the default ping type. It uses both the ACK ( <B>-PA</B> ) and
+@@ -397,7 +397,7 @@
+ "PA" (or rely on the default behavior) to achieve this same
+ effect.
+
+- <B>-O</B> This option activates remote host identification via TCP/IP fin-
++ <B id="-O">-O</B> This option activates remote host identification via TCP/IP fin-
+ gerprinting. In other words, it uses a bunch of techniques to
+ detect subtleties in the underlying operating system network
+ stack of the computers you are scanning. It uses this informa-
+@@ -436,7 +436,7 @@
+ for each packet they send. This makes them vulnerable to sev-
+ eral advanced information gathering and spoofing attacks.
+
+- <B>--osscan_limit</B>
++ <B id="--osscan_limit">--osscan_limit</B>
+ OS detection is far more effective if at least one open and one
+ closed TCP port are found. Set this option and Nmap will not
+ even try OS detection against hosts that do not meet this crite-
+@@ -444,7 +444,7 @@
+ against many hosts. It only matters when OS detection is
+ requested (-O or -A options).
+
+- <B>-A</B> This option enables _a_dditional _a_dvanced and _a_ggressive
++ <B id="-A">-A</B> This option enables _a_dditional _a_dvanced and _a_ggressive
+ options. I haven’t decided exactly which it stands for yet :).
+ Presently this enables OS Detection (-O) and version scanning
+ (-sV). More features may be added in the future. The point is
+@@ -453,7 +453,7 @@
+ enables features, and not timing options (such as -T4) or ver-
+ bosity options (-v) that you might wan’t as well.
+
+- <B>-6</B> This options enables IPv6 support. All targets must be IPv6 if
++ <B id="-6">-6</B> This options enables IPv6 support. All targets must be IPv6 if
+ this option is used, and they can be specified via normal DNS
+ name (AAAA record) or as a literal IP address such as
+ 3ffe:501:4819:2000:210:f3ff:fe03:4d0 . Currently, connect() TCP
+@@ -461,7 +461,7 @@
+ or other scan types, have a look at http://nmap6.source-
+ forge.net/ .
+
+- <B>--send_eth</B>
++ <B id="--send_eth">--send_eth</B>
+ Asks Nmap to send packets at the raw ethernet (data link) layer
+ rather than the higher IP (network) layer. By default, Nmap
+ chooses the one which is generally best for the platform it is
+@@ -471,12 +471,12 @@
+ port. Nmap still uses raw IP packets when there is no other
+ choice (such as non-ethernet connections).
+
+- <B>--send_ip</B>
++ <B id="--send_ip">--send_ip</B>
+ Asks Nmap to send packets via raw IP sockets rather than sending
+ lower level ethernet frames. It is the complement to the
+ --send-eth option.discussed previously.
+
+- <B>--spoof_mac</B> <B>[mac,</B> <B>prefix,</B> <B>or</B> <B>vendor</B> <B>substring]</B>
++ <B id="--spoof_mac">--spoof_mac</B> <B>[mac,</B> <B>prefix,</B> <B>or</B> <B>vendor</B> <B>substring]</B>
+ Ask Nmap to use the given MAC address for all of the raw ether-
+ net frames it sends. The MAC given can take several formats.
+ If it is simply the string "0", Nmap chooses a completely random
+@@ -492,7 +492,7 @@
+ are "Apple", "0", "01:02:03:04:05:06", "deadbeefcafe", "0020F2",
+ and "Cisco".
+
+- <B>-f</B> This option causes the requested scan (including ping scans) to
++ <B id="-f">-f</B> This option causes the requested scan (including ping scans) to
+ use tiny fragmented IP packets. The idea is to split up the TCP
+ header over several packets to make it harder for packet fil-
+ ters, intrusion detection systems, and other annoyances to
+@@ -521,7 +521,7 @@
+ It works fine for my Linux, FreeBSD, and OpenBSD boxes and some
+ people have reported success with other *NIX variants.
+
+- <B>-v</B> Verbose mode. This is a highly recommended option and it gives
++ <B id="-v">-v</B> Verbose mode. This is a highly recommended option and it gives
+ out more information about what is going on. You can use it
+ twice for greater effect. You can also use <B>-d</B> a few times if
+ you really want to get crazy with scrolling the screen!
+@@ -530,11 +530,11 @@
+ options. As you may have noticed, this man page is not exactly
+ a "quick reference" :)
+
+- <B>-oN</B> <B>&lt;logfilename&gt;</B>
++ <B id="-oN">-oN</B> <B>&lt;logfilename&gt;</B>
+ This logs the results of your scans in a normal <B>human</B> <B>readable</B>
+ form into the file you specify as an argument.
+
+- <B>-oX</B> <B>&lt;logfilename&gt;</B>
++ <B id="-oX">-oX</B> <B>&lt;logfilename&gt;</B>
+ This logs the results of your scans in <B>XML</B> form into the file
+ you specify as an argument. This allows programs to easily cap-
+ ture and interpret Nmap results. You can give the argument "-"
+@@ -546,7 +546,7 @@
+ the XML output structure is available at http://www.inse-
+ cure.org/nmap/data/nmap.dtd .
+
+- <B>--stylesheet</B> <B>&lt;filename&gt;</B>
++ <B id="--stylesheet">--stylesheet</B> <B>&lt;filename&gt;</B>
+ Nmap ships with an XSL stylesheet named nmap.xsl for viewing or
+ translating XML output to HTML. The XML output includes an xml-
+ stylesheet directive which points to nmap.xml where it was ini-
+@@ -563,12 +563,12 @@
+ URL is often more useful, but the local filesystem locaton of
+ nmap.xsl is used by default for privacy reasons.
+
+- <B>--no_stylesheet</B>
++ <B id="--no_stylesheet">--no_stylesheet</B>
+ Specify this option to prevent Nmap from associating any XSL
+ stylesheet with its XML output. The xml-stylesheet directive is
+ omitted.
+
+- <B>-oG</B> <B>&lt;logfilename&gt;</B>
++ <B id="-oG">-oG</B> <B>&lt;logfilename&gt;</B>
+ This logs the results of your scans in a <B>grepable</B> form into the
+ file you specify as an argument. This simple format provides
+ all the information on one line (so you can easily grep for port
+@@ -582,17 +582,17 @@
+ will still go to stderr). Also note that "-v" will cause some
+ extra information to be printed.
+
+- <B>-oA</B> <B>&lt;basefilename&gt;</B>
++ <B id="-oA">-oA</B> <B>&lt;basefilename&gt;</B>
+ This tells Nmap to log in ALL the major formats (normal,
+ grepable, and XML). You give a base for the filename, and the
+ output files will be base.nmap, base.gnmap, and base.xml.
+
+- <B>-oS</B> <B>&lt;logfilename&gt;</B>
++ <B id="-oS">-oS</B> <B>&lt;logfilename&gt;</B>
+ thIs l0gz th3 r3suLtS of YouR ScanZ iN a <B>s|&lt;ipT</B> <B>kiDd|3</B> f0rM iNto
+ THe fiL3 U sPecfy 4s an arGuMEnT! U kAn gIv3 the 4rgument "-"
+ (wItHOUt qUOteZ) to sh00t output iNT0 stDouT!@!!
+
+- <B>--resume</B> <B>&lt;logfilename&gt;</B>
++ <B id="--resume">--resume</B> <B>&lt;logfilename&gt;</B>
+ A network scan that is canceled due to control-C, network out-
+ age, etc. can be resumed using this option. The logfilename
+ must be either a normal (-oN) or grepable (-oG) log from the
+@@ -600,7 +600,7 @@
+ same as the aborted scan). Nmap will start on the machine after
+ the last one successfully scanned in the log file.
+
+- <B>--exclude</B> <B>&lt;host1</B> <B>[,host2][,host3],..."&gt;</B>
++ <B id="--exclude">--exclude</B> <B>&lt;host1</B> <B>[,host2][,host3],..."&gt;</B>
+ Specifies a list of targets (hosts, ranges, netblocks) that
+ should be excluded from a scan. Useful to keep from scanning
+ yourself, your ISP, particularly sensitive hosts, etc.
+@@ -610,16 +610,16 @@
+ targets are provided in an newline-delimited exclude_file rather
+ than on the command line.
+
+- <B>--allports</B>
++ <B id="--allports">--allports</B>
+ Causes version detection (-sV) to scan all open ports found,
+ including those excluded as dangerous (likely to cause crashes
+ or other problems) in nmap-service-probes.
+
+- <B>--append_output</B>
++ <B id="--append_output">--append_output</B>
+ Tells Nmap to append scan results to any output files you have
+ specified rather than overwriting those files.
+
+- <B>-iL</B> <B>&lt;inputfilename&gt;</B>
++ <B id="-iL">-iL</B> <B>&lt;inputfilename&gt;</B>
+ Reads target specifications from the file specified RATHER than
+ from the command line. The file should contain a list of host
+ or network expressions separated by spaces, tabs, or newlines.
+@@ -628,7 +628,7 @@
+ section <I>target</I> <I>specification</I> for more information on the expres-
+ sions you fill the file with.
+
+- <B>-iR</B> <B>&lt;num</B> <B>hosts&gt;</B>
++ <B id="-iR">-iR</B> <B>&lt;num</B> <B>hosts&gt;</B>
+ This option tells Nmap to generate its own hosts to scan by sim-
+ ply picking random numbers :). It will never end after the
+ given number of IPs has been scanned -- use 0 for a never-ending
+@@ -637,7 +637,7 @@
+ bored, try <I>nmap</I> <I>-sS</I> <I>-PS80</I> <I>-iR</I> <I>0</I> <I>-p</I> <I>80</I> to find some web servers
+ to look at.
+
+- <B>-p</B> <B>&lt;port</B> <B>ranges&gt;</B>
++ <B id="-p">-p</B> <B>&lt;port</B> <B>ranges&gt;</B>
+ This option specifies what ports you want to specify. For exam-
+ ple "-p 23" will only try port 23 of the target host(s). "-p
+ 20-30,139,60000-" scans ports between 20 and 30, port 139, and
+@@ -656,13 +656,13 @@
+ tocol qualifier is given, the port numbers are added to all pro-
+ tocol lists.
+
+- <B>-F</B> <B>Fast</B> <B>scan</B> <B>mode.</B>
++ <B id="-F">-F</B> <B>Fast</B> <B>scan</B> <B>mode.</B>
+ Specifies that you only wish to scan for ports listed in the
+ services file which comes with nmap (or the protocols file for
+ -sO). This is obviously much faster than scanning all 65535
+ ports on a host.
+
+- <B>-D</B> <B>&lt;decoy1</B> <B>[,decoy2][,ME],...&gt;</B>
++ <B id="-D">-D</B> <B>&lt;decoy1</B> <B>[,decoy2][,ME],...&gt;</B>
+ Causes a decoy scan to be performed which makes it appear to the
+ remote host that the host(s) you specify as decoys are scanning
+ the target network too. Thus their IDS might report 5-10 port
+@@ -708,7 +708,7 @@
+ will filter out your spoofed packets, although many (currently
+ most) do not restrict spoofed IP packets at all.
+
+- <B>-S</B> <B>&lt;IP_Address&gt;</B>
++ <B id="-S">-S</B> <B>&lt;IP_Address&gt;</B>
+ In some circumstances, <I>nmap</I> may not be able to determine your
+ source address ( <I>nmap</I> will tell you if this is the case). In
+ this situation, use -S with your IP address (of the interface
+@@ -723,11 +723,11 @@
+ ning them. <B>-e</B> would generally be required for this sort of
+ usage.
+
+- <B>-e</B> <B>&lt;interface&gt;</B>
++ <B id="-e">-e</B> <B>&lt;interface&gt;</B>
+ Tells nmap what interface to send and receive packets on. Nmap
+ should be able to detect this but it will tell you if it cannot.
+
+- <B>--source_port</B> <B>&lt;portnumber&gt;</B>
++ <B id="-g">--source_port</B> <B>&lt;portnumber&gt;</B>
+ Sets the source port number used in scans. Many naive firewall
+ and packet filter installations make an exception in their rule-
+ set to allow DNS (53) or FTP-DATA (20) packets to come through
+@@ -746,7 +746,7 @@
+ for using this option, because I sometimes store useful informa-
+ tion in the source port number.
+
+- <B>--data_length</B> <B>&lt;number&gt;</B>
++ <B id="--data_length">--data_length</B> <B>&lt;number&gt;</B>
+ Normally Nmap sends minimalistic packets that only contain a
+ header. So its TCP packets are generally 40 bytes and ICMP echo
+ requests are just 28. This option tells Nmap to append the
+@@ -755,22 +755,22 @@
+ portscan packets are. This slows things down, but can be
+ slightly less conspicuous.
+
+- <B>-n</B> Tells Nmap to <B>NEVER</B> do reverse DNS resolution on the active IP
++ <B id="-n">-n</B> Tells Nmap to <B>NEVER</B> do reverse DNS resolution on the active IP
+ addresses it finds. Since DNS is often slow, this can help
+ speed things up.
+
+- <B>-R</B> Tells Nmap to <B>ALWAYS</B> do reverse DNS resolution on the target IP
++ <B id="-R">-R</B> Tells Nmap to <B>ALWAYS</B> do reverse DNS resolution on the target IP
+ addresses. Normally this is only done when a machine is found
+ to be alive.
+
+- <B>-r</B> Tells Nmap <B>NOT</B> to randomize the order in which ports are
++ <B id="-r">-r</B> Tells Nmap <B>NOT</B> to randomize the order in which ports are
+ scanned.
+
+- <B>--ttl</B> <B>&lt;value&gt;</B>
++ <B id="-ttl">--ttl</B> <B>&lt;value&gt;</B>
+ Sets the IPv4 time to live field in sent packets to the given
+ value.
+
+- <B>--privileged</B>
++ <B id="--privileged">--privileged</B>
+ Tells Nmap to simply assume that it is privileged enough to per-
+ form raw socket sends, packet sniffing, and similar operations
+ that usually require root privileges on UNIX systems. By
+@@ -792,25 +792,25 @@
+ activate this mode and then type usually more familiar and fea-
+ ture-complete.
+
+- <B>--randomize_hosts</B>
++ <B id="--randomize_hosts">--randomize_hosts</B>
+ Tells Nmap to shuffle each group of up to 2048 hosts before it
+ scans them. This can make the scans less obvious to various
+ network monitoring systems, especially when you combine it with
+ slow timing options (see below).
+
+- <B>-M</B> <B>&lt;max</B> <B>sockets&gt;</B>
++ <B id="-M">-M</B> <B>&lt;max</B> <B>sockets&gt;</B>
+ Sets the maximum number of sockets that will be used in parallel
+ for a TCP connect() scan (the default). This is useful to slow
+ down the scan a little bit and avoid crashing remote machines.
+ Another approach is to use -sS, which is generally easier for
+ machines to handle.
+
+- <B>--packet_trace</B>
++ <B id="--packet_trace">--packet_trace</B>
+ Tells Nmap to show all the packets it sends and receives in a
+ tcpdump-like format. This can be tremendously useful for debug-
+ ging, and is also a good learning tool.
+
+- <B>--datadir</B> <B>[directoryname]</B>
++ <B id="--datadir">--datadir</B> <B>[directoryname]</B>
+ Nmap obtains some special data at runtime in files named nmap-
+ service-probes, nmap-services, nmap-protocols, nmap-rpc, nmap-
+ mac-prefixes, and nmap-os-fingerprints. Nmap first searches
+@@ -830,7 +830,7 @@
+ meet your objectives. The following options provide a fine
+ level of control over the scan timing:
+
+- <B>-T</B> <B>&lt;Paranoid|Sneaky|Polite|Normal|Aggressive|Insane&gt;</B>
++ <B id="-T">-T</B> <B>&lt;Paranoid|Sneaky|Polite|Normal|Aggressive|Insane&gt;</B>
+ These are canned timing policies for conveniently expressing
+ your priorities to Nmap. <B>Paranoid</B> mode scans <B>very</B> slowly in the
+ hopes of avoiding detection by IDS systems. It serializes all
+@@ -859,17 +859,17 @@
+ line. Otherwise the defaults for the selected timing mode will
+ override your choices.
+
+- <B>--host_timeout</B> <B>&lt;milliseconds&gt;</B>
++ <B id="--host_timeout">--host_timeout</B> <B>&lt;milliseconds&gt;</B>
+ Specifies the amount of time Nmap is allowed to spend scanning a
+ single host before giving up on that IP. The default timing
+ mode has no host timeout.
+
+- <B>--max_rtt_timeout</B> <B>&lt;milliseconds&gt;</B>
++ <B id="--max_rtt_timeout">--max_rtt_timeout</B> <B>&lt;milliseconds&gt;</B>
+ Specifies the maximum amount of time Nmap is allowed to wait for
+ a probe response before retransmitting or timing out that par-
+ ticular probe. The default mode sets this to about 9000.
+
+- <B>--min_rtt_timeout</B> <B>&lt;milliseconds&gt;</B>
++ <B id="--min_rtt_timeout">--min_rtt_timeout</B> <B>&lt;milliseconds&gt;</B>
+ When the target hosts start to establish a pattern of responding
+ very quickly, Nmap will shrink the amount of time given per
+ probe. This speeds up the scan, but can lead to missed packets
+@@ -877,13 +877,13 @@
+ you can guarantee that Nmap will wait at least the given amount
+ of time before giving up on a probe.
+
+- <B>--initial_rtt_timeout</B> <B>&lt;milliseconds&gt;</B>
++ <B id="--initial_rtt_timeout">--initial_rtt_timeout</B> <B>&lt;milliseconds&gt;</B>
+ Specifies the initial probe timeout. This is generally only
+ useful when scanning firewalled hosts with -P0. Normally Nmap
+ can obtain good RTT estimates from the ping and the first few
+ probes. The default mode uses 6000.
+
+- <B>--max_hostgroup</B> <B>&lt;numhosts&gt;</B>
++ <B id="--max_hostgroup">--max_hostgroup</B> <B>&lt;numhosts&gt;</B>
+ Specifies the maximum number of hosts that Nmap is allowed to
+ scan in parallel. Most of the port scan techniques support
+ multi-host operation, which makes them much quicker. Spreading
+@@ -894,7 +894,7 @@
+ at a time) Nmap behavior. Note that the ping scanner handles
+ its own grouping, and ignores this value.
+
+- <B>--min_hostgroup</B> <B>&lt;numhosts&gt;</B>
++ <B id="--min_hostgroup">--min_hostgroup</B> <B>&lt;numhosts&gt;</B>
+ Specifies the minimum host group size (see previous entry).
+ Large values (such as 50) are often beneficial for unattended
+ scans, though they do take up more memory. Nmap may override
+@@ -902,19 +902,19 @@
+ the same network interface, and some scan types can only handle
+ one host at a time.
+
+- <B>--max_parallelism</B> <B>&lt;number&gt;</B>
++ <B id="--max_parallelism">--max_parallelism</B> <B>&lt;number&gt;</B>
+ Specifies the maximum number of scans Nmap is allowed to perform
+ in parallel. Setting this to one means Nmap will never try to
+ scan more than 1 port at a time. It also effects other parallel
+ scans such as ping sweep, RPC scan, etc.
+
+- <B>--min_parallelism</B> <B>&lt;number&gt;</B>
++ <B id="--min_parallelism">--min_parallelism</B> <B>&lt;number&gt;</B>
+ Tells Nmap to scan at least the given number of ports in paral-
+ lel. This can speed up scans against certain firewalled hosts
+ by an order of magnitude. But be careful -- results will become
+ unreliable if you push it too far.
+
+- <B>--scan_delay</B> <B>&lt;milliseconds&gt;</B>
++ <B id="--scan_delay">--scan_delay</B> <B>&lt;milliseconds&gt;</B>
+ Specifies the <B>minimum</B> amount of time Nmap must wait between
+ probes. This is mostly useful to reduce network load or to slow
+ the scan way down to sneak under IDS thresholds. Nmap will
+@@ -924,7 +924,7 @@
+ So Nmap will try to detect this and lower its rate of UDP probes
+ to one per second.
+
+- <B>--max_scan_delay</B> <B>&lt;milliseconds&gt;</B>
++ <B id="--max_scan_delay">--max_scan_delay</B> <B>&lt;milliseconds&gt;</B>
+ As noted above, Nmap will sometimes enforce a special delay
+ between sending packets. This can provide more accurate results
+ while reducing network congestion, but it can slow the scans
+@@ -938,7 +938,7 @@
+
+
+ </PRE>
+-<H2>TARGET SPECIFICATION</H2><PRE>
++<H2 id="target">TARGET SPECIFICATION</H2><PRE>
+ Everything that isn’t an option (or option argument) in nmap is treated
+ as a target host specification. The simplest case is listing single
+ hostnames or IP addresses on the command line. If you want to scan a
diff --git a/src/nmapoutputbuffer.cpp b/src/nmapoutputbuffer.cpp
new file mode 100644
index 0000000..2667ce8
--- /dev/null
+++ b/src/nmapoutputbuffer.cpp
@@ -0,0 +1,41 @@
+/***************************************************************************
+ * *
+ * Copyright (C) 2005 by Kevin Gilbert *
+ * kev.gilbert@cdu.edu.au *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ * *
+ ***************************************************************************/
+
+#include "nmapoutputbuffer.h"
+
+// constructor
+// ===========
+
+NmapOutputBuffer::NmapOutputBuffer( const uint bufferSize )
+: m_buffer( new char[ bufferSize]),
+ m_free( false )
+{
+}
+
+// destructor
+// ==========
+
+NmapOutputBuffer::~NmapOutputBuffer( )
+{ delete [] m_buffer;
+}
+
+
diff --git a/src/nmapoutputbuffer.h b/src/nmapoutputbuffer.h
new file mode 100644
index 0000000..b741dc4
--- /dev/null
+++ b/src/nmapoutputbuffer.h
@@ -0,0 +1,50 @@
+/***************************************************************************
+ * *
+ * Copyright (C) 2005 by Kevin Gilbert *
+ * kev.gilbert@cdu.edu.au *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ * *
+ ***************************************************************************/
+
+#ifndef _NMAPOUTPUTBUFFER_H_
+#define _NMAPOUTPUTBUFFER_H_
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "global.h"
+
+class NmapOutputBuffer
+{ public:
+ NmapOutputBuffer( const uint bufferSize );
+ virtual ~NmapOutputBuffer( );
+
+ string buffer( ) const { return m_buffer; }
+ bool isFree( ) const { return m_free; }
+ uint length( ) const { return m_length; }
+ void length( const uint l ) { m_length = l; }
+ void setBusy( ) { m_free = false; }
+ void setFree( ) { m_free = true; }
+
+ private:
+ string m_buffer;
+ bool m_free;
+ uint m_length;
+};
+
+#endif // _NMAPOUTPUTBUFFER_H_
diff --git a/src/outputwidget.cpp b/src/outputwidget.cpp
new file mode 100644
index 0000000..2bc82c9
--- /dev/null
+++ b/src/outputwidget.cpp
@@ -0,0 +1,174 @@
+/***************************************************************************
+ * *
+ * Copyright (C) 2005, 2006 by Kevin Gilbert *
+ * kev.gilbert@cdu.edu.au *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ * *
+ ***************************************************************************/
+
+#include <qfile.h>
+#include <qtimer.h>
+
+#include <kconfig.h>
+#include <kdebug.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+
+#include "knmap.h"
+#include "outputwidget.h"
+
+// constructor
+// ===========
+
+OutputWidget::OutputWidget( QWidget* parent, const char* name )
+: QTextEdit( parent, name ),
+ m_append( false ),
+ m_dataBytes( 0 ),
+ m_firstSave( true ),
+ m_priorType( OutputType( -1 ))
+{ setFamily( "monospace" );
+ setReadOnly( true );
+ QTimer::singleShot( 0, this, SLOT( slotUpdateStatusBarText( )));
+}
+
+// addOutput
+// =========
+
+void OutputWidget::addOutput( const OutputType type, const char* buffer, const int buflen )
+{ m_dataBytes += buflen;
+ QString outputText = QString::fromLatin1( buffer, buflen );
+ QString prependText;
+
+ if( m_append && type == m_priorType && m_priorType != OutputType( -1 ))
+ { uint paraNo = paragraphs( ) - 1;
+ prependText = text( paraNo );;
+ prependText = prependText.left( prependText.length( ) - 1 );
+ removeParagraph( paraNo );
+ }
+
+ m_append = buffer[ buflen - 1 ] != '\n';
+ m_priorType = type;
+
+ switch( type )
+ { case Stderr:
+ m_dataBytes += 14;
+ append( "<b><i>" + prependText + outputText + "</i></b>" );
+ break;
+
+ case Stdin:
+ m_dataBytes +=7;
+ append( "<b>" + prependText + outputText + "</b>" );
+ break;
+
+ case Stdout:
+ append( prependText + outputText );
+ break;
+ }
+
+ slotUpdateStatusBarText();
+}
+
+// clearOutput
+// ===========
+
+void OutputWidget::clearOutput( )
+{ m_dataBytes = 0;
+ clear( );
+ slotUpdateStatusBarText();
+}
+
+// fileSave
+// ========
+
+bool OutputWidget::fileSave( const bool saveAs )
+{ if( (saveAs || m_firstSave) && !Knmap::getFilePath( "Output save file", m_path, true ))
+ return false;
+
+ m_firstSave = false;
+ QFile file( m_path );
+
+ if( !file.open( IO_WriteOnly ))
+ { KMessageBox::error( this, QString( i18n( "Could not open \"%1\"\n%2" )).arg( m_path ).arg( file.errorString( )));
+ return false;
+ }
+
+ QTextStream stream( &file );
+ uint noOfParagraphs = paragraphs( );
+ uint paragraphNo;
+
+ for( paragraphNo = 0; paragraphNo < noOfParagraphs; paragraphNo++ )
+ stream << text( paragraphNo ) << endl;
+
+ file.close( );
+ return true;
+}
+
+// fileSaveAs
+// ==========
+
+bool OutputWidget::fileSaveAs( )
+{ return fileSave( true );
+}
+
+// readProfile
+// ===========
+
+void OutputWidget::readProfile( KConfig* config )
+{ m_path = config->readPathEntry( "path" );
+}
+
+// saveProfile
+// ===========
+
+void OutputWidget::saveProfile( KConfig* config )
+{ config->writeEntry( "path", m_path );
+}
+
+// slotUpdateStatusBarText
+// =======================
+
+void OutputWidget::slotUpdateStatusBarText( )
+{ QString dataBytes;
+
+ if( m_dataBytes < 1024 )
+ dataBytes = QString::number( m_dataBytes ) + " bytes";
+ else
+ if( m_dataBytes < 1024 * 1024 )
+ { float kiloBytes = m_dataBytes / float( 1024 );
+
+ if( kiloBytes < 10 )
+ dataBytes.sprintf( "%.3f KBytes", kiloBytes );
+ else
+ if( kiloBytes < 100 )
+ dataBytes.sprintf( "%.2f KBytes", kiloBytes );
+ else
+ dataBytes.sprintf( "%.1f KBytes", kiloBytes );
+ }
+ else
+ { float megaBytes = m_dataBytes / float( 1024 * 1024 );
+
+ if( megaBytes < 10 )
+ dataBytes.sprintf( "%.3f MBytes", megaBytes );
+ else
+ if( megaBytes < 100 )
+ dataBytes.sprintf( "%.2f MBytes", megaBytes );
+ else
+ dataBytes.sprintf( "%.1f MBytes", megaBytes );
+ }
+
+ emit( statusBarText( QString( "Output: %1 lines (%2)" ).arg( QString::number( paragraphs( ) - 1 )).arg( dataBytes )));
+}
diff --git a/src/outputwidget.h b/src/outputwidget.h
new file mode 100644
index 0000000..8555fde
--- /dev/null
+++ b/src/outputwidget.h
@@ -0,0 +1,79 @@
+/***************************************************************************
+ * *
+ * Copyright (C) 2005, 2006 by Kevin Gilbert *
+ * kev.gilbert@cdu.edu.au *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ * *
+ ***************************************************************************/
+
+#ifndef _OUTPUTWIDGET_H_
+#define _OUTPUTWIDGET_H_
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <qtextedit.h>
+#include "global.h"
+
+// forward class definitions
+// =========================
+
+class KConfig;
+
+// OutputWidget class definition
+// =============================
+
+class OutputWidget : public QTextEdit
+{ Q_OBJECT
+
+ public:
+ OutputWidget( QWidget* parent = NULL, const char* name = NULL );
+
+ // output type definitions
+ // =======================
+
+ enum OutputType
+ { Stderr,
+ Stdin,
+ Stdout
+ };
+
+ void addOutput( const OutputType type, const char* buffer, const int buflen );
+ void clearOutput( );
+ bool fileSave( const bool saveAs = false );
+ bool fileSaveAs( );
+ void readProfile( KConfig* config );
+ void saveProfile( KConfig* config );
+
+ signals:
+ void statusBarText( const QString& );
+
+ public slots:
+ void slotUpdateStatusBarText( );
+
+ private:
+ void appendLine( const OutputType type, const QString& text );
+
+ bool m_append;
+ uint m_dataBytes;
+ bool m_firstSave;
+ QString m_path;
+ OutputType m_priorType;
+};
+
+#endif // _OUTPUTWIDGET_H_
diff --git a/src/pandsoptions.cpp b/src/pandsoptions.cpp
new file mode 100644
index 0000000..f007be0
--- /dev/null
+++ b/src/pandsoptions.cpp
@@ -0,0 +1,415 @@
+/***************************************************************************
+ * *
+ * Copyright (C) 2005, 2006 by Kevin Gilbert *
+ * kev.gilbert@cdu.edu.au *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ * *
+ ***************************************************************************/
+
+#include <qcheckbox.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qlineedit.h>
+
+#include <kconfig.h>
+#include <kdebug.h>
+#include <kglobal.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+
+#include "pandsoptions.h"
+#include "whatsthis.h"
+
+// constructor
+// ===========
+
+PAndSOptions::PAndSOptions( QWidget* parent, const char* name )
+: QWidget( parent, name )
+{ createLayout( );
+}
+
+// createLayout
+// ============
+
+void PAndSOptions::createLayout( )
+{ QGridLayout* gridLayout = new QGridLayout( this );
+
+ m_ackCheckBox = new QCheckBox( i18n( "TCP ACK (-PA)" ), this, "ack check" );
+ m_ackLineEdit = new QLineEdit( this, "ack edit" );
+ m_arpCheckBox = new QCheckBox( i18n( "ARP (-PR)" ), this, "arp check" );
+ m_dontPingCheckBox = new QCheckBox( i18n( "Don't ping (-P0)" ), this, "dont ping check" );
+ m_echoCheckBox = new QCheckBox( i18n( "ICMP echo (-PE)" ), this, "icmp echo check" );
+ m_netmaskCheckBox = new QCheckBox( i18n( "ICMP netmask (-PM)" ), this, "icmp netmask check" );
+ m_synCheckBox = new QCheckBox( i18n( "TCP SYN (-PS)" ), this, "syn check" );
+ m_synLineEdit = new QLineEdit( this, "syn edit" );
+ m_timestampCheckBox = new QCheckBox( i18n( "ICMP timestamp (-PP)" ), this, "icmp timestamp check" );
+
+ byte row = 1;
+ gridLayout->addWidget( new QLabel( " ", this ), row, 1 );
+ gridLayout->addWidget( m_ackCheckBox, row++, 3 );
+ gridLayout->addWidget( new QLabel( " ", this ), row, 1 );
+ gridLayout->addWidget( m_ackLineEdit, row++, 3 );
+ gridLayout->addWidget( new QLabel( "#", this ), row, 1 );
+ gridLayout->addWidget( m_arpCheckBox, row++, 3 );
+ gridLayout->addWidget( new QLabel( " ", this ), row, 1 );
+ gridLayout->addWidget( m_dontPingCheckBox, row++, 3 );
+ gridLayout->addWidget( new QLabel( "#", this ), row, 1 );
+ gridLayout->addWidget( m_echoCheckBox, row++, 3 );
+ byte rowBlock1 = row;
+
+ row = 1;
+ gridLayout->addWidget( new QLabel( " ", this ), row, 5 );
+ gridLayout->addWidget( m_netmaskCheckBox, row++, 7 );
+ gridLayout->addWidget( new QLabel( " ", this ), row, 5 );
+ gridLayout->addWidget( m_synCheckBox, row++, 7 );
+ gridLayout->addWidget( new QLabel( " ", this ), row, 5 );
+ gridLayout->addWidget( m_synLineEdit, row++, 7 );
+ gridLayout->addWidget( new QLabel( "#", this ), row, 5 );
+ gridLayout->addWidget( m_timestampCheckBox, row++, 7 );
+ byte rowBlock2 = row;
+
+ m_scanFTPBounceCheckBox = new QCheckBox( i18n( "FTP Bounce (-b)" ), this, "ftp bounce scan check" );
+ m_scanFTPRelayLineEdit = new QLineEdit( this, "ftp relay edit" );
+ m_scanIdleCheckBox = new QCheckBox( i18n( "Idle (-sI)" ), this, "idle scan check" );
+ m_scanListCheckBox = new QCheckBox( i18n( "List Scan (-sL)" ), this, "list scan check" );
+ m_scanNullCheckBox = new QCheckBox( i18n( "Null Scan (-sN)" ), this, "null scan check" );
+ m_scanPingCheckBox = new QCheckBox( i18n( "Ping Scan (-sP)" ), this, "ping scan check" );
+ m_scanProtocolCheckBox = new QCheckBox( i18n( "Protocol Scan (-sO)" ), this, "protocol scan check" );
+ m_scanRPCCheckBox = new QCheckBox( i18n( "RPC (-sR)" ), this, "rpc scan check" );
+ m_scanFINCheckBox = new QCheckBox( i18n( "Stealth FIN (-sF)" ), this, "fin scan check" );
+ m_scanAckCheckBox = new QCheckBox( i18n( "TCP Ack Scan (-sA)" ), this, "ack scan check" );
+ m_scanSYNCheckBox = new QCheckBox( i18n( "TCP SYN (-sS)" ), this, "syn scan check" );
+ m_scanTCPConnectCheckBox = new QCheckBox( i18n( "TCP Connect (-sT)" ), this, "connect scan check" );
+ m_scanUDPCheckBox = new QCheckBox( i18n( "UDP Scan (-sU)" ), this, "udp scan check" );
+ m_scanVersionCheckBox = new QCheckBox( i18n( "Version Detection (-sV)" ), this, "version scan check" );
+ m_scanWindowCheckBox = new QCheckBox( i18n( "Window Scan (-sW)" ), this, "window scan check" );
+ m_scanXmasCheckBox = new QCheckBox( i18n( "Xmas Tree (-sX)" ), this, "xmas scan check" );
+ m_zombieLineEdit = new QLineEdit( this, "zombie edit" );
+
+ row = 1;
+ gridLayout->addWidget( new QLabel( " ", this ), row, 9 );
+ gridLayout->addWidget( m_scanFTPBounceCheckBox, row++, 11 );
+ gridLayout->addWidget( new QLabel( " ", this ), row, 9 );
+ gridLayout->addWidget( m_scanFTPRelayLineEdit, row++, 11 );
+ gridLayout->addWidget( new QLabel( "#", this ), row, 9 );
+ gridLayout->addWidget( m_scanIdleCheckBox, row++, 11 );
+ gridLayout->addWidget( new QLabel( " ", this ), row, 9 );
+ gridLayout->addWidget( m_zombieLineEdit, row++, 11 );
+ gridLayout->addWidget( new QLabel( " ", this ), row, 9 );
+ gridLayout->addWidget( m_scanListCheckBox, row++, 11 );
+ gridLayout->addWidget( new QLabel( "#", this ), row, 9 );
+ gridLayout->addWidget( m_scanNullCheckBox, row++, 11 );
+ byte rowBlock3 = row;
+
+ row = 1;
+ gridLayout->addWidget( new QLabel( " ", this ), row, 13 );
+ gridLayout->addWidget( m_scanPingCheckBox, row++, 15 );
+ gridLayout->addWidget( new QLabel( "#", this ), row, 13 );
+ gridLayout->addWidget( m_scanProtocolCheckBox, row++, 15 );
+ gridLayout->addWidget( new QLabel( " ", this ), row, 13 );
+ gridLayout->addWidget( m_scanRPCCheckBox, row++, 15 );
+ gridLayout->addWidget( new QLabel( "#", this ), row, 13 );
+ gridLayout->addWidget( m_scanFINCheckBox, row++, 15 );
+ gridLayout->addWidget( new QLabel( "#", this ), row, 13 );
+ gridLayout->addWidget( m_scanAckCheckBox, row++, 15 );
+ gridLayout->addWidget( new QLabel( "#", this ), row, 13 );
+ gridLayout->addWidget( m_scanSYNCheckBox, row++, 15 );
+ byte rowBlock4 = row;
+
+ row = 1;
+ gridLayout->addWidget( new QLabel( " ", this ), row, 17 );
+ gridLayout->addWidget( m_scanTCPConnectCheckBox, row++, 19 );
+ gridLayout->addWidget( new QLabel( "#", this ), row, 17 );
+ gridLayout->addWidget( m_scanUDPCheckBox, row++, 19 );
+ gridLayout->addWidget( new QLabel( " ", this ), row, 17 );
+ gridLayout->addWidget( m_scanVersionCheckBox, row++, 19 );
+ gridLayout->addWidget( new QLabel( "#", this ), row, 17 );
+ gridLayout->addWidget( m_scanWindowCheckBox, row++, 19 );
+ gridLayout->addWidget( new QLabel( "#", this ), row, 17 );
+ gridLayout->addWidget( m_scanXmasCheckBox, row++, 19 );
+ byte rowBlock5 = row;
+
+ gridLayout->setColStretch( 0, 5 );
+ gridLayout->setColStretch( 2, 1 );
+ gridLayout->setColStretch( 3, 20 );
+ gridLayout->setColStretch( 4, 5 );
+ gridLayout->setColStretch( 6, 1 );
+ gridLayout->setColStretch( 7, 20 );
+ gridLayout->setColStretch( 8, 5 );
+ gridLayout->setColStretch( 10, 1 );
+ gridLayout->setColStretch( 11, 20 );
+ gridLayout->setColStretch( 12, 5 );
+ gridLayout->setColStretch( 14, 1 );
+ gridLayout->setColStretch( 15, 20 );
+ gridLayout->setColStretch( 16, 5 );
+ gridLayout->setColStretch( 18, 1 );
+ gridLayout->setColStretch( 19, 20 );
+ gridLayout->setColStretch( 20, 5 );
+
+ gridLayout->setRowStretch( 0, 10 );
+ gridLayout->setRowStretch( _max_( rowBlock1, _max_( rowBlock2, _max_( rowBlock3, _max_( rowBlock4, rowBlock5 )))), 10 );
+}
+
+// finaliseInitialisation
+// ======================
+
+void PAndSOptions::finaliseInitialisation( )
+{ WhatsThis* whatsThis = new WhatsThis( this );
+
+ connect( m_ackCheckBox, SIGNAL( clicked( )), SLOT( slotAckClicked( )));
+ connect( m_scanFTPBounceCheckBox, SIGNAL( clicked( )), SLOT( slotScanFTPBounceCheckBoxClicked( )));
+ connect( m_scanIdleCheckBox, SIGNAL( clicked( )), SLOT( slotScanIdleCheckBoxClicked( )));
+ connect( m_synCheckBox, SIGNAL( clicked( )), SLOT( slotSynClicked( )));
+ connect( whatsThis, SIGNAL( clicked( )), SLOT( slotWhatsThisClicked( )));
+
+ connect( m_ackCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_ackLineEdit, SIGNAL( textChanged ( const QString& )), SIGNAL( optionsDirty( )));
+ connect( m_arpCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_dontPingCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_echoCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_netmaskCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_scanAckCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_scanFINCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_scanFTPBounceCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_scanFTPRelayLineEdit, SIGNAL( textChanged ( const QString& )), SIGNAL( optionsDirty( )));
+ connect( m_scanIdleCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_scanListCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_scanNullCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_scanPingCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_scanProtocolCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_scanRPCCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_scanSYNCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_scanTCPConnectCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_scanUDPCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_scanVersionCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_scanWindowCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_scanXmasCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_synCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_synLineEdit, SIGNAL( textChanged ( const QString& )), SIGNAL( optionsDirty( )));
+ connect( m_timestampCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_zombieLineEdit, SIGNAL( textChanged ( const QString& )), SIGNAL( optionsDirty( )));
+}
+
+// getOptions
+// ==========
+
+bool PAndSOptions::getOptions( bool& needRoot )
+{ m_ackState = m_ackCheckBox->isChecked( );
+ m_ackValue = m_ackLineEdit->text( );
+ m_arpState = m_arpCheckBox->isChecked( );
+ m_dontPingState = m_dontPingCheckBox->isChecked( );
+ m_echoState = m_echoCheckBox->isChecked( );
+ m_netmaskState = m_netmaskCheckBox->isChecked( );
+ m_scanAckState = m_scanAckCheckBox->isChecked( );
+ m_scanFINState = m_scanFINCheckBox->isChecked( );
+ m_scanFTPBounceState = m_scanFTPBounceCheckBox->isChecked( );
+ m_scanFTPRelayHost = m_scanFTPRelayLineEdit->text( );
+ m_scanIdleState = m_scanIdleCheckBox->isChecked( );
+ m_scanListState = m_scanListCheckBox->isChecked( );
+ m_scanNullState = m_scanNullCheckBox->isChecked( );
+ m_scanPingState = m_scanPingCheckBox->isChecked( );
+ m_scanProtocolState = m_scanProtocolCheckBox->isChecked( );
+ m_scanRPCState = m_scanRPCCheckBox->isChecked( );
+ m_scanSYNState = m_scanSYNCheckBox->isChecked( );
+ m_scanTCPConnectState = m_scanTCPConnectCheckBox->isChecked( );
+ m_scanUDPState = m_scanUDPCheckBox->isChecked( );
+ m_scanVersionState = m_scanVersionCheckBox->isChecked( );
+ m_scanWindowState = m_scanWindowCheckBox->isChecked( );
+ m_scanXmasState = m_scanXmasCheckBox->isChecked( );
+ m_synState = m_synCheckBox->isChecked( );
+ m_synValue = m_synLineEdit->text( );
+ m_timestampState = m_timestampCheckBox->isChecked( );
+ m_zombieDetails = m_zombieLineEdit->text( );
+
+ needRoot = needRoot ||
+ m_arpState ||
+ m_echoState ||
+ m_scanAckState ||
+ m_scanFINState ||
+ m_scanIdleState ||
+ m_scanNullState ||
+ m_scanProtocolState ||
+ m_scanSYNState ||
+ m_scanUDPState ||
+ m_scanWindowState ||
+ m_scanXmasState ||
+ m_timestampState;
+
+ return true;
+}
+
+// readProfile
+// ===========
+
+void PAndSOptions::readProfile( KConfig* config )
+{ m_ackState = config->readBoolEntry( "ackState" );
+ m_ackValue = config->readEntry( "ackValue" );
+ m_arpState = config->readBoolEntry( "arpState" );
+ m_dontPingState = config->readBoolEntry( "dontPingState" );
+ m_echoState = config->readBoolEntry( "echoState" );
+ m_netmaskState = config->readBoolEntry( "netmaskState" );
+ m_scanAckState = config->readBoolEntry( "scanAckState" );
+ m_scanFINState = config->readBoolEntry( "scanFINState" );
+ m_scanFTPBounceState = config->readBoolEntry( "scanFTPBounceState" );
+ m_scanFTPRelayHost = config->readEntry( "scanFTPRelayHost" );
+ m_scanIdleState = config->readBoolEntry( "scanIdleState" );
+ m_scanListState = config->readBoolEntry( "scanListState" );
+ m_scanNullState = config->readBoolEntry( "scanNullState" );
+ m_scanPingState = config->readBoolEntry( "scanPingState" );
+ m_scanProtocolState = config->readBoolEntry( "scanProtocolState" );
+ m_scanRPCState = config->readBoolEntry( "scanRPCState" );
+ m_scanSYNState = config->readBoolEntry( "scanSYNState" );
+ m_scanTCPConnectState = config->readBoolEntry( "scanTCPConnectState" );
+ m_scanUDPState = config->readBoolEntry( "scanUDPState" );
+ m_scanVersionState = config->readBoolEntry( "scanVersionState" );
+ m_scanWindowState = config->readBoolEntry( "scanWindowState" );
+ m_scanXmasState = config->readBoolEntry( "scanXmasState" );
+ m_synState = config->readBoolEntry( "synState" );
+ m_synValue = config->readEntry( "synValue" );
+ m_timestampState = config->readBoolEntry( "timestampState" );
+ m_zombieDetails = config->readEntry( "zombieDetails" );
+}
+
+// saveProfile
+// ===========
+
+void PAndSOptions::saveProfile( KConfig* config )
+{ config->writeEntry( "ackState", m_ackState );
+ config->writeEntry( "ackValue", m_ackValue );
+ config->writeEntry( "arpState", m_arpState );
+ config->writeEntry( "dontPingState", m_dontPingState );
+ config->writeEntry( "echoState", m_echoState );
+ config->writeEntry( "netmaskState", m_netmaskState );
+ config->writeEntry( "scanAckState", m_scanAckState );
+ config->writeEntry( "scanFINState", m_scanFINState );
+ config->writeEntry( "scanFTPBounceState", m_scanFTPBounceState );
+ config->writeEntry( "scanFTPRelayHost", m_scanFTPRelayHost );
+ config->writeEntry( "scanIdleState", m_scanIdleState );
+ config->writeEntry( "scanListState", m_scanListState );
+ config->writeEntry( "scanNullState", m_scanNullState );
+ config->writeEntry( "scanPingState", m_scanPingState );
+ config->writeEntry( "scanProtocolState", m_scanProtocolState );
+ config->writeEntry( "scanRPCState", m_scanRPCState );
+ config->writeEntry( "scanSYNState", m_scanSYNState );
+ config->writeEntry( "scanTCPConnectState", m_scanTCPConnectState );
+ config->writeEntry( "scanUDPState", m_scanUDPState );
+ config->writeEntry( "scanVersionState", m_scanVersionState );
+ config->writeEntry( "scanWindowState", m_scanWindowState );
+ config->writeEntry( "scanXmasState", m_scanXmasState );
+ config->writeEntry( "synState", m_synState );
+ config->writeEntry( "synValue", m_synValue );
+ config->writeEntry( "timestampState", m_timestampState );
+ config->writeEntry( "zombieDetails", m_zombieDetails );
+}
+
+// setInitialValues
+// ================
+
+void PAndSOptions::setInitialValues( )
+{ m_ackCheckBox->setChecked( m_ackState );
+ m_ackLineEdit->setText( m_ackValue );
+ m_arpCheckBox->setChecked( m_arpState );
+ m_dontPingCheckBox->setChecked( m_dontPingState );
+ m_echoCheckBox->setChecked( m_echoState );
+ m_netmaskCheckBox->setChecked( m_netmaskState );
+ m_scanAckCheckBox->setChecked( m_scanAckState );
+ m_scanFINCheckBox->setChecked( m_scanFINState );
+ m_scanFTPBounceCheckBox->setChecked( m_scanFTPBounceState );
+ m_scanFTPRelayLineEdit->setText( m_scanFTPRelayHost );
+ m_scanIdleCheckBox->setChecked( m_scanIdleState );
+ m_scanListCheckBox->setChecked( m_scanListState );
+ m_scanNullCheckBox->setChecked( m_scanNullState );
+ m_scanPingCheckBox->setChecked( m_scanPingState );
+ m_scanProtocolCheckBox->setChecked( m_scanProtocolState );
+ m_scanRPCCheckBox->setChecked( m_scanRPCState );
+ m_scanSYNCheckBox->setChecked( m_scanSYNState );
+ m_scanTCPConnectCheckBox->setChecked( m_scanTCPConnectState );
+ m_scanUDPCheckBox->setChecked( m_scanUDPState );
+ m_scanVersionCheckBox->setChecked( m_scanVersionState );
+ m_scanWindowCheckBox->setChecked( m_scanWindowState );
+ m_scanXmasCheckBox->setChecked( m_scanXmasState );
+ m_synCheckBox->setChecked( m_synState );
+ m_synLineEdit->setText( m_synValue );
+ m_timestampCheckBox->setChecked( m_timestampState );
+ m_zombieLineEdit->setText( m_zombieDetails );
+
+ slotAckClicked( );
+ slotScanFTPBounceCheckBoxClicked( );
+ slotScanIdleCheckBoxClicked( );
+ slotSynClicked( );
+}
+
+// slotAckClicked
+// ==============
+
+void PAndSOptions::slotAckClicked( )
+{ m_ackLineEdit->setEnabled( m_ackCheckBox->isChecked( ));
+}
+
+// slotScanFTPBounceCheckBoxClicked
+// ================================
+
+void PAndSOptions::slotScanFTPBounceCheckBoxClicked( )
+{ m_scanFTPRelayLineEdit->setEnabled( m_scanFTPBounceCheckBox->isChecked( ));
+}
+
+// slotScanIdleCheckBoxClicked
+// ===========================
+
+void PAndSOptions::slotScanIdleCheckBoxClicked( )
+{ m_zombieLineEdit->setEnabled( m_scanIdleCheckBox->isChecked( ));
+}
+
+// slotSynClicked
+// ==============
+
+void PAndSOptions::slotSynClicked( )
+{ m_synLineEdit->setEnabled( m_synCheckBox->isChecked( ));
+}
+
+// slotWhatsThisClicked
+// ====================
+
+void PAndSOptions::slotWhatsThisClicked( )
+{ if( m_ackCheckBox->hasMouse( )) emit( displayHelp( "-PA" ));
+ else if( m_ackLineEdit->hasMouse( )) emit( displayHelp( "-PA" ));
+ else if( m_arpCheckBox->hasMouse( )) emit( displayHelp( "-PR" ));
+ else if( m_dontPingCheckBox->hasMouse( )) emit( displayHelp( "-P0" ));
+ else if( m_echoCheckBox->hasMouse( )) emit( displayHelp( "-PE" ));
+ else if( m_netmaskCheckBox->hasMouse( )) emit( displayHelp( "-PM" ));
+ else if( m_scanAckCheckBox->hasMouse( )) emit( displayHelp( "-sA" ));
+ else if( m_scanFINCheckBox->hasMouse( )) emit( displayHelp( "-sF" ));
+ else if( m_scanFTPBounceCheckBox->hasMouse( )) emit( displayHelp( "-b" ));
+ else if( m_scanFTPRelayLineEdit->hasMouse( )) emit( displayHelp( "-b" ));
+ else if( m_scanIdleCheckBox->hasMouse( )) emit( displayHelp( "-sI" ));
+ else if( m_zombieLineEdit->hasMouse( )) emit( displayHelp( "-sI" ));
+ else if( m_scanListCheckBox->hasMouse( )) emit( displayHelp( "-sL" ));
+ else if( m_scanNullCheckBox->hasMouse( )) emit( displayHelp( "-sN" ));
+ else if( m_scanPingCheckBox->hasMouse( )) emit( displayHelp( "-sP" ));
+ else if( m_scanProtocolCheckBox->hasMouse( )) emit( displayHelp( "-sO" ));
+ else if( m_scanRPCCheckBox->hasMouse( )) emit( displayHelp( "-sR" ));
+ else if( m_scanTCPConnectCheckBox->hasMouse( )) emit( displayHelp( "-sT" ));
+ else if( m_scanUDPCheckBox->hasMouse( )) emit( displayHelp( "-sU" ));
+ else if( m_scanVersionCheckBox->hasMouse( )) emit( displayHelp( "-sV" ));
+ else if( m_scanWindowCheckBox->hasMouse( )) emit( displayHelp( "-sW" ));
+ else if( m_scanSYNCheckBox->hasMouse( )) emit( displayHelp( "-sS" ));
+ else if( m_scanXmasCheckBox->hasMouse( )) emit( displayHelp( "-sX" ));
+ else if( m_synCheckBox->hasMouse( )) emit( displayHelp( "-PS" ));
+ else if( m_synLineEdit->hasMouse( )) emit( displayHelp( "-PS" ));
+ else if( m_timestampCheckBox->hasMouse( )) emit( displayHelp( "-PP" ));
+ else emit( displayUnknown( ));
+}
diff --git a/src/pandsoptions.h b/src/pandsoptions.h
new file mode 100644
index 0000000..92a487c
--- /dev/null
+++ b/src/pandsoptions.h
@@ -0,0 +1,153 @@
+/***************************************************************************
+ * *
+ * Copyright (C) 2005, 2006 by Kevin Gilbert *
+ * kev.gilbert@cdu.edu.au *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ * *
+ ***************************************************************************/
+
+#ifndef _PANDSOPTIONS_H_
+#define _PANDSOPTIONS_H_
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <qwidget.h>
+#include "global.h"
+
+// forward class definitions
+// =========================
+
+class QCheckBox;
+class QLineEdit;
+class KConfig;
+
+// SimpleOptions class definition
+// ==============================
+
+class PAndSOptions : public QWidget
+{ Q_OBJECT
+
+ public:
+ PAndSOptions( QWidget* parent, const char* name = NULL );
+
+ void finaliseInitialisation( );
+ bool getOptions( bool& needRoot );
+ void readProfile( KConfig* config );
+ void saveProfile( KConfig* config );
+ void setInitialValues( );
+
+ bool ackState( ) const { return m_ackState; }
+ QString ackValue( ) const { return m_ackValue; }
+ bool arpState( ) const { return m_arpState; }
+ bool dontPingState( ) const { return m_dontPingState; }
+ bool echoState( ) const { return m_echoState; }
+ bool netmaskState( ) const { return m_netmaskState; }
+ bool scanAckState( ) const { return m_scanAckState; }
+ bool scanFINState( ) const { return m_scanFINState; }
+ bool scanFTPBounceState( ) const { return m_scanFTPBounceState; }
+ QString scanFTPRelayHost( ) const { return m_scanFTPRelayHost; }
+ bool scanIdleState( ) const { return m_scanIdleState; }
+ bool scanListState( ) const { return m_scanListState; }
+ bool scanNullState( ) const { return m_scanNullState; }
+ bool scanPingState( ) const { return m_scanPingState; }
+ bool scanProtocolState( ) const { return m_scanProtocolState; }
+ bool scanRPCState( ) const { return m_scanRPCState; }
+ bool scanSYNState( ) const { return m_scanSYNState; }
+ bool scanTCPConnectState( ) const { return m_scanTCPConnectState; }
+ bool scanUDPState( ) const { return m_scanUDPState; }
+ bool scanVersionState( ) const { return m_scanVersionState; }
+ bool scanWindowState( ) const { return m_scanWindowState; }
+ bool scanXmasState( ) const { return m_scanXmasState; }
+ bool synState( ) const { return m_synState; }
+ QString synValue( ) const { return m_synValue; }
+ bool timestampState( ) const { return m_timestampState; }
+ QString zombieDetails( ) const { return m_zombieDetails; }
+
+ signals:
+ void disableFastScan( );
+ void displayDocBook( const QString& );
+ void displayHelp( const QString& );
+ void displayUnknown( );
+ void optionsDirty( );
+
+ private slots:
+ void slotAckClicked( );
+ void slotScanFTPBounceCheckBoxClicked( );
+ void slotScanIdleCheckBoxClicked( );
+ void slotSynClicked( );
+ void slotWhatsThisClicked( );
+
+ private:
+ void createLayout( );
+
+ QCheckBox* m_ackCheckBox;
+ QLineEdit* m_ackLineEdit;
+ bool m_ackState;
+ QString m_ackValue;
+ QCheckBox* m_arpCheckBox;
+ bool m_arpState;
+ QCheckBox* m_dontPingCheckBox;
+ bool m_dontPingState;
+ QCheckBox* m_echoCheckBox;
+ bool m_echoState;
+ QCheckBox* m_netmaskCheckBox;
+ bool m_netmaskState;
+ QCheckBox* m_scanAckCheckBox;
+ bool m_scanAckState;
+ QCheckBox* m_scanFINCheckBox;
+ bool m_scanFINState;
+ QCheckBox* m_scanFTPBounceCheckBox;
+ bool m_scanFTPBounceState;
+ QString m_scanFTPRelayHost;
+ QLineEdit* m_scanFTPRelayLineEdit;
+ QCheckBox* m_scanIdleCheckBox;
+ bool m_scanIdleState;
+ QCheckBox* m_scanListCheckBox;
+ bool m_scanListState;
+ QCheckBox* m_scanNullCheckBox;
+ bool m_scanNullState;
+ QCheckBox* m_scanPingCheckBox;
+ bool m_scanPingState;
+ QCheckBox* m_scanProtocolCheckBox;
+ bool m_scanProtocolState;
+ QCheckBox* m_scanRPCCheckBox;
+ bool m_scanRPCState;
+ QCheckBox* m_scanTCPConnectCheckBox;
+ bool m_scanTCPConnectState;
+ QCheckBox* m_scanUDPCheckBox;
+ bool m_scanUDPState;
+ QCheckBox* m_scanVersionCheckBox;
+ bool m_scanVersionState;
+ QCheckBox* m_scanWindowCheckBox;
+ bool m_scanWindowState;
+ QCheckBox* m_scanSYNCheckBox;
+ bool m_scanSYNState;
+ QCheckBox* m_scanXmasCheckBox;
+ bool m_scanXmasState;
+ QCheckBox* m_synCheckBox;
+ QLineEdit* m_synLineEdit;
+ bool m_synState;
+ QString m_synValue;
+ QCheckBox* m_timestampCheckBox;
+ bool m_timestampState;
+ QString m_zombieDetails;
+ QLineEdit* m_zombieLineEdit;
+};
+
+#endif // _PANDSOPTIONS_H_
diff --git a/src/profiledialog.cpp b/src/profiledialog.cpp
new file mode 100644
index 0000000..b4c8f2b
--- /dev/null
+++ b/src/profiledialog.cpp
@@ -0,0 +1,325 @@
+/***************************************************************************
+ * *
+ * Copyright (C) 2005, 2006 by Kevin Gilbert *
+ * kev.gilbert@cdu.edu.au *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ * *
+ ***************************************************************************/
+
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qlineedit.h>
+#include <qlistbox.h>
+#include <qmap.h>
+#include <qpopupmenu.h>
+
+#include <kapplication.h>
+#include <kconfig.h>
+#include <kdebug.h>
+#include <kinputdialog.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+
+#include "profiledialog.h"
+
+// constructor
+// ===========
+
+ProfileDialog::ProfileDialog( Action action,
+ const QString& currentProfile,
+ QWidget* parent,
+ const char* name )
+: KDialogBase( Plain, "", Ok | Cancel, Ok, parent, name ),
+ m_action( action )
+{ switch( m_action )
+ { case Copy: setCaption( "Copy profile" ); break;
+ case Delete: setCaption( "Delete profile" ); break;
+ case Load: setCaption( "Load profile" ); break;
+ case Rename: setCaption( "Rename profile" ); break;
+ case SaveAs: setCaption( "Save profile as" ); break;
+ }
+
+ createlayout( );
+ setInitialValues( currentProfile );
+
+ connect( m_profileListBox, SIGNAL( contextMenuRequested( QListBoxItem*, const QPoint& )), SLOT( slotProfileListContextMenu( QListBoxItem*, const QPoint& )));
+ connect( m_profileListBox, SIGNAL( doubleClicked( QListBoxItem* )), SLOT( slotOk( )));
+ connect( m_profileListBox, SIGNAL( selectionChanged( )), SLOT( slotProfileListBoxChanged( )));
+}
+
+// checkForDuplicateName
+// =====================
+
+bool ProfileDialog::checkForDuplicateName( const QString& profileName )
+{ if( !kapp->config( )->hasGroup( PROFILE_PREFIX + profileName ))
+ return true;
+
+ KMessageBox::sorry( this, QString( i18n( "Profile \"%1\" already exists, please choose another name or press 'Cancel'" )).arg( profileName ), i18n( "Duplicate profile name" ));
+ return false;
+}
+
+// constructNewProfileName
+// =======================
+
+QString ProfileDialog::constructNewProfileName( const QString& initialProfileName ) const
+{ QString profileName = PROFILE_PREFIX + initialProfileName + "_copy";
+
+ while( kapp->config( )->hasGroup( profileName ))
+ profileName += "_copy";
+
+ return stripPrefix( profileName );
+}
+
+// copy
+// ====
+
+void ProfileDialog::copy( const QString& fromProfileName, const QString& toProfileName )
+{ QMap<QString, QString> map = kapp->config( )->entryMap( PROFILE_PREFIX + fromProfileName );
+ kapp->config( )->setGroup( PROFILE_PREFIX + toProfileName );
+
+ for( QMap<QString, QString>::Iterator it = map.begin( ); it != map.end( ); ++it )
+ kapp->config( )->writeEntry( it.key( ), it.data( ));
+
+ m_profileListBox->insertItem( toProfileName );
+ m_profileListBox->sort( );
+}
+
+// createlayout
+// ============
+
+void ProfileDialog::createlayout( )
+{ QGridLayout* layout = new QGridLayout( plainPage( ));
+ m_profileListBox = new QListBox( plainPage( ), "profiles list box" );
+ m_profileLineEdit = new QLineEdit( plainPage( ), "profiles line edit" );
+
+ layout->addWidget( new QLabel( "Profile name: ", plainPage( ), "name label" ), 1, 1, Qt::AlignRight );
+ layout->addWidget( m_profileLineEdit, 1, 2 );
+ layout->addWidget( new QLabel( "Known profiles: ", plainPage( ), "name label" ), 3, 1, Qt::AlignRight | Qt::AlignTop );
+ layout->addWidget( m_profileListBox, 3, 2 );
+
+ layout->setColStretch( 0, 1 );
+ layout->setColStretch( 2, 20 );
+ layout->setColStretch( 3, 1 );
+
+ layout->setRowStretch( 0, 2 );
+ layout->setRowStretch( 2, 1 );
+ layout->setRowStretch( 3, 10 );
+ layout->setRowStretch( 4, 2 );
+
+ switch( m_action )
+ { case Delete:
+ case Load:
+ m_profileLineEdit->setReadOnly( true );
+ break;
+
+ default:
+ break;
+ }
+}
+
+// deelete
+// =======
+
+void ProfileDialog::deelete( const QString& profileName, const bool ask )
+{ if( !kapp->config( )->hasGroup( PROFILE_PREFIX + profileName ))
+ { ASSERT( false );
+ return ;
+ }
+
+ QListBoxItem* item = m_profileListBox->findItem( profileName, Qt::ExactMatch );
+ ASSERT( item != NULL );
+
+ if( item != NULL )
+ deelete( item, ask );
+}
+
+// deelete
+// =======
+
+void ProfileDialog::deelete( QListBoxItem* item, const bool ask )
+{ if( ask && KMessageBox::Yes != KMessageBox::questionYesNo( this,
+ QString( i18n( "Delete profile \"%1\"?" )).arg( item->text( )),
+ i18n( "Confirm profile deletion" )))
+ return;
+
+ kapp->config( )->deleteGroup( PROFILE_PREFIX + item->text( ));
+ m_profileListBox->takeItem( item );
+ delete item;
+}
+
+// getNewProfileName
+// =================
+
+bool ProfileDialog::getNewProfileName( QString& profileName )
+{ while( true )
+ { bool ok;
+ profileName = KInputDialog::getText( i18n( "Profile name" ), i18n( "New profile name" ), profileName, &ok, this, "profile name" );
+
+ if( !ok )
+ return false;
+
+ if( checkForDuplicateName( profileName ))
+ break;
+ }
+
+ return true;
+}
+
+// setInitialValues
+// ================
+
+void ProfileDialog::setInitialValues( const QString& currentProfile )
+{ ushort currentItem = ushort( -1 );
+ QStringList profileList = kapp->config( )->groupList( );
+ ushort i;
+ QStringList::Iterator it;
+
+ for( i = 0, it = profileList.begin( ); it != profileList.end( ); ++it )
+ if( (*it).startsWith( PROFILE_PREFIX ))
+ { m_profileListBox->insertItem( stripPrefix( *it ), i );
+
+ if( *it == currentProfile )
+ currentItem = i;
+
+ i++;
+ }
+
+ if( currentItem != ushort( -1 ))
+ { m_profileListBox->setSelected( currentItem, true );
+
+ if( m_action == Copy )
+ m_profileLineEdit->setText( constructNewProfileName( m_profileListBox->currentText( )));
+ else
+ m_profileLineEdit->setText( m_profileListBox->currentText( ));
+ }
+
+ m_profileListBox->sort( );
+}
+
+// slotCopy
+// ========
+
+void ProfileDialog::slotCopy( )
+{ QString fromProfileName = m_contextItem->text( );
+ QString toProfileName = constructNewProfileName( fromProfileName );
+
+ if( getNewProfileName( toProfileName ))
+ copy( fromProfileName, toProfileName );
+}
+
+// slotDelete
+// ==========
+
+void ProfileDialog::slotDelete( )
+{ deelete( m_contextItem, true );
+}
+
+// slotOk
+// ======
+
+void ProfileDialog::slotOk( )
+{ QString fromProfileName;
+ QListBoxItem* item;
+ QString toProfileName;
+
+ switch( m_action )
+ { case Copy:
+ fromProfileName = m_profileListBox->currentText( );
+ toProfileName = m_profileLineEdit->text( );
+
+ if( !checkForDuplicateName( toProfileName ))
+ return;
+
+ copy( fromProfileName, toProfileName );
+ break;
+
+ case Delete:
+ deelete( m_profileLineEdit->text( ), true );
+ break;
+
+ case Load:
+ m_profileName = PROFILE_PREFIX + m_profileLineEdit->text( );
+ break;
+
+ case Rename:
+ fromProfileName = m_profileListBox->currentText( );
+ toProfileName = m_profileLineEdit->text( );
+
+ if( !checkForDuplicateName( toProfileName ))
+ return;
+
+ copy( fromProfileName, toProfileName );
+ deelete( fromProfileName, false );
+ break;
+
+ case SaveAs:
+ m_profileName = m_profileLineEdit->text( );
+ item = m_profileListBox->findItem( m_profileName, Qt::ExactMatch );
+
+ if( item != NULL )
+ if( KMessageBox::Yes != KMessageBox::questionYesNo( this, QString( i18n( "Profile \"%1\" already exists - overwrite it?" )).arg( m_profileName ), i18n( "Profile exists" )))
+ return;
+
+ m_profileName = PROFILE_PREFIX + m_profileName;
+ break;
+ }
+
+ KDialogBase::slotOk( );
+}
+
+// slotProfileListBoxChanged
+// =========================
+
+void ProfileDialog::slotProfileListBoxChanged( )
+{ if( m_action == Copy )
+ m_profileLineEdit->setText( constructNewProfileName( m_profileListBox->currentText( )));
+ else
+ m_profileLineEdit->setText( m_profileListBox->currentText( ));
+}
+
+// slotProfileListContextMenu
+// ==========================
+
+void ProfileDialog::slotProfileListContextMenu( QListBoxItem* item, const QPoint& pos )
+{ m_contextItem = item;
+ QPopupMenu* contextMenu = new QPopupMenu( this, "context menu" );
+
+ contextMenu->insertItem( i18n( "&Copy" ), this, SLOT( slotCopy( )));
+ contextMenu->insertItem( i18n( "&Delete" ), this, SLOT( slotDelete( )));
+ contextMenu->insertItem( i18n( "&Rename" ), this, SLOT( slotRename( )));
+
+ contextMenu->exec( pos );
+}
+
+// slotRename
+// ==========
+
+void ProfileDialog::slotRename( )
+{ QString profileName = m_contextItem->text( );
+
+ if( getNewProfileName( profileName ))
+ { copy( m_contextItem->text( ), profileName );
+ deelete( m_contextItem, false );
+ }
+}
+
+// stripPrefix
+// ===========
+
+QString ProfileDialog::stripPrefix( const QString& profileName ) const
+{ return profileName.right( profileName.length( ) - strlen( PROFILE_PREFIX ));
+}
diff --git a/src/profiledialog.h b/src/profiledialog.h
new file mode 100644
index 0000000..3165dce
--- /dev/null
+++ b/src/profiledialog.h
@@ -0,0 +1,90 @@
+/***************************************************************************
+ * *
+ * Copyright (C) 2005, 2006 by Kevin Gilbert *
+ * kev.gilbert@cdu.edu.au *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ * *
+ ***************************************************************************/
+
+#ifndef _GETPROFILEDIALOG_H_
+#define _GETPROFILEDIALOG_H_
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <kdialogbase.h>
+#include "global.h"
+
+// forward class definitions
+// =========================
+
+class KConfig;
+class QLineEdit;
+class QListBox;
+class QListBoxItem;
+class QString;
+
+// ProfileDialog class definition
+// ==============================
+
+class ProfileDialog : public KDialogBase
+{ Q_OBJECT
+
+ public:
+ enum Action
+ { Copy,
+ Delete,
+ Load,
+ Rename,
+ SaveAs
+ };
+
+ ProfileDialog( Action action,
+ const QString& currentProfile,
+ QWidget* parent = NULL,
+ const char* name = NULL );
+
+ QString profileName( ) const { return m_profileName; }
+
+ private slots:
+ void slotOk( );
+ void slotCopy( );
+ void slotDelete( );
+ void slotProfileListBoxChanged( );
+ void slotProfileListContextMenu( QListBoxItem* item, const QPoint& pos );
+ void slotRename( );
+
+ private:
+ bool checkForDuplicateName( const QString& profileName );
+ QString constructNewProfileName( const QString& initialProfileName ) const;
+ void copy( const QString& fromProfileName, const QString& toProfileName );
+ void createlayout( );
+ void deelete( const QString& profileName, const bool ask );
+ void deelete( QListBoxItem* item, const bool ask );
+ bool getNewProfileName( QString& profileName );
+ void setInitialValues( const QString& currentProfile );
+ QString stripPrefix( const QString& profileName ) const;
+
+ Action m_action;
+ QListBoxItem* m_contextItem;
+ QString m_profileName;
+ QLineEdit* m_profileLineEdit;
+ QListBox* m_profileListBox;
+};
+
+#endif // _GETPROFILEDIALOG_H_
diff --git a/src/scanmonitor.cpp b/src/scanmonitor.cpp
new file mode 100644
index 0000000..413dd93
--- /dev/null
+++ b/src/scanmonitor.cpp
@@ -0,0 +1,139 @@
+/***************************************************************************
+ * *
+ * Copyright (C) 2005 by Kevin Gilbert *
+ * kev.gilbert@cdu.edu.au *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ * *
+ ***************************************************************************/
+
+#include <errno.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/select.h>
+#include <sys/time.h>
+
+#include <qapplication.h>
+
+#include <klocale.h>
+
+#include "nmapoutputbuffer.h"
+#include "scanmonitor.h"
+#include "scanmonitorevent.h"
+#include "scanwidget.h"
+
+// constructor
+// ===========
+
+ScanMonitor::ScanMonitor( ScanWidget* parent )
+: QThread( ),
+ m_buffer( NULL ),
+ m_nmapBufferSize( 16384 ),
+ m_parent( parent )
+{ m_buffers.setAutoDelete( true );
+}
+
+// getBuffer
+// =========
+
+void ScanMonitor::getBuffer( )
+{ for( m_buffer = m_buffers.first( ); m_buffer != NULL; m_buffer = m_buffers.next( ))
+ if( m_buffer->isFree( ))
+ { m_buffer->setBusy( );
+ m_buffers.take( );
+ m_buffers.append( m_buffer );
+ return;
+ }
+
+ m_buffer = new NmapOutputBuffer( m_nmapBufferSize );
+ m_buffers.append( m_buffer );
+}
+
+// readNmapOutput
+// ==============
+
+void ScanMonitor::readNmapOutput( const int pipeFD, const ScanMonitorEventType type )
+{ while( true )
+ { if( m_buffer == NULL )
+ getBuffer( );
+ else
+ m_buffer->setBusy( );
+
+ int bytesRead = ::read( pipeFD, m_buffer->buffer( ), m_nmapBufferSize );
+
+ if( bytesRead > 0 )
+ { m_buffer->length( bytesRead );
+ QApplication::postEvent( m_parent, new ScanMonitorEvent( type, m_buffer ));
+ m_buffer = NULL;
+ continue;
+ }
+
+ if( !bytesRead || errno == EAGAIN || errno == EBADF )
+ { m_buffer->setFree( );
+ break;
+ }
+
+ QString text = QString( i18n( "error reading nmap output from pipe: %2\n" )).arg( strerror( errno ));
+ strcpy( m_buffer->buffer( ), text.ascii( ));
+ m_buffer->length( text.length( ));
+ QApplication::postEvent( m_parent, new ScanMonitorEvent( StderrType, m_buffer ));
+ m_buffer = NULL;
+ break;
+ }
+}
+
+// run
+// ===
+
+void ScanMonitor::run( )
+{ fd_set efds;
+ fd_set rfds;
+ struct timeval timeout;
+
+ while( true )
+ { FD_ZERO( &efds );
+ FD_ZERO( &rfds );
+
+ FD_SET( m_pipeStderrFD, &efds);
+ FD_SET( m_pipeStdoutFD, &efds);
+
+ FD_SET( m_pipeStderrFD, &rfds);
+ FD_SET( m_pipeStdoutFD, &rfds);
+
+ timeout.tv_sec = 2;
+ timeout.tv_usec = 0;
+
+ if( !select( _max_( m_pipeStderrFD, m_pipeStdoutFD ) + 1, &rfds, NULL, &efds, &timeout ))
+ continue;
+
+ if( FD_ISSET( m_pipeStderrFD, &efds ) || FD_ISSET( m_pipeStdoutFD, &efds ))
+ break;
+
+ if( FD_ISSET( m_pipeStderrFD, &rfds ))
+ readNmapOutput( m_pipeStderrFD, StderrType );
+
+ if( FD_ISSET( m_pipeStdoutFD, &rfds ))
+ readNmapOutput( m_pipeStdoutFD, StdoutType );
+ }
+}
+
+// setPipeFDs
+// ==========
+
+void ScanMonitor::setPipeFDs( const int pipeStderrFD, const int pipeStdoutFD )
+{ m_pipeStderrFD = pipeStderrFD;
+ m_pipeStdoutFD = pipeStdoutFD;
+}
diff --git a/src/scanmonitor.h b/src/scanmonitor.h
new file mode 100644
index 0000000..8112f9a
--- /dev/null
+++ b/src/scanmonitor.h
@@ -0,0 +1,68 @@
+/***************************************************************************
+ * *
+ * Copyright (C) 2005 by Kevin Gilbert *
+ * kev.gilbert@cdu.edu.au *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ * *
+ ***************************************************************************/
+
+#ifndef _SCANMONITOR_H_
+#define _SCANMONITOR_H_
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <qptrlist.h>
+#include <qthread.h>
+
+#include "global.h"
+
+// forward class definitions
+// =========================
+
+class NmapOutputBuffer;
+class ScanWidget;
+
+// ScanMonitor class definition
+// ============================
+
+class ScanMonitor : public QThread
+{ public:
+ enum ScanMonitorEventType
+ { StderrType = QEvent::User,
+ StdoutType
+ };
+
+ ScanMonitor( ScanWidget* parent );
+ void setPipeFDs( const int pipeStderrFD, const int pipeStdoutFD );
+
+ private:
+ void getBuffer( );
+ void readNmapOutput( const int pipeFD, const ScanMonitorEventType type );
+ void run( );
+
+ nobPtr m_buffer;
+ const uint m_nmapBufferSize;
+ ScanWidget* m_parent;
+ int m_pipeStderrFD;
+ int m_pipeStdoutFD;
+
+ QPtrList<NmapOutputBuffer> m_buffers;
+};
+
+#endif // _SCANMONITOR_H_
diff --git a/src/scanmonitorevent.cpp b/src/scanmonitorevent.cpp
new file mode 100644
index 0000000..825d9dd
--- /dev/null
+++ b/src/scanmonitorevent.cpp
@@ -0,0 +1,32 @@
+/***************************************************************************
+ * *
+ * Copyright (C) 2005 by Kevin Gilbert *
+ * kev.gilbert@cdu.edu.au *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ * *
+ ***************************************************************************/
+
+#include "scanmonitorevent.h"
+
+// constructor
+// ===========
+
+ScanMonitorEvent::ScanMonitorEvent( const int type, const nobPtr buffer )
+: QCustomEvent( type ),
+ m_buffer( buffer )
+{
+}
diff --git a/src/scanmonitorevent.h b/src/scanmonitorevent.h
new file mode 100644
index 0000000..1b86b6a
--- /dev/null
+++ b/src/scanmonitorevent.h
@@ -0,0 +1,42 @@
+/***************************************************************************
+ * *
+ * Copyright (C) 2005 by Kevin Gilbert *
+ * kev.gilbert@cdu.edu.au *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ * *
+ ***************************************************************************/
+
+#ifndef _SCANMONITOREVENT_H_
+#define _SCANMONITOREVENT_H_
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <qevent.h>
+#include "global.h"
+
+class ScanMonitorEvent : public QCustomEvent
+{ public:
+ ScanMonitorEvent( const int type, const nobPtr buffer );
+ nobPtr buffer( ) const { return m_buffer; }
+
+ private:
+ nobPtr m_buffer;
+};
+
+#endif // _SCANMONITOREVENT_H_
diff --git a/src/scannamedialog.cpp b/src/scannamedialog.cpp
new file mode 100644
index 0000000..4a1a645
--- /dev/null
+++ b/src/scannamedialog.cpp
@@ -0,0 +1,102 @@
+/***************************************************************************
+ * *
+ * Copyright (C) 2005, 2006 by Kevin Gilbert *
+ * kev.gilbert@cdu.edu.au *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ * *
+ ***************************************************************************/
+
+#include <qcheckbox.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qlineedit.h>
+
+#include <kdebug.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+
+#include "scannamedialog.h"
+#include "scanwidget.h"
+
+// constructor
+// ===========
+
+ScanNameDialog::ScanNameDialog( ScanWidget* scanWidget, QWidget* parent, const char* name )
+: KDialogBase( Plain, "Scan name", Ok | Cancel, Ok, parent, name )
+{ createlayout( );
+
+ if( scanWidget != NULL )
+ { m_scanNameEdit->setText( scanWidget->scanName( ));
+ m_useHostNameCheckbox->setChecked( scanWidget->useTargetHost( ));
+ }
+
+ if( !m_useHostNameCheckbox->isChecked( ))
+ m_scanNameEdit->setFocus( );
+}
+
+// createlayout
+// ============
+
+void ScanNameDialog::createlayout( )
+{ QGridLayout* gridLayout = new QGridLayout( plainPage( ));
+ byte row = 1;
+
+ m_useHostNameCheckbox = new QCheckBox( "Use Target Host name", plainPage( ), "use target checkbox" );
+ gridLayout->addWidget( m_useHostNameCheckbox, row++, 1 );
+
+ byte editRowTop = row++;
+ m_scanNameEdit = new QLineEdit( plainPage( ), "name edit" );
+ gridLayout->addWidget( new QLabel( "Scan name", plainPage( ), "name label" ), row++, 1 );
+ gridLayout->addWidget( m_scanNameEdit, row++, 1 );
+
+ gridLayout->setColStretch( 0, 1 );
+ gridLayout->setColStretch( 1, 5 );
+ gridLayout->setColStretch( 2, 1 );
+
+ gridLayout->setRowStretch( 0, 1 );
+ gridLayout->setRowStretch( editRowTop, 1 );
+ gridLayout->setRowStretch( row, 1 );
+
+ m_useHostNameCheckbox->setChecked( true );
+ slotUseHostNameToggled( true );
+ connect( m_useHostNameCheckbox, SIGNAL( toggled( bool )), SLOT( slotUseHostNameToggled( bool )));
+}
+
+// slotOk
+// ======
+
+void ScanNameDialog::slotOk( )
+{ m_scanName = m_scanNameEdit->text( );
+ m_useHostName = m_useHostNameCheckbox->isChecked( );
+
+ if( !m_useHostName && m_scanName.isEmpty( ))
+ { KMessageBox::sorry( this, "Please enter a name or select \"Use Target Host name\"", "No scan name" );
+ return;
+ }
+
+ KDialogBase::slotOk( );
+}
+
+// slotUseHostNameToggled
+// ======================
+
+void ScanNameDialog::slotUseHostNameToggled( bool on )
+{ m_scanNameEdit->setEnabled( !on );
+
+ if( !on )
+ m_scanNameEdit->setFocus( );
+}
diff --git a/src/scannamedialog.h b/src/scannamedialog.h
new file mode 100644
index 0000000..0fba9ee
--- /dev/null
+++ b/src/scannamedialog.h
@@ -0,0 +1,65 @@
+/***************************************************************************
+ * *
+ * Copyright (C) 2005, 2006 by Kevin Gilbert *
+ * kev.gilbert@cdu.edu.au *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ * *
+ ***************************************************************************/
+
+#ifndef _SCANNAMEDIALOG_H_
+#define _SCANNAMEDIALOG_H_
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <kdialogbase.h>
+#include "global.h"
+
+// forward class definitions
+// =========================
+
+class QCheckBox;
+class QLineEdit;
+class ScanWidget;
+
+// ScanNameDialog class definition
+// ===============================
+
+class ScanNameDialog : public KDialogBase
+{ Q_OBJECT
+
+ public:
+ ScanNameDialog( ScanWidget* scanWidget, QWidget* parent = NULL, const char* name = NULL );
+
+ QString scanName( ) const { return m_scanName; }
+ bool useHostName( ) const { return m_useHostName; }
+
+ private slots:
+ void slotOk( );
+ void slotUseHostNameToggled( bool on );
+
+ private:
+ void createlayout( );
+
+ QString m_scanName;
+ QLineEdit* m_scanNameEdit;
+ bool m_useHostName;
+ QCheckBox* m_useHostNameCheckbox;
+};
+
+#endif // _SCANNAMEDIALOG_H_
diff --git a/src/scanstack.cpp b/src/scanstack.cpp
new file mode 100644
index 0000000..7a49900
--- /dev/null
+++ b/src/scanstack.cpp
@@ -0,0 +1,194 @@
+/***************************************************************************
+ * *
+ * Copyright (C) 2005, 2006 by Kevin Gilbert *
+ * kev.gilbert@cdu.edu.au *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ * *
+ ***************************************************************************/
+
+#include <qdict.h>
+
+#include <kdebug.h>
+#include <klocale.h>
+
+#include "htmlwidget.h"
+#include "scanstack.h"
+#include "scanwidget.h"
+
+// constructor
+// ===========
+
+ScanStack::ScanStack( QWidget* parent, const char* name )
+: QWidgetStack( parent, name ),
+ m_dictSize( 29 ),
+ m_firstScanWidget( NULL ),
+ m_widgetId( 1 )
+{ m_scanWidgetDict = new QDict<ScanWidget>( m_dictSize );
+ m_scanWidgetDict->setAutoDelete( true );
+}
+
+// appendAndRaiseWidget
+// ====================
+
+void ScanStack::appendAndRaiseWidget( ScanWidget* scanWidget )
+{ addWidget( scanWidget, m_widgetId );
+ raiseWidget( m_widgetId );
+ m_widgetId++;
+
+ if( m_firstScanWidget == NULL )
+ m_firstScanWidget = scanWidget;
+
+ ushort index = m_scanWidgetDict->count( );
+
+ if( index == m_dictSize )
+ { m_dictSize *= 2; // yes - i know it's supposed to be prime!
+ m_scanWidgetDict->resize( m_dictSize );
+ }
+
+ m_scanWidgetDict->insert( QString::number( index ), scanWidget );
+}
+
+// appendHTMLWidget
+// ================
+
+void ScanStack::appendHTMLWidget( HTMLWidget* htmlWidget )
+{ ASSERT( m_widgetId == 1 );
+ addWidget( (QWidget*) htmlWidget, m_widgetId++ );
+}
+
+// findScanWidget
+// ==============
+
+short ScanStack::findScanWidget( const ScanWidget* scanWidget )
+{ ushort i;
+
+ for( resetScanWidgets( i ); moreScanWidgets( i ); nextScanWidget( i ))
+ if( scanWidget == currentScanWidget( i ))
+ return i;
+
+ return -1;
+}
+
+// indexOfVisibleScanWidget
+// ========================
+
+short ScanStack::indexOfVisibleScanWidget( )
+{ ushort i;
+
+ for( resetScanWidgets( i ); moreScanWidgets( i ); nextScanWidget( i ))
+ if( isVisibleWidget( currentScanWidget( i )))
+ break;
+
+ if( !moreScanWidgets( i ))
+ { ASSERT( false );
+ return -1;
+ }
+
+ return i;
+}
+
+// makeScanWidgetVisible
+// =====================
+
+ScanWidget* ScanStack::makeScanWidgetVisible( const ushort index )
+{ ScanWidget* current = scanWidget( index );
+
+ if( current == NULL )
+ ASSERT( false );
+ else
+ { current->ignoreTabChanges( true );
+ raiseWidget( current );
+ current->ignoreTabChanges( false );
+ }
+
+ return current;
+}
+
+// moveScanWidget
+// ==============
+
+ScanWidget* ScanStack::moveScanWidget( const ushort fromIndex )
+{ short toIndex = indexOfVisibleScanWidget( );
+
+ if( toIndex < 0 )
+ return NULL;
+
+ ScanWidget* scanWidget = m_scanWidgetDict->take( QString::number( fromIndex ));
+
+ if( fromIndex < toIndex )
+ for( ushort index = fromIndex + 1; index <= toIndex; index++ )
+ { ScanWidget* scanWidget = m_scanWidgetDict->take( QString::number( index ));
+ m_scanWidgetDict->insert( QString::number( index - 1 ), scanWidget );
+ }
+ else
+ for( short index = fromIndex - 1; index >= toIndex; index-- )
+ { ScanWidget* scanWidget = m_scanWidgetDict->take( QString::number( index ));
+ m_scanWidgetDict->insert( QString::number( index + 1 ), scanWidget );
+ }
+
+ m_scanWidgetDict->insert( QString::number( toIndex ), scanWidget );
+ return scanWidget;
+}
+
+// removeScanWidget
+// ================
+
+void ScanStack::removeScanWidget( ScanWidget* scanWidgetToRemove )
+{ ushort n = m_scanWidgetDict->count( );
+
+ if( n == 1 )
+ return;
+
+ short index = findScanWidget( scanWidgetToRemove );
+
+ if( index < 0 )
+ { ASSERT( false );
+ return;
+ }
+
+ m_scanWidgetDict->remove( QString::number( index ));
+
+ for( ushort i = index + 1; i < n; i++ )
+ { ScanWidget* scanWidget = m_scanWidgetDict->take( QString::number( i ));
+ m_scanWidgetDict->insert( QString::number( i - 1 ), scanWidget );
+ }
+
+ if( index >=short( m_scanWidgetDict->count( )))
+ index = m_scanWidgetDict->count( ) - 1;
+
+ ScanWidget* newVisibleWidget = scanWidget( index );
+ newVisibleWidget->ignoreTabChanges( true );
+ raiseWidget( newVisibleWidget );
+ newVisibleWidget->ignoreTabChanges( false );
+}
+
+// visibleWidget
+// =============
+
+ScanWidget* ScanStack::visibleWidget( )
+{ return (ScanWidget*) QWidgetStack::visibleWidget( );
+}
+
+// wrapText
+// ========
+
+void ScanStack::wrapText( const bool wrap )
+{ ushort i;
+
+ for( resetScanWidgets( i ); moreScanWidgets( i ); nextScanWidget( i ))
+ currentScanWidget( i )->wrapText( wrap );
+}
diff --git a/src/scanstack.h b/src/scanstack.h
new file mode 100644
index 0000000..44f6242
--- /dev/null
+++ b/src/scanstack.h
@@ -0,0 +1,76 @@
+/***************************************************************************
+ * *
+ * Copyright (C) 2005, 2006 by Kevin Gilbert *
+ * kev.gilbert@cdu.edu.au *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ * *
+ ***************************************************************************/
+
+#ifndef _SCANSTACK_H_
+#define _SCANSTACK_H_
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <qdict.h>
+#include <qwidgetstack.h>
+#include "global.h"
+
+// forward class definitions
+// =========================
+
+class HTMLWidget;
+class ScanWidget;
+
+// ScanStack class definition
+// ==========================
+
+class ScanStack : public QWidgetStack
+{ Q_OBJECT
+
+ public:
+ ScanStack( QWidget* parent, const char* name = NULL );
+
+ void appendAndRaiseWidget( ScanWidget* scanWidget );
+ void appendHTMLWidget( HTMLWidget* htmlWidget );
+ ushort count( ) const { return m_scanWidgetDict->count( ); }
+ ScanWidget* currentScanWidget( const ushort index ) { return scanWidget( index ); }
+ short findScanWidget( const ScanWidget* scanWidget );
+ ScanWidget* firstScanWidget( ) const { return m_firstScanWidget; }
+ short indexOfVisibleScanWidget( );
+ bool isVisibleWidget( const ScanWidget* scanWidget ) { return scanWidget == visibleWidget( ); }
+ ScanWidget* makeScanWidgetVisible( const ushort index );
+ bool moreScanWidgets( const ushort index ) const { return index < m_scanWidgetDict->count( ); }
+ ScanWidget* moveScanWidget( const ushort fromIndex );
+ void nextScanWidget( ushort& index ) { index++; }
+ void removeScanWidget( ScanWidget* scanWidget );
+ void resetScanWidgets( ushort& index ) { index = 0; }
+ ScanWidget* visibleWidget( );
+ void wrapText( const bool wrap );
+
+ private:
+ ScanWidget* scanWidget( const ushort index ) { return (*m_scanWidgetDict)[ QString::number( index )]; }
+
+ ushort m_dictSize;
+ ScanWidget* m_firstScanWidget;
+ ushort m_widgetId;
+
+ QDict<ScanWidget>* m_scanWidgetDict;
+};
+
+#endif // _SCANSTACK_H_
diff --git a/src/scanwidget.cpp b/src/scanwidget.cpp
new file mode 100644
index 0000000..3e8a7aa
--- /dev/null
+++ b/src/scanwidget.cpp
@@ -0,0 +1,1061 @@
+/***************************************************************************
+ * *
+ * Copyright (C) 2005, 2006 by Kevin Gilbert *
+ * kev.gilbert@cdu.edu.au *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ * *
+ ***************************************************************************/
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include <qfile.h>
+#include <qlayout.h>
+#include <qpushbutton.h>
+#include <qstringlist.h>
+#include <qtimer.h>
+
+#include <kapplication.h>
+#include <kconfig.h>
+#include <kdebug.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+#include <kprocess.h>
+#include <kstandarddirs.h>
+#include <ktabwidget.h>
+#include <kurl.h>
+
+#include "commonwidget.h"
+#include "compoundwidget.h"
+#include "htmlwidget.h"
+#include "knmap.h"
+#include "loggingoptions.h"
+#include "nmapoutputbuffer.h"
+#include "outputwidget.h"
+#include "pandsoptions.h"
+#include "profiledialog.h"
+#include "scanmonitor.h"
+#include "scanmonitorevent.h"
+#include "scanwidget.h"
+#include "simpleoptions.h"
+#include "tabwidgetdata.h"
+#include "tabwidgetptrlist.h"
+#include "timingwidget.h"
+
+// constructor
+// ===========
+
+ScanWidget::ScanWidget( const QString& scanName,
+ const bool useTargetHost,
+ QWidget* parent,
+ const char* name )
+: QFrame( parent, name ),
+ m_dirty (false ),
+ m_hideOptions( true ),
+ m_ignoreTabChanges( false ),
+ m_nmapProcess( NULL ),
+ m_pipeStderr( NULL ),
+ m_pipeStdout( NULL ),
+ m_scanMonitor( NULL ),
+ m_scanName( scanName ),
+ m_state( dormant ),
+ m_useTargetHost( useTargetHost )
+{ setFrameStyle( QFrame::WinPanel | QFrame::Sunken );
+ createLayout( );
+ m_clearOutputButton->setEnabled( false );
+ m_stopButton->setEnabled( false );
+ m_startButton->setDefault( true );
+
+ srand( time( NULL ));
+ QTimer::singleShot( 0, this, SLOT( slotFinaliseInitialisation( )));
+}
+
+// destructor
+// ==========
+
+ScanWidget::~ScanWidget( )
+{ if( m_nmapProcess != NULL )
+ { m_nmapProcess->kill( SIGKILL );
+ delete m_nmapProcess;
+ }
+
+ if( m_pipeStderr != NULL )
+ { m_pipeStderr->remove( );
+ delete m_pipeStderr;
+ }
+
+ if( m_pipeStdout != NULL )
+ { m_pipeStdout->remove( );
+ delete m_pipeStdout;
+ }
+
+ if( m_scanMonitor != NULL )
+ { m_scanMonitor->terminate( );
+ while( m_scanMonitor->running( )) ;
+ delete m_scanMonitor;
+ }
+}
+
+// buildNmapOptionsList
+// ====================
+
+QStringList ScanWidget::buildNmapOptionsList( )
+{ QStringList nmapOptions;
+ nmapOptions << KStandardDirs::findExe ( "nmap" );
+
+ if( m_commonWidget->resovleAlwaysState( ))
+ nmapOptions << "-R";
+
+ if( m_commonWidget->resovleNeverState( ))
+ nmapOptions << "-n";
+
+ if( m_timingWidget->hostTimeoutState( ))
+ { nmapOptions << "--host_timeout";
+ nmapOptions << QString::number( m_timingWidget->hostTimeoutValue( ));
+ }
+
+ if( m_timingWidget->initialRTTTimeoutState( ))
+ { nmapOptions << "--initial_rtt_timeout";
+ nmapOptions << QString::number( m_timingWidget->initialRTTTimeoutValue( ));
+ }
+
+ if( m_timingWidget->maxHostGroupState( ))
+ { nmapOptions << "--max_hostgroup";
+ nmapOptions << QString::number( m_timingWidget->maxHostGroupValue( ));
+ }
+
+ if( m_timingWidget->minHostGroupState( ))
+ { nmapOptions << "--min_hostgroup";
+ nmapOptions << QString::number( m_timingWidget->minHostGroupValue( ));
+ }
+
+ if( m_timingWidget->maxParallelismState( ))
+ { nmapOptions << "--max_parallelism";
+ nmapOptions << QString::number( m_timingWidget->maxParallelismValue( ));
+ }
+
+ if( m_timingWidget->minParallelismState( ))
+ { nmapOptions << "--min_parallelism";
+ nmapOptions << QString::number( m_timingWidget->minParallelismValue( ));
+ }
+
+ if( m_timingWidget->maxRTTTimeoutState( ))
+ { nmapOptions << "--max_rtt_timeout";
+ nmapOptions << QString::number( m_timingWidget->maxRTTTimeoutValue( ));
+ }
+
+ if( m_timingWidget->minRTTTimeoutState( ))
+ { nmapOptions << "--min_rtt_timeout";
+ nmapOptions << QString::number( m_timingWidget->minRTTTimeoutValue( ));
+ }
+
+ if( m_timingWidget->maxScanDelayState( ))
+ { nmapOptions << "--max_scan_delay";
+ nmapOptions << QString::number( m_timingWidget->maxScanDelayValue( ));
+ }
+
+ if( m_timingWidget->scanDelayState( ))
+ { nmapOptions << "--scan_delay";
+ nmapOptions << QString::number( m_timingWidget->scanDelayValue( ));
+ }
+
+ if( !m_timingWidget->simpleTiming( ).isEmpty( ))
+ { nmapOptions << "-T";
+ nmapOptions << m_timingWidget->simpleTiming( );
+ }
+
+ if( m_pAndSWidget->ackState( ))
+ nmapOptions << "-PA" + m_pAndSWidget->ackValue( );
+
+ if( m_pAndSWidget->arpState( ))
+ nmapOptions << "-PR";
+
+ if( m_pAndSWidget->dontPingState( ))
+ nmapOptions << "-P0";
+
+ if( m_pAndSWidget->echoState( ))
+ nmapOptions << "-PE";
+
+ if( m_pAndSWidget->netmaskState( ))
+ nmapOptions << "-PM";
+
+ if( m_pAndSWidget->synState( ))
+ nmapOptions << "-PS" + m_pAndSWidget->synValue( );
+
+ if( m_pAndSWidget->timestampState( ))
+ nmapOptions << "-PP";
+
+ if( m_commonWidget->portRangesState( ))
+ { nmapOptions << "-p";
+ nmapOptions << m_commonWidget->portRanges( )->join( "," );
+ }
+
+ if( m_compoundWidget->dataDirState( ))
+ { nmapOptions << "--datadir";
+ nmapOptions << m_compoundWidget->dataDirValue( );
+ }
+
+ if( m_compoundWidget->debugLevelState( ))
+ for( byte i = 0; i < m_compoundWidget->debugLevelValue( ); i++ )
+ nmapOptions << "-d";
+
+ if( m_compoundWidget->dataLengthState( ))
+ { nmapOptions << "--data_length";
+ nmapOptions << QString::number( m_compoundWidget->dataLengthValue( ));
+ }
+
+ if( m_compoundWidget->decoyState( ))
+ { nmapOptions << "-D";
+ nmapOptions << m_compoundWidget->decoyValue( );
+ }
+
+ if( m_compoundWidget->excludeState( ))
+ { nmapOptions << "--exclude";
+ nmapOptions << m_compoundWidget->excludeValue( );
+ }
+
+ if( m_compoundWidget->excludeFileState( ))
+ { nmapOptions << "--excludefile";
+ nmapOptions << m_compoundWidget->excludeFileValue( );
+ }
+
+ if( m_compoundWidget->fragmentLevelState( ))
+ for( byte i = 0; i < m_compoundWidget->fragmentLevelValue( ); i++ )
+ nmapOptions << "-f";
+
+ if( m_compoundWidget->interfaceState( ))
+ { nmapOptions << "-e";
+ nmapOptions << m_compoundWidget->interfaceValue( );
+ }
+
+ if( m_compoundWidget->maxSocketsState( ))
+ { nmapOptions << "-M";
+ nmapOptions << QString::number( m_compoundWidget->maxSocketsValue( ));
+ }
+
+ if( m_compoundWidget->randomIPState( ))
+ { nmapOptions << "-iR";
+ nmapOptions << QString::number( m_compoundWidget->randomIPValue( ));
+ }
+
+ if( m_compoundWidget->sourcePortState( ))
+ { nmapOptions << "--source_port";
+ nmapOptions << QString::number( m_compoundWidget->sourcePortValue( ));
+ }
+
+ if( m_compoundWidget->sourceIPState( ))
+ { nmapOptions << "-S";
+ nmapOptions << m_compoundWidget->sourceIPValue( );
+ }
+
+ if( m_compoundWidget->spoofMacState( ))
+ { nmapOptions << "--spoof_mac";
+ nmapOptions << m_compoundWidget->spoofMacValue( );
+ }
+
+ if( m_compoundWidget->targetFileState( ))
+ { nmapOptions << "-iL";
+ nmapOptions << m_compoundWidget->targetFileValue( );
+ }
+
+ if( m_compoundWidget->ttlState( ))
+ { nmapOptions << "--ttl";
+ nmapOptions << QString::number( m_compoundWidget->ttlValue( ));
+ }
+
+ if( m_simpleWidget->ipV6State( ))
+ nmapOptions << "-6";
+
+ if( m_simpleWidget->allPortsState( ))
+ nmapOptions << "--allports";
+
+ if( m_loggingWidget->appendOutputState( ))
+ nmapOptions << "--append_output";
+
+ if( m_loggingWidget->baseFileNameState( ))
+ { nmapOptions << "-oA";
+ nmapOptions << m_loggingWidget->baseFileNameValue( );
+ }
+
+ if( m_simpleWidget->fastScanState( ))
+ nmapOptions << "-F";
+
+ if( m_loggingWidget->grepableLogState( ))
+ { nmapOptions << "-oG";
+ nmapOptions << m_loggingWidget->grepableLogValue( );
+ }
+
+ if( m_simpleWidget->noRandomPortsState( ))
+ nmapOptions << "-r";
+
+ if( m_loggingWidget->normalLogState( ))
+ { nmapOptions << "-oN";
+ nmapOptions << m_loggingWidget->normalLogValue( );
+ }
+
+ if( m_loggingWidget->noStylesheetState( ))
+ nmapOptions << "--no_stylesheet";
+
+ if( m_simpleWidget->osDetectionState( ))
+ nmapOptions << "-O";
+
+ if( m_simpleWidget->osScanLimitState( ))
+ nmapOptions << "--osscan_limit";
+
+ if( m_simpleWidget->packetTraceState( ))
+ nmapOptions << "--packet_trace";
+
+ if( m_simpleWidget->privilegedState( ))
+ nmapOptions << "--privileged";
+
+ if( m_simpleWidget->randomizeHostsState( ))
+ nmapOptions << "--randomize_hosts";
+
+ if( m_loggingWidget->resumeState( ))
+ { nmapOptions << "--resume";
+ nmapOptions << m_loggingWidget->resumeValue( );
+ }
+
+ if( m_loggingWidget->scriptKiddieState( ))
+ { nmapOptions << "-oS";
+ nmapOptions << m_loggingWidget->scriptKiddieValue( );
+ }
+
+ if( m_pAndSWidget->scanAckState( ))
+ nmapOptions << "-sA";
+
+ if( m_pAndSWidget->scanFINState( ))
+ nmapOptions << "-sF";
+
+ if( m_pAndSWidget->scanFTPBounceState( ))
+ { nmapOptions << "-b";
+ nmapOptions << m_pAndSWidget->scanFTPRelayHost( );
+ }
+
+ if( m_pAndSWidget->scanIdleState( ))
+ { nmapOptions << "-sI";
+ nmapOptions << m_pAndSWidget->zombieDetails( );
+ }
+
+ if( m_pAndSWidget->scanListState( ))
+ nmapOptions << "-sL";
+
+ if( m_pAndSWidget->scanNullState( ))
+ nmapOptions << "-sN";
+
+ if( m_pAndSWidget->scanPingState( ))
+ nmapOptions << "-sP";
+
+ if( m_pAndSWidget->scanProtocolState( ))
+ nmapOptions << "-sO";
+
+ if( m_pAndSWidget->scanRPCState( ))
+ nmapOptions << "-sR";
+
+ if( m_pAndSWidget->scanTCPConnectState( ))
+ nmapOptions << "-sT";
+
+ if( m_pAndSWidget->scanSYNState( ))
+ nmapOptions << "-sS";
+
+ if( m_pAndSWidget->scanUDPState( ))
+ nmapOptions << "-sU";
+
+ if( m_pAndSWidget->scanVersionState( ))
+ nmapOptions << "-sV";
+
+ if( m_pAndSWidget->scanWindowState( ))
+ nmapOptions << "-sW";
+
+ if( m_pAndSWidget->scanXmasState( ))
+ nmapOptions << "-sX";
+
+ if( m_simpleWidget->sendEthState( ))
+ nmapOptions << "--send_eth";
+
+ if( m_simpleWidget->sendIPState( ))
+ nmapOptions << "--send_ip";
+
+ if( m_loggingWidget->stylesheetState( ))
+ { nmapOptions << "--stylesheet";
+ nmapOptions << m_loggingWidget->stylesheetValue( );
+ }
+
+ if( m_simpleWidget->verboseState( ))
+ nmapOptions << "-v";
+
+ if( m_loggingWidget->xmlLogState( ))
+ { nmapOptions << "-oX";
+ nmapOptions << m_loggingWidget->xmlLogValue( );
+ }
+
+ nmapOptions << m_commonWidget->host( );
+ return nmapOptions;
+}
+
+// closePipe
+// =========
+
+void ScanWidget::closePipe( QFile*& pipe, int& pipeFD )
+{ if( pipe == NULL )
+ return;
+
+ ::close( pipeFD );
+
+ pipe->remove( );
+ delete pipe;
+ pipe = NULL;
+}
+
+// createLayout
+// ============
+
+void ScanWidget::createLayout( )
+{ m_commonWidget = new CommonWidget( this, "common widget" );
+ m_compoundWidget = new CompoundWidget( this, "compound widget" );
+ m_loggingWidget = new LoggingOptions( this, "logging widget" );
+ m_pAndSWidget = new PAndSOptions( this, "p and s widget" );
+ m_simpleWidget = new SimpleOptions( this, "simple widget" );
+ m_timingWidget = new TimingWidget( this, "timing widget" );
+ m_tabWidget = new KTabWidget( this, "tab widget" );
+
+ m_tabWidget->setTabReorderingEnabled( true );
+
+ byte row = 0;
+ QVBoxLayout* layout = new QVBoxLayout( this );
+ layout->addWidget( m_tabWidget, row++ );
+
+ QHBoxLayout* buttonLayout = new QHBoxLayout( );
+ m_clearOutputButton = new QPushButton( i18n( "Clear output" ), this, "clear output button" );
+ m_hideOptionsButton = new QPushButton( i18n( "Hide options" ), this, "hide options button" );
+ m_startButton = new QPushButton( i18n( "Start nmap" ), this, "start button" );
+ m_stopButton = new QPushButton( i18n( "Stop nmap" ), this, "stop button" );
+
+ byte col = 0;
+ buttonLayout->insertStretch( col++, 10 );
+ buttonLayout->insertWidget( col++, m_startButton, 5 );
+ buttonLayout->insertStretch( col++, 3 );
+ buttonLayout->insertWidget( col++, m_stopButton, 5 );
+ buttonLayout->insertStretch( col++, 3 );
+ buttonLayout->insertWidget( col++, m_hideOptionsButton, 5 );
+ buttonLayout->insertStretch( col++, 3 );
+ buttonLayout->insertWidget( col++, m_clearOutputButton, 5 );
+ buttonLayout->insertStretch( col++, 10 );
+ layout->addLayout( buttonLayout, row );
+
+ m_outputWidget = new OutputWidget( this, "output widget" );
+ layout->addWidget( m_outputWidget, row++ );
+}
+
+// createPipe
+// ==========
+
+bool ScanWidget::createPipe( const QString type, const QString& tempDir, QFile*& pipe, int& pipeFD )
+{ while( true )
+ { pipe = new QFile( QString( "%1knmap_%2_%3" ).arg( tempDir ).arg( type ).arg( rand( )));
+
+ if( !pipe->exists( ))
+ break;
+
+ delete pipe;
+ }
+
+ if( mkfifo( pipe->name( ), 0600 ))
+ { QString text = QString( i18n( "Couldn't create the named pipe \"%1\" for nmap output: %2\n" )).arg( pipe->name( )).arg( strerror( errno ));
+ m_outputWidget->addOutput( OutputWidget::Stderr, text, text.length( ));
+
+ delete pipe;
+ pipe = NULL;
+ return false;
+ }
+
+ pipeFD = ::open( pipe->name( ), O_RDONLY | O_NONBLOCK );
+
+ if( pipeFD != -1 )
+ return true;
+
+ QString text = QString( i18n( "Couldn't open the named pipe \"%1\" for nmap output: %2\n" )).arg( pipe->name( ))
+ .arg( strerror( errno ));
+ m_outputWidget->addOutput( OutputWidget::Stderr, text, text.length( ));
+
+ delete pipe;
+ pipe = NULL;
+ return false;
+}
+
+// createPipes
+// ===========
+
+bool ScanWidget::createPipes( )
+{ ASSERT( m_pipeStderr == NULL );
+ ASSERT( m_pipeStdout == NULL );
+
+ KStandardDirs standardDirs;
+ QStringList tempDir = standardDirs.resourceDirs( "tmp" );
+
+ if( tempDir.isEmpty( ))
+ { QString text = QString( i18n( "Couldn't create the named pipe for nmap output: no temp file dir\n" ));
+ m_outputWidget->addOutput( OutputWidget::Stderr, text, text.length( ));
+ return false;
+ }
+
+ if( !createPipe( "stderr", tempDir[ 0 ], m_pipeStderr, m_pipeStderrFD ))
+ return false;
+
+ return createPipe( "stderr", tempDir[ 0 ], m_pipeStdout, m_pipeStdoutFD );
+}
+
+// customEvent
+// ===========
+
+void ScanWidget::customEvent( QCustomEvent* event )
+{ smePtr scanMonitorEvent = (ScanMonitorEvent*) event;
+ nobPtr buffer;
+
+ switch( event->type( ))
+ { case ScanMonitor::StderrType:
+ buffer = scanMonitorEvent->buffer( );
+ m_outputWidget->addOutput( OutputWidget::Stderr, buffer->buffer( ), buffer->length( ));
+ buffer->setFree( );
+ break;
+
+ case ScanMonitor::StdoutType:
+ buffer = scanMonitorEvent->buffer( );
+ m_outputWidget->addOutput( OutputWidget::Stdout, buffer->buffer( ), buffer->length( ));
+ buffer->setFree( );
+ break;
+
+ default:
+ kdDebug( ) << "internal error in ScanWidget::customEvent - unknown event type "
+ << event->type( )
+ << " - ignoring it"
+ << endl;
+ }
+}
+
+// fileSave
+// ========
+
+void ScanWidget::fileSave( )
+{ if( m_outputWidget->fileSave( ))
+ emit( outputAvailable( false, true ));
+}
+
+// fileSaveAs
+// ==========
+
+void ScanWidget::fileSaveAs( )
+{ if( m_outputWidget->fileSaveAs( ))
+ emit( outputAvailable( false, true ));
+}
+
+// getOptions
+// ==========
+
+bool ScanWidget::getOptions( )
+{ m_piping = false;
+
+ if( !m_commonWidget->getOptions( ))
+ return false;
+
+ if( !m_compoundWidget->getOptions( m_piping ))
+ return false;
+
+ if( !m_loggingWidget->getOptions( ))
+ return false;
+
+ if( !m_pAndSWidget->getOptions( m_piping ))
+ return false;
+
+ if( !m_simpleWidget->getOptions( m_piping ))
+ return false;
+
+ if( !m_timingWidget->getOptions( ))
+ return false;
+
+ if( m_commonWidget->host( ).isEmpty( ) && !m_compoundWidget->targetFileState( ))
+ { KMessageBox::error( this, i18n( QString( "Target host(s) not specified by \"Target host(s)\" or \"Target hosts file\" options" )), i18n( "Target host(s) error" ));
+ return false;
+ }
+
+ return true;
+}
+
+// profileAskAndSave
+// =================
+
+void ScanWidget::profileAskAndSave( )
+{ if( !m_dirty )
+ return;
+
+ if( KMessageBox::Yes != KMessageBox::questionYesNo( this,
+ i18n( "Profile has been updated - save it now?" ),
+ i18n( "Profile data updated" )))
+ return;
+
+ profileSave( );
+}
+
+// profileCopy
+// ===========
+
+void ScanWidget::profileCopy( )
+{ ProfileDialog dlg( ProfileDialog::Copy, m_profileName, this, "profile dlg" );
+ dlg.exec( );
+}
+
+// profileDelete
+// =============
+
+void ScanWidget::profileDelete( )
+{ ProfileDialog dlg( ProfileDialog::Delete, m_profileName, this, "profile dlg" );
+ dlg.exec( );
+}
+
+// profileLoad
+// ===========
+
+void ScanWidget::profileLoad( )
+{ profileAskAndSave( );
+ ProfileDialog dlg( ProfileDialog::Load, m_profileName, this, "profile dlg" );
+
+ if( dlg.exec( ) != QDialog::Accepted )
+ return;
+
+ m_profileName = dlg.profileName( );
+ saveProfileName( );
+ profileRead( );
+ setInitialValues( );
+}
+
+// profileRead
+// ===========
+
+void ScanWidget::profileRead( )
+{ KConfig* config = kapp->config( );
+
+ kapp->config( )->setGroup( m_profileName );
+ m_commonWidget->readProfile( config );
+ m_compoundWidget->readProfile( config );
+ m_loggingWidget->readProfile( config );
+ m_pAndSWidget->readProfile( config );
+ m_outputWidget->readProfile( config );
+ m_simpleWidget->readProfile( config );
+ m_timingWidget->readProfile( config );
+
+ m_commonIndex = config->readNumEntry( "commonWidget", 0 );
+ m_compoundIndex = config->readNumEntry( "compoundWidget", 2 );
+ m_currentTab = config->readNumEntry( "currentTab", 0 );
+ m_loggingIndex = config->readNumEntry( "loggingWidget", 3 );
+ m_pAndSIndex = config->readNumEntry( "pAndSWidget", 4 );
+ m_simpleIndex = config->readNumEntry( "simpleWidget", 1 );
+ m_timingIndex = config->readNumEntry( "timingWidget", 5 );
+ m_useTargetHost = config->readBoolEntry( "useTargetHost", false );
+}
+
+// profileRename
+// =============
+
+void ScanWidget::profileRename( )
+{ ProfileDialog dlg( ProfileDialog::Rename, m_profileName, this, "profile dlg" );
+ dlg.exec( );
+}
+
+// profileSave
+// ===========
+
+void ScanWidget::profileSave( )
+{ if( !getOptions( ))
+ if( KMessageBox::Yes != KMessageBox::questionYesNo( this, i18n( "Do you still want to save the profile? (It may be in an inconsistent state." ), i18n( "Save inconsistent profile" )))
+ return;
+
+ KConfig* config = kapp->config( );
+ config->setGroup( m_profileName );
+
+ m_commonWidget->saveProfile( config );
+ m_compoundWidget->saveProfile( config );
+ m_loggingWidget->saveProfile( config );
+ m_outputWidget->saveProfile( config );
+ m_pAndSWidget->saveProfile( config );
+ m_simpleWidget->saveProfile( config );
+ m_timingWidget->saveProfile( config );
+
+ config->writeEntry( "commonWidget", m_tabWidget->indexOf( m_commonWidget ));
+ config->writeEntry( "compoundWidget", m_tabWidget->indexOf( m_compoundWidget ));
+ config->writeEntry( "currentTab", m_tabWidget->currentPageIndex( ));
+ config->writeEntry( "loggingWidget", m_tabWidget->indexOf( m_loggingWidget ));
+ config->writeEntry( "pAndSWidget", m_tabWidget->indexOf( m_pAndSWidget ));
+ config->writeEntry( "simpleWidget", m_tabWidget->indexOf( m_simpleWidget ));
+ config->writeEntry( "timingWidget", m_tabWidget->indexOf( m_timingWidget ));
+ config->writeEntry( "useTargetHost", m_useTargetHost );
+
+ slotOptionsDirty( false );
+}
+
+// profileSaveAs
+// =============
+
+void ScanWidget::profileSaveAs( )
+{ ProfileDialog dlg( ProfileDialog::SaveAs, m_profileName, this, "profile dlg" );
+
+ if( dlg.exec( ) != QDialog::Accepted )
+ return;
+
+ m_profileName = dlg.profileName( );
+ saveProfileName( );
+ profileSave( );
+}
+
+// readSettings
+// ============
+
+void ScanWidget::readSettings( )
+{ KConfig* config = kapp->config( );
+ config->setGroup( m_scanName );
+ m_profileName = config->readEntry( "profileName", DEFAULT_PROFILE );
+
+ profileRead( );
+}
+
+// renameScan
+// ==========
+
+void ScanWidget::renameScan( const QString& newScanName )
+{ kapp->config( )->deleteGroup( m_scanName );
+ m_scanName = newScanName;
+}
+
+// saveProfileName
+// ===============
+
+void ScanWidget::saveProfileName( )
+{ KConfig* config = kapp->config( );
+ config->setGroup( m_scanName );
+ config->writeEntry( "profileName", m_profileName );
+}
+
+// saveSettings
+// ============
+
+void ScanWidget::saveSettings( )
+{ saveProfileName( );
+ profileSave( );
+}
+
+// setInitialValues
+// ================
+
+void ScanWidget::setInitialValues( )
+{ m_commonWidget->setInitialValues( );
+ m_compoundWidget->setInitialValues( );
+ m_loggingWidget->setInitialValues( );
+ m_pAndSWidget->setInitialValues( );
+ m_simpleWidget->setInitialValues( );
+ m_timingWidget->setInitialValues( );
+
+ TabWidgetPtrList list;
+ list.append( new TabWidgetData( m_commonIndex, i18n( "Common options" ), m_commonWidget ));
+ list.append( new TabWidgetData( m_compoundIndex, i18n( "Compound options" ), m_compoundWidget ));
+ list.append( new TabWidgetData( m_loggingIndex, i18n( "Logging options" ), m_loggingWidget ));
+ list.append( new TabWidgetData( m_pAndSIndex, i18n( "Ping and Scan options" ), m_pAndSWidget ));
+ list.append( new TabWidgetData( m_simpleIndex, i18n( "Simple options" ), m_simpleWidget ));
+ list.append( new TabWidgetData( m_timingIndex, i18n( "Timing options" ), m_timingWidget ));
+ list.sort( );
+
+ while( m_tabWidget->count( ))
+ m_tabWidget->removePage( m_tabWidget->page( 0 ));
+
+ for( TabWidgetData* widgetData = list.first( ); widgetData != NULL; widgetData = list.next( ))
+ m_tabWidget->insertTab( widgetData->widget( ), widgetData->title( ), widgetData->index( ));
+
+ m_tabWidget->setCurrentPage( m_currentTab );
+}
+
+// setProfileName
+// ==============
+
+void ScanWidget::setProfileName( const QString& profileName )
+{ m_profileName = profileName;
+ saveProfileName( );
+ profileRead( );
+}
+
+// slotClearOutput
+// ===============
+
+void ScanWidget::slotClearOutput( )
+{ m_clearOutputButton->setEnabled( false );
+ m_outputWidget->clearOutput( );
+ emit( outputAvailable( false, false ));
+}
+
+// slotDisplayDocBook
+// ==================
+
+void ScanWidget::slotDisplayDocBook( const QString& anchor )
+{ KProcess* process = new KProcess;
+ *process << "khelpcenter";
+ *process << "help:/knmap//index.html#" + anchor;
+ process->start( KProcess::DontCare );
+}
+
+// slotDisplayUnknown
+// ==================
+
+void ScanWidget::slotDisplayUnknown( )
+{ KMessageBox::sorry( this, i18n( "There is no help available for the item you have selected!\nTOUGH!!!\nDon't bother me with you pathetic whinges. Go get a life." ), i18n( "Help unavailable" ));
+}
+
+// slotFinaliseInitialisation
+// ==========================
+
+void ScanWidget::slotFinaliseInitialisation( )
+{ setInitialValues( );
+ m_commonWidget->finaliseInitialisation( );
+ m_compoundWidget->finaliseInitialisation( );
+ m_pAndSWidget->finaliseInitialisation( );
+ m_simpleWidget->finaliseInitialisation( );
+ m_timingWidget->finaliseInitialisation( );
+
+ connect( m_outputWidget, SIGNAL( statusBarText( const QString& )), SIGNAL( statusBarText( const QString& )));
+
+ connect( m_clearOutputButton, SIGNAL( clicked( )), SLOT( slotClearOutput( )));
+ connect( m_commonWidget, SIGNAL( disableFastScan( )), m_simpleWidget, SLOT( slotDisableFastScan( )));
+ connect( m_commonWidget, SIGNAL( targetChanged( const QString& )), SLOT( slotTargetChanged( const QString& )));
+ connect( m_hideOptionsButton, SIGNAL( clicked( )), SLOT( slotHideOptions( )));
+ connect( m_simpleWidget, SIGNAL( disablePortRanges( )), m_commonWidget, SLOT( slotDisablePortRanges( )));
+ connect( m_startButton, SIGNAL( clicked( )), SLOT( slotStartClicked( )));
+ connect( m_stopButton, SIGNAL( clicked( )), SLOT( slotStopClicked( )));
+ connect( m_tabWidget, SIGNAL( currentChanged( QWidget* )), SLOT( slotTabChanged( QWidget* )));
+
+ connect( m_commonWidget, SIGNAL( optionsDirty( )), SLOT( slotOptionsDirty( )));
+ connect( m_compoundWidget, SIGNAL( optionsDirty( )), SLOT( slotOptionsDirty( )));
+ connect( m_loggingWidget, SIGNAL( optionsDirty( )), SLOT( slotOptionsDirty( )));
+ connect( m_pAndSWidget, SIGNAL( optionsDirty( )), SLOT( slotOptionsDirty( )));
+ connect( m_simpleWidget, SIGNAL( optionsDirty( )), SLOT( slotOptionsDirty( )));
+ connect( m_tabWidget, SIGNAL( movedTab( int, int )), SLOT( slotOptionsDirty( )));
+ connect( m_timingWidget, SIGNAL( optionsDirty( )), SLOT( slotOptionsDirty( )));
+
+ connect( m_commonWidget, SIGNAL( displayHelp( const QString& )), SIGNAL( displayHelp( const QString& )));
+ connect( m_compoundWidget, SIGNAL( displayHelp( const QString& )), SIGNAL( displayHelp( const QString& )));
+ connect( m_loggingWidget, SIGNAL( displayHelp( const QString& )), SIGNAL( displayHelp( const QString& )));
+ connect( m_pAndSWidget, SIGNAL( displayHelp( const QString& )), SIGNAL( displayHelp( const QString& )));
+ connect( m_simpleWidget, SIGNAL( displayHelp( const QString& )), SIGNAL( displayHelp( const QString& )));
+ connect( m_timingWidget, SIGNAL( displayHelp( const QString& )), SIGNAL( displayHelp( const QString& )));
+
+ connect( m_commonWidget, SIGNAL( displayDocBook( const QString& )), SLOT( slotDisplayDocBook( const QString&)));
+ connect( m_compoundWidget, SIGNAL( displayDocBook( const QString& )), SLOT( slotDisplayDocBook( const QString&)));
+ connect( m_loggingWidget, SIGNAL( displayDocBook( const QString& )), SLOT( slotDisplayDocBook( const QString&)));
+ connect( m_pAndSWidget, SIGNAL( displayDocBook( const QString& )), SLOT( slotDisplayDocBook( const QString&)));
+ connect( m_simpleWidget, SIGNAL( displayDocBook( const QString& )), SLOT( slotDisplayDocBook( const QString&)));
+ connect( m_timingWidget, SIGNAL( displayDocBook( const QString& )), SLOT( slotDisplayDocBook( const QString&)));
+
+ connect( m_commonWidget, SIGNAL( displayUnknown( )), SLOT( slotDisplayUnknown( )));
+ connect( m_compoundWidget, SIGNAL( displayUnknown( )), SLOT( slotDisplayUnknown( )));
+ connect( m_loggingWidget, SIGNAL( displayUnknown( )), SLOT( slotDisplayUnknown( )));
+ connect( m_pAndSWidget, SIGNAL( displayUnknown( )), SLOT( slotDisplayUnknown( )));
+ connect( m_simpleWidget, SIGNAL( displayUnknown( )), SLOT( slotDisplayUnknown( )));
+ connect( m_timingWidget, SIGNAL( displayUnknown( )), SLOT( slotDisplayUnknown( )));
+
+ if( m_useTargetHost )
+ renameScan( m_commonWidget->getHostName( ));
+}
+
+// slotHideOptions
+// ===============
+
+void ScanWidget::slotHideOptions( )
+{ if( m_hideOptions )
+ { m_tabWidget->hide( );
+ m_hideOptionsButton->setText( i18n( "Show options" ));
+ }
+ else
+ { m_tabWidget->show( );
+ m_hideOptionsButton->setText( i18n( "Hide options" ));
+ }
+
+ m_hideOptions = !m_hideOptions;
+}
+
+// slotOptionsDirty
+// ================
+
+void ScanWidget::slotOptionsDirty( const bool dirty )
+{ m_dirty = dirty;
+ emit( optionsDirty( ));
+}
+
+// slotProcessExited
+// =================
+
+void ScanWidget::slotProcessExited( )
+{ delete m_nmapProcess;
+ m_nmapProcess = NULL;
+
+ if( m_piping )
+ { closePipe( m_pipeStderr, m_pipeStderrFD );
+ closePipe( m_pipeStdout, m_pipeStdoutFD );
+
+ if( m_scanMonitor != NULL )
+ while( m_scanMonitor->running( ))
+ sleep( 1 );
+ }
+
+ m_stopButton->setEnabled( false );
+ m_startButton->setEnabled( true );
+
+ emit( scanStopped( this ));
+}
+
+// slotReceivedStderr
+// ==================
+
+void ScanWidget::slotReceivedStderr( KProcess* /* process */, char* buffer, int buflen )
+{ m_clearOutputButton->setEnabled( true );
+ m_outputWidget->addOutput( OutputWidget::Stderr, buffer, buflen );
+ emit( outputAvailable( true, true ));
+}
+
+// slotReceivedStdout
+// ==================
+
+void ScanWidget::slotReceivedStdout( KProcess* /* process */, char* buffer, int buflen )
+{ m_clearOutputButton->setEnabled( true );
+ m_outputWidget->addOutput( OutputWidget::Stdout, buffer, buflen );
+ emit( outputAvailable( true, true ));
+}
+
+// slotStartClicked
+// ================
+
+void ScanWidget::slotStartClicked( )
+{ if( !getOptions( ))
+ return;
+
+ m_stopButton->setEnabled( true );
+ m_startButton->setEnabled( false );
+
+ if( m_piping && !createPipes( ))
+ return;
+
+ QStringList nmapOptions = buildNmapOptionsList( );
+ m_nmapProcess = new KProcess;
+
+ if( !m_piping )
+ *m_nmapProcess << nmapOptions;
+ else
+ { nmapOptions << ">";
+ nmapOptions << m_pipeStdout->name( );
+
+ nmapOptions << "2>";
+ nmapOptions << m_pipeStderr->name( );
+
+ *m_nmapProcess << "kdesu";
+ *m_nmapProcess << "-n";
+ *m_nmapProcess << nmapOptions.join( " " );
+ }
+
+ QValueList<QCString> args = m_nmapProcess->args( );
+ QString cmd;
+ QValueList<QCString>::iterator it;
+
+ for( it = args.begin( ); it != args.end( ); ++it )
+ cmd += *it + " ";
+
+ cmd.stripWhiteSpace( );
+ m_clearOutputButton->setEnabled( true );
+ m_outputWidget->addOutput( OutputWidget::Stdin, cmd, cmd.length( ));
+
+ emit( outputAvailable( true, true ));
+ connect( m_nmapProcess, SIGNAL( processExited( KProcess* )), SLOT( slotProcessExited( )));
+
+ if( !m_piping )
+ { connect( m_nmapProcess,
+ SIGNAL( receivedStderr( KProcess*, char*, int )),
+ SLOT( slotReceivedStderr( KProcess*, char*, int )));
+
+ connect( m_nmapProcess,
+ SIGNAL( receivedStdout( KProcess*, char*, int )),
+ SLOT( slotReceivedStdout( KProcess*, char*, int )));
+ }
+
+ m_nmapProcess->start( KProcess::NotifyOnExit, KProcess::AllOutput );
+ m_state = running;
+ emit( scanStarted( ));
+
+ if( !m_piping )
+ return;
+
+ if( m_scanMonitor == NULL )
+ m_scanMonitor = new ScanMonitor( this );
+
+ m_scanMonitor->setPipeFDs( m_pipeStderrFD, m_pipeStdoutFD );
+ m_scanMonitor->start( );
+}
+
+// slotStopClicked
+// ===============
+
+void ScanWidget::slotStopClicked( )
+{ m_stopButton->setEnabled( false );
+ m_nmapProcess->kill( );
+}
+
+// slotTabChanged
+// ==============
+
+void ScanWidget::slotTabChanged( QWidget* /* toWidget */)
+{ if( !m_ignoreTabChanges )
+ slotOptionsDirty( );
+}
+
+// slotTabChanged
+// ==============
+
+void ScanWidget::slotTargetChanged( const QString& target )
+{ if( m_useTargetHost )
+ emit( scanRename( target ));
+}
+
+// updateStatusBarText
+// ===================
+
+void ScanWidget::updateStatusBarText( )
+{ m_outputWidget->slotUpdateStatusBarText( );
+}
+
+// useTargetHost
+// ==============
+
+void ScanWidget::useTargetHost( const bool b )
+{ m_useTargetHost = b;
+
+ if( m_useTargetHost )
+ emit( scanRename( m_commonWidget->getHostName( )));
+}
+
+// wrapText
+// ========
+
+void ScanWidget::wrapText( const bool wrap )
+{ m_outputWidget->setWordWrap( wrap ? QTextEdit::WidgetWidth : QTextEdit::NoWrap );
+}
diff --git a/src/scanwidget.h b/src/scanwidget.h
new file mode 100644
index 0000000..decb7cb
--- /dev/null
+++ b/src/scanwidget.h
@@ -0,0 +1,172 @@
+/***************************************************************************
+ * *
+ * Copyright (C) 2005, 2006 by Kevin Gilbert *
+ * kev.gilbert@cdu.edu.au *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ * *
+ ***************************************************************************/
+
+#ifndef _SCANWIDGET_H_
+#define _SCANWIDGET_H_
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <qframe.h>
+#include "global.h"
+
+// forward class definitions
+// =========================
+
+class CommonWidget;
+class CompoundWidget;
+class HTMLWidget;
+class KConfig;
+class KProcess;
+class KTabWidget;
+class LoggingOptions;
+class OutputWidget;
+class PAndSOptions;
+class QFile;
+class QLineEdit;
+class QPushButton;
+class QStringList;
+class ScanMonitor;
+class SimpleOptions;
+class TimingWidget;
+
+// ScanWidget class definition
+// ===========================
+
+class ScanWidget : public QFrame
+{ Q_OBJECT
+
+ public:
+ ScanWidget( const QString& scanName,
+ const bool useTargetHost,
+ QWidget* parent = NULL,
+ const char* name = NULL );
+ virtual ~ScanWidget( );
+
+ enum State
+ { dormant,
+ finished,
+ running
+ };
+
+ void fileSave( );
+ void fileSaveAs( );
+ void ignoreTabChanges( const bool b ) { m_ignoreTabChanges = b; }
+ bool isDirty( ) const { return m_dirty; }
+ void profileAskAndSave( );
+ void profileCopy( );
+ void profileDelete( );
+ void profileLoad( );
+ QString profileName( ) const { return m_profileName; }
+ void profileRename( );
+ void profileSave( );
+ void profileSaveAs( );
+ void readSettings( );
+ void renameScan( const QString& newScanName );
+ void saveSettings( );
+ QString scanName( ) const { return m_scanName; }
+ void setProfileName( const QString& profileName );
+ State state( ) const { return m_state; }
+ void state( const State s ) { m_state = s; }
+ void updateStatusBarText( );
+ bool useTargetHost( ) const { return m_useTargetHost; }
+ void useTargetHost( const bool b );
+ void wrapText( const bool wrap );
+
+ signals:
+ void displayHelp( const QString& );
+ void errorLoadingLocalManPage( const QString& );
+ void optionsDirty( );
+ void outputAvailable( const bool, const bool );
+ void scanRename( const QString& );
+ void scanStarted( );
+ void scanStopped( ScanWidget* );
+ void setManPageActionStuff( const bool );
+ void statusBarText( const QString& );
+
+ private slots:
+ void slotClearOutput( );
+ void slotDisplayDocBook( const QString& anchor );
+ void slotDisplayUnknown( );
+ void slotFinaliseInitialisation( );
+ void slotHideOptions( );
+ void slotOptionsDirty( const bool dirty = true );
+ void slotProcessExited( );
+ void slotReceivedStderr( KProcess* process, char* buffer, int buflen );
+ void slotReceivedStdout( KProcess* process, char* buffer, int buflen );
+ void slotStartClicked( );
+ void slotStopClicked( );
+ void slotTabChanged( QWidget* toWidget );
+ void slotTargetChanged( const QString& target );
+
+ private:
+ QStringList buildNmapOptionsList( );
+ void closePipe( QFile*& pipe, int& pipeFD );
+ void createLayout( );
+ bool createPipe( const QString type, const QString& tempDir, QFile*& pipe, int& pipeFD );
+ bool createPipes( );
+ void customEvent( QCustomEvent* event );
+ bool getOptions( );
+ void getPortRanges( QStringList* portRanges );
+ void initialiseManPage( );
+ void profileRead( );
+ void saveProfileName( );
+ void setInitialValues( );
+
+ QPushButton* m_clearOutputButton;
+ int m_commonIndex;
+ CommonWidget* m_commonWidget;
+ int m_compoundIndex;
+ CompoundWidget* m_compoundWidget;
+ int m_currentTab;
+ bool m_dirty;
+ bool m_hideOptions;
+ QPushButton* m_hideOptionsButton;
+ int m_htmlIndex;
+ bool m_ignoreTabChanges;
+ int m_loggingIndex;
+ LoggingOptions* m_loggingWidget;
+ KProcess* m_nmapProcess;
+ OutputWidget* m_outputWidget;
+ int m_pAndSIndex;
+ PAndSOptions* m_pAndSWidget;
+ QFile* m_pipeStderr;
+ QFile* m_pipeStdout;
+ int m_pipeStderrFD;
+ int m_pipeStdoutFD;
+ bool m_piping;
+ QString m_profileName;
+ ScanMonitor* m_scanMonitor;
+ QString m_scanName;
+ int m_simpleIndex;
+ SimpleOptions* m_simpleWidget;
+ QPushButton* m_startButton;
+ State m_state;
+ QPushButton* m_stopButton;
+ KTabWidget* m_tabWidget;
+ int m_timingIndex;
+ TimingWidget* m_timingWidget;
+ bool m_useTargetHost;
+};
+
+#endif // _SCANWIDGET_H_
diff --git a/src/simpleoptions.cpp b/src/simpleoptions.cpp
new file mode 100644
index 0000000..56df1a2
--- /dev/null
+++ b/src/simpleoptions.cpp
@@ -0,0 +1,247 @@
+/***************************************************************************
+ * *
+ * Copyright (C) 2005, 2006 by Kevin Gilbert *
+ * kev.gilbert@cdu.edu.au *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ * *
+ ***************************************************************************/
+
+#include <qcheckbox.h>
+#include <qlabel.h>
+#include <qlayout.h>
+
+#include <kconfig.h>
+#include <kdebug.h>
+#include <kglobal.h>
+#include <klocale.h>
+
+#include "simpleoptions.h"
+#include "whatsthis.h"
+
+// constructor
+// ===========
+
+SimpleOptions::SimpleOptions( QWidget* parent, const char* name )
+: QWidget( parent, name )
+{ createLayout( );
+}
+
+// createLayout
+// ============
+
+void SimpleOptions::createLayout( )
+{ QGridLayout* gridLayout = new QGridLayout( this );
+
+ byte row = 1;
+ m_allPortsCheckBox = new QCheckBox( i18n( "All ports (--allports)" ), this, "all ports check" );
+ m_fastScanCheckBox = new QCheckBox( i18n( "Fast Scan (-F)" ), this, "fast scan check" );
+ m_ipV6CheckBox = new QCheckBox( i18n( "IPV6 support (-6)" ), this, "ipv6 check" );
+ m_privilegedCheckBox = new QCheckBox( i18n( "Assume privileged (--privileged)" ), this, "privileged check" );
+ m_noRandomPortsCheckBox = new QCheckBox( i18n( "No Random Ports (-r)" ), this, "no random ports check" );
+ m_osDetectionCheckBox = new QCheckBox( i18n( "OS Detection (-O)" ), this, "os detection check" );
+ m_osScanLimitCheckBox = new QCheckBox( i18n( "OS scan limit (--osscan_limit)" ), this, "os scan limit check" );
+ m_packetTraceCheckBox = new QCheckBox( i18n( "Packet trace (--packet_trace)" ), this, "packet trace check" );
+ m_prepackagedCheckBox = new QCheckBox( i18n( "Prepackaged options (-A)" ), this, "prepackaged check" );
+ m_randomizeHostsCheckBox = new QCheckBox( i18n( "Randomize hosts (--randomize_hosts)" ), this, "randomize check" );
+ m_sendEthCheckBox = new QCheckBox( i18n( "Send raw eth. packets (--send_eth)" ), this, "send eth check" );
+ m_sendIPCheckBox = new QCheckBox( i18n( "Send raw IP packets (--send_ip)" ), this, "send ip check" );
+ m_verboseCheckBox = new QCheckBox( i18n( "Verbose (-v)" ), this, "verbose check" );
+
+ row = 1;
+ gridLayout->addWidget( new QLabel( " ", this ), row, 1 );
+ gridLayout->addWidget( m_allPortsCheckBox, row++, 3 );
+ gridLayout->addWidget( new QLabel( " ", this ), row, 1 );
+ gridLayout->addWidget( m_privilegedCheckBox, row++, 3 );
+ gridLayout->addWidget( new QLabel( " ", this ), row, 1 );
+ gridLayout->addWidget( m_fastScanCheckBox, row++, 3 );
+ gridLayout->addWidget( new QLabel( " ", this ), row, 1 );
+ gridLayout->addWidget( m_ipV6CheckBox, row++, 3 );
+ gridLayout->addWidget( new QLabel( " ", this ), row, 1 );
+ gridLayout->addWidget( m_noRandomPortsCheckBox, row++, 3 );
+ byte rowBlock1 = row;
+
+ row = 1;
+ gridLayout->addWidget( new QLabel( "#", this ), row, 5 );
+ gridLayout->addWidget( m_osDetectionCheckBox, row++, 7 );
+ gridLayout->addWidget( new QLabel( " ", this ), row, 5 );
+ gridLayout->addWidget( m_osScanLimitCheckBox, row++, 7 );
+ gridLayout->addWidget( new QLabel( " ", this ), row, 5 );
+ gridLayout->addWidget( m_packetTraceCheckBox, row++, 7 );
+ gridLayout->addWidget( new QLabel( " ", this ), row, 5 );
+ gridLayout->addWidget( m_prepackagedCheckBox, row++, 7 );
+ byte rowBlock2 = row;
+
+ row = 1;
+ gridLayout->addWidget( new QLabel( " ", this ), row, 9 );
+ gridLayout->addWidget( m_randomizeHostsCheckBox, row++, 11 );
+ gridLayout->addWidget( new QLabel( " ", this ), row, 9 );
+ gridLayout->addWidget( m_sendEthCheckBox, row++, 11 );
+ gridLayout->addWidget( new QLabel( " ", this ), row, 9 );
+ gridLayout->addWidget( m_sendIPCheckBox, row++, 11 );
+ gridLayout->addWidget( new QLabel( " ", this ), row, 9 );
+ gridLayout->addWidget( m_verboseCheckBox, row++, 11 );
+ byte rowBlock3 = row;
+
+ gridLayout->setColStretch( 0, 8 );
+ gridLayout->setColStretch( 2, 1 );
+ gridLayout->setColStretch( 4, 8 );
+ gridLayout->setColStretch( 6, 1 );
+ gridLayout->setColStretch( 8, 8 );
+ gridLayout->setColStretch( 10, 1 );
+ gridLayout->setColStretch( 12, 8 );
+
+ gridLayout->setRowStretch( 0, 10 );
+ gridLayout->setRowStretch( _max_( rowBlock1, _max_( rowBlock2, rowBlock3 )) + 1, 10 );
+}
+
+// finaliseInitialisation
+// ======================
+
+void SimpleOptions::finaliseInitialisation( )
+{ WhatsThis* whatsThis = new WhatsThis( this );
+
+ connect( m_fastScanCheckBox, SIGNAL( clicked( )), SLOT( slotFastScanCheckBoxClicked( )));
+ connect( whatsThis, SIGNAL( clicked( )), SLOT( slotWhatsThisClicked( )));
+
+ connect( m_allPortsCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_fastScanCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_ipV6CheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_noRandomPortsCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_osDetectionCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_osScanLimitCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_packetTraceCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_prepackagedCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_privilegedCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_randomizeHostsCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_sendEthCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_sendIPCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_verboseCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+}
+
+// getOptions
+// ==========
+
+bool SimpleOptions::getOptions( bool& needRoot )
+{ m_allPortsState = m_allPortsCheckBox->isChecked( );
+ m_fastScanState = m_fastScanCheckBox->isChecked( );
+ m_ipV6State = m_ipV6CheckBox->isChecked( );
+ m_noRandomPortsState = m_noRandomPortsCheckBox->isChecked( );
+ m_osDetectionState = m_osDetectionCheckBox->isChecked( );
+ m_osScanLimitState = m_osScanLimitCheckBox->isChecked( );
+ m_packetTraceState = m_packetTraceCheckBox->isChecked( );
+ m_prepackagedState = m_prepackagedCheckBox->isChecked( );
+ m_privilegedState = m_privilegedCheckBox->isChecked( );
+ m_randomizeHostsState = m_randomizeHostsCheckBox->isChecked( );
+ m_sendEthState = m_sendEthCheckBox->isChecked( );
+ m_sendIPState = m_sendIPCheckBox->isChecked( );
+ m_verboseState = m_verboseCheckBox->isChecked( );
+
+ needRoot = needRoot || m_osDetectionState;
+ return true;
+}
+
+// readProfile
+// ===========
+
+void SimpleOptions::readProfile( KConfig* config )
+{ m_allPortsState = config->readBoolEntry( "allPortsState" );
+ m_fastScanState = config->readBoolEntry( "fastScanState" );
+ m_ipV6State = config->readBoolEntry( "ipV6State" );
+ m_noRandomPortsState = config->readBoolEntry( "noRandomPortsState" );
+ m_osDetectionState = config->readBoolEntry( "osDetectionState" );
+ m_osScanLimitState = config->readBoolEntry( "osScanLimitState" );
+ m_packetTraceState = config->readBoolEntry( "packetTraceState" );
+ m_prepackagedState = config->readBoolEntry( "prepackagedState" );
+ m_privilegedState = config->readBoolEntry( "privilegedState" );
+ m_randomizeHostsState = config->readBoolEntry( "randomizeHostsState" );
+ m_sendEthState = config->readBoolEntry( "sendEthState" );
+ m_sendIPState = config->readBoolEntry( "sendIPState" );
+ m_verboseState = config->readBoolEntry( "verboseState" );
+}
+
+// saveProfile
+// ===========
+
+void SimpleOptions::saveProfile( KConfig* config )
+{ config->writeEntry( "allPortsState", m_allPortsState );
+ config->writeEntry( "fastScanState", m_fastScanState );
+ config->writeEntry( "ipV6State", m_ipV6State );
+ config->writeEntry( "noRandomPortsState", m_noRandomPortsState );
+ config->writeEntry( "osDetectionState", m_osDetectionState );
+ config->writeEntry( "osScanLimitState", m_osScanLimitState );
+ config->writeEntry( "packetTraceState", m_packetTraceState );
+ config->writeEntry( "prepackagedState", m_prepackagedState );
+ config->writeEntry( "privilegedState", m_privilegedState );
+ config->writeEntry( "randomizeHostsState", m_randomizeHostsState );
+ config->writeEntry( "sendEthState", m_sendEthState );
+ config->writeEntry( "sendIPState", m_sendIPState );
+ config->writeEntry( "verboseState", m_verboseState );
+}
+
+// setInitialValues
+// ================
+
+void SimpleOptions::setInitialValues( )
+{ m_allPortsCheckBox->setChecked( m_allPortsState );
+ m_fastScanCheckBox->setChecked( m_fastScanState );
+ m_ipV6CheckBox->setChecked( m_ipV6State );
+ m_noRandomPortsCheckBox->setChecked( m_noRandomPortsState );
+ m_osDetectionCheckBox->setChecked(m_osDetectionState );
+ m_osScanLimitCheckBox->setChecked(m_osScanLimitState );
+ m_packetTraceCheckBox->setChecked( m_packetTraceState );
+ m_prepackagedCheckBox->setChecked( m_prepackagedState );
+ m_privilegedCheckBox->setChecked( m_privilegedState );
+ m_randomizeHostsCheckBox->setChecked( m_randomizeHostsState );
+ m_sendEthCheckBox->setChecked( m_sendEthState );
+ m_sendIPCheckBox->setChecked( m_sendIPState );
+ m_verboseCheckBox->setChecked( m_verboseState );
+}
+
+// slotDisableFastScan
+// ===================
+
+void SimpleOptions::slotDisableFastScan( )
+{ m_fastScanCheckBox->setChecked( false );
+}
+
+// slotFastScanCheckBoxClicked
+// ===========================
+
+void SimpleOptions::slotFastScanCheckBoxClicked( )
+{ if( m_fastScanCheckBox->isChecked( ))
+ emit( disablePortRanges( ));
+}
+
+// slotWhatsThisClicked
+// ====================
+
+void SimpleOptions::slotWhatsThisClicked( )
+{ if( m_allPortsCheckBox->hasMouse( )) emit( displayHelp( "--allports" ));
+ else if( m_fastScanCheckBox->hasMouse( )) emit( displayHelp( "-F" ));
+ else if( m_ipV6CheckBox->hasMouse( )) emit( displayHelp( "-6" ));
+ else if( m_noRandomPortsCheckBox->hasMouse( )) emit( displayHelp( "-r" ));
+ else if( m_osDetectionCheckBox->hasMouse( )) emit( displayHelp( "-O" ));
+ else if( m_osScanLimitCheckBox->hasMouse( )) emit( displayHelp( "--osscan_limit" ));
+ else if( m_packetTraceCheckBox->hasMouse( )) emit( displayHelp( "--packet_trace" ));
+ else if( m_prepackagedCheckBox->hasMouse( )) emit( displayHelp( "-A" ));
+ else if( m_privilegedCheckBox->hasMouse( )) emit( displayHelp( "--privileged" ));
+ else if( m_randomizeHostsCheckBox->hasMouse( )) emit( displayHelp( "--randomize_hosts" ));
+ else if( m_sendEthCheckBox->hasMouse( )) emit( displayHelp( "--send_eth" ));
+ else if( m_sendIPCheckBox->hasMouse( )) emit( displayHelp( "--send_ip" ));
+ else if( m_verboseCheckBox->hasMouse( )) emit( displayHelp( "-v" ));
+ else emit( displayUnknown( ));
+}
diff --git a/src/simpleoptions.h b/src/simpleoptions.h
new file mode 100644
index 0000000..009c35d
--- /dev/null
+++ b/src/simpleoptions.h
@@ -0,0 +1,113 @@
+/***************************************************************************
+ * *
+ * Copyright (C) 2005, 2006 by Kevin Gilbert *
+ * kev.gilbert@cdu.edu.au *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ * *
+ ***************************************************************************/
+
+#ifndef _SIMPLEOPTIONS_H_
+#define _SIMPLEOPTIONS_H_
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <qwidget.h>
+#include "global.h"
+
+// forward class definitions
+// =========================
+
+class QCheckBox;
+class KConfig;
+
+// SimpleOptions class definition
+// ==============================
+
+class SimpleOptions : public QWidget
+{ Q_OBJECT
+
+ public:
+ SimpleOptions( QWidget* parent, const char* name = NULL );
+
+ void finaliseInitialisation( );
+ bool getOptions( bool& needRoot );
+ void readProfile( KConfig* config );
+ void saveProfile( KConfig* config );
+ void setInitialValues( );
+
+ bool allPortsState( ) const { return m_allPortsState; }
+ bool fastScanState( ) const { return m_fastScanState; }
+ bool ipV6State( ) const { return m_ipV6State; }
+ bool noRandomPortsState( ) const { return m_noRandomPortsState; }
+ bool osDetectionState( ) const { return m_osDetectionState; }
+ bool osScanLimitState( ) const { return m_osScanLimitState; }
+ bool packetTraceState( ) const { return m_packetTraceState; }
+ bool prepackagedState( ) const { return m_prepackagedState; }
+ bool privilegedState( ) const { return m_privilegedState; }
+ bool randomizeHostsState( ) const { return m_randomizeHostsState; }
+ bool sendEthState( ) const { return m_sendEthState; }
+ bool sendIPState( ) const { return m_sendIPState; }
+ bool verboseState( ) const { return m_verboseState; }
+
+ signals:
+ void disablePortRanges( );
+ void displayDocBook( const QString& );
+ void displayHelp( const QString& );
+ void displayUnknown( );
+ void optionsDirty( );
+
+ public slots:
+ void slotDisableFastScan( );
+
+ private slots:
+ void slotFastScanCheckBoxClicked( );
+ void slotWhatsThisClicked( );
+
+ private:
+ void createLayout( );
+
+ QCheckBox* m_allPortsCheckBox;
+ bool m_allPortsState;
+ QCheckBox* m_fastScanCheckBox;
+ bool m_fastScanState;
+ QCheckBox* m_ipV6CheckBox;
+ bool m_ipV6State;
+ QCheckBox* m_noRandomPortsCheckBox;
+ bool m_noRandomPortsState;
+ QCheckBox* m_osDetectionCheckBox;
+ bool m_osDetectionState;
+ QCheckBox* m_osScanLimitCheckBox;
+ bool m_osScanLimitState;
+ QCheckBox* m_packetTraceCheckBox;
+ bool m_packetTraceState;
+ QCheckBox* m_prepackagedCheckBox;
+ bool m_prepackagedState;
+ QCheckBox* m_privilegedCheckBox;
+ bool m_privilegedState;
+ QCheckBox* m_randomizeHostsCheckBox;
+ bool m_randomizeHostsState;
+ QCheckBox* m_sendEthCheckBox;
+ bool m_sendEthState;
+ QCheckBox* m_sendIPCheckBox;
+ bool m_sendIPState;
+ QCheckBox* m_verboseCheckBox;
+ bool m_verboseState;
+};
+
+#endif // _SIMPLEOPTIONS_H_
diff --git a/src/stylesheetdialog.cpp b/src/stylesheetdialog.cpp
new file mode 100644
index 0000000..94c351e
--- /dev/null
+++ b/src/stylesheetdialog.cpp
@@ -0,0 +1,128 @@
+/***************************************************************************
+ * *
+ * Copyright (C) 2005, 2006 by Kevin Gilbert *
+ * kev.gilbert@cdu.edu.au *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ * *
+ ***************************************************************************/
+
+#include <qiconset.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qlineedit.h>
+#include <qlistbox.h>
+#include <qpushbutton.h>
+#include <qstring.h>
+#include <qstringlist.h>
+
+#include <kdebug.h>
+#include <kfiledialog.h>
+#include <kglobalsettings.h>
+#include <kiconloader.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+
+#include "stylesheetdialog.h"
+
+// constructor
+// ===========
+
+StylesheetDialog::StylesheetDialog( const QString& currentStylesheetURL,
+ const QStringList& stylesheetURLs,
+ QWidget* parent,
+ const char* name )
+: KDialogBase( Plain, "'man' stylesheet location", Ok | Cancel, Ok, parent, name ),
+ m_currentStylesheetURL( currentStylesheetURL ),
+ m_stylesheetURLs( stylesheetURLs )
+{ QGridLayout* layout = new QGridLayout( plainPage( ));
+ KIconLoader* iconLoader = KGlobal::iconLoader( );
+ QIconSet fileOpenIconSet = iconLoader->loadIconSet( "fileopen", KIcon::Small );
+ QPushButton* urlButton = new QPushButton( fileOpenIconSet, NULL, plainPage( ), "stylesheet url button" );
+ m_urlLineEdit = new QLineEdit( plainPage( ), "stylesheet url line edit" );
+ m_urlListBox = new QListBox( plainPage( ), "stylesheet url list box" );
+
+ m_urlListBox->insertStringList( stylesheetURLs );
+ m_urlLineEdit->setMinimumWidth( int( 1.1 * m_urlListBox->maxItemWidth( )));
+ m_urlLineEdit->setText( currentStylesheetURL );
+
+ layout->addWidget( new QLabel( "Stylesheet URL: ", plainPage( ), "url label" ), 1, 1, Qt::AlignRight );
+ layout->addWidget( m_urlLineEdit, 1, 2 );
+ layout->addWidget( urlButton, 1, 3 );
+ layout->addWidget( new QLabel( "Known URLs: ", plainPage( ), "url label" ), 3, 1, Qt::AlignRight | Qt::AlignTop );
+ layout->addWidget( m_urlListBox, 3, 2 );
+
+ layout->setColStretch( 0, 1 );
+ layout->setColStretch( 2, 20 );
+ layout->setColStretch( 4, 1 );
+
+ layout->setRowStretch( 0, 2 );
+ layout->setRowStretch( 2, 1 );
+ layout->setRowStretch( 3, 10 );
+ layout->setRowStretch( 4, 2 );
+
+ connect( urlButton, SIGNAL( clicked( )), SLOT( slotURLButtonClicked( )));
+ connect( m_urlListBox, SIGNAL( doubleClicked( QListBoxItem* )), SLOT( slotURLListBoxDoubleClicked( QListBoxItem* )));
+}
+
+// slotOk
+// ======
+
+void StylesheetDialog::slotOk( )
+{ QString currentStylesheetURL = m_urlLineEdit->text( );
+ QStringList::Iterator it = m_stylesheetURLs.find( currentStylesheetURL );
+
+ if( it != m_stylesheetURLs.end( ))
+ m_stylesheetURLs.remove( it );
+
+ if( !QFile::exists( currentStylesheetURL ))
+ { KMessageBox::sorry( this, QString( i18n( "The stylesheet \"%1\" does not exist" )).arg( currentStylesheetURL ), i18n( "Nonexistant stylesheet" ));
+ QListBoxItem* item = m_urlListBox->findItem( currentStylesheetURL, Qt::ExactMatch );
+
+ if( item != NULL )
+ { m_urlListBox->removeItem( m_urlListBox->index( item ));
+ emit( stylesheetRemoved( ));
+ }
+
+ m_urlLineEdit->clear( );
+ return;
+ }
+
+ m_stylesheetURLs.push_front( currentStylesheetURL );
+ KDialogBase::slotOk( );
+}
+
+// slotURLButtonClicked
+// ====================
+
+void StylesheetDialog::slotURLButtonClicked( )
+{ QString filter = "*.css|CSS files\n*.*|All files";
+ QString startDir = (m_currentStylesheetURL.isEmpty( )) ? KGlobalSettings::documentPath( ) : m_currentStylesheetURL;
+ QString stylesheetURL = KFileDialog::getOpenFileName( startDir, filter, this, "url path dlg" );
+
+ if( stylesheetURL.isEmpty( ))
+ return;
+
+ m_urlLineEdit->setText( stylesheetURL );
+}
+
+// slotURLListBoxDoubleClicked
+// ===========================
+
+void StylesheetDialog::slotURLListBoxDoubleClicked( QListBoxItem* item )
+{ m_urlLineEdit->setText( item->text( ));
+ slotOk( );
+}
diff --git a/src/stylesheetdialog.h b/src/stylesheetdialog.h
new file mode 100644
index 0000000..50be040
--- /dev/null
+++ b/src/stylesheetdialog.h
@@ -0,0 +1,70 @@
+/***************************************************************************
+ * *
+ * Copyright (C) 2005, 2006 by Kevin Gilbert *
+ * kev.gilbert@cdu.edu.au *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ * *
+ ***************************************************************************/
+
+#ifndef _STYLESHEETDIALOG_H_
+#define _STYLESHEETDIALOG_H_
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <kdialogbase.h>
+#include "global.h"
+
+// forward class definitions
+// =========================
+
+class QListBox;
+class QLineEdit;
+class QString;
+class QStringList;
+
+// StylesheetDialog class definition
+// =================================
+
+class StylesheetDialog : public KDialogBase
+{ Q_OBJECT
+
+ public:
+ StylesheetDialog( const QString& currentStylesheetURL,
+ const QStringList& stylesheetURLs,
+ QWidget* parent = NULL,
+ const char* name = NULL );
+
+ QStringList stylesheetURLs( ) const { return m_stylesheetURLs; }
+
+ signals:
+ void stylesheetRemoved( );
+
+ private slots:
+ void slotOk( );
+ void slotURLButtonClicked( );
+ void slotURLListBoxDoubleClicked( QListBoxItem* item );
+
+ private:
+ QString m_currentStylesheetURL;
+ QStringList m_stylesheetURLs;
+ QListBox* m_urlListBox;
+ QLineEdit* m_urlLineEdit;
+};
+
+#endif // _STYLESHEETDIALOG_H_
diff --git a/src/tabwidgetdata.cpp b/src/tabwidgetdata.cpp
new file mode 100644
index 0000000..8fdcf0c
--- /dev/null
+++ b/src/tabwidgetdata.cpp
@@ -0,0 +1,39 @@
+/***************************************************************************
+ * *
+ * Copyright (C) 2005, 2006 by Kevin Gilbert *
+ * kev.gilbert@cdu.edu.au *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ * *
+ ***************************************************************************/
+
+#include <qstring.h>
+#include <qwidget.h>
+
+#include <kdebug.h>
+#include <klocale.h>
+
+#include "tabwidgetdata.h"
+
+// constructor
+// ===========
+
+TabWidgetData::TabWidgetData( const int index, const QString& title, QWidget* widget )
+: m_index( index ),
+ m_title( title ),
+ m_widget( widget )
+{
+}
diff --git a/src/tabwidgetdata.h b/src/tabwidgetdata.h
new file mode 100644
index 0000000..c72b3ff
--- /dev/null
+++ b/src/tabwidgetdata.h
@@ -0,0 +1,49 @@
+/***************************************************************************
+ * *
+ * Copyright (C) 2005, 2006 by Kevin Gilbert *
+ * kev.gilbert@cdu.edu.au *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ * *
+ ***************************************************************************/
+
+#ifndef _TABWIDGETDATA_H_
+#define _TABWIDGETDATA_H_
+
+// forward class definitions
+// =========================
+
+class QString;
+class QWidget;
+
+// TabWidgetData class definition
+// ==============================
+
+class TabWidgetData
+{ public:
+ TabWidgetData( const int index, const QString& title, QWidget* widget );
+
+ int index( ) const { return m_index; }
+ QString title( ) const { return m_title; }
+ QWidget* widget( ) const { return m_widget; }
+
+ private:
+ int m_index;
+ QString m_title;
+ QWidget* m_widget;
+};
+
+#endif // _TABWIDGETDATA_H_
diff --git a/src/tabwidgetptrlist.cpp b/src/tabwidgetptrlist.cpp
new file mode 100644
index 0000000..1e5408c
--- /dev/null
+++ b/src/tabwidgetptrlist.cpp
@@ -0,0 +1,47 @@
+/***************************************************************************
+ * *
+ * Copyright (C) 2005, 2006 by Kevin Gilbert *
+ * kev.gilbert@cdu.edu.au *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ * *
+ ***************************************************************************/
+
+#include <qptrcollection.h>
+
+#include <kdebug.h>
+#include <klocale.h>
+
+#include "tabwidgetptrlist.h"
+
+// constructor
+// ===========
+
+TabWidgetPtrList::TabWidgetPtrList( )
+{ setAutoDelete( true );
+}
+
+// compareItems
+// ============
+
+int TabWidgetPtrList::compareItems( QPtrCollection::Item item1, QPtrCollection::Item item2 )
+{ typedef TabWidgetData* DataPtr;
+
+ if( DataPtr( item1 )->index( ) < DataPtr( item2 )->index( ))
+ return -1;
+
+ return DataPtr( item1 )->index( ) != DataPtr( item2 )->index( );
+}
diff --git a/src/tabwidgetptrlist.h b/src/tabwidgetptrlist.h
new file mode 100644
index 0000000..56e835f
--- /dev/null
+++ b/src/tabwidgetptrlist.h
@@ -0,0 +1,49 @@
+/***************************************************************************
+ * *
+ * Copyright (C) 2005, 2006 by Kevin Gilbert *
+ * kev.gilbert@cdu.edu.au *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ * *
+ ***************************************************************************/
+
+#ifndef _TABWIDGETPTRLIST_H_
+#define _TABWIDGETPTRLIST_H_
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <qptrlist.h>
+#include "global.h"
+#include "tabwidgetdata.h"
+
+// forward class definitions
+// =========================
+
+class QPtrCollection;
+
+// TabWidgetPtrList class definition
+// =================================
+
+class TabWidgetPtrList : public QPtrList<TabWidgetData>
+{ public:
+ TabWidgetPtrList( );
+
+ int compareItems( QPtrCollection::Item item1, QPtrCollection::Item item2 );
+};
+
+#endif // _TABWIDGETPTRLIST_H_
diff --git a/src/timingwidget.cpp b/src/timingwidget.cpp
new file mode 100644
index 0000000..30f121b
--- /dev/null
+++ b/src/timingwidget.cpp
@@ -0,0 +1,664 @@
+/***************************************************************************
+ * *
+ * Copyright (C) 2005, 2006 by Kevin Gilbert *
+ * kev.gilbert@cdu.edu.au *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ * *
+ ***************************************************************************/
+
+#include <qbuttongroup.h>
+#include <qcheckbox.h>
+#include <qiconset.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qlineedit.h>
+#include <qpushbutton.h>
+#include <qradiobutton.h>
+
+#include <kconfig.h>
+#include <kdebug.h>
+#include <kglobal.h>
+#include <kiconloader.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+
+#include "timingwidget.h"
+#include "whatsthis.h"
+
+// constructor
+// ===========
+
+TimingWidget::TimingWidget( QWidget* parent, const char* name )
+: QWidget( parent, name )
+{ createLayout( );
+}
+
+// createLayout
+// ============
+
+void TimingWidget::createLayout( )
+{ QGridLayout* gridLayout = new QGridLayout( this );
+ KIconLoader* iconLoader = KGlobal::iconLoader( );
+ QIconSet clearLeftIconSet = iconLoader->loadIconSet( "clear_left", KIcon::Small );
+
+ byte row = 1;
+ QButtonGroup* timingGroupBox = new QButtonGroup( 7, Qt::Vertical, "Simple Timing", this, "timing group box" );
+ m_defaultRadio = new QRadioButton( i18n( "Default" ), timingGroupBox, "default radio button" );
+ m_aggressiveRadio = new QRadioButton( i18n( "Aggressive (-T4)" ), timingGroupBox, "aggressive radio button" );
+ m_insaneRadio = new QRadioButton( i18n( "Insane (-T5)" ), timingGroupBox, "insane radio button" );
+ m_normalRadio = new QRadioButton( i18n( "Normal (-T3)" ), timingGroupBox, "normal radio button" );
+ m_paranoidRadio = new QRadioButton( i18n( "Paranoid (-T0)" ), timingGroupBox, "paranoid radio button" );
+ m_politeRadio = new QRadioButton( i18n( "Polite (-T2)" ), timingGroupBox, "polite radio button" );
+ m_sneakyRadio = new QRadioButton( i18n( "Sneaky (-T1)" ), timingGroupBox, "sneaky radio button" );
+ gridLayout->addMultiCellWidget( timingGroupBox, row, row + 7, 1, 1 );
+ row += 7;
+ byte rowBlock1 = row;
+
+ m_hostTimeoutButton = new QPushButton( clearLeftIconSet, NULL, this, "host timeout button" );
+ m_initialRTTTimeoutButton = new QPushButton( clearLeftIconSet, NULL, this, "initial rtt timeout button" );
+ m_maxHostGroupButton = new QPushButton( clearLeftIconSet, NULL, this, "max host group button" );
+ m_maxParallelismButton = new QPushButton( clearLeftIconSet, NULL, this, "max parallelism button" );
+ m_maxRTTTimeoutButton = new QPushButton( clearLeftIconSet, NULL, this, "max rtt timeout button" );
+ m_maxScanDelayButton = new QPushButton( clearLeftIconSet, NULL, this, "max scan delay button" );
+ m_minHostGroupButton = new QPushButton( clearLeftIconSet, NULL, this, "min host group button" );
+ m_minParallelismButton = new QPushButton( clearLeftIconSet, NULL, this, "min parallelism button" );
+ m_minRTTTimeoutButton = new QPushButton( clearLeftIconSet, NULL, this, "min rtt timeout button" );
+ m_scanDelayButton = new QPushButton( clearLeftIconSet, NULL, this, "min scan delay button" );
+
+ m_hostTimeoutCheckBox = new QCheckBox( i18n( "Host timeout (--host_timeout)" ), this, "host timeout checkbox" );
+ m_initialRTTTimeoutCheckBox = new QCheckBox( i18n( "Initial RTT timeout (--initial_rtt_timeout)" ), this, "initial rtt timeout checkbox" );
+ m_maxHostGroupCheckBox = new QCheckBox( i18n( "Max Host group (--max_hostgroup)" ), this, "max host group checkbox" );
+ m_maxParallelismCheckBox = new QCheckBox( i18n( "Max Parallelism (--max_parallelism)" ), this, "max parallelism checkbox" );
+ m_maxRTTTimeoutCheckBox = new QCheckBox( i18n( "Max RTT timeout (--max_rtt_timeout)" ), this, "max rtt timeout checkbox" );
+ m_maxScanDelayCheckBox = new QCheckBox( i18n( "Max Scan delay (--max_scan_delay)" ), this, "max scan delay checkbox" );
+ m_minHostGroupCheckBox = new QCheckBox( i18n( "Min Host group (--min_hostgroup)" ), this, "min host group checkbox" );
+ m_minParallelismCheckBox = new QCheckBox( i18n( "Min Parallelism (--min_parallelism)" ), this, "min parallelism checkbox" );
+ m_minRTTTimeoutCheckBox = new QCheckBox( i18n( "Min RTT timeout (--min_rtt_timeout)" ), this, "min rtt timeout checkbox" );
+ m_scanDelayCheckBox = new QCheckBox( i18n( "Min Scan delay (--scan_delay)" ), this, "min scan delay checkbox" );
+
+ m_hostTimeoutLineEdit = new QLineEdit( this, "host timeout line edit" );
+ m_initialRTTTimeoutLineEdit = new QLineEdit( this, "initial rtt timeout line edit" );
+ m_maxHostGroupLineEdit = new QLineEdit( this, "max host group line edit" );
+ m_maxParallelismLineEdit = new QLineEdit( this, "max parallelism line edit" );
+ m_maxRTTTimeoutLineEdit = new QLineEdit( this, "max rtt timeout line edit" );
+ m_maxScanDelayLineEdit = new QLineEdit( this, "max scan delay line edit" );
+ m_minHostGroupLineEdit = new QLineEdit( this, "min host group line edit" );
+ m_minParallelismLineEdit = new QLineEdit( this, "min parallelism line edit" );
+ m_minRTTTimeoutLineEdit = new QLineEdit( this, "min rtt timeout line edit" );
+ m_scanDelayLineEdit = new QLineEdit( this, "min scan delay line edit" );
+
+ m_hostTimeoutLineEdit->setInputMask( "999999" );
+ m_initialRTTTimeoutLineEdit->setInputMask( "999999" );
+ m_maxHostGroupLineEdit->setInputMask( "999999" );
+ m_maxParallelismLineEdit->setInputMask( "999999" );
+ m_maxRTTTimeoutLineEdit->setInputMask( "999999" );
+ m_maxScanDelayLineEdit->setInputMask( "999999" );
+ m_minHostGroupLineEdit->setInputMask( "999999" );
+ m_minParallelismLineEdit->setInputMask( "999999" );
+ m_minRTTTimeoutLineEdit->setInputMask( "999999" );
+ m_scanDelayLineEdit->setInputMask( "999999" );
+
+ row = 1;
+ gridLayout->addWidget( m_hostTimeoutCheckBox, row, 3 );
+ gridLayout->addWidget( m_hostTimeoutLineEdit, row, 4 );
+ gridLayout->addWidget( m_hostTimeoutButton, row++, 5 );
+
+ gridLayout->addWidget( m_maxHostGroupCheckBox, row, 3 );
+ gridLayout->addWidget( m_maxHostGroupLineEdit, row, 4 );
+ gridLayout->addWidget( m_maxHostGroupButton, row++, 5 );
+
+ gridLayout->addWidget( m_minHostGroupCheckBox, row, 3 );
+ gridLayout->addWidget( m_minHostGroupLineEdit, row, 4 );
+ gridLayout->addWidget( m_minHostGroupButton, row++, 5 );
+
+ gridLayout->addWidget( m_maxParallelismCheckBox, row, 3 );
+ gridLayout->addWidget( m_maxParallelismLineEdit, row, 4 );
+ gridLayout->addWidget( m_maxParallelismButton, row++, 5 );
+
+ gridLayout->addWidget( m_minParallelismCheckBox, row, 3 );
+ gridLayout->addWidget( m_minParallelismLineEdit, row, 4 );
+ gridLayout->addWidget( m_minParallelismButton, row++, 5 );
+ byte rowBlock2 = row;
+
+ row = 1;
+ gridLayout->addWidget( m_initialRTTTimeoutCheckBox, row, 7 );
+ gridLayout->addWidget( m_initialRTTTimeoutLineEdit, row, 8 );
+ gridLayout->addWidget( m_initialRTTTimeoutButton, row++, 9 );
+
+ gridLayout->addWidget( m_maxRTTTimeoutCheckBox, row, 7 );
+ gridLayout->addWidget( m_maxRTTTimeoutLineEdit, row, 8 );
+ gridLayout->addWidget( m_maxRTTTimeoutButton, row++, 9 );
+
+ gridLayout->addWidget( m_minRTTTimeoutCheckBox, row, 7 );
+ gridLayout->addWidget( m_minRTTTimeoutLineEdit, row, 8 );
+ gridLayout->addWidget( m_minRTTTimeoutButton, row++, 9 );
+
+ gridLayout->addWidget( m_maxScanDelayCheckBox, row, 7 );
+ gridLayout->addWidget( m_maxScanDelayLineEdit, row, 8 );
+ gridLayout->addWidget( m_maxScanDelayButton, row++, 9 );
+
+ gridLayout->addWidget( m_scanDelayCheckBox, row, 7 );
+ gridLayout->addWidget( m_scanDelayLineEdit, row, 8 );
+ gridLayout->addWidget( m_scanDelayButton, row++, 9 );
+ byte rowBlock3 = row;
+
+ gridLayout->setColStretch( 0, 3 );
+ gridLayout->setColStretch( 2, 3 );
+ gridLayout->setColStretch( 4, 10 );
+ gridLayout->setColStretch( 6, 3 );
+ gridLayout->setColStretch( 8, 10 );
+ gridLayout->setColStretch( 10, 3 );
+
+ gridLayout->setRowStretch( 0, 10 );
+ gridLayout->setRowStretch( _max_( rowBlock1, _max_( rowBlock2, rowBlock3 )) + 1, 10 );
+}
+
+// finaliseInitialisation
+// ======================
+
+void TimingWidget::finaliseInitialisation( )
+{ WhatsThis* whatsThis = new WhatsThis( this );
+
+ connect( m_aggressiveRadio, SIGNAL( clicked( )), SLOT( slotAggressiveRadioClicked( )));
+ connect( m_defaultRadio, SIGNAL( clicked( )), SLOT( slotDefaultRadioClicked( )));
+ connect( m_hostTimeoutButton, SIGNAL( clicked( )), SLOT( slotHostTimeoutButtonClicked( )));
+ connect( m_hostTimeoutCheckBox, SIGNAL( clicked( )), SLOT( slotHostTimeoutCheckBoxClicked( )));
+ connect( m_initialRTTTimeoutButton, SIGNAL( clicked( )), SLOT( slotInitialRTTTimeoutButtonClicked( )));
+ connect( m_initialRTTTimeoutCheckBox, SIGNAL( clicked( )), SLOT( slotInitialRTTTimeoutCheckBoxClicked( )));
+ connect( m_insaneRadio, SIGNAL( clicked( )), SLOT( slotInsaneRadioClicked( )));
+ connect( m_maxHostGroupButton, SIGNAL( clicked( )), SLOT( slotMaxHostGroupButtonClicked( )));
+ connect( m_maxHostGroupCheckBox, SIGNAL( clicked( )), SLOT( slotMaxHostGroupCheckBoxClicked( )));
+ connect( m_maxParallelismButton, SIGNAL( clicked( )), SLOT( slotMaxParallelismButtonClicked( )));
+ connect( m_maxParallelismCheckBox, SIGNAL( clicked( )), SLOT( slotMaxParallelismCheckBoxClicked( )));
+ connect( m_maxRTTTimeoutButton, SIGNAL( clicked( )), SLOT( slotMaxRTTTimeoutButtonClicked( )));
+ connect( m_maxRTTTimeoutCheckBox, SIGNAL( clicked( )), SLOT( slotMaxRTTTimeoutCheckBoxClicked( )));
+ connect( m_maxScanDelayButton, SIGNAL( clicked( )), SLOT( slotMaxScanDelayButtonClicked( )));
+ connect( m_maxScanDelayCheckBox, SIGNAL( clicked( )), SLOT( slotMaxScanDelayCheckBoxClicked( )));
+ connect( m_minHostGroupButton, SIGNAL( clicked( )), SLOT( slotMinHostGroupButtonClicked( )));
+ connect( m_minHostGroupCheckBox, SIGNAL( clicked( )), SLOT( slotMinHostGroupCheckBoxClicked( )));
+ connect( m_minParallelismButton, SIGNAL( clicked( )), SLOT( slotMinParallelismButtonClicked( )));
+ connect( m_minParallelismCheckBox, SIGNAL( clicked( )), SLOT( slotMinParallelismCheckBoxClicked( )));
+ connect( m_minRTTTimeoutButton, SIGNAL( clicked( )), SLOT( slotMinRTTTimeoutButtonClicked( )));
+ connect( m_minRTTTimeoutCheckBox, SIGNAL( clicked( )), SLOT( slotMinRTTTimeoutCheckBoxClicked( )));
+ connect( m_normalRadio, SIGNAL( clicked( )), SLOT( slotNormalRadioClicked( )));
+ connect( m_paranoidRadio, SIGNAL( clicked( )), SLOT( slotParanoidRadioClicked( )));
+ connect( m_politeRadio, SIGNAL( clicked( )), SLOT( slotPoliteRadioClicked( )));
+ connect( m_scanDelayButton, SIGNAL( clicked( )), SLOT( slotScanDelayButtonClicked( )));
+ connect( m_scanDelayCheckBox, SIGNAL( clicked( )), SLOT( slotScanDelayCheckBoxClicked( )));
+ connect( m_sneakyRadio, SIGNAL( clicked( )), SLOT( slotSneakyRadioClicked( )));
+ connect( whatsThis, SIGNAL( clicked( )), SLOT( slotWhatsThisClicked( )));
+
+ connect( m_aggressiveRadio, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_defaultRadio, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_hostTimeoutCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_hostTimeoutLineEdit, SIGNAL( textChanged( const QString& )), SIGNAL( optionsDirty( )));
+ connect( m_initialRTTTimeoutCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_initialRTTTimeoutLineEdit, SIGNAL( textChanged( const QString& )), SIGNAL( optionsDirty( )));
+ connect( m_insaneRadio, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_maxHostGroupCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_maxHostGroupLineEdit, SIGNAL( textChanged( const QString& )), SIGNAL( optionsDirty( )));
+ connect( m_maxParallelismCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_maxParallelismLineEdit, SIGNAL( textChanged( const QString& )), SIGNAL( optionsDirty( )));
+ connect( m_maxRTTTimeoutCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_maxRTTTimeoutLineEdit, SIGNAL( textChanged( const QString& )), SIGNAL( optionsDirty( )));
+ connect( m_maxScanDelayCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_maxScanDelayLineEdit, SIGNAL( textChanged( const QString& )), SIGNAL( optionsDirty( )));
+ connect( m_minHostGroupCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_minHostGroupLineEdit, SIGNAL( textChanged( const QString& )), SIGNAL( optionsDirty( )));
+ connect( m_minParallelismCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_minParallelismLineEdit, SIGNAL( textChanged( const QString& )), SIGNAL( optionsDirty( )));
+ connect( m_minRTTTimeoutCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_minRTTTimeoutLineEdit, SIGNAL( textChanged( const QString& )), SIGNAL( optionsDirty( )));
+ connect( m_normalRadio, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_paranoidRadio, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_politeRadio, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_scanDelayCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+ connect( m_scanDelayLineEdit, SIGNAL( textChanged( const QString& )), SIGNAL( optionsDirty( )));
+ connect( m_sneakyRadio, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
+}
+
+// getOptions
+// ==========
+
+bool TimingWidget::getOptions( )
+{ bool maxHostGroupState = m_maxHostGroupCheckBox->isChecked( );
+ uint maxHostGroupValue = m_maxHostGroupLineEdit->text( ).toUInt( );
+ bool maxParallelismState = m_maxParallelismCheckBox->isChecked( );
+ uint maxParallelismValue = m_maxParallelismLineEdit->text( ).toUInt( );
+ bool maxRTTTimeoutState = m_maxRTTTimeoutCheckBox->isChecked( );
+ uint maxRTTTimeoutValue = m_maxRTTTimeoutLineEdit->text( ).toUInt( );
+ bool maxScanDelayState = m_maxScanDelayCheckBox->isChecked( );
+ uint maxScanDelayValue = m_maxScanDelayLineEdit->text( ).toUInt( );
+ bool minHostGroupState = m_minHostGroupCheckBox->isChecked( );
+ uint minHostGroupValue = m_minHostGroupLineEdit->text( ).toUInt( );
+ bool minParallelismState = m_minParallelismCheckBox->isChecked( );
+ uint minParallelismValue = m_minParallelismLineEdit->text( ).toUInt( );
+ bool minRTTTimeoutState = m_minRTTTimeoutCheckBox->isChecked( );
+ uint minRTTTimeoutValue = m_minRTTTimeoutLineEdit->text( ).toUInt( );
+ bool scanDelayState = m_scanDelayCheckBox->isChecked( );
+ uint scanDelayValue = m_scanDelayLineEdit->text( ).toUInt( );
+
+ if( minHostGroupValue > maxHostGroupValue )
+ { KMessageBox::error( this, i18n( QString( "Min host group not < Max host group" )), i18n( "Host group error" ));
+ return false;
+ }
+
+ if( minParallelismValue > maxParallelismValue )
+ { KMessageBox::error( this, i18n( QString( "Min parallelism not < Max parallelism" )), i18n( "Parallelism error" ));
+ return false;
+ }
+
+ if( minRTTTimeoutValue > maxRTTTimeoutValue )
+ { KMessageBox::error( this, i18n( QString( "Min RTT timeout not < Max RTT timeout" )), i18n( "RTT timeout error" ));
+ return false;
+ }
+
+ if( scanDelayValue > maxScanDelayValue )
+ { KMessageBox::error( this, i18n( QString( "Min scan delay not < Max scan delay" )), i18n( "Scan delay error" ));
+ return false;
+ }
+
+ m_hostTimeoutState = m_hostTimeoutCheckBox->isChecked( );
+ m_hostTimeoutValue = m_hostTimeoutLineEdit->text( ).toUInt( );
+ m_initialRTTTimeoutState = m_initialRTTTimeoutCheckBox->isChecked( );
+ m_initialRTTTimeoutValue = m_initialRTTTimeoutLineEdit->text( ).toUInt( );
+ m_maxHostGroupState = maxHostGroupState;
+ m_maxHostGroupValue = maxHostGroupValue;
+ m_maxParallelismState = maxParallelismState;
+ m_maxParallelismValue = maxParallelismValue;
+ m_maxRTTTimeoutState = maxRTTTimeoutState;
+ m_maxRTTTimeoutValue = maxRTTTimeoutValue;
+ m_maxScanDelayState = maxScanDelayState;
+ m_maxScanDelayValue = maxScanDelayValue;
+ m_minHostGroupState = minHostGroupState;
+ m_minHostGroupValue = minHostGroupValue;
+ m_minParallelismState = minParallelismState;
+ m_minParallelismValue = minParallelismValue;
+ m_minRTTTimeoutState = minRTTTimeoutState;
+ m_minRTTTimeoutValue = minRTTTimeoutValue;
+ m_scanDelayState = scanDelayState;
+ m_scanDelayValue = scanDelayValue;
+
+ return true;
+}
+
+// readProfile
+// ===========
+
+void TimingWidget::readProfile( KConfig* config )
+{ m_hostTimeoutState = config->readBoolEntry( "hostTimeoutState" );
+ m_hostTimeoutValue = config->readNumEntry( "hostTimeoutValue" );
+ m_initialRTTTimeoutState = config->readBoolEntry( "initialRTTTimeoutState" );
+ m_initialRTTTimeoutValue = config->readNumEntry( "initialRTTTimeoutValue" );
+ m_maxHostGroupState = config->readBoolEntry( "maxHostGroupState" );
+ m_maxHostGroupValue = config->readNumEntry( "maxHostGroupValue" );
+ m_maxParallelismState = config->readBoolEntry( "maxParallelismState" );
+ m_maxParallelismValue = config->readNumEntry( "maxParallelismValue" );
+ m_maxRTTTimeoutState = config->readBoolEntry( "maxRTTTimeoutState" );
+ m_maxRTTTimeoutValue = config->readNumEntry( "maxRTTTimeoutValue" );
+ m_maxScanDelayState = config->readBoolEntry( "maxScanDelayState" );
+ m_maxScanDelayValue = config->readNumEntry( "maxScanDelayValue" );
+ m_minHostGroupState = config->readBoolEntry( "minHostGroupState" );
+ m_minHostGroupValue = config->readNumEntry( "minHostGroupValue" );
+ m_minParallelismState = config->readBoolEntry( "minParallelismState" );
+ m_minParallelismValue = config->readNumEntry( "minParallelismValue" );
+ m_minRTTTimeoutState = config->readBoolEntry( "minRTTTimeoutState" );
+ m_minRTTTimeoutValue = config->readNumEntry( "minRTTTimeoutValue" );
+ m_scanDelayState = config->readBoolEntry( "scanDelayState" );
+ m_scanDelayValue = config->readNumEntry( "scanDelayValue" );
+
+ m_simpleTimingValue = Timing( config->readNumEntry( "simpleTimingValue", Normal_T3_Timing ));
+}
+
+// saveProfile
+// ===========
+
+void TimingWidget::saveProfile( KConfig* config )
+{ config->writeEntry( "hostTimeoutState", m_hostTimeoutState );
+ config->writeEntry( "hostTimeoutValue", m_hostTimeoutValue );
+ config->writeEntry( "initialRTTTimeoutState", m_initialRTTTimeoutState );
+ config->writeEntry( "initialRTTTimeoutValue", m_initialRTTTimeoutValue );
+ config->writeEntry( "maxHostGroupState", m_maxHostGroupState );
+ config->writeEntry( "maxHostGroupValue", m_maxHostGroupValue );
+ config->writeEntry( "maxParallelismState", m_maxParallelismState );
+ config->writeEntry( "maxParallelismValue", m_maxParallelismValue );
+ config->writeEntry( "maxRTTTimeoutState", m_maxRTTTimeoutState );
+ config->writeEntry( "maxRTTTimeoutValue", m_maxRTTTimeoutValue );
+ config->writeEntry( "maxScanDelayState", m_maxScanDelayState );
+ config->writeEntry( "maxScanDelayValue", m_maxScanDelayValue );
+ config->writeEntry( "minHostGroupState", m_minHostGroupState );
+ config->writeEntry( "minHostGroupValue", m_minHostGroupValue );
+ config->writeEntry( "minParallelismState", m_minParallelismState );
+ config->writeEntry( "minParallelismValue", m_minParallelismValue );
+ config->writeEntry( "minRTTTimeoutState", m_minRTTTimeoutState );
+ config->writeEntry( "minRTTTimeoutValue", m_minRTTTimeoutValue );
+ config->writeEntry( "scanDelayState", m_scanDelayState );
+ config->writeEntry( "scanDelayValue", m_scanDelayValue );
+ config->writeEntry( "simpleTimingValue", m_simpleTimingValue );
+}
+
+// setInitialValues
+// ================
+
+void TimingWidget::setInitialValues( )
+{ m_hostTimeoutCheckBox->setChecked( m_hostTimeoutState );
+ m_hostTimeoutLineEdit->setEnabled( m_hostTimeoutState );
+ m_hostTimeoutLineEdit->setText( QString::number( m_hostTimeoutValue ));
+ m_initialRTTTimeoutCheckBox->setChecked( m_initialRTTTimeoutState );
+ m_initialRTTTimeoutLineEdit->setEnabled( m_initialRTTTimeoutState );
+ m_initialRTTTimeoutLineEdit->setText( QString::number( m_initialRTTTimeoutValue ));
+ m_maxHostGroupCheckBox->setChecked( m_maxHostGroupState );
+ m_maxHostGroupLineEdit->setEnabled( m_maxHostGroupState );
+ m_maxHostGroupLineEdit->setText( QString::number( m_maxHostGroupValue ));
+ m_maxParallelismCheckBox->setChecked( m_maxParallelismState );
+ m_maxParallelismLineEdit->setEnabled( m_maxParallelismState );
+ m_maxParallelismLineEdit->setText( QString::number( m_maxParallelismValue ));
+ m_maxRTTTimeoutCheckBox->setChecked( m_maxRTTTimeoutState );
+ m_maxRTTTimeoutLineEdit->setEnabled( m_maxRTTTimeoutState );
+ m_maxRTTTimeoutLineEdit->setText( QString::number( m_maxRTTTimeoutValue ));
+ m_maxScanDelayCheckBox->setChecked( m_maxScanDelayState );
+ m_maxScanDelayLineEdit->setEnabled( m_maxScanDelayState );
+ m_maxScanDelayLineEdit->setText( QString::number( m_maxScanDelayValue ));
+ m_minHostGroupCheckBox->setChecked( m_minHostGroupState );
+ m_minHostGroupLineEdit->setEnabled( m_minHostGroupState );
+ m_minHostGroupLineEdit->setText( QString::number( m_minHostGroupValue ));
+ m_minParallelismCheckBox->setChecked( m_minParallelismState );
+ m_minParallelismLineEdit->setEnabled( m_minParallelismState );
+ m_minParallelismLineEdit->setText( QString::number( m_minParallelismValue ));
+ m_minRTTTimeoutCheckBox->setChecked( m_minRTTTimeoutState );
+ m_minRTTTimeoutLineEdit->setEnabled( m_minRTTTimeoutState );
+ m_minRTTTimeoutLineEdit->setText( QString::number( m_minRTTTimeoutValue ));
+ m_scanDelayCheckBox->setChecked( m_scanDelayState );
+ m_scanDelayLineEdit->setEnabled( m_scanDelayState );
+ m_scanDelayLineEdit->setText( QString::number( m_scanDelayValue ));
+
+ switch( m_simpleTimingValue )
+ { case Aggressive_T4_Timing: m_aggressiveRadio->setChecked( true ); break;
+ case Default_Timing: m_defaultRadio->setChecked( true ); break;
+ case Insane_T5_Timing: m_insaneRadio->setChecked( true ); break;
+ case Normal_T3_Timing: m_normalRadio->setChecked( true ); break;
+ case Paranoid_T0_Timing: m_paranoidRadio->setChecked( true ); break;
+ case Polite_T2_Timing: m_politeRadio->setChecked( true ); break;
+ case Sneaky_T1_Timing: m_sneakyRadio->setChecked( true ); break;
+
+ default:
+ kdDebug( ) << "internal error - unknown simple timing value " << m_simpleTimingValue << endl;
+ ASSERT( false );
+ }
+}
+
+// simpleTiming
+// ============
+
+QString TimingWidget::simpleTiming( ) const
+{ switch( m_simpleTimingValue )
+ { case Aggressive_T4_Timing: return "Aggressive";
+ case Default_Timing: return "";
+ case Insane_T5_Timing: return "Insane";
+ case Normal_T3_Timing: return "Normal";
+ case Paranoid_T0_Timing: return "Paranoid";
+ case Polite_T2_Timing: return "Polite";
+ case Sneaky_T1_Timing: return "Sneaky";
+ }
+
+ kdDebug( ) << "internal error - unknown simple timing value " << m_simpleTimingValue << endl;
+ ASSERT( false );
+ return QString::null;
+}
+
+// slotAggressiveRadioClicked
+// ==========================
+
+void TimingWidget::slotAggressiveRadioClicked( )
+{ m_simpleTimingValue = Aggressive_T4_Timing;
+}
+
+// slotDefaultRadioClicked
+// =======================
+
+void TimingWidget::slotDefaultRadioClicked( )
+{ m_simpleTimingValue = Default_Timing;
+}
+
+// slotHostTimeoutButtonClicked
+// ============================
+
+void TimingWidget::slotHostTimeoutButtonClicked( )
+{ m_hostTimeoutLineEdit->clear( );
+}
+
+// slotHostTimeoutCheckBoxClicked
+// ==============================
+
+void TimingWidget::slotHostTimeoutCheckBoxClicked( )
+{ m_hostTimeoutButton->setEnabled( m_hostTimeoutCheckBox->isChecked( ));
+ m_hostTimeoutLineEdit->setEnabled( m_hostTimeoutCheckBox->isChecked( ));
+}
+
+// slotInitialRTTTimeoutButtonClicked
+// ==================================
+
+void TimingWidget::slotInitialRTTTimeoutButtonClicked( )
+{ m_initialRTTTimeoutLineEdit->clear( );
+}
+
+// slotInitialRTTTimeoutCheckBoxClicked
+// ====================================
+
+void TimingWidget::slotInitialRTTTimeoutCheckBoxClicked( )
+{ m_initialRTTTimeoutButton->setEnabled( m_initialRTTTimeoutCheckBox->isChecked( ));
+ m_initialRTTTimeoutLineEdit->setEnabled( m_initialRTTTimeoutCheckBox->isChecked( ));
+}
+
+// slotInsaneRadioClicked
+// ======================
+
+void TimingWidget::slotInsaneRadioClicked( )
+{ m_simpleTimingValue = Insane_T5_Timing;
+}
+
+// slotMaxHostGroupButtonClicked
+// =============================
+
+void TimingWidget::slotMaxHostGroupButtonClicked( )
+{ m_maxHostGroupLineEdit->clear( );
+}
+
+// slotMaxHostGroupCheckBoxClicked
+// ===============================
+
+void TimingWidget::slotMaxHostGroupCheckBoxClicked( )
+{ m_maxHostGroupButton->setEnabled( m_maxHostGroupCheckBox->isChecked( ));
+ m_maxHostGroupLineEdit->setEnabled( m_maxHostGroupCheckBox->isChecked( ));
+}
+
+// slotMaxParallelismButtonClicked
+// ===============================
+
+void TimingWidget::slotMaxParallelismButtonClicked( )
+{ m_maxParallelismLineEdit->clear( );
+}
+
+// slotMaxParallelismCheckBoxClicked
+// =================================
+
+void TimingWidget::slotMaxParallelismCheckBoxClicked( )
+{ m_maxParallelismButton->setEnabled( m_maxParallelismCheckBox->isChecked( ));
+ m_maxParallelismLineEdit->setEnabled( m_maxParallelismCheckBox->isChecked( ));
+}
+
+// slotMaxRTTTimeoutButtonClicked
+// ==============================
+
+void TimingWidget::slotMaxRTTTimeoutButtonClicked( )
+{ m_maxRTTTimeoutLineEdit->clear( );
+}
+
+// slotMaxRTTTimeoutCheckBoxClicked
+// ================================
+
+void TimingWidget::slotMaxRTTTimeoutCheckBoxClicked( )
+{ m_maxRTTTimeoutButton->setEnabled( m_maxRTTTimeoutCheckBox->isChecked( ));
+ m_maxRTTTimeoutLineEdit->setEnabled( m_maxRTTTimeoutCheckBox->isChecked( ));
+}
+
+// slotMaxScanDelayButtonClicked
+// =============================
+
+void TimingWidget::slotMaxScanDelayButtonClicked( )
+{ m_maxScanDelayLineEdit->clear( );
+}
+
+// slotMaxScanDelayCheckBoxClicked
+// ===============================
+
+void TimingWidget::slotMaxScanDelayCheckBoxClicked( )
+{ m_maxScanDelayButton->setEnabled( m_maxScanDelayCheckBox->isChecked( ));
+ m_maxScanDelayLineEdit->setEnabled( m_maxScanDelayCheckBox->isChecked( ));
+}
+
+// slotMinHostGroupButtonClicked
+// =============================
+
+void TimingWidget::slotMinHostGroupButtonClicked( )
+{ m_minHostGroupLineEdit->clear( );
+}
+
+// slotMinHostGroupCheckBoxClicked
+// ===============================
+
+void TimingWidget::slotMinHostGroupCheckBoxClicked( )
+{ m_minHostGroupButton->setEnabled( m_minHostGroupCheckBox->isChecked( ));
+ m_minHostGroupLineEdit->setEnabled( m_minHostGroupCheckBox->isChecked( ));
+}
+
+// slotMinParallelismButtonClicked
+// ===============================
+
+void TimingWidget::slotMinParallelismButtonClicked( )
+{ m_minParallelismLineEdit->clear( );
+}
+
+// slotMinParallelismCheckBoxClicked
+// =================================
+
+void TimingWidget::slotMinParallelismCheckBoxClicked( )
+{ m_minParallelismButton->setEnabled( m_minParallelismCheckBox->isChecked( ));
+ m_minParallelismLineEdit->setEnabled( m_minParallelismCheckBox->isChecked( ));
+}
+
+// slotMinRTTTimeoutButtonClicked
+// ==============================
+
+void TimingWidget::slotMinRTTTimeoutButtonClicked( )
+{ m_minRTTTimeoutLineEdit->clear( );
+}
+
+// slotMinRTTTimeoutCheckBoxClicked
+// ================================
+
+void TimingWidget::slotMinRTTTimeoutCheckBoxClicked( )
+{ m_minRTTTimeoutButton->setEnabled( m_minRTTTimeoutCheckBox->isChecked( ));
+ m_minRTTTimeoutLineEdit->setEnabled( m_minRTTTimeoutCheckBox->isChecked( ));
+}
+
+// slotNormalRadioClicked
+// ======================
+
+void TimingWidget::slotNormalRadioClicked( )
+{ m_simpleTimingValue = Normal_T3_Timing;
+}
+
+// slotParanoidRadioClicked
+// ========================
+
+void TimingWidget::slotParanoidRadioClicked( )
+{ m_simpleTimingValue = Paranoid_T0_Timing;
+}
+
+// slotPoliteRadioClicked
+// ======================
+
+void TimingWidget::slotPoliteRadioClicked( )
+{ m_simpleTimingValue = Polite_T2_Timing;
+}
+
+// slotScanDelayButtonClicked
+// ==========================
+
+void TimingWidget::slotScanDelayButtonClicked( )
+{ m_scanDelayLineEdit->clear( );
+}
+
+// slotScanDelayCheckBoxClicked
+// ============================
+
+void TimingWidget::slotScanDelayCheckBoxClicked( )
+{ m_scanDelayButton->setEnabled( m_scanDelayCheckBox->isChecked( ));
+ m_scanDelayLineEdit->setEnabled( m_scanDelayCheckBox->isChecked( ));
+}
+
+// slotSneakyRadioClicked
+// ======================
+
+void TimingWidget::slotSneakyRadioClicked( )
+{ m_simpleTimingValue = Sneaky_T1_Timing;
+}
+
+// slotWhatsThisClicked
+// ====================
+
+void TimingWidget::slotWhatsThisClicked( )
+{ if( m_aggressiveRadio->hasMouse( )) emit( displayHelp( "-T" ));
+ else if( m_defaultRadio->hasMouse( )) emit( displayDocBook( "timing_options" ));
+ else if( m_hostTimeoutButton->hasMouse( )) emit( displayHelp( "--host_timeout" ));
+ else if( m_hostTimeoutCheckBox->hasMouse( )) emit( displayHelp( "--host_timeout" ));
+ else if( m_hostTimeoutLineEdit->hasMouse( )) emit( displayHelp( "--host_timeout" ));
+ else if( m_initialRTTTimeoutButton->hasMouse( )) emit( displayHelp( "--initial_rtt_timeout" ));
+ else if( m_initialRTTTimeoutCheckBox->hasMouse( )) emit( displayHelp( "--initial_rtt_timeout" ));
+ else if( m_initialRTTTimeoutLineEdit->hasMouse( )) emit( displayHelp( "--initial_rtt_timeout" ));
+ else if( m_insaneRadio->hasMouse( )) emit( displayHelp( "-T" ));
+ else if( m_maxHostGroupButton->hasMouse( )) emit( displayHelp( "--max_hostgroup" ));
+ else if( m_maxHostGroupCheckBox->hasMouse( )) emit( displayHelp( "--max_hostgroup" ));
+ else if( m_maxHostGroupLineEdit->hasMouse( )) emit( displayHelp( "--max_hostgroup" ));
+ else if( m_maxParallelismButton->hasMouse( )) emit( displayHelp( "--max_parallelism" ));
+ else if( m_maxParallelismCheckBox->hasMouse( )) emit( displayHelp( "--max_parallelism" ));
+ else if( m_maxParallelismLineEdit->hasMouse( )) emit( displayHelp( "--max_parallelism" ));
+ else if( m_maxRTTTimeoutButton->hasMouse( )) emit( displayHelp( "--max_rtt_timeout" ));
+ else if( m_maxRTTTimeoutCheckBox->hasMouse( )) emit( displayHelp( "--max_rtt_timeout" ));
+ else if( m_maxRTTTimeoutLineEdit->hasMouse( )) emit( displayHelp( "--max_rtt_timeout" ));
+ else if( m_maxScanDelayButton->hasMouse( )) emit( displayHelp( "--max_scan_delay" ));
+ else if( m_maxScanDelayCheckBox->hasMouse( )) emit( displayHelp( "--max_scan_delay" ));
+ else if( m_maxScanDelayLineEdit->hasMouse( )) emit( displayHelp( "--max_scan_delay" ));
+ else if( m_minHostGroupButton->hasMouse( )) emit( displayHelp( "--min_hostgroup" ));
+ else if( m_minHostGroupCheckBox->hasMouse( )) emit( displayHelp( "--min_hostgroup" ));
+ else if( m_minHostGroupLineEdit->hasMouse( )) emit( displayHelp( "--min_hostgroup" ));
+ else if( m_minParallelismButton->hasMouse( )) emit( displayHelp( "--min_parallelism" ));
+ else if( m_minParallelismCheckBox->hasMouse( )) emit( displayHelp( "--min_parallelism" ));
+ else if( m_minParallelismLineEdit->hasMouse( )) emit( displayHelp( "--min_parallelism" ));
+ else if( m_minRTTTimeoutButton->hasMouse( )) emit( displayHelp( "--min_rtt_timeout" ));
+ else if( m_minRTTTimeoutCheckBox->hasMouse( )) emit( displayHelp( "--min_rtt_timeout" ));
+ else if( m_minRTTTimeoutLineEdit->hasMouse( )) emit( displayHelp( "--min_rtt_timeout" ));
+ else if( m_normalRadio->hasMouse( )) emit( displayHelp( "-T" ));
+ else if( m_paranoidRadio->hasMouse( )) emit( displayHelp( "-T" ));
+ else if( m_politeRadio->hasMouse( )) emit( displayHelp( "-T" ));
+ else if( m_scanDelayButton->hasMouse( )) emit( displayHelp( "--scan_delay" ));
+ else if( m_scanDelayCheckBox->hasMouse( )) emit( displayHelp( "--scan_delay" ));
+ else if( m_scanDelayLineEdit->hasMouse( )) emit( displayHelp( "--scan_delay" ));
+ else if( m_sneakyRadio->hasMouse( )) emit( displayHelp( "-T" ));
+ else emit( displayUnknown( ));
+}
diff --git a/src/timingwidget.h b/src/timingwidget.h
new file mode 100644
index 0000000..943404e
--- /dev/null
+++ b/src/timingwidget.h
@@ -0,0 +1,190 @@
+/***************************************************************************
+ * *
+ * Copyright (C) 2005, 2006 by Kevin Gilbert *
+ * kev.gilbert@cdu.edu.au *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ * *
+ ***************************************************************************/
+#ifndef _TIMINGWIDGET_H_
+#define _TIMINGWIDGET_H_
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <qwidget.h>
+#include "global.h"
+
+// forward class definitions
+// =========================
+
+class KConfig;
+class QCheckBox;
+class QLineEdit;
+class QPushButton;
+class QRadioButton;
+
+// TimingWidget class definition
+// =============================
+
+class TimingWidget : public QWidget
+{ Q_OBJECT
+
+ public:
+ TimingWidget( QWidget* parent, const char* name = NULL );
+
+ void finaliseInitialisation( );
+ bool getOptions( );
+ void readProfile( KConfig* config );
+ void saveProfile( KConfig* config );
+ void setInitialValues( );
+ QString simpleTiming( ) const;
+
+ bool hostTimeoutState( ) const { return m_hostTimeoutState; }
+ uint hostTimeoutValue( ) const { return m_hostTimeoutValue; }
+ bool initialRTTTimeoutState( ) const { return m_initialRTTTimeoutState; }
+ uint initialRTTTimeoutValue( ) const { return m_initialRTTTimeoutValue; }
+ bool maxHostGroupState( ) const { return m_maxHostGroupState; }
+ uint maxHostGroupValue( ) const { return m_maxHostGroupValue; }
+ bool maxParallelismState( ) const { return m_maxParallelismState; }
+ uint maxParallelismValue( ) const { return m_maxParallelismValue; }
+ bool maxRTTTimeoutState( ) const { return m_maxRTTTimeoutState; }
+ uint maxRTTTimeoutValue( ) const { return m_maxRTTTimeoutValue; }
+ bool maxScanDelayState( ) const { return m_maxScanDelayState; }
+ uint maxScanDelayValue( ) const { return m_maxScanDelayValue; }
+ bool minHostGroupState( ) const { return m_minHostGroupState; }
+ uint minHostGroupValue( ) const { return m_minHostGroupValue; }
+ bool minParallelismState( ) const { return m_minParallelismState; }
+ uint minParallelismValue( ) const { return m_minParallelismValue; }
+ bool minRTTTimeoutState( ) const { return m_minRTTTimeoutState; }
+ uint minRTTTimeoutValue( ) const { return m_minRTTTimeoutValue; }
+ bool scanDelayState( ) const { return m_scanDelayState; }
+ uint scanDelayValue( ) const { return m_scanDelayValue; }
+
+ signals:
+ void displayDocBook( const QString& );
+ void displayHelp( const QString& );
+ void displayUnknown( );
+ void optionsDirty( );
+
+ private slots:
+ void slotAggressiveRadioClicked( );
+ void slotDefaultRadioClicked( );
+ void slotHostTimeoutButtonClicked( );
+ void slotHostTimeoutCheckBoxClicked( );
+ void slotInitialRTTTimeoutButtonClicked( );
+ void slotInitialRTTTimeoutCheckBoxClicked( );
+ void slotInsaneRadioClicked( );
+ void slotMaxHostGroupButtonClicked( );
+ void slotMaxHostGroupCheckBoxClicked( );
+ void slotMaxParallelismButtonClicked( );
+ void slotMaxParallelismCheckBoxClicked( );
+ void slotMaxRTTTimeoutButtonClicked( );
+ void slotMaxRTTTimeoutCheckBoxClicked( );
+ void slotMaxScanDelayButtonClicked( );
+ void slotMaxScanDelayCheckBoxClicked( );
+ void slotMinHostGroupButtonClicked( );
+ void slotMinHostGroupCheckBoxClicked( );
+ void slotMinParallelismButtonClicked( );
+ void slotMinParallelismCheckBoxClicked( );
+ void slotMinRTTTimeoutButtonClicked( );
+ void slotMinRTTTimeoutCheckBoxClicked( );
+ void slotNormalRadioClicked( );
+ void slotParanoidRadioClicked( );
+ void slotPoliteRadioClicked( );
+ void slotScanDelayButtonClicked( );
+ void slotScanDelayCheckBoxClicked( );
+ void slotSneakyRadioClicked( );
+ void slotWhatsThisClicked( );
+
+ private:
+ void createLayout( );
+
+ // simple timing indices
+ // =====================
+
+ enum Timing
+ { Default_Timing,
+ Aggressive_T4_Timing,
+ Insane_T5_Timing,
+ Normal_T3_Timing,
+ Paranoid_T0_Timing,
+ Polite_T2_Timing,
+ Sneaky_T1_Timing
+ };
+
+ QRadioButton* m_aggressiveRadio;
+ QRadioButton* m_defaultRadio;
+ QPushButton* m_hostTimeoutButton;
+ QCheckBox* m_hostTimeoutCheckBox;
+ QLineEdit* m_hostTimeoutLineEdit;
+ bool m_hostTimeoutState;
+ uint m_hostTimeoutValue;
+ QPushButton* m_initialRTTTimeoutButton;
+ QCheckBox* m_initialRTTTimeoutCheckBox;
+ QLineEdit* m_initialRTTTimeoutLineEdit;
+ bool m_initialRTTTimeoutState;
+ uint m_initialRTTTimeoutValue;
+ QRadioButton* m_insaneRadio;
+ QPushButton* m_maxHostGroupButton;
+ QCheckBox* m_maxHostGroupCheckBox;
+ QLineEdit* m_maxHostGroupLineEdit;
+ bool m_maxHostGroupState;
+ uint m_maxHostGroupValue;
+ QPushButton* m_maxParallelismButton;
+ QCheckBox* m_maxParallelismCheckBox;
+ QLineEdit* m_maxParallelismLineEdit;
+ bool m_maxParallelismState;
+ uint m_maxParallelismValue;
+ QPushButton* m_maxRTTTimeoutButton;
+ QCheckBox* m_maxRTTTimeoutCheckBox;
+ QLineEdit* m_maxRTTTimeoutLineEdit;
+ bool m_maxRTTTimeoutState;
+ uint m_maxRTTTimeoutValue;
+ QPushButton* m_maxScanDelayButton;
+ QCheckBox* m_maxScanDelayCheckBox;
+ QLineEdit* m_maxScanDelayLineEdit;
+ bool m_maxScanDelayState;
+ uint m_maxScanDelayValue;
+ QPushButton* m_minHostGroupButton;
+ QCheckBox* m_minHostGroupCheckBox;
+ QLineEdit* m_minHostGroupLineEdit;
+ bool m_minHostGroupState;
+ uint m_minHostGroupValue;
+ QPushButton* m_minParallelismButton;
+ QCheckBox* m_minParallelismCheckBox;
+ QLineEdit* m_minParallelismLineEdit;
+ bool m_minParallelismState;
+ uint m_minParallelismValue;
+ QPushButton* m_minRTTTimeoutButton;
+ QCheckBox* m_minRTTTimeoutCheckBox;
+ QLineEdit* m_minRTTTimeoutLineEdit;
+ bool m_minRTTTimeoutState;
+ uint m_minRTTTimeoutValue;
+ QRadioButton* m_normalRadio;
+ QRadioButton* m_paranoidRadio;
+ QRadioButton* m_politeRadio;
+ QPushButton* m_scanDelayButton;
+ QCheckBox* m_scanDelayCheckBox;
+ QLineEdit* m_scanDelayLineEdit;
+ bool m_scanDelayState;
+ uint m_scanDelayValue;
+ Timing m_simpleTimingValue;
+ QRadioButton* m_sneakyRadio;
+};
+
+#endif // _TIMINGWIDGET_H_
diff --git a/src/whatsthis.cpp b/src/whatsthis.cpp
new file mode 100644
index 0000000..5369a6b
--- /dev/null
+++ b/src/whatsthis.cpp
@@ -0,0 +1,42 @@
+/***************************************************************************
+ * *
+ * Copyright (C) 2005, 2006 by Kevin Gilbert *
+ * kev.gilbert@cdu.edu.au *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ * *
+ ***************************************************************************/
+
+#include <kdebug.h>
+#include <klocale.h>
+
+#include "whatsthis.h"
+
+// constructor
+// ===========
+
+WhatsThis::WhatsThis( QWidget* widget )
+: QWhatsThis( widget )
+{
+}
+
+// text
+// ====
+
+QString WhatsThis::text( const QPoint& /*pos */)
+{ emit( clicked( ));
+ return "";
+}
diff --git a/src/whatsthis.h b/src/whatsthis.h
new file mode 100644
index 0000000..37479a0
--- /dev/null
+++ b/src/whatsthis.h
@@ -0,0 +1,53 @@
+/***************************************************************************
+ * *
+ * Copyright (C) 2005, 2006 by Kevin Gilbert *
+ * kev.gilbert@cdu.edu.au *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ * *
+ ***************************************************************************/
+
+#ifndef _WHATSTHIS_H_
+#define _WHATSTHIS_H_
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <qobject.h>
+#include <qwhatsthis.h>
+#include "global.h"
+
+// forward class definitions
+// =========================
+
+class QPoint;
+
+// WhatsThis class definition
+// ==========================
+
+class WhatsThis : public QObject, public QWhatsThis
+{ Q_OBJECT
+
+ public:
+ WhatsThis( QWidget* widget );
+ QString text( const QPoint& pos );
+
+ signals:
+ void clicked( );
+};
+
+#endif // _WHATSTHIS_H_