News for hackers. Stuff that matters.
Re:Making Python Less Random by Joker_vD on Friday July 12, 2024 @09:27AM (#40945376)
Of course, this doesn't help with someone (e.g. me) who prefers to get their random numbers by reading them from /dev/random:

    $ strace python3 -c 'with open("/dev/random", "rb") as f: print(f.read(8))'
    [snip-snip]
    openat(AT_FDCWD, "/dev/random", O_RDONLY|O_CLOEXEC) = 3
    newfstatat(3, "", {st_mode=S_IFCHR|0666, st_rdev=makedev(0x1, 0x8), ...}, AT_EMPTY_PATH) = 0
    ioctl(3, TCGETS, 0x7ffd8198d640)        = -1 EINVAL (Invalid argument)
    lseek(3, 0, SEEK_CUR)                   = 0
    read(3, "\366m@\t5Q9\206\341\316/pXK\266\273~J\27\321:\34\330VL\253L\34\217\264L\373"..., 4096) = 4096
    write(1, "b'\\xf6m@\\t5Q9\\x86'\n", 19b'\xf6m@\t5Q9\x86'
    ) = 19
    close(3)                                = 0
There is also /dev/urandom.
Re:Making Python Less Random by frakt0x90 on Friday July 12, 2024 @01:03PM (#40947381)
os.urandom does read from /dev/urandom: https://docs.python.org/3/library/os.html#os.urandom
Re:Making Python Less Random by skinner927 on Saturday July 13, 2024 @08:44AM (#40953780)
From kernel 5.18 onwards, /dev/random and /dev/urandom are exactly the same.
Re:Making Python Less Random by Joker_vD on Saturday July 13, 2024 @08:50AM (#40953810)
They are still two different filenames (and two different inodes), if you want to intercept openning them.