Tuesday, December 23, 2014

Script - NMAP

Script - NMAP

=========================================================
#!/bin/bash
# This script is going to scan network 192.168.1.0/24 with name and
# append to file name host-up-with-ports.txt
nmap --top-ports 65535 192.168.1.0/24 &> host-up-with-ports.txt
=========================================================
#!/bin/bash
# This script is going to scan network 192.168.1.0/24 with name and
# append to file name hosts-up-with-name.txt
nmap -sP 192.168.1.0/24 |grep "Nmap scan report" >> hosts-up-with-name.txt
=========================================================
#!/bin/bash
# This script is going to ping all hosts in network 192.168.1.0/24
# and it will append all the hosts up to to file hosts-up.txt
check_ping()
{
  ping -c 1 $1 > /dev/null
  [ $? -eq 0 ] && echo Node with IP: $i is up.
}
for i in 192.168.1.{1..255}
do
check_ping $i |grep "Node with IP" >> hosts-up.txt
done
=========================================================
#!/bin/bash
# This is a master script going to run and call another script with the following optoins
clear
# Variables
user=$(whoami)
break="====================="
echo $break
echo "Hello H4cK3R%!"
echo $break
echo
echo "Welcome, Mr. $user"
echo
echo
echo "1. Check Hosts Up"
echo "2. Scan Hosts Up"
echo "3. Scan Hosts Ports"
echo ""
echo -n "Choice: "
read choice
echo $choice
case $choice in
        1) ./check_ping.sh;;
        2) ./scan-host-with-name.sh;;
        3) ./scan_ports.sh;;
        *) echo "Please Enter the valid option."
esac



Saturday, December 20, 2014

SNMPWALK


snmpwalk

snmpwalk : retrieve a subtree of management values using SNMP GETNEXT requests.

snmpwalk [APPLICATION OPTIONS] [COMMON OPTIONS] [OID]

snmpwalk -v 2c -c C0mmunity 1.2.3.4 .1.3.6.1.4.1.8886.18.2.6.3.3.1.6.10234001

C0mmunity = Community Name
1.2.3.4 = IP address of device
.1.3.6.1.4.1.8886.18.2.6.3.3.1.6.10234001 = OID

example another command:

snmpwalk -mALL -v1 -c C0mmunity 1.2.3.4 system


#SNMP #SNMWALK

Saturday, September 13, 2014

Simple Nagios

Nagios is one of the power full monitoring system.

This script work well on OS: CentOS 64bit , Version 6.2 
Copy all the red.


#!/bin/bash

# Copy this and paste into a file name: install-nagios.sh
# Make it executable by: chmod +x install-nagios.sh
# Run this file: ./install-nagios.sh

####################
# HowTheScriptDoes #
####################
# 1. Add Repo
echo ""
echo "Adding repo..."
echo ""
wget http://epel.mirror.net.in/epel/6/i386/epel-release-6-8.noarch.rpm
rpm -ivh epel-release-6-8.noarch.rpm

# 2. Install dependencies
echo ""
echo "Install dependencies ..."
echo ""
yum -y install httpd php gcc glibc glibc-common gd gd-devel make net-snmp

# 3. Install Nagios
echo ""
echo "Instailling Nagios ..."
echo ""
yum -y install nagios*

# 4. Create user: nagiosadmin
echo ""
echo "Creating user: nagiosadmin ,Please Enter the Password: ..."
htpasswd /etc/nagios/passwd nagiosadmin

# 5. Start web service and Nagios
echo ""
echo "Starting web service and Nagios ..."
service httpd start
chkconfig nagios on
service nagios start
chkconfig httpd on

# 6. Allow port 80
echo ""
echo "Accepting Port 80 ..."
sed -i -e '/22/a \-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT' /etc/sysconfig/iptables
echo "Restarting service iptables ..."
service iptables restart

# 7. Finished,
echo ""
echo ""
echo "Enjoy, ... Access to your Nagios Server by: http://server-ip/nagios with your password."


Wednesday, September 3, 2014

Copy File and Folder Older then 7days

Copy File and Folder Older then 7days


find /in/this/directory/ -mtime -7 -exec cp -p {} /to/new/path/ \;

Note:

-7 = Last 7 days
cp -p = Copy and keep the owner,permission and timestamp

Rename Multiple File In One Command

Rename Multiple File In One Command


for FILE in *.txt ; do mv $FILE $FILE-04092014 ; done

Tuesday, August 19, 2014

Keys

VMware Workstation V.10 Key

HA4FW-8G052-DZ8Q0-U295P-83KLV
5F4PK-42181-9ZXP9-T31Q6-1CVKM
JY468-44L9M-DZ479-3UA72-CAKHR

4F6Z5-80H42-FZ889-L007M-ACJJN
5F6E9-DHL4J-HZ640-KLA70-8C0NN
1Z0G9-67285-FZG78-ZL3Q2-234JG
4C4EK-89KDL-5ZFP9-1LA5P-2A0J0
HY086-4T01N-CZ3U0-CV0QM-13DNU

5U4GA-DQ09H-EZK48-YTAQP-83K79
NU4FQ-DFH40-0ZA01-8A37K-32RKL
HF0DA-FF086-VZ739-AA87H-236M4
HF0A8-FMJ1P-1Z1U1-LK1N2-9AGKJ
5A477-D3284-3ZUF0-2K154-23R0P
MY47Y-2MK1M-6ZQC0-7J05M-8A60D
5V6K2-29243-HZDV0-VVA76-93A2R
NA28T-DR114-AZ9Z8-R1250-93U27
MF4JG-4H3DK-NZ3L0-KHCNM-8AMNP
NA6F3-2HKEM-6ZDF8-Q18N6-33DNN
1Y2FZ-AHJ5H-6ZU09-DKA5M-82RQ7
5U6KQ-6M240-LZMW1-U13N2-AAX7X
HA4FW-8G052-DZ8Q0-U295P-83KLV
5F4PK-42181-9ZXP9-T31Q6-1CVKM
JY468-44L9M-DZ479-3UA72-CAKHR
4F6Z5-80H42-FZ889-L007M-ACJJN
5F6E9-DHL4J-HZ640-KLA70-8C0NN