SELF DESTRUCTION OF (.EXE)
Heres your chance to share your own tutorials with the community. Just post them on here. If your lucky they may even be posted on the main site.
10 posts
Page 1 of 1
before i came up with this tutorial, i wondered how to self destruct an exe file after a given
span of time. when you have a software like parental control you can have an option saying-
"SELF DESTROY ON" and a textbox to provide a date. the end date will be the destruction date
of the file and the beginning date is where when you have activated it. SELF DESTRUCTION OF
EXE FILE IS VERY IMPORTANT FOR SOME REASONS.
so let's start:
create: one BUTTON, ONE LABEL AND A TIMER
below Form1 (public class form1) add this code:======================
dont use the product name, because if the user change the name of the exe file the batch
file cant find it anymore (this function is very important in order for the batch file
to locate the current exe file that is renamed
the timer will stop when it reach the given time and create a batch file , the batch file
will start immediately, kill the current process using cmd, and delete the exe file
as soon as the exe file is deleted the batch file will delete itself.
============that's it =====================================
so the FULL CODE WILL BE LIKE THIS:
span of time. when you have a software like parental control you can have an option saying-
"SELF DESTROY ON" and a textbox to provide a date. the end date will be the destruction date
of the file and the beginning date is where when you have activated it. SELF DESTRUCTION OF
EXE FILE IS VERY IMPORTANT FOR SOME REASONS.
so let's start:
create: one BUTTON, ONE LABEL AND A TIMER
below Form1 (public class form1) add this code:======================
Code: Select all
create a function to get the current running .exe name :================ Dim timelimit As Integer = 10 'set the time for countdown
dont use the product name, because if the user change the name of the exe file the batch
file cant find it anymore (this function is very important in order for the batch file
to locate the current exe file that is renamed
Code: Select all
on button.click add this code:==============
Private Function getfilename(ByVal path As String, ByVal b As String) As String
Dim word As String = path
Dim label As String = b
Dim lines() As String = word.Split("\")
For Each line As String In lines
If line.ToLower.Contains(".exe") Then
label = line
End If
Next
Return label
End Function
Code: Select all
on the timer, add this code================ Timer1.Start() 'interval is= 1000
the timer will stop when it reach the given time and create a batch file , the batch file
will start immediately, kill the current process using cmd, and delete the exe file
as soon as the exe file is deleted the batch file will delete itself.
Code: Select all
timelimit -= 1
Label1.Text = "TIME LEFT IN SECONDS: " & timelimit
If timelimit <= 0 Then
Timer1.Stop()
Dim filename As String = getfilename(Application.ExecutablePath, "true")
Dim f2delet As String = Application.ExecutablePath 'the full path of exe file
Dim sb As New System.Text.StringBuilder ' string bulider=- to build the text and save as batch file
sb.AppendLine("@echo off")
sb.AppendLine(":Begin")
sb.AppendLine("taskkill /f /im """ & filename & "") 'kill the exe file when its running
sb.AppendLine("del /s /q " & """" & f2delet & """") 'force delete the exe file based on the full path
sb.AppendLine("if exist " & """" & f2delet & """" & " goto :begin") ' if not deleted then go back- this is infinate
sb.AppendLine("DEL ""%~f0""") 'enable the batch file to delete itself after it delete the exe file
IO.File.WriteAllText(Application.StartupPath & "\selfdelete.bat", sb.ToString())
Process.Start(Application.StartupPath & "\selfdelete.bat")
End If
============that's it =====================================
so the FULL CODE WILL BE LIKE THIS:
Code: Select all
HERE'S THE SAMPLE EXE :::
HERE'S THE FULL PROJECT:::
Public Class Form1
Dim timelimit As Integer = 10 'set the time for countdown
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
timelimit -= 1
Label1.Text = "TIME LEFT IN SECONDS: " & timelimit
If timelimit <= 0 Then
Timer1.Stop()
' function to get the filename from executable path, even if the user change the name of exe file it will still be deleted soon
Dim filename As String = getfilename(Application.ExecutablePath, "true")
Dim f2delet As String = Application.ExecutablePath 'the full path of exe file
Dim sb As New System.Text.StringBuilder ' string bulider=- to build the text and save as batch file
sb.AppendLine("@echo off")
sb.AppendLine(":Begin")
sb.AppendLine("taskkill /f /im """ & filename & "") 'kill the exe file when its running
sb.AppendLine("del /s /q " & """" & f2delet & """") 'force delete the exe file based on the full path
sb.AppendLine("if exist " & """" & f2delet & """" & " goto :begin") ' if not deleted then go back- this is infinate
sb.AppendLine("DEL ""%~f0""") 'enable the batch file to delete itself after it delete the exe file
IO.File.WriteAllText(Application.StartupPath & "\selfdelete.bat", sb.ToString())
Process.Start(Application.StartupPath & "\selfdelete.bat")
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Timer1.Start() 'interval is= 1000
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
'function to get the filename from of the current exe file- dont use the product name, because if the user change the name
'of the exe file the batch file cant find it anymore (this function is very important in order for the batch file
'to locate the current exe file that is renamed
Private Function getfilename(ByVal path As String, ByVal b As String) As String
Dim word As String = path
Dim label As String = b
Dim lines() As String = word.Split("\")
For Each line As String In lines
If line.ToLower.Contains(".exe") Then
label = line
End If
Next
Return label
End Function
End Class
You do not have the required permissions to view the files attached to this post.
Interesting tutorial +rep
What use would there be in destroying itself though?
What use would there be in destroying itself though?
My name is Tom | Visit my blog where I post new content every day! Tom's Daily Blog | MineCraft is awesome!
Thank you for the rep.
#smashapps , it's useful when you make an app like K****ger / pc monitoring software.
#smashapps , it's useful when you make an app like K****ger / pc monitoring software.
It's also useful for RATs and other hacking tools where you want to remove the program and evidence.
* Disclaimer, this ^ is all illegal :P *
* Disclaimer, this ^ is all illegal :P *
We shall let the revolution begin.. the revolution for freedom, freedom against censorship. We shall fight in the fields and in the streets, we shall fight in the hills; we shall never surrender
Thanks #noypikami and #Codex
My name is Tom | Visit my blog where I post new content every day! Tom's Daily Blog | MineCraft is awesome!
Besides just hacking tools, you can inquire this in Updating your application or performing other functions inside of the batch file itself ya know? A very well written tutorial my dear sir.
#Codex a RAT ain't illegal to have installed on a computer or a server you own it's only illegal to have on someone else's computer doing malicious stuff
you could have a program that removes itself when the computer is rebooted then when it's restarted it could be reprogrammed to start a newer version of the program from a dropbox.
you could have a program that removes itself when the computer is rebooted then when it's restarted it could be reprogrammed to start a newer version of the program from a dropbox.
#benji_19994 that's true, but a RAT is usually associated with criminal or malicious activity. There are some legitimate uses to it, but it's less likely that case in most of the RATs.
We shall let the revolution begin.. the revolution for freedom, freedom against censorship. We shall fight in the fields and in the streets, we shall fight in the hills; we shall never surrender
Codex wrote:#benji_19994 that's true, but a RAT is usually associated with criminal or malicious activity. There are some legitimate uses to it, but it's less likely that case in most of the RATs.BTW It was introduced for parenting purposes and network administrating purposes.
Find my programs on Softpedia
10 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023