On 08/26/2011 01:23 PM, Jameson Williams wrote:
> On 08/26/2011 09:16 AM, Daniel Herrington wrote:
>> Does anyone know a way to do a scan of a remote server to get the bitness?
>>
>> I tried nmap -O but the output does not say if it's 64 or 32 bit.
>>
> I'm seeing the value you want in the nmap fingerprint output via:
>
> nmap -A -vvv<hostname>
>
> ...
> OS:x86_64-unknown-linux-gnu...
> ...
>
> There probably is a more succinct way to get the info, though.
Well here, and so for fun, here's a quick 'n' dirty bash script to
automate the task over n hosts given at the command line, e.g.
Usage: ./detect_bitness <host1 [host2 ...]>
#!/bin/bash
function die() {
echo "$@"
exit 1
}
function detect_os() {
output=$(nmap -A -vvv "$@")
[ -z "$output" ] && die "Bad output from nmap."
arch=$(echo $output | grep x86_64)
if [ -z "$arch" ]; then
# Assume limited set of archs;
# only modern and Genuine Intel (tm) brand certified
processors ;-)
echo "32"
else
echo "64"
fi
}
[ "x$EUID" == "x0" ] || die "Run as root."
while read line; do
hosts=($line)
for host in ${hosts[@]}; do
bitness=$(detect_os "$host")
echo "$host: $bitness"
done
done <<< "$@"
_______________________________________________
PLUG mailing list
[email protected]
http://lists.pdxlinux.org/mailman/listinfo/plug