I managed to delete "cd ..
" in a CMD Windows with <path/to/git>\latest\usr\bin
in %PATH%
. That gives me access to rm.exe
.
vonc@VONCAVN7 C:\test
> where rm
D:\prgs\git\latest\usr\bin\rm.exe
I had:
vonc@VONCAVN7 C:\test
> dir /x
Volume in drive C is test
Directory of C:\test
08/08/2017 07:11 <DIR> .
08/08/2017 07:11 <DIR> ..
08/08/2017 07:11 0 cd ..
With that, I typed:
vonc@VONCAVN7 C:\test
> rm cd*
And the file cd ..
was gone
As commented by eryksun,
rm.exe
isn't a Linux app. It uses msys-2.0.dll
, which links with Windows API functions from kernel32.dll
and native NT system calls from ntdll.dll
.
In this case it's how it bypasses the Windows API to make direct system calls that solves the problem: NtOpenFile
(open the directory to list it and the "cd ..
" file to delete it), NtQueryDirectoryFile
(list the directory), and NtSetInformationFile
(set the file's delete disposition).
As eryksun commented, the pure Windows syntax (meaning, it does not need a Git Linux-like command like rm
) would have worked too:
del "\\?\C:\test\cd .."
See "What does \\?\
mean when prepended to a file path".
That will disable all string parsing and send the string that follows it straight to the file system.