1 6 6

:

  1. #1
    .: :.
    Debian 6
    XFCE

    Sep 2009
    1,693
    1,830
    2,944 945



    . , . :



    . . ﻻ ﻻ .

    Random.org . .

    : : atmospheric noise.mp3

    True random number generating TRNG . .

    ﻻ . , :

    :
    /dev/random
    /dev/urandom
    . :

    :
    $ head -c 20 /dev/random | od -A n
     077014 177764 176343 161473 111636 161460 172252 060302
     040502 050614
    $ head -c 20 /dev/urandom | od -A n
     057322 103636 013477 140350 053411 025265 041226 161722
     160756 163327
    $
    head 20 od . :

    :
    $ head -c 20 /dev/random
    ...
    $ head -c 20 /dev/urandom
    ...
    $ cat /dev/random
    ...
    $ cat /dev/urandom
    ...
    $
    random urandom . random .

    pixel :



    , ﻻ . sine :





    sine .



    , . Pseudo-random number generator PRNG ﻷ 100% . .

    Linear congruential generator ( ):



    Z L I M. M I Z M , L , seed, 0.3223, 0.653 ...

    L . L L .

    L . , . urand rand .

    Python ( ):

    :
    #!/usr/bin/python
    # -*- encoding: utf-8 -*-
    
    __author__ ='Barakat'
    __license__='GPL'
    __emali___ ='barakat@linuxac.org'
    
    M  =555
    Z  =333
    I  =222
    L  =0.32355
    
    for i in xrange(0, 10):
        L=float(Z * float(L) + I) % float(M)
        print L
    :

    :
    $ python lcg.py
    329.74215
    136.13595
    45.2713499987
    312.359549582
    452.73001072
    21.0935698566
    31.158762239
    52.8678255893
    66.9859212524
    328.31177704
    $
    . random, urandom , seed:

    :
    import re
    
    def rand_seed():
        L  =1.0
        for i in [float(ord(x)) for x in open("/dev/random", "r").read(10)]:
            try:
                L  =L / i
            except ZeroDivisionError:
                pass
        L  ="0." + re.findall("^\d+\.(.*)", str(L))[0][0:7]
        return float(L)
    10 random . :

    :
    #!/usr/bin/python
    # -*- encoding: utf-8 -*-
    
    import re
    
    __author__ ='Barakat'
    __license__='GPL'
    __emali___ ='barakat@linuxac.org'
    
    def rand_seed():
        L  =1.0
        for i in [float(ord(x)) for x in open("/dev/random", "r").read(10)]:
            try:
                L  =L / i
            except ZeroDivisionError:
                pass
        L  ="0." + re.findall("^\d+\.(.*)", str(L))[0][0:7]
        return float(L)
    
    M  =555
    Z  =333
    I  =222
    L  =rand_seed()
    
    for i in xrange(0, 10):
        L=float(Z * float(L) + I) % float(M)
        print L
    :

    :
    $ python lcg.py 
    328.5343257
    288.9304581
    420.842547301
    502.568251267
    522.2276718
    408.814709557
    382.298282574
    432.328097061
    442.256321262
    418.354980222
    $ python lcg.py
    287.5624386
    520.2920538
    319.253915401
    528.553828591
    295.424920963
    363.49868072
    277.060679795
    353.206371808
    179.721812205
    129.363464395
    $
    :




    rand C :

    :
    #include<stdio.h>
    #include<stdlib.h>
    #include<time.h>
    
    int main(void){
    
        int i;
        srand(time(NULL));
    
        for(i=0; i <= 10 ; i++){
            printf("%d\n", rand());
        }
    
        return(0);
    
    }
    Python ctypes :

    :
    #!/usr/bin/python
    # -*- encoding: utf-8 -*-
    
    from ctypes import *
    from ctypes.util import *
    
    __author__ ='Barakat'
    __license__='GPL'
    __emali___ ='barakat@linuxac.org'
    
    c  =CDLL(find_library("c"))
    
    c.srand(c.time(None))
    
    for i in xrange(1, 10):
            print c.rand()
    :



    , OpenSSL RAND_pseudo_bytes :

    :
    #include<stdio.h>
    #include<openssl/rand.h>
    
    int main(void){
    
        int i;
        unsigned char array[1];
    
        for(i=0; i <= 10 ; i++){
            RAND_pseudo_bytes((unsigned char*) array, sizeof(array));        
            printf("%d\n", array[0]);
        }
    
        return(0);
    }
    Python ctypes :

    :
    #!/usr/bin/python
    # -*- encoding: utf-8 -*-
    
    from ctypes import *
    from ctypes.util import *
    
    __author__ ='Barakat'
    __license__='GPL'
    __emali___ ='barakat@linuxac.org'
    
    ssl=CDLL(find_library('ssl'))
    
    for i in xrange(1, 10):
            array  =(c_ubyte * 1)()
            ssl.RAND_pseudo_bytes(byref(array), sizeof(array))
            print array[0]
    :



    rand php :




    .

    : PHP rand(0,1) on Windows OpenSSL rand() on Debian

    : PHP GENERATE_SEED() Weak Random Number Seed Vulnerability


    :

    :
    #!/usr/bin/python
    # -*- encoding: utf-8 -*-
    
    """
    Author  : Barakat <barakat@linuxac.org>
    Website : http://cipher2000.blogspot.com/
    
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.m
    
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
    """
    
    __author__ ='Barakat'
    __license__='GPL'
    __emali___ ='barakat@linuxac.org'
    
    import cairo
    import pango
    import pangocairo
    import re
    import time
    import math
    from ctypes import *
    from ctypes.util import find_library
    
    height, width =300, 450
    
    def draw_text(ctx, text):
        pango_ctx  =pangocairo.CairoContext(ctx)
        pango_ctx.set_antialias(cairo.ANTIALIAS_SUBPIXEL)
        layout     =pango_ctx.create_layout()
        font       =pango.FontDescription('10')
        layout.set_font_description(font)
        layout.set_text(" " + text)
        ctx.set_source_rgb(0, 0, 0)
        pango_ctx.update_layout(layout)
        pango_ctx.show_layout(layout)
        return layout.get_pixel_extents()
    
    
    # /dev/urandom noise
    sur =cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height)
    ctx =cairo.Context(sur)
    
    ctx.set_source_rgb(1, 1, 1)
    ctx.rectangle(0, 0, width, height)
    ctx.fill()
    
    urandom    =open('/dev/urandom').read(height * width)
    urandom    =map(lambda x : float(ord(x)), urandom)
    
    for y in xrange(20, height):
        for x in xrange(0, width):
           ][color=urandom.pop() % 2
            ctx.set_source_rgb(color, color, color)
            ctx.rectangle(x, y, 1, 1)
            ctx.fill()
    
    draw_text(ctx, '/dev/urandom noise')
    ctx.rectangle(0, 0, width, height)
    ctx.stroke()
    sur.write_to_png('random1.png')
    
    
    # Using the time
    sur =cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height)
    ctx =cairo.Context(sur)
    
    ctx.set_source_rgb(1, 1, 1)
    ctx.rectangle(0, 0, width, height)
    ctx.fill()
    
    for y in xrange(20, height):
        for x in xrange(0, width):
           ][color=time.time() % 2
            ctx.set_source_rgb(color, color, color)
            ctx.rectangle(x, y, 1, 1)
            ctx.fill()
    
    draw_text(ctx, 'Using the time')
    ctx.rectangle(0, 0, width, height)
    ctx.stroke()
    sur.write_to_png('random2.png')
    
    
    
    # Using sin function
    sur =cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height)
    ctx =cairo.Context(sur)
    
    ctx.set_source_rgb(1, 1, 1)
    ctx.rectangle(0, 0, width, height)
    ctx.fill()
    
    x  =0
    
    for y in xrange(20, height):
        for x in xrange(0, width):
           ][color=math.sin(x) % 2
            x   += 1
            ctx.set_source_rgb(color, color, color)
            ctx.rectangle(x, y, 1, 1)
            ctx.fill()
    
    draw_text(ctx, 'Using sin function')
    ctx.rectangle(0, 0, width, height)
    ctx.stroke()
    sur.write_to_png('random3.png')
    
    
    
    # LCG "(Z * L + I) mod M"
    def rand_seed():
        L  =1.0
        for i in [float(ord(x)) for x in open("/dev/urandom", "r").read(10)]:
            try:
                L  =L / i
            except ZeroDivisionError:
                pass
        L  ="0." + re.findall("^\d+\.(.*)", str(L))[0][0:7]
        return float(L)
    
    sur =cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height)
    ctx =cairo.Context(sur)
    
    ctx.set_source_rgb(1, 1, 1)
    ctx.rectangle(0, 0, width, height)
    ctx.fill()
    
    L  =rand_seed()
    I  =51.0
    M  =46.0
    Z  =99.0
    
    for y in xrange(20, height):
        for x in xrange(0, width):
            L=(Z * float(L) + I) % float(M)
            color  =int(L) % 2
            ctx.set_source_rgb(color, color, color)
            ctx.rectangle(x, y, 1, 1)
            ctx.fill()
    
    
    draw_text(ctx, 'LCG "(Z * L + I) mod M""')
    ctx.rectangle(0, 0, width, height)
    ctx.stroke()
    sur.write_to_png('random4.png')
    
    
    # C rand with srand
    sur =cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height)
    ctx =cairo.Context(sur)
    
    ctx.set_source_rgb(1, 1, 1)
    ctx.rectangle(0, 0, width, height)
    ctx.fill()
    
    c  =CDLL(find_library("c"))
    c.srand(c.time(None))
    
    for y in xrange(20, height):
        for x in xrange(0, width):
           ][color=c.rand() % 2
            ctx.set_source_rgb(color, color, color)
            ctx.rectangle(x, y, 1, 1)
            ctx.fill()
    
    draw_text(ctx, 'C rand with srand')
    ctx.rectangle(0, 0, width, height)
    ctx.stroke()
    sur.write_to_png('random5.png')
    
    
    
    # OpenSSL RAND_pseudo_bytes
    sur =cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height)
    ctx =cairo.Context(sur)
    
    ctx.set_source_rgb(1, 1, 1)
    ctx.rectangle(0, 0, width, height)
    ctx.fill()
    
    ssl=CDLL(find_library('ssl'))
    
    for y in xrange(20, height):
        for x in xrange(0, width):
            array  =(c_ubyte * 1)()
            ssl.RAND_pseudo_bytes(byref(array), sizeof(array))
           ][color=array[0] % 2
            ctx.set_source_rgb(color, color, color)
            ctx.rectangle(x, y, 1, 1)
            ctx.fill()
    
    draw_text(ctx, 'OpenSSL RAND_pseudo_bytes')
    ctx.rectangle(0, 0, width, height)
    ctx.stroke()
    sur.write_to_png('random6.png')

  2. 19 :


  3. #2
    .: :.
    X11

    Jun 2009
    5,851
    6,351
    6,737 2,826
    1

    ɡ micro-seconds nano-seconds ( 1970 ) ɡ (mod) . microsecond ( ) ǡ ( ɡ busses ...).

    0 512 :
    microseconds 1970 ( !) mod ( ) 512 0 512 ǡ microsecond .

    : .
    !


    --
    IRC: Fakhouri



  4. 4 :

    , , ,

  5. #3
    .: :.
    Debian 6
    XFCE

    Sep 2009
    1,693
    1,830
    2,944 945

    ,

    . . . :







    :



    :

    :
    #!/usr/bin/python
    # -*- encoding: utf-8 -*-
    
    import cairo
    import pango
    import pangocairo
    import datetime
    
    height, width  = 300, 450
    
    def draw_text(ctx, text):
        pango_ctx   = pangocairo.CairoContext(ctx)
        pango_ctx.set_antialias(cairo.ANTIALIAS_SUBPIXEL)
        layout      = pango_ctx.create_layout()
        font        = pango.FontDescription('10')
        layout.set_font_description(font)
        layout.set_text(" " + text)
        ctx.set_source_rgb(0, 0, 0)
        pango_ctx.update_layout(layout)
        pango_ctx.show_layout(layout)
        return layout.get_pixel_extents()
    
    
    sur  = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height)
    ctx  = cairo.Context(sur)
    
    ctx.set_source_rgb(1, 1, 1)
    ctx.rectangle(0, 0, width, height)
    ctx.fill()
    
    for y in xrange(20, height):
        for x in xrange(0, width):
            color = datetime.datetime.now().microsecond % 2
            ctx.set_source_rgb(color, color, color)
            ctx.rectangle(x, y, 1, 1)
            ctx.fill()
    
    draw_text(ctx, 'Using microsecond')
    ctx.rectangle(0, 0, width, height)
    ctx.stroke()
    sur.write_to_png('mac.png')
         . 

:	mac2.png‏ 
:	938 
:	24.5  
:	16719       . 

:	mac1.png‏ 
:	973 
:	25.2  
:	16718       . 

:	mac3.png‏ 
:	955 
:	26.1  
:	16720  

  6. 3 :

    , ,

  7. #4
    :: ::
    Ubuntu 12.04
    GNOME3

    Jun 2009
    386
    618
    609 197

    ( ) -> md5 salt -> ASCII ->


  8. 2 :

    ,

  9. #5
    Fedora 16
    GNOME

    Feb 2010
    63
    58
    21 13

    , , ,




  10. :


  11. #6
    .: :.
    X11

    Jun 2009
    5,851
    6,351
    6,737 2,826
    1

    @
    ( ) ɡ !

    ^ ȡ ɡ ɡ ɡ !

    ɡ ɡ !

    @
    .
    !


    --
    IRC: Fakhouri



  12. :


: 1 (0 1 )

  1. []
    KroYos .: :.
    : 18
    : 25-12-2010, 02:29 AM
  2. [] gnome ram
    .: :.
    : 3
    : 13-05-2010, 08:36 PM
  3. [] ɿ
    mohamed clay .: :.
    : 7
    : 11-03-2010, 09:23 AM
  4. (rand)
    .: :.
    : 2
    : 03-12-2009, 02:10 PM
  5. [] pdf
    alsadi .: :.
    : 1
    : 20-11-2009, 02:32 PM