Skip to content

Commit

Permalink
Added overflow detection
Browse files Browse the repository at this point in the history
  • Loading branch information
forsdev1 committed Apr 1, 2015
1 parent 5c26625 commit c5fc4c1
Show file tree
Hide file tree
Showing 9 changed files with 219 additions and 232 deletions.
39 changes: 25 additions & 14 deletions Connector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,14 @@ int my_trace(CURL *handle, curl_infotype type,
return 0;
}

static size_t nWriteCallback(void *contents, size_t size, size_t nmemb, void *userp)
size_t nWriteCallback(void *contents, size_t size, size_t nmemb, void *userp)
{
((std::string*)userp)->append((char*)contents, size * nmemb);
Activity += nmemb;
int ssz = ((std::string*)userp)->size();
if(ssz > 180000) {
return -1;
}
return size * nmemb;
}

Expand All @@ -116,10 +121,10 @@ int Connector::nConnect(const char* ip, const int port, std::string *buffer,
const std::string *lpString){
buffer->clear();
CURL *curl = curl_easy_init();
curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 0L);

if (curl)
{
curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 0L);
if (MapWidgetOpened) {
struct data config;
config.trace_ascii = 1; /* enable ascii tracing */
Expand Down Expand Up @@ -178,14 +183,15 @@ int Connector::nConnect(const char* ip, const int port, std::string *buffer,
(port == 21 && buffer->size() > 0)) {
if (MapWidgetOpened) stt->doEmitionAddIncData(QString(ip), QString(buffer->c_str()));
Activity += buffer->size();
return buffer->size();
return buffer->size();
} else {
if (res != 28 &&
res != 7 &&
res != 67 &&
res != 52 &&
res != 55 &&
res != 56) {
res != 55 &&
res != 56 &&
res != 23) {
if (res == 5) {
stt->doEmitionRedFoundData("Couldn't resolve proxy. The given proxy host could not be resolved. ");
return -2;
Expand Down Expand Up @@ -215,24 +221,29 @@ int Connector::nConnect(const char* ip, const int port, std::string *buffer,
else stt->doEmitionRedFoundData("CURL error: (" + QString::number(res) + ") " +
QString(ip) + ":" + QString::number(port));
}
++offlines;
return -1;

if(res == 23 && buffer->size() > 0) {
if (MapWidgetOpened) stt->doEmitionAddIncData(QString(ip), QString("[OVERFLOW]"));
return buffer->size();
} else {
stt->doEmitionOffline(QString::number(++offlines));
return -1;
}
}
} else {
stt->doEmitionRedFoundData("Curl error.");
return -1;
};

if (MapWidgetOpened) stt->doEmitionAddIncData(QString(ip), QString(buffer->c_str()));
Activity += buffer->size();
if (MapWidgetOpened) stt->doEmitionAddIncData(QString(ip), QString(buffer->c_str()));
return buffer->size();
}

int Connector::_ConnectToPort(std::string ip, int port, char *hl)
int Connector::_ConnectToPort(char* ip, int port)
{
if(gPingNScan)
{
if(_pingMyTarget(ip.c_str()) == 0)
if(_pingMyTarget(ip) == 0)
{
return -2;
};
Expand All @@ -241,16 +252,16 @@ int Connector::_ConnectToPort(std::string ip, int port, char *hl)
std::string buffer;
int size = 0;

if (port == 22) size = SSHAuth::SSHLobby(ip.c_str(), port, &buffer);
else size = nConnect(ip.c_str(), port, &buffer);
if (port == 22) size = SSHAuth::SSHLobby(ip, port, &buffer);
else size = nConnect(ip, port, &buffer);

if(size > 0)
{
++Alive;
++found;
stt->doEmitionChangeParsed(QString::number(saved) + "/" + QString::number(found));
Lexems lx;
lx._filler(port, buffer.c_str(), (char*)ip.c_str(), size, &lx, hl);
lx._filler(port, buffer.c_str(), ip, size, &lx);
};

return 0;
Expand Down
2 changes: 1 addition & 1 deletion Connector.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ class Connector {
const char *postData = NULL,
const std::vector<std::string> *customHeaders = NULL,
const std::string *lpString = NULL);
static int _ConnectToPort(std::string ip, int port, char *hl);
static int _ConnectToPort(char *ip, int port);
};
#endif // CONNECTOR_H
7 changes: 4 additions & 3 deletions Threader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ std::queue<std::string> Threader::ipQueue;

void Threader::fireThread(std::string ip, void *func(void)) {

std::unique_lock<std::mutex> lk(m);
ipQueue.push(ip);
std::unique_lock<std::mutex> lk(m);
ipQueue.push(ip);

if(threadId < gThreads) {
++threadId;
std::thread workerThread(func);
Expand All @@ -26,6 +27,6 @@ void Threader::cleanUp() {
lk.unlock();
lk.release();
threadId = 0;
std::queue<std::string> empty = {};
std::queue<std::string> empty = {};
std::swap(ipQueue, empty);
}
3 changes: 1 addition & 2 deletions externData.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
extern QJsonArray *jsonArr;

extern unsigned long long gTargetsOverall;
extern char top_level_domain[128];
extern volatile int cons, BrutingThrds, gThreads;
extern char **loginLst, **passLst, **wfLoginLst, **wfPassLst, **sshlpLst, **GlobalNegatives;
extern bool trackerOK, __savingBackUpFile, globalScanFlag, MapWidgetOpened,
Expand All @@ -40,7 +39,7 @@ extern int found, indexIP, gMode,
extern unsigned int Activity;
extern char trcSrv[256], trcScr[256], trcProxy[128], trcPersKey[64],
trcPort[32], trcSrvPortLine[32], saveEndIP[128],
gRange[128], gFirstDom[128], gPorts[65536],
gRange[128], gTLD[128], gPorts[65536],
gProxyIP[64], gProxyPort[8],
currentIP[MAX_ADDR_LEN],
finalIP[32];
Expand Down
Loading

0 comments on commit c5fc4c1

Please sign in to comment.