João Paul
João Paul
CC#
Created by João Paul on 4/1/2024 in #help
Named pipe connection over network error (The username or password is incorrect)
To anyone with this issue. After some grueling days of debugging and talking with microsoft techs I came to the conclusion that named pipes use the network sharing protocol from windows and also, they follow the same rules. So basically... removed password from network folders... everything worked after that.
3 replies
CC#
Created by João Paul on 4/1/2024 in #help
Named pipe connection over network error (The username or password is incorrect)
the following is the code used to create the named pipe on the server side:
// Define security descriptor for the named pipe
PipeSecurity pipeSecurity = new PipeSecurity();

var sid = new SecurityIdentifier(WellKnownSidType.WorldSid, null);
var account = (NTAccount)sid.Translate(typeof(NTAccount));

// Add an access rule allowing Everyone to connect to the pipe
pipeSecurity.AddAccessRule(new PipeAccessRule(account.ToString(), PipeAccessRights.FullControl, AccessControlType.Allow));

PipeServer = NamedPipeServerStreamConstructors.New(CurrentPipeState.PipeName, PipeDirection.InOut, -1, PipeTransmissionMode.Byte, PipeOptions.Asynchronous, 0, 0, pipeSecurity);
// Define security descriptor for the named pipe
PipeSecurity pipeSecurity = new PipeSecurity();

var sid = new SecurityIdentifier(WellKnownSidType.WorldSid, null);
var account = (NTAccount)sid.Translate(typeof(NTAccount));

// Add an access rule allowing Everyone to connect to the pipe
pipeSecurity.AddAccessRule(new PipeAccessRule(account.ToString(), PipeAccessRights.FullControl, AccessControlType.Allow));

PipeServer = NamedPipeServerStreamConstructors.New(CurrentPipeState.PipeName, PipeDirection.InOut, -1, PipeTransmissionMode.Byte, PipeOptions.Asynchronous, 0, 0, pipeSecurity);
Note, that due to using a .Net framework version which lacked the native constructor, I had to use a plugin that copied the constructor that took pipeSecurity as an argument from another version. This should not change anything since the code is the same, but it explains the different naming for the initialization. The client pipe is created with the following code:
CoreEventPipeWrapper = new CoreControlEventNamedPipeWrapper("CorePipe", CoreControlEventNamedPipeWrapper.Type.CLIENT);
CoreEventPipeWrapper.CurrentPipeState.OriginMachineName = CoreClientName;
CoreEventPipeWrapper.OnClientConnected += onCoreClientConnection;
Task.Run(() => CoreEventPipeWrapper.Connect<CoreControlEvent>(CoreServerIp));


The wrapper being used just "hides" the marshalling of data and uses

PipeClient = new NamedPipeClientStream(serverName, CurrentPipeState.PipeName, PipeDirection.InOut, PipeOptions.Asynchronous);
CoreEventPipeWrapper = new CoreControlEventNamedPipeWrapper("CorePipe", CoreControlEventNamedPipeWrapper.Type.CLIENT);
CoreEventPipeWrapper.CurrentPipeState.OriginMachineName = CoreClientName;
CoreEventPipeWrapper.OnClientConnected += onCoreClientConnection;
Task.Run(() => CoreEventPipeWrapper.Connect<CoreControlEvent>(CoreServerIp));


The wrapper being used just "hides" the marshalling of data and uses

PipeClient = new NamedPipeClientStream(serverName, CurrentPipeState.PipeName, PipeDirection.InOut, PipeOptions.Asynchronous);
for the connection
3 replies
CC#
Created by João Paul on 3/25/2024 in #help
✅ Running cmd line command via c# not working
the /k worked. Thanks a lot 😄
4 replies