GoHacking.com: Ethical Hacking and Cyber Security
Home » C SOURCE CODES

A Self Destructing Program in C

Submitted by on Saturday, 1 March 200823 Comments

This program will destroy itself upon execution. The program will cause the .exe file to be deleted upon execution. That is this program is capable of destroying itself upon execution. Here is the code
 

 
#include<stdio.h>
#include<conio.h>
#include<dos.h>
void main()
{
printf(“This program will destroy itself if u press any key!!!\n”);
getch();
remove(_argv[0]);/*array of pointers to command line arguments*/
}
 

HOW TO COMPILE ?

Load the source code to the compiler and compile (press Alt-F9) and then press F9. This will generate the .exe file in the current directory (Bin directory). Execute this .exe file it will destroy itself upon execution.

Popularity: 2% [?]


Subscribe to GoHacking.Com


Enjoyed this article?
Subscribe to GoHacking.Com and get daily updates in your email for free


  By using/following this site you agree to our Legal Disclaimer

23 Comments »

  • anarghya said:

    i donot understand remove(_argv[0])

  • Srikanth (author) said:

    Whenever we run any program the element _argv[0] (array of ptrs to command line arguments) contains the name of the program itself.For eg: If we are running a program(.exe file) whose name is “sample.exe” then the _argv[0] would contain this name.That is why we are passing _argv[0](nothing but the name of the program) as an argument to remove() function which will delete itsef eventually

  • Anonymous said:

    hi,
    i am bharadwaj and i want to destroy orkut account with a simple program is there any posibility pls

    check it

  • Srikanth (author) said:

    @ Bharadwaj

    Are you joking? It’s not possible yaar…

  • josh said:

    i didn’t get it. do i need to copy and paste this code and save in any format . will i be runnig it later or wat?????? pls help me m confused
    Pls reply ASAP

  • Srikanth (author) said:

    @ josh

    Copy and paste the code to a notepad. Rename the extension from .txt to .C, now compile it to get an executable(.exe file). Now if you execute/run this file it’ll destroy itself upon execution.

  • abhishek said:

    hi frnd………from which website,i can free download jdk1.6.0_02????????

  • Srikanth (author) said:

    @ abhishek

    You can download it from sun microsystem’s site… or search it on google.

  • Atinder said:

    Mr.srikanth….er!!!rather Mr. bardwaj it is possible to delete orkut account u wish after having access…this cat be done easily by making a trojan …bypassing firewall….stealing data frm secure connection…not easy man…keep learning…and ur space filler…its beaten…kaspersky don’t let it execute if self defence is enabled…one thing more…a virus must be self replicating thus urs is only a mere pro….for more info ….read von nuemans self replication….keep it up man….njoy life

  • Yasir Ali said:

    nice Shot SRIKANTH……io like ur work.i am beginer.and i m very Glad that u r helping others.Keep It up.my Prayers r with u.

  • rexter said:

    hello srikanth….
    would u plz submit a c coading that will delete a file(any extention) in my hard disk…
    thnx…

  • dr.xhacker said:

    Use of a program like this?

    Like your site its self destructive

  • Chris said:

    You’ve done a great job dude..

  • vipan said:

    whats command line argument ??
    srikanth

  • Ayush said:

    Nice one….

  • Tirtharaj said:

    stdio.h is the header file in the above program

  • Tharun said:

    hi,Im just a 12th standard student.I am impressed of your blog.I want to know more about computers and the ways of hacking…just to prevent getting hacked.i want to know more about you.plz contact me.Suggest me for future studies.

  • Abir said:

    I like ur posts@the author..Go ahead and give some real things..

  • Asdf said:

    You could add this to the end of the space eater program and get rid of the warnings and it would be a great security tool.

  • jatinder bhola said:

    hey Srikanth, i’m a btech student of cse trade…..i knw c++ but only in therotical way. i lov programming…..
    i need a way to learn how we communicate wid h\w using c n many more ,so want a bound of u pls contact me
    i’ll wait 4 ur response
    guide me Srikanth ………….
    u’r luking interesting ……..

  • GamingGarage said:

    wow man nice program really..i will try this in my college systems :p

  • dantalian said:

    its a simple logic…dude

  • Murali krishna said:

    hmm its good
    can u write the java program without main function and print a message on the screen
    if it is possible please post the code in this blog

Leave your response!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.