OpenSSH on Cygwin: directory...

- AV AC AU C I A
发布: 2025-04-13
修订: 2025-04-13

Portable OpenSSH supports running on Cygwin. However, the SFTP client only filters out forward slashes (in `do_lsreaddir()`) and the directory names "." and ".." (in `download_dir_internal()`). On Windows, including in Cygwin, backslashes can also be used for directory traversal. To reproduce: On the server: Patch OpenSSH like this, then build it: ``` --- openssh-7.4p1/sftp-server.c 2016-12-18 20:59:41.000000000 -0800 +++ openssh-7.4p1-patched/sftp-server.c 2016-12-20 15:55:34.980000300 -0800 @@ -1065,10 +1065,11 @@ strcmp(path, "/") ? "/" : "", dp->d_name); if (lstat(pathname, &st) < 0) continue; stat_to_attrib(&st, &(stats[count].attrib)); stats[count].name = xstrdup(dp->d_name); +for (i=0; i<strlen(stats[count].name); i++) if (stats[count].name[i] == '#') stats[count].name[i] = '\\'; stats[count].long_name = ls_file(dp->d_name, &st, 0, 0); count++; /* send up to 100 entries in one message */ /* XXX check packet size instead */ if (count == 100) ``` Ensure that an OpenSSH server...

0%
暂无可用Exp或PoC
当前有0条受影响产品信息