🌐
GitHub
github.com › SpiderLabs › ikeforce › issues › 10
Problem with pyopenssl==17.2.0 · Issue #10 · SpiderLabs/ikeforce
May 30, 2023 - Traceback (most recent call last): File "./ikeforce.py", line 307, in iCookie = ikeneg.secRandom(8).encode('hex') File "/home/master/git/ikeforce/ikeclient.py", line 46, in secRandom randomBytes = OpenSSL.rand.bytes(bytes) AttributeError: 'module' object has no attribute 'rand'
Author   mariobranco
🌐
GitHub
github.com › EmpireProject › Empire › issues › 697
AttributeError: 'module' object has no attribute 'rand' · Issue #697 · EmpireProject/Empire
September 14, 2017 - Traceback` (most recent call last): File "./empire", line 11, in <module> from lib.common import empire File "/opt/Empire/lib/common/empire.py", line 27, in <module> import agents File "/opt/Empire/lib/common/agents.py", line 68, in <module> import encryption File "/opt/Empire/lib/common/encryption.py", line 62, in <module> random_function = OpenSSL.rand.bytes AttributeError: 'module' object has no attribute 'rand'
Discussions

AttibuteError: 'module' object has no attribute 'rand' has occured at acme/acme/crypto_util.py with >=pyOpenSSL-17.2.0
My operating system is (include version): CentOS 6.9 I installed Certbot with (certbot-auto, OS package manager, pip, etc): pip I ran this command and it produced this output: certbot certonly --st... More on github.com
🌐 github.com
19
September 14, 2017
'module' object has no attribute 'rand'
Empire Version master branch git OS Information (Linux flavor, Python version) kali Expected behavior and description of the error, including any actions taken immediately prior to the error. The m... More on github.com
🌐 github.com
3
December 19, 2017
python - random.randint error: "AttributeError: 'module' object has no attribute 'randint'" - Stack Overflow
I have some code that looks something like this: import random n = 0 while n More on stackoverflow.com
🌐 stackoverflow.com
openssl - Python AttributeError: 'module' object has no attribute 'SSL_ST_INIT' - Stack Overflow
A Python script of mine is failing with: Traceback (most recent call last): File "./inspect_sheet.py", line 21, in main() File "./inspect_sheet.py", line 12, in main More on stackoverflow.com
🌐 stackoverflow.com
🌐
GitHub
github.com › certbot › certbot › issues › 5123
AttributeError: module 'OpenSSL' has no attribute 'rand' · Issue #5123 · certbot/certbot
September 20, 2017 - 2017/09/20 18:43:06 [notice] 7251#7251: signal process started An unexpected error occurred: AttributeError: module 'OpenSSL' has no attribute 'rand' Please see the logfiles in /var/log/letsencrypt for more details.
Published   Sep 20, 2017
🌐
GitHub
github.com › certbot › certbot › issues › 5111
AttibuteError: 'module' object has no attribute 'rand' has occured at acme/acme/crypto_util.py with >=pyOpenSSL-17.2.0 · Issue #5111 · certbot/certbot
September 14, 2017 - Renewing an existing certificate Performing the following challenges: tls-sni-01 challenge for domain.com Cleaning up challenges An unexpected error occurred: AttributeError: 'module' object has no attribute 'rand' Please see the logfiles in /var/log/letsencrypt for more details.
Author   darkcircle
🌐
GitHub
github.com › EmpireProject › Empire › issues › 871
'module' object has no attribute 'rand' · Issue #871 · EmpireProject/Empire
December 19, 2017 - upon using ./empire, empire should open normally however after a update(update/upgrade/autoremove) i get the following error Traceback (most recent call last): File "./empire", line 13, in from lib.common import empire, helpers File "/root/Desktop/123/Empire-master/lib/common/empire.py", line 31, in import agents File "/root/Desktop/123/Empire-master/lib/common/agents.py", line 68, in import encryption File "/root/Desktop/123/Empire-master/lib/common/encryption.py", line 62, in random_function = OpenSSL.rand.bytes AttributeError: 'module' object has no attribute 'rand'
Author   bkr32
🌐
MacPorts
trac.macports.org › ticket › 58835
#58835 (gajim 0.16.8_0 OpenSSL.rand.load_file(str(RNG_SEED)) AttributeError: 'module' object has no attribute 'load_file') – MacPorts
try: import OpenSSL.rand from common import crypto # Seed from file OpenSSL.rand.load_file(str(RNG_SEED)) crypto.add_entropy_sources_OpenSSL() OpenSSL.rand.write_file(str(RNG_SEED)) PYOPENSSL_PRNG_PRESENT = True except ImportError: log.info("PyOpenSSL PRNG not available") except AttributeError: log.info("PyOpenSSL PRNG not available")
🌐
OpenSSL
openssl.org › docs › man1.1.1 › man3 › RAND_bytes.html
RAND_bytes - OpenSSL Documentation
RAND_bytes, RAND_priv_bytes, RAND_pseudo_bytes - generate random data · RAND_bytes() generates num random bytes using a cryptographically secure pseudo random generator (CSPRNG) and stores them in buf
Find elsewhere
🌐
Pyopenssl
pyopenssl.org › en › 16.1.0 › api › rand.html
rand — An interface to the OpenSSL pseudo random number generator — pyOpenSSL 16.1.0 documentation
Functions from this module shouldn’t be used. Use urandom instead · This module handles the OpenSSL pseudo random number generator (PRNG) and declares the following:
🌐
Rdrr.io
rdrr.io › cran › openssl › man › rand_bytes.html
rand_bytes: Generate random bytes and numbers with OpenSSL in openssl: Toolkit for Encryption, Signatures and Certificates Based on OpenSSL
February 26, 2026 - View source: R/rand.R · this set of functions generates random bytes or numbers from OpenSSL. This provides a cryptographically secure alternative to R's default random number generator. rand_bytes generates n random cryptographically secure bytes
🌐
GitHub
github.com › EmpireProject › Empire › issues › 883
cant start empire recieve errors · Issue #883 · EmpireProject/Empire
December 25, 2017 - Traceback (most recent call last): File "./empire", line 13, in from lib.common import empire, helpers File "/pentest/powershell/empire-ps/lib/common/empire.py", line 31, in import agents File "/pentest/powershell/empire-ps/lib/common/agents.py", line 68, in import encryption File "/pentest/powershell/empire-ps/lib/common/encryption.py", line 62, in random_function = OpenSSL.rand.bytes AttributeError: 'module' object has no attribute 'rand'
Author   dan7ez
🌐
JetBrains
intellij-support.jetbrains.com › hc › en-us › community › posts › 115000478550-AttributeError-module-random-has-no-attribute-randint-
AttributeError: module 'random' has no attribute 'randint' – IDEs Support (IntelliJ Platform) | JetBrains
July 24, 2017 - I am getting an error, while writing a simple random number generating code. How can this be resolved. I just recently took up learning python and tried to code in pycharm.
Top answer
1 of 1
5

Your implementation of print_hexa is wrong. Random bytes may contain 0x00 and the function may stop there. Even worse thing is that if the random bytes don't contain 0x00, it will do out-of-range access to find 0x00.

To avoid this issue, the length to print should be given to print_hexa separately.

#include <openssl/rand.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>

uint8_t *generate_salt()
{
    uint8_t *res = malloc(16 * sizeof(uint8_t));
    RAND_bytes(res, 16);
    return res;
}

void print_hexa(uint8_t *message, int message_length)
{
    for (int i = 0; i < message_length; i++)
    {
        printf("%02x", message[i]);
    }
    printf(";\n");
}
int main()
{
    for (int i = 0; i < 20; i++)
    {
        print_hexa(generate_salt(), 16);
    }
}

Another choice is hard-coding the length as you did in the generate_salt function.

#include <openssl/rand.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>

uint8_t *generate_salt()
{
    uint8_t *res = malloc(16 * sizeof(uint8_t));
    RAND_bytes(res, 16);
    return res;
}

void print_hexa(uint8_t *message)
{
    for (int i = 0; i < 16; i++)
    {
        printf("%02x", message[i]);
    }
    printf(";\n");
}
int main()
{
    for (int i = 0; i < 20; i++)
    {
        print_hexa(generate_salt());
    }
}

Defining the length as macro is better than writing the magic number 16 directly.

#include <openssl/rand.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>

#define LENGTH 16

uint8_t *generate_salt()
{
    uint8_t *res = malloc(LENGTH * sizeof(uint8_t));
    RAND_bytes(res, LENGTH);
    return res;
}

void print_hexa(uint8_t *message)
{
    for (int i = 0; i < LENGTH; i++)
    {
        printf("%02x", message[i]);
    }
    printf(";\n");
}
int main()
{
    for (int i = 0; i < 20; i++)
    {
        print_hexa(generate_salt());
    }
}
🌐
Reddit
reddit.com › r/learnpython › 'module' object has no attribute 'randint' help
r/learnpython on Reddit: 'module' object has no attribute 'randint' HELP
September 19, 2018 -

I'm supposed to be making a code that lets you play Rock-Paper-Scissors with the computer as part of my beginner exercises. Obviously this is gonna require me to import the random module to make the computer throw out different moves. So I first tested importing the module by making this simple code:

import random

print(random.randint(1,100))

But when I test it, the error written in the title shows up. My file is not named random.py to avoid conflicts with the imported module. Is there a workaround for this?

🌐
OpenSSL
docs.openssl.org › 4.0 › man7 › RAND
RAND - OpenSSL Documentation
As a normal application developer, you do not have to worry about any details, just use RAND_bytes(3) to obtain random data. Having said that, there is one important rule to obey: Always check the error return value of RAND_bytes(3) and do not take randomness for granted.
🌐
GitHub
github.com › python › typeshed › issues › 3459
Crypto.Random: Module has no attribute "get_random_bytes" · Issue #3459 · python/typeshed
November 12, 2019 - Are you reporting a bug, or opening a feature request? Bug Prerequisite: pip install pycrypto Example code: # test_27.py # Python 2.7 annotation style from Crypto import Random b27 = Random.get_random_bytes(10) # type: bytes # test_35.py...
Author   muendelezaji