c/c++实现获取NOD32升级账号密码

摘要:
=“”){stringstrCom=“wget q”;//wget命令,-q表示不显示下载信息strCom.append;system;//执行wgetifstreamfin;if(!

功能有待完善和添加

#include <iostream>
#include <ctime>
#include <cstring>
#include <string>
#include <fstream>
#include <sstream>
#include <cstdlib>
using namespace std;

//通过Wget来获取网页
string GetHtmlByWget(string url)
{
	//获取待下载网页文件名
	string fileName = url.substr((int)url.find_last_of("/") + 1);
	if(fileName != "")
	{
		string strCom = "wget -q "; //wget命令,-q表示不显示下载信息
		strCom.append(url);
		system(strCom.c_str()); //执行wget

		ifstream fin(fileName.c_str());
		if(!fin)
		{
			return "";
		}
		string strHtml = "";
		char chTemp[1024] = "";
		//读取网页文件到内存中
		while(fin.getline(chTemp , 1024))
		{
			strHtml.append(string(chTemp));
			strcpy(chTemp , "");
		}
		fin.close();
		strCom = "del -f ";  //删除文件命令,-f表示直接删除不做任何提示
		strCom.append(fileName);
		system(strCom.c_str()); //删除刚才下载下来的文件
		return strHtml; //返回网页源码
	}
	else
	{
		return "";
	}
}

string GetHtmlPath(int y, int m, int d)
{
	stringstream str;
	string now;
	string path = "http://www.nod32jihuoma.cn/nod32-id/";

	str << y + 1900;
	str >> now;
	path.append(now);
	path.append("-");
	now.clear();
	str.clear();

	int month = m + 1;
	if(month / 10 == 0)
	{
		str << 0;
		str >> now;
		path.append(now);
		now.clear();
		str.clear();
	}
	str << month;
	str >> now;
	path.append(now);
	path.append("-");
	now.clear();
	str.clear();

	int day = d;
	if(day / 10 == 0)
	{
		str << 0;
		str >> now;
		path.append(now);
		now.clear();
		str.clear();
	}
	str << day;
	str >> now;
	path.append(now);
	path.append(".html");
	now.clear();
	str.clear();
	return path;
}



void SearchData(int n)
{
	ofstream cout("key.txt");
	const string key = "<div>用户名:";//13
	const string value = " 密 码:";//14
	time_t t = time(NULL);
	struct tm* cur = localtime(&t);
	int y = cur->tm_year;
	int m = cur->tm_mon;
	int d = cur->tm_mday;
	for(int i = 0 ; i < n; i++)
	{
		int dd = d - i;
		string path = GetHtmlPath(y, m, dd);
		cout << "获取网址" << "\n" << path << endl;
		string data = GetHtmlByWget(path);

		//cout << data << endl;

		cout << y + 1900 << "年" << m + 1 << "月" << dd << "日 " << endl; 
		cout << "用户名:           密码:" <<endl;
		for(size_t pos = 0; pos < data.size(); pos++)
		{
			size_t t = data.find(key,pos);
			if(t == string::npos)
				break;
			t += 13;
			for(int i = 1; i <= 14; i++,t++)
			{
				cout << data[t];
			}
			cout << "    ";
			t += 14;
			for(int i = 1; i <= 10; i++,t++)
			{
				cout << data[t];
			}
			pos = t;
			cout << endl;
		}
	}
	cout.close();
}
int main()
{
	SearchData(2);
	
	string str;
	ifstream fin("key.txt");
	while(fin)
	{
		getline(fin,str);
		cout << str << endl;
		str.clear();
	}
	fin.close();
	return 0;
}

效果图:

c/c++实现获取NOD32升级账号密码第1张c/c++实现获取NOD32升级账号密码第2张

由于获取NOD32激活码的网址更改为http://www.nod32jihuoma.cn/nod32-id/index.html

即不需要网址最后的时间的处理了,变得更加简单化

相应的代码更改为:

#include <iostream>
#include <ctime>
#include <cstring>
#include <string>
#include <fstream>
#include <sstream>
#include <cstdlib>
#include <afxinet.h>
using namespace std;

string GetHtml(CString url)
{
	CString content;
	CString data;
	DWORD dwStatusCode;
	CInternetSession session("HttpClient");

	CHttpFile* pfile = (CHttpFile *)session.OpenURL(url);
	pfile -> QueryInfoStatusCode(dwStatusCode);
	if(dwStatusCode == HTTP_STATUS_OK)
	{ 
		while (pfile -> ReadString(data))
		{
			content  += data;
		}
	}
	pfile -> Close();
	delete pfile;
	session.Close();
	return string(content.GetBuffer(content.GetLength()));
}

void SearchData()
{
	ofstream cout("key.txt");
	const string key = "</p><p>用户名:";//15
	const string value = " 密 码:";//14
	time_t t = time(NULL);
	struct tm* cur = localtime(&t);
	int y = cur->tm_year;
	int m = cur->tm_mon;
	int d = cur->tm_mday;
	string path = "http://www.nod32jihuoma.cn/nod32-id/index.html";
	cout << "获取网址" << "\n" << path << endl;
	CString url;
	url.Format("%s",path.c_str());
	string data = GetHtml(url);

	//cout << data << endl;

	cout << y + 1900 << "年" << m + 1 << "月" << d << "日 " << endl; 
	cout << "用户名:           密码:" <<endl;
	for(size_t pos = 0; pos < data.size(); pos++)
	{
		size_t t = data.find(key,pos);
		if(t == string::npos)
			break;
		t += 15;
		for(int i = 1; i <= 14; i++,t++)
		{
			cout << data[t];
		}
		cout << "    ";
		t += 14;
		for(int i = 1; i <= 10; i++,t++)
		{
			cout << data[t];
		}
		pos = t;
		cout << endl;
	}
	cout.close();
}

int main() 
{ 
	SearchData();

	string str;
	ifstream fin("key.txt");
	while(fin)
	{
		getline(fin,str);
		cout << str << endl;
		str.clear();
	}
	fin.close();
	system("pause");
	return 0;
}  

http://www.nod32jihuoma.cn/nod32-id/index.html

#include <iostream>
#include <ctime>
#include <cstring>
#include <string>
#include <fstream>
#include <sstream>
#include <cstdlib>
using namespace std;

//通过Wget来获取网页
string GetHtmlByWget(string url)
{
	//获取待下载网页文件名
	string fileName = url.substr((int)url.find_last_of("/") + 1);
	if(fileName != "")
	{
		string strCom = "wget -q "; //wget命令,-q表示不显示下载信息
		strCom.append(url);
		system(strCom.c_str()); //执行wget

		ifstream fin(fileName.c_str());
		if(!fin)
		{
			return "";
		}
		string strHtml = "";
		char chTemp[1024] = "";
		//读取网页文件到内存中
		while(fin.getline(chTemp , 1024))
		{
			strHtml.append(string(chTemp));
			strcpy(chTemp , "");
		}
		fin.close();
		strCom = "del -f ";  //删除文件命令,-f表示直接删除不做任何提示
		strCom.append(fileName);
		system(strCom.c_str()); //删除刚才下载下来的文件
		return strHtml; //返回网页源码
	}
	else
	{
		return "";
	}
}

void SearchData()
{
	ofstream cout("key.txt");
	const string key = "</p><p>用户名:";//15 
	const string value = " 密 码:";//14
	time_t t = time(NULL);
	struct tm* cur = localtime(&t);
	int y = cur->tm_year;
	int m = cur->tm_mon;
	int d = cur->tm_mday;
		string path = "http://www.nod32jihuoma.cn/nod32-id/index.html";
		cout << "获取网址" << "\n" << path << endl;
		string data = GetHtmlByWget(path);

		//cout << data << endl;

		cout << y + 1900 << "年" << m + 1 << "月" << d << "日 " << endl; 
		cout << "用户名:           密码:" <<endl;
		for(size_t pos = 0; pos < data.size(); pos++)
		{
			size_t t = data.find(key,pos);
			if(t == string::npos)
				break;
			t += 15;
			for(int i = 1; i <= 14; i++,t++)
			{
				cout << data[t];
			}
			cout << "    ";
			t += 14;
			for(int i = 1; i <= 10; i++,t++)
			{
				cout << data[t];
			}
			pos = t;
			cout << endl;
		}
	cout.close();
}
int main()
{
	SearchData();
	
	string str;
	ifstream fin("key.txt");
	while(fin)
	{
		getline(fin,str);
		cout << str << endl;
		str.clear();
	}
	fin.close();
	system("pause");
	return 0;
}

免责声明:文章转载自《c/c++实现获取NOD32升级账号密码》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇Pascal精要笔记设立主机——godaddy主机使用说明之一下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

操作笔记:linux下安装mysql

1,检查linux下是否安装了mysql shell指令如下: [root@iZ945sgm0ugZ ~]# rpm -qa|grep -i mysql 如果有的话:做出挨个删除(eg:rpm -ev mysql-connector-odbc-5.2.5-6.el7.x86_64) [root@iZ945sgm0ugZ ~]# rpm -qa|grep -...

【DLL相关】实现函数的DLL封装,并在另一个项目中调用

直接给出步骤: ===========函数的DLL封装=========== 1.创建第一个项目:win32控制台程序,应用程序类型:DLL,附加选项:导出符号(命名:double_dll) 2.double_dll.h中加入函数定义   extern DOUBLE_DLL_API int doublefun(int);//DOUBLE_DLL_API 根...

html中#include file的使用方法

有两个文件a.htm和b.htm,在同一文件夹下a.htm内容例如以下 <!-- #include file="b.htm" --> b.htm内容例如以下 今天:雨 31 ℃~26 ℃ <br />明天:雷阵雨 33 ℃~27 ℃ 直接在浏览器中打开a,没有不论什么显示,后来知道,include是SSI(Server Side...

Linux平台Java调用so库JNI使用例子

1.确保gcc编译器已安装 2.编写HelloJNI.java代码,用native声明需要用C实现的函数。 如果源程序是包含在package里的话,应该建立同样的文件夹结构,比如/home/swan/test/net/wangliping/HelloJNI.java   package net.wanglipingpublic class Hello...

java 实现基于opencv全景图合成

因项目需要,自己做了demo,从中学习很多,所以分享出来,希望有这方面需求的少走一些弯路,opencv怎么安装网上教程多多,这里不加详细说明,我安装的opencv-3.3.0  如上图所示,找到相应的jar包,这里讲一下如何这个jar如何导入Maven仓库 mvn install:install-file -Dfile=D:opencv-3.0.0ope...

你可能不知道Windows系统下有一个UNIX子系统

作者:朱金灿 来源:hhttp://blog.csdn.net/clever101 请看下面一段代码: #include <time.h> #include <sys/types.h> #include <sys/stat.h> #include <stdio.h> #include <errno....