Thursday, June 22, 2006

Desert Scroll Cypher

[RECOVERED FROM MY OLD BLOGS]

Overview:
Desert Scroll is an old project of mine which i wrote in perl couple of years ago
and basicly its an implementation of a Book encryption
Loading && Mapping the key file:
at first before every encryption/decryption of plain text a key is being loaded into the memory of the script/program and then mapped into a bi-dimensional array while the first dimension is used to map all ASCII numeric values that exists in the key and in the second dimension there are all the offsets of the same ASCII value which exists in the key file
Encrypting process:
the process of the encryption is basicly a replacment of the original characters in the plaintext with the one of the offsets which lays under that ASCII value in the array
its worth mentioning that no addition steps has been taken to camouflage and prevent from the third side to understand the mechanisem of this encryption
  1. perl Desert_Scroll-v1.0-recode.pl dec.txt mentor_crpyt.txt http://www.blackhat.org.il/uploads/hackermanifesto.txt -e

output:

  1. 836 1465 431 2199 253 848 1539 358 566 1350 733 25 930 1689 1009 2759 1645 1357 2695
  2. 143 469 278 395 74 106 2954 2661 3127 87 2775 922 2207 1876 2637 1794 2279 3098 103
  3. 48 801 1394 1190 1497 2055 3123 773 3140

use LWP::Simple;
system('cls');
print qq~;—————————————————————————–;
;Desert Scroll v1.0:                                Exodus/nullfield\@gmail.com;
;—————————————————————————–;
[!]INPUT: Desert_Scroll-v1.0-recode.pl $ARGV[0] $ARGV[1] $ARGV[2] $ARGV[3]
~;
if(@ARGV==1 && @ARGV[0] eq "-h")
{
print qq~
 Use:
 the defination  of the arguments of the encoder/decoder routines is using the
 following syntax:
 perl Desert_Scroll-v1.0-recode.pl     <-e/-d>
 <-e/-d> -> -e to encode, -d to decode.
      -> source text to encode/decode or a qouted text.
     -> destenation to output the resaults.
      -> I. a pointer to the key file
              II. an interger to generate a key
              III. an URL pointing on the key source(format: http://…)
 
 You can also use the key-generator stand-alone features by using the
 following synatx:
 perl Desert_Scroll-v1.0-recode.pl <-g>
  -> key length.
    -> Destenation of the key file.
~;}
 
elsif(@ARGV[0] eq "-g")
{
 if(@ARGV!=3)
 {
  print qq~
[!]in order to use the key generator function you must follow this syntax:
[!] perl Desert_Scroll-v1.0-recode.pl -g
[!]  -> key length.
[!]    -> Destenation of the key file.
~;
  exit;
 }
 print "\n[V]Generating key…\n";
 $key=key_gen(@ARGV[1]);
 print "[V]Key is being saved to @ARGV[2].\n";
 save_file(@ARGV[2],$key);
 print "[V]Key generation completed.\n";
}
 
elsif(@ARGV!=3)
{
 print qq~
[!]DS is using the following syntax:
[!]Use: perl Desert_Scroll-v1.0-recode.pl    <-e/-d>
[!]type "perl Desert_Scroll-v1.0-recode.pl -h" for fully specifications about DS.
 
~;
}
if(@ARGV[3] eq "-e")
{
 
 $file=file_content(@ARGV[0]);
 $key=file_content(@ARGV[2]);
 if(!$file)
 {print"[!]Couldnt open source file therefore argument treated like a string.\n";}
 $key_string=@ARGV[2];
 if($key_string=~/http\:\/\//)
 {
  print "[!]Downloading the key from: $key_string\n";
  $key=get($key_string);
 }
 elsif($key=file_content($key_string))
 { print "[!]Opening the source of the key file.\n"; }
 else
 {
  print "[!]Couldnt open Key-file therfore argument treated like a length interger.\n";
  $key=key_gen($key_string);
  save_file("[key]".@ARGV[0],$key);
  print "[!]New Generated key has been saved to \"[key]@ARGV[0]\"\n";
 }
 key_map($key);
 print "[V]Key mapped successfully in memory.\n";
 save_file(@ARGV[1],encode($file));
 print "[V]Encoded file is saved to \"@ARGV[1]\".\n";
 print "[V]Encoding complete.\n";
 close(DEST);
 $e=;
}
elsif(@ARGV[3] eq "-d")
{
 $file=file_content(@ARGV[0]);
 $key=file_content(@ARGV[2]);
 if(!$file)
 {print"[!]Couldnt open source file therefore argument treated like a string.\n"; }
 if(@ARGV[2]=~/http\:\/\//)
 {
  print "[!]Downloading the key from: @ARGV[2]\n";
  $key=get(@ARGV[2]);
 }
 elsif(!$key)
 { print "[X]Could'nt Open the source key file, decoding process failed.\n";exit;}
 print "[!]Opening the source of the key file.\n";
 save_file(@ARGV[1],decode($file,$key));
 print "[V]Decoded file is saved to \"@ARGV[1]\".\n";
 print "[V]Decoding complete.\n";
 close(DEST);
 $e=;
 
}
 
sub file_content()
{
 my $content,$line;
 my ($source)=@_;
 open(FILE_CON,$source) || return 0;
 while($line=) {$content.=$line;}
 close(FILE_CON);
 return $content;
}
sub save_file()
{
 my ($dest,$content)=@_;
 if(!open(FILE_SAV,">$dest"))
 { print("[X]Unable to open the file.\n"); }
 print FILE_SAV $content;
 close(FILE_SAV);
}
 
sub key_gen()
{
 my ($len)=@_;
 for($i=0; $i<=$len;$i++)
 {
  $keytext.=$rnd_char=chr(rand(255));
 }
 return $keytext;
}
 
sub encode
{
 my ($content)=@_;
 $len=length($content);
 for($i=0;$i<=$len;$i++) # foreach letter
 {
  $num=ord(substr($content,$i,1));
  if(@{$map[$num]})
  {
   $rand_var_alloc = $map[$num][int(rand(scalar(@{$map[$num]})))];
   $encoded.="$rand_var_alloc ";
  }
  else { print "[X]the ASCII value $num doesnt exist in the key this might cause data loss..\n";}
 }
 return $encoded;
 
}
 
sub decode
{
 my @encoded,$num,$letter,$decoded;
 my ($content,$key_src)=@_;
 @encoded = split(/ /,$content);
 foreach $num (@encoded)
 {
  $letter = substr($key_src,$num,1);
  $decoded .= $letter;
 }
 return $decoded
 
}
 
sub key_map
{
 my ($content)=@_;
 my $num,$i;
 for($i=0;$i<=length($content);$i++)
 {
  $num=ord(substr($content,$i,1));
  push(@{$map[$num]},$i);
 }
 return(1);
}

5 comments:

  1. This comment has been removed by a blog administrator.

    ReplyDelete
  2. You can use this keylogger for android that is also available for iOS and would be a great hacking tool for all the interested in various security issues.

    ReplyDelete
  3. Thank you so much for the post and I likes your old project Desert Scroll Cypher. Because I am planned to implement a Book encryption.I think your program will helps me little bit.I have interest in programming and recently I developed a site best essay writing service using SQL.But I never tried out perl.

    ReplyDelete
  4. Have been looking for information on the subject! thanks to the author for the perfectly presented material!
    Delhi Female Escorts

    ReplyDelete
  5. Very nice, I truly like your article. Your focuses are well made and relatable. A debt of gratitude is in order for composing connecting with and fascinating material. In a perfect world this site winds up noticeably more unmistakable and clear for others.thanks
    Gurgaon Escorts By Anshita Sharma

    ReplyDelete

Note: Only a member of this blog may post a comment.