Here is a simple banner grabber written in awk. all it does is query the http server and extracts the 'Server' paramater from the HTTP header and returns the result.
#!/usr/bin/env gawk BEGIN { } { ## START _MAIN port=80; getline host<ARGV[1] HTTP = "/inet/tcp/0/" host "/" port PROCINFO[HTTP, "READ_TIMEOUT"] = 1000 print "HEAD / HTTP/1.0\r\n\r\n" |& HTTP while ( (HTTP |& getline) > 0) { if ($1 ~ /Server:/) print $0 } close("/inet/tcp/0/" host "/80") } ## END _MAIN END { }
If we run the script...
root@asus:~/pentest_notes/SCANNING% awk -f simple_banner_grabber.awk awk.txt Server: Apache/2.4.18 (Ubuntu) root@asus:~/pentest_notes/SCANNING%
BASH example
Here an example in Bash.
#!/usr/bin/env bash ## ## Simple HTTP banner grabber ## host="127.0.0.1" port=80 exec 3<>/dev/tcp/${host}/${port} echo -e "HEAD / HTTP/1.0\r\n\r\n" >&3 cat <&3 | awk '/Server: (.+)/ {print $0}'
We run the script...
root@asus:~/pentest_notes/SCANNING% ./simple_banner_grabber.sh Server: Apache/2.4.18 (Ubuntu) root@asus:~/pentest_notes/SCANNING%
No comments:
Post a Comment