From a527c6d43c9654e091b9f73aa68f604dcecccf11 Mon Sep 17 00:00:00 2001 From: cora48 Date: Fri, 13 Mar 2015 17:27:21 +0300 Subject: [PATCH] BA refac --- BasicAuth.cpp | 25 ++++++++++++++++++++++++ BasicAuth.h | 22 ++++++++++++++++++++++ BruteUtils.cpp | 35 ++++++++++++++++++++++++++++++++++ BruteUtils.h | 11 +++++++++++ Connector.cpp | 8 ++++---- Connector.h | 3 ++- WebformWorker.h | 6 +++--- connector_old.cpp | 48 ++++++++--------------------------------------- nesca.pro | 8 ++++++-- 9 files changed, 116 insertions(+), 50 deletions(-) create mode 100644 BasicAuth.cpp create mode 100644 BasicAuth.h create mode 100644 BruteUtils.cpp create mode 100644 BruteUtils.h diff --git a/BasicAuth.cpp b/BasicAuth.cpp new file mode 100644 index 0000000..f99ff97 --- /dev/null +++ b/BasicAuth.cpp @@ -0,0 +1,25 @@ +#include + +lopaStr BA::_BABrute(char *cookie, + char *ip, + int port, + char *pathT, + char *method) +{ + +} + +lopaStr BA::_BALobby(char *cookie, + char *ip, + int port, + char *path, + char *method) +{ + while(BrutingThrds >= gMaxBrutingThreads) Sleep(700); + + BruteUtils::BConInc(); + lopaStr res = _BABrute(cookie, ip, port, path, method); + BruteUtils::BConDec(); + + return res; +} diff --git a/BasicAuth.h b/BasicAuth.h new file mode 100644 index 0000000..70ec150 --- /dev/null +++ b/BasicAuth.h @@ -0,0 +1,22 @@ +#ifndef BASICAUTH_H +#define BASICAUTH_H + +#include +#include + +class BA : BruteUtils{ +private: + lopaStr _BABrute(char *cookie, + char *ip, + int port, + char *pathT, + char *method); + + lopaStr _BALobby(char *cookie, + char *ip, + int port, + char *path, + char *method); +}; + +#endif // BASICAUTH_H diff --git a/BruteUtils.cpp b/BruteUtils.cpp new file mode 100644 index 0000000..14144c7 --- /dev/null +++ b/BruteUtils.cpp @@ -0,0 +1,35 @@ +#include +#include "STh.h" +#include "externData.h" + +void BruteUtils::BConInc() +{ +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) +__asm + { + lock inc BrutingThrds; + }; +#else + asm("lock incl BrutingThrds"); +#endif + + stt->doEmitionChangeBA(QString::number(BrutingThrds)); +} + +void BruteUtils::BConDec() +{ + if(BrutingThrds > 0) + { +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) + __asm + { + lock dec BrutingThrds; + }; +#else + asm("lock decl BrutingThrds"); +#endif + } + + stt->doEmitionChangeBA(QString::number(BrutingThrds)); + +} diff --git a/BruteUtils.h b/BruteUtils.h new file mode 100644 index 0000000..1580076 --- /dev/null +++ b/BruteUtils.h @@ -0,0 +1,11 @@ +#ifndef BRUTEUTILS_H +#define BRUTEUTILS_H + +class BruteUtils { + +public: + static void BConInc(); + static void BConDec(); +}; + +#endif // BRUTEUTILS_H diff --git a/Connector.cpp b/Connector.cpp index 8de8fea..38297a9 100644 --- a/Connector.cpp +++ b/Connector.cpp @@ -173,7 +173,7 @@ int _EstablishSSHConnection(char *host, int port, std::string *buffer, const cha char pass[32] = {0}; char temp[64] = {0}; isActive = 1; - BConInc(); + BruteUtils::BConInc(); int sz = 0; char *ptr1 = 0; int res = -1; @@ -192,19 +192,19 @@ int _EstablishSSHConnection(char *host, int port, std::string *buffer, const cha if(res == 0) { if(i == 0) return -2; //Failhit - BConDec(); + BruteUtils::BConDec(); isActive = 0; return 1; } else if(res == -2) { - BConDec(); + BruteUtils::BConDec(); isActive = 0; return -2; }; Sleep(500); }; - BConDec(); + BruteUtils::BConDec(); isActive = 0; return -1; } diff --git a/Connector.h b/Connector.h index 4c6d3ca..0fa3fee 100644 --- a/Connector.h +++ b/Connector.h @@ -2,8 +2,9 @@ #define CONNECTOR_H #include -#include #include +#include +#include "STh.h" #if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) #include diff --git a/WebformWorker.h b/WebformWorker.h index b01fd95..f7deed8 100644 --- a/WebformWorker.h +++ b/WebformWorker.h @@ -2,13 +2,13 @@ #define WEBFORMWORKER_H #include -#include "STh.h" #include "Connector.h" #include -#include #include +#include +#include "STh.h" -class WFClass { +class WFClass : BruteUtils { private: static bool active; int passCounter = 1; diff --git a/connector_old.cpp b/connector_old.cpp index a610c24..026f9d0 100644 --- a/connector_old.cpp +++ b/connector_old.cpp @@ -1,5 +1,4 @@ -#pragma once -#include "STh.h" +#include "STh.h" #include #include #include @@ -8,6 +7,7 @@ #include "externData.h" #include #include +#include #if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) #include @@ -30,38 +30,6 @@ int _countFTPDirectories(char *recvBuff){ return dirCounter; } -void BConInc() -{ -#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) -__asm - { - lock inc BrutingThrds; - }; -#else - asm("lock incl BrutingThrds"); -#endif - - stt->doEmitionChangeBA(QString::number(BrutingThrds)); -} - -void BConDec() -{ - if(BrutingThrds > 0) - { -#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) - __asm - { - lock dec BrutingThrds; - }; -#else - asm("lock decl BrutingThrds"); -#endif - } - - stt->doEmitionChangeBA(QString::number(BrutingThrds)); - -} - bool debugWriteWait = false; void _DebugWriteHTMLToFile(char *request, char *buff) { @@ -904,9 +872,9 @@ lopaStr _BALobby(char *cookie, char *ip, int port, char *path, char *method) { while(BrutingThrds >= gMaxBrutingThreads) Sleep(700); - BConInc(); + BruteUtils::BConInc(); lopaStr res = _BABrute(cookie, ip, port, path, method); - BConDec(); + BruteUtils::BConDec(); return res; } @@ -1338,9 +1306,9 @@ lopaStr _FTPLobby(char *ip, int port, PathStr *ps) ZeroMemory(lps.pass, sizeof(lps.pass)); ZeroMemory(lps.other, sizeof(lps.other)); - BConInc(); + BruteUtils::BConInc(); lps = _FTPBrute(ip, port, ps); - BConDec(); + BruteUtils::BConDec(); return lps; } @@ -1744,9 +1712,9 @@ lopaStr _IPCameraBLobby(char *ip, int port, char *SPEC) { while(BrutingThrds >= gMaxBrutingThreads) Sleep(1000); - BConInc(); + BruteUtils::BConInc(); lopaStr res = _IPCameraBrute(ip, port, SPEC); - BConDec(); + BruteUtils::BConDec(); return res; } diff --git a/nesca.pro b/nesca.pro index a493743..4cb5581 100644 --- a/nesca.pro +++ b/nesca.pro @@ -40,7 +40,9 @@ SOURCES +=\ WebformWorker.cpp \ Connector.cpp \ connector_old.cpp \ - Utils.cpp + Utils.cpp \ + BruteUtils.cpp \ + BasicAuth.cpp HEADERS += ActivityDrawerTh_HorNet.h \ @@ -67,7 +69,9 @@ HEADERS += ActivityDrawerTh_HorNet.h \ vercheckerthread.h \ Utils.h \ WebformWorker.h \ - Connector.h + Connector.h \ + BasicAuth.h \ + BruteUtils.h FORMS += nesca_3.ui