LINUX


Monday 29 July 2013

Linux / Unix pv Command: Monitor Progress of Data Sent Via a Pipe

Linux / Unix pv Command: Monitor Progress of Data Sent Via a Pipe

The pv command allows you to see the progress of data through a pipeline. It provides the following info:
  1. Time elapsed
  2. Percentage completed (with progress bar)
  3. Current throughput rate
  4. Total data transferred
  5. ETA

From the project home page:
It can be inserted into any normal pipeline between two processes to give a visual indication of how quickly data is passing through, how long it has taken, how near to completion it is, and an estimate of how long it will be until completion.

How do I install pv command?

By default pv command is not installed. Type the following apt-get command under Debian / Ubuntu Linux:
# apt-get install pv
Sample outputs:
 
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
  doc-base
The following NEW packages will be installed:
  pv
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 28.9 kB of archives.
After this operation, 143 kB of additional disk space will be used.
Get:1 http://mirror.anl.gov/debian/ squeeze/main pv amd64 1.1.4-1 [28.9 kB]
Fetched 28.9 kB in 1s (16.1 kB/s)
Selecting previously deselected package pv.
(Reading database ... 32240 files and directories currently installed.)
Unpacking pv (from .../archives/pv_1.1.4-1_amd64.deb) ...
Processing triggers for man-db ...
Setting up pv (1.1.4-1) .
 
RHEL / CentOS / SL / Fedora Linux users, turn on EPEL repo and type the following yum command to install pv:
# yum install pv
Sample outputs:
 
Loaded plugins: product-id, protectbase, rhnplugin, subscription-manager
Updating certificate-based repositories.
Unable to read consumer identity
0 packages excluded due to repository protections
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package pv.x86_64 0:1.1.4-3.el6 will be installed
--> Finished Dependency Resolution
 
Dependencies Resolved
 
====================================================================================================
 Package            Arch                   Version                       Repository            Size
====================================================================================================
Installing:
 pv                 x86_64                 1.1.4-3.el6                   epel                  34 k
 
Transaction Summary
====================================================================================================
Install       1 Package(s)
 
Total download size: 34 k
Installed size: 67 k
Is this ok [y/N]: y
Downloading Packages:
pv-1.1.4-3.el6.x86_64.rpm                                                    |  34 kB     00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : pv-1.1.4-3.el6.x86_64                                                            1/1
Installed products updated.
  Verifying  : pv-1.1.4-3.el6.x86_64                                                            1/1
 
Installed:
  pv.x86_64 0:1.1.4-3.el6
 
Complete!
 
FreeBSD users can use the port to install pv, enter:
# cd /usr/ports/sysutils/pv/
# make install clean

OR add the binary package, run:
# pkg_add -r pv

pv Command syntax

The syntax is
 
pv filename
pv filename > /path/to/output
pv options filename | command1
pv options filename | command1 > output.file
pv filename | command1
command1 | pv | command2
pv -options input.file | command1 | pv -options > output.file
 

pv command Examples

In this example copy a file called origin-cdn.cyberciti.org_access.log to /tmp/origin-cdn-access.log and show progress:
# pv origin-cdn.cyberciti.org_access.log > /tmp/origin-cdn-access.log
OR just send it to /dev/null:
# pv origin-cdn.cyberciti.org_access.log > /dev/null
1.41GB 0:00:21 [66.3MB/s] [=====================================================>] 100%
Use nc to create a network port # 2000. Type the following command:
$ nc -l -v -w 30 -p 2000 > /tmp/data.bin
Open another terminal and type:
$ pv firmware33921.bin | nc -w 1 127.0.0.1 2000
Sample outputs:
Fig.01: pv command in action
Fig.01: pv command in action

In this example you can see progress of both pipes:
 
pv -cN rawlogfile origin-cdn.cyberciti.org_access.log | gzip | pv -cN gziplogfile > access.log.gz
 
Sample outputs:
Fig.02: pv displaying output of complicated pipes and commands
Fig.02: pv displaying output of complicated pipes and commands

Where,
  • -c : Use cursor positioning escape sequences instead of just using carriage returns. This is useful in conjunction with -N (name) if you are using multiple pv invocations in a single, long, pipeline.
  • N rawlogfile : Prefix the output information with NAME. Useful in conjunction with -c if you have a complicated pipeline and you want to be able to tell different parts of it apart.

pv and dialog command

You can create a progress bar (progress indicator) when copying/moving/extracting files or making backups using the gauge box:
 
echo percentage | dialog --gauge "text" height width percent
echo "10" | dialog --gauge "Please wait" 10 70 0
echo "50" | dialog --gauge "Please wait" 10 70 0
echo "100" | dialog --gauge "Please wait" 10 70 0
 
In this example, extract tar ball and show progress using the dialog command:
 
(pv -n backup.tar.gz | tar xzf - -C path/to/data ) 2>&1 | dialog --gauge "Running tar, please wait..." 10 70 0
 
Sample outputs:
Fig.03: pv and dialog command in action
Fig.03: pv and dialog command in action
Finally, you can always use the rsync command to display progress bar for both local and remote files.

Unix / Linux Command For Tracking Down Wasted Disk Space

agedu: Unix / Linux Command For Tracking Down Wasted Disk Space

Most sysadmin will run low on disk space. Users will demand more space and you need to free space. You will find out files that's a waste of space and delete it or move to an archive medium. But, how do you find the right files to delete that can help recover maximum space? Say hello to agedu tool (pronounced as 'age dee you') - it scans a directory tree and produces reports about how much disk space is used in each directory and subdirectory, and also how that usage of disk space corresponds to files with last-access times a long time ago. In other words, this command might help you to free up disk space.

du vs agedu

The du command summarize disk usage of each file, recursively for directories. This tool is like du, but unlike du, it also distinguishes between large collections of data which are still in use and ones which have not been accessed in months or years - for instance, large archives downloaded, unpacked, used once, and never cleaned up. Where du helps you find what's using your disk space, agedu helps you find what's wasting your disk space.

How does agedu works?

From the man page:
Most Unix file systems, in their default mode, helpfully record when a file was last accessed. Not just when it was written or modified, but when it was even read. So if you generated a large amount of data years ago, forgot to clean it up, and have never used it since, then it ought in principle to be possible to use those last-access time stamps to tell the difference between that and a large amount of data you're still using regularly.
agedu is a program which does this. It does basically the same sort of disk scan as du, but it also records the last-access times of everything it scans. Then it builds an index that lets it efficiently generate reports giving a summary of the results for each subdirectory, and then it produces those reports on demand.

Install agedu

Deiban / Ubuntu Linux user type the following apt-get command to install agedu:
# apt-get install agedu
Sample outputs:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
  agedu
0 upgraded, 1 newly installed, 0 to remove and 13 not upgraded.
Need to get 46.4 kB of archives.
After this operation, 131 kB of additional disk space will be used.
Get:1 http://debian.osuosl.org/debian/ squeeze/main agedu amd64 8928-1 [46.4 kB]
Fetched 46.4 kB in 1s (29.8 kB/s)
Selecting previously deselected package agedu.
(Reading database ... 274216 files and directories currently installed.)
Unpacking agedu (from .../agedu_8928-1_amd64.deb) ...
Processing triggers for man-db ...
Setting up agedu (8928-1) ...
FreeBSD unix user can use the port as follows:
# cd /usr/ports/sysutils/agedu/
# make install clean

OR alternatively use the binary package provided by FreeBSD:
# pkg_add -r agedu
RHEL / CentOS / Fedora / Scientific Linux user turn on EPEL repo and type the following yum command to install agedu:
# yum install agedu
Sample outupts:
 
Loaded plugins: auto-update-debuginfo, product-id, protectbase, rhnplugin,
              : subscription-manager
Updating certificate-based repositories.
Unable to read consumer identity
0 packages excluded due to repository protections
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package agedu.x86_64 0:0-2.r9153.el6 will be installed
--> Finished Dependency Resolution
 
Dependencies Resolved
 
================================================================================
 Package         Arch             Version                  Repository      Size
================================================================================
Installing:
 agedu           x86_64           0-2.r9153.el6            epel            47 k
 
Transaction Summary
================================================================================
Install       1 Package(s)
 
Total download size: 47 k
Installed size: 83 k
Is this ok [y/N]: y
Downloading Packages:
agedu-0-2.r9153.el6.x86_64.rpm                           |  47 kB     00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : agedu-0-2.r9153.el6.x86_64                                   1/1
Installed products updated.
  Verifying  : agedu-0-2.r9153.el6.x86_64                                   1/1
 
Installed:
  agedu.x86_64 0:0-2.r9153.el6
 
Complete!
 

How do I use agedu command?

First, you need to scan your disk and build an index file containing a special data structure, enter:
$ agedu -s /home/vivek
$ sudo agedu -s /var
$ agedu -s /nas05

Sample outputs:
Built pathname index, 103484 entries, 8642180 bytes of index
Faking directory atimes
Building index
Final index file size = 23654856 bytes
In above examples, I started agedu by telling it to do a scan of a directory tree and build an index for /home/vivek, /var, and /nas05 directories. Next, logical step is to query the index by typing the following command:
$ agedu -w
Sample outputs:
Using Linux /proc/net magic authentication
URL: http://127.0.0.1:42113/
Fire up a graphical web browser, type the following url:
http://127.0.0.1:42113/
Sample outputs:
Unix / Linux: Correlate Disk Usage With Last-access Times
Fig.01: agedu report

You can see a graphical representation of the disk usage in /home/vivek and its immediate subdirectories, with varying colours used to show the difference between disused and recently-accessed data. Feel free to click on any subdirectory to descend into it and see a report for its subdirectories in turn; click on parts of the pathname at the top of any page to return to higher-level directories. To terminate this mode, just press [CTRL]+[D]. You can set the network address and port number on which agedu should listen when running its web server:
$ agedu -w --address addr[:port]
$ agedu -w --address 192.168.1.5:9000

You can also control access to the web pages it serves:
$ agedu -w --address 192.168.1.5:9000 --auth basic
Sample outputs:
Username: agedu
Password: 696cv6r297upqzmt
URL: http://192.168.1.5:9000/
agedu will normally make up a username and password for you. But, you can set your own user name and password:
$ agedu -w --address 192.168.1.5:9000 --auth basic --auth-fd 0
Sample outputs:
vivek:cAnd1Bar
The authentication details should consist of the username (vivek), followed by a colon (:), followed by the password (cAnd1Bar), followed immediately by end of file (press [CTRL]+[D]).

Can I access agedu reports using terminal mode?

Type the following command (replace /home/wwwroot with actual path):
$ agedu -t /home/wwwroot
Sample outputs:
53569312    /home/wwwroot
30427672    /home/wwwroot/logs
83997004    /home/wwwroot/images
You will get a summary of the disk usage in /home/wwwroot and its subdirectories. The output is much the same format as du command. To see how much old data is there, pass the the -a option to show only files last accessed a certain length of time ago. For example, to see only files which haven't been looked at in twelve months or more:
$ agedu -t /home/wwwroot -a 12m
Sample outputs:
2220        /home/wwwroot
2236        /home

How do I see only the disk space taken by MP3 files or .AVI files?

Run the command as follows in current directory:
$ agedu -s . --exclude '*' --include '*.mp3'
$ agedu -s . --exclude '*' --include '*.avi'

To view reports, run:
$ agedu -w
The reports and first two command will cause everything to be omitted from the scan, but then the MP3 files to be put back in. If you then wanted only a subset of those MP3s, you could then exclude some of them again by adding, say, --exclude-path './steviewonder/*'
$ agedu -s ~/Downloads/drm-free/music --exclude '*' --include '*.mp3' --exclude-path './steviewonder/*'

How do I delete files and reclaim disk space again?

In my case /home/vivek/iso-images/ was taking too much space. I found out older vmware-workstation, Linux / Unix iso and binary files. I deleted all those old unwanted files and recovered 16.5GB disk space using nothing but simple rm command:
$ rm ~/iso-images/vmware*
$ rm ~/iso-images/centos-4* ~/iso-images/centos-5*

How do I remove agedu index file?

Use the ls command to see the size of agedu index file:
$ ls agedu.dat -lh
Sample outputs:
-rw------- 1 vivek vivek 23M Oct 21 01:55 agedu.dat
To remove index file, enter:
$ agedu -R
OR
$ rm agedu.dat
However, you can also put -R on the end of a command line to indicate that agedu should delete its index file after it finishes performing other operations such as displaying web pages:
$ agedu -w -R
This blog post gives you the quick tour of what agedu does. This command has many more options for complex situations that comes with usual array of unix command line options. So, I recommend that you read the man page for more information or visit the project home page to grab the latest source code:
$ man agedu

Top 30 Nmap Command Examples For Sys/Network Admins

Top 30 Nmap Command Examples For Sys/Network Admins

Nmap is short for Network Mapper. It is an open source security tool for network exploration, security scanning and auditing. However, nmap command comes with lots of options that can make the utility more robust and difficult to follow for new users.
The purpose of this post is to introduce a user to the nmap command line tool to scan a host and/or network, so to find out the possible vulnerable points in the hosts. You will also learn how to use Nmap for offensive and defensive purposes.
nmap in action
nmap in action

More about nmap

From the man page:
Nmap ("Network Mapper") is an open source tool for network exploration and security auditing. It was designed to rapidly scan large networks, although it works fine against single hosts. Nmap uses raw IP packets in novel ways to determine what hosts are available on the network, what services (application name and version) those hosts are offering, what operating systems (and OS versions) they are running, what type of packet filters/firewalls are in use, and dozens of other characteristics. While Nmap is commonly used for security audits, many systems and network administrators find it useful for routine tasks such as network inventory, managing service upgrade schedules, and monitoring host or service uptime.
It was originally written by Gordon Lyon and it can answer the following questions easily:
  1. What computers did you find running on the local network?
  2. What IP addresses did you find running on the local network?
  3. What is the operating system of your target machine?
  4. Find out what ports are open on the machine that you just scanned?
  5. Find out if the system is infected with malware or virus.
  6. Search for unauthorized servers or network service on your network.
  7. Find and remove computers which don't meet the organization's minimum level of security.

Sample setup (LAB)

Port scanning may be illegal in some jurisdictions. So setup a lab as follows:
                              +---------+
        +---------+           | Network |         +--------+
        | server1 |-----------+ swtich  +---------|server2 |
        +---------+           | (sw0)   |         +--------+
                              +----+----+
                                   |
                                   |
                         +---------+----------+
                         | wks01 Linux/OSX    |
                         +--------------------+
Where,
  • wks01 is your computer either running Linux/OS X or Unix like operating system. It is used for scanning your local network. The nmap command must be installed on this computer.
  • server1 can be powered by Linux / Unix / MS-Windows operating systems. This is an unpatched server. Feel free to install a few services such as a web-server, file server and so on.
  • server2 can be powered by Linux / Unix / MS-Windows operating systems. This is a fully patched server with firewall. Again, feel free to install few services such as a web-server, file server and so on.
  • All three systems are connected via switch.

How do I install nmap?

See:
  1. Debian / Ubuntu Linux: Install nmap Software For Scanning Network
  2. CentOS / RHEL: Install nmap Network Security Scanner
  3. OpenBSD: Install nmap Network Security Scanner

#1: Scan a single host or an IP address (IPv4)

### Scan a single ip address ###
nmap 192.168.1.1
 
## Scan a host name ###
nmap server1.cyberciti.biz
 
## Scan a host name with more info###
nmap -v server1.cyberciti.biz
 
Sample outputs:
Fig.01: nmap output
Fig.01: nmap output

#2: Scan multiple IP address or subnet (IPv4)

nmap 192.168.1.1 192.168.1.2 192.168.1.3
## works with same subnet i.e. 192.168.1.0/24
nmap 192.168.1.1,2,3
You can scan a range of IP address too:
nmap 192.168.1.1-20
You can scan a range of IP address using a wildcard:
nmap 192.168.1.*
Finally, you scan an entire subnet:
nmap 192.168.1.0/24

#3: Read list of hosts/networks from a file (IPv4)

The -iL option allows you to read the list of target systems using a text file. This is useful to scan a large number of hosts/networks. Create a text file as follows:
cat > /tmp/test.txt
Sample outputs:
server1.cyberciti.biz
192.168.1.0/24
192.168.1.1/24
10.1.2.3
localhost
The syntax is:
nmap -iL /tmp/test.txt

#4: Excluding hosts/networks (IPv4)

When scanning a large number of hosts/networks you can exclude hosts from a scan:
nmap 192.168.1.0/24 --exclude 192.168.1.5
nmap 192.168.1.0/24 --exclude 192.168.1.5,192.168.1.254
OR exclude list from a file called /tmp/exclude.txt
nmap -iL /tmp/scanlist.txt --excludefile /tmp/exclude.txt

#5: Turn on OS and version detection scanning script (IPv4)

nmap -A 192.168.1.254
nmap -v -A 192.168.1.1
nmap -A -iL /tmp/scanlist.txt 

#6: Find out if a host/network is protected by a firewall

nmap -sA 192.168.1.254
nmap -sA server1.cyberciti.biz

#7: Scan a host when protected by the firewall

nmap -PN 192.168.1.1
nmap -PN server1.cyberciti.biz

#8: Scan an IPv6 host/address

The -6 option enable IPv6 scanning. The syntax is:
nmap -6 IPv6-Address-Here
nmap -6 server1.cyberciti.biz
nmap -6 2607:f0d0:1002:51::4
nmap -v A -6 2607:f0d0:1002:51::4

#9: Scan a network and find out which servers and devices are up and running

This is known as host discovery or ping scan:
nmap -sP 192.168.1.0/24
Sample outputs:
Host 192.168.1.1 is up (0.00035s latency).
MAC Address: BC:AE:C5:C3:16:93 (Unknown)
Host 192.168.1.2 is up (0.0038s latency).
MAC Address: 74:44:01:40:57:FB (Unknown)
Host 192.168.1.5 is up.
Host nas03 (192.168.1.12) is up (0.0091s latency).
MAC Address: 00:11:32:11:15:FC (Synology Incorporated)
Nmap done: 256 IP addresses (4 hosts up) scanned in 2.80 second

#10: How do I perform a fast scan?

nmap -F 192.168.1.1

#11: Display the reason a port is in a particular state

nmap --reason 192.168.1.1
nmap --reason server1.cyberciti.biz

#12: Only show open (or possibly open) ports

nmap --open 192.168.1.1
nmap --open server1.cyberciti.biz

#13: Show all packets sent and received

nmap --packet-trace 192.168.1.1
nmap --packet-trace server1.cyberciti.biz

14#: Show host interfaces and routes

This is useful for debugging (ip command or route command or netstat command like output using nmap)
nmap --iflist
Sample outputs:
Starting Nmap 5.00 ( http://nmap.org ) at 2012-11-27 02:01 IST
************************INTERFACES************************
DEV    (SHORT)  IP/MASK          TYPE        UP MAC
lo     (lo)     127.0.0.1/8      loopback    up
eth0   (eth0)   192.168.1.5/24   ethernet    up B8:AC:6F:65:31:E5
vmnet1 (vmnet1) 192.168.121.1/24 ethernet    up 00:50:56:C0:00:01
vmnet8 (vmnet8) 192.168.179.1/24 ethernet    up 00:50:56:C0:00:08
ppp0   (ppp0)   10.1.19.69/32    point2point up
 
**************************ROUTES**************************
DST/MASK         DEV    GATEWAY
10.0.31.178/32   ppp0
209.133.67.35/32 eth0   192.168.1.2
192.168.1.0/0    eth0
192.168.121.0/0  vmnet1
192.168.179.0/0  vmnet8
169.254.0.0/0    eth0
10.0.0.0/0       ppp0
0.0.0.0/0        eth0   192.168.1.2
 

#15: How do I scan specific ports?

map -p [port] hostName
## Scan port 80
nmap -p 80 192.168.1.1
 
## Scan TCP port 80
nmap -p T:80 192.168.1.1
 
## Scan UDP port 53
nmap -p U:53 192.168.1.1
 
## Scan two ports ##
nmap -p 80,443 192.168.1.1
 
## Scan port ranges ##
nmap -p 80-200 192.168.1.1
 
## Combine all options ##
nmap -p U:53,111,137,T:21-25,80,139,8080 192.168.1.1
nmap -p U:53,111,137,T:21-25,80,139,8080 server1.cyberciti.biz
nmap -v -sU -sT -p U:53,111,137,T:21-25,80,139,8080 192.168.1.254
 
## Scan all ports with * wildcard ##
nmap -p "*" 192.168.1.1
 
## Scan top ports i.e. scan $number most common ports ##
nmap --top-ports 5 192.168.1.1
nmap --top-ports 10 192.168.1.1
 
Sample outputs:
Starting Nmap 5.00 ( http://nmap.org ) at 2012-11-27 01:23 IST
Interesting ports on 192.168.1.1:
PORT     STATE  SERVICE
21/tcp   closed ftp
22/tcp   open   ssh
23/tcp   closed telnet
25/tcp   closed smtp
80/tcp   open   http
110/tcp  closed pop3
139/tcp  closed netbios-ssn
443/tcp  closed https
445/tcp  closed microsoft-ds
3389/tcp closed ms-term-serv
MAC Address: BC:AE:C5:C3:16:93 (Unknown)
 
Nmap done: 1 IP address (1 host up) scanned in 0.51 seconds
 

#16: The fastest way to scan all your devices/computers for open ports ever

nmap -T5 192.168.1.0/24

#17: How do I detect remote operating system?

You can identify a remote host apps and OS using the -O option:
 
nmap -O 192.168.1.1
nmap -O  --osscan-guess 192.168.1.1
nmap -v -O --osscan-guess 192.168.1.1
Sample outputs:
Starting Nmap 5.00 ( http://nmap.org ) at 2012-11-27 01:29 IST
NSE: Loaded 0 scripts for scanning.
Initiating ARP Ping Scan at 01:29
Scanning 192.168.1.1 [1 port]
Completed ARP Ping Scan at 01:29, 0.01s elapsed (1 total hosts)
Initiating Parallel DNS resolution of 1 host. at 01:29
Completed Parallel DNS resolution of 1 host. at 01:29, 0.22s elapsed
Initiating SYN Stealth Scan at 01:29
Scanning 192.168.1.1 [1000 ports]
Discovered open port 80/tcp on 192.168.1.1
Discovered open port 22/tcp on 192.168.1.1
Completed SYN Stealth Scan at 01:29, 0.16s elapsed (1000 total ports)
Initiating OS detection (try #1) against 192.168.1.1
Retrying OS detection (try #2) against 192.168.1.1
Retrying OS detection (try #3) against 192.168.1.1
Retrying OS detection (try #4) against 192.168.1.1
Retrying OS detection (try #5) against 192.168.1.1
Host 192.168.1.1 is up (0.00049s latency).
Interesting ports on 192.168.1.1:
Not shown: 998 closed ports
PORT   STATE SERVICE
22/tcp open  ssh
80/tcp open  http
MAC Address: BC:AE:C5:C3:16:93 (Unknown)
Device type: WAP|general purpose|router|printer|broadband router
Running (JUST GUESSING) : Linksys Linux 2.4.X (95%), Linux 2.4.X|2.6.X (94%), MikroTik RouterOS 3.X (92%), Lexmark embedded (90%), Enterasys embedded (89%), D-Link Linux 2.4.X (89%), Netgear Linux 2.4.X (89%)
Aggressive OS guesses: OpenWrt White Russian 0.9 (Linux 2.4.30) (95%), OpenWrt 0.9 - 7.09 (Linux 2.4.30 - 2.4.34) (94%), OpenWrt Kamikaze 7.09 (Linux 2.6.22) (94%), Linux 2.4.21 - 2.4.31 (likely embedded) (92%), Linux 2.6.15 - 2.6.23 (embedded) (92%), Linux 2.6.15 - 2.6.24 (92%), MikroTik RouterOS 3.0beta5 (92%), MikroTik RouterOS 3.17 (92%), Linux 2.6.24 (91%), Linux 2.6.22 (90%)
No exact OS matches for host (If you know what OS is running on it, see http://nmap.org/submit/ ).
TCP/IP fingerprint:
OS:SCAN(V=5.00%D=11/27%OT=22%CT=1%CU=30609%PV=Y%DS=1%G=Y%M=BCAEC5%TM=50B3CA
OS:4B%P=x86_64-unknown-linux-gnu)SEQ(SP=C8%GCD=1%ISR=CB%TI=Z%CI=Z%II=I%TS=7
OS:)OPS(O1=M2300ST11NW2%O2=M2300ST11NW2%O3=M2300NNT11NW2%O4=M2300ST11NW2%O5
OS:=M2300ST11NW2%O6=M2300ST11)WIN(W1=45E8%W2=45E8%W3=45E8%W4=45E8%W5=45E8%W
OS:6=45E8)ECN(R=Y%DF=Y%T=40%W=4600%O=M2300NNSNW2%CC=N%Q=)T1(R=Y%DF=Y%T=40%S
OS:=O%A=S+%F=AS%RD=0%Q=)T2(R=N)T3(R=N)T4(R=Y%DF=Y%T=40%W=0%S=A%A=Z%F=R%O=%R
OS:D=0%Q=)T5(R=Y%DF=Y%T=40%W=0%S=Z%A=S+%F=AR%O=%RD=0%Q=)T6(R=Y%DF=Y%T=40%W=
OS:0%S=A%A=Z%F=R%O=%RD=0%Q=)T7(R=N)U1(R=Y%DF=N%T=40%IPL=164%UN=0%RIPL=G%RID
OS:=G%RIPCK=G%RUCK=G%RUD=G)IE(R=Y%DFI=N%T=40%CD=S)
Uptime guess: 12.990 days (since Wed Nov 14 01:44:40 2012)
Network Distance: 1 hop
TCP Sequence Prediction: Difficulty=200 (Good luck!)
IP ID Sequence Generation: All zeros
Read data files from: /usr/share/nmap
OS detection performed. Please report any incorrect results at http://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 12.38 seconds
           Raw packets sent: 1126 (53.832KB) | Rcvd: 1066 (46.100KB)
See also: Fingerprinting a web-server and a dns server command line tools for more information.

#18: How do I detect remote services (server / daemon) version numbers?

nmap -sV 192.168.1.1
Sample outputs:
Starting Nmap 5.00 ( http://nmap.org ) at 2012-11-27 01:34 IST
Interesting ports on 192.168.1.1:
Not shown: 998 closed ports
PORT   STATE SERVICE VERSION
22/tcp open  ssh     Dropbear sshd 0.52 (protocol 2.0)
80/tcp open  http?
1 service unrecognized despite returning data.

#19: Scan a host using TCP ACK (PA) and TCP Syn (PS) ping

If firewall is blocking standard ICMP pings, try the following host discovery methods:
nmap -PS 192.168.1.1
nmap -PS 80,21,443 192.168.1.1
nmap -PA 192.168.1.1
nmap -PA 80,21,200-512 192.168.1.1

#20: Scan a host using IP protocol ping

nmap -PO 192.168.1.1

#21: Scan a host using UDP ping

This scan bypasses firewalls and filters that only screen TCP:
nmap -PU 192.168.1.1
nmap -PU 2000.2001 192.168.1.1

#22: Find out the most commonly used TCP ports using TCP SYN Scan

 
### Stealthy scan ###
nmap -sS 192.168.1.1
 
### Find out the most commonly used TCP ports using  TCP connect scan (warning: no stealth scan)
###  OS Fingerprinting ###
nmap -sT 192.168.1.1
 
### Find out the most commonly used TCP ports using TCP ACK scan
nmap -sA 192.168.1.1
 
### Find out the most commonly used TCP ports using TCP Window scan
nmap -sW 192.168.1.1
 
### Find out the most commonly used TCP ports using TCP Maimon scan
nmap -sM 192.168.1.1
 

#23: Scan a host for UDP services (UDP scan)

Most popular services on the Internet run over the TCP protocol. DNS, SNMP, and DHCP are three of the most common UDP services. Use the following syntax to find out UDP services:
nmap -sU nas03
nmap -sU 192.168.1.1
Sample outputs:
 
Starting Nmap 5.00 ( http://nmap.org ) at 2012-11-27 00:52 IST
Stats: 0:05:29 elapsed; 0 hosts completed (1 up), 1 undergoing UDP Scan
UDP Scan Timing: About 32.49% done; ETC: 01:09 (0:11:26 remaining)
Interesting ports on nas03 (192.168.1.12):
Not shown: 995 closed ports
PORT     STATE         SERVICE
111/udp  open|filtered rpcbind
123/udp  open|filtered ntp
161/udp  open|filtered snmp
2049/udp open|filtered nfs
5353/udp open|filtered zeroconf
MAC Address: 00:11:32:11:15:FC (Synology Incorporated)
 
Nmap done: 1 IP address (1 host up) scanned in 1099.55 seconds
 

#24: Scan for IP protocol

This type of scan allows you to determine which IP protocols (TCP, ICMP, IGMP, etc.) are supported by target machines:
nmap -sO 192.168.1.1

#25: Scan a firewall for security weakness

The following scan types exploit a subtle loophole in the TCP and good for testing security of common attacks:
 
## TCP Null Scan to fool a firewall to generate a response ##
## Does not set any bits (TCP flag header is 0) ##
nmap -sN 192.168.1.254
 
## TCP Fin scan to check firewall ##
## Sets just the TCP FIN bit ##
nmap -sF 192.168.1.254
 
## TCP Xmas scan to check firewall ##
## Sets the FIN, PSH, and URG flags, lighting the packet up like a Christmas tree ##
nmap -sX 192.168.1.254
 
See how to block Xmas packkets, syn-floods and other conman attacks with iptables.

#26: Scan a firewall for packets fragments

The -f option causes the requested scan (including ping scans) to use tiny fragmented IP packets. The idea is to split up the TCP header over
several packets to make it harder for packet filters, intrusion detection systems, and other annoyances to detect what you are doing.
nmap -f 192.168.1.1
nmap -f fw2.nixcraft.net.in
nmap -f 15 fw2.nixcraft.net.in
## Set your own offset size with the --mtu option ##
nmap --mtu 32 192.168.1.1

#27: Cloak a scan with decoys

The -D option it appear to the remote host that the host(s) you specify as decoys are scanning the target network too. Thus their IDS might report 5-10 port scans from unique IP addresses, but they won't know which IP was scanning them and which were innocent decoys:
nmap -n -Ddecoy-ip1,decoy-ip2,your-own-ip,decoy-ip3,decoy-ip4 remote-host-ip
nmap -n -D192.168.1.5,10.5.1.2,172.1.2.4,3.4.2.1 192.168.1.5

#28: Scan a firewall for MAC address spoofing

 
### Spoof your MAC address ##
nmap --spoof-mac MAC-ADDRESS-HERE 192.168.1.1
 
### Add other options ###
nmap -v -sT -PN --spoof-mac MAC-ADDRESS-HERE 192.168.1.1
 
 
### Use a random MAC address ###
### The number 0, means nmap chooses a completely random MAC address ###
nmap -v -sT -PN --spoof-mac 0 192.168.1.1
 

#29: How do I save output to a text file?

The syntax is:
nmap 192.168.1.1 > output.txt
nmap -oN /path/to/filename 192.168.1.1
nmap -oN output.txt 192.168.1.1

#30: Not a fan of command line tools?

Try zenmap the official network mapper front end:
Zenmap is the official Nmap Security Scanner GUI. It is a multi-platform (Linux, Windows, Mac OS X, BSD, etc.) free and open source application which aims to make Nmap easy for beginners to use while providing advanced features for experienced Nmap users. Frequently used scans can be saved as profiles to make them easy to run repeatedly. A command creator allows interactive creation of Nmap command lines. Scan results can be saved and viewed later. Saved scan results can be compared with one another to see how they differ. The results of recent scans are stored in a searchable database.
You can install zenmap using the following apt-get command:
$ sudo apt-get install zenmap
Sample outputs:
[sudo] password for vivek:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
  zenmap
0 upgraded, 1 newly installed, 0 to remove and 11 not upgraded.
Need to get 616 kB of archives.
After this operation, 1,827 kB of additional disk space will be used.
Get:1 http://debian.osuosl.org/debian/ squeeze/main zenmap amd64 5.00-3 [616 kB]
Fetched 616 kB in 3s (199 kB/s)
Selecting previously deselected package zenmap.
(Reading database ... 281105 files and directories currently installed.)
Unpacking zenmap (from .../zenmap_5.00-3_amd64.deb) ...
Processing triggers for desktop-file-utils ...
Processing triggers for gnome-menus ...
Processing triggers for man-db ...
Setting up zenmap (5.00-3) ...
Processing triggers for python-central ...
Type the following command to start zenmap:
$ sudo zenmap
Sample outputs
Fig.02: zenmap in action

Install FlareGet Download Manager on Ubuntu / Linux Mint

Install FlareGet Download Manager on Ubuntu / Linux Mint

Hello,
I have already posted the article for the Download Manager but Posting for One More Internet Download Manager called FlareGet on Linux.
By Performing this Howto You will able to Install and Use FlareGet Internet Download Manager on Ubuntu 13.04 / 12.10 / 12.04 / 11.10 and Linux Mint 14 / 13 / 12 .
I am using FlareGet from Past few days and It is worth Internet Download Manager to have on Linux Platform.
FlareGet
FlareGet

Remove If any previous version of FlareGet is Installed.
tejas-barot@linux-support-ahmedabad:~# sudo apt-get remove flareget
# Now Lets Install FlareGet on Ubuntu / Linux Mint :-
Step 1 :- Add PPA to your Ubuntu  

tejas-barot@linux-support-ahmedabad:~# sudo add-apt-repository ppa:upubuntu-com/flareget-i386
Step 2 :- Update Repository
tejas-barot@linux-support-ahmedabad:~# sudo apt-get update
Step 3 :- Install FlareGet
tejas-barot@linux-support-ahmedabad:~# sudo apt-get install flareget
Step 4 :- Execute Following command to Launch FlareGet
tejas-barot@linux-support-ahmedabad:~# flareget
That’s IT. FlareGet is Installed and Ready to use.

Send SMTP email from Command Line Linux / SSMTP / GMAIL

Send SMTP email from Command Line Linux / SSMTP / GMAIL

Dear All,
It is not possible that on every Single System there is mail server available.
There is no mail server configured on your System and You want to send e-mail using SMTP Authentication then you can send mail by ssmtp utility.
You can use the Same Method for RHEL / CentOS / Fedora / Ubuntu.
So In this Article, I will show you that How can can send e-mail using Gmail Authentication using SMTP.
SMTP Mail
SMTP Mail
In this Article, We will use utility called SSMTP.
SSMTP RPM / DEB / Package Must be installed to Use this utility.
To Perform this HowTo :-
Step 1. You have to be root to Install and Perform this Howto.
Step 2. Open the ssmtp.conf in /etc/ssmtp/ssmtp.conf and Add the Following lines as per your requirement.
[root@linux-support-tejas-barot-ahmedabad ~]# vim /etc/ssmtp/ssmtp.conf 
Add the Following Configurations to /etc/ssmtp/ssmtp.conf and SAVE and EXIT 
root=smtpauth@gmail.com
mailhub=smtp.gmail.com:587
AuthUser=smtpauth@gmail.com
AuthPass=P@ssw0rd
UseSTARTTLS=yes

Step 3. Now Let’s say Now You want to send a Particular message. Like :-
Subject will be “Check the Server Health” and Body will be your “Cannot Access Server“.
So For the same Create a File called /root/message.txt and Add Following content to file :-
[root@linux-support-tejas-barot-ahmedabad ~]# vim /root/message.txt
Subject: Check the Server Health
Cannot Access Server

Step 4. Now to Send an e-mail Execute Following command :-
Syntax is ssmtp -vvvv recipientmail@domain.com < <message-file>
[root@linux-support-tejas-barot-ahmedabad ~]# ssmtp -vvvv recipient@domain.com < message.txt
That’s IT

Download Fedora 19 Schrödinger’s Cat / CD / DVD / ISO / 32-Bit / 64-Bi

Hello All,
Its Great New For Fedora Lovers. Once Fedora 19 Schrödinger’s Cat released final Version. Fedora 19 Final Release Links are updated here. You can download Fedora 19 Final Release from below links.
Fedora 19
Fedora 19
Fedora 19 Final now released and Available for Download Now, In this post i will post a Links from where you can download Fedora 19 Schrödinger’s Cat.
Fedora 19 Features List :- http://fedoraproject.org/wiki/Releases/19/FeatureList
Fedora Lovers excited about this release and for them I am posting Links which can helps you to download Fedora 19 Schrödinger’s Cat Easily.
Download Fedora 19 Schrödinger’s Cat from links below :-
Download Fedora 19 Schrödinger’s Cat Desktop Gnome Live CD ISO for 32-Bit ( i686 ) Hardware Click on this Link :-
http://download.fedoraproject.org/pub/fedora/linux/releases/19/Live/i386/Fedora-Live-Desktop-i686-19-1.iso
Download Fedora 19 Schrödinger’s Cat Desktop Gnome Live CD ISO for 64-Bit ( x86_64 ) Hardware Click on this Links :-
Download Fedora 19 Schrödinger’s Cat Desktop Installation DVD ISO for 32-Bit ( i686 ) Hardware Click on this Links :-
http://download.fedoraproject.org/pub/fedora/linux/releases/19/Fedora/i386/iso/Fedora-19-i386-DVD.iso
Download Fedora 18 Desktop Installation DVD ISO for 64-Bit ( x86_64 ) Hardware Click on this Links :-
http://download.fedoraproject.org/pub/fedora/linux/releases/19/Fedora/x86_64/iso/Fedora-19-x86_64-DVD.iso
Download Fedora 18 Cloud Images :- http://fedoraproject.org/en/get-fedora-options#clouds
More Spins You can Download at :- http://fedoraproject.org/en/get-fedora-options
If you like this then Please Click Google +1 Button and Show Your Support. Your Support will encourage me to write more articles.

Mount / Access NTFS Filesystem / Partition on RHEL / CentOS 6.x

Mount / Access NTFS Filesystem / Partition on RHEL / CentOS 6.x

Hello,
Getting Error for NTFS File System on RHEL / CentOS ?
Unable to mount Partition
Error mounting: mount: unknown filesystem type ‘ntfs’
NTFS on CentOS 6
NTFS on CentOS 6
In ENT Linux like RHEL and CentOS there are no packages installed by default to access or Mount NTFS Partition, I have already share the same kind of article way behind for RHEL 5.x.
I am Sharing how to, So By Following this you will able to Mount / Access NTFS Partitions / FileSystem on Red Hat Enterprise Linux 6.x and CentOS 6.x
NTFS 3g
NTFS 3g
It is very simple and Basic to Install NTFS Modules on both Linux, Almost Same method is used for the CentOS and RHEL 6.x.
Only Few Packages which needs to be Installed and You are done.
1. Execute Below Command to Install and Configure EPEL Repository 
[root@tejas-barot-linux-support-ahmedabad ~]# wget http://epel.mirror.net.in/epel/6/i386/epel-release-6-8.noarch.rpm
[root@tejas-barot-linux-support-ahmedabad ~]# rpm -Uvh epel-release-6-8.noarch.rpm
2. Execute Below Command to Install Package related to NTFS Mount :-
[root@tejas-barot-linux-support-ahmedabad ~]# yum -y install ntfs-3g ntfsprogs
3. Attach NTFS Drive and Execute Below command to Find and Mount Partition :-

# To Find Attached NTFS Partition Execute Below Command :-

[root@tejas-barot-linux-support-ahmedabad ~]# fdisk -l | grep “NTFS”
# You will get output Something like below :- 
/dev/sdb1 * 1 1034 1973248 7 HPFS/NTFS
Execute Below command to Mount NTFS Partition
[root@tejas-barot-linux-support-ahmedabad ~]# mount /dev/sdb1 /mnt
4. To Mount NTFS Partition Permanently You can add following entry to /etc/fstab
<device-name> <mount-point> <file-system-type> <options> <dump> <checking>
Example Entry :-
/dev/sdb1 /mnt ntfs-3g default 0 0
Save and Exit from /etc/fstab
That’s IT, Now You will able to Mount / Access NTFS Partition on RHEL / CentOS 6.x
If you like this then Please Click Google +1 Button and Show Your Support. Your Support will encourage me to write more articles.