21.03.2013 Views

Problem - Kevin Tafuro

Problem - Kevin Tafuro

Problem - Kevin Tafuro

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Discussion<br />

We strongly recommend that you do not increase your entropy estimates<br />

based on any kernel state collected, particularly on a system that<br />

is mostly idle. Much of the time, kernel state changes more slowly<br />

than people think. In addition, attackers may be able to query the<br />

same data and get very similar results.<br />

The internal state of an operating system can change quickly, but that does not mean<br />

there is necessarily any entropy there to collect. See Recipe 11.19 for a discussion<br />

about estimating how much entropy you are getting.<br />

Definitely do not query sources like these very often, because you are unlikely to get<br />

additional entropy running in a tight loop, and the overhead involved is extremely<br />

high.<br />

On systems with a /proc filesystem, pretty much all of the interesting operating system–specific<br />

information you might want to query is available by reading the files in<br />

the /proc directory. The contents of the files in that directory are updated as the user<br />

reads from those files. Open the files anew every time you want to poll for possible<br />

entropy.<br />

On systems without /proc, you can try to get information by running commands<br />

that might change frequently and capturing all the data in the command. Be sure to<br />

call out to any commands you run in a secure manner, as discussed in Recipes 1.7<br />

and 1.8.<br />

When calling commands, state does not actually change very quickly at all, particularly<br />

on systems with few users. It is popular to query the ps and df commands (using<br />

the flags that give the most entropy, of course), but there is often almost no entropy<br />

in the output they produce.<br />

Other commands that some operating systems may have, where there might be some<br />

frequent change (though we would not count on it) include the following:<br />

• sysctl: Use the -A flag.<br />

• iostat<br />

• lsof<br />

• netstat: Use the -s flag if you want to see highly detailed information that may<br />

change frequently on machines that see a lot of network traffic.<br />

• pstat<br />

• tcpdump: Ask it to capture a small number of packets.<br />

• vmstat<br />

Gathering Entropy from System State | 645<br />

This is the Title of the Book, eMatter Edition<br />

Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!