Installing Numpy on Windows 7 / 8 with Python 2.7 (Unable to find vcvarsall.bat)

Installing Numpy is as easy as running the command below:

  • pip install numpy

However, If you don’t have a C/C++ compiler installed, you can get the following error while you are trying to install Numpy on Windows 7 or 8.1:

  • error: Microsoft Visual C++ 9.0 is required (Unable to find vcvarsall.bat)

Easiest way to install Numpy is using the (unofficial) binary packages from Christoph’s site.

It worked for me, it should also work for you..

Posted in Data Analysis, Machine Learning, Python | Tagged , , | Leave a comment

MongoDB – PyMongo error while connecting to a remote server: [Errno 111] Connection refused

If you are trying to connect a remote server (e.g. Linux Ubuntu) via PyMongo, it is probable that you get an error as below:

  • pymongo.errors.ConnectionFailure: [Errno 111] Connection refused

In order to resolve this issue, you need to enable external interfaces on the remote server by commenting out the line with “bind_ip =” in MongoDB configuration file (/etc/mongodb.conf). Here are the steps you can take to achieve this:

  • Edit the MongoDB configuration file
    • sudo nano /etc/mongodb.conf
  • Find the line with “bind_ip =”
  • Add a “#” character in front of the line to comment it out
  • Save changes (Ctrl+o) to file and exit the editor (Ctrl+x)
  • Restart the MongoDB service
    • sudo service mongodb restart

By following the above steps, my issue is resolved. However, there are cases having the same error while connecting to the local server, this is because server is shut down uncleanly and need to be repaired.

Posted in Data Analysis, Linux | Tagged , , , , | Leave a comment

How to back up indexed data or change default database location in Splunk

In Splunk, data is indexed into database directories called buckets. Indexed data is transferred from one type of bucket to another as it ages. Below types of buckets are listed:

Bucket type


Default location

Hot bucket

Currently being written to

(format: hot_v1_<ID>)

<Splunk directory>\var\lib\splunk\defaultdb\db

Warm bucket

Rolled from hot

(format: db_<newest_time>_ <oldest_time>_<localid>)

<Splunk directory>\var\lib\splunk\defaultdb\db

Cold bucket

Rolled from warm

<Splunk directory>\var\lib\splunk\defaultdb\colddb

Frozen bucket

Gets deleted or archieved

Thawed bucket

Archieved and later thawed data

<Splunk directory>\var\lib\splunk\defaultdb\thaweddb

Firstly, data is written to a hot bucket. When hot bucket reaches to a specified size/age or whenever Splunkd service gets restarted, data in hot bucket moved/rolled into a warm bucket. When number of warm buckets reaches to a value (default: 300), data in oldest warm bucket is moved/rolled into a cold bucket.

To backup indexed data

  • Simply copy the following directories and their entire content to another location:
    • <Splunk directory>\var\lib\splunk\defaultdb\db
      <Splunk directory>\var\lib\splunk\defaultdb\colddb
      <Splunk directory>\var\lib\splunk\defaultdb\thaweddb
      (* default splunk directory: “C:\Program Files\Splunk”)

Note: If there is a hot bucket (in format “hot_v1_<ID>”), carry out one of the following steps to roll it to a warm bucket:

  • Simply restart the Splunkd service in command line (preffered)
    • net stop/start splunkd
  • Or manually roll hot bucket to warm in command line (not preffered)
    • splunk _internal call /data/indexes/<index_name>/roll-hot-buckets –auth <admin_username>:<admin_password>

To change default database location

  • Stop Splunkd service in command line
    • net stop splunkd
  • Copy indexes.conf file under “<Splunk directory>\etc\system\default” to “<Splunk directory>\etc\system\local”
  • Edit indexes.conf file under “<Splunk directory>\etc\system\local” as below:
    • Locate the “index definitions” section
    • Change the location of each database under “[main]” tag as below:
      • homePath: <New database path>\db
        coldPath: <New database path>\colddb
        thawedPath: <New database path>\thaweddb
        (* example new database path: “C:\Splunk DB\project 1”)
  • Start Splunkd service
    • net start splunkd

Posted in Data Analysis | Tagged , , , | Leave a comment

How to set your VM to auto start at system startup in VirtualBox 4.2 on Ubuntu 12.04

There is a handy feature in VirtualBox 4.2 that lets you configure your VM to be automatically started every time system starts up. Below you can find the steps needed to configure your VirtualBox installation to achieve that on Ubuntu 12.04 LTS.

First, edit the default virtualbox configuration file and add the path to autostart database directory file and autostart configuration file to it.

  • nano /etc/default/virtualbox
  • Add the following entries:
    • VBOXAUTOSTART_DB=/etc/vbox

Since we have added the autostart configuration file path to virtualbox configuration file, create it and specify the virtualbox user that is allowed to start VM (mine is my-vbox-user).

  • nano /etc/vbox/vboxauto.conf
  • Add an entry for each user allowed to run autostart:
    • default_policy = deny
      my-vbox-user = {
      allow = true

In order vboxusers to write to the vbox directory, set permissions on it and also the sticky bit (make sure my-vbox-user is in the vboxusers group).

  • chgrp vboxusers /etc/vbox
  • chmod 1775 /etc/vbox

Set the path to the autostart database directory for the user allowed above (my-vbox-user).

  • VBoxManage setproperty autostartdbpath /etc/vbox

Set VirtualBox to automatically start the VM (my-VM) when system starts up and poweroff it when system halts.

  • VBoxManage modifyvm my-VM –autostart-enabled on –autostop-type poweroff
  • After executing it, you should have the following files under the directory/etc/vbox:
    • my-vbox-user.start

Restart the vboxauto service for changes to take effect.

  • service vboxautostart-service stop
    service vboxautostart-service start
Posted in Linux, Virtualization | Tagged , , , | 10 Comments

Shrink/reduce size of WinSxS folder on Windows 7 and gain gigabytes of free space

WinSxS folder contains a copy of protected system files and DLLs. Windows Resource Protection mechanism checks the integrity of the protected system files periodically and  re-installs any protected file from this folder if its integrity could not be verified due to a compromise or corruption.

After each Windows update, some system files are changed by Microsoft. However, WinSxS folder still keeps the old files along with the new system files in case the updates are roll backed. Therefore, size of this folder keeps growing and growing with each update, especially after each service pack installations.

Finally, you can shrink or reduce the size of the WinSxS folder on Windows 7 SP 1 by using the following command (if you are not planing to uninstall the service packs):

  • DISM.exe /Online /Cleanup-Image /SpSuperseded
Posted in Windows Security | Tagged , , | 1 Comment

Installing VirtualBox (4.2) and phpVirtualBox (4.2.4) on headless Ubuntu Server (12.04 LTS)

Ubuntu 12.04 LTS Server is a headless server and does not have X-Window, therefore phpVirtualBox is needed to manage VirtualBox. There are two steps covered here in this post; one for instaling Virtualbox 4.2.4 and the other one for installing phpVirtualbox 4.2.4 (the most current version at the time of writing this post).

Step 1. Installing VirtualBox 4.2

  • Download the Oracle public key for apt-secure and register it as below:
  • Add VirtualBox repository to Ubuntu’s package resource list and update it
  • Install VirtualBox 4.2
    • sudo apt-get install virtualbox-4.2
  • Add a local user to the “vboxusers” group for using VirtualBox
    • sudo adduser <your-local-user> vboxusers
  • Create a config file for VirtualBox under “/etc/default” and add the local user as a VirtualBox web service user
    • sudo nano /etc/default/virtualbox
    • Locate the line starting with “VBOXWEB_USER” and change it as below
      • VBOXWEB_USER=<your-local-user>
  • Download and install the VirtualBox Extension Pack for the remote desktop connection to the virtual machines

Step 2. Installing phpVirtualBox 4.2.4

  • Install LAMP (Linux, Apache, Mysql, Php) components (keep the ‘^’ at the end)
    • sudo apt-get install lamp-server^
    • Check the web server installation
      • http://localhost
    • Check the PHP installion
      • echo “<?php phpinfo(); ?>” | sudo tee /var/www/testing.php
      • http://localhost/testing.php
  • Download phpVirtualBox according to the installed VirtualBox version (4.2)
    • wget
  • Unzip the contents of the
    • unzip
    • (If unzip is not installed: sudo apt-get install unzip)
  • Create a directory for phpVirtualBox under “/var/www” and copy the contents of unzipped there
    • sudo mkdir /var/www/phpvirtualbox
    • sudo cp -R phpvirtualbox-4.2-4/* /var/www/phpvirtualbox
  • Prepare the phpVirtualBox config file
    • sudo cp /var/www/phpvirtualbox/config.php-example /var/www/phpvirtualbox/config.php
  • Enter the local user’s credential to the “$username” and “$password” fields in the config file
    • var $username = ‘<your-local-user>’
    • var $password = ‘<your-local-user-pass>’
  • Start the VirtualBox web service
    • sudo /etc/init.d/vboxweb-service start
  • Restart the server
    • sudo shutdown -r now
  • Connect to the web interface of phpVirtualBox
    • http://localhost/phpvirtualbox
      • username: admin
      • password: admin

That’s the whole process to get phpVirtualBox work properly along with VirtualBox. I hope it also worked for you.

Posted in Linux, Virtualization | Tagged , , , , | Leave a comment

Virtualbox – VBoxManage: error: Adding machine ‘Ubuntu-VM’ to the autostart database failed with VERR_ACCESS_DENIED

In Ubuntu 12.04 LTS, I tried to configure Virtualbox 4.2 to start my VM automatically when the system starts up. However, I got an error message as below after following the instructions in chapter 9.24.1 in Virtualbox User Manual:

VBoxManage: error: Adding machine ‘Ubuntu-VM’ to the autostart database failed with VERR_ACCESS_DENIED

Then I realized that I missed giving write acccess for virtualbox users on autostart database directory (/etc/vbox) and setting the sticky bit:

  • sudo chgrp vboxusers /etc/vbox
  • sudo chmod 1775 /etc/vbox

* Check if your user is in vboxusers group by executing “groups <userid>” command.

I set the autostart database directory for the user:

  • VBoxManage setproperty autostartdbpath /etc/vbox

And executed once again the command to set my VM (Ubuntu-VM) to automatically startup:

  • VBoxManage modifyvm Ubuntu-VM –autostart-enabled on

* After executing this command, you should have <userid>.start file under /etc/vbox directory.
** If you still get the same error message, manually create <userid>.start file under /etc/vbox.

I restarted the vboxauto service for changes to take effect:

  • sudo service vboxautostart-service stop
  • sudo service vboxautostart-service start

After setting the required write permission and sticky bit on the /etc/box directory, it worked.

Posted in Linux, Virtualization | Tagged , | 2 Comments

How to remove administrative shares in Windows XP, Vista and 7

In order to remove administrative shares in Windows, add the following two registry keys to the registry.

  • To remove administrative shares for local administrator accounts, add the following key to the specified location;

Key: SYSTEM\CurrentControlSet\Services\LanManServer\Parameters
Name: AutoShareWks
Value: 0

  • To remove administrative shares for domain administrator accounts, add the following key to the specified location;

Key: SYSTEM\CurrentControlSet\Services\LanManServer\Parameters
Name: AutoShareServer
Value: 0

After editing the registry, restart the Workstation and Server services to take the chances effect without restarting the computer.

        • Restart the Workstation service;

net stop/start lanmanworkstation

        • Restart the Server service;

net stop/start lanmanserver

Posted in Windows Security | Tagged , | Leave a comment

Installing Python Pefile and UPX on Amazon Linux AMI (Especially for SET)

If your application (e.g. SET) requires python pefile or UPX, you can not install them easily using Yum package manager on Amazon Linux AMI because Amazon’s default repositories do not contain these packages. However, you can install them as described below:

Installing Python Pefile

  • Download pefile zip file (current version as this post is posted)
    • wget
  • Unzip the downloaded zip file
    •  unzip
  • Change directory to unzipped folder and install the pefile
    • cd pefile-1.2.10-114
    • python install

Installing UPX

  • Get the UPX rpm package (for 32 bit)
    •  rpm -ivh
  • Clean the repository and install the UPX using yum package manager
    • yum clean all
    • yum install upx.i686

It took some time for me to get them installed on Amazon Linux AMI, so I hope you can save some time by reading this post.

Posted in Bulut Bilişim - Cloud Computing, Linux, Penetration Testing | Tagged , , , | Leave a comment