lloydlabs / delete-self-poc Goto Github PK
View Code? Open in Web Editor NEWA way to delete a locked file, or current running executable, on disk.
License: MIT License
A way to delete a locked file, or current running executable, on disk.
License: MIT License
LPWSTR lpwStream = (LPWSTR)DS_STREAM_RENAME;
fRename.FileNameLength = sizeof(lpwStream);
sizeof(lpwStream) is always 8 bytes on 64-bit OS
FILE_RENAME_INFO fRename;
RtlCopyMemory(fRename.FileName, lpwStream, sizeof(lpwStream));
The FILE_RENAME_INFO.FileName buffer need to be allocated by yourself
I've compiled it with VS 2019 and tested this POC on all recent Windows versions:
PC
Server
Very strange issue here. I am implementing this as part of a larger tool and in doing testing for compatibility with x86, I have found that it fails when ran as a normal user, however succeeds when ran as an Administrator. The x64 version of course works in both medium and high integrity. This testing was done on a windows 7 VM, however I also tested the x86 version on a windows 11 VM where I encountered the same issue.
Attached is a screenshot showing the issue. Top cmd prompt is normal user, bottom is admin.
I added a GetLastError() call which returned error 123, or:
"ERROR_INVALID_NAME
123 (0x7B)
The filename, directory name, or volume label syntax is incorrect."
per MSDN. This occurs at line 26 where SetFileInformationByHandle is called.
Does anyone have any ideas here? I'd believe that there is some incompatibility issue with x86, but the fact that it suceeds as an Admin but fails as a normal user, whereas it works fine for both on x64 is throwing me for a loop.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.