First version of Hosts Up ready and working

This commit is contained in:
Jack-Benny Persson 2014-06-03 19:11:13 +02:00
parent 2f2e8d9185
commit df0d784126
11 changed files with 206 additions and 60 deletions

17
LICENSE Normal file
View File

@ -0,0 +1,17 @@
Copyright (C) 2014 Jack-Benny Persson <jack-benny@cyberinfo.se>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

14
README.md Normal file
View File

@ -0,0 +1,14 @@
# Hosts Up #
Hosts Up is a collection of small PHP scripts and HTML documents I've made to
help me keep track of live hosts on my network at home and at work. Each time
the webpage is refreshed a new ping sweep on the network is performed. To see
which ports are open one can just click on a host and another script fires up an
Nmap scan of the host. The result is showed on the webpage. Both the ping sweep
and scans are using Nmap. Hence Nmap is required aswell as PHP's ability to
exeucte Nmap.
## Some screenshots ##
![alt text](screenshots/index.png "Hosts Up index page")
![alt text](screenshots/scan.png "Hosts Up scan page")

17
about.php Normal file
View File

@ -0,0 +1,17 @@
<?php
include ("htmlblock.html");
?>
<h1>About</h1>
<p class="text">
Hosts Up is a small collection of PHP scripts and HTML documents
I've made to simplify the task of keeping track of live hosts on
my network. It's nothing fancy or anything but it fulfills it purpose.
Hosts Up requires Nmap and that PHP is allowed to run the Nmap program
on the server it's being executed on. It's Nmap that takes care of the
pinging and port scanning of hosts.
</p>
</body>
</html>

16
help.php Normal file
View File

@ -0,0 +1,16 @@
<?php
include ("htmlblock.html");
?>
<h1>Help</h1>
<p class="text">
When entering the Hosts Up webpage it scans the network specified in the
index.php file ($network variable) and displays all live hosts. The scan is a
simple ping sweep performed by Nmap. When a host is clicked it is automatically
port scanned and the results show up on the webpage. That's pretty much all
there is to it.
</p>
</body>
</html>

View File

@ -1,22 +1,75 @@
body
{
background-color:#bababa;
}
h1
{
color:#28699b;
font-family:"Arial";
text-align:left;
}
p
{
font-family:"Arial";
font-size:24px;
background-color:#bababa;
}
#middle {
h1
{
color:#28699b;
font-family:"Arial";
text-align:left;
}
p
{
font-family:"Arial";
font-size:22px;
}
p.top
{
font-family:"Arial";
font-size:18px;
}
p.text
{
font-family:"Arial";
font-size:16px;
}
pre
{
font-size:18px;
}
a:link
{
text-decoration:none;
color:#000000;
}
a:visited
{
text-decoration:none;
color:#000000;
}
a:hover
{
text-decoration:underline;
color:#000000;
}
a:active
{
text-decoration:none;
color:#000000;
}
#middle
{
position: absolute;
left: 40%;
left: 35%;
top: 10%;
width:400px;
margin: 0px
}
#top
{
position: absolute;
left: 35%;
top: 5%
margin: 0px
}

View File

@ -1,46 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="description" content="HostsUp" />
<meta name="author" content="Jack-Benny Persson" />
<link rel="stylesheet" type="text/css" href="hosts_up.css" title="HostsUp"/>
<title>HostsUp</title>
</head>
<body>
<div id = "middle">
<?php
$network = "192.168.0.0/24";
$hosts = shell_exec("nmap $network -sn");
/* Match any IP-number
[0-9] = all digits from 0-9
{1,3} = one, two or three digits
\. = a dot
Hence, 0-9 one, two or three time, a dot, and then all over again
*/
preg_match_all("/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/", $hosts,
$out);
print "<h1>Hosts that are up</h1>\n";
print "<p>\n";
foreach ($out[0] as $i)
{
print $i . "<br />\n";
}
print "</p>\n";
?>
</div>
</body>
</html>

25
htmlblock.html Normal file
View File

@ -0,0 +1,25 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="description" content="Hosts Up" />
<meta name="author" content="Jack-Benny Persson" />
<link rel="stylesheet" type="text/css" href="hosts_up.css" title="Hosts Up"/>
<title>Hosts Up</title>
</head>
<body>
<div id = "top">
<p class="top">
<a href="index.php">Hosts Up</a> | <a href="help.php">Help</a>
| <a href="about.php">About</a> | <a href="LICENSE">Copyright</a>
</p>
<hr />
</div>
<div id = "middle">

28
index.php Normal file
View File

@ -0,0 +1,28 @@
<?php
include("htmlblock.html");
// Change the network variable to your network
$network = "192.168.0.0/24";
$hosts = shell_exec("nmap $network -sn");
// Regexp to match any IP-number
preg_match_all("/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/", $hosts,
$out);
print "<h1>Hosts that are up</h1>\n";
print "<p>\n";
foreach ($out[0] as $i)
{
print "<a href=\"scan.php?host=$i\">$i</a> <br />\n";
}
print "</p>\n";
?>
</div>
</body>
</html>

22
scan.php Normal file
View File

@ -0,0 +1,22 @@
<?php
include("htmlblock.html");
print "<h1>Open ports on $_GET[host]</h1>\n";
print "<pre>\n";
$portscan = shell_exec("nmap $_GET[host]");
preg_match_all('/[0-9]{1,5}\/..p.*/', $portscan, $openports);
foreach ($openports[0] as $out)
{
print "$out\n";
}
?>
</pre>
</div>
</body>
</html>

BIN
screenshots/index.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

BIN
screenshots/scan.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB