Difference (last change)
(no other diffs,
normal page display)
Deleted: 54d53
This program will self-destruct after it is run.
 | import std.c.windows.windows;
import std.stdio;
import std.string;
import std.process;
extern(Windows)
{
struct SHELLEXECUTEINFO
{
DWORD cbSize;
ULONG fMask;
HWND hwnd;
LPCTSTR lpVerb;
LPCTSTR lpFile;
LPCTSTR lpParameters;
LPCTSTR lpDirectory;
int nShow;
HINSTANCE hInstApp;
LPVOID lpIDList;
LPCTSTR lpClass;
HKEY hkeyClass;
DWORD dwHotKey;
union
{
HANDLE hIcon;
HANDLE hMonitor;
}
HANDLE hProcess;
}
alias SHELLEXECUTEINFO* LPSHELLEXECUTEINFO;
bool ShellExecuteExA(LPSHELLEXECUTEINFO);
}
bool selfDestruct()
{
char[] modfname;
modfname.length = 256;
auto ns = GetModuleFileNameA(cast(HMODULE)null, &modfname[0], 256);
string modname = std.conv.to!string(modfname[0 .. ns]).strip;
string batname = getenv("TEMP")~"\\sd.bat";
auto helperbat = File(batname, "w");
helperbat.writeln(":TRY");
helperbat.writeln("PING 1.1.1.1 -n 1 -w 1000 >NUL"); //wait 1 sec
helperbat.writeln(`del "`~modname~`"`);
helperbat.writeln("IF EXIST \""~modname~"\" GOTO TRY");
helperbat.writeln("del %TEMP%\\sd.bat");
helperbat.close();
SHELLEXECUTEINFO info;
info.cbSize = SHELLEXECUTEINFO.sizeof;
info.lpVerb = "open";
info.lpFile = cast(const(char)*)batname;
info.nShow = SW_HIDE;
return ShellExecuteExA(&info);
}
int main()
{
return selfDestruct();
} |
|
|