In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >
Share
Shulou(Shulou.com)05/31 Report--
It is believed that many inexperienced people do not know what to do about the named pipeline of windows security. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
Recently, the school opened an operating system course to record what they learned about network security in named pipes.
About named pipes:
Named pipes, also known as named pipes (Named Pipes), is a simple interprocess communication (IPC) mechanism, and Microsoft Windows mostly provides support for it (but not Windows CE). Named pipes can support reliable, one-way or two-way data communication between different processes on the same computer or across different computers across a network. An important reason for recommending named pipes as a process communication scheme is that they take full advantage of Windows's built-in security features (ACL, etc.).
Designing cross-computer applications with named pipes is actually very simple and does not require in-depth knowledge of the underlying network transport protocols (such as TCP, UDP, IP, IPX). This is because named pipes use the Microsoft Network provider (MSNP) redirector to establish communication between processes over the same network, so that applications do not have to care about the details of the network protocol.
A named pipe is a pipe with a name that can communicate one-way or two-sided between a server and one or more clients. All instances of named pipes have the same name, but each instance has its own buffer and handle to provide separate pipes for different clients. Using an instance enables multiple pipe clients to use the same named pipe at the same time.
The name of the named pipe is unique in this system.
Named pipes can be accessed by any process that meets the permission requirements.
Named pipes can only be created locally.
The client of a named pipe can be a local process (local access:\.\ pipe\ PipeName) or a remote process (access remote:\ ServerName\ pipe\ PipeName).
Named pipe is more flexible than anonymous pipe, server and client can be any process, anonymous pipe is generally used for parent-child process communication.
List all named pipes in the computer:
In versions above powershell3, we can use the
[System.IO.Directory]:: GetFiles ("\\.\\ pipe\")
To view all the named pipes that exist on this machine, or to view them using process explorer
Creation and communication of named pipes
The communication method for naming pipes in windows is:
① create named pipe-- > ② connection named pipe-- > ③ read-write named pipe
The detailed process is as follows:
The named pipe is created by calling the function CreateNamedPipe (), and the function prototype is as follows:
HANDLE WINAPI CreateNamedPipe (_ In_ LPCTSTR lpName, _ In_ DWORD dwOpenMode, _ In_ DWORD dwPipeMode, _ In_ DWORD nMaxInstances, _ In_ DWORD nOutBufferSize, _ In_ DWORD nInBufferSize, _ In_ DWORD nDefaultTimeOut, _ In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes)
For more information, please see https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-createnamedpipea.
After the creation, the server can call the function ConnectNamedPipe () to wait for the connection request from the client. The function prototype is as follows:
BOOL WINAPI ConnectNamedPipe (_ In_ HANDLE hNamedPipe, _ Inout_opt_ LPOVERLAPPED lpOverlapped)
For more information, please see https://docs.microsoft.com/en-us/windows/win32/api/namedpipeapi/nf-namedpipeapi-connectnamedpipe.
For the client, you need to determine whether the named pipe is available before connecting to the named pipe created by the server. You can call the function WaitNamedPipe () to implement the
The function prototype is as follows:
BOOL WaitNamedPipeA (LPCSTR lpNamedPipeName, DWORD nTimeOut)
For more information, please see https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-waitnamedpipea.
When the WaitNamedPipe () call succeeds, you can use CreateFile () to open the handle to the acquired pipe.
Then the client reads and writes the named pipe using the functions ReadFile () and WriteFile (). The function prototype is as follows:
BOOL WriteFile (HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite, LPDWORD lpNumberOfBytesWritten, LPOVERLAPPED lpOverlapped); BOOL ReadFile (HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, LPDWORD lpNumberOfBytesRead, LPOVERLAPPED lpOverlapped)
For more information, please see:
WriteFile function (fileapi.h)-Win32 apps
ReadFile function (fileapi.h)-Win32 apps
Demo:
Here is a small demo for named pipe communication:
Server:
# include # include # define BUF_SIZE 1024 using namespace std; int main (int argc,char * argv []) {HANDLE hype; char rev_ buf [BUF _ SIZE]; DWORD rel_buf; h_pipe = CreateNamedPipe ("\\.\\ pipe\\ pipename", PIPE_ACCESS_INBOUND, PIPE_READMODE_BYTE | PIPE_WAIT, PIPE_UNLIMITED_INSTANCES, BUF_SIZE, BUF_SIZE, 0, nullptr); if (h_pipe = INVALID_HANDLE_VALUE) {cout
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.