-rw-r--r-- | noncore/net/wellenreiter/gui/configbase.ui | 8 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/main.cpp | 17 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/mainwindow.cpp | 9 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/protolistview.cpp | 2 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.cpp | 16 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.h | 1 |
6 files changed, 45 insertions, 8 deletions
diff --git a/noncore/net/wellenreiter/gui/configbase.ui b/noncore/net/wellenreiter/gui/configbase.ui index 422826a..590ca92 100644 --- a/noncore/net/wellenreiter/gui/configbase.ui +++ b/noncore/net/wellenreiter/gui/configbase.ui @@ -92,48 +92,52 @@ </property> <property stdset="1"> <name>text</name> <string>Driver:</string> </property> </widget> <widget row="2" column="0" rowspan="1" colspan="4" > <class>QCheckBox</class> <property stdset="1"> <name>name</name> <cstring>prismHeader</cstring> </property> <property stdset="1"> <name>text</name> <string>Use additional PRISM header</string> </property> </widget> <widget row="6" column="0" rowspan="1" colspan="4" > <class>QGroupBox</class> <property stdset="1"> <name>name</name> <cstring>GroupBox1</cstring> </property> <property stdset="1"> + <name>enabled</name> + <bool>false</bool> + </property> + <property stdset="1"> <name>title</name> <string>Scan on channel</string> </property> <property> <name>layoutMargin</name> </property> <property> <name>layoutSpacing</name> </property> <grid> <property stdset="1"> <name>margin</name> <number>4</number> </property> <property stdset="1"> <name>spacing</name> <number>2</number> </property> <widget row="1" column="1" > <class>QCheckBox</class> <property stdset="1"> <name>name</name> <cstring>channel6</cstring> </property> @@ -438,48 +442,52 @@ <property stdset="1"> <name>minValue</name> <number>100</number> </property> <property stdset="1"> <name>lineStep</name> <number>100</number> </property> <property stdset="1"> <name>value</name> <number>1000</number> </property> <property> <name>whatsThis</name> <string>Choose the channel hop interval.</string> </property> </widget> <widget row="5" column="0" rowspan="1" colspan="4" > <class>QCheckBox</class> <property stdset="1"> <name>name</name> <cstring>adaptiveHopping</cstring> </property> <property stdset="1"> + <name>enabled</name> + <bool>false</bool> + </property> + <property stdset="1"> <name>text</name> <string>Use Adaptive(TM) Hop Scheme</string> </property> </widget> </grid> </widget> <widget> <class>QWidget</class> <property stdset="1"> <name>name</name> <cstring>tab</cstring> </property> <attribute> <name>title</name> <string>Capture</string> </attribute> <grid> <property stdset="1"> <name>margin</name> <number>5</number> </property> <property stdset="1"> <name>spacing</name> <number>3</number> diff --git a/noncore/net/wellenreiter/gui/main.cpp b/noncore/net/wellenreiter/gui/main.cpp index 96ebb3f..55a5260 100644 --- a/noncore/net/wellenreiter/gui/main.cpp +++ b/noncore/net/wellenreiter/gui/main.cpp @@ -25,75 +25,90 @@ // ==> 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->setCaption( "Wellenreiter II" ); w->show(); #endif a.processEvents(); // show the window before doing the safety checks int result = -1; // root check if ( getuid() ) { qWarning( QObject::tr( "Wellenreiter: trying to run as non-root!" ) ); result = QMessageBox::warning( w, " - Wellenreiter II - (non-root)", QObject::tr( "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& ) ) ... + static int killed = false; + 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)", QObject::tr( "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 ) ); + qWarning( "Wellenreiter: can't kill process #%d (%s)", result, strerror( errno ) ); + else + killed = true; } } a.exec(); + + if ( killed ) + { + result = QMessageBox::warning( w, " - Wellenreiter II - (dhcp)", QObject::tr( "Restart your dhcp client?" ), QMessageBox::Yes, QMessageBox::No ); + if ( result == QMessageBox::Yes ) + { + system( QString().sprintf( "dhclient &; udhcpcd &; dhcpcd &" ) ); + } + } + delete w; return 0; } diff --git a/noncore/net/wellenreiter/gui/mainwindow.cpp b/noncore/net/wellenreiter/gui/mainwindow.cpp index 7241f7a..3e36f5b 100644 --- a/noncore/net/wellenreiter/gui/mainwindow.cpp +++ b/noncore/net/wellenreiter/gui/mainwindow.cpp @@ -114,50 +114,51 @@ WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * n file->insertItem( tr( "&New" ), this, SLOT( fileNew() ) ); id = file->insertItem( tr( "&Load" ), fileLoad ); file->insertItem( tr( "&Save" ), fileSave ); file->insertSeparator(); file->insertItem( tr( "&Exit" ), qApp, SLOT( quit() ) ); QPopupMenu* view = new QPopupMenu( mb ); view->insertItem( tr( "&Configure..." ) ); QPopupMenu* sniffer = new QPopupMenu( mb ); sniffer->insertItem( tr( "&Configure..." ), this, SLOT( showConfigure() ) ); sniffer->insertSeparator(); startID = sniffer->insertItem( tr( "&Start" ), mw, SLOT( startClicked() ) ); sniffer->setItemEnabled( startID, false ); stopID = sniffer->insertItem( tr( "Sto&p" ), mw, SLOT( stopClicked() ) ); sniffer->setItemEnabled( stopID, false ); QPopupMenu* demo = new QPopupMenu( mb ); demo->insertItem( tr( "&Add something" ), this, SLOT( demoAddStations() ) ); id = mb->insertItem( tr( "&File" ), file ); //id = mb->insertItem( tr( "&View" ), view ); //mb->setItemEnabled( id, false ); id = mb->insertItem( tr( "&Sniffer" ), sniffer ); - //id = mb->insertItem( tr( "&Demo" ), demo ); - //mb->setItemEnabled( id, true ); + + id = mb->insertItem( tr( "&Demo" ), demo ); + mb->setItemEnabled( id, true ); #ifdef QWS mb->insertItem( startButton ); mb->insertItem( stopButton ); mb->insertItem( c ); mb->insertItem( d ); #else // Qt3 changed the insertion order. It's now totally random :( mb->insertItem( d ); mb->insertItem( c ); mb->insertItem( stopButton ); mb->insertItem( startButton ); #endif updateToolButtonState(); // setup status bar (for now only on X11) #ifndef QWS statusBar()->message( tr( "Ready." ) ); #endif connect( mw, SIGNAL( startedSniffing() ), this, SLOT( changedSniffingState() ) ); connect( mw, SIGNAL( stoppedSniffing() ), this, SLOT( changedSniffingState() ) ); }; @@ -194,48 +195,50 @@ void WellenreiterMainWindow::updateToolButtonState() menuBar()->setItemEnabled( startID, false ); } } void WellenreiterMainWindow::changedSniffingState() { startButton->setEnabled( !mw->sniffing ); menuBar()->setItemEnabled( startID, !mw->sniffing ); stopButton->setEnabled( mw->sniffing ); menuBar()->setItemEnabled( stopID, mw->sniffing ); } WellenreiterMainWindow::~WellenreiterMainWindow() { delete infoIconSet; delete settingsIconSet; delete startIconSet; delete stopIconSet; }; void WellenreiterMainWindow::demoAddStations() { + mw = 0; + mw->netView()->addNewItem( "managed", "Vanille", "00:00:20:EF:A6:43", true, 6, 80 ); mw->netView()->addNewItem( "managed", "Vanille", "00:30:6D:EF:A6:23", true, 11, 10 ); mw->netView()->addNewItem( "adhoc", "ELAN", "00:A0:F8:E7:16:22", false, 3, 10 ); mw->netView()->addNewItem( "adhoc", "ELAN", "00:AA:01:E7:56:62", false, 3, 15 ); mw->netView()->addNewItem( "adhoc", "ELAN", "00:B0:8E:E7:56:E2", false, 3, 20 ); } QString WellenreiterMainWindow::getFileName( bool save ) { QMap<QString, QStringList> map; map.insert( tr("All"), QStringList() ); QStringList text; text << "text/*"; map.insert( tr("Text"), text ); text << "*"; map.insert( tr("All"), text ); QString str; if ( save ) { #ifdef QWS str = OFileDialog::getSaveFileName( 2, "/", QString::null, map ); #else @@ -338,24 +341,26 @@ void WellenreiterMainWindow::fileLoadSession() } } } void WellenreiterMainWindow::fileNew() { mw->netView()->clear(); mw->logWindow()->clear(); mw->hexWindow()->clear(); } void WellenreiterMainWindow::closeEvent( QCloseEvent* e ) { if ( mw->isDaemonRunning() ) { QMessageBox::warning( this, "Wellenreiter/Opie", tr( "Sniffing in progress!\nPlease stop sniffing before closing." ) ); e->ignore(); } else { QMainWindow::closeEvent( e ); } } + + diff --git a/noncore/net/wellenreiter/gui/protolistview.cpp b/noncore/net/wellenreiter/gui/protolistview.cpp index f4b45d0..daca095 100644 --- a/noncore/net/wellenreiter/gui/protolistview.cpp +++ b/noncore/net/wellenreiter/gui/protolistview.cpp @@ -63,49 +63,49 @@ ProtocolListView::ProtocolListView( QWidget* parent, const char* name, WFlags f addProtocol( "802.11 Data" ); addProtocol( "IP" ); addProtocol( "ARP" ); addProtocol( "UDP" ); addProtocol( "TCP" ); } ProtocolListView::~ProtocolListView() { } void ProtocolListView::addProtocol( const QString& name ) { QHBox* hbox = new QHBox( vbox ); new QCheckBox( name, hbox, (const char*) name ); if ( parse ) { QComboBox* combo = new QComboBox( hbox, (const char*) name ); #ifdef QWS combo->setFixedWidth( 75 ); #endif - combo->insertItem( "Ignore" ); + combo->insertItem( "Pass" ); combo->insertItem( "Discard!" ); combo->insertItem( "TouchSound" ); combo->insertItem( "AlarmSound" ); combo->insertItem( "KeySound" ); combo->insertItem( "LedOn" ); combo->insertItem( "LedOff" ); combo->insertItem( "LogMessage" ); combo->insertItem( "MessageBox" ); } else { QComboBox* combo = new QComboBox( hbox, (const char*) name ); #ifdef QWS combo->setFixedWidth( 75 ); #endif combo->insertItem( "Pass" ); combo->insertItem( "Discard!" ); } } bool ProtocolListView::isProtocolChecked( const QString& name ) { QCheckBox* box = (QCheckBox*) child( (const char*) name ); diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp index 965f6b0..4257be1 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.cpp +++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp @@ -382,107 +382,114 @@ void Wellenreiter::stopClicked() emit( stoppedSniffing() ); // 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!" ) ); return; } // configure device - ONetwork* net = ONetwork::instance(); iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); - // set monitor mode + // 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; + } + // 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: 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", - tr( "Can't set device into monitor mode." ) ); + tr( "Can't set interface '%1' into monitor mode:\n" ).arg( iface->name() ) + strerror( errno ) ); return; } } // open pcap and start sniffing if ( cardtype != DEVTYPE_FILE ) { pcap->open( interface ); if ( configwindow->writeCaptureFile->isOn() ) { QString dumpname( configwindow->captureFileName->text() ); dumpname.append( '-' ); dumpname.append( QTime::currentTime().toString().replace( QRegExp( ":" ), "-" ) ); dumpname.append( ".wellenreiter" ); pcap->openDumpFile( dumpname ); } else { pcap->open( interface ); } } else { pcap->open( QFile( interface ) ); } if ( !pcap->isOpen() ) { QMessageBox::warning( this, "Wellenreiter II", - tr( "Can't open packet capturer:\n" ) + QString(strerror( errno ) )); + tr( "Can't open packet capturer for '%1':\n" ).arg( iface->name() ) + 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; @@ -509,24 +516,25 @@ void Wellenreiter::timerEvent( QTimerEvent* ) receivePacket( p ); delete p; } } void Wellenreiter::doAction( const QString& action, const QString& protocol, OPacket* p ) { if ( action == "TouchSound" ) ODevice::inst()->touchSound(); else if ( action == "AlarmSound" ) ODevice::inst()->alarmSound(); else if ( action == "KeySound" ) ODevice::inst()->keySound(); else if ( action == "LedOn" ) ODevice::inst()->setLedState( Led_Mail, Led_On ); else if ( action == "LedOff" ) ODevice::inst()->setLedState( Led_Mail, Led_Off ); else if ( action == "LogMessage" ) logwindow->log( QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) ); else if ( action == "MessageBox" ) QMessageBox::information ( this, "Notification!", QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) ); } + diff --git a/noncore/net/wellenreiter/gui/wellenreiter.h b/noncore/net/wellenreiter/gui/wellenreiter.h index 37e692c..d776492 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.h +++ b/noncore/net/wellenreiter/gui/wellenreiter.h @@ -27,48 +27,49 @@ class QTimerEvent; class QPixmap; class OPacket; class OWaveLanManagementPacket; class OWaveLanDataPacket; class OPacketCapturer; class OWirelessNetworkInterface; class ManufacturerDB; class WellenreiterConfigWindow; class MLogWindow; class MHexWindow; 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; }; MHexWindow* hexWindow() const { return hexwindow; }; bool isDaemonRunning() const { return sniffing; }; + public: bool sniffing; protected: virtual void timerEvent( QTimerEvent* ); public slots: void channelHopped(int); void receivePacket(OPacket*); void startClicked(); void stopClicked(); signals: void startedSniffing(); void stoppedSniffing(); private: void handleBeacon( OPacket* p, OWaveLanManagementPacket* beacon ); void handleData( OPacket* p, OWaveLanDataPacket* data ); void handleNotification( OPacket* p ); void doAction( const QString& action, const QString& protocol, OPacket* p ); QObject* childIfToParse( OPacket* p, const QString& protocol ); bool checkDumpPacket( OPacket* p ); private: |