1
mirror of https://github.com/rapid7/metasploit-payloads synced 2025-01-02 11:36:22 +01:00

Make use of proper CSPRNG when possible

This commit is contained in:
jvoisin 2024-09-01 22:26:53 +02:00
parent 7f21e9a29b
commit c387d2f139

View File

@ -822,10 +822,17 @@ function channel_read($chan_id, $len) {
}
function rand_xor_byte() {
if (can_call_function('random_int')) {
return chr(random_int(1, 255));
}
return chr(mt_rand(1, 255));
}
function rand_bytes($size) {
if (can_call_function('random_bytes')) {
return random_bytes($size)
}
$b = '';
for ($i = 0; $i < $size; $i++) {
$b .= rand_xor_byte();