Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Wednesday, February 29, 2012

netdiscover

Not saying anything smart in this post, just placing here as note to self about the name of this tool and basic commands to get it started if I'm on a new machine that needs it.



sudo apt-get install netdiscover
sudo netdiscover
sudo netdiscover -r 192.168.1.0/24
sudo netdiscover -i wlan0 -r 192.168.1.0/24
sudo netdiscover -h
Netdiscover 0.3-beta7 [Active/passive arp reconnaissance tool]
Written by: Jaime Penalba 

Usage: netdiscover [-i device] [-r range | -l file | -p] [-s time] [-n node] [-c count] [-f] [-d] [-S] [-P] [-C]
  -i device: your network device
  -r range: scan a given range instead of auto scan. 192.168.6.0/24,/16,/8
  -l file: scan the list of ranges contained into the given file
  -p passive mode: do not send anything, only sniff
  -F filter: Customize pcap filter expression (default: "arp")
  -s time: time to sleep between each arp request (miliseconds)
  -n node: last ip octet used for scanning (from 2 to 253)
  -c count: number of times to send each arp reques (for nets with packet loss)
  -f enable fastmode scan, saves a lot of time, recommended for auto
  -d ignore home config files for autoscan and fast mode
  -S enable sleep time supression betwen each request (hardcore mode)
  -P print results in a format suitable for parsing by another program
  -L in parsable output mode (-P), continue listening after the active scan is completed

If -r, -l or -p are not enabled, netdiscover will scan for common lan addresses.

Sunday, December 23, 2007

Recursive Bash Program


< source_code>
#!/bin/bash
LIMIT=$1
if [ $2 ]
then
CELL=$2
else
CELL=[] 
fi 
#******************
print_horizontal_line()
{
ME=0
while [ $ME -lt $LIMIT ] 
do
echo -n $CELL 
let "ME= ME+1"
done
}
#******************

#******************
print_vertical_line()
{
ME2=0
while [ $ME2 -lt $LIMIT ] 
do
print_horizontal_line  
echo     
let "ME2= ME2+1"
done
}
#******************
print_vertical_line;
let "LIMIT= LIMIT/2"
if [ $LIMIT -le 0 ]
then
exit
else
$0 $LIMIT $CELL
fi
exit
</source_code>

This short program to the above serves to demonstrate some basic bash programming syntax and a (very) basic use of recursion. If the program is run on the command line as:

lancemiller$ recursive_bash 4
[][][][]
[][][][]
[][][][]
[][][][]
[][]
[][]
[]
In shell programming the arguments are numbered
$0  $1   $2   $3   $4 ....etc 
recursive_bash 4
 ^             ^
 |             |
$0             $1

The recursive_bash program is going to take $1 (numeral 4 in this example) and perform some math and print a certain amount of characters as a result. First $1 is assigned to the variable LIMIT. Math and print statements occur using $LIMIT. $CELL is the character that will be printed. Argument $2 is optional. Example:

lancemiller$ recursive_bash 4 cat
catcatcatcat                   ^
catcatcatcat                   |
catcatcatcat              arg $2   
catcatcatcat
catcat
catcat
cat

$LIMIT is divided by 2.-> let "LIMIT= LIMIT/2" Then the recursive moment comes in recursive_bash at the line that says: 
$0 $LIMIT $CELL
$0 is the program itself(recursive_bash). It is called over and over till
let "LIMIT= LIMIT/2" results in zero. When $LIMIT is equal or less than zero the program exits.