Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

finlandia:~> apropos win win: nothing appropriate.


devel / comp.security.ssh / Re: Error output may not be obtained when executing a command with plink

SubjectAuthor
* Error output may not be obtained when executing a command with plinkozawa01 jins
`- Re: Error output may not be obtained when executing a command with plinkozawa01 jins

1
Error output may not be obtained when executing a command with plink

<cb91d831-1d0b-4331-82d9-a8c8d6d5e3a2n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=245&group=comp.security.ssh#245

  copy link   Newsgroups: comp.security.ssh
X-Forwarded-Encrypted: i=1; AJvYcCVNEX8rXgaPExSopUncNGbakQHoFeuJJAwbQC+LdKHsQ/Lxa7y2slfFnelfEv2swPZ//sMMMMfGtBBQnzEF3Tr0tdEJtlFnOMyBy5mu3iGa8gPuHGd4Ww==
X-Received: by 2002:a05:622a:2287:b0:42c:7cba:a1a with SMTP id ay7-20020a05622a228700b0042c7cba0a1amr83079qtb.9.1707889505695;
Tue, 13 Feb 2024 21:45:05 -0800 (PST)
X-Forwarded-Encrypted: i=1; AJvYcCV+dONdOq3FS36b5uje9UsHa1bHT450vi6gltDH9IHauLSa8Xg+cFEMKJAZsKYP8XCd+bSMbtIgLnSlPDLhNfY8pjPErMT7h/DPhpq+lDW/oogeLA==
X-Received: by 2002:a4a:d0d2:0:b0:59a:8e50:f761 with SMTP id
u18-20020a4ad0d2000000b0059a8e50f761mr79966oor.1.1707889505481; Tue, 13 Feb
2024 21:45:05 -0800 (PST)
Path: i2pn2.org!i2pn.org!news.swapon.de!news.mixmin.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.security.ssh
Date: Tue, 13 Feb 2024 21:45:05 -0800 (PST)
Injection-Info: google-groups.googlegroups.com; posting-host=114.179.20.136; posting-account=rK1rvwoAAAB-RToWaE9B_Nq3adn8bgEk
NNTP-Posting-Host: 114.179.20.136
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <cb91d831-1d0b-4331-82d9-a8c8d6d5e3a2n@googlegroups.com>
Subject: Error output may not be obtained when executing a command with plink
From: jinsozawa01@gmail.com (ozawa01 jins)
Injection-Date: Wed, 14 Feb 2024 05:45:05 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: ozawa01 jins - Wed, 14 Feb 2024 05:45 UTC

Hello,

For example, when you specify a path that does not exist with the ls command, plink will terminate without displaying the error output until the end.
Also, at this time, plink's exit code is returned as 0.

It doesn't always happen, but it has a high probability.

For details, please check the 「■Log when occurs」and「■Log when it does not occur」 below.

This problem seems to occur from plink version 0.77 or later.
It doesn't happen in 0.76.

Has anyone encountered the same phenomenon?

Thanks.

■plink version
plink: Release 0.80
Build platform: 64-bit x86 Windows
Compiler: clang 14.0.0 , emulating Visual Studio 2022 (17.2), _MSC_VER=1932, _MSC_FULL_VER=193231329
Source commit: c96fb0f10a4266513f8ebd3781550dac387d1dd1

■Running OS version
Windows Server 2019 Standard

■Connecting protocol
SSH

■Connecting server
I tried the following two types

・Red Hat Enterprise Linux release 8.1 (Ootpa)
・Red Hat Enterprise Linux release 9.1 (Plow)

■Log when occurs
D:\work\putty>plink.exe root@xxx.xxx.xxx.xxx -pw "xxxxx" -P 22 -v -no-antispoof "ls NotExistsDierectory"
Looking up host "xxx.xxx.xxx.xxx" for SSH connection
Connecting to xxx.xxx.xxx.xxx port 22
We claim version: SSH-2.0-PuTTY_Release_0.80
Connected to xxx.xxx.xxx.xxx
Remote version: SSH-2.0-OpenSSH_8.7
Using SSH protocol version 2
No GSSAPI security context available
Doing ECDH key exchange with curve Curve25519, using hash SHA-256 (unaccelerated)
Server also has ecdsa-sha2-nistp256/rsa-sha2-512/rsa-sha2-256 host keys, but we don't know any of them
Host key fingerprint is:
ssh-ed25519 255 SHA256:wcNJXRAyMFZZHBaDsju5qovDY4VnvbJhqTFKZPHSFlI
The host key is not cached for this server:
xxx.xxx.xxx.xxx (port 22)
You have no guarantee that the server is the computer you
think it is.
The server's ssh-ed25519 key fingerprint is:
ssh-ed25519 255 SHA256:wcNJXRAyMFZZHBaDsju5qovDY4VnvbJhqTFKZPHSFlI
If you trust this host, enter "y" to add the key to Plink's
cache and carry on connecting.
If you want to carry on connecting just once, without adding
the key to the cache, enter "n".
If you do not trust this host, press Return to abandon the
connection.
Store key in cache? (y/n, Return cancels connection, i for more info) n
Initialised AES-256 SDCTR (AES-NI accelerated) outbound encryption
Initialised HMAC-SHA-256 (unaccelerated) outbound MAC algorithm
Initialised AES-256 SDCTR (AES-NI accelerated) inbound encryption
Initialised HMAC-SHA-256 (unaccelerated) inbound MAC algorithm
Using username "root".
Using SSPI from SECUR32.DLL
Trying gssapi-with-mic...
Attempting GSSAPI authentication
GSSAPI authentication request refused
Sent password
Access granted
Opening main session channel
Opened main channel
Started a shell/command
ls: c

D:\work\putty>echo %errorlevel%
0

■Log when it does not occur
D:\work\putty>plink.exe root@xxx.xxx.xxx.xxx -pw xxxxx -P 22 -v -no-antispoof "Is Not ExistsDierectory"
Looking up host "xxx.xxx.xxx.xxx" for SSH connection
Connecting to xxx.xxx.xxx.xxx port 22
Connected to xxx.xxx.xxx.xxx
We claim version: SSH-2.0-PuTTY_Release_0.80
Remote version: SSH-2.0-OpenSSH_8.7
Using SSH protocol version 2
No GSSAPI security context available
Doing ECDH key exchange with curve Curve25519, using hash SHA-256 (unaccelerated)
Server also has ecdsa-sha2-nistp256/rsa-sha2-512/rsa-sha2-256 host keys, but we don't know any of them
Host key fingerprint is:
ssh-ed25519 255 SHA256:wcNJXRAyMFZZHBaDsju5qovDY4VnvbJhqTFKZPHSFlI
The host key is not cached for this server:
xxx.xxx.xxx.xxx (port 22)
You have no guarantee that the server is the computer you
think it is.
The server's ssh-ed25519 key fingerprint is:
ssh-ed25519 255 SHA256:wcNJXRAyMFZZHBaDsju5qovDY4VnvbJhqTFKZPHSFlI
If you trust this host, enter "y" to add the key to Plink's
cache and carry on connecting.
If you want to carry on connecting just once, without adding
the key to the cache, enter "n".
If you do not trust this host, press Return to abandon the
connection.
Store key in cache? (y/n, Return cancels connection, i for more info) n
Initialised AES-256 SDCTR (AES-NI accelerated) outbound encryption
Initialised HMAC-SHA-256 (unaccelerated) outbound MAC algorithm
Initialised AES-256 SDCTR (AES-NI accelerated) inbound encryption
Initialised HMAC-SHA-256 (unaccelerated) inbound MAC algorithm
Using username "root".
Using SSPI from SECUR32.DLL
Trying gssapi-with-mic...
Attempting GSSAPI authentication
GSSAPI authentication request refused
Sent password
Access granted
Opening main session channel
Opened main channel
Started a shell/command
ls: cannot access 'NotExistsDierectory': No such file or directory
Session sent command exit status 2

D:\work\putty>echo %errorlevel%
2

Re: Error output may not be obtained when executing a command with plink

<8515f0e0-616f-449d-ad22-2ee9614bfc8dn@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=246&group=comp.security.ssh#246

  copy link   Newsgroups: comp.security.ssh
X-Forwarded-Encrypted: i=1; AJvYcCWImYN7X75K8Di6wMjj30oKM9mNp57WvzbdpRj+MOH1B9avBEdDH8r7uWtYdyAhEyJM2aic0taAt88vJk5LU6Fcr7lDLQtU+6Nq0AyzjiYPTOS52v7B
X-Received: by 2002:a05:6214:f66:b0:68f:5fe8:9e92 with SMTP id iy6-20020a0562140f6600b0068f5fe89e92mr340593qvb.4.1708321659006;
Sun, 18 Feb 2024 21:47:39 -0800 (PST)
X-Forwarded-Encrypted: i=1; AJvYcCWPadiXwJzK449sJAt8klRIsNjBab/ScvVS70IKA8b3s4H+3uGPIROh/R03db5jbxa0GWWAeZGVl2/VVti+rCMxhHDFIxxE1P6XKQPN/kAxNnKnkQ==
X-Received: by 2002:a05:6871:79a:b0:210:9b29:fbac with SMTP id
o26-20020a056871079a00b002109b29fbacmr463204oap.9.1708321658794; Sun, 18 Feb
2024 21:47:38 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!3.us.feeder.erje.net!feeder.erje.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.security.ssh
Date: Sun, 18 Feb 2024 21:47:38 -0800 (PST)
In-Reply-To: <cb91d831-1d0b-4331-82d9-a8c8d6d5e3a2n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=114.179.20.136; posting-account=rK1rvwoAAAB-RToWaE9B_Nq3adn8bgEk
NNTP-Posting-Host: 114.179.20.136
References: <cb91d831-1d0b-4331-82d9-a8c8d6d5e3a2n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <8515f0e0-616f-449d-ad22-2ee9614bfc8dn@googlegroups.com>
Subject: Re: Error output may not be obtained when executing a command with plink
From: jinsozawa01@gmail.com (ozawa01 jins)
Injection-Date: Mon, 19 Feb 2024 05:47:39 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2359
 by: ozawa01 jins - Mon, 19 Feb 2024 05:47 UTC

I don't know if it's the correct fix, but after making the following fix, the problem no longer occurs.

putty-src\windows\handle-io.c
>static void handle_try_output(struct handle_output *ctx)
>{
> if (!ctx->busy && bufchain_size(&ctx->queued_data)) {
> ptrlen data = bufchain_prefix(&ctx->queued_data);
> ctx->buffer = data.ptr;
> ctx->len = min(data.len, ~(DWORD)0);
> SetEvent(ctx->ev_from_main);
> ctx->busy = true;
> } else if (!ctx->busy && bufchain_size(&ctx->queued_data) == 0 &&
> ctx->outgoingeof == EOF_PENDING) {
> // comment out
> //ctx->sentdata(ctx->sentdata_param, 0, 0, true);
>
> // Add here. I have copied the processing from the same method in Putty v0.76.
> CloseHandle(ctx->h);
> ctx->h = INVALID_HANDLE_VALUE;
> ctx->outgoingeof = EOF_SENT;
> }
>}

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor