Build your own security tools

So you have read tons of tutorials, guides, FAQ’s and you have some kind of image of what computer security is. The next logical step that you should make is to start learning a programming language. I’m not going to describe each language ( its advantages and disadvantages ). Instead I will focus on just one language: Perl (Practical Extraction and Reporting Language).

This language was written for manipulating text, but it has become one of the best languages available to programmers. You can write games, web applications and about everything you can think of. I want to show you just how easy it is to write some security tools using Perl.

I’m going to start with a port scanner. For those of you that don’t know what a port scanner is, here is a little definition: a port scanner is a program that checks if a certain port is open (by connecting to it).

I. The port scanner

# scanner.pl
use strict;
use warnings;
use IO::Socket;
$|++;
my($host,$a,$b)=@ARGV;
map { my $s=IO::Socket::INET->new(PeerAddr=>$host,PeerPort=>$_);
print "$_ - openn" if $s } ($a..$b);

That my friends is a very simple port scanner! You can run it from your command line (command prompt in windows or konsole in linux) like this:

perl scanner.pl host_to_scan starting_port ending_port

II. The brute forcer

Perhaps you gained access to some computers, or you’re just testing a password to see how strong it is. One of the most used encryption method is the md5 algorithm (it’s also the one used by the Linux/Unix/BSD Operating System).

The md5 hash (that’s the name a password gets after it’s being encrypted) cannot be transformed back to its corresponding word. Let me give you an example: the word “security” after its md5 encryption will become the hash e91e6348157868de9dd8b25c81aebfb9.

Let’s say you have the hash and you find out what word it is. You would have to find a way to decrypt it, which isn’t possible because md5 cannot be decrypted. So that leaves you with the question: so how can I find out what word does a hash represent? Well, since you can’t decrypt it, why not try encrypting words and see if the resulting hash matches the hash we’re trying to crack?

Here’s the perl code that does that:

# brute.pl
use strict;
use warnings;
use Digest::MD5 qw(md5_hex);
my $hash=shift || die "Give me a hash to crackn";
my $file=shift || die "Give me a dictionary filen";
open(F,$file) || die "can't open the filen";
while(<F>)
{
print "Processing $_";
chomp($_);
my $t=md5_hex($_);
print " $tn";
die "Found it -> $_n" if($t eq $hash);
}

Here’s how you run it :

perl brute.pl md5_hash_to_crack text_file

So you would have to supply it with an md5 hash and a dictionary file (that has words in it, one per line). The script will read each of the words, encrypt it and check if the hash matches the hash we’re trying to crack. If it does, we found the word :) !

This concludes the first part of building your own security tools. Next time we’ll talk about creating a bot and keeping track of your filesystem.

All these articles are for educational purposes. The author is not in any way responsible for your actions.

Related posts:

  1. Google Hacking: Ten Simple Security Searches That Work
  2. Online PDF conversion tools
  3. Optical mouse into a Scanner
  4. ICICI Mobile Banking application security analysis
  5. Secure PHP Programming!

Tags: ,

14 Responses to “Build your own security tools”

  1. ravi sharma 24. Dec, 2006 at 11:12 am #

    i found usefull information in this site.

    thanx,
    Ravi Sharma

  2. MetLife 21. Jan, 2007 at 10:31 pm #

    Lovely. Made my day (which is saying something)

  3. femi 11. Mar, 2007 at 10:11 pm #

    this is a very nice place ..i guess..

  4. sonu 06. Apr, 2007 at 5:50 am #

    thnx.really this solves my problem

  5. phentermine online pharmacy 07. Jun, 2007 at 5:07 pm #

    I like the way you set up that your info is the homepage, nicely done. Thanks!

  6. [fazed] 05. Jul, 2007 at 7:31 pm #

    I think its a funny tutorial for a few reasons:
    1) That port scanner is set at the default port timeout
    which would mean that it would take ages to actually complete
    a port scan
    2) That is not a brute forcer. A brute forcer goes through every possible
    combinations of the given character set, what you have created
    in nothing more than your simple md5 DICTIONARY cracker
    which can be done in 4 lines of python code.

    apart from that.. not bad i guess.. but only because it
    attempts to explain what is going on..

  7. Canon HG10 29. Feb, 2008 at 8:20 pm #

    wow… so useful information thank you very much ;)
    GREAT WORK

  8. canon sx110 04. Sep, 2008 at 3:46 pm #

    thank you very much
    in your post everything is comprehendible

Trackbacks/Pingbacks

  1. free casino game play free casino game online free online casino game no download - 03. May, 2008

    texas holdem rules texas holdem poker texas holdem gratis…

    Yet jeu jack black casino online francais…

  2. regles poker no limit - 03. May, 2008

    fax loan no online payday…

    Near texas holdem wertigkeit association canadian loan payday…

  3. instant approval uk credit card - 05. May, 2008

    poker instrucciones de juego…

    Applying for free funny voice ringtones mobile ringtones converter…

  4. cash advance loan with savings account cash advance loan utah - 06. May, 2008

    regole baccarat…

    Il casino gioca giocare a poker on line…

  5. regles du jeux du poker - 28. May, 2008

    jouer au poker sur paris…

    If You are jouez au poker gratuites télécharger texas holdem en ligne poker texas holdem no limit poker online en francais pacifique poker…

  6. casino online español - 10. Jul, 2008

    casino online español…

    La alquiler ruletas juego streep poker online poker strategy gioco poker on line gratis jugar omaha poker…

Leave a Reply