Government Security
Network Security Resources

Jump to content

Photo

Some Simple Bash Programs

- - - - - scanning dns ipad android sniffing port scan
  • Please log in to reply
1 reply to this topic

#1 chompish

chompish

    Private

  • Members
  • 3 posts

Posted 02 March 2012 - 10:27 AM

I've been working on teaching myself Bash and have come up with a few simple programs. They may or may not be of use to anyone.

I would like some constructive critiscism on them.

ARP detecter:

#!/bin/bash
export REALARP=`arp -a | cut -d" " -f 4`
echo $REALARP
sleep 50
export NEWARP=`arp -a |cut -d" " -f 4`
echo $NEWARP
while [ "$REALARP" = "$NEWARP" ]; do
sleep 5
export NEWARP=`arp -a | cut -d" " -f 4`
done
zenity --warning --text "ARP table changed, new entry is $NEWARP"

The below tries to setup an internet connection then runs onto another script. in the process is also checks DNS resolution. This came in handy for an automated Sniffing attack i was testing using Backtrack on my android. I know there is more efficient ways to do the loops, but this worked and thats all that mattered really.
#!/bin/bash
STRING="Working"
RECEVIED="1 received"
PINGFILE="./ping.txt"
NEXTSCRIPT= #path to the next script
echo $STRING
#Try DHCP
dhclient
#ping external address and output to file
ping -c 1 www.google.com > /root/Desktop/ping.txt
#check for PING reply from file
if [[ -n $(grep "$RECEVIED" /root/Desktop/ping.txt) ]]; then $NEXTSCRIPT && exit
else echo "shit" && # Set IP address
ifconfig eth0 down
ifconfig eth0 192.168.1.252
ifconfig eth0 up
fi
#ping external address and output to file
ping -c 1 www.google.com > /root/Desktop/ping.txt
#check for PING reply from file
if [[ -n $(grep "$RECEVIED" /root/Desktop/ping.txt) ]]; then IPADDRESS="192.168.1.252" && $NEXTSCRIPT && exit
else echo "shit" && # Set IP address
ifconfig eth0 down
ifconfig eth0 192.168.0.252
ifconfig eth0 up
fi
#ping external address and output to file
ping -c 1 www.google.com > /root/Desktop/ping.txt
#check for PING reply from file
if [[ -n $(grep "$RECEVIED" /root/Desktop/ping.txt) ]]; then IPADDRESS="192.168.0.252" && $NEXTSCRIPT && exit
else echo "shit" && # Set IP address
ifconfig eth0 down
ifconfig eth0 10.0.0.252
ifconfig eth0 up
fi
#ping external address and output to file
ping -c 1 www.google.com > /root/Desktop/ping.txt
#check for PING reply from file
if [[ -n $(grep "$RECEVIED" /root/Desktop/ping.txt) ]]; then IPADDRESS="10.0.0.252" && $NEXTSCRIPT && exit
else echo "shit" && # Set IP address
ifconfig eth0 down
ifconfig eth0 10.0.1.252
ifconfig eth0 up
fi
ping -c 1 www.google.com > /root/Desktop/ping.txt
if [[ -n $(grep "$RECEVIED" /root/Desktop/ping.txt) ]]; then IPADDRESS="10.0.1.252" && $NEXTSCRIPT && exit
else echo "shite, its no working. you suck" &&

exit

a quick way to user NC's port scanning (if you're retarded like me and can never remember the syntax without checking it a few times)
#!/bin/bash
echo "host"
read host
echo "ports # - #"
read ports
nc -vv -z -w2 $host $ports -o nc.txt &
cat nc.txt

ip forwarding and start wireshark
#!/bin/bash
echo 1 > /proc/sys/net/ipv4/ip_forward
cat /proc/sys/net/ipv4/ip_forward
wireshark -i eth0 -w /root/Desktop/capture.cap -k

There is nothing special about these at all, they have just been usefull to me from time to time so thought they may come in handy to someone else

#2 Glyph

Glyph

    General of the Army

  • GSO Management
  • 1,603 posts

Posted 24 April 2013 - 07:04 AM

find all alive hosts in a class C.

Replace 172.16.4 with the first three octets of the Class C you wish to check.

<code>

#!/bin/bash
for ip in $(seq 1 254); do
ping -c 1 172.16.4.$ip | grep "bytes from" | cut -d" " -f 4 | cut -d":" -f 1 &
done
</code>







Also tagged with one or more of these keywords: scanning, dns, ipad, android, sniffing, port scan