Click here to Skip to main content
15,891,375 members
Articles / Desktop Programming / MFC

Driver to Hide Processes and Files

, ,
Rate me:
Please Sign up or sign in to vote.
4.57/5 (145 votes)
17 Aug 2009CPOL12 min read 658.3K   28.6K   369  
In this article, we describe the driver we created to hide processes and files in a system.
#include "WildCardsTest.h"
#include <boost/test/test_tools.hpp>

#include "WildCards.h"
#include <iostream>

namespace UnitTest
{
struct Mask
{
    wchar_t* mask;
    bool result[10];
};
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
wchar_t* target[10]={        L"C:\\A.A",      L"test.exe",   L"world.html",     L"h.exe",      L"readme",       L".err",     L"test3.exe",    L"text.txt", L"helloworld.txt", L"closeme"};
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//                          |             |               |               |               |               |               |               |               |               |               |
Mask mask0   ={ L"*.*",     {   true,          true,           true,            true,           false,         true,           true,           true,           true,          false       }};
//                          |             |               |               |               |               |               |               |               |               |               |
Mask mask1   ={ L"*.txt",   {   false,         false,          false,           false,          false,         false,          false,          true,           true,          false       }};
//                          |             |               |               |               |               |               |               |               |               |               |
Mask mask2   ={ L"*.exe",   {   false,         true,           false,           true,           false,         false,          true,           false,          false,         false       }};
//                          |             |               |               |               |               |               |               |               |               |               |
Mask mask3   ={ L"*.html",  {   false,         false,          true,            false,          false,         false,          false,          false,          false,         false       }};
//                          |             |               |               |               |               |               |               |               |               |               |
Mask mask4   ={ L"test.*",  {   false,         true,           false,           false,          false,         false,          false,          false,          false,         false       }};
//                          |             |               |               |               |               |               |               |               |               |               |
Mask mask5   ={ L"test?.*", {   false,         false,          false,           false,          false,         false,          true,           false,          false,         false       }};
//                          |             |               |               |               |               |               |               |               |               |               |
Mask mask6   ={ L"r**",     {   false,         false,          false,           false,          true,          false,          false,          false,          false,         false       }};
//                          |             |               |               |               |               |               |               |               |               |               |
Mask mask7   ={ L".??r",    {   false,         false,          false,           false,          false,         true,           false,          false,          false,         false       }};
//                          |             |               |               |               |               |               |               |               |               |               |
Mask mask8   ={ L"*",       {   true,          true,           true,            true,           true,          true,           true,           true,           true,          true        }};
//                          |             |               |               |               |               |               |               |               |               |               |
Mask mask9   ={ L"h?l?o?o*",{   false,         false,          false,           false,          false,         false,          false,          false,          true,          false       }};
//                          |             |               |               |               |               |               |               |               |               |               |
Mask mask10  ={ L"C:\\*",   {   true,          false,          false,           false,          false,         false,          false,          false,          false,         false       }};
//                          |             |               |               |               |               |               |               |               |               |               |
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

void FormatError(wchar_t* mask,wchar_t* target, bool expectedResult)
{
    std::wstring error = L"Error mask not correct. Mask: \"";
    error += mask;
    error += L"\" Target: \"";
    error += target;
    error += L"\" Expected Result: ";
    error += expectedResult?L"true":L"false";
    error += L"\n";

    std::wcout << error.c_str();
    BOOST_CHECK_MESSAGE(false,"");
}
void TestImpl(wchar_t* maskIn,bool* resultIn)
{
    // Loop for enumerating targets
    for( size_t i = 0 ; i<10 ; ++i )
    {
        bool res = utils::ApplyWildCards(maskIn,target[i]);
        if( res != resultIn[i] )
            FormatError(maskIn,target[i],resultIn[i]);
    }
}
void WildCardsTestByTrustedResult()
{ 
    TestImpl(mask0.mask,mask0.result);
    TestImpl(mask1.mask,mask1.result);
    TestImpl(mask2.mask,mask2.result);
    TestImpl(mask3.mask,mask3.result);
    TestImpl(mask4.mask,mask4.result);
    TestImpl(mask5.mask,mask5.result);
    TestImpl(mask6.mask,mask6.result);
    TestImpl(mask7.mask,mask7.result);
    TestImpl(mask8.mask,mask8.result);
	TestImpl(mask9.mask,mask9.result);
	TestImpl(mask10.mask,mask10.result);
}
}//namespace UnitTest

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Chief Technology Officer Apriorit Inc.
United States United States
ApriorIT is a software research and development company specializing in cybersecurity and data management technology engineering. We work for a broad range of clients from Fortune 500 technology leaders to small innovative startups building unique solutions.

As Apriorit offers integrated research&development services for the software projects in such areas as endpoint security, network security, data security, embedded Systems, and virtualization, we have strong kernel and driver development skills, huge system programming expertise, and are reals fans of research projects.

Our specialty is reverse engineering, we apply it for security testing and security-related projects.

A separate department of Apriorit works on large-scale business SaaS solutions, handling tasks from business analysis, data architecture design, and web development to performance optimization and DevOps.

Official site: https://www.apriorit.com
Clutch profile: https://clutch.co/profile/apriorit
This is a Organisation

33 members

Written By
Software Developer Codedgers Inc
Ukraine Ukraine
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Written By
Software Developer (Junior) ApriorIT
Ukraine Ukraine
Sergey Popenko.
22 years old.
The Driver Team`s software developer.
Master of the Applied Math faculty, the Dnipropetrovsk National University, Ukraine.

Comments and Discussions