summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2003-04-10 22:23:47 (UTC)
committer mickeyl <mickeyl>2003-04-10 22:23:47 (UTC)
commitd5df2032280242a44c44e3e6e875361756587cd6 (patch) (side-by-side diff)
tree1724a36362a85a79b87d57d8628011af4a8446ed
parent7be68c0e03961ef8da0e0fa9683ab83770b41d62 (diff)
downloadopie-d5df2032280242a44c44e3e6e875361756587cd6.zip
opie-d5df2032280242a44c44e3e6e875361756587cd6.tar.gz
opie-d5df2032280242a44c44e3e6e875361756587cd6.tar.bz2
add sanity (non-root & dhcp running) checks for startup phase
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/main.cpp59
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.cpp13
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiterbase.cpp2
3 files changed, 72 insertions, 2 deletions
diff --git a/noncore/net/wellenreiter/gui/main.cpp b/noncore/net/wellenreiter/gui/main.cpp
index 8d4ef57..03da135 100644
--- a/noncore/net/wellenreiter/gui/main.cpp
+++ b/noncore/net/wellenreiter/gui/main.cpp
@@ -1,40 +1,99 @@
/**********************************************************************
** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved.
**
** This file is part of Opie Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
**********************************************************************/
#include "mainwindow.h"
#ifdef QWS
#include <opie2/oapplication.h>
#else
#include <qapplication.h>
#endif
+#include <qmessagebox.h>
+#include <qstringlist.h>
+
+// ==> OProcess
+#include <qdir.h>
+#include <qfileinfo.h>
+#include <qregexp.h>
+#include <qtextstream.h>
+
+#include <errno.h>
+#include <signal.h>
+#include <string.h>
+#include <unistd.h>
+
int main( int argc, char **argv )
{
#ifdef QWS
OApplication a( argc, argv, "Wellenreiter II" );
#else
QApplication a( argc, argv );
#endif
WellenreiterMainWindow* w = new WellenreiterMainWindow();
#ifdef QWS
a.showMainWidget( w );
#else
a.setMainWidget( w );
w->show();
#endif
+
+ a.processEvents(); // show the window before doing the safety checks
+ int result = -1;
+
+ // root check
+ if ( getuid() )
+ {
+ qWarning( "Wellenreiter: trying to run as non-root!" );
+ result = QMessageBox::warning( w, " - Wellenreiter II - (non-root)", "You have started Wellenreiter II\n"
+ "as non-root. You will have\nonly limited functionality.\nProceed anyway?",
+ QMessageBox::Yes, QMessageBox::No );
+ if ( result == QMessageBox::No ) return -1;
+ }
+
+ // dhcp check - NOT HERE! This really belongs as a static member to OProcess
+ // and I want to call it like that: if ( OProcess::isRunning( QString& ) ) ...
+
+ QString line;
+ QDir d = QDir( "/proc" );
+ QStringList dirs = d.entryList( QDir::Dirs );
+ QStringList::Iterator it;
+ for ( it = dirs.begin(); it != dirs.end(); ++it )
+ {
+ //qDebug( "next entry: %s", (const char*) *it );
+ QFile file( "/proc/"+*it+"/cmdline" );
+ file.open( IO_ReadOnly );
+ if ( !file.isOpen() ) continue;
+ QTextStream t( &file );
+ line = t.readLine();
+ //qDebug( "cmdline = %s", (const char*) line );
+ if ( line.contains( "dhcp" ) ) break;
+ }
+ if ( line.contains( "dhcp" ) )
+ {
+ qWarning( "Wellenreiter: found dhcp process #%d", (*it).toInt() );
+ result = QMessageBox::warning( w, " - Wellenreiter II - (dhcp)", "You have a dhcp client running.\n"
+ "This can severly limit scanning!\nShould I kill it for you?",
+ QMessageBox::Yes, QMessageBox::No );
+ if ( result == QMessageBox::Yes )
+ {
+ if ( -1 == ::kill( (*it).toInt(), SIGTERM ) )
+ qWarning( "Wellenreiter: can't kill process (%s)", result, strerror( errno ) );
+ }
+ }
+
a.exec();
delete w;
return 0;
}
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp
index be2a86e..b4b6aa3 100644
--- a/noncore/net/wellenreiter/gui/wellenreiter.cpp
+++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp
@@ -14,48 +14,49 @@
***********************************************************************/
// Opie
#ifdef QWS
#include <opie/odevice.h>
using namespace Opie;
#endif
#ifdef QWS
#include <opie2/oapplication.h>
#else
#include <qapplication.h>
#endif
#include <opie2/onetwork.h>
#include <opie2/opcap.h>
// Qt
#include <qcheckbox.h>
#include <qcombobox.h>
#include <qpushbutton.h>
#include <qlineedit.h>
#include <qmessagebox.h>
+#include <qregexp.h>
#include <qspinbox.h>
#include <qtoolbutton.h>
#include <qmainwindow.h>
// Standard
#include <assert.h>
#include <errno.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <stdlib.h>
// Local
#include "wellenreiter.h"
#include "scanlist.h"
#include "logwindow.h"
#include "hexwindow.h"
#include "configwindow.h"
#include "statwindow.h"
#include "manufacturers.h"
Wellenreiter::Wellenreiter( QWidget* parent )
@@ -304,75 +305,85 @@ void Wellenreiter::startClicked()
case DEVTYPE_HOSTAP: iface->setMonitoring( new OHostAPMonitoringInterface( iface ) ); break;
case DEVTYPE_ORINOCO: iface->setMonitoring( new OOrinocoMonitoringInterface( iface ) ); break;
case DEVTYPE_MANUAL: QMessageBox::information( this, "Wellenreiter II", "Bring your device into\nmonitor mode now." ); break;
case DEVTYPE_FILE: qDebug( "Wellenreiter: Capturing from file '%s'", (const char*) interface ); break;
default: assert( 0 ); // shouldn't reach this
}
// switch device into monitor mode
if ( cardtype < DEVTYPE_FILE )
{
if ( cardtype != DEVTYPE_MANUAL )
iface->setMonitorMode( true );
if ( !iface->monitorMode() )
{
QMessageBox::warning( this, "Wellenreiter II", "Can't set device into monitor mode." );
return;
}
}
// open pcap and start sniffing
if ( cardtype != DEVTYPE_FILE )
{
if ( configwindow->writeCaptureFile->isEnabled() )
{
- pcap->open( interface, configwindow->captureFileName->text() );
+ QString dumpname( configwindow->captureFileName->text() );
+ dumpname.append( '-' );
+ dumpname.append( QTime::currentTime().toString().replace( QRegExp( ":" ), "-" ) );
+ dumpname.append( ".wellenreiter" );
+ pcap->open( interface, dumpname );
}
else
{
pcap->open( interface );
}
}
else
{
pcap->open( QFile( interface ) );
}
if ( !pcap->isOpen() )
{
QMessageBox::warning( this, "Wellenreiter II", "Can't open packet capturer:\n" + QString(strerror( errno ) ));
return;
}
// set capturer to non-blocking mode
pcap->setBlocking( false );
// start channel hopper
if ( cardtype != DEVTYPE_FILE )
iface->setChannelHopping( 1000 ); //use interval from config window
if ( cardtype != DEVTYPE_FILE )
{
// connect socket notifier and start channel hopper
connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) );
connect( iface->channelHopper(), SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) );
}
else
{
// start timer for reading packets
startTimer( 100 );
}
logwindow->log( "(i) Started Scanning." );
sniffing = true;
emit( startedSniffing() );
+ if ( cardtype != DEVTYPE_FILE ) channelHopped( 6 ); // set title
+ else
+ {
+ assert( parent() );
+ ( (QMainWindow*) parent() )->setCaption( "Wellenreiter II - replaying capture file..." );
+ }
}
void Wellenreiter::timerEvent( QTimerEvent* )
{
qDebug( "Wellenreiter::timerEvent()" );
OPacket* p = pcap->next();
receivePacket( p );
delete p;
}
diff --git a/noncore/net/wellenreiter/gui/wellenreiterbase.cpp b/noncore/net/wellenreiter/gui/wellenreiterbase.cpp
index 245b9fc..9745069 100644
--- a/noncore/net/wellenreiter/gui/wellenreiterbase.cpp
+++ b/noncore/net/wellenreiter/gui/wellenreiterbase.cpp
@@ -110,49 +110,49 @@ WellenreiterBase::WellenreiterBase( QWidget* parent, const char* name, WFlags f
PixmapLabel1_3_2->setAlignment( int( QLabel::AlignCenter ) );
aboutLayout->addWidget( PixmapLabel1_3_2, 0, 0 );
TextLabel1_4_2 = new QLabel( about, "TextLabel1_4_2" );
QFont TextLabel1_4_2_font( TextLabel1_4_2->font() );
TextLabel1_4_2_font.setFamily( "adobe-helvetica" );
TextLabel1_4_2_font.setPointSize( 10 );
TextLabel1_4_2->setFont( TextLabel1_4_2_font );
TextLabel1_4_2->setText( tr( "<p align=center>\n"
"<hr>\n"
"Max Moser<br>\n"
"Martin J. Muench<br>\n"
"Michael Lauer<br><hr>\n"
"<b>www.remote-exploit.org</b>\n"
"</p>" ) );
TextLabel1_4_2->setAlignment( int( QLabel::AlignCenter ) );
aboutLayout->addWidget( TextLabel1_4_2, 1, 0 );
#ifdef QWS
TabWidget->addTab( ap, "wellenreiter/networks", tr( "Nets" ) );
TabWidget->addTab( logwindow, "wellenreiter/log", tr( "Log" ) );
TabWidget->addTab( hexwindow, "wellenreiter/hex", tr( "Hex" ) );
- TabWidget->addTab( statwindow, "wellenreiter/stat", tr( "Stats" ) );
+ TabWidget->addTab( statwindow, "wellenreiter/stat", tr( "Stat" ) );
TabWidget->addTab( about, "wellenreiter/about", tr( "About" ) );
#else
TabWidget->addTab( ap, /* "wellenreiter/networks", */ tr( "Networks" ) );
TabWidget->addTab( logwindow, /* "wellenreiter/log", */ tr( "Log" ) );
TabWidget->addTab( hexwindow, /* "wellenreiter/hex", */ tr( "Hex" ) );
TabWidget->addTab( statwindow, /* "wellenreiter/hex", */ tr( "Stat" ) );
TabWidget->addTab( about, /* "wellenreiter/about", */ tr( "About" ) );
#endif
WellenreiterBaseLayout->addWidget( TabWidget );
#ifdef QWS
TabWidget->setCurrentTab( tr( "Nets" ) );
#endif
}
/*
* Destroys the object and frees any allocated resources
*/
WellenreiterBase::~WellenreiterBase()
{
// no need to delete child widgets, Qt does it all for us
}