IP randomizer fix

This commit is contained in:
cora32 2015-08-22 00:27:13 +03:00
parent 0179b11188
commit b55618722f
9 changed files with 51 additions and 234 deletions

View File

@ -35,6 +35,6 @@ void ActivityDrawerTh_HorNet::run()
makeActLine(((float)Activity / (nm != 0 ? nm : 1)) * 10); makeActLine(((float)Activity / (nm != 0 ? nm : 1)) * 10);
adtHN->doEmitDrawActivityLine(QString::number(Activity) + "b"); adtHN->doEmitDrawActivityLine(QString::number(Activity) + "b");
Activity = 0; Activity = 0;
msleep(150); msleep(200);
}; };
} }

View File

@ -1,32 +0,0 @@
#include "ColoredIndexBarDrawer.h"
int cIndex = 0;
void ColoredIndexBarDrawer::doEmitionDrawPointerPB2(int pointer)
{
emit pbTh2->drawPointerPB2(pointer);
};
void ColoredIndexBarDrawer::run()
{
globalScanFlag = true;
int oldPointer = 0;
msleep(1000);
while (globalScanFlag)
{
msleep(200);
int sz = stt->getColoredIndexes().size();
if (sz > 0) {
int pointer = 100 * cIndex / sz;
if (pointer < oldPointer) {
oldPointer = 0;
}
if (pointer > oldPointer) {
doEmitionDrawPointerPB2(pointer);
oldPointer = pointer;
}
}
msleep(1000);
}
};

View File

@ -1,20 +0,0 @@
#ifndef CIPBD_H
#define CIPBD_H
#pragma once
#include "STh.h"
#include "externData.h"
class ColoredIndexBarDrawer : public QThread
{
Q_OBJECT
public: signals : void drawPointerPB2(int);
public:
static void doEmitionDrawPointerPB2(int pointer);
protected:
void run();
};
extern ColoredIndexBarDrawer *pbTh2;
#endif // CIPBD_H

View File

@ -6,6 +6,9 @@
#include <qjsonvalue.h> #include <qjsonvalue.h>
#include <qjsonarray.h> #include <qjsonarray.h>
#include <qjsondocument.h> #include <qjsondocument.h>
#include "IPRandomizer.h"
#include "HikvisionLogin.h"
#include <ctime>
int gTimeOut = 3; int gTimeOut = 3;
int gPingTimeout = 1; int gPingTimeout = 1;
@ -1176,10 +1179,6 @@ void MainStarter::startDNSScan(){
}; };
} }
struct Corac {
int index;
std::string ip;
};
void MainStarter::startImportScan(){ void MainStarter::startImportScan(){
if (MainStarter::flCounter == 0) if (MainStarter::flCounter == 0)
@ -1190,35 +1189,21 @@ void MainStarter::startImportScan(){
return; return;
}; };
//std::vector<std::string> ipVec;
std::vector<Corac> ipVec;
struct in_addr tAddr; struct in_addr tAddr;
int ipOffset = 6;
//for (gflIndex = 0; gflIndex < MainStarter::flCounter; ++gflIndex)
for (gflIndex = 0; gflIndex < MainStarter::flCounter; gflIndex += ipOffset)
{
//sprintf(metaRange, "%d.%d.%d.%d-%d.%d.%d.%d",
// ipsstartfl[gflIndex][0], ipsstartfl[gflIndex][1], ipsstartfl[gflIndex][2], ipsstartfl[gflIndex][3],
// ipsendfl[gflIndex][0], ipsendfl[gflIndex][1], ipsendfl[gflIndex][2], ipsendfl[gflIndex][3]);
//ip1 = (ipsstartfl[gflIndex][0] * 16777216) + switch (gShuffle) {
// (ipsstartfl[gflIndex][1] * 65536) + case true: {
// (ipsstartfl[gflIndex][2] * 256) + int ipOffset = 6;
// ipsstartfl[gflIndex][3]; for (gflIndex = 0; gflIndex < MainStarter::flCounter; gflIndex += ipOffset)
//ip2 = (ipsendfl[gflIndex][0] * 16777216) + {
// (ipsendfl[gflIndex][1] * 65536) +
// (ipsendfl[gflIndex][2] * 256) +
// ipsendfl[gflIndex][3];
switch (gShuffle) {
case true: {
int ipGap = MainStarter::flCounter - gflIndex; int ipGap = MainStarter::flCounter - gflIndex;
if (ipGap < ipOffset) if (ipGap < ipOffset)
{ {
ipOffset = ipGap; ipOffset = ipGap;
}; };
for (int j = gflIndex, coracIndex = 0; j < gflIndex + ipOffset; ++j, coracIndex++) std::vector<IPRangeHolder> ipRangeVec;
for (int j = gflIndex; j < gflIndex + ipOffset; ++j)
{ {
/*sprintf(metaRange, "%d.%d.%d.%d-%d.%d.%d.%d", /*sprintf(metaRange, "%d.%d.%d.%d-%d.%d.%d.%d",
ipsstartfl[j][0], ipsstartfl[j][1], ipsstartfl[j][2], ipsstartfl[j][3], ipsstartfl[j][0], ipsstartfl[j][1], ipsstartfl[j][2], ipsstartfl[j][3],
@ -1232,94 +1217,54 @@ void MainStarter::startImportScan(){
(ipsendfl[j][2] * 256) + (ipsendfl[j][2] * 256) +
ipsendfl[j][3]; ipsendfl[j][3];
for (unsigned long i = ip1; i <= ip2; ++i) IPRangeHolder holder;
{ holder.ip1 = ip1;
if (!globalScanFlag) goto haters_gonna_hate_IM; holder.ip2 = ip2;
ipRangeVec.push_back(holder);
tAddr.s_addr = ntohl(i);
Corac corac;
corac.ip = std::string(inet_ntoa(tAddr));
corac.index = coracIndex;
ipVec.push_back(corac);
}
} }
IPRandomizer ipRandomizer(ipRangeVec, 20000);
std::random_shuffle(ipVec.begin(), ipVec.end()); int ip = 0;
for (int k = 0; k < ipVec.size(); ++k) while ((ip = ipRandomizer.getNext()) != 0) {
{
stt->addColoredIndex(ipVec[k].index);
}
stt->doEmitionUpdatePB2();
while (ipVec.size() != 0) {
++cIndex;
//stt->doEmitionDrawPointerPB2(pointer++);
while (cons >= gThreads && globalScanFlag) Sleep(500); while (cons >= gThreads && globalScanFlag) Sleep(500);
if (!globalScanFlag) goto haters_gonna_hate_IM; if (!globalScanFlag) goto haters_gonna_hate_IM;
++indexIP; ++indexIP;
strcpy(currentIP, ipVec[0].ip.c_str()); tAddr.s_addr = ntohl(ip);
ipVec.erase(ipVec.begin()); strcpy(currentIP, inet_ntoa(tAddr));
verboseProgress(gTargets); verboseProgress(gTargets);
Threader::fireThread(currentIP, (void*(*)(void))_connect); Threader::fireThread(currentIP, (void*(*)(void))_connect);
} }
}
haters_gonna_hate_IM:;
break;
}
case false: {
ip1 = (ipsstartfl[gflIndex][0] * 16777216) +
(ipsstartfl[gflIndex][1] * 65536) +
(ipsstartfl[gflIndex][2] * 256) +
ipsstartfl[gflIndex][3];
ip2 = (ipsendfl[gflIndex][0] * 16777216) +
(ipsendfl[gflIndex][1] * 65536) +
(ipsendfl[gflIndex][2] * 256) +
ipsendfl[gflIndex][3];
struct in_addr tAddr;
for (unsigned long i = ip1; i <= ip2; ++i) {
// for (unsigned long i = ip1; i <= ip2; ++i) { while (cons >= gThreads && globalScanFlag) Sleep(500);
if (!globalScanFlag) break;
// if (!globalScanFlag) break; ++indexIP;
// tAddr.s_addr = ntohl(i); tAddr.s_addr = ntohl(i);
// ipVec.push_back(inet_ntoa(tAddr)); strcpy(currentIP, inet_ntoa(tAddr));
verboseProgress(gTargets);
// if (ipVec.size() >= (gTargets > 10000 ? 10000 : gTargets)) { Threader::fireThread(currentIP, (void*(*)(void))_connect);
}
// std::random_shuffle(ipVec.begin(), ipVec.end()); break;
// while (ipVec.size() != 0) { };
// while (cons >= gThreads && globalScanFlag) Sleep(500);
// if (!globalScanFlag) goto haters_gonna_hate_IM;
// ++indexIP;
// strcpy(currentIP, ipVec[0].c_str());
// ipVec.erase(ipVec.begin());
// verboseProgress(gTargets);
// Threader::fireThread(currentIP, (void*(*)(void))_connect);
// }
// }
// }
haters_gonna_hate_IM:;
break;
}
case false: {
ip1 = (ipsstartfl[gflIndex][0] * 16777216) +
(ipsstartfl[gflIndex][1] * 65536) +
(ipsstartfl[gflIndex][2] * 256) +
ipsstartfl[gflIndex][3];
ip2 = (ipsendfl[gflIndex][0] * 16777216) +
(ipsendfl[gflIndex][1] * 65536) +
(ipsendfl[gflIndex][2] * 256) +
ipsendfl[gflIndex][3];
struct in_addr tAddr;
for (unsigned long i = ip1; i <= ip2; ++i) {
while (cons >= gThreads && globalScanFlag) Sleep(500);
if (!globalScanFlag) break;
++indexIP;
tAddr.s_addr = ntohl(i);
strcpy(currentIP, inet_ntoa(tAddr));
verboseProgress(gTargets);
Threader::fireThread(currentIP, (void*(*)(void))_connect);
}
break;
};
}
} }
} }
@ -1417,9 +1362,9 @@ int thread_cleanup(void)
return 1; return 1;
} }
#include "HikvisionLogin.h"
void MainStarter::start(const char* targets, const char* ports) { void MainStarter::start(const char* targets, const char* ports) {
std::srand(std::time(NULL));
HikVis::hikCounter = 0; HikVis::hikCounter = 0;
HikVis::rviCounter = 0; HikVis::rviCounter = 0;
saveBackup = true; saveBackup = true;

View File

@ -7,12 +7,6 @@ void STh::doEmitionChangeBARow(int index, QString loginPass, QString percentage)
emit stt->signalChangeBARow(index, loginPass, percentage); emit stt->signalChangeBARow(index, loginPass, percentage);
} }
void STh::doEmitionUpdatePB2()
{
cIndex = 0;
emit stt->updPB2();
}
void STh::doEmitionShowRedVersion() void STh::doEmitionShowRedVersion()
{ {
emit stt->showRedVersion(); emit stt->showRedVersion();

2
STh.h
View File

@ -51,7 +51,6 @@ public:
static void doEmitionBlockButton(bool value); static void doEmitionBlockButton(bool value);
//BA TablelistView //BA TablelistView
static void doEmitionChangeBARow(int index, QString loginPass, QString percentage); static void doEmitionChangeBARow(int index, QString loginPass, QString percentage);
static void doEmitionUpdatePB2();
signals: signals:
public: signals: void showRedVersion(); public: signals: void showRedVersion();
@ -59,7 +58,6 @@ public: signals: void startScanIP();
public: signals: void startScanDNS(); public: signals: void startScanDNS();
public: signals: void startScanImport(); public: signals: void startScanImport();
public: signals: void signalDataSaved(bool); public: signals: void signalDataSaved(bool);
public: signals : void updPB2();
public: signals: void changeFoundData(QString); public: signals: void changeFoundData(QString);
public: signals: void changeRedFoundData(QString); public: signals: void changeRedFoundData(QString);

View File

@ -15,7 +15,6 @@
#include <qdesktopservices.h> #include <qdesktopservices.h>
#include <qmessagebox.h> #include <qmessagebox.h>
#include "progressbardrawer.h" #include "progressbardrawer.h"
#include "ColoredIndexBarDrawer.h"
#include "FileDownloader.h" #include "FileDownloader.h"
#include "HikvisionLogin.h" #include "HikvisionLogin.h"
#include <QCryptographicHash> #include <QCryptographicHash>
@ -80,7 +79,6 @@ ActivityDrawerTh_HorNet *adtHN = new ActivityDrawerTh_HorNet();
DrawerTh_VoiceScanner *vsTh = new DrawerTh_VoiceScanner(); DrawerTh_VoiceScanner *vsTh = new DrawerTh_VoiceScanner();
PieStat *psTh = new PieStat(); PieStat *psTh = new PieStat();
ProgressbarDrawer *pbTh = new ProgressbarDrawer(); ProgressbarDrawer *pbTh = new ProgressbarDrawer();
ColoredIndexBarDrawer *pbTh2 = new ColoredIndexBarDrawer();
bool MapWidgetOpened = false; bool MapWidgetOpened = false;
bool globalScanFlag; bool globalScanFlag;
@ -94,7 +92,6 @@ QGraphicsScene *sceneActivityGrid;
QGraphicsScene *sceneTextPlacer; QGraphicsScene *sceneTextPlacer;
QGraphicsScene *sceneVoice; QGraphicsScene *sceneVoice;
QGraphicsScene *pbScene; QGraphicsScene *pbScene;
QGraphicsScene *pb2Scene;
QGraphicsScene *jobRangeVisualScene; QGraphicsScene *jobRangeVisualScene;
QString importFileName = ""; QString importFileName = "";
@ -154,7 +151,6 @@ int PekoWidget::m_windowCounter = 0;
int PekoWidget::offset = 0; int PekoWidget::offset = 0;
int psh_lul(PIP_ADAPTER_INFO zzaza) int psh_lul(PIP_ADAPTER_INFO zzaza)
{ {
int chc = 0; int chc = 0;
@ -401,7 +397,6 @@ void setSceneArea()
sceneTextPlacer = new QGraphicsScene(); sceneTextPlacer = new QGraphicsScene();
sceneVoice = new QGraphicsScene(); sceneVoice = new QGraphicsScene();
pbScene = new QGraphicsScene(); pbScene = new QGraphicsScene();
pb2Scene = new QGraphicsScene();
jobRangeVisualScene = new QGraphicsScene(); jobRangeVisualScene = new QGraphicsScene();
ui->graphicLog->setScene(sceneGrid); ui->graphicLog->setScene(sceneGrid);
@ -413,7 +408,6 @@ void setSceneArea()
ui->graphicTextPlacer->setScene(sceneTextPlacer); ui->graphicTextPlacer->setScene(sceneTextPlacer);
ui->graphicsVoice->setScene(sceneVoice); ui->graphicsVoice->setScene(sceneVoice);
ui->pbgv->setScene(pbScene); ui->pbgv->setScene(pbScene);
ui->pbgv_2->setScene(pb2Scene);
ui->jobRangeVisual->setScene(jobRangeVisualScene); ui->jobRangeVisual->setScene(jobRangeVisualScene);
ui->graphicLog->setSceneRect(0, 0, ui->graphicLog->width(), ui->graphicLog->height()); ui->graphicLog->setSceneRect(0, 0, ui->graphicLog->width(), ui->graphicLog->height());
@ -425,7 +419,6 @@ void setSceneArea()
ui->graphicTextPlacer->setSceneRect(0, 0, ui->graphicTextPlacer->width(), ui->graphicTextPlacer->height()); ui->graphicTextPlacer->setSceneRect(0, 0, ui->graphicTextPlacer->width(), ui->graphicTextPlacer->height());
ui->graphicsVoice->setSceneRect(0, 0, ui->graphicsVoice->width(), ui->graphicsVoice->height()); ui->graphicsVoice->setSceneRect(0, 0, ui->graphicsVoice->width(), ui->graphicsVoice->height());
ui->pbgv->setSceneRect(0, 0, ui->pbgv->width(), ui->pbgv->height()); ui->pbgv->setSceneRect(0, 0, ui->pbgv->width(), ui->pbgv->height());
ui->pbgv_2->setSceneRect(0, 0, ui->pbgv_2->width(), ui->pbgv_2->height());
ui->jobRangeVisual->setSceneRect(0, 0, ui->jobRangeVisual->width(), ui->jobRangeVisual->height()); ui->jobRangeVisual->setSceneRect(0, 0, ui->jobRangeVisual->width(), ui->jobRangeVisual->height());
@ -2101,40 +2094,6 @@ void nesca_3::slotPBUpdate()
pbScene->addLine(4, 77, 6, 77, pbPen); pbScene->addLine(4, 77, 6, 77, pbPen);
pbScene->addLine(4, 88, 6, 88, pbPen); pbScene->addLine(4, 88, 6, 88, pbPen);
} }
#include <unordered_map>
std::unordered_map<int, QColor> colorMap = {
{ 0, QColor("#DC143C") },
{ 1, QColor("#000080") },
{ 2, QColor("#3CB371") },
{ 3, QColor("#20B2AA") },
{ 4, QColor("#00BFFF") },
{ 5, QColor("#DEB887") }
};
int ciSz = 1;
void nesca_3::slotPB2Update()
{
pb2Scene->clear();
QList<int> cIndexes = stt->getColoredIndexes();
ciSz = cIndexes.size();
int percValue = ciSz / 100;
for (int i = 0, j = 0; i < ciSz; i += percValue, j++) {
int val = ciSz - i;
if (val < percValue) {
percValue = val;
}
pb2Scene->addLine(0, j, 26, j, colorMap[cIndexes[i]]);
}
}
void nesca_3::slotPB2DrawPointer(int pointer) {
QGraphicsRectItem* rect = new QGraphicsRectItem(0, 0, 26, pointer);
rect->setBrush(QBrush(QColor(0, 0, 0, 100)));
pb2Scene->addItem(rect);
//pb2Scene->addRect(0, pointer, 26, pointer, QColor(255, 255, 255, 160));
pb2Scene->addLine(0, pointer, 26, pointer, QColor(255, 255, 255, 255));
}
void nesca_3::changeNSTrackLabel(bool status) void nesca_3::changeNSTrackLabel(bool status)
{ {
if(status) ui->NSTrackStatusLabel->setStyleSheet("background-color: green; border: 1px solid white;"); if(status) ui->NSTrackStatusLabel->setStyleSheet("background-color: green; border: 1px solid white;");
@ -2255,8 +2214,6 @@ void nesca_3::ConnectEvrthng()
{ {
connect(stt, SIGNAL(signalBlockButton(bool)), this, SLOT(slotBlockButtons(bool))); connect(stt, SIGNAL(signalBlockButton(bool)), this, SLOT(slotBlockButtons(bool)));
connect(pbTh, SIGNAL(upd()), this, SLOT(slotPBUpdate())); connect(pbTh, SIGNAL(upd()), this, SLOT(slotPBUpdate()));
connect(stt, SIGNAL(updPB2()), this, SLOT(slotPB2Update()));
connect(pbTh2, SIGNAL(drawPointerPB2(int)), this, SLOT(slotPB2DrawPointer(int)));
connect ( ui->secretMessageBut_1, SIGNAL( clicked() ), this, SLOT( smReaction() ) ); connect ( ui->secretMessageBut_1, SIGNAL( clicked() ), this, SLOT( smReaction() ) );
connect ( ui->secretMessageBut_2, SIGNAL( clicked() ), this, SLOT( smReaction() ) ); connect ( ui->secretMessageBut_2, SIGNAL( clicked() ), this, SLOT( smReaction() ) );
connect ( ui->secretMessageBut_3, SIGNAL( clicked() ), this, SLOT( smReaction() ) ); connect ( ui->secretMessageBut_3, SIGNAL( clicked() ), this, SLOT( smReaction() ) );
@ -2691,7 +2648,6 @@ void nesca_3::trayButtonClicked()
void nesca_3::ChangeShuffle(bool val) void nesca_3::ChangeShuffle(bool val)
{ {
gShuffle = val; gShuffle = val;
ui->pbgv_2->setVisible(val);
} }
void nesca_3::ChangeTrackerOK(bool val) void nesca_3::ChangeTrackerOK(bool val)
@ -3007,7 +2963,6 @@ void nesca_3::ImportScanSeq()
startFlag = true; startFlag = true;
pbTh->start(); pbTh->start();
pbTh2->start();
ui->importButton->setText("Stop"); ui->importButton->setText("Stop");
ui->importButton->setStyleSheet( ui->importButton->setStyleSheet(
" #importButton {" " #importButton {"
@ -3176,9 +3131,9 @@ void nesca_3::finishLoading() {
CreateVerFile(); CreateVerFile();
dtHN->start(); //dtHN->start();
dtME2->start(); //dtME2->start();
adtHN->start(); //adtHN->start();
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) #if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__)

View File

@ -65,8 +65,6 @@ protected:
void ChangePingerOK(bool val); void ChangePingerOK(bool val);
void changeNSTrackLabel(bool status); void changeNSTrackLabel(bool status);
void slotPBUpdate(); void slotPBUpdate();
void slotPB2Update();
void slotPB2DrawPointer(int pointer);
void DNSLine_ValueChanged(); void DNSLine_ValueChanged();
void slotShowRedVersion(); void slotShowRedVersion();
void slotTabChanged(int index); void slotTabChanged(int index);

View File

@ -963,28 +963,7 @@ color: rgb(214, 214, 0);</string>
<widget class="QGraphicsView" name="pbgv"> <widget class="QGraphicsView" name="pbgv">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>451</x> <x>440</x>
<y>20</y>
<width>26</width>
<height>102</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">background-color:rgb(38, 38, 38);
border: 1px solid rgb(227, 227, 227);
border-radius: 3px;</string>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
</widget>
<widget class="QGraphicsView" name="pbgv_2">
<property name="geometry">
<rect>
<x>420</x>
<y>20</y> <y>20</y>
<width>26</width> <width>26</width>
<height>102</height> <height>102</height>