From a17df57d904fbfe1f1bef0d150dbf197e208def3 Mon Sep 17 00:00:00 2001 From: cora48 Date: Fri, 27 Mar 2015 13:38:38 +0300 Subject: [PATCH] Fixed ignoing of first string in negative list. --- .gitignore | 1 + FTPAuth.cpp | 3 ++ FileUpdater.cpp | 3 +- SSHAuth.cpp | 13 +++++++-- finder.cpp | 3 ++ nesca_startModule.cpp | 64 +++++++++++++++++++++---------------------- 6 files changed, 51 insertions(+), 36 deletions(-) diff --git a/.gitignore b/.gitignore index c517839..f16d26c 100644 --- a/.gitignore +++ b/.gitignore @@ -40,3 +40,4 @@ result_files-* nesca moc_* *~ +*.user diff --git a/FTPAuth.cpp b/FTPAuth.cpp index 3ba1817..4a7299d 100644 --- a/FTPAuth.cpp +++ b/FTPAuth.cpp @@ -1,4 +1,5 @@ #include "FTPAuth.h" +#include "FileUpdater.h" bool FTPA::checkOutput(const string *buffer) { if(Utils::ci_find_substr(*buffer, "230") != -1) { @@ -27,6 +28,7 @@ lopaStr FTPA::FTPBrute(const char *ip, const int port, PathStr *ps) { for(int i = 0; i < MaxLogin; ++i) { if(!globalScanFlag) return lps; + FileUpdater::cv.wait(FileUpdater::lk, []{return FileUpdater::ready;}); if(strlen(loginLst[i]) <= 1) continue; strcpy(login, loginLst[i]); @@ -34,6 +36,7 @@ lopaStr FTPA::FTPBrute(const char *ip, const int port, PathStr *ps) { for(int j = 0; j < MaxPass; ++j) { if(!globalScanFlag) return lps; + FileUpdater::cv.wait(FileUpdater::lk, []{return FileUpdater::ready;}); if(strlen(passLst[j]) <= 1) continue; strcpy(pass, passLst[j]); diff --git a/FileUpdater.cpp b/FileUpdater.cpp index 32b3f18..16709c1 100644 --- a/FileUpdater.cpp +++ b/FileUpdater.cpp @@ -27,7 +27,7 @@ void ReadUTF8(FILE* nFile, char *cp) { && (buffFG[0] == '\t' && buffFG[1] == '\t' && buffFG[2] == '\t' && (buffFG[3] == '/' && buffFG[4] == '/')) == false) { ++GlobalNegativeSize; - }; + } ZeroMemory(buffFG, sizeof(buffFG)); }; @@ -139,6 +139,7 @@ void negativeLoader() { } else { + rewind(nFile); ReadUTF8(nFile, "1251"); }; } diff --git a/SSHAuth.cpp b/SSHAuth.cpp index 3398382..0553112 100644 --- a/SSHAuth.cpp +++ b/SSHAuth.cpp @@ -1,4 +1,5 @@ #include "SSHAuth.h" +#include "FileUpdater.h" int _sshConnect(char *user, char *pass, const char *host, int port) { @@ -17,8 +18,9 @@ int _sshConnect(char *user, char *pass, const char *host, int port) ssh_options_set(my_ssh_session, SSH_OPTIONS_HOST, hostStr); ssh_options_set(my_ssh_session, SSH_OPTIONS_PORT, &port); - int sshTimeout = gTimeOut + 1; - ssh_options_set(my_ssh_session, SSH_OPTIONS_TIMEOUT, &sshTimeout); + ssh_options_set(my_ssh_session, SSH_OPTIONS_STRICTHOSTKEYCHECK, 0); + ssh_options_set(my_ssh_session, SSH_OPTIONS_GSSAPI_DELEGATE_CREDENTIALS, 0); + ssh_options_set(my_ssh_session, SSH_OPTIONS_TIMEOUT, &(gTimeOut + 1)); int rc = ssh_connect(my_ssh_session); @@ -91,17 +93,22 @@ int SSHBrute(const char* host, int port, std::string *buffer, const char *banner for(int i = 0; i < MaxSSHPass; ++i) { + FileUpdater::cv.wait(FileUpdater::lk, []{return FileUpdater::ready;}); if(!globalScanFlag) break; strcpy(temp, sshlpLst[i]); ptr1 = strstr(temp, ":"); - if (ptr1 == NULL) { + + if (ptr1 == NULL) { stt->doEmitionRedFoundData("[SSH]Wrong format: " + QString(temp)); return -1; } + sz = ptr1 - temp; strncpy(login, temp, sz); strcpy(pass, ptr1 + 1); + res = check_ssh_pass(login, pass, temp, host, port, buffer, banner); + ZeroMemory(login, sizeof(login)); ZeroMemory(pass, sizeof(pass)); ZeroMemory(temp, sizeof(temp)); diff --git a/finder.cpp b/finder.cpp index 221658f..81c4ff6 100644 --- a/finder.cpp +++ b/finder.cpp @@ -8,6 +8,7 @@ #include "FTPAuth.h" #include "SSHAuth.h" #include +#include "FileUpdater.h" char* strstri(const char *_Str, const char *_SubStr) { @@ -190,6 +191,8 @@ int globalSearchNeg(const char *buffcpy, const char *ip, int port) char negWord[256] = {0}; for(int i = 0; i < GlobalNegativeSize; ++i) { + + FileUpdater::cv.wait(FileUpdater::lk, []{return FileUpdater::ready;}); if(!globalScanFlag) return -1; strcpy(negWord, GlobalNegatives[i]); diff --git a/nesca_startModule.cpp b/nesca_startModule.cpp index 039c126..2ecc0e1 100644 --- a/nesca_startModule.cpp +++ b/nesca_startModule.cpp @@ -60,6 +60,38 @@ volatile int cons = 0; volatile int BrutingThrds = 0; volatile int threads = 20; +unsigned char tl(unsigned char d) +{ + if(d >= 192 && d <= 223) + { + return (unsigned char)(d + 32); + } + else + { + return tolower(d); + }; +} + +std::string toLowerStr(const char *str) +{ + if(str != NULL) { + int tsz = strlen(str); + char *strr = new char[tsz+1]; + ZeroMemory(strr, tsz); + + for (int i = 0; i < tsz; i++) + { + strr[i] = tl(str[i]); + }; + + memset(strr + tsz, '\0', 1); + + std::string tstr = std::string(strr); + delete []strr; + return tstr; + } else return ""; +} + void SaveErrorLog(char *sender, char *MesSent, char *ReplRecv) { FILE *errFile = fopen("./logs/ns-track_errors.html", "r"); @@ -725,38 +757,6 @@ unsigned long int numOfIps(int ipsstart[], int ipsend[]) { return gTargets; } -unsigned char tl(unsigned char d) -{ - if(d >= 192 && d <= 223) - { - return (unsigned char)(d + 32); - } - else - { - return tolower(d); - }; -} - -std::string toLowerStr(const char *str) -{ - if(str != NULL) { - int tsz = strlen(str); - char *strr = new char[tsz+1]; - ZeroMemory(strr, tsz); - - for (int i = 0; i < tsz; i++) - { - strr[i] = tl(str[i]); - }; - - memset(strr + tsz, '\0', 1); - - std::string tstr = std::string(strr); - delete []strr; - return tstr; - } else return ""; -} - void _connect() { std::string ip = ""; while (globalScanFlag) {