1
/***************************************************************************
3
* Copyright (C) 2005, 2006 by Kevin Gilbert *
4
* kev.gilbert@cdu.edu.au *
6
* This program is free software; you can redistribute it and/or modify *
7
* it under the terms of the GNU General Public License as published by *
8
* the Free Software Foundation; either version 2 of the License, or *
9
* (at your option) any later version. *
11
* This program is distributed in the hope that it will be useful, *
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14
* GNU General Public License for more details. *
16
* You should have received a copy of the GNU General Public License *
17
* along with this program; if not, write to the *
18
* Free Software Foundation, Inc., *
19
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
21
***************************************************************************/
23
#include <qcheckbox.h>
26
#include <qlineedit.h>
32
#include <kmessagebox.h>
34
#include "pandsoptions.h"
35
#include "whatsthis.h"
40
PAndSOptions::PAndSOptions( QWidget* parent, const char* name )
41
: QWidget( parent, name )
48
void PAndSOptions::createLayout( )
49
{ QGridLayout* gridLayout = new QGridLayout( this );
51
m_ackCheckBox = new QCheckBox( i18n( "TCP ACK (-PA)" ), this, "ack check" );
52
m_ackLineEdit = new QLineEdit( this, "ack edit" );
53
m_arpCheckBox = new QCheckBox( i18n( "ARP (-PR)" ), this, "arp check" );
54
m_dontPingCheckBox = new QCheckBox( i18n( "Don't ping (-P0)" ), this, "dont ping check" );
55
m_echoCheckBox = new QCheckBox( i18n( "ICMP echo (-PE)" ), this, "icmp echo check" );
56
m_netmaskCheckBox = new QCheckBox( i18n( "ICMP netmask (-PM)" ), this, "icmp netmask check" );
57
m_synCheckBox = new QCheckBox( i18n( "TCP SYN (-PS)" ), this, "syn check" );
58
m_synLineEdit = new QLineEdit( this, "syn edit" );
59
m_timestampCheckBox = new QCheckBox( i18n( "ICMP timestamp (-PP)" ), this, "icmp timestamp check" );
62
gridLayout->addWidget( new QLabel( " ", this ), row, 1 );
63
gridLayout->addWidget( m_ackCheckBox, row++, 3 );
64
gridLayout->addWidget( new QLabel( " ", this ), row, 1 );
65
gridLayout->addWidget( m_ackLineEdit, row++, 3 );
66
gridLayout->addWidget( new QLabel( "#", this ), row, 1 );
67
gridLayout->addWidget( m_arpCheckBox, row++, 3 );
68
gridLayout->addWidget( new QLabel( " ", this ), row, 1 );
69
gridLayout->addWidget( m_dontPingCheckBox, row++, 3 );
70
gridLayout->addWidget( new QLabel( "#", this ), row, 1 );
71
gridLayout->addWidget( m_echoCheckBox, row++, 3 );
75
gridLayout->addWidget( new QLabel( " ", this ), row, 5 );
76
gridLayout->addWidget( m_netmaskCheckBox, row++, 7 );
77
gridLayout->addWidget( new QLabel( " ", this ), row, 5 );
78
gridLayout->addWidget( m_synCheckBox, row++, 7 );
79
gridLayout->addWidget( new QLabel( " ", this ), row, 5 );
80
gridLayout->addWidget( m_synLineEdit, row++, 7 );
81
gridLayout->addWidget( new QLabel( "#", this ), row, 5 );
82
gridLayout->addWidget( m_timestampCheckBox, row++, 7 );
85
m_scanFTPBounceCheckBox = new QCheckBox( i18n( "FTP Bounce (-b)" ), this, "ftp bounce scan check" );
86
m_scanFTPRelayLineEdit = new QLineEdit( this, "ftp relay edit" );
87
m_scanIdleCheckBox = new QCheckBox( i18n( "Idle (-sI)" ), this, "idle scan check" );
88
m_scanListCheckBox = new QCheckBox( i18n( "List Scan (-sL)" ), this, "list scan check" );
89
m_scanNullCheckBox = new QCheckBox( i18n( "Null Scan (-sN)" ), this, "null scan check" );
90
m_scanPingCheckBox = new QCheckBox( i18n( "Ping Scan (-sP)" ), this, "ping scan check" );
91
m_scanProtocolCheckBox = new QCheckBox( i18n( "Protocol Scan (-sO)" ), this, "protocol scan check" );
92
m_scanRPCCheckBox = new QCheckBox( i18n( "RPC (-sR)" ), this, "rpc scan check" );
93
m_scanFINCheckBox = new QCheckBox( i18n( "Stealth FIN (-sF)" ), this, "fin scan check" );
94
m_scanAckCheckBox = new QCheckBox( i18n( "TCP Ack Scan (-sA)" ), this, "ack scan check" );
95
m_scanSYNCheckBox = new QCheckBox( i18n( "TCP SYN (-sS)" ), this, "syn scan check" );
96
m_scanTCPConnectCheckBox = new QCheckBox( i18n( "TCP Connect (-sT)" ), this, "connect scan check" );
97
m_scanUDPCheckBox = new QCheckBox( i18n( "UDP Scan (-sU)" ), this, "udp scan check" );
98
m_scanVersionCheckBox = new QCheckBox( i18n( "Version Detection (-sV)" ), this, "version scan check" );
99
m_scanWindowCheckBox = new QCheckBox( i18n( "Window Scan (-sW)" ), this, "window scan check" );
100
m_scanXmasCheckBox = new QCheckBox( i18n( "Xmas Tree (-sX)" ), this, "xmas scan check" );
101
m_zombieLineEdit = new QLineEdit( this, "zombie edit" );
104
gridLayout->addWidget( new QLabel( " ", this ), row, 9 );
105
gridLayout->addWidget( m_scanFTPBounceCheckBox, row++, 11 );
106
gridLayout->addWidget( new QLabel( " ", this ), row, 9 );
107
gridLayout->addWidget( m_scanFTPRelayLineEdit, row++, 11 );
108
gridLayout->addWidget( new QLabel( "#", this ), row, 9 );
109
gridLayout->addWidget( m_scanIdleCheckBox, row++, 11 );
110
gridLayout->addWidget( new QLabel( " ", this ), row, 9 );
111
gridLayout->addWidget( m_zombieLineEdit, row++, 11 );
112
gridLayout->addWidget( new QLabel( " ", this ), row, 9 );
113
gridLayout->addWidget( m_scanListCheckBox, row++, 11 );
114
gridLayout->addWidget( new QLabel( "#", this ), row, 9 );
115
gridLayout->addWidget( m_scanNullCheckBox, row++, 11 );
116
byte rowBlock3 = row;
119
gridLayout->addWidget( new QLabel( " ", this ), row, 13 );
120
gridLayout->addWidget( m_scanPingCheckBox, row++, 15 );
121
gridLayout->addWidget( new QLabel( "#", this ), row, 13 );
122
gridLayout->addWidget( m_scanProtocolCheckBox, row++, 15 );
123
gridLayout->addWidget( new QLabel( " ", this ), row, 13 );
124
gridLayout->addWidget( m_scanRPCCheckBox, row++, 15 );
125
gridLayout->addWidget( new QLabel( "#", this ), row, 13 );
126
gridLayout->addWidget( m_scanFINCheckBox, row++, 15 );
127
gridLayout->addWidget( new QLabel( "#", this ), row, 13 );
128
gridLayout->addWidget( m_scanAckCheckBox, row++, 15 );
129
gridLayout->addWidget( new QLabel( "#", this ), row, 13 );
130
gridLayout->addWidget( m_scanSYNCheckBox, row++, 15 );
131
byte rowBlock4 = row;
134
gridLayout->addWidget( new QLabel( " ", this ), row, 17 );
135
gridLayout->addWidget( m_scanTCPConnectCheckBox, row++, 19 );
136
gridLayout->addWidget( new QLabel( "#", this ), row, 17 );
137
gridLayout->addWidget( m_scanUDPCheckBox, row++, 19 );
138
gridLayout->addWidget( new QLabel( " ", this ), row, 17 );
139
gridLayout->addWidget( m_scanVersionCheckBox, row++, 19 );
140
gridLayout->addWidget( new QLabel( "#", this ), row, 17 );
141
gridLayout->addWidget( m_scanWindowCheckBox, row++, 19 );
142
gridLayout->addWidget( new QLabel( "#", this ), row, 17 );
143
gridLayout->addWidget( m_scanXmasCheckBox, row++, 19 );
144
byte rowBlock5 = row;
146
gridLayout->setColStretch( 0, 5 );
147
gridLayout->setColStretch( 2, 1 );
148
gridLayout->setColStretch( 3, 20 );
149
gridLayout->setColStretch( 4, 5 );
150
gridLayout->setColStretch( 6, 1 );
151
gridLayout->setColStretch( 7, 20 );
152
gridLayout->setColStretch( 8, 5 );
153
gridLayout->setColStretch( 10, 1 );
154
gridLayout->setColStretch( 11, 20 );
155
gridLayout->setColStretch( 12, 5 );
156
gridLayout->setColStretch( 14, 1 );
157
gridLayout->setColStretch( 15, 20 );
158
gridLayout->setColStretch( 16, 5 );
159
gridLayout->setColStretch( 18, 1 );
160
gridLayout->setColStretch( 19, 20 );
161
gridLayout->setColStretch( 20, 5 );
163
gridLayout->setRowStretch( 0, 10 );
164
gridLayout->setRowStretch( _max_( rowBlock1, _max_( rowBlock2, _max_( rowBlock3, _max_( rowBlock4, rowBlock5 )))), 10 );
167
// finaliseInitialisation
168
// ======================
170
void PAndSOptions::finaliseInitialisation( )
171
{ WhatsThis* whatsThis = new WhatsThis( this );
173
connect( m_ackCheckBox, SIGNAL( clicked( )), SLOT( slotAckClicked( )));
174
connect( m_scanFTPBounceCheckBox, SIGNAL( clicked( )), SLOT( slotScanFTPBounceCheckBoxClicked( )));
175
connect( m_scanIdleCheckBox, SIGNAL( clicked( )), SLOT( slotScanIdleCheckBoxClicked( )));
176
connect( m_synCheckBox, SIGNAL( clicked( )), SLOT( slotSynClicked( )));
177
connect( whatsThis, SIGNAL( clicked( )), SLOT( slotWhatsThisClicked( )));
179
connect( m_ackCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
180
connect( m_ackLineEdit, SIGNAL( textChanged ( const QString& )), SIGNAL( optionsDirty( )));
181
connect( m_arpCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
182
connect( m_dontPingCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
183
connect( m_echoCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
184
connect( m_netmaskCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
185
connect( m_scanAckCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
186
connect( m_scanFINCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
187
connect( m_scanFTPBounceCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
188
connect( m_scanFTPRelayLineEdit, SIGNAL( textChanged ( const QString& )), SIGNAL( optionsDirty( )));
189
connect( m_scanIdleCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
190
connect( m_scanListCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
191
connect( m_scanNullCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
192
connect( m_scanPingCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
193
connect( m_scanProtocolCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
194
connect( m_scanRPCCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
195
connect( m_scanSYNCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
196
connect( m_scanTCPConnectCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
197
connect( m_scanUDPCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
198
connect( m_scanVersionCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
199
connect( m_scanWindowCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
200
connect( m_scanXmasCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
201
connect( m_synCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
202
connect( m_synLineEdit, SIGNAL( textChanged ( const QString& )), SIGNAL( optionsDirty( )));
203
connect( m_timestampCheckBox, SIGNAL( clicked( )), SIGNAL( optionsDirty( )));
204
connect( m_zombieLineEdit, SIGNAL( textChanged ( const QString& )), SIGNAL( optionsDirty( )));
210
bool PAndSOptions::getOptions( bool& needRoot )
211
{ m_ackState = m_ackCheckBox->isChecked( );
212
m_ackValue = m_ackLineEdit->text( );
213
m_arpState = m_arpCheckBox->isChecked( );
214
m_dontPingState = m_dontPingCheckBox->isChecked( );
215
m_echoState = m_echoCheckBox->isChecked( );
216
m_netmaskState = m_netmaskCheckBox->isChecked( );
217
m_scanAckState = m_scanAckCheckBox->isChecked( );
218
m_scanFINState = m_scanFINCheckBox->isChecked( );
219
m_scanFTPBounceState = m_scanFTPBounceCheckBox->isChecked( );
220
m_scanFTPRelayHost = m_scanFTPRelayLineEdit->text( );
221
m_scanIdleState = m_scanIdleCheckBox->isChecked( );
222
m_scanListState = m_scanListCheckBox->isChecked( );
223
m_scanNullState = m_scanNullCheckBox->isChecked( );
224
m_scanPingState = m_scanPingCheckBox->isChecked( );
225
m_scanProtocolState = m_scanProtocolCheckBox->isChecked( );
226
m_scanRPCState = m_scanRPCCheckBox->isChecked( );
227
m_scanSYNState = m_scanSYNCheckBox->isChecked( );
228
m_scanTCPConnectState = m_scanTCPConnectCheckBox->isChecked( );
229
m_scanUDPState = m_scanUDPCheckBox->isChecked( );
230
m_scanVersionState = m_scanVersionCheckBox->isChecked( );
231
m_scanWindowState = m_scanWindowCheckBox->isChecked( );
232
m_scanXmasState = m_scanXmasCheckBox->isChecked( );
233
m_synState = m_synCheckBox->isChecked( );
234
m_synValue = m_synLineEdit->text( );
235
m_timestampState = m_timestampCheckBox->isChecked( );
236
m_zombieDetails = m_zombieLineEdit->text( );
238
needRoot = needRoot ||
245
m_scanProtocolState ||
258
void PAndSOptions::readProfile( KConfig* config )
259
{ m_ackState = config->readBoolEntry( "ackState" );
260
m_ackValue = config->readEntry( "ackValue" );
261
m_arpState = config->readBoolEntry( "arpState" );
262
m_dontPingState = config->readBoolEntry( "dontPingState" );
263
m_echoState = config->readBoolEntry( "echoState" );
264
m_netmaskState = config->readBoolEntry( "netmaskState" );
265
m_scanAckState = config->readBoolEntry( "scanAckState" );
266
m_scanFINState = config->readBoolEntry( "scanFINState" );
267
m_scanFTPBounceState = config->readBoolEntry( "scanFTPBounceState" );
268
m_scanFTPRelayHost = config->readEntry( "scanFTPRelayHost" );
269
m_scanIdleState = config->readBoolEntry( "scanIdleState" );
270
m_scanListState = config->readBoolEntry( "scanListState" );
271
m_scanNullState = config->readBoolEntry( "scanNullState" );
272
m_scanPingState = config->readBoolEntry( "scanPingState" );
273
m_scanProtocolState = config->readBoolEntry( "scanProtocolState" );
274
m_scanRPCState = config->readBoolEntry( "scanRPCState" );
275
m_scanSYNState = config->readBoolEntry( "scanSYNState" );
276
m_scanTCPConnectState = config->readBoolEntry( "scanTCPConnectState" );
277
m_scanUDPState = config->readBoolEntry( "scanUDPState" );
278
m_scanVersionState = config->readBoolEntry( "scanVersionState" );
279
m_scanWindowState = config->readBoolEntry( "scanWindowState" );
280
m_scanXmasState = config->readBoolEntry( "scanXmasState" );
281
m_synState = config->readBoolEntry( "synState" );
282
m_synValue = config->readEntry( "synValue" );
283
m_timestampState = config->readBoolEntry( "timestampState" );
284
m_zombieDetails = config->readEntry( "zombieDetails" );
290
void PAndSOptions::saveProfile( KConfig* config )
291
{ config->writeEntry( "ackState", m_ackState );
292
config->writeEntry( "ackValue", m_ackValue );
293
config->writeEntry( "arpState", m_arpState );
294
config->writeEntry( "dontPingState", m_dontPingState );
295
config->writeEntry( "echoState", m_echoState );
296
config->writeEntry( "netmaskState", m_netmaskState );
297
config->writeEntry( "scanAckState", m_scanAckState );
298
config->writeEntry( "scanFINState", m_scanFINState );
299
config->writeEntry( "scanFTPBounceState", m_scanFTPBounceState );
300
config->writeEntry( "scanFTPRelayHost", m_scanFTPRelayHost );
301
config->writeEntry( "scanIdleState", m_scanIdleState );
302
config->writeEntry( "scanListState", m_scanListState );
303
config->writeEntry( "scanNullState", m_scanNullState );
304
config->writeEntry( "scanPingState", m_scanPingState );
305
config->writeEntry( "scanProtocolState", m_scanProtocolState );
306
config->writeEntry( "scanRPCState", m_scanRPCState );
307
config->writeEntry( "scanSYNState", m_scanSYNState );
308
config->writeEntry( "scanTCPConnectState", m_scanTCPConnectState );
309
config->writeEntry( "scanUDPState", m_scanUDPState );
310
config->writeEntry( "scanVersionState", m_scanVersionState );
311
config->writeEntry( "scanWindowState", m_scanWindowState );
312
config->writeEntry( "scanXmasState", m_scanXmasState );
313
config->writeEntry( "synState", m_synState );
314
config->writeEntry( "synValue", m_synValue );
315
config->writeEntry( "timestampState", m_timestampState );
316
config->writeEntry( "zombieDetails", m_zombieDetails );
322
void PAndSOptions::setInitialValues( )
323
{ m_ackCheckBox->setChecked( m_ackState );
324
m_ackLineEdit->setText( m_ackValue );
325
m_arpCheckBox->setChecked( m_arpState );
326
m_dontPingCheckBox->setChecked( m_dontPingState );
327
m_echoCheckBox->setChecked( m_echoState );
328
m_netmaskCheckBox->setChecked( m_netmaskState );
329
m_scanAckCheckBox->setChecked( m_scanAckState );
330
m_scanFINCheckBox->setChecked( m_scanFINState );
331
m_scanFTPBounceCheckBox->setChecked( m_scanFTPBounceState );
332
m_scanFTPRelayLineEdit->setText( m_scanFTPRelayHost );
333
m_scanIdleCheckBox->setChecked( m_scanIdleState );
334
m_scanListCheckBox->setChecked( m_scanListState );
335
m_scanNullCheckBox->setChecked( m_scanNullState );
336
m_scanPingCheckBox->setChecked( m_scanPingState );
337
m_scanProtocolCheckBox->setChecked( m_scanProtocolState );
338
m_scanRPCCheckBox->setChecked( m_scanRPCState );
339
m_scanSYNCheckBox->setChecked( m_scanSYNState );
340
m_scanTCPConnectCheckBox->setChecked( m_scanTCPConnectState );
341
m_scanUDPCheckBox->setChecked( m_scanUDPState );
342
m_scanVersionCheckBox->setChecked( m_scanVersionState );
343
m_scanWindowCheckBox->setChecked( m_scanWindowState );
344
m_scanXmasCheckBox->setChecked( m_scanXmasState );
345
m_synCheckBox->setChecked( m_synState );
346
m_synLineEdit->setText( m_synValue );
347
m_timestampCheckBox->setChecked( m_timestampState );
348
m_zombieLineEdit->setText( m_zombieDetails );
351
slotScanFTPBounceCheckBoxClicked( );
352
slotScanIdleCheckBoxClicked( );
359
void PAndSOptions::slotAckClicked( )
360
{ m_ackLineEdit->setEnabled( m_ackCheckBox->isChecked( ));
363
// slotScanFTPBounceCheckBoxClicked
364
// ================================
366
void PAndSOptions::slotScanFTPBounceCheckBoxClicked( )
367
{ m_scanFTPRelayLineEdit->setEnabled( m_scanFTPBounceCheckBox->isChecked( ));
370
// slotScanIdleCheckBoxClicked
371
// ===========================
373
void PAndSOptions::slotScanIdleCheckBoxClicked( )
374
{ m_zombieLineEdit->setEnabled( m_scanIdleCheckBox->isChecked( ));
380
void PAndSOptions::slotSynClicked( )
381
{ m_synLineEdit->setEnabled( m_synCheckBox->isChecked( ));
384
// slotWhatsThisClicked
385
// ====================
387
void PAndSOptions::slotWhatsThisClicked( )
388
{ if( m_ackCheckBox->hasMouse( )) emit( displayHelp( "-PA" ));
389
else if( m_ackLineEdit->hasMouse( )) emit( displayHelp( "-PA" ));
390
else if( m_arpCheckBox->hasMouse( )) emit( displayHelp( "-PR" ));
391
else if( m_dontPingCheckBox->hasMouse( )) emit( displayHelp( "-P0" ));
392
else if( m_echoCheckBox->hasMouse( )) emit( displayHelp( "-PE" ));
393
else if( m_netmaskCheckBox->hasMouse( )) emit( displayHelp( "-PM" ));
394
else if( m_scanAckCheckBox->hasMouse( )) emit( displayHelp( "-sA" ));
395
else if( m_scanFINCheckBox->hasMouse( )) emit( displayHelp( "-sF" ));
396
else if( m_scanFTPBounceCheckBox->hasMouse( )) emit( displayHelp( "-b" ));
397
else if( m_scanFTPRelayLineEdit->hasMouse( )) emit( displayHelp( "-b" ));
398
else if( m_scanIdleCheckBox->hasMouse( )) emit( displayHelp( "-sI" ));
399
else if( m_zombieLineEdit->hasMouse( )) emit( displayHelp( "-sI" ));
400
else if( m_scanListCheckBox->hasMouse( )) emit( displayHelp( "-sL" ));
401
else if( m_scanNullCheckBox->hasMouse( )) emit( displayHelp( "-sN" ));
402
else if( m_scanPingCheckBox->hasMouse( )) emit( displayHelp( "-sP" ));
403
else if( m_scanProtocolCheckBox->hasMouse( )) emit( displayHelp( "-sO" ));
404
else if( m_scanRPCCheckBox->hasMouse( )) emit( displayHelp( "-sR" ));
405
else if( m_scanTCPConnectCheckBox->hasMouse( )) emit( displayHelp( "-sT" ));
406
else if( m_scanUDPCheckBox->hasMouse( )) emit( displayHelp( "-sU" ));
407
else if( m_scanVersionCheckBox->hasMouse( )) emit( displayHelp( "-sV" ));
408
else if( m_scanWindowCheckBox->hasMouse( )) emit( displayHelp( "-sW" ));
409
else if( m_scanSYNCheckBox->hasMouse( )) emit( displayHelp( "-sS" ));
410
else if( m_scanXmasCheckBox->hasMouse( )) emit( displayHelp( "-sX" ));
411
else if( m_synCheckBox->hasMouse( )) emit( displayHelp( "-PS" ));
412
else if( m_synLineEdit->hasMouse( )) emit( displayHelp( "-PS" ));
413
else if( m_timestampCheckBox->hasMouse( )) emit( displayHelp( "-PP" ));
414
else emit( displayUnknown( ));