See all GNU/Linux related FAQ
The GHOST (CVE-2015-0235) is serious network function vulnerability in Glibc. How do I check and test if a my Linux based server is secure using command line options?

There are two methods to test and find out if your server or desktop powered by Linux is secure or not:

(a) A simple C test program for all Linux based servers (distro independent; generic method). [donotprint]

Tutorial details
Difficulty level Easy
Root privileges No
Requirements Linux
Est. reading time 2 minutes

(b) A simple bash shell test program for RHEL or CentOS or Scientifc Linux server only.

Method #1: GHOST.C Glibc Vulnerability Test C Program

Type the following wget command to download GHOST.C on a Linux based system:

## OR
wget -O GHOST.c

Compile it:

gcc -o GHOST GHOST.c

Test i:


Sample outputs:

Fig. 01: GHOST.c  bug:  A simple way to test if Linux system is secure or not

Fig. 01: GHOST.c bug: A simple way to test if Linux system is secure or not

Method #2: Vulnerability Test Bash Script

Visit this url to download a script (or grab it here). You need to have an account with RHN. The script tells whether your system is vulnerable or not. Run script as follows:

wget -O

Sample outputs:

Fig.02: Fig.02: output on a RHEL/CentOS  based system

Fig.02: Fig.02: output on a RHEL/CentOS based system

What to do if my server is not secure or Vulnerable to the Ghost attack?

See this tutorial page for securing your server by applying patches to glibc.

This entry is 1 of 2 in the Linux GHOST Glibc Critical Security Vulnerability series. Keep reading the rest of the series:
  1. Check Ghost Vulnerability Test Programs
  2. Secure and Patch Your Linux Server For Ghost Bug

πŸ₯Ί Was this helpful? Please add a comment to show your appreciation or feedback.

nixCrat Tux Pixel Penguin
Hi! 🀠
I'm Vivek Gite, and I write about Linux, macOS, Unix, IT, programming, infosec, and open source. Subscribe to my RSS feed or email newsletter for updates.

17 comments… add one
  • Jon Zeolla Jan 28, 2015 @ 14:18

    Linux Sever should be Linux Server

  • Deltaray Jan 28, 2015 @ 14:42

    The md5sum of the GHOST.c code from the website that I tested with is


    You should always check this before compiling downloaded code, otherwise the next exploit on you will be a man in the middle attack.

  • Jacob Jan 28, 2015 @ 15:16

    Where’d you hear about ghost.c on uchicago’s webshare?

  • Stu Jan 28, 2015 @ 18:23

    That’s odd, the MD5 I get is d0ed67a61753e568596a830e7171a8eb. Which one of has the right version?

    • Deltaray Jan 28, 2015 @ 19:37

      There are probably slightly different versions going around with differing whitespace, etc. I mentioned the site because its probably more static than the gist URL. Either way, just make sure that you’re downloading something legit.

      • Stu Jan 29, 2015 @ 18:16

        I would agree with that last sentence. But then, how trustworthy am I? You might try to see if you can reverse the hash I posted.

        Reviewing the code might not be entirely sufficient as the MITM could exclude vulnerable versions but ilthe code could appear safe to run.

    • Samir Jan 29, 2015 @ 3:07

      Try get MD5 hash of source code file => GHOST.c

  • jmstrupp Jan 28, 2015 @ 19:27

    Single Step:

    # curl -L | sh -s --
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  2172  100  2172    0     0   7676      0 --:--:-- --:--:-- --:--:--  7674
    Vulnerable glibc version <= 2.17-54
    Vulnerable glibc version <= 2.5-122
    Vulnerable glibc version <= 2.12-1.148
    Detected glibc version 2.17 revision 55
    Not Vulnerable.
    • Deltaray Jan 29, 2015 @ 18:28

      If your concern is security, then don’t pipe shell scripts directly into your shell.

  • Y. Jan 28, 2015 @ 19:32

    $ md5sum GHOST.c
    a19b0657c80d74ea5c4f4544dc9998c5 GHOST.c
    $ md5sum

    $ ./GHOST
    $ bash
    Vulnerable glibc version <= 2.17-54
    Vulnerable glibc version <= 2.5-122
    Vulnerable glibc version <= 2.12-1.148
    Detected glibc version 2.12 revision 149
    Not Vulnerable.

    • πŸ›‘οΈ Vivek Gite (Author and Admin) nixCraft Jan 29, 2015 @ 5:40

      The script has been updated.

  • Palant Jan 29, 2015 @ 12:00

    A practical thing (hope it could be helpful for anyone). You don’t need to reboot the whole server after updating. If you are not able to do reboot β€” use this cmd which relaunchs only several applications that actually use vulnerable glibc:

    for s in $(lsof | grep libc | awk '{print $1}' | sort | uniq); do if [[ -f "/etc/init.d/$s" && "$(ps aufx | grep -v grep | grep $s)" ]]; then echo $s; service $s restart; fi; done


  • Nhoya Feb 5, 2015 @ 11:50
    #GHOST vulnerability detector (DEBIAN & co.)
    libc_main_vers=$(dpkg -l | grep libc6 | awk '{ print $3 }' | awk -F . '{ print $1 }')
    upd=$(dpkg -l | grep libc6| awk '{ print $3 }'| tail -c 2)
    sub=$(dpkg -l | grep libc6| awk '{ print $3 }'| awk -F . '{print$2}' |head -c 2)
    for ver in ${libc_main_vers}; do
        if (( ver = 2  && upd >= 7 && sub >= 12 )); then
            echo not vulnerable
            if ((ver > 2 )); then
                    echo not vulnerable
                    echo "vulnerable to GHOST (CVE-2015-0235)"
    exit 0  

    This is the script working for Debian (

  • stb_in_va Feb 6, 2015 @ 20:37

    Great write up!

    Are Solaris glib packages vulnerable? Not finding anything online (or from Oracle) about it.



  • wan Mar 11, 2015 @ 15:22

    sorry guys…my server doesnt have rpm package..and i am unable to connect it to any internet connection since it is prohibited. But i still need to check the vulnerability of our system. How can i do it ? thx

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre> for code samples. Your comment will appear only after approval by the site admin.