| 1 | #cxx . . $ `<file>/main.cpp`/include <QApplication> |
| 2 | #include <QTextCodec> |
| 3 | #include <QTranslator> |
| 4 | #include <QLocale> |
| 5 | #include <QString> |
| 6 | #include <QLibraryInfo> |
| 7 | #include <QDir> |
| 8 | #include <QStandardPaths> |
| 9 | #include <QMessageLogger> |
| 10 | #include <QProcess> |
| 11 | #include <QMessageBox> |
| 12 | |
| 13 | #include "mainwindow.h"cxx . . $ `<file>/mainwindow.h`/ |
| 14 | #include "config_qnetstatview.h"cxx . . $ `<file>/config_qnetstatview.h`/ |
| 15 | #include "DialogPasswordPrompt.h"cxx . . $ `<file>/DialogPasswordPrompt.h`/ |
| 16 | |
| 17 | #if defined(Q_OS_WIN) |
| 18 | bool SetDebugPrivileges(){ |
| 19 | TOKEN_PRIVILEGES tp; |
| 20 | LUID luid; |
| 21 | HANDLE hToken; |
| 22 | |
| 23 | if(!OpenProcessToken(GetCurrentProcess(),TOKEN_READ|TOKEN_ADJUST_PRIVILEGES,&hToken)) |
| 24 | {return false;} |
| 25 | |
| 26 | if(!LookupPrivilegeValueA(NULL,"SeDebugPrivilege",&luid)) |
| 27 | {CloseHandle(hToken);return false;} |
| 28 | |
| 29 | tp.PrivilegeCount=1; |
| 30 | tp.Privileges[0].Luid=luid; |
| 31 | tp.Privileges[0].Attributes=SE_PRIVILEGE_ENABLED; |
| 32 | |
| 33 | if(!AdjustTokenPrivileges(hToken,FALSE,&tp,0,NULL,NULL)) |
| 34 | {CloseHandle(hToken);return false;} |
| 35 | |
| 36 | CloseHandle(hToken); |
| 37 | return true; |
| 38 | } |
| 39 | #endif |
| 40 | |
| 41 | void printUsagecxx . . $ printUsage(49f6e7a06ebc5aa8).(){ |
| 42 | qInfocxx . . $ `<external>/10450329605257866924/qlogging.h:165:9`!("%s",qPrintablecxx . . $ `<external>/15045578679651060896/qglobal.h:831:11`!(QObject::tr("Usage: qnetstatview [options]"))); |
| 43 | qInfocxx . . $ `<external>/10450329605257866924/qlogging.h:165:9`!("%s",qPrintablecxx . . $ `<external>/15045578679651060896/qglobal.h:831:11`!(QCoreApplication::applicationName() +" - "+QObject::tr("Shows detailed listings of all TCP and UDP endpoints"))); |
| 44 | qInfocxx . . $ `<external>/10450329605257866924/qlogging.h:165:9`!() <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). ""; |
| 45 | qInfocxx . . $ `<external>/10450329605257866924/qlogging.h:165:9`!() <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "Options:"; |
| 46 | qInfocxx . . $ `<external>/10450329605257866924/qlogging.h:165:9`!("%s",qPrintablecxx . . $ `<external>/15045578679651060896/qglobal.h:831:11`!("-h, --help "+QObject::tr("Displays this help."))); |
| 47 | qInfocxx . . $ `<external>/10450329605257866924/qlogging.h:165:9`!("%s",qPrintablecxx . . $ `<external>/15045578679651060896/qglobal.h:831:11`!("-v, --version "+QObject::tr("Displays version information."))); |
| 48 | qInfocxx . . $ `<external>/10450329605257866924/qlogging.h:165:9`!("%s",qPrintablecxx . . $ `<external>/15045578679651060896/qglobal.h:831:11`!("--run-as-root "+QObject::tr("Run as root."))); |
| 49 | } |
| 50 | |
| 51 | void runAsRootcxx . . $ runAsRoot(49f6e7a06ebc5aa8).(){ |
| 52 | QStringcxx . . $ QString# appForEnterRoot = ""cxx . . $ QString#QString(85c52e162fed56f9).; |
| 53 | |
| 54 | QStringListcxx . . $ QStringList# possibleAppscxx . . $ QStringList#QStringList(d3efa563c6b2065f). {"kdesu5","kdesu","gksu","pkexec"}; |
| 55 | |
| 56 | for (QStringcxx . . $ QString# app:possibleApps){ |
| 57 | if (QStandardPathscxx . . $ QStandardPaths#::findExecutablecxx . . $ QStandardPaths#findExecutable(dbae7be5ce410806).(app)!=cxx . . $ QString#`operator!=`(7d4bdb1abc417636).""){ |
| 58 | appForEnterRoot=cxx . . $ QString#`operator=`(b79fde0b0ce9b948).app; |
| 59 | break; |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | if (appForEnterRoot==cxx . . $ QString#`operator==`(7d4bdb1abc417636)."pkexec"){ |
| 64 | system(QStringcxx . . $ QString#("pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY "+cxx . . $ operator+(c75c3ae4eb9af1a8).QApplicationcxx . . $ QApplication#::applicationDirPathcxx . . $ QCoreApplication#applicationDirPath(4365c3963150523e).()+cxx . . $ operator+(3d22f08efddf8107)."/"+cxx . . $ operator+(fab9b4f80031f353).qAppNamecxx . . $ qAppName(4365c3963150523e).()+cxx . . $ operator+(3d22f08efddf8107)." ").toStdStringcxx . . $ QString#toStdString(219584694fe2b248).().datacxx . . $ std/__cxx11/basic_string#data(258ee1c9e0a18a5c).()); |
| 65 | exit(0); |
| 66 | } |
| 67 | |
| 68 | |
| 69 | if (appForEnterRoot==cxx . . $ QString#`operator==`(7d4bdb1abc417636)."kdesu5" or appForEnterRoot==cxx . . $ QString#`operator==`(7d4bdb1abc417636)."kdesu"){ |
| 70 | QProcesscxx . . $ QProcess#::startDetachedcxx . . $ QProcess#startDetached(e1defb592416720d).(appForEnterRoot+cxx . . $ operator+(3d22f08efddf8107)." "+cxx . . $ operator+(fab9b4f80031f353).QApplicationcxx . . $ QApplication#::applicationDirPathcxx . . $ QCoreApplication#applicationDirPath(4365c3963150523e).()+cxx . . $ operator+(3d22f08efddf8107)."/"+cxx . . $ operator+(fab9b4f80031f353).qAppNamecxx . . $ qAppName(4365c3963150523e).()+cxx . . $ operator+(3d22f08efddf8107)." 2> /dev/null &"); |
| 71 | exit(0); |
| 72 | } |
| 73 | |
| 74 | if (appForEnterRoot==cxx . . $ QString#`operator==`(7d4bdb1abc417636)."gksu"){ |
| 75 | QProcesscxx . . $ QProcess#::startDetachedcxx . . $ QProcess#startDetached(e1defb592416720d).("gksu -u root "+cxx . . $ operator+(c75c3ae4eb9af1a8).QApplicationcxx . . $ QApplication#::applicationDirPathcxx . . $ QCoreApplication#applicationDirPath(4365c3963150523e).()+cxx . . $ operator+(3d22f08efddf8107)."/"+cxx . . $ operator+(fab9b4f80031f353).qAppNamecxx . . $ qAppName(4365c3963150523e).()+cxx . . $ operator+(3d22f08efddf8107)." 2> /dev/null &"); |
| 76 | exit(0); |
| 77 | } |
| 78 | |
| 79 | |
| 80 | DialogPasswordPromptcxx . . $ DialogPasswordPrompt# pscxx . . $ DialogPasswordPrompt#DialogPasswordPrompt(108f35f7aa7f3cf9).; |
| 81 | if (ps.execcxx . . $ QDialog#exec(b126dc7c1de90089).()){ |
| 82 | QStringcxx . . $ QString# password = ps.getPasswordcxx . . $ DialogPasswordPrompt#getPassword(4365c3963150523e).(); |
| 83 | |
| 84 | int code = system(QStringcxx . . $ QString#("echo \""+cxx . . $ operator+(c75c3ae4eb9af1a8).password+cxx . . $ operator+(3d22f08efddf8107)."\" | sudo -S -b "+cxx . . $ operator+(fab9b4f80031f353).QApplicationcxx . . $ QApplication#::applicationDirPathcxx . . $ QCoreApplication#applicationDirPath(4365c3963150523e).()+cxx . . $ operator+(3d22f08efddf8107)."/"+cxx . . $ operator+(fab9b4f80031f353).qAppNamecxx . . $ qAppName(4365c3963150523e).()+cxx . . $ operator+(3d22f08efddf8107)." &> /dev/null").toStdStringcxx . . $ QString#toStdString(219584694fe2b248).().c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).()); |
| 85 | if (code!=0){ |
| 86 | QMessageBoxcxx . . $ QMessageBox#::criticalcxx . . $ QMessageBox#critical(a9e3742e6f7b4147).(nullptr,QObjectcxx . . $ QObject#::trcxx . . $ QObject#tr(75d9f1c324b4579d).("Restart as root"),QObjectcxx . . $ QObject#::trcxx . . $ QObject#tr(75d9f1c324b4579d).("Application startup failed. The password may have been typed incorrectly or you is not in the sudoers file. Restart as root canceled")); |
| 87 | } |
| 88 | exit(0); |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | int maincxx . . $ main(afcd3168fc1188a4).(int argc, char *argv[]) { |
| 93 | QApplicationcxx . . $ QApplication# appcxx . . $ QApplication#QApplication(6e9b1c7df49e191d).(argc, argv); |
| 94 | |
| 95 | QCoreApplicationcxx . . $ QCoreApplication#::setOrganizationNamecxx . . $ QCoreApplication#setOrganizationName(3520e46b33348bf6).("DanSoft"cxx . . $ QString#QString(85c52e162fed56f9).); |
| 96 | QCoreApplicationcxx . . $ QCoreApplication#::setOrganizationDomaincxx . . $ QCoreApplication#setOrganizationDomain(3520e46b33348bf6).("dansoft.ru"cxx . . $ QString#QString(85c52e162fed56f9).); |
| 97 | QCoreApplicationcxx . . $ QCoreApplication#::setApplicationVersioncxx . . $ QCoreApplication#setApplicationVersion(3520e46b33348bf6).(QNETSTATVIEW_VERSIONcxx . . $ `config_qnetstatview.h:4:9`!); |
| 98 | QCoreApplicationcxx . . $ QCoreApplication#::setApplicationNamecxx . . $ QCoreApplication#setApplicationName(3520e46b33348bf6).("QNetStatView"cxx . . $ QString#QString(85c52e162fed56f9).); |
| 99 | |
| 100 | |
| 101 | QDircxx . . $ QDir# dirConfigcxx . . $ QDir#QDir(3520e46b33348bf6).(QStandardPathscxx . . $ QStandardPaths#::writableLocationcxx . . $ QStandardPaths#writableLocation(7d8b34fbb6a9c1bf).(QStandardPathscxx . . $ QStandardPaths#::AppConfigLocationcxx . . $ QStandardPaths#AppConfigLocation.)); |
| 102 | if (dirConfig.existscxx . . $ QDir#exists(50ce9a9e25b4a850).()==false) dirConfig.mkpathcxx . . $ QDir#mkpath(f3b39adf77d9c36c).(dirConfig.pathcxx . . $ QDir#path(6ef7b6c27b00b43d).()); |
| 103 | |
| 104 | QTextCodeccxx . . $ QTextCodec#::setCodecForLocalecxx . . $ QTextCodec#setCodecForLocale(1f30447839ed391).(QTextCodeccxx . . $ QTextCodec#::codecForNamecxx . . $ QTextCodec#codecForName(914382192c9ca379).("UTF8")); |
| 105 | |
| 106 | QTranslatorcxx . . $ QTranslator# translatorcxx . . $ QTranslator#QTranslator(749de1b6ae65bddd).; |
| 107 | QStringcxx . . $ QString# locale = QLocalecxx . . $ QLocale#::systemcxx . . $ QLocale#system(7171962d3a2fd395).().namecxx . . $ QLocale#name(6ef7b6c27b00b43d).(); |
| 108 | |
| 109 | translator.loadcxx . . $ QTranslator#load(142924642d8b819d).(QStringcxx . . $ QString#QString(85c52e162fed56f9).(PATH_USERDATAcxx . . $ `<built-in>:480:9`!)+cxx . . $ operator+(fab9b4f80031f353).QStringcxx . . $ QString#QString(85c52e162fed56f9).("/langs/qnetstatview_") +cxx . . $ operator+(fab9b4f80031f353). locale); |
| 110 | app.installTranslatorcxx . . $ QCoreApplication#installTranslator(d376406de50edad7).(&translator); |
| 111 | |
| 112 | //set translator for default widget's text (for example: QMessageBox's buttons) |
| 113 | QTranslatorcxx . . $ QTranslator# qtTranslatorcxx . . $ QTranslator#QTranslator(749de1b6ae65bddd).; |
| 114 | qtTranslator.loadcxx . . $ QTranslator#load(142924642d8b819d).("qt_"+cxx . . $ operator+(c75c3ae4eb9af1a8).locale,QLibraryInfocxx . . $ QLibraryInfo#::locationcxx . . $ QLibraryInfo#location(dd7ac78f10b8a525).(QLibraryInfocxx . . $ QLibraryInfo#::TranslationsPathcxx . . $ QLibraryInfo#TranslationsPath.)); |
| 115 | app.installTranslatorcxx . . $ QCoreApplication#installTranslator(d376406de50edad7).(&qtTranslator); |
| 116 | |
| 117 | #if defined(Q_OS_WIN) |
| 118 | SetDebugPrivileges(); |
| 119 | #endif |
| 120 | |
| 121 | |
| 122 | for (QStringcxx . . $ QString# arg:QCoreApplicationcxx . . $ QCoreApplication#::argumentscxx . . $ QCoreApplication#arguments(669a05bc42dd57cc).()){ |
| 123 | if (arg==cxx . . $ QString#`operator==`(7d4bdb1abc417636)."--help" or arg==cxx . . $ QString#`operator==`(7d4bdb1abc417636)."-h"){ |
| 124 | printUsagecxx . . $ printUsage(49f6e7a06ebc5aa8).(); |
| 125 | return 0; |
| 126 | } |
| 127 | |
| 128 | if (arg==cxx . . $ QString#`operator==`(7d4bdb1abc417636)."--version" or arg==cxx . . $ QString#`operator==`(7d4bdb1abc417636)."-v"){ |
| 129 | qInfocxx . . $ `<external>/10450329605257866924/qlogging.h:165:9`!("QNetStatView: %s",QNETSTATVIEW_VERSIONcxx . . $ `config_qnetstatview.h:4:9`!); |
| 130 | return 0; |
| 131 | } |
| 132 | |
| 133 | if (arg.toLowercxx . . $ QString#toLower(dca2c5857e9adf82).()==cxx . . $ QString#`operator==`(7d4bdb1abc417636)."--run-as-root"){ |
| 134 | runAsRootcxx . . $ runAsRoot(49f6e7a06ebc5aa8).(); |
| 135 | return 0; |
| 136 | } |
| 137 | } |
| 138 | |
| 139 | |
| 140 | |
| 141 | MainWindowcxx . . $ MainWindow# windowcxx . . $ MainWindow#MainWindow(108f35f7aa7f3cf9).; |
| 142 | window.resizecxx . . $ QWidget#resize(3e454b8ccf442868).(800,600); |
| 143 | window.showcxx . . $ QWidget#show(49f6e7a06ebc5aa8).(); |
| 144 | |
| 145 | return app.execcxx . . $ QApplication#exec(b126dc7c1de90089).(); |
| 146 | } |
| 147 |