VC Display Web page verification code, Analog CSDN Web page login

Source: Internet
Author: User

Abstract: By:koma These two days, would like to take a moment to study QQ space, the farm plug-in, so grab packet analysis of a, only a pity, in the QQ Web page when the encryption processing, unfortunately I do not have the Web programming. Some friends have said that those are through the JS code encryption, but I JS is also a blank, really apprenticeship not first die, ashamed ashamed ... In...
By:koma

These two days, originally wanted to spend a bit of time to study QQ space, farm plug-in, and then grabbed the packet analysis of a, only a pity, in the QQ Web page when the encryption processing, unfortunately I do not have the Web programming. Some friends have said that those are through the JS code encryption, but I JS is also a blank, really "apprenticeship not die first", ashamed ashamed ...

So had to pick csdn this kind of simple try to learn (for learning communication), the following is the study notes:

Program run:

1. Native environment: Windows XP SP3, ADSL

2. Development tools: WildPackets OmniPeek V5.1.4

Visual C + + 6.0

IE6.0

Flexedit V2.3.1871

3. Data package:

(QQ login, in the password 2222 encryption when the jam, I tried a lot of encryption algorithm, eventually ended in failure ...)

4, Verification code display using IStream and IPicture to display:

View Plaincopy to Clipboardprint?
/************************************************************************/ 
/* Function Description: Get the application's current directory  
/* Parameters: no  
/* Return value: Returns the directory path, CString type string  
/* By:koma 2009.10.13 11:23 
/************** / 
CString C***dlg::getexepath ()  
{  
Char pathbuf[260]; 
int pathlen =:: GetModuleFileName (null,pathbuf,260);

Replace the horizontal bar
while (TRUE)
{
if (pathbuf[pathlen--]== ' \ \ ')
Break
}
Pathbuf[++pathlen]= 0x0;
CString fname = pathbuf;
return fname;
}
/************************************************************************/
/* Function Description: Get the application's current directory
/* Parameter: None
/* Return value: Return directory path, CString type string
/* By:koma 2009.10.13 11:23
/************************************************************************/
CString C***dlg::getexepath ()
{
Char pathbuf[260];
int Pathlen =:: GetModuleFileName (null,pathbuf,260);

Replace the horizontal bar
while (TRUE)
{
if (pathbuf[pathlen--]== ' \ \ ')
Break
}
Pathbuf[++pathlen]= 0x0;
CString fname = pathbuf;
return fname;
}

View Plaincopy to Clipboardprint?
/************************************************************************/
/* Function Description: Download CAPTCHA image
/* Parameter: None
/* return value: None
/* By:koma 2009.10.13 11:50
/************************************************************************/
void C***dlg::D ownurlimage ()
{
CInternetSession session;
CString strURL;
CFile *pfile,out;
Char buff[512];
CString strpath;

Generate eight-bit random numbers to form a verification code
int nRand1 = rand ()%100000+10000;
int nRand2 = rand ()%200000+10000;

Strurl.format (");
strpath = Getexepath () + "\\test.tmp";
PFile = Session. OpenURL (strURL);
Out. Open (strpath, Cfile::modecreate | Cfile::modewrite);
while (Pfile->read (buff,512)) {
Out. Write (buff,512);
}
Out. Flush ();
Out. Close ();
}
/************************************************************************/
/* Function Description: Download CAPTCHA image
/* Parameter: None
/* return value: None
/* By:koma 2009.10.13 11:50
/************************************************************************/
void C***dlg::D ownurlimage ()
{
CInternetSession session;
CString strURL;
CFile *pfile,out;
Char buff[512];
CString strpath;

Generate eight-bit random numbers to form a verification code
int nRand1 = rand ()%100000+10000;
int nRand2 = rand ()%200000+10000;

Strurl.format (");
strpath = Getexepath () + "\\test.tmp";
PFile = Session. OpenURL (strURL);
Out. Open (strpath, Cfile::modecreate | Cfile::modewrite);
while (Pfile->read (buff,512)) {
Out. Write (buff,512);
}
Out. Flush ();
Out. Close ();
}

View Plaincopy to Clipboardprint?
/************************************************************************/
/* Function Description: show Captcha picture
/* Parameter: None
/* return value: None
/* By:koma 2009.10.13 13:12
/************************************************************************/
void C***dlg::showimage ()
{
:: CoInitialize (NULL); Initialize COM
HRESULT hr;
CFile file;
CString strpath;
CPAINTDC DC (this);

strpath = Getexepath () + "\\test.tmp";
File. Open (strpath, Cfile::moderead | Cfile::sharedenynone);

DWORD dwsize = file. GetLength ();
Hglobal Hmem =:: GlobalAlloc (Gmem_moveable, dwsize);
LPVOID lpbuf =:: GlobalLock (HMEM);

File. Readhuge (Lpbuf, dwsize);
File. Close ();
:: GlobalUnlock (HMEM);

IStream is obtained by HGLOBAL, the parameter true means releasing the IStream while releasing the memory
hr =:: CreateStreamOnHGlobal (Hmem,true,&pstream);
ASSERT (SUCCEEDED (HR));

hr =:: OleLoadPicture (PStream, dwsize, TRUE, Iid_ipicture, (LPVOID *) &ppicture);
ASSERT (HR==S_OK);

Long nwidth,nheight; Wide-height mm_himetric mode, unit 0.01 mm
Ppicture->get_width (&nwidth); Wide
Ppicture->get_height (&nheight); High

CSize sz (nwidth,nheight); Original large display
dc. HIMETRICTODP (&SZ); Convert mm_himetric mode units to mm_text pixels

Ppicture->render (Dc.m_hdc,10,100,sz.cx,sz.cy,0,nheight,nwidth,-nheight,null);
CRect rect (10,100,sz.cx + 10,sz.cy + 100);

Save the picture area so that only the picture area is refreshed later
M_picrect = rect;
if (ppicture)//release ipicture pointer
Ppicture->release ();
if (PStream)//release IStream pointer while releasing HMEM
Pstream->release ();
:: CoUninitialize ();
}
/************************************************************************/
/* Function Description: show Captcha picture
/* Parameter: None
/* return value: None
/* By:koma 2009.10.13 13:12
/************************************************************************/
void C***dlg::showimage ()
{
:: CoInitialize (NULL); Initialize COM
HRESULT hr;
CFile file;
CString strpath;
CPAINTDC DC (this);

strpath = Getexepath () + "\\test.tmp";
File. Open (strpath, Cfile::moderead | Cfile::sharedenynone);

DWORD dwsize = file. GetLength ();
Hglobal Hmem =:: GlobalAlloc (Gmem_moveable, dwsize);
LPVOID lpbuf =:: GlobalLock (HMEM);

File. Readhuge (Lpbuf, dwsize);
File. Close ();
:: GlobalUnlock (HMEM);

IStream is obtained by HGLOBAL, the parameter true means releasing the IStream while releasing the memory
hr =:: CreateStreamOnHGlobal (Hmem,true,&pstream);
ASSERT (SUCCEEDED (HR));

hr =:: OleLoadPicture (PStream, dwsize, TRUE, Iid_ipicture, (LPVOID *) &ppicture);
ASSERT (HR==S_OK);

Long nwidth,nheight; Wide-height mm_himetric mode, unit 0.01 mm
Ppicture->get_width (&nwidth); Wide
Ppicture->get_height (&nheight); High

CSize sz (nwidth,nheight); Original large display
dc. HIMETRICTODP (&SZ); Convert mm_himetric mode units to mm_text pixels

Ppicture->render (Dc.m_hdc,10,100,sz.cx,sz.cy,0,nheight,nwidth,-nheight,null);
CRect rect (10,100,sz.cx + 10,sz.cy + 100);

Save the picture area so that only the picture area is refreshed later
M_picrect = rect;
if (ppicture)//release ipicture pointer
Ppicture->release ();
if (PStream)//release IStream pointer while releasing HMEM
Pstream->release ();
:: CoUninitialize ();
}

VC Display Web page verification code, Analog CSDN Web page login

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.