flat assembler
Message board for the users of flat assembler.

Index > Linux > randomizing source with /dev/urandom

Author
Thread Post new topic Reply to topic
redsock



Joined: 09 Oct 2009
Posts: 357
Location: Australia
redsock
Attempting to read a byte from /dev/urandom like:

Code:
virtual at 0
    file '/dev/urandom',1
    load randbyte from 0
end virtual    


results in:

file '/dev/urandom',1
error: value out of range.

Any other creative way to get a random byte into compile-time?

Cheers
[/code]
Post 30 May 2014, 02:55
View user's profile Send private message Reply with quote
redsock



Joined: 09 Oct 2009
Posts: 357
Location: Australia
redsock
Further details of what fasm is doing:

After a quick strace, fasm is trying to determine the file length of /dev/urandom and is of course unable to.

open("//dev/urandom", O_RDONLY) = 3
lseek(3, 0, SEEK_END) = 0

thus, value out of range is because of the end returning 0... Hmm.
Post 30 May 2014, 03:10
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17271
Location: In your JS exploiting you and your system
revolution
You could do any of:
  • Write a small program to write a single random byte to a file periodically
  • Edit fasm source code to force it to read the requested bytes for zero length streams
  • Manually edit you source code with a new value before assembling
  • Increase the clock speed of you system to make it unreliable and produce random binaries each time
  • Wait hundreds (thousands?) of years for the bits to decay into a different state
  • Others?
Post 30 May 2014, 05:13
View user's profile Send private message Visit poster's website Reply with quote
gens



Joined: 18 Feb 2013
Posts: 161
gens
redsock wrote:
Further details of what fasm is doing:

After a quick strace, fasm is trying to determine the file length of /dev/urandom and is of course unable to.

open("//dev/urandom", O_RDONLY) = 3
lseek(3, 0, SEEK_END) = 0

thus, value out of range is because of the end returning 0... Hmm.


do a
dd if=/dev/urandom of=./tmp_rand_file bs=1 count=n

where n is how much bytes
Post 30 May 2014, 19:47
View user's profile Send private message Reply with quote
redsock



Joined: 09 Oct 2009
Posts: 357
Location: Australia
redsock
revolution wrote:
You could do any of:
  • Write a small program to write a single random byte to a file periodically
  • Edit fasm source code to force it to read the requested bytes for zero length streams
  • Manually edit you source code with a new value before assembling
  • Increase the clock speed of you system to make it unreliable and produce random binaries each time
  • Wait hundreds (thousands?) of years for the bits to decay into a different state
  • Others?


BAHAH, love your work revolution!

It is actually for fixed Diffie-Hellman public parameters, which are fine to stay relatively static (when sufficiently large), but I thought the compile-time randomized selection from a pool of my verified safe primes would be a cool thing to add.

Grabbing bytes from the PRNG before compile time certainly works, I was just hoping for a funky way to do it in the fasm source itself instead of scripting the build process and/or Makefiles.

Cheers and thanks for the chuckles anyway, hahah! Legend!

This one in particular:

Quote:
Increase the clock speed of you system to make it unreliable and produce random binaries each time
HA! that is a crackup.
Post 30 May 2014, 22:51
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.