#include "windows.h"
#include "stdio.h"
#include "string.h"
//#include "winsock2.h"
//#include "wininet.h"
#pragma comment (lib,"ws2_32")
void LogToFile(char *LogText);
//有ProxyServer键值就取回来返回true,否则返回false;
bool CheckProxySetting(char * subkey,struct ProxyData * pCurrent);
//check proxyserver connection status
bool CheckProxyConnection(struct ProxyData * head);
//test http conn to either the proxy server or ditect the web server.
bool CheckHTTPconnction(char *hostname,int port,char * req,char * key);
//check intranet connection status
bool CheckIntranetConn();
struct ProxyData
{
char pServer[128];
int pPort;
ProxyData * pdNext;
};
void main()
{
/*
//使用wininet函数在system权限下是没有办法获得正确的结果的,另外,还存在另外一种情况,
//就是没有勾选"使用代理服务器访问网络"的时候Internet Setting子键里面一样有Proxy Server的值,
//这种情况存在的概率是相当大的,因为很多用户并不会用bypass设置来同时访问内外网,要访问内网就
//关掉上面的勾选。读取注册表键理论上可以有效减少漏报。
//同样要解决system权限下current_user键没有办法使用的问题,测试的时候使用psu在system权限下看到
//current_user里面的确没有信息,但是在HEKY_USERS/S-1-5-21-1935655697-725345543-839522115-500/
//下面却有相应的信息。回到administrators权限下还是/S-1-5-21-1935655697-725345543-839522115-500/
//有了下面枚举子键的想法。尝试中。
INTERNET_PROXY_INFO *pIEinfo = NULL;
DWORD dwSize = 0;
BOOL bRet = InternetQueryOption(NULL, INTERNET_OPTION_PROXY, pIEinfo, &dwSize);
pIEinfo = (INTERNET_PROXY_INFO*)new char[dwSize];
bRet = InternetQueryOption(NULL, INTERNET_OPTION_PROXY, pIEinfo, &dwSize);
LogToFile((char *)(pIEinfo+1));
printf("/nResult:%s",pIEinfo+1);
*/
int index=0;
char keyBuff[256]={0};
DWORD dwSize=sizeof(keyBuff);
struct ProxyData *p,*q,*head;
char *got=NULL;
bool succ=false;
head=NULL;
p=NULL;
q=NULL;
while(RegEnumKeyEx(HKEY_USERS,index,keyBuff,&dwSize,NULL,NULL,NULL,NULL)!=ERROR_NO_MORE_ITEMS)
{
printf("/nSubkey: %s",keyBuff);
//LogToFile(keyBuff);
//handle the result we have got
if((strstr(keyBuff,"DEFAULT")==NULL)&&(strstr(keyBuff,"Classes")==NULL)) //we can only find right result in de key like xxxxx-xxx,experience from my test.
{
q=(struct ProxyData *)GlobalAlloc(GMEM_ZEROINIT,sizeof(struct ProxyData));
if(q == NULL)
{
printf("/nAllo
#include "stdio.h"
#include "string.h"
//#include "winsock2.h"
//#include "wininet.h"
#pragma comment (lib,"ws2_32")
void LogToFile(char *LogText);
//有ProxyServer键值就取回来返回true,否则返回false;
bool CheckProxySetting(char * subkey,struct ProxyData * pCurrent);
//check proxyserver connection status
bool CheckProxyConnection(struct ProxyData * head);
//test http conn to either the proxy server or ditect the web server.
bool CheckHTTPconnction(char *hostname,int port,char * req,char * key);
//check intranet connection status
bool CheckIntranetConn();
struct ProxyData
{
char pServer[128];
int pPort;
ProxyData * pdNext;
};
void main()
{
/*
//使用wininet函数在system权限下是没有办法获得正确的结果的,另外,还存在另外一种情况,
//就是没有勾选"使用代理服务器访问网络"的时候Internet Setting子键里面一样有Proxy Server的值,
//这种情况存在的概率是相当大的,因为很多用户并不会用bypass设置来同时访问内外网,要访问内网就
//关掉上面的勾选。读取注册表键理论上可以有效减少漏报。
//同样要解决system权限下current_user键没有办法使用的问题,测试的时候使用psu在system权限下看到
//current_user里面的确没有信息,但是在HEKY_USERS/S-1-5-21-1935655697-725345543-839522115-500/
//下面却有相应的信息。回到administrators权限下还是/S-1-5-21-1935655697-725345543-839522115-500/
//有了下面枚举子键的想法。尝试中。
INTERNET_PROXY_INFO *pIEinfo = NULL;
DWORD dwSize = 0;
BOOL bRet = InternetQueryOption(NULL, INTERNET_OPTION_PROXY, pIEinfo, &dwSize);
pIEinfo = (INTERNET_PROXY_INFO*)new char[dwSize];
bRet = InternetQueryOption(NULL, INTERNET_OPTION_PROXY, pIEinfo, &dwSize);
LogToFile((char *)(pIEinfo+1));
printf("/nResult:%s",pIEinfo+1);
*/
int index=0;
char keyBuff[256]={0};
DWORD dwSize=sizeof(keyBuff);
struct ProxyData *p,*q,*head;
char *got=NULL;
bool succ=false;
head=NULL;
p=NULL;
q=NULL;
while(RegEnumKeyEx(HKEY_USERS,index,keyBuff,&dwSize,NULL,NULL,NULL,NULL)!=ERROR_NO_MORE_ITEMS)
{
printf("/nSubkey: %s",keyBuff);
//LogToFile(keyBuff);
//handle the result we have got
if((strstr(keyBuff,"DEFAULT")==NULL)&&(strstr(keyBuff,"Classes")==NULL)) //we can only find right result in de key like xxxxx-xxx,experience from my test.
{
q=(struct ProxyData *)GlobalAlloc(GMEM_ZEROINIT,sizeof(struct ProxyData));
if(q == NULL)
{
printf("/nAllo