hacking contest

hacking exploits security forum
hacking
compliance articles
upgrade backup exec
information security consultant

m0et
here is the deal..
i have a txt file with about 400 md5 hashes in it and they are all over the file in difrent lines..
so my request is -can somebody build a little progy that will find all the 32 consecutive cherecters (all md5 hashes have 32 charecters in them-letters and numbers)

and the proggy needs to copy all the hashes to a .txt file-one hash per line..


can somebody help me here ??

10xxxx-please dont think that im just a lamer-im just not a good coder sad.gif


Killaloop
this was one nice lesson. it perfectly fit to where I'm currently at learning perl.
here you go. you need active perl for it.
name your file with the hashes input.txt and just run the pl file. the hashes will be displayed and you will find a new file output.txt.
Note: if file is to big the perl script can't hold the data and will find no hash. test it and tell me about probs (1 minute work)

#!/usr/bin/perl -w

$words = ("");
open(INPUT, "<input.txt") || "input.txt not found\n";
open(OUTPUT, ">output.txt") || "Error creating file\n";
@input = <INPUT>;
$count = 0;

foreach(<@input>)
{
push(@Lines, $_);
}
close(INPUT);

print "\nSearching for Hash: \n\n";
foreach(@Lines)

{
$words++;

if(/([a-f0-9]){32}/)

{
print OUTPUT "$count:$_\n";
print "$_\n";
$count++
}

}

if ($count ne '0') {
print "\nFound $count Hashes: \n\n";
}
else {
print "\nNo MD5 Hash found or file too big: \n\n";
}
print "File has $words words\n" if ($words > 0);

close(OUTPUT);
m0et
10X ALOT !

1 MORE QUESTION.
THE INPUT FILE IS 4 MGS BIG :|

IS THAT TOO MUCH...


BTW...

CAN ADD TO THE SCRIPT A FUNCTION THE AT THE OUTPUT FILE WILL ADD ANUMBER AND ":" BEFORE EVERY HASH?

EX:

1:HASH
2:HASH
3:HASH


10X MAN
Killaloop
the file is way to big to hold it into one variable. I'm not as far into perl to split the stream. you can split the file into parts and test it.
about the numbers, here you go:
/edit: did I say that I love perl? smile.gif

$words = ("");
open(INPUT, "<input.txt") || "input.txt not found\n";
open(OUTPUT, ">output.txt") || "Error creating file\n";
@input = <INPUT>;
$count = 0;

foreach(<@input>)
{
push(@Lines, $_);
}
close(INPUT);

print "\nSearching for Hash: \n\n";
foreach(@Lines)

{
$words++;

if(/([a-f0-9]){32}/)

{
print OUTPUT "$count:$_\n";
print "$_\n";
$count++
}

}

if ($count ne '0') {
print "\nFound $count Hashes: \n\n";
}
else {
print "\nNo MD5 Hash found or file too big: \n\n";
}
print "File has $words words\n" if ($words > 0);

close(OUTPUT);
m0et
thanks alot man!!

you helped me alot !!
Killaloop
QUOTE (m0et @ May 11 2004, 01:07 PM)
thanks alot man!!

you helped me alot !!

good to know.
tested with some bigger files seems to take forever. 50k file worked nice too.

Searching for Hash:

0123456789abcedf01234569abcedf41
0123456789abcedf01233569abcedf41
012345678ffbcedf01234569abcedf41

Found 3 Hashes:

File has 16050 words

output.txt looks like that:
0:0123456789abcedf01234569abcedf41
1:0123456789abcedf01233569abcedf41
2:012345678ffbcedf01234569abcedf41

also note I will edit the script now and remove the chomp line which isn't needed and speeds up the process!! If you got time and hardware power you can ofcource try bigger files.
Killaloop
1000% speed fixed code. since I'm quite new to perl I split the process into 2 parts now. now you can open your 5mb file without any problem, really speedy. 15mb text file within 5 seconds.


open(INPUT, "<input.txt") || "input.txt not found\n";
open(OUTPUT, ">output.txt") || "Error creating file\n";
$count = 0;
@input = <INPUT>;

print "\nSearching for Hash: \n\n";
foreach(@input)
{
if(/([a-f0-9]){32}/)

{
push(@Lines, $_);
}
}
foreach(<@Lines>)
{
if(/([a-f0-9]){32}/)

{
$count++;
print OUTPUT "$count:$_\n";
print "$_\n";
}
}
close(INPUT);
if ($count ne '0')
{
print "\nFound $count Hashes: \n\n";
}
else {
print "\nNo MD5 Hash found\n\n";
}
close(OUTPUT);
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.

 
Invision Power Board © 2001-2005 Invision Power Services, Inc.