Wednesday, March 5, 2014

Carving ASCII Streams from /dev/urandom


    , =======================================  ,
    | Carving ASCII Streams from /dev/urandom  |
     ,======================================= ' 

                 ---------------
                [ A CLEAN SLATE ]
                 ---------------

        - Start with catting /dev/urandom.
            - cat /dev/urandom
        - Let's throw this output into xxd for some regular streaming
            - | xxd -b 
        - Now we have a dump of the stream in binary.
            -  10100101001001010010
        - Let's take a cut of the portion we care about.
            - cut -c 9-62
        - Also remove all whitespace:
            - sed 's/ //g'
        - And Let's also repeat this stream twice using sed.
            - sed 's/\(.*\)/\1\1/g'


            ------------------------- 
          [ Now for the fun part .... ]
            ------------------------- 

         - We'll now take all 1's and convert them to a certain symbol.
             - sed 's/1/_/g'
         - Repeat with 0's
             - sed 's/0/-/g'


         We now have something to work with....


          ,,,,,,,,,,,,,,,,,,,,,,,,,,,,  
         Let's play around a little bit
          ............................  



         # Finding repeated patterns can be Fun:
         sed 's/____/====/g'
         sed 's/-_-/| |/g'
         sed 's/--==/[  ]/g'
         sed 's/]==/\\\\\\/g'
         sed 's/|---/*  */g'
         sed 's/___/} {/g'


         # Let's add some Color to it:
         # NOTE: Keep this on the End not to lose any color :)
         egrep "{|}|-|:"

         # Let's give this some Boundries:
         sed 's/$/..|::]/g; s/^/[::|../g' 

        # And some Spacing:
        sed 's/^/\t\t/g' 


        # Final Result:
        cat /dev/urandom | xxd -b | cut -c 9-62 | sed 's/ //g' | sed 's/\(.*\)/\1\1/g' | sed 's/1/_/g' | sed 's/0/-/g' | sed 's/____/====/g' | sed 's/-_-/| |/g' | sed 's/--==/[  ]/g' | sed 's/]==/\\\\\\/g' | sed 's/|---/*  */g' | sed 's/___/} {/g' | sed 's/$/..|::]/g; s/^/[::|../g' | sed 's/^/\t\t/g' | egrep "{|}|-|:"

        # Play with any of the general rules above to change the outcome.

        # Or keep Going and Slice it Up!

        cat /dev/urandom | xxd -b | cut -c 9-62 | sed 's/ //g' | sed 's/\(.*\)/\1\1/g' | sed 's/1/_/g' | sed 's/0/-/g' | sed 's/____/====/g' | sed 's/-_-/| |/g' | sed 's/--==/[  ]/g' | sed 's/]==/\\\\\\/g' | sed 's/|---/*  */g' | sed 's/___/} {/g' | sed 's/$/..|::]/g; s/^/[::|../g' | sed 's/^/\t\t/g' | cut -c 15-45 | sed 's/\(.*\)/\1\1\1\1/g' | sed 's/|/ /g' | sed 's/ /_/g' | sed 's/\\/\//g' | sed 's/\/\/\//\\ \//g' | sed 's/____/(  )/g' | sed 's/====/\\  ]/g' | cut -c 10-50 | sed 's/\(.*\)/\1\1/g' | sed 's/^/.__/g; s/$/__./g' | sed 's/(  )/- | /g' | sed 's/ /@/g' | sed 's/-/_/g' | sed 's/_\\/| /g' | sed 's/@@/@*/g' | sed 's/...@.../@ }_{ @/g' | sed 's/^/\t\t|/g;s/$/|/g' | sed 's/\(^...............\)\(...............\)\(...............\)\(...............\)\(...............\)/\1|\2|\3|\4|/g' | egrep "}_{|\.|.\*."