Nmap PHP FE


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Nmap PHP FE
# 1  
Old 08-12-2003
Nmap PHP FE

Hi everyone!
I've temporarily come out of hibernation (and will be gone for about two weeks after this post too) to ask for input on a small PHP script I have just completed.

The script aims to be a remote front-end for Nmap - now for the safety of this post, I ask that any replies refrain from saying anything related to (attack) hacking - god knows Neo's never taken it lightly when a newbie starts spewing his guts (and i'm not challenging his justification - it's his forum, after all).

the tarball is located at:

http://www.geocities.com/karmathetec..._pgp_fe.tar.gz

(i had to make a geocities account for this - it better be worth it! Smilie )

Thanks for any input!
# 2  
Old 08-13-2003
i was trying to teach my self bash scripting, just to get a comfortable with it anyway and i wrote a script that uses nmap. its very simple, and the only real thing i learned with it is how to use command line options. anyway it was fun to write and i do use it as an easy way to see if my server is up. right now this script only tests to see if a few services are running, and one fake service just for good measure for my self to see if its working. im gonna add more probably, and try to find a way to remove the dependancy on nmap. its easy to add more, if you want to see it post back and i will post the script. BTW my script has nothing to do with hacking, i just wrote it as an easy way to make sure all services on my server are up.
# 3  
Old 08-13-2003
ah what the hell ill post it. all comments are stripped from the script to save space, everything is very self explanitory as this is very basic.

serverstatus.sh
Code:
#!/bin/bash
echo "Starting server stat..."

ftp_func2 ()
{
if  echo $a | grep 21 > /dev/null
then
	echo "ftp is running"
else
	echo "ftp is not running"
fi

}

ssh_func2 ()
{
if echo $a | grep 22 > /dev/null
then
	echo "ssh is running"
else
	echo "ssh is not running"
fi

}

fake_func2 ()
{
if echo $a | grep testing > /dev/null
then
	echo "fake service running" # shouldnt be
else
	echo "fake service not running"
fi

}

telnet_func2 ()
{
if echo $a | grep 23 > /dev/null
then
	echo "telnet is running"
else
	echo "telnet is not running"
fi

}

smtp_func2 ()
{
if echo $a | grep 25 > /dev/null
then
	echo "smtp is running"
else
	echo "smtp is not running"
fi

}

http_func2 ()
{
if echo $a | grep 80 > /dev/null
then
	echo "http is running"
else
	echo "http is not running"
fi

}

pop_func2 () # not 2, not 4, but 3
{
if echo $a | grep 110 > /dev/null
then
	echo "pop3 is running"
else
	echo "pop3 is not running"
fi

}
non_interactivemode_func ()
{
	ftp_func2
	ssh_func2
	fake_func2 # this is just to make me feel better
	telnet_func2
	smtp_func2
	http_func2
	pop_func2
}

version_func ()
{
echo "Serverstat 0.9"
echo "Copyright 2003 Joseph Oldak."
echo "This is free software; There is NO warranty; not even for MERCHANTABILITY or"
echo "FITNESS FOR A PARTICULAR PURPOSE.		-taken from GNU grep -V"
echo "This script was written soley for my own use and is extremely simple."
echo "It is more of an exercise for my self to learn BASH shell scripting."

}

help_func ()
{
echo "Serverstat 0.9" 
echo "This script checks to see what services are running on a given host."
echo "You must run serverstat with the -s option to tell it what host to scan."
echo "For now, this script uses nmap, however in the future it wont require it."
echo "The options i or n are required, one or the other."
echo "Example: ./serverstat -si somehostname.com"
echo "-s	Specify hostname, either in dotted quad, or a FQDN."
echo "-i	Interactive mode, select what to check is running."
echo "-n	Non-Interactive mode, scans everything. Mainly for use in other scripts"
echo "-v	Output version information."
echo "-h	Output usage (this help message)."

}
interactivemode_func ()
{
clear

echo "Select which services you wish to check status of  : "; echo $hostname2
echo "1. ftp"; echo "$b"
echo "2. ssh"; echo "$c"
echo "3. telnet"; echo "$e"
echo "4. smtp"; echo "$f"
echo "5. http"; echo "$g"
echo "6. pop3"; echo "$p"
echo "7. exit server status"
echo "select from 1-7"

read option_number

case "$option_number" in

1 )
ftp_func
;;

2 )
ssh_func
;;

3 )
telnet_func
;;

4 )
smtp_func
;;

5 )
http_func
;;

6 )
pop_func
;;

7 )
echo " Quiting ..."
exit 0
;;

* )
echo "please select 1-7"
interactivemode_func
;;
esac
}


main () 
{
NO_ARGS=0
E_OPTERROR=65

if [ $# -eq "$NO_ARGS" ] # should check for no arguments
then
	echo "Usage: `basename $0` -s<OPTIONS> <HOSTNAME> "
	echo "You must specify interactive, or non interactive mode for now"
	echo "Try './serverstatus -h' for more information."
	exit $E_OPTERROR
fi

while getopts ":sinvh" Option
do
	case $Option in

		s )
			hostname=`echo $@`
			hostname2=`echo $hostname|awk '{print $2}'`
			echo $hostname2
			a=`nmap $hostname2`

		;;

		i )
			interactivemode_func
		;;

		n )
			non_interactivemode_func
		;;

		v )
			version_func
		;;

		h )
			help_func
		;;

		* )
			echo "Unimplemented option chosen"
		;;
	esac
done

shift $(($OPTIND - 1))

}

# ok this is retarded ...
ftp_func ()
{
if  echo $a | grep 21 > /dev/null
then
	echo "ftp is running"
	b=`echo ftp is running`
else
	echo "ftp is not running"
	b=`echo ftp is not running`
fi
interactivemode_func
}

ssh_func ()
{
if echo $a | grep 22 > /dev/null
then
	echo "ssh is running"
	c=`echo ssh is running`
else
	echo "ssh is not running"
	c=`echo ssh is not running`
fi
interactivemode_func
}

fake_func ()
{
if echo $a | grep testing > /dev/null
then
	echo "fake service running" # shouldnt be
	d=`echo fake service is running`
else
	echo "fake service not running"
	d=`echo fake service is not running`
fi
interactivemode_func
}

telnet_func ()
{
if echo $a | grep 23 > /dev/null
then
	echo "telnet is running"
	e=`echo telnet is running`
else
	echo "telnet is not running"
	e=`echo telnet is not running`
fi
interactivemode_func
}

smtp_func ()
{
if echo $a | grep 25 > /dev/null
then
	echo "smtp is running"
	f=`echo smtp is running`
else
	echo "smtp is not running"
	f=`echo smtp is not running`
fi
interactivemode_func
}

http_func ()
{
if echo $a | grep 80 > /dev/null
then
	echo "http is running"
	g=`echo http is running`
else
	echo "http is not running"
	g=`echo http is not running`
fi
interactivemode_func
}

pop_func () # not 2, not 4, but 3
{
if echo $a | grep 110 > /dev/null
then
	echo "pop3 is running"
	p=`echo pop3 is running`
else
	echo "pop3 is not running"
	p=`echo pop3 is not running`
fi
interactivemode_func
}

main "$@"

# 4  
Old 08-13-2003
Shiny. may i include it in my php FE? the extra error-checking could certainly be useful Smilie

Last edited by Karma; 08-13-2003 at 02:27 PM..
# 5  
Old 08-13-2003
sure ! Smilie

just give me credit for my orignial code that you may use.

the command line option checking i got most of it from the advanced BASH shell scripting guide at tldp.org .

but im glad someone other than me may get good use out of that.
# 6  
Old 08-14-2003
Credit?! of course! i mentioned in the header of index.php that anyone who contributed would be given proper credit! tell me what you want said! e-mail address, ICQ UIN, url, name, street, phone number, fax, SIN, whatever you want.

While i don't really believe in intellectual property, i *strongly* believe in giving proper credit.

And so does my hybernation begin again - see you in 2 wks... hopefully with your script included.
# 7  
Old 09-06-2003
The latest version can be found here:

http://karma.luniac.com/misc/nmap_php_fe.tar.gz
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Homework & Coursework Questions

How to scan IP range using nmap?

Scripting language : Bash Shell Script 1. problem statement I have to create function in which read IP addresses one by one from one file (iplist.txt) and scan these IP using nmap. This scan IP's output is saved in output.txt file and parse output.txt to save only open ports with particular IP... (3 Replies)
Discussion started by: sk151993
3 Replies

2. Cybersecurity

Help with NMAP

I'm seeing a persistent address showing up on my firewall router logs. The address is 10.98.115.9:67, and is broadcasting to 255.255.255.255. I know that this would typically signal a BOOTP service, such as a bootp server announcing itself on the network. But I can't isolate which machine it... (3 Replies)
Discussion started by: renoir611
3 Replies

3. Linux

nmap binaries for linux

Hi , I am exploring the nmap utility for Linux. I know that, nmap binaries are specific to the platforms e.g. nmap binaries will be diferent for Windows , AIX , Solaris and Linux platforms. Can anyone tell me , will the nmap binaries be different for different flavours of Linux such as... (1 Reply)
Discussion started by: jatin56
1 Replies

4. Solaris

Nmap error

I 'm getting following error when i run nmap for an ip .. what could be the reason for it ? #nmap 10.22.67.18 Starting Nmap 4.68 ( Nmap - Free Security Scanner For Network Exploration & Security Audits. ) at 2009-07-06 19:07 UTC Warning: Unable to open interface e1000g3301000 -- skipping it.... (2 Replies)
Discussion started by: fugitive
2 Replies

5. Shell Programming and Scripting

FTP/nmap/.netrc

So... I'm trying to script and FTP Backup of some files from openVMS Alpha machine to a Unixware 7 machine. I decided to use .netrc to do all the FTP actions however when I send the nmap command. It pretty much gets ignored while even other things such "ascii", "case" etc.. get respected... (0 Replies)
Discussion started by: thesubmitter
0 Replies

6. Red Hat

To change of port name in nmap

Hi, Is it possible to change the nmap port name: For eg: 21/tcp open ftp 53/tcp open domain 80/tcp open http 111/tcp open rpcbind 836/tcp open unknown 843/tcp open unknown 953/tcp open rndc I need to change the port number 836 unknown to the name of the... (4 Replies)
Discussion started by: gsiva
4 Replies

7. AIX

nmap on aix 5.2

I'm trying to compile nmap 4.11 on an aix 5.2 machine and get the following error when attempting the 'make' command; make "Makefile", line 1: make: 1254-055 Dependency line needs colon or double colon operator. "Makefile", line 14: make: 1254-055 Dependency line needs colon or double colon... (2 Replies)
Discussion started by: zuessh
2 Replies

8. UNIX for Dummies Questions & Answers

nmap results

Hi, Whenever I tried to run nmap on my linux (red hat 6.2) boxes i got these outputs: 4444/tcp filtered krb524 6666/tcp filtered irc-serv 6699/tcp filtered napster 8888/tcp filtered sun-answerbook Can anybody please... (10 Replies)
Discussion started by: necro
10 Replies

9. Cybersecurity

Nmap

I am pretty new at running nmap ,and i have some doubt about some o/ps the nmap shows I tried to scan my own system for UDP open ports I see that if i use one UDP port say 13 It shows that its in open state , etc But if i scan for the whole UDP ports in the nmap-services . I gives te... (2 Replies)
Discussion started by: DPAI
2 Replies
Login or Register to Ask a Question