Port of call.

One thing that is good for an network administrator is to be able to see if a web server is up without having to load a browser. Of course the web browsers usually run on port 80. Here is a short script to do that.

Grab a root webpage and save the code. Great for seeing if a server is up.
Usage:  ./webpageget.sh site outputfile
./getwebpage.sh oesrvr1 oesrvr1_rootpage
rm: cannot remove `oesrvr1_rootpage’: No such file or directory
<html>
<head>
<title> Offshore Educators (Main Page) 1 </title>
<base href=”http://oesrvr1/oe/”&gt;
</head>
<FRAMESET ROWS=”15%,*”>
<FRAME SRC=”title.html” NAME=TITLE SCROLLING=NO>
<FRAMESET COLS=”20%,*” FRAMEBORDER=no>
<FRAME SRC=”tools.html” NAME=SIDEBAR noresize>
<FRAME SRC=”notes.html” NAME=NOTES noresize>
</FRAMESET>
<NOFRAMES>
<H1> Offshore Educators</H1>
No frames? No Problem! Take a look at our
<A HREF=”plain.html”>no-frames</A> version.
</NOFRAMES>
</FRAMESET>
</html>
<code>
exec 3<>/dev/tcp/$1/80
echo “GET /” >&3
rm $2
cat <&3 > $2
cat $2
</code>

A while back I mentioned that you could find what systems are connected to your network with ./pingalll.sh (aka finding what homes are on the block)

 $ ./pingall.sh
You are using network 1.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=0.746 ms
64 bytes from 192.168.1.31: icmp_seq=1 ttl=64 time=0.404 ms
64 bytes from 192.168.1.99: icmp_seq=1 ttl=255 time=4.84 ms
64 bytes from 192.168.1.115: icmp_seq=1 ttl=64 time=0.064 ms

Now let's go one step further and find out what ports are accessible (i.e. 80 if the web server). This is also a first test to see how vunerable your internet faced systems are. Sometimes this is known as penetration testing (pen testing) at it's most rudimentary level. This also the first step most hackers will use to see of they can get into your system(s).

Simple port scan (aka finding out which windows and or doors are open or unlocked at a particular home.)

Usage portscan.sh host firstport lastport

$ ./portscan.sh  oesrvr1  1  1024
“22 open”
“25 open”
“80 open”
“110 open”
“111 open”
“143 open”
“993 open”
“995 open”

<code>

#!/bin/bash
IP=$1
firstport=$2
lastport=$3
function portscan
{
for ((counter=$firstport; counter<=$lastport; counter++))
do
(echo >/dev/tcp/$IP/$counter) > /dev/null 2>&1 && echo “$counter open”
done
}
portscan
</code>

If a port is not open that maybe while you can not access a particlar service such as the web server. After looking at the numbers enough, you will know what the most important ones do. In this case you know there is a mail, ssh, web and etcetera. 

Comments

Popular posts from this blog

Guiless?

Web.com and Network Solutions, the Walmart of the internet.

MSOffice vs Libreoffice