Trustwave and Cybereason Merge to Form Global MDR Powerhouse for Unparalleled Cybersecurity Value. Learn More

Trustwave and Cybereason Merge to Form Global MDR Powerhouse for Unparalleled Cybersecurity Value. Learn More

Services
Managed Detection & Response

Eliminate active threats with 24/7 threat detection, investigation, and response.

Co-Managed SOC (SIEM)

Maximize your SIEM investment, stop alert fatigue, and enhance your team with hybrid security operations support.

Advisory & Diagnostics

Advance your cybersecurity program and get expert guidance where you need it most.

Penetration Testing

Test your physical locations and IT infrastructure to shore up weaknesses before exploitation.

Database Security

Prevent unauthorized access and exceed compliance requirements.

Email Security

Stop email threats others miss and secure your organization against the #1 ransomware attack vector.

Digital Forensics & Incident Response

Prepare for the inevitable with 24/7 global breach response in-region and available on-site.

Firewall & Technology Management

Mitigate risk of a cyberattack with 24/7 incident and health monitoring and the latest threat intelligence.

Solutions
BY TOPIC
Microsoft Security
Unlock the full power of Microsoft Security
Offensive Security
Solutions to maximize your security ROI
Rapidly Secure New Environments
Security for rapid response situations
Securing the Cloud
Safely navigate and stay protected
Securing the IoT Landscape
Test, monitor and secure network objects
Why Trustwave
About Us
Awards and Accolades
Trustwave SpiderLabs Team
Trustwave Fusion Security Operations Platform
Trustwave Security Colony
Partners
Technology Alliance Partners
Key alliances who align and support our ecosystem of security offerings
Trustwave PartnerOne Program
Join forces with Trustwave to protect against the most advance cybersecurity threats

Installing VMware Tools on Kali Linux and Some Debugging Basics

I have been using Backtrack for a while now and decided to switch to Kali Linux, a new open source distribution by the creators of Back track. It's built on Debian and is FHS compliant, which is a very good thing.

So I downloaded the VMware image from the Kali Linux download page and ran it using VMware Fusion. The first thing I did (and I guess everybody does) was run an "apt-get update && apt-get dist-upgrade" to upgrade the system. Immediately after that, I found an annoying issue when trying to drag and drop files from the host into the VM. Here is the error message I got each time I tried to copy a file:

"There was an error getting information about …"

11793_ca2b249f-662d-4eaf-838e-ccc6b389b31d

Apparently, the VMware Tools needed to be upgraded and, believe me, it was not an easy task.

Vmware Tools Installation

To install the VMware Tools, I selected "Reinstall VMware Tools" from the "Virtual Machine" menu (I am using VMware Fusion 5.0.3 on Mac OS X, but the same procedure should apply on other platforms and versions).

8862_3dfd87c8-c8cd-4244-bf24-2d7afeee6446

This automatically mounted a virtual CD containing the installation software.

10160_7be3e28c-18b0-4e8f-9f4c-ba105963fa61

My next step would be to copy the compressed file, un tar it and run the installer (the version at the time of writing was 9.2.2-893683). This process is not as easy as it might appear:

# cp /media/cdrom/VMwareTools-9.2.2-893683.tar.gz .# tar xzvf VMwareTools-9.2.2-893683.tar.gz# cd  vmware-tools-distrib/# ./vmware-install.pl

After answering some questions with the default options, I ended up with the following:

11610_c16e3c11-1495-4d62-8136-833aed38a4a8

I needed to dig deeper into the vmware-config-tools.pl code to understand what was going on.

Looking at vmware-config-tools.pl

When I opened the file /usr/bin/vmware-config-tools.pl with my favorite editor and searched for the string "is not a valid path to," I found this at line 6152:

BSL_9137_4b6be0a5-7eb9-4504-a271-91a319869bfa

Apparently, $kh_path was empty (""), and I needed to find out why. The first parameter of the get ValidKernel Headers Path()function is $kh_path and upon further review I found the code responsible for setting its value (line 6192):

$gKernelHeaders = `$modconfig --get-kernel-headers $mcKverOpt $appLoaderArgs`;

I just added this code right after the line6192 in vmware-config-tools.pl to find out what the command actually is:

print("$modconfig --get-kernel-headers $mcKverOpt $appLoaderArgs");

Running the tool again gave me this:

12619_f12a82ba-210d-4e18-9189-a21d37b03905

Next I tried executing this command:

8032_13cf0c09-2e39-4388-babf-4e32b9d8c682

As I expected, nothing happened. I had to plunge further and find out which files the tool was calling. I suspected that missing files might have been the issue.

Tracing the system calls with strace I found the following:

# apt-get install strace# strace '/usr/lib/vmware-tools/sbin32/vmware-modconfig-console' --validate-kernel-headers -k 3.7-trunk-686-pae "" -- -l "/usr/lib/vmware-tools"

Here is the interesting part:

BSL_12668_f3549705-5cab-4617-bb79-5265b8efc291

...[SNIP]...access("/lib/modules/3.7-trunk-686-pae/build/include/linux/version.h", F_OK) = -1 ENOENT (No such file or directory)...[SNIP]...

With that, I'd discovered the issue: the file/lib/modules/3.7-trunk-686-pae/build/include/linux/version.h was missing.

To fix it, I used this:

# cd /lib/modules/3.7-trunk-686-pae/build/include/# ln -s /usr/src/linux-headers-3.7-trunk-686-pae/include/generated/uapi/linux/version.h linux/version.h

And I was presented with the following after running vmware-config-tools.pl again:

11077_a793caf8-ec13-46d2-b1a0-f30db8d62ce0

"Excellent," I thought, "it's fixed." In actuality, there was more work to do:

10449_89c53681-f79b-467e-8f7d-33a2ba4d4b16

Some of the services reported an error, and one in particular didnot start:

...[SNIP].../etc/init.d/vmware-tools: 1088: local: ': bad variable name     Blocking file system:      failed...[SNIP]...

Fixing /etc/init.d/vmware-tools

It seems that the service initialization script also needed to be fixed. For more details, I opened the /etc/init.d/vmware-tools file to see what lies at line 1088:

local run_kver=`get_version_integer`

The get_version_integer() function is defined as follows:

9392_579b38c3-78db-4c8c-ae66-08a579320f63

As you can see above, the script gets the kernel version number by running the "uname –r" command and parsing the result string.

Running the command gave me this:

# uname –r3.7-trunk-686-pae

The issue here is that the script is expecting a set of three numbers (kernel version, major revision and minor revision), but here the u name command only returns two numbers: the kernel version and the major revision (3.7).

When the script called the kernel_version_integer() function, the calling parameter values were wrong:

v1="3"v2="7-trunk-686-pae"v3=""

Here is the kernel_version_integer() function definition:

kernel_version_integer() {  echo $(((($1 * 256) + $2) * 256 + $3))}

The error was that the following operation was executed and, obviously, it failed:

((3 * 256) + 7-trunk-686-pae) * 256 +

The correct operation should be:

((3 * 256) + 7) * 256 + 0

So we have two issues here: v2 is not correctly parsed and v3 is not set to zero.

Here is how I quickly fixed the code of the get_version_integer()function:

get_version_integer() {  local version_uts  local v1  local v2  local v3   version_uts=`uname -r`   # There is no double quote around the back-quoted expression on purpose  # There is no double quote around $version_uts on purpose  set `IFS='.'; echo $version_uts`  v1="$1"  v2="$2"  v3="$3"  # There is no double quote around the back-quoted expression on purpose  # There is no double quote around $v3 on purpose  if [ -z "$v1" ]; then    v1="0"  else    set `IFS='-ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz'; echo $v1`    v1="$1"  fi  if [ -z "$v2" ]; then    v2="0"  else    set `IFS='-ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz'; echo $v2`    v2="$1"  fi  if [ -z "$v3" ]; then    v3="0"  else    set `IFS='-ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz'; echo $v3`    v3="$1"  fi kernel_version_integer "$v1" "$v2" "$v3"}

I found that this resolved the error:

12371_e7768cd7-c99f-44b0-9a1c-9ffb89570522

Perfect! The services started successfully.

Keep in mind that I ran vmware-config-tools.pl. If you want to re-run the whole installation with vmware-install.pl, the file/etc/init.d/vmware-tools will be overwritten. In that case, you would need to modify the file vmware-tools-distrib/installer/services.sh in the VMware Tools installation directory because it will overwrite/etc/init.d/vmware-tools.

Conclusion

It is not always easy to update VMware Tools utility, especially when using non-common Linux distributions. I haven't tried the VMware Fusion 6.0 yet and don't know if these issues are still there, but I'm sure you will have to adapt the fixes according to the errors you may find.

I hope this post will be useful and will save you some time. But remember, debugging basics are important, and you may have to repeat the process for the next kernel or VMware upgrade.

ABOUT TRUSTWAVE

Trustwave is a globally recognized cybersecurity leader that reduces cyber risk and fortifies organizations against disruptive and damaging cyber threats. Our comprehensive offensive and defensive cybersecurity portfolio detects what others cannot, responds with greater speed and effectiveness, optimizes client investment, and improves security resilience. Learn more about us.

Latest Intelligence

Discover how our specialists can tailor a security program to fit the needs of
your organization.

Request a Demo