Skip to content

Commit

Permalink
BA refac
Browse files Browse the repository at this point in the history
  • Loading branch information
forsdev1 committed Mar 13, 2015
1 parent 633a081 commit a527c6d
Show file tree
Hide file tree
Showing 9 changed files with 116 additions and 50 deletions.
25 changes: 25 additions & 0 deletions BasicAuth.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include <BasicAuth.h>

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;
}
22 changes: 22 additions & 0 deletions BasicAuth.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#ifndef BASICAUTH_H
#define BASICAUTH_H

#include <BruteUtils.h>
#include <mainResources.h>

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
35 changes: 35 additions & 0 deletions BruteUtils.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include <BruteUtils.h>
#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));

}
11 changes: 11 additions & 0 deletions BruteUtils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#ifndef BRUTEUTILS_H
#define BRUTEUTILS_H

class BruteUtils {

public:
static void BConInc();
static void BConDec();
};

#endif // BRUTEUTILS_H
8 changes: 4 additions & 4 deletions Connector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down
3 changes: 2 additions & 1 deletion Connector.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
#define CONNECTOR_H

#include <externData.h>
#include <STh.h>
#include <Utils.h>
#include <BruteUtils.h>
#include "STh.h"

#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__)
#include <iphlpapi.h>
Expand Down
6 changes: 3 additions & 3 deletions WebformWorker.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
#define WEBFORMWORKER_H

#include <Utils.h>
#include "STh.h"
#include "Connector.h"
#include <mainResources.h>
#include <externData.h>
#include <externFunctions.h>
#include <BruteUtils.h>
#include "STh.h"

class WFClass {
class WFClass : BruteUtils {

private: static bool active;
int passCounter = 1;
Expand Down
48 changes: 8 additions & 40 deletions connector_old.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#pragma once
#include "STh.h"
#include "STh.h"
#include <libssh/libssh.h>
#include <sstream>
#include <openssl/md5.h>
Expand All @@ -8,6 +7,7 @@
#include "externData.h"
#include <openssl/err.h>
#include <Utils.h>
#include <BruteUtils.h>

#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__)
#include <iphlpapi.h>
Expand All @@ -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)
{
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down
8 changes: 6 additions & 2 deletions nesca.pro
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ SOURCES +=\
WebformWorker.cpp \
Connector.cpp \
connector_old.cpp \
Utils.cpp
Utils.cpp \
BruteUtils.cpp \
BasicAuth.cpp


HEADERS += ActivityDrawerTh_HorNet.h \
Expand All @@ -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

Expand Down

0 comments on commit a527c6d

Please sign in to comment.