author | mickeyl <mickeyl> | 2004-05-01 16:15:05 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-05-01 16:15:05 (UTC) |
commit | fd2bbf9a09aa7a13bd8a43db351b9153e5a4b7ab (patch) (side-by-side diff) | |
tree | 17e24a7acb78e995e53ec7127e2d20a834984706 | |
parent | d5abd7878f553f5ac0a41966b27f4c09389d3cfd (diff) | |
download | opie-fd2bbf9a09aa7a13bd8a43db351b9153e5a4b7ab.zip opie-fd2bbf9a09aa7a13bd8a43db351b9153e5a4b7ab.tar.gz opie-fd2bbf9a09aa7a13bd8a43db351b9153e5a4b7ab.tar.bz2 |
- be really paranoid about wireless extension versions for compile time vs. run time
- register handlers for SIGSEGV and SIGBUG to emergency-close the capture file
-rw-r--r-- | noncore/net/wellenreiter/ChangeLog | 3 | ||||
-rw-r--r-- | noncore/net/wellenreiter/TODO | 6 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.cpp | 48 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.h | 5 |
4 files changed, 56 insertions, 6 deletions
diff --git a/noncore/net/wellenreiter/ChangeLog b/noncore/net/wellenreiter/ChangeLog index fdc8aa7..b59f9f9 100644 --- a/noncore/net/wellenreiter/ChangeLog +++ b/noncore/net/wellenreiter/ChangeLog @@ -1,50 +1,53 @@ 2004-??-?? Michael Lauer <mickey@Vanille.de> + * Registered a signal handler. We're now trying to gracefully exit and emergency close capture files. + This should allow reproducing failures. + * Added sanity check for compile time vs. run time Wireless Extension versions. * Added sanity check isPresent(interface) before starting the engine. * Added a View submenu. Added actions to expand and collapse all items. * Switched to a (hopefully) more reliable method reading from gpsd. * Added parsing of named ProbeRequests. Display only-probed-yet SSIDs in a different network color. * Rewrote the simple actions on new {Network, Client, Station}. Besides playing a sound or blinking a LED, a user customizable script can now be executed, if something has been detected. This opens up many possibilities, i.e. a qcop to qpegps or exec'ing flite (speech). * Added decloaking of cloaked ESSIDs (length != 0, but essid[0] == \0). * Hided the 'Parse' Tab in the configuration window. Not functional now and may come later * Added parsing of control frames. Display stations sending them SSID "<unknown>" for now. * Added command line option "-nocheck" to skip non-root and dhcp tests. * Improved the speed of and user feedback during reading the manufacturer list. * GPS coordinates are now presented in the DMS (as opposed to decimal) format. 2003-12-18 Michael Lauer <mickey@Vanille.de> * Released as Version 1.0.2 (Development Snapshot) * Added automatic uploading of capture files to "The Capture Dump" site at http://www.Vanille.de/projects/capturedump.spy * Initial reading of the manufacturer database happens now in background * Removed deprecated setMonitorMode() API ==> Use setMode( "monitor" ) now. The monitor mode now tries to use the standard IW_MODE_MONITOR first. If that doesn't work, it falls back to using the proprietary iwpriv commands 2003-11-30 Michael Lauer <mickey@Vanille.de> * Released as Version 1.0.1 (Development Snapshot) * Fixed ARP decoding for wired networks. Interestingly, 802.11 encapsulates these in IP packets, while wired ethernet just tags the type_of_protocol. * Added reading GPS data from a gps daemon. * Started preparations for utilizing Wellenreiter II in wired networks. * Implemented persistant configuration interface and retriggerable auto detection. * Added QCOP interface for talking to opie-networksettings. * Added parsing of DHCP packets and detecting DHCP servers. * Overhauled the configuration window and started with the customizable event system. * Added disabling the screensaver. * Added automatic opening and scrolling to the network tree if a new station appears. 2003-05-10 Michael Lauer <mickey@Vanille.de> * Released as Version 1.0 (Stable) * Added restarting the dhcp client if having killed it before. * Decouple dump files from live capture to shift control over 'what' is dumped to applications. 2003-05-05 Michael Lauer <mickey@Vanille.de> * Released as Version 1.0-RC1 (Release Candidate) * Fixed rare segfaults while sniffing and operating the GUI simultaenously. diff --git a/noncore/net/wellenreiter/TODO b/noncore/net/wellenreiter/TODO index 0640d23..f0a193d 100644 --- a/noncore/net/wellenreiter/TODO +++ b/noncore/net/wellenreiter/TODO @@ -1,77 +1,75 @@ /************************************************************************ /* W e l l e n r e i t e r I I /* =============================== /* /* Version: 1.0.2 /************************************************************************ ---------------------------------------------------- Ideas as of Wellenreiter II / April 2004 ---------------------------------------------------- -------- BUILD -------- - fix building against X11 again -------- ENGINE -------- - enable multiple packet sources - infrared - bluetooth - - usb? + - usb - define packet structure in a metalanguage and generate the actual parsing code (hmmm) - pester the ethereal folks to settle for an application independant packet dissection framework... (unlikely) - adaptive hopping scheme ! - gather interface capabilities - enable sniffing in wired networks -- fix autodetection (interface name) +- fix autodetection (the interface name is not selected correctly) - use ethtool IOCTLs (if present) --------- UI --------- - display interface capabilities (or rewrite networksettings?) - distinguish wireless bridges (WDS traffic) - add configuration for scrollback buffer in hex window and log window - revamp hex window, make it more sophisticated than just a QMultiLineEdit - tree view - beep over headphone / customizable - count/display number of wireless networks / APs since last start/stop --------- FILES --------- - write kismet-like .network format and format to be importable into AutoRoute - implement beacon stripping (the first beacon is enough to detect a new network - further beacons just blow up the capture file) - write wi-scan format like that: # $Creator: Wellenreiter II Version 1.0.2 # $Format: wi-scan # Latitude Longitude ( SSID ) Type ( BSSID ) Time (GMT) [ SNR Sig Noise ] # $DateGMT: 2004-02-07 N 41.1008009 W 8.3893034 ( Porceven ) BBS ( 00:a0:f8:41:91:63 ) 22:32:39 (GMT) [ 21 177 156 ] -- add SIGSEGV handler for emergency closing the capture file etc. - diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp index 40cd105..12b3978 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.cpp +++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp @@ -13,141 +13,175 @@ #include "gps.h" #include "wellenreiter.h" #include "scanlist.h" #include "logwindow.h" #include "packetview.h" #include "configwindow.h" #include "statwindow.h" #include "graphwindow.h" #include "protolistview.h" /* OPIE */ #ifdef QWS #include <opie2/oapplication.h> #include <opie2/odebug.h> #include <opie2/odevice.h> #else #include <qapplication.h> #endif #include <opie2/omanufacturerdb.h> #include <opie2/onetwork.h> #include <opie2/opcap.h> #include <qpe/qcopenvelope_qws.h> using namespace Opie::Core; using namespace Opie::Net; using namespace Opie::Ui; /* QT */ #include <qcheckbox.h> #include <qcombobox.h> #include <qdatetime.h> #include <qpushbutton.h> #include <qlineedit.h> #include <qmessagebox.h> #include <qobjectlist.h> #include <qregexp.h> #include <qspinbox.h> #include <qtimer.h> #include <qtoolbutton.h> #include <qmainwindow.h> /* STD */ #include <assert.h> #include <errno.h> #include <unistd.h> #include <string.h> #include <sys/types.h> #include <stdlib.h> +#include <signal.h> + +Wellenreiter* Wellenreiter::instance = 0; Wellenreiter::Wellenreiter( QWidget* parent ) : WellenreiterBase( parent, 0, 0 ), sniffing( false ), iface( 0 ), configwindow( 0 ) { logwindow->log( "(i) Wellenreiter has been started." ); // // detect operating system // #ifdef QWS QString sys; sys.sprintf( "(i) Running on '%s'.", (const char*) ODevice::inst()->systemString() ); _system = ODevice::inst()->system(); logwindow->log( sys ); #endif netview->setColumnWidthMode( 1, QListView::Manual ); connect( netview, SIGNAL( joinNetwork(const QString&,const QString&,int,const QString&) ), this, SLOT( joinNetwork(const QString&,const QString&,int,const QString&) ) ); pcap = new OPacketCapturer(); pcap->setAutoDelete( false ); gps = new GPS( this ); QTimer::singleShot( 1000, this, SLOT( initialTimer() ) ); + registerSignalHandler(); } Wellenreiter::~Wellenreiter() { delete pcap; + //unregisterSignalHandler(); } void Wellenreiter::initialTimer() { - odebug << "Wellenreiter::preloading manufacturer database..." << oendl; + odebug << "preloading manufacturer database..." << oendl; OManufacturerDB::instance(); } +void Wellenreiter::signalHandler( int sig ) +{ + oerr << "Aye! Received SIGSEGV or SIGBUS! Trying to exit gracefully..." << oendl; + if ( Wellenreiter::instance->sniffing ) + { + Wellenreiter::instance->pcap->close(); + Wellenreiter::instance->stopClicked(); + } + oerr << "Phew. Seemed to work." << oendl; + ::exit( -1 ); +} + + +void Wellenreiter::registerSignalHandler() +{ + Wellenreiter::instance = this; + struct sigaction action; + + action.sa_handler = Wellenreiter::signalHandler; + if (sigemptyset(&action.sa_mask)) + oerr << "sigemptyset() failure:" << strerror( errno ) << oendl; + if (sigaction(SIGSEGV, &action, NULL)) + oerr << "can't set up a signal handler for SIGSEGV:" << strerror( errno ) << oendl; + if (sigaction(SIGBUS, &action, NULL)) + oerr << "can't set up a signal handler for SIGBUS:" << strerror( errno ) << oendl; + odebug << "signal handlers setup." << oendl; +} + + void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw ) { configwindow = cw; } void Wellenreiter::channelHopped(int c) { QString title = "Wellenreiter II -scan- ["; QString left; if ( c > 1 ) left.fill( '.', c-1 ); title.append( left ); title.append( '|' ); if ( c < iface->channels() ) { QString right; right.fill( '.', iface->channels()-c ); title.append( right ); } title.append( "]" ); //title.append( QString().sprintf( " %02d", c ) ); assert( parent() ); ( (QMainWindow*) parent() )->setCaption( title ); } void Wellenreiter::handleNotification( OPacket* p ) { QObjectList* l = p->queryList(); QObjectListIt it( *l ); QObject* o; while ( (o = it.current()) != 0 ) { QString name = it.current()->name(); if ( configwindow->parsePackets->isProtocolChecked( name ) ) { QString action = configwindow->parsePackets->protocolAction( name ); odebug << "parsePacket-action for '" << (const char*) name << "' seems to be '" << action << "'" << oendl; doAction( action, name, p ); } else { odebug << "protocol '" << name << "' not checked in parsePackets." << oendl; } ++it; } } @@ -457,126 +491,136 @@ void Wellenreiter::stopClicked() if ( iface ) { // switch off monitor mode iface->setMode( "managed" ); // switch off promisc flag iface->setPromiscuousMode( false ); system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess } logwindow->log( "(i) Stopped Scanning." ); assert( parent() ); ( (QMainWindow*) parent() )->setCaption( "Wellenreiter II" ); // message the user QMessageBox::information( this, "Wellenreiter II", tr( "Your wireless card\nshould now be usable again." ) ); sniffing = false; emit( stoppedSniffing() ); #ifdef QWS if ( WellenreiterConfigWindow::instance()->disablePM->isChecked() ) { QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; } #else #warning FIXME: setScreenSaverMode is not operational on the X11 build #endif // print out statistics for( QMap<QString,int>::ConstIterator it = pcap->statistics().begin(); it != pcap->statistics().end(); ++it ) statwindow->updateCounter( it.key(), it.data() ); } void Wellenreiter::startClicked() { // get configuration from config window const QString& interface = configwindow->interfaceName->currentText(); const int cardtype = configwindow->driverType(); const int interval = configwindow->hoppingInterval(); if ( ( interface == "" ) || ( cardtype == 0 ) ) { QMessageBox::information( this, "Wellenreiter II", - tr( "Your device is not\nproperly configured. Please reconfigure!" ) ); + tr( "No device configured.\nPlease reconfigure!" ) ); return; } // configure device ONetwork* net = ONetwork::instance(); // TODO: check if interface is wireless and support sniffing for non-wireless interfaces if ( cardtype != DEVTYPE_FILE ) { if ( !net->isPresent( interface ) ) { QMessageBox::information( this, "Wellenreiter II", tr( "The configured device (%1)\nis not available on this system\n. Please reconfigure!" ).arg( interface ) ); return; } iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); // fails if network is not wireless! assert( iface ); // bring device UP iface->setUp( true ); if ( !iface->isUp() ) { QMessageBox::warning( this, "Wellenreiter II", tr( "Can't bring interface '%1' up:\n" ).arg( iface->name() ) + strerror( errno ) ); return; } + + // check if wireless extension version matches + if ( ONetwork::wirelessExtensionCompileVersion() != iface->wirelessExtensionDriverVersion() ) + { + QMessageBox::critical( this, "Wellenreiter II", tr( "<p>The Wireless Extension Versions<br>are not matching!<p>" + " Wellenreiter II : WE V%1<br>Interface driver: WE V%2" ) + .arg( QString::number( ONetwork::wirelessExtensionCompileVersion() ) ) + .arg( QString::number( iface->wirelessExtensionDriverVersion() ) ) ); + return; + } } // set monitor mode bool usePrism = configwindow->usePrismHeader(); switch ( cardtype ) { case DEVTYPE_CISCO: iface->setMonitoring( new OCiscoMonitoringInterface( iface, usePrism ) ); break; case DEVTYPE_WLAN_NG: iface->setMonitoring( new OWlanNGMonitoringInterface( iface, usePrism ) ); break; case DEVTYPE_HOSTAP: iface->setMonitoring( new OHostAPMonitoringInterface( iface, usePrism ) ); break; case DEVTYPE_ORINOCO: iface->setMonitoring( new OOrinocoMonitoringInterface( iface, usePrism ) ); break; case DEVTYPE_MANUAL: QMessageBox::information( this, "Wellenreiter II", tr( "Bring your device into\nmonitor mode now." ) ); break; case DEVTYPE_FILE: odebug << "Wellenreiter: Capturing from file '" << interface << "'" << oendl; break; default: assert( 0 ); // shouldn't reach this } // switch device into monitor mode if ( cardtype < DEVTYPE_FILE ) { if ( cardtype != DEVTYPE_MANUAL ) iface->setMode( "monitor" ); if ( iface->mode() != "monitor" ) { if ( QMessageBox::warning( this, "Wellenreiter II", tr( "Can't set interface '%1'\ninto monitor mode:\n" ).arg( iface->name() ) + strerror( errno ) + tr( "\nContinue with limited functionality?" ), QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No ) return; } } // open GPS device if ( configwindow->enableGPS->isChecked() ) { odebug << "Wellenreiter:GPS enabled @ " << configwindow->gpsdHost->currentText() << ":" << configwindow->gpsdPort->value() << "" << oendl; gps->open( configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); } // open pcap and start sniffing if ( configwindow->writeCaptureFile->isChecked() ) // write to a user specified capture file? { dumpname = configwindow->captureFileName->text(); if ( dumpname.isEmpty() ) dumpname = "captureFile"; dumpname.append( '-' ); dumpname.append( QTime::currentTime().toString().replace( QRegExp( ":" ), "-" ) ); dumpname.append( ".wellenreiter" ); } else // write it anyway ;) { diff --git a/noncore/net/wellenreiter/gui/wellenreiter.h b/noncore/net/wellenreiter/gui/wellenreiter.h index f609ef4..32e5690 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.h +++ b/noncore/net/wellenreiter/gui/wellenreiter.h @@ -1,107 +1,112 @@ /********************************************************************** ** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved. ** ** 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. ** **********************************************************************/ #ifndef WELLENREITER_H #define WELLENREITER_H #include "wellenreiterbase.h" #ifdef QWS #include <opie2/odevice.h> #endif +#include <signal.h> + class QTimerEvent; class QPixmap; namespace Opie {namespace Net {class OPacket;}} namespace Opie {namespace Net {class OWaveLanManagementPacket;}} namespace Opie {namespace Net {class OWaveLanControlPacket;}} namespace Opie {namespace Net {class OWaveLanDataPacket;}} namespace Opie {namespace Net {class OEthernetPacket;}} namespace Opie {namespace Net {class OARPPacket;}} namespace Opie {namespace Net {class OMacAddress;}} namespace Opie {namespace Net {class OIPPacket;}} namespace Opie {namespace Net {class OPacket;}} namespace Opie {namespace Net {class OWirelessNetworkInterface;}} namespace Opie {namespace Net {class OPacketCapturer;}} class PacketView; class WellenreiterConfigWindow; class MLogWindow; class GPS; class Wellenreiter : public WellenreiterBase { Q_OBJECT public: Wellenreiter( QWidget* parent = 0 ); ~Wellenreiter(); void setConfigWindow( WellenreiterConfigWindow* cw ); MScanListView* netView() const { return netview; }; MLogWindow* logWindow() const { return logwindow; }; PacketView* hexWindow() const { return hexwindow; }; bool isDaemonRunning() const { return sniffing; }; QString captureFileName() const { return dumpname; }; public: bool sniffing; + static Wellenreiter* instance; + static void signalHandler( int sig ); protected: virtual void timerEvent( QTimerEvent* ); public slots: void initialTimer(); void channelHopped(int); void receivePacket(Opie::Net::OPacket*); void startClicked(); void stopClicked(); void joinNetwork(const QString&,const QString&,int,const QString&); signals: void startedSniffing(); void stoppedSniffing(); private: void handleManagementFrame( Opie::Net::OPacket* p, Opie::Net::OWaveLanManagementPacket* ); void handleManagementFrameBeacon( Opie::Net::OPacket* p, Opie::Net::OWaveLanManagementPacket* ); void handleManagementFrameProbeRequest( Opie::Net::OPacket* p, Opie::Net::OWaveLanManagementPacket* ); void handleManagementFrameProbeResponse( Opie::Net::OPacket* p, Opie::Net::OWaveLanManagementPacket* ); void handleControlFrame( Opie::Net::OPacket* p, Opie::Net::OWaveLanControlPacket* control ); void handleWlanData( Opie::Net::OPacket* p, Opie::Net::OWaveLanDataPacket* data, Opie::Net::OMacAddress& from, Opie::Net::OMacAddress& to ); void handleEthernetData( Opie::Net::OPacket* p, Opie::Net::OEthernetPacket* data, Opie::Net::OMacAddress& from, Opie::Net::OMacAddress& to ); void handleARPData( Opie::Net::OPacket* p, Opie::Net::OARPPacket* arp, Opie::Net::OMacAddress& from, Opie::Net::OMacAddress& to ); void handleIPData( Opie::Net::OPacket* p, Opie::Net::OIPPacket* ip, Opie::Net::OMacAddress& from, Opie::Net::OMacAddress& to ); void handleNotification( Opie::Net::OPacket* p ); void doAction( const QString& action, const QString& protocol, Opie::Net::OPacket* p ); QObject* childIfToParse( Opie::Net::OPacket* p, const QString& protocol ); bool checkDumpPacket( Opie::Net::OPacket* p ); + void registerSignalHandler(); private: #ifdef QWS Opie::Core::OSystem _system; // Opie Operating System identifier #endif QString dumpname; Opie::Net::OWirelessNetworkInterface* iface; Opie::Net::OPacketCapturer* pcap; WellenreiterConfigWindow* configwindow; GPS* gps; //void readConfig(); //void writeConfig(); }; #endif |