While messing around with DTrace, I devised a way to extract the Apache version with a simple DTrace script (this of course can be acquired with telnet and netcat, but it’s fun doing things with DTrace):
$ cat version.d
#pragma D option quiet
pid$target::ap_get_server_version:return
{
printf("Apache web Server Version: %sn",copyinstr(arg1));
}
$ for i in
pgrep httpd; do dtrace -p i -s version.d & done
[1] 24581
[2] 24582
[3] 24583
Apache web Server Version: Apache/2.0.54 (Unix)
Apache web Server Version: Apache/2.0.54 (Unix)
Apache web Server Version: Apache/2.0.54 (Unix)
Apache web Server Version: Apache/2.0.54 (Unix)
$ pkill dtrace
This example utilizes the pid provider to catch returns from ap_get_server_version, and prints the function return value as a string (the return value is a pointer to a global variable named server_version, which contains the token definition from the ServerTokens command). I looooooooooooooves me some DTrace!