Read more »
Showing posts with label Shell_Scripting. Show all posts
Showing posts with label Shell_Scripting. Show all posts
How to use Curl in Linux : Curl Guide For beginners
Curl is a command line tool for getting or sending files using URL syntax. It is used to transfer data from or to a server, using one of the supported protocols (DICT, FILE, FTP, FTPS, GOPHER, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMB, SMBS, SMTP, SMTPS, TELNET and TFTP). The command is designed to work without user interaction. We can use curl for download files from internet, sending custom HTTP ( GET and POST ) request, as FPT client, sending e-mails etc. Curl can be used in many different and interesting ways. Some of the main features of curl is :
A Beginners Guide to vi / vim text editor
vi (visual editor) is a terminal based text editing application, originally created for the Unix operating system. It is a fast, powerful and most popular and classic text editor in the Linux family. It is available in almost all Linux and Unix Distributions, and works the same across different platforms and Distributions. Vi does not contain any menu, instead it uses combinations of keystrokes to accomplish an action. It requires very few resources to run. An improved version of the vi editor which is called the VIM (Vi IMproved) has also been made available now. The vi editor is a full screen editor and has two modes of operation:
A Beginners Guide to nano text editor
nano is a text editor for Unix-like computing systems or operating environments using a command line interface. It emulates the Pico text editor, part of the Pine email client, and also provides additional functionality. nano was first created in 1999 with the name TIP by Chris Allegretta. The name was changed to nano on 10 January 2000 to avoid a naming conflict with the existing Unix utility tip. In this tutorial, we will discuss the basic usage of the Nano editor, as well as some of the features it provides. The following screenshot shows the editor in action:
Shell script to Ping your Home Lan Network
i wrote a simple shell script which ping the provided range of ip in a Lan network and shows the host is up or down.
ping.sh
Now lets run it
./ping.sh 100 120
Thanks..
ping.sh
#!/bin/bash
# ./ping.sh <starting_address> <end_address>
# ./ping.sh 100 120
#
for((x=$1;x<=$2;x++))
do
ping -W1 -c1 192.168.0.$x > /dev/null
if [ $? -eq 0 ]
then
echo "host 192.168.0.$x : Up"
else
echo "host 192.168.0.$x : Down"
fi
done
Now lets run it
./ping.sh 100 120
Thanks..
Monitoring CPU tempreture and Fan speed through Shell Scripting
First we need to install lm-sensors (Linux Monitroing Sensors) tool. The lm-sensors provides tools and drivers for monitoring temperature, voltage, humidity and fans speed. First start terminal and update the repository
sudo apt-get update
now Install lm-sensors
sudo apt-get install lm-sensors
after the completion of installation type following command in terminal
sudo sensors-detect
after that run following command
sudo service kmod start
It will ask you few questions, Answer 'Yes' for all of them. Finally to get your CPU temperature type sensors in your terminal.
sensors
Now here is the simple shell script which prints the CPU temperature and Fan Speed.
the output of script ./cpu.sh
Thanks...!! (*_*)
sudo apt-get update
now Install lm-sensors
sudo apt-get install lm-sensors
after the completion of installation type following command in terminal
sudo sensors-detect
after that run following command
sudo service kmod start
It will ask you few questions, Answer 'Yes' for all of them. Finally to get your CPU temperature type sensors in your terminal.
sensors
Now here is the simple shell script which prints the CPU temperature and Fan Speed.
#!/bin/bash
# Shows the cpu tempreture and Fan speed
#
while ((1))
do
clear
echo "CPU Tempreture : "
echo "==========================================================|"
sensors | egrep "Core|fan"
echo "==========================================================|"
sleep 2
done
the output of script ./cpu.sh
Thanks...!! (*_*)
A simple Zip Password Cracker Shell script for Linux Systems
Hello Guys, in this post we look at a simple Zip Password cracker shell script which Brute-Force a password protected zip file in order to get the password.
Code
Simple Zip Password Cracker
Download Code from Here :
Now here is the Demonstration Video :
Code
Simple Zip Password Cracker
#!/usr/bin/bash env
#
# +=======================================================+
# || A Simple ZIP Password Cracker ||
# || Developed By : http:\\www.sec-articles.blogspot.com ||
# +=======================================================+
#
declare -r TRUE=0
declare -r FALSE=1
flag=$FALSE
counter=0
# Declaring char_sets
chars_1=`echo {a..z}`
chars_2=`echo {A..Z}`
chars_3=`echo {0..9}`
chars_4="~ ! @ \$ % ^ - _ = + { } [ ] : , . / ?"
# cracking function
function cracker()
{
pass=$1
echo "trying Password $pass"
counter=$(($counter + 1))
unzip -P $pass -o $file_name
[ $? -eq 0 ] && clear && Banner && echo "Password Found : $pass" && echo "Password tried : $counter"&& return $TRUE || return $FALSE
}
# word_List generator
function word_gen()
{
args=$1
[ ${#args} -ge $length ] && cracker $1 && echo "Password Cracked" && flag=$TRUE && exit
if [ ${#args} -lt $length ]; then
for c in $chars; do
word_gen $1$c
done
fi
}
function is_num()
{
[ "$1" -eq "$1" ] > /dev/null 2>&1
return $?
}
function Show_message()
{
echo "+===============================================+"
echo "| A Simple ZIP Password Cracker |"
echo "| Developed By : http:\\\\www.sec-articles.net |"
echo "+===============================================+"
echo " ./s_zipcrack [Mode b/d] {[Lenght_of_Passowrd] [Type_Password] [location]} {[location]}"
echo""
echo " For brute_force Mode :- "
echo " ./s_zipcrack -b [Lenght_of_Passowrd] [Type_Password] [zip_file_location]"
echo " Length_of_Password - integer value"
echo " Type_of_Password - \"A\" Upper_case A-Z"
echo " - \"a\" Lower_case a-z"
echo " - \"n\" numeric 0-9"
echo " - \"c\" Special_chars !.?"
echo " zip_file_Location - Full Path of Zip File"
echo " Example : ./s_zipcrack -b 4 n /home/user/Desktop/secure.zip"
echo ""
echo " For Dictonary Mode : - "
echo " ./s_zipcrack -d [Password_dictonary_file] [zip_file_Location]"
echo " Password_dictonary_file - Full Path of Password dictonary file "
echo " zip_file_Location - Full Path of Zip file"
}
function Banner()
{
echo "+===============================================+"
echo "| A Simple ZIP Password Cracker |"
echo "| Developed By : http:\\\\www.sec-articles.net |"
echo "+===============================================+"
echo ""
}
function brute_force()
{
# Handling Arguments
if [ "$1" = "" ]
then
Show_message
exit
fi
if is_num $1
then
length=$1
else
length=2
fi
for args in "$@"; do
case $args in
a) chars="$chars $chars_1" ;;
A) chars="$chars $chars_2" ;;
n) chars="$chars $chars_3" ;;
c) chars="$chars $chars_4" ;;
esac;
done
if [ "$chars" = "" ]
then
chars="$chars_1"
fi
for arg in "$@"; do
if [ -a $arg ]
then
file_name=$arg
break
fi
done
if [ "$file_name" = "" ]
then
Banner
echo "Could not find \"$3\""
echo "please check the file location & try Again."
exit
fi
#calling word_gen function
for w in $chars; do
word_gen $w
done
}
function dictonary()
{
if [ "$1" = "" ]
then
Banner
echo "please give the password_list."
exit 1
elif [ "$2" = "" ]
then
Banner
echo "please give the zip file location."
exit 1
fi
if [ -a $1 ]
then
pass_list=$1
else
Banner
echo "could not find \"$1\""
echo "please check the file location & try Again."
exit 1
fi
if [ -a $2 ]
then
file_name=$2
else
Banner
echo "could not find \"$2\""
echo "please check the file location & try Again."
exit 1
fi
# reading passwords & calling to cracker function
length=`cat $pass_list | wc -l`
for ((i=0;i<=$length;i++))
do
passwd=`sed -n "$i"p $pass_list`
cracker $passwd && echo "Password Cracked" && flag=$TRUE && exit
done
}
# Main
if [ "$1" = "b" ]
then
brute_force $2 $3 $4
elif [ "$1" = "d" ]
then
dictonary $2 $3
elif [ "$1" = "" ]
then
Show_message
exit
else
Banner
echo "Error in Arguments..!?"
echo "please choose the correct mode. b/d [brute_force/dictonary_attack]"
exit
fi
if [ $flag -eq $FALSE ]
then
clear
Banner
echo "Could not Found Password ?? "
echo "Password tried : $counter"
echo "please Try Again with other Keywords."
fi
Download Code from Here :
How To Use It
First download the script from above given link then open a terminal and change its permission into executable, i run this script in Ubuntu.
chmod +x zp_crack.sh
then run the script
The first argument is mode which decides BruteForce method & there is two modes
1. b :
BruteForce with any combination of characters for example aaaa, aaab, aaac..... zzzz, 1111, 1112, 1113, ...... 9999 etc. With this mode program will takes three additional arguments
Length of password : It specify the length of word & takes an integer value as input.
Type of password : It specify which type of character set you want to use for example use "a" for lowercase alphabet characters, "A" for uppercase alphabet characters, "n" for numeric characters, "s" for special characters.
Zip file location : Give the full path of zip file.
Now to test this program we need to create a password protected zip file. first create a text file
type this command oin your terminal
echo This is secret Document > secret.txt
Then zip it using zip utility
zip -P abcd secure.zip secret.txt
above command will create a zip file "secure.zip" with password "abcd". Now the password abcd consists four lowercase characters, so now we try to crack this password with our tool
Syntax is :
./zp_crack.sh b 4 a /home/ajay/Desktop/secure.zip
then hit enter
Bingo!!... password cracked.
2. d :
Bruteforce with a list of words and try every word in that list to crack password. Its also known as "Dictionary Attack", with this mode program takes two additional arguments
Password Dictionary Files : give the full path of password list or dictionary file.
Zip File Location : give the full path of zip file.
To demonstrate this i use a small list of words
now the syntax will be :
./zp_crack.sh d /home/ajay/Desktop/pass_list.txt /home/ajay/Desktop/secure.zip
Again password is cracked.
Remember this is very basic BruteForce tool and it may not work on complex and lengthy passwords.
So, that's it. thanks for reading this post & if you like it then please comment and share this post.
Now here is the Demonstration Video :
Thank_you..!! <(*_*)>
Linux & Shell Scripting Guide For Beginner's
In simple words Linux is an Operating System just like Windows and Mac OSx, but the main difference between Linux and other Operating Systems is that the Linux is Open Source Operating System. It means you are free to download, use, modify and redistribute it without paying any bucks because it is entirely free. Most Linux Operating Systems or often called Linux Distributions are Community developed and a number of companies are also contribute to its development. The word Linux Stands for LINUs + uniX , because it is built on Unix tradition and the Linux kernel is created by linus torvalds.
Get Started With Linux
Linux Distributions takes linux kernel and combines it with free software to create a complete Operating System. Currently there are more then 280 different Linux Distributions available. To know more about Linux Distributions visit : destrowatch.com. Here is the list of Top 10 Destros : Click here. But as a Beginner perspective I would recommend to first try Ubuntu because of its simple user interface, it is one of the most popular and well-known Linux Distribution. You can download the latest Ubuntu ISO image from here , After download the ISO file, burn it on a DVD or either make a bootable usb. You can also use Ubuntu without installing it by using Live cds or usb drives, just boot your PC or Laptop with bootable DVD or USB drives and click on "Try Ubuntu" Button.
or if you want to install Ubuntu then hit install Button and follow the instructions. You can also use virtualization software such as Virtual Box or VMware to install Ubuntu. this method is best for Beginners because it could not causes any changes in your physical drives or host OS. I am using Virtual Box which can be found here. So in order to install Ubuntu in Virtual Box first download and install Virtual Box, then follow these steps :
Some Basics About Ubuntu
By default Ubuntu 14.04 uses unity Desktop Environment, the main components of Ubuntu Desktop are
Panel : Panel is a horizontal bar placed at top of the Desktop, it contains status bar and Application Menu button, where we can access system settings, Shutdown button etc.
Launcher : Launcher is a vertical docking station at the left side of the Desktop, it contains files, folders and Applications shortcuts to launch it quickly. In order to attach new Application on launcher just right click on the App icon and click "Lock to Launcher" & to detach an App right click and then click "Unlock from Launcher".
Dash : With the help of Dash interface we can easily search any file, folder or Application and run or launch it, it also shows recently run applications. To open Dash click on the Ubuntu button located at top of the launcher.
Command Line Interface
In CLI or Command Line Interface a user type a command in a console window to interact with files and Operating System & receive the result back from the system. It is Beneficial to know how to use CLI because it gives more power and control over commands and Operating Systems as compared to GUI or Graphical User Interface. It does not consumes much memory and processor's resources as comparison to GUI. To launch a Console window in Ubuntu click on the Dash and type 'Terminal' then click on the terminal Icon.
Now type this command : echo hello world
Command Shell Scripting
A Shell script is a program file, which contains a series of commands and executes all commands sequentially at one time. Shell scripts are not Binary files, instead these are simple ASCII text files. We can create a Shell script by using a text editor. In Ubuntu we can use nano text editor to create our first Shell script. nano is a command-line text editor and very easy to use. So first of all start a terminal or console then type
nano script.sh
and press enter.
In nano type these commands
#!/bin/bash
echo "hello world This is My First Shell Script"
read -p "Enter Your Name : " name
echo "hello world This is My First Shell Script"
read -p "Enter Your Name : " name
echo "hello $name"
after that press Ctrl+O and then press enter to save your file. To exit nano press Ctrl+X
Now we need to give the Shell permission to execute the Shell script by using chmod command type this command : chmod +x script.sh
To execute the script type : ./script.sh
First line of this script indicates what program is used to interpret the script, which is Bash interpreter. In third line we use echo command, which simply prints all given arguments. In fourth line we use read command, in this command we use -p parameter, so first it prints the arguments under " " and then it reads user supplied data then points it to a variable name. The next command is echo with variable $name.
Resources for Shell Scripting Tutorials :
So thats it, this is a short guide to Linux and Shell Scripting For Beginners, I hope you like it.
Subscribe to:
Posts (Atom)










