Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

C# 

Dropping Then Deleting File

Hello i've asked for help before but now i need help on how to drop a dll file that it gets from a web server or smth in a temp folder and after the program closes they get deleted!

Thanks in advance

// Holocaust 🤝
Perform your cleanup in an OnClosing/ProcessExit event. Only problem is this won't fire if the process is killed or suspended manually.
(Mar 13, 2016 04:35 AM)Odus Wrote:  Perform your cleanup in an OnClosing/ProcessExit event. Only problem is this won't fire if the process is killed or suspended manually.

okok but the program is going to close when the dll gets injected!

do you have any idea of how i may drop it in a temp folder?

// Holocaust 🤝
(Mar 13, 2016 04:35 AM)Odus Wrote:  Perform your cleanup in an OnClosing/ProcessExit event. Only problem is this won't fire if the process is killed or suspended manually.

Yep. So check to see if the file exists when the program is run again.
(Mar 13, 2016 04:35 AM)Odus Wrote:  Perform your cleanup in an OnClosing/ProcessExit event. Only problem is this won't fire if the process is killed or suspended manually.

WaitForExit would probably be better because it just waits until the process is terminated.


Code
string dumpPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Temp", Guid.NewGuid().ToString("N") + ".exe");
//Drop to dumpPath
Process p = Process.Start(dumpPath);
p.WaitForExit();
File.Delete(dumpPath);
Lotta blood to let, peace to make, give a fuk about a check
(Mar 13, 2016 04:50 AM)BahNahNah Wrote:  WaitForExit would probably be better because it just waits until the process is terminated.

If the child process is terminated then yes, but wasn't OP wanting to delete when the parent process ends?
(Mar 13, 2016 06:35 AM)Odus Wrote:  If the child process is terminated then yes, but wasn't OP wanting to delete when the parent process ends?

i want it to put my dll file in a temp folder and inject it and after injection it will close and the dll will get deleted 😖
If a process has loaded a .dll with LoadLibrary you won't be able to remove that .dll from the file system because it is in use, if that's what you're asking.
You can delete the injector, sure, but you won't be able to remove the dll.


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C#] by JoseCmanXDIIMay 7, 2022 03:50 PM 10 276 May 7, 2022 03:50 PM
Last Post: JoseCmanXDII
[Python] by xx1ben99xxOct 17, 2016 04:05 PM 3 104 Oct 17, 2016 04:05 PM
Last Post: bytez
[.NET] by Tha SneakApr 16, 2015 02:57 PM 5 168 Apr 16, 2015 02:57 PM
Last Post: Zyklon A