VPN-Management-GUI 2.0.3 porting start

This commit is contained in:
Christoph Haas 2012-07-16 19:30:19 +00:00
commit d3b0130655
545 changed files with 19128 additions and 0 deletions

11
.project Normal file
View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>vpnmanager</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
</buildSpec>
<natures>
</natures>
</projectDescription>

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

BIN
Admin/Modules/Home/img/tux.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

30
Admin/Modules/Home/index.php Executable file
View File

@ -0,0 +1,30 @@
<?php
include ($_SERVER["DOCUMENT_ROOT"]."/Site/checkadmin.php");
//include ($_SERVER["DOCUMENT_ROOT"]."/Config/_siteconfig_.php");
?>
<!-- MAIN CONTENT BEGINN ################################################################################ -->
<h1><b>Administration Center</b></h1>
<table>
<tr><td width=60%>
<h2>Actions:</h2>
<?php
$moduleid = 0;
foreach ($SITE_MODULES_ADMIN as $modul)
{
$moduleid++;
$cut = strpos($modul, "#");
$modtitle = substr($modul,0,$cut);
echo "<a href=\"/Admin/index.php?site=".$moduleid."&uebergabe=0&uebergabe2=0&uebergabe3=0&uebergabe4=0\">
<p># ".$modtitle."</p>
</a>";
}
?>
<a href ="/sql/"><p># PhpMyAdmin</p></a>
</td>
<td>
<img src="/Admin/Modules/Home/img/tux.png">
</td>
</tr>
</table>

171
Admin/Modules/Logviewer/index.php Executable file
View File

@ -0,0 +1,171 @@
<?php
include($_SERVER["DOCUMENT_ROOT"]."/Site/checkadmin.php");
include ($_SERVER["DOCUMENT_ROOT"]."/Config/_dbconfig_.php");
@mysql_connect($MYSQL_HOST,$MYSQL_USER,$MYSQL_PASS);
@$x=mysql_select_db($MYSQL_DATABASE);
if (empty($x))
{
echo "ERROR 0x01, Failed to connect to database!<br>";
exit;
}
$sort = mysql_real_escape_string($_POST["dirsort"]); //$_GET["sort"];
$by = mysql_real_escape_string($_POST["sortby"]); //$_GET["by"];
$table = mysql_real_escape_string($_POST["table"]); //$_GET["table"];
$client= mysql_real_escape_string($_POST["client"]);
?>
<!-- MAIN CONTENT BEGINN ################################################################################ -->
<form action="<?php echo $PHP_SELF; ?>" method="post">
<br>
<select name="dirsort" size=1>
<option <?php if($sort=="ASC") echo "selected";?> value="ASC">Up</option>
<option <?php if($sort=="DESC") echo "selected";?> value="DESC">Down</option>
</select>
<select name="table" size=1>
<option <?php if($table=="year") echo "selected";?> value="year">Year</option>
<option <?php if($table=="month") echo "selected";?> value="month">Month</option>
<option <?php if($table=="connections") echo "selected";?> value="connections">All</option>
</select>
<select name="sortby" size=1>
<option <?php if($by=="id") echo "selected";?> value="id">ID</option>
<option <?php if($by=="client") echo "selected";?> value="client">Client</option>
<option <?php if($by=="sent") echo "selected";?> value="sent">Sent</option>
<option <?php if($by=="received") echo "selected";?> value="received">Received</option>
<option <?php if($by=="ip") echo "selected";?> value="ip">IP</option>
</select>
Search Client:<input type="text" name="client" size="20" <?php if($client !="") echo "value=".$client;?> ></td>
<input type="submit" value="go!">
</form>
<!------ Sorting Leiste Start-->
<?
// MYsql befehl basteln
$sql = "SELECT * FROM $table ORDER BY $by $sort;";
$result = mysql_query($sql);
echo "<br><table border=1>";
if($table=='connections')
{
echo "<tr><td>Start Time</td><td>Stop Time</td><td>Client Name</td><td>Client IP</td><td>Download
</td><td>Upload</td></tr>\n";
}
else if($table=='month')
{
echo "<tr><td>Month</td><td>Year</td><td>Connection Time</td><td>Client Name</td><td>Download
</td><td>Upload</td></tr>\n";
}
else if($table=='year')
{
echo "<tr><td>Year</td><td>Connection Time</td><td>Client Name</td><td>Download
</td><td>Upload</td></tr>\n";
}
else
{
}
// ------------------------------------------------ Mysql lesen
if ($result)
{
while ($ar=mysql_fetch_array($result,MYSQL_ASSOC))
{
if($ar["sent"]>1024)
{
$sentbytes = round($ar["sent"]/1024,2) . " KiB";
if($ar["sent"]>1048576)
{
$sentbytes = round($ar["sent"]/1024/1024,2) . " MiB";
if($ar["sent"]>1073741824)
{
$sentbytes = round($ar["sent"]/1024/1024/1024,2) . " GiB";
}
}
}
else
{
$sentbytes = $ar["sent"]. " Byte";
}
if($ar["received"]>1024)
{
$receivedbytes = round($ar["received"]/1024,2) . " KiB";
if($ar["received"]>1048576)
{
$receivedbytes = round($ar["received"]/1024/1024,2) . " MiB";
if($ar["received"]>1073741824)
{
$receivedbytes = round($ar["received"]/1024/1024/1024,2) . " GiB";
}
}
}
else
{
$receivedbytes = $ar["received"]. " Byte";
}
if($table=='connections')
{
if($ar["stop"] != 0)
{
$stop = date("r",$ar["stop"]);
}
else
{
$stop = "running session";
}
if($client == "" || $ar["client"] == $client)
{
echo "<tr><td>",date("r",$ar["start"]),"</td><td>",$stop,"</td><td>",$ar["client"],
"</td><td>",$ar["ip"],
"</td><td align=right>",$sentbytes,
"</td><td align=right>",$receivedbytes,
"</td></tr>\n";
}
}
else if($table=='month')
{
$hour = floor($ar["time"]/3600);
$min = floor($ar["time"]/60 - $hour *60);
$sec = $ar["time"]-$hour*3600-$min*60;
$timestring = $hour .":". $min .":". $sec;
if($client == "" || $ar["client"] == $client)
{
echo "<tr><td>",$ar["month"],"</td><td>",$ar["year"],"</td><td>",$timestring,
"</td><td>",$ar["client"],
"</td><td align=right>",$sentbytes,"</td><td align=right>",$receivedbytes,
"</td></tr>\n";
}
}
else if($table=='year')
{
$hour = floor($ar["time"]/3600);
$min = floor($ar["time"]/60 - $hour *60);
$sec = $ar["time"]-$hour*3600-$min*60;
$timestring = $hour .":". $min .":". $sec;
if($client == "" || $ar["client"] == $client)
{
echo "<tr><td>",$ar["year"],"</td><td>",$timestring,
"</td><td>",$ar["client"],
"</td><td align=right>",$sentbytes,"</td><td align=right>",$receivedbytes,
"</td></tr>\n";
}
}
else
{
}
}
}
else
{
echo "<br>";
}
echo "</table>";
mysql_close();
?>

10
Admin/Modules/Munin/index.php Executable file
View File

@ -0,0 +1,10 @@
<?php
include ($_SERVER["DOCUMENT_ROOT"]."/Site/checkadmin.php");
?>
<iframe id="iframe" src="/munin/" width="99%" height=1024
scrolling="auto" marginheight="0" marginwidth="0" frameborder="0">
<p> Ihr Browser kann leider keine eingebetteten Frames anzeigen:
Sie k&ouml;nnen die eingebettete Seite &uuml;ber den folgenden Verweis
aufrufen: <a href="/munin/">SELFHTML</a>
</p>
</iframe>

View File

@ -0,0 +1,42 @@
<?php
session_start();
include ($_SERVER["DOCUMENT_ROOT"]."/Site/checkadmin.php");
include ($_SERVER["DOCUMENT_ROOT"]."/Site/mysql.php");
$moduleurl = $_REQUEST["path"];
list($db,$conn) = db_connect();
if (empty($db))
{
die ("Keine Verbindung zur Datenbank! [<b><font color=red>FAIL</b></font>]<br>");
}
if(is_null($_REQUEST["withsquid"]))
{
$_REQUEST["withsquid"] = "0";
}
if(is_null($_REQUEST["withmail"]))
{
$_REQUEST["withmail"] = "0";
}
if(is_null($_REQUEST["withusersquid"]))
{
$_REQUEST["withusersquid"] = "0";
}
// Daten eintragen
while (list ($attr, $value) = each ($_REQUEST))
{
if($attr != "path")
{
// SQL-Anweisung erstellen
$sql = "UPDATE ".
"config SET value='".mysql_real_escape_string($value)."' WHERE attr = '".mysql_real_escape_string($attr)."'";
mysql_query ($sql);
}
}
header ("Location: ".$moduleurl."&uebergabe=1");
?>

242
Admin/Modules/Settings/index.php Executable file
View File

@ -0,0 +1,242 @@
<?php
$moduleurl = $_SERVER["REQUEST_URI"];
$urlcut = strpos($moduleurl, "&");
if($urlcut > 0)
{
$moduleurl = substr($moduleurl,0,$urlcut);
}
else
{
if(strpos($moduleurl, "?") == 0)
{
$moduleurl = $_SERVER["REQUEST_URI"]."?site=1";
}
}
$url = $moduleurl;
include ($_SERVER["DOCUMENT_ROOT"]."/Site/checkadmin.php");
$status = $_REQUEST["uebergabe"];
?>
<!-- MAIN CONTENT BEGINN ################################################################################ -->
<h1><b>Settings</b></h1>
<?php
switch($status)
{
case 1:
echo "<b>Settings saved successfully!</b>";
break;
case 2:
echo "<b>Domain ACL saved successfully!</b>";
break;
case 3:
echo "<b>Blocked Client ACL saved successfully!</b>";
break;
case 4:
echo "<b>Allowed Client ACL saved successfully!</b>";
break;
default:
break;
}
echo "
<form action=\"/Admin/Modules/Settings/change.php\" method=\"post\">
<table>
<br>
<tr>
<td>Sitename:</td>
<td><input type=\"text\" name=\"sitename\" size=\"50\" value=\"".db_getconfval("sitename")."\"><td>
</tr>
<tr>
<td>Sitesubname</td>
<td><input type=\"text\" name=\"subname\" size=\"50\" value=\"".db_getconfval("subname")."\"><td>
</tr>
<tr>
<td>Siteinfo (Header Marquee)</td>
<td><input type=\"text\" name=\"siteinfo\" size=\"50\" value=\"".db_getconfval("siteinfo")."\"><td>
</tr>
<tr>
<td>Theme:</td>
<td>
<select name=\"sitetheme\" size=1> ";
// Öffnet ein Unterverzeichnis mit dem Namen "daten"
$verzeichnis = openDir($_SERVER["DOCUMENT_ROOT"]."/Themes");
// Verzeichnis lesen
while ($file = readDir($verzeichnis))
{
// Höhere Verzeichnisse nicht anzeigen!
if ($file != "." && $file != "..")
{
$filecut = strpos($file, ".");
if($filecut > 0)
{
$file = substr($file,0,$filecut);
echo "<option "; if(db_getconfval("sitetheme")==$file) echo "selected "; echo "value=\"".$file."\">".$file."</option>";
}
}
}
// Verzeichnis schließen
closeDir($verzeichnis);
echo "
</select>
</td>
</tr>
<tr>
<td>OpenVPN Config Directory (WITHOUT ending /):</td>
<td><input type=\"text\" name=\"ovpnconfdir\" size=\"50\" value=\"".db_getconfval("ovpnconfdir")."\"><td>
</tr>
<tr>
<td>OpenVPN Config File Name:</td>
<td><input type=\"text\" name=\"ovpnconffile\" size=\"50\" value=\"".db_getconfval("ovpnconffile")."\"><td>
</tr>
<tr>
<td>OpenVPN Key Directory (WITHOUT ending /):</td>
<td><input type=\"text\" name=\"ovpnkeydir\" size=\"50\" value=\"".db_getconfval("ovpnkeydir")."\"><td>
</tr>
<tr>
<td>OpenVPN Additional Download Directory (e.g. for client.ovpn, ca.crt, readme ...) (WITHOUT ending /):</td>
<td><input type=\"text\" size=\"50\" name=\"publicdown\" value=\"".db_getconfval("publicdown")."\"></td>
</tr>
<tr>
<td>Download Directory (for Explorer, WITHOUT ending /):</td>
<td><input type=\"text\" name=\"downdir\" size=\"50\" value=\"".db_getconfval("downdir")."\"><td>
</tr>
<tr>
<td>Enable Mail Support:</td>
<td><input type=\"checkbox\" name=\"withmail\" value=\"1\" "; if(db_getconfval("withmail")=="1") echo "checked"; echo"></td>
</tr>";
if(db_getconfval("withmail")=="1")
{
echo"
<tr>
<td>SMTP Server:</td>
<td><input type=\"text\" name=\"mserv\" size=\"50\" value=\"".db_getconfval("mserv")."\"><td>
</tr>
<tr>
<td>SMTP User:</td>
<td><input type=\"text\" name=\"muser\" size=\"50\" value=\"".db_getconfval("muser")."\"><td>
</tr>
<tr>
<td>SMTP Password:</td>
<td><input type=\"password\" name=\"mpass\" size=\"50\" value=\"".db_getconfval("mpass")."\"><td>
</tr>
<tr>
<td>SMTP Sender Mail-Address:</td>
<td><input type=\"text\" name=\"mname\" size=\"50\" value=\"".db_getconfval("mname")."\"><td>
</tr>";
}
echo"
<tr>
<td>Enable Squid Repair:</td>
<td><input type=\"checkbox\" name=\"withusersquid\" value=\"1\" "; if(db_getconfval("withusersquid")=="1") echo "checked"; echo"></td>
</tr>
<tr>
<td>Enable Squid Support:</td>
<td><input type=\"checkbox\" name=\"withsquid\" value=\"1\" "; if(db_getconfval("withsquid")=="1") echo "checked"; echo"></td>
</tr>";
if(db_getconfval("withsquid")=="1")
{
echo"
<tr>
<td>SQUID Config Directory (WITHOUT ending /):</td>
<td><input type=\"text\" name=\"sqdir\" size=\"50\" value=\"".db_getconfval("sqdir")."\"><td>
</tr>
<tr>
<td>SQUID Config File Name:</td>
<td><input type=\"text\" name=\"sqconf\" size=\"50\" value=\"".db_getconfval("sqconf")."\"><td>
</tr>
<tr>
<td>SQUID Dynamic Directory (WIHTOUT ending /):</td>
<td><input type=\"text\" name=\"sqddir\" size=\"50\" value=\"".db_getconfval("sqddir")."\"><td>
</tr>";
}
echo"
</table>
<input type=\"hidden\" name=\"path\" size=\"50\" value=\"".$moduleurl."\">
<input type=\"submit\" value=\"Save settings\">
</form> ";
if(db_getconfval("withsquid")=="1")
{
echo"
<br />
<hr/ >
<form action=\"".$url."\" method =\"post\">
<p>Squid Domain ACL (blocked Domains):</p>
<textarea name=\"inhalt\" rows=5 cols=100 wrap=\"virtual\">";
include(db_getconfval("sqdir")."/denied_domains.acl");
echo "
</textarea><br />
<input name=\"submit\" type=\"submit\" id=\"submit\" value=\"Speichern\" />
<input type=\"reset\" name=\"Submit2\" value=\"Reset\" />
</form>";
echo "
<hr />
<form action=\"".$url."\" method =\"post\">
<p>Squid Client ACL (blocked Clients):</p>
<textarea name=\"inhaltc\" rows=5 cols=100 wrap=\"virtual\">";
include(db_getconfval("sqdir")."/denied_clients.acl");
echo "
</textarea><br>
<input name=\"submitc\" type=\"submit\" id=\"submit\" value=\"Speichern\" />
<input type=\"reset\" name=\"Submit2c\" value=\"Reset\" />
</form>";
echo "
<hr />
<form action=\"".$url."\" method =\"post\">
<p>Squid Client ACL (allowed Clients):</p>
<textarea name=\"inhalta\" rows=5 cols=100 wrap=\"virtual\">";
include(db_getconfval("sqdir")."/allowed_clients.acl");
echo "
</textarea><br>
<input name=\"submita\" type=\"submit\" id=\"submit\" value=\"Speichern\" />
<input type=\"reset\" name=\"Submit2a\" value=\"Reset\" />
</form>";
if ($_REQUEST["submit"] == "Speichern")
{
$fp = fopen(db_getconfval("sqdir")."/denied_domains.acl","w");
$data =$_REQUEST["inhalt"];
$data = str_replace("\r","",$data);
exec("touch /var/vpn/squid_restart");
fputs($fp,$data);
fclose($fp);
echo "<meta http-equiv=\"Refresh\" content=\"1; ".$url."&uebergabe=2\">";
}
if ($_REQUEST["submitc"] == "Speichern")
{
$fp = fopen(db_getconfval("sqdir")."/denied_clients.acl","w");
$data =$_REQUEST["inhaltc"];
$data = str_replace("\r","",$data);
exec("touch /var/vpn/squid_restart");
fputs($fp,$data);
fclose($fp);
echo "<meta http-equiv=\"Refresh\" content=\"1; ".$url."&uebergabe=3\">";
}
if ($_REQUEST["submita"] == "Speichern")
{
$fp = fopen(db_getconfval("sqdir")."/allowed_clients.acl","w");
$data =$_REQUEST["inhalta"];
$data = str_replace("\r","",$data);
exec("touch /var/vpn/squid_restart");
fputs($fp,$data);
fclose($fp);
echo "<meta http-equiv=\"Refresh\" content=\"1; ".$url."&uebergabe=4\">";
}
}
?>

View File

@ -0,0 +1,14 @@
<?php
session_start();
include ($_SERVER["DOCUMENT_ROOT"]."/Site/checkadmin.php");
include ($_SERVER["DOCUMENT_ROOT"]."/Config/_siteconfig_.php");
$id = $_REQUEST["id"];
$path = $_REQUEST["path"];
// Write to file vpnid_man
$myFile = db_getconfval("sqddir")."/vpnid_man";
$fh = fopen($myFile, 'w') or die("can't open file");
fwrite($fh, $id);
fclose($fh);
header ("Location: ".$path."&uebergabe=1&uebergabe2=1");
?>

9
Admin/Modules/Squid/delbl.php Executable file
View File

@ -0,0 +1,9 @@
<?php
session_start();
$path = $_REQUEST["path"];
include ($_SERVER["DOCUMENT_ROOT"]."/Site/checkadmin.php");
include ($_SERVER["DOCUMENT_ROOT"]."/Site/mysql.php");
$ret = passthru("echo > ".db_getconfval("sqddir")."/blacklist");
echo $ret;
header ("Location: ".$path."&uebergabe=1&uebergabe2=2");
?>

View File

@ -0,0 +1,66 @@
<?php
//include($_SERVER["DOCUMENT_ROOT"]."/Site/mysql.php");
// Change: your company name
$config['Company_Name'] = 'SchulVPN';
// Change: your company home page
$config['URL_Home_Page'] = 'http://10.10.63.60/index.php';
$config['AUTH_REALM'] = $config['Company_Name'] .' OpenVPN Web GUI v.0.3.2';
// What files to include into ZIP
$config['Download']['ZIP']['.pem'] = true;
$config['Download']['ZIP']['.key'] = true;
$config['Download']['ZIP']['.csr'] = false;
// All the following files should be placed into downloads folder
$config['Download']['ZIP']['Others'] = array ('readme.txt','ca.crt', 'schulvpn.ovpn', 'certinstall.sh');
//$config['Download']['ZIP']['Others'] = array ('readme.txt', 'install.cmd', 'tls-auth.key');
// Use the real absolute path here.
$config['PluginsAbsolutePath'] = $_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNConfig/plugins/";
// If there are no plugins
//$config['Plugins'] = NULL;
// Otherwise, follow this example:
//$config['Plugins']['PLUGINMANE']['Folder'] = 'FOLDERNAME';
// The post-install helper plugin. Shows if PHP5 has the neccessary functions available
$config['Plugins']['systemcheck']['Folder'] = 'systemcheck';
// OPENVPN ________________________________
// Change: the configuration directory
$config['openvpn']['folder'] = db_getconfval("ovpnconfdir")."/";
// Change: configuration and status file names
$config['openvpn']['config'] = $config['openvpn']['folder'].db_getconfval("ovpnconffile");
$config['openvpn']['status'] = $config['openvpn']['folder']."openvpn-status.log";
// OPENSSL ________________________________
// Change: openssl keys directory
$config['openssl']['folder'] = db_getconfval("ovpnkeydir")."/keys/";
// Change: different folders for Public Certificates, Certificate Requests and Private Keys.
// NOTE: openssl somehow respects only newpem folder (for Public Certificates).
$config['openssl']['pubfolder'] = $config['openssl']['folder'];
$config['openssl']['reqfolder'] = $config['openssl']['folder'];
$config['openssl']['prvfolder'] = $config['openssl']['folder'];
// Change: openssl CA private and public keys
$config['openssl']['CA']['priv'] = $config['openssl']['folder'] .'ca.key';
$config['openssl']['CA']['pub'] = $config['openssl']['folder'] .'ca.crt';
// Change: openssl serial file
$config['openssl']['serial'] = $config['openssl']['folder'] .'serial';
// Change: openssl database
$config['openssl']['database'] = $config['openssl']['folder'] .'index.txt';
// Change: openssl configuration
$config['openssl']['config'] = $config['openvpn']['folder'] .'openssl.cnf';
// NEW OPENSSL CERTIFICATE DEFAULTS _________
// Change all of them as it is done in your easy-rsa/vars
$config['openssl']['default']['expiration'] = 3560;
$config['openssl']['default']['countryName'] = 'AT';
$config['openssl']['default']['stateOrProvinceName'] = 'Tirol';
$config['openssl']['default']['localityName'] = 'Innsbruck';
$config['openssl']['default']['organizationName'] = 'HTL';
$config['openssl']['default']['organizationalUnitName'] = '';
$config['openssl']['default']['commonName'] = '';
$config['openssl']['default']['emailAddress'] = 'vpn@students.htlinn.ac.at';
?>

View File

@ -0,0 +1,251 @@
<?php
// ----------------------------------------------
function load_plugins ()
{
global $config;
if (isset ($config['Plugins']))
{
foreach ($config['Plugins'] as $PluginName => $PluginData)
{
// Check if the config.inc for a plugin exists
if (file_exists ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/plugins/". $PluginData['Folder'] ."/config.inc"))
{
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/plugins/". $PluginData['Folder'] ."/config.inc");
// Check if claimed inc files do exist
if (isset ($config['Plugins'][$PluginName]['Action']['Include']) &&
!file_exists ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/plugins/". $PluginData['Folder'] ."/".
$config['Plugins'][$PluginName]['Action']['Include']))
$config['Plugins'][$PluginName]['Action']['Include'] = NULL;
if (isset ($config['Plugins'][$PluginName]['Left']['Menu']) &&
!file_exists ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/plugins/". $PluginData['Folder'] ."/".
$config['Plugins'][$PluginName]['Left']['Menu']))
$config['Plugins'][$PluginName]['Left']['Menu'] = NULL;
if (isset ($config['Plugins'][$PluginName]['Left']['Status']) &&
!file_exists ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/plugins/". $PluginData['Folder'] ."/".
$config['Plugins'][$PluginName]['Left']['Status']))
$config['Plugins'][$PluginName]['Left']['Status'] = NULL;
}
}
}
}
// ----------------------------------------------
function seconds_string ($seconds, $periods = null)
{
$Wanted = '';
// Define time periods
if (!is_array ($periods))
{
$periods = array (
'years' => 31556926,
'months' => 2629743,
'weeks' => 604800,
'days' => 86400,
'hours' => 3600,
'minutes' => 60,
'seconds' => 1
);
}
// Wanted
if (empty ($seconds))
{ $Wanted = ''; }
else
{
// Loop
$seconds = (int) $seconds;
foreach ($periods as $period => $value)
{
$count = floor ($seconds / $value);
if ($count == 0)
continue;
elseif ($count == 1)
$Wanted .= ($count . ' ' . substr ($period, 0, strlen ($period) - 1) . ' ');
else
$Wanted .= ($count . ' ' . $period . ' ');
$seconds = $seconds % $value;
}
}
return rtrim ($Wanted);
}
// ----------------------------------------------
function chomp (&$string)
{
if (is_array ($string))
{
foreach ($string as $i => $val)
{ $endchar = chomp ($string[$i]); }
}
else
{
$endchar = substr ("$string", strlen("$string") - 1, 1);
if ($endchar == "\n")
{ $string = substr ("$string", 0, -1); }
}
return $endchar;
}
// ----------------------------------------------
function str_strip_spaces ($aline)
{
while (strpos ($aline, "\t") != FALSE) $aline = str_replace ("\t", ' ', $aline);
while (strpos ($aline, ' ') != FALSE) $aline = str_replace (' ', ' ', $aline);
return $aline;
}
// ----------------------------------------------
// Returns $afile only if it is the full name, or prefixed by $apath
function str_file_fullname ($apath, $afile)
{
if (substr ($afile, 0, 1) != '/')
$afile = ($apath . $afile);
return $afile;
}
// ----------------------------------------------
// Returns $afile only if it is the full name, or prefixed by $apath
function str_openssldata_to_string ($adata)
{
$Return = '';
$amonth = array ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
if (substr ($adata, -1, 1) == 'Z')
{
$Return = sprintf ("%s %d %s%02d, %02d:%02d:%02d",
$amonth [substr ($adata, 2, 2) - 1],
substr ($adata, 4, 2),
(substr ($adata, 0, 2) > 50 ? '19' : '20'),
substr ($adata, 0, 2),
substr ($adata, 6, 2),
substr ($adata, 8, 2),
substr ($adata, 10, 2));
}
return $Return;
}
// ----------------------------------------------
function str_get_sometag ($aline, $sometag)
{
if (eregi ($sometag, $aline, $anarray))
return $anarray[1];
else
return '';
}
// ----------------------------------------------
// Writes content into file
// Optionally sames old file into backup file.
// The Backup File has to reside on the same partition!
function writefile ($afile, $adata, $abackup = NULL)
{
// Move the old file into Backup one
if ($abackup != NULL)
{
if (file_exists ($afile))
{
if (file_exists ($abackup))
if (!unlink ($abackup))
exit;
if (!rename ($afile, $abackup))
exit;
}
}
$fp = fopen ($afile, "w", 0);
if (!$fp)
exit;
fputs ($fp, $adata);
fclose ($fp);
}
// ----------------------------------------------
// Guess the full file name
function if_file_exists (&$sFileName, $bFix = FALSE)
{
global $config;
if (strpos ($sFileName, '/') == FALSE)
{
$sLongFileName = $config['openvpn']['folder'] . $sFileName;
if (file_exists ($sLongFileName) && $bFix)
$sFileName = $sLongFileName;
}
return file_exists ($sFileName);
}
// ----------------------------------------------
function zlib_check_functions ()
{
$Result = '';
$ZLibs = array
(
'gzcompress'
);
foreach ($ZLibs as $Function)
{
$Result .= $Function . '<font color="black">:</font> ' . (function_exists ($Function) ?
'<font color="black">OK</font>' :
'<font color="red">DOES NOT EXIST</font>') . '<br>';
}
return $Result;
}
// ----------------------------------------------
function html_dump ($aname, $athing)
{
echo '<pre><b><font color="darkgreen">'. $aname .'</font></b>: ';
print_r ($athing);
echo "</pre><br>\n";
}
// ----------------------------------------------
function html_error ($amessage, $ifexit = true)
{
global $config;
echo $amessage;
if ($ifexit)
exit;
}
// ----------------------------------------------
function html_postredir ($url)
{
header ('HTTP/1.1 303 REDIRECT');
header ('Location: '. $url);
#header ('Status: 303'); // if 1st header generates 500, then commend it out and use this one as 2nd
}
// ----------------------------------------------
// ----------------------------------------------
function html_download ($sFile, $sName)
{
header ('Content-type: application/octet-stream');
header ('Content-Disposition: attachment; filename="'. $sName . '"');
readfile ($sFile);
}
// ----------------------------------------------
function html_download_data ($sData, $sName)
{
header ('Content-type: application/octet-stream');
header ('Content-Disposition: attachment; filename="'. $sName . '"');
echo $sData;
}
?>

View File

@ -0,0 +1,377 @@
<?php
// ----------------------------------------------
function openssl_check_functions ()
{
$Result = '';
$OpenSSLs = array
(
'openssl_csr_new',
'openssl_csr_sign',
'openssl_csr_export_to_file',
'openssl_pkey_new',
'openssl_pkey_get_private',
'openssl_pkey_export_to_file',
'openssl_x509_export_to_file'
);
foreach ($OpenSSLs as $Function)
{
$Result .= $Function . '<font color="black">:</font> ' . (function_exists ($Function) ?
'<font color="black">OK</font>' :
'<font color="red">DOES NOT EXIST</font>') . '<br>';
}
return $Result;
}
// ----------------------------------------------
function openssl_load_database ($afile = '')
{
global $config;
global $openssl;
$afile = ($afile == '' ? $config['openssl']['database'] : $afile);
$lines = file ($afile);
if (!is_array ($lines))
exit;
foreach ($lines as $line_num => $line)
{
chomp ($line);
$linetokens = explode ("\t", $line);
// Ensure that all the fields are set
if (count ($linetokens) == 6)
{
// Decode the openssl's database. See apps/apps.h
$openssl['Database'][] = array ('Status' => $linetokens[0],
'ExpDate' => $linetokens[1],
'RevDate' => $linetokens[2],
'Serial' => $linetokens[3],
'File' => $linetokens[4],
'Name' => $linetokens[5],
'Country' => openssl_get_country ($linetokens[5]),
'State' => openssl_get_state ($linetokens[5]),
'City' => openssl_get_city ($linetokens[5]),
'Company' => openssl_get_company ($linetokens[5]),
'Department' => openssl_get_department ($linetokens[5]),
'CN' => openssl_get_CN ($linetokens[5]),
'Email' => openssl_get_email ($linetokens[5])
);
}
}
}
// ----------------------------------------------
function openssl_write_database ($afile = '')
{
global $config;
global $openssl;
$afile = ($afile == '' ? $config['openssl']['database'] : $afile);
$atext = '';
for ($i = 0; $i < count ($openssl['Database']); $i++)
{
$atext .= ($atext == '' ? '' : "\n");
$atext .= $openssl['Database'][$i]['Status'] ."\t".
$openssl['Database'][$i]['ExpDate'] ."\t".
$openssl['Database'][$i]['RevDate'] ."\t".
$openssl['Database'][$i]['Serial'] ."\t".
$openssl['Database'][$i]['File'] ."\t".
$openssl['Database'][$i]['Name'];
}
writefile ($afile, $atext, $afile .'.old');
}
// ----------------------------------------------
function openssl_write_database_attr ($atext = '', $afile = '')
{
global $config;
global $openssl;
$afile = ($afile == '' ? $config['openssl']['database'] : $afile) .'.attr';
$atext = ($atext == '' ? "unique_subject = yes\n" : $atext);
if (file_exists ($afile))
{
ob_start ();
readfile ($afile);
$atext = ob_get_contents ();
ob_end_clean ();
}
writefile ($afile, $atext, $afile .'.old');
}
// ----------------------------------------------
// Returns the PEM file with spaces reduced and replaced to &nbsp;
function openssl_load_cert ($anid)
{
global $config;
do
{
$lines = file ($config['openssl']['pubfolder'] . $anid . '.pem');
if (!is_array ($lines))
{
$Return = '';
break;
}
foreach ($lines as $line_num => $line)
{
chomp ($line);
$Return[] = str_replace (' ', '&nbsp;', htmlspecialchars (str_replace (' ', ' ', $line)));
}
} while (FALSE);
return $Return;
}
// ----------------------------------------------
function openssl_load_serial ($afile = '')
{
global $config;
$afile = ($afile == '' ? $config['openssl']['serial'] : $afile);
$lines = file ($afile);
if (!is_array ($lines))
exit;
$Return = sscanf ($lines[0], "%X");
return $Return[0];
}
// ----------------------------------------------
function openssl_write_serial ($iNumber, $afile = '')
{
global $config;
$afile = ($afile == '' ? $config['openssl']['serial'] : $afile);
writefile ($afile, openssl_hex_serial ($iNumber) . "\n", $afile .'.old');
}
// ----------------------------------------------
// Supports up to 999,999 serials
function openssl_hex_serial ($iNumber)
{
if ($iNumber < 100)
$sString = sprintf ("%02X", $iNumber);
elseif ($iNumber < 10000)
$sString = sprintf ("%04X", $iNumber);
else
$sString = sprintf ("%06X", $iNumber);
return $sString;
}
// ----------------------------------------------
// Builds User Private Key, CSR and Public Certificate
function openssl_build_key (&$anoutput, $adn, $validdays = NULL)
{
global $config;
global $openssl;
$anoutput = '';
$Return = FALSE;
// Allow to override default value
$validdays = ($validdays == NULL ? $config['openssl']['default']['expiration'] : $validdays);
do
{
if (!isset ($adn) ||
!isset ($adn['countryName']) ||
!isset ($adn['stateOrProvinceName']) ||
!isset ($adn['localityName']) ||
!isset ($adn['organizationName']) ||
!isset ($adn['organizationalUnitName']) ||
!isset ($adn['commonName']) ||
!isset ($adn['emailAddress'])
)
{ $anoutput .= "- ERROR on ". __LINE__ ." line: incomplete DN information\n"; break; }
$anoutput .= "+ OK got the valid input\n";
// Get the new User Private Key
$UserPrivKey = openssl_pkey_new (array($config['openssl']['config'],0));
if ($UserPrivKey == FALSE)
{ $anoutput .= "- ERROR on ". (__LINE__ - 2) ." line (openssl_pkey_new):\n ". openssl_error_strings () ." (that might usually mean that the openssl.cnf file is unavailable)"; break; }
$anoutput .= "+ OK got the User Private Key\n";
// Generate the User Certificate Request
$UserReq = openssl_csr_new ($adn,
$UserPrivKey,
$config['openssl']['config']);
if ($UserReq == FALSE)
{ $anoutput .= "- ERROR on ". (__LINE__ - 4) ." line (openssl_csr_new):\n ". openssl_error_strings (); break; }
$anoutput .= "+ OK generated the User Certificate Request\n";
// Read the openssl serial
$CAserial = openssl_load_serial ($config['openssl']['serial']);
$anoutput .= "+ OK read current openssl serial (". openssl_hex_serial ($CAserial) .")\n";
$UserPubCertFile = $config['openssl']['pubfolder'] . openssl_hex_serial ($CAserial) .'.pem';
$UserCertReqFile = $config['openssl']['reqfolder'] . openssl_hex_serial ($CAserial) .'.csr';
$UserPrivKeyFile = $config['openssl']['prvfolder'] . openssl_hex_serial ($CAserial) .'.key';
// Read the openssl database
openssl_load_database ($config['openssl']['database']);
$anoutput .= "+ OK read the openssl database (". count ($openssl['Database']) ." items)\n";
// Get CA's Private Key
$CAPrivKey = openssl_pkey_get_private ($config['openssl']['CA']['priv']);
if ($CAPrivKey == FALSE)
{ $anoutput .= "- ERROR on ". (__LINE__ - 2) ." line (openssl_pkey_get_private)\n ". openssl_error_strings (); break; }
$anoutput .= "+ OK read the CA Private Key\n";
// Get a CA-signed cert that lasts for 1 year
$UserPubCert = openssl_csr_sign ($UserReq,
$config['openssl']['CA']['pub'],
$CAPrivKey,
$validdays,
$config['openssl']['config'],
$CAserial);
if ($UserPubCert == FALSE)
{ $anoutput .= "- ERROR on ". (__LINE__ - 7) ." line (openssl_csr_sign)\n ". openssl_error_strings (); break; }
$anoutput .= "+ OK signed the User Certificate Request with CA Private Key\n";
// Add the new row into openssl database
$openssl['Database'][] = array ('Status' => 'V',
'ExpDate' => date ('ymdHis',
time() +
date ('Z') +
($validdays * 24 * 60 * 60)) .'Z',
'RevDate' => '',
'Serial' => openssl_hex_serial ($CAserial),
'File' => openssl_hex_serial ($CAserial) .'.crt',
'Name' => openssl_make_name ($adn)
);
// Create files
$OldUMask = umask (0007);
// Write User Private Key
if (!openssl_pkey_export_to_file ($UserPrivKey, $UserPrivKeyFile, NULL, $config['openssl']['config']))
{ $anoutput .= "- ERROR on ". (__LINE__ - 1) ." line (openssl_pkey_export_to_file)\n ". openssl_error_strings () ." (That might mean that the key folder is not write enabled for www user)"; break; }
$anoutput .= "+ OK wrote User Private Key into file $UserPrivKeyFile\n";
// Write User Public Certificate
if (!openssl_x509_export_to_file ($UserPubCert, $UserPubCertFile, FALSE))
{ $anoutput .= "- ERROR on ". (__LINE__ - 1) ." line (openssl_x509_export_to_file)\n ". openssl_error_strings (); break; }
$anoutput .= "+ OK wrote User Public Certificate into file $UserPubCertFile\n";
// Write User Certificate Request
if (!openssl_csr_export_to_file ($UserReq, $UserCertReqFile))
{ $anoutput .= "- ERROR on ". (__LINE__ - 1) ." line (openssl_csr_export_to_file)\n ". openssl_error_strings (); break; }
$anoutput .= "+ OK wrote User Certificate Request into file $UserCertReqFile\n";
// Write new openssl database
openssl_write_database ($config['openssl']['database']);
openssl_write_database_attr ('', $config['openssl']['database']);
$anoutput .= "+ OK wrote new openssl database\n";
// Write new openssl serial
openssl_write_serial ($CAserial + 1, $config['openssl']['serial']);
$anoutput .= "+ OK wrote new openssl serial\n";
umask ($OldUMask);
$Return = openssl_hex_serial ($CAserial);
} while (FALSE);
return $Return;
}
// ----------------------------------------------
function openssl_error_strings ()
{
$sString = '';
while ($msg = openssl_error_string ())
$sString .= $msg ."\n";
return $sString;
}
// ----------------------------------------------
function openssl_make_name ($adn)
{
$sString = '';
if (strlen ($adn['countryName']) > 0) $sString .= '/C=' . $adn['countryName'];
if (strlen ($adn['stateOrProvinceName']) > 0) $sString .= '/ST=' . $adn['stateOrProvinceName'];
if (strlen ($adn['localityName']) > 0) $sString .= '/L=' . $adn['localityName'];
if (strlen ($adn['organizationName']) > 0) $sString .= '/O=' . $adn['organizationName'];
if (strlen ($adn['organizationalUnitName']) > 0) $sString .= '/OU=' . $adn['organizationalUnitName'];
if (strlen ($adn['commonName']) > 0) $sString .= '/CN=' . $adn['commonName'];
if (strlen ($adn['emailAddress']) > 0) $sString .= '/emailAddress='. $adn['emailAddress'];
return $sString;
}
// ----------------------------------------------
function openssl_get_country ($aline)
{ return str_get_sometag ($aline . '/', '\/C=([^/]*)\/'); }
// ----------------------------------------------
function openssl_get_state ($aline)
{ return str_get_sometag ($aline . '/', '\/ST=([^/]*)\/'); }
// ----------------------------------------------
function openssl_get_city ($aline)
{ return str_get_sometag ($aline . '/', '\/L=([^/]*)\/'); }
// ----------------------------------------------
function openssl_get_company ($aline)
{ return str_get_sometag ($aline . '/', '\/O=([^/]*)\/'); }
// ----------------------------------------------
function openssl_get_department ($aline)
{ return str_get_sometag ($aline . '/', '\/OU=([^/]*)\/'); }
// ----------------------------------------------
function openssl_get_CN ($aline)
{ return str_get_sometag ($aline . '/', '\/CN=([^/]*)\/'); }
// ----------------------------------------------
function openssl_get_email ($aline)
{ return str_get_sometag ($aline . '/', '\/emailAddress=([^/]*)\/'); }
// ----------------------------------------------
// Guess the full file name
function openssl_get_filename ($iSerial, $sExt)
{
global $config;
$sReturn = $config['openssl']['folder'] . openssl_hex_serial ($iSerial) . $sExt;
if (!file_exists ($sReturn))
{
$sReturn = $config['openssl']['pubfolder'] . openssl_hex_serial ($iSerial) . $sExt;
if (!file_exists ($sReturn))
{
$sReturn = $config['openssl']['reqfolder'] . openssl_hex_serial ($iSerial) . $sExt;
if (!file_exists ($sReturn))
{
$sReturn = $config['openssl']['prvfolder'] . openssl_hex_serial ($iSerial) . $sExt;
if (!file_exists ($sReturn))
{
$sReturn = '';
}
}
}
}
return $sReturn;
}
?>

View File

@ -0,0 +1,11 @@
<?php
session_start();
include ($_SERVER["DOCUMENT_ROOT"]."/Site/checkadmin.php");
include ($_SERVER["DOCUMENT_ROOT"]."/Config/_siteconfig_.php");
$path = $_REQUEST["path"];
// Write to file vpnid_man
exec("touch /var/vpn/squid_restart");
header ("Location: ".$path."&uebergabe=1&uebergabe2=3");
?>

View File

@ -0,0 +1,11 @@
<?php
session_start();
include ($_SERVER["DOCUMENT_ROOT"]."/Site/checkadmin.php");
include ($_SERVER["DOCUMENT_ROOT"]."/Config/_siteconfig_.php");
$path = $_REQUEST["path"];
// Write to file vpnid_man
exec("touch /var/vpn/squid_start");
header ("Location: ".$path."&uebergabe=1&uebergabe2=4");
?>

View File

@ -0,0 +1,11 @@
<?php
session_start();
include ($_SERVER["DOCUMENT_ROOT"]."/Site/checkadmin.php");
include ($_SERVER["DOCUMENT_ROOT"]."/Config/_siteconfig_.php");
$path = $_REQUEST["path"];
// Write to file vpnid_man
exec("touch /var/vpn/squid_stop");
header ("Location: ".$path."&uebergabe=1&uebergabe2=5");
?>

45
Admin/Modules/Squid/index.php Executable file
View File

@ -0,0 +1,45 @@
<?php
include ($_SERVER["DOCUMENT_ROOT"]."/Site/checkadmin.php");
$moduleurl = $_SERVER["REQUEST_URI"];
$urlcut = strpos($moduleurl, "&");
if($urlcut > 0)
{
$moduleurl = substr($moduleurl,0,$urlcut);
}
else
{
if(strpos($moduleurl, "?") == 0)
{
$moduleurl = $_SERVER["REQUEST_URI"]."?site=1";
}
}
$mode = $_REQUEST["uebergabe"];
$status = $_REQUEST["uebergabe2"];
echo" <p><a href=\"".$moduleurl."&uebergabe=0\">Home</a>
| <a href=\"".$moduleurl."&uebergabe=1\">Config</a>
| <a href=\"".$moduleurl."&uebergabe=2\">Logviewer</a></p><hr><br>";
switch($status)
{
default:
break;
}
switch($mode)
{
case 1:
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/Squid/index_config.php");
break;
case 2:
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/Squid/index_log.php");
break;
default:
echo"<h1><b>Squid Management</b></h1>
<h2>Choose an action:</h2>
<p># <a href=\"".$moduleurl."&uebergabe=1\">Config</a></p>
<p># <a href=\"".$moduleurl."&uebergabe=2\">Logviewer</a></p><br>";
break;
}
?>

View File

@ -0,0 +1,297 @@
<?php
include ($_SERVER["DOCUMENT_ROOT"]."/Site/checkadmin.php");
//include($_SERVER["DOCUMENT_ROOT"]."/Site/mysql.php");
include($_SERVER["DOCUMENT_ROOT"]."/Config/_dbconfig_.php");
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/Squid/include/config.inc");
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/Squid/include/functions.inc");
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/Squid/include/openssl-functions.inc");
openssl_load_database ();
@$y = mysql_connect($MYSQL_HOST,$MYSQL_USER,$MYSQL_PASS);
@$x = mysql_select_db($MYSQL_DATABASE);
if (empty($x))
{
echo "ERROR 0x01, Failed to connect to database!<br>";
exit;
}
$sort = mysql_real_escape_string($_POST["dirsort"]); //$_GET["sort"];
$by = mysql_real_escape_string($_POST["sortby"]); //$_GET["by"];
$userid = mysql_real_escape_string($_POST["userid"]); //$_GET["userid"];
$search = mysql_real_escape_string($_POST["search"]); //$_GET["search"];
$moduleurl = $_SERVER["REQUEST_URI"];
$urlcut = strpos($moduleurl, "&");
$moduleurl = substr($moduleurl,0,$urlcut);
?>
<!-- MAIN CONTENT BEGINN ################################################################################ -->
<h1><b>Squid Config</b></h1>
<?php
if(is_file("/var/run/squid.pid"))
{
echo "<b>Squid is currently: <font color=green>running</font></b><br />";
}
else
{
echo "<b>Squid is currently: <font color=red>stopped</font></b><br />";
}
if ($_REQUEST["uebergabe2"]=="3")
{
echo "<b>Squid restarted successfully!</b>";
echo "<meta http-equiv=\"Refresh\" content=\"1; url=".$moduleurl."&uebergabe=1&uebergabe2=0\">";
}
if ($_REQUEST["uebergabe2"]=="4")
{
echo "<b>Squid started successfully!</b>";
echo "<meta http-equiv=\"Refresh\" content=\"1; url=".$moduleurl."&uebergabe=1&uebergabe2=0\">";
}
if ($_REQUEST["uebergabe2"]=="5")
{
echo "<b>Squid stopped successfully!</b>";
echo "<meta http-equiv=\"Refresh\" content=\"3; url=".$moduleurl."&uebergabe=1&uebergabe2=0\">";
}
?>
<table>
<tr>
<td>
<form action="/Admin/Modules/Squid/include/restartsquid.php" method="post" >
<input type="hidden" name="path" size="50" value="<?php echo $moduleurl;?>" />
<input type="submit" value="Restart Squid" />
</form>
</td>
<?php
if(!is_file("/var/run/squid.pid"))
{
echo "
<td>
<form action=\"/Admin/Modules/Squid/include/startsquid.php\" method=\"post\" >
<input type=\"hidden\" name=\"path\" size=\"50\" value=\"".$moduleurl."\" />
<input type=\"submit\" value=\"Start Squid\" />
</form>
</td>";
}
?>
<?php
if(is_file("/var/run/squid.pid"))
{
echo "
<td>
<form action=\"/Admin/Modules/Squid/include/stopsquid.php\" method=\"post\" >
<input type=\"hidden\" name=\"path\" size=\"50\" value=\"".$moduleurl."\" />
<input type=\"submit\" value=\"Stop Squid\" />
</form>
</td>";
}
?>
</tr>
</table>
<br />
<h2>Change Proxy Account:</h2>
<?php
if ($_REQUEST["uebergabe2"]=="1")
{
echo "<b>Changed Squid Account successfully!</b>";
}
?>
<br>
<p>
<form action="/Admin/Modules/Squid/changesquid.php" method="post" >
Squid ID (HEX):
<input type="text" name="id" size="3">
<input type="hidden" name="path" size="50" value="<?php echo $moduleurl;?>">
<input type="submit" value="Change Squid User">
</form>
</p>
<p>
Current Squid User:
<?php
function dec_to_hex($dec)
{
$sign = ""; // suppress errors
if( $dec < 0){ $sign = "-"; $dec = abs($dec); }
$hex = Array( 0 => 0, 1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5,
6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 'A',
11 => 'B', 12 => 'C', 13 => 'D', 14 => 'E',
15 => 'F' );
do
{
$h = $hex[($dec%16)] . $h;
$dec /= 16;
}
while( $dec >= 1 );
return $sign . $h;
}
$zeile = exec(escapeshellcmd("cat ".db_getconfval("sqddir")."/vpnid"));
$zeile = dec_to_hex($zeile);
//echo $zeile;
if(strlen ($zeile) <2)
{
$zeile = "0".$zeile;
}
if(strlen ($zeile) >2)
{
$zeile=substr($zeile, 0, -1);
}
@$y = mysql_connect($MYSQL_HOST,$MYSQL_USER,$MYSQL_PASS);
@$x = mysql_select_db($MYSQL_DATABASE);
if (empty($x))
{
echo "ERROR 0x01, Failed to connect to database!<br>";
exit;
}
$sql4 = "SELECT * FROM userdata WHERE VPNId = '".$zeile."';";
$result4 = mysql_query($sql4);
//echo $sql4;
$ar4=mysql_fetch_array($result4,MYSQL_ASSOC);
echo "<b>" . $ar4["Vorname"] . " " . $ar4["Nachname"] . "</b> VPNId: <b>" . $ar4["VPNId"]."</b>";
mysql_close();
?>
</p>
<br>
<h2>Blacklisted Accounts:</h2>
<?php
if ($_REQUEST["uebergabe2"]=="2")
{
echo "<b>Blacklist cleared successfully!</b>";
}
?>
<table border=1>
<tr><td><b>Squid ID</b></td><td><b>Nickname</b></td><td><b>Vorname</b></td><td><b>Nachname</b></td></tr>
<?php
$thisFileContent = file(db_getconfval("sqddir")."/blacklist");
//echo db_getconfval("sqddir")."/blacklist";
$blindex = 0;
foreach ($thisFileContent as $zeile)
{
@$y = mysql_connect($MYSQL_HOST,$MYSQL_USER,$MYSQL_PASS);
@$x = mysql_select_db($MYSQL_DATABASE);
if (empty($x))
{
echo "ERROR 0x01, Failed to connect to database!<br>";
exit;
}
$hascontent = true;
if (strlen($zeile) >2)
{
$zeile=substr($zeile, 0, -1);
}
$sql3 = "SELECT * FROM userdata WHERE VPNId = '".$zeile."';";
$result3 = mysql_query($sql3);
$ar3=mysql_fetch_array($result3,MYSQL_ASSOC);
$nick = $ar3["Nickname"];
if($nick == "")
$hascontent=false;
$vor = $ar3["Vorname"];
if($vor == "")
$hascontent=false;
$nach = $ar3["Nachname"];
if($nach == "")
$hascontent=false;
if($hascontent == true)
{
$blindex = $blindex+1;
echo "<tr><td>".$zeile."</td><td>".$nick."</td><td>".$vor."</td><td>".$nach."</td></tr>";
}
mysql_close();
}
?>
</table>
<p> Blacklisted accounts:
<b>
<?php echo $blindex; ?></b> out of: <b>
<?php
if (count($openssl['Database']) == 0)
echo 'no certificates</b>';
elseif (count($openssl['Database'])-1 == 1)
{
echo '1</b> certificate';
}
elseif (count($openssl['Database'])-1 > 1)
{
echo '';
echo count($openssl['Database'])-1;
echo '</b> certificates';
}?>
</p>
<p>
<form action="/Admin/Modules/Squid/delbl.php" method="post" >
<input type="hidden" name="path" size="50" value="<?php echo $moduleurl;?>">
<input type="submit" value="Clear Blacklist">
</form>
</p>
<br>
<h2>User changed Proxy Accounts:</h2>
<form action="<?php echo $PHP_SELF; ?>" method="post">
<select name="dirsort" size=1>
<option <?php if($sort=="ASC") echo "selected";?> value="ASC">Up</option>
<option <?php if($sort=="DESC") echo "selected";?> value="DESC">Down</option>
</select>
<select name="sortby" size=1>
<option <?php if($by=="Id") echo "selected";?> value="Id">ID</option>
<option <?php if($by=="VPNId") echo "selected";?> value="VPNId">VPNId</option>
<option <?php if($by=="Time") echo "selected";?> value="Time">Time</option>
<option <?php if($by=="IP") echo "selected";?> value="IP">IP</option>
<option <?php if($by=="Nickname") echo "selected";?> value="Nickname">Nickname</option>
</select>
Search User:<input type="text" name="search" size="20" <?php if($search !="") echo "value=".$search;?> ></td>
<input type="submit" value="go!">
</form>
<!------ Sorting Leiste Start-->
<?php
@$y = mysql_connect($MYSQL_HOST,$MYSQL_USER,$MYSQL_PASS);
@$x = mysql_select_db($MYSQL_DATABASE);
if (empty($x))
{
echo "ERROR 0x01, Failed to connect to database!<br>";
exit;
}
// MYsql befehl basteln
if($by == "Nickname")
{
$sql = "SELECT * FROM proxyrepair;";
}
else
{
$sql = "SELECT * FROM proxyrepair ORDER BY $by $sort;";
}
$result = mysql_query($sql);
echo "<br><table border=1>";
echo "<tr><td><b>User ID</b></td><td><b>VPN Id</b></td><td><b>Nickname</b></td><td><b>Vorname</b></td><td><b>Nachname</b></td><td><b>Client IP</b></td><td><b>Time</b></td><td><b>Dead VPN ID</b></td></tr>\n";
// ------------------------------------------------ Mysql lesen
if ($result)
{
while ($ar=mysql_fetch_array($result,MYSQL_ASSOC))
{
$sql = "SELECT * FROM userdata WHERE Id = '".$ar["Id"]."' AND (Nickname LIKE '%".$search."%' OR Vorname LIKE '%".$search."%' OR Id LIKE '%".$search."%' OR VPNId LIKE '%".$search."%');";
$result2 = mysql_query($sql);
$ar2=mysql_fetch_array($result2,MYSQL_ASSOC);
if($ar2["Nickname"] != "")
echo "<tr><td>",$ar["Id"],"</td><td>",$ar["VPNId"],"</td><td>",$ar2["Nickname"],"</td><td>",$ar2["Vorname"],"</td><td>",$ar2["Nachname"],
"</td><td>", $ar["IP"],"</td><td>",$ar["Time"],"</td><td>",$ar["RepID"],"</td></tr>\n";
}
}
else
{
echo "<br>";
}
echo "</table>";
mysql_close();
?>

View File

@ -0,0 +1,30 @@
<?php
include ($_SERVER["DOCUMENT_ROOT"]."/Site/checkadmin.php");
//include($_SERVER["DOCUMENT_ROOT"]."/Site/mysql.php");
include($_SERVER["DOCUMENT_ROOT"]."/Config/_dbconfig_.php");
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/Squid/include/config.inc");
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/Squid/include/functions.inc");
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/Squid/include/openssl-functions.inc");
openssl_load_database ();
@$y = mysql_connect($MYSQL_HOST,$MYSQL_USER,$MYSQL_PASS);
@$x = mysql_select_db($MYSQL_DATABASE);
if (empty($x))
{
echo "ERROR 0x01, Failed to connect to database!<br>";
exit;
}
$sort = mysql_real_escape_string($_POST["dirsort"]); //$_GET["sort"];
$by = mysql_real_escape_string($_POST["sortby"]); //$_GET["by"];
$userid = mysql_real_escape_string($_POST["userid"]); //$_GET["userid"];
$search = mysql_real_escape_string($_POST["search"]); //$_GET["search"];
$moduleurl = $_SERVER["REQUEST_URI"];
$urlcut = strpos($moduleurl, "&");
$moduleurl = substr($moduleurl,0,$urlcut);
?>
<!-- MAIN CONTENT BEGINN ################################################################################ -->
<h1><b>Squid Logs</b></h1>
<?php
require "/usr/local/mysar/www/index.php"; ?>

View File

@ -0,0 +1,3 @@
export CPATH=..:$HOME/include:/usr/local/include:/usr/include:/usr/include/mysql
needed: libmysqlclient-dev
gcc -l mysqlclient -o traffic Traffic.c

View File

@ -0,0 +1,4 @@
user: openvpn
passwd: openvpnlog
database: openvpn
host: localhost

View File

@ -0,0 +1,7 @@
#!/bin/bash
let x=0x3f
echo $x
let x=0xfffe
echo $x

View File

@ -0,0 +1,134 @@
/* OpenVPN - Squid Load Balancer*
*------------------------------*
* Version 1.0 *
* Written by Christoph Haas *
* License: LGPL *
* 12.10.2010 *
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <mysql/mysql.h>
#include <regex.h>
#include <string.h>
#define __MAX_LINE__ 100
#define __MAX_FIELD__ 255
#define false 0
#define true 1
MYSQL mysql;
int connect_db(char *config)
{
FILE *db_data = NULL;
regex_t reg;
char user[__MAX_LINE__] = "";
char passwd[__MAX_LINE__] = "";
char database[__MAX_LINE__] = "";
char host[__MAX_LINE__] = "";
int port = 0;
char tmp[__MAX_LINE__];
char buf[__MAX_LINE__];
int a, b;
int length;
if((db_data = fopen(config, "r")) == NULL)
{
fprintf(stderr, "Can't open %s for reading.\n", config);
return false;
}
regcomp(&reg, "^([a-zA-Z0-9:]+)[ ][a-zA-Z0-9]+$", REG_EXTENDED | REG_NEWLINE);
while(fgets(buf, __MAX_LINE__, db_data))
{
length = strlen(buf);
if(length < 3)continue;
if(length >= __MAX_LINE__)
{
fclose(db_data);
regfree(&reg);
fprintf(stderr, "To long line in config file.\n");
return false;
}
if(buf[0] == '#')continue;
if(regexec(&reg, buf, 0, 0, 0))
{
fclose(db_data);
regfree(&reg);
fprintf(stderr, "Syntax error in config file.\n");
return false;
}
for(a = 0, b = 0; a < strlen(buf); a++)
{
if(buf[a] == ' ')b++;
}
if(b != 1)
{
fclose(db_data);
regfree(&reg);
fprintf(stderr, "Syntax error in config file.\n");
return false;
}
if((strncmp(buf, "user: ", 6)) == 0)sscanf(buf, "%s %s", tmp, user);
if((strncmp(buf, "passwd: ", 8)) == 0)sscanf(buf, "%s %s", tmp, passwd);
if((strncmp(buf, "database: ", 10)) == 0)sscanf(buf, "%s %s", tmp, database);
if((strncmp(buf, "host: ", 6)) == 0)sscanf(buf, "%s %s", tmp, host);
if((strncmp(buf, "port: ", 6)) == 0)sscanf(buf, "%s %d", tmp, &port);
}
fclose(db_data);
regfree(&reg);
if((strlen(user) < 1) || (strlen(passwd) < 1) ||
(strlen(database) < 1) || (strlen(host) < 1))
{
fprintf(stderr, "One value for MySQL connection isn't set. \
Please set user, passwd, database and host.\n");
return false;
}
mysql_init(&mysql);
if((mysql_real_connect(&mysql, host, user, passwd, database, port, NULL, 0)) == NULL)
{
fprintf(stderr, "%s\n", mysql_error(&mysql));
return false;
}
return true;
}
int main(int argc, char **argv)
{
MYSQL_RES *result;
MYSQL_ROW row;
char Query[200]= "SELECT * FROM userdata WHERE VPNId = '\0";
if(argc == 2)
{
/*iID = atoi(argv[1]);
printf("Int:%d\n", iID);
sprintf(ID,"%-#10x",iID);
printf("String:%s\n", ID);*/
connect_db("/home/christoph/squid_dynamic/db.conf"); // Datenbank Verbindung aufbauen
strcat(Query, argv[1]); // Query builden
strcat(Query,"'"); //
mysql_query(&mysql, Query); // Query abschicken
result = mysql_store_result(&mysql); // Result speichern
while ((row = mysql_fetch_row(result))) // Alle Datensätze auslesen (in dem Fall eh nur einer)
{
printf("%s:%s\n", row[9], row[10]); // Feld 9 und 10 (login/pass) aus dem datensatz ausgeben
}
mysql_free_result(result); // Result wieder löschen
mysql_close(&mysql); // Datenbank Verbindung schliesen
}
else
{
printf("USAGE: sqidy xx | xx = VPNId\n"); // bei flascheingabe der Parameter
}
}

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1 @@
00

View File

@ -0,0 +1,115 @@
#!/bin/bash
# Zaehlvariable einlesen
id=$ID_VPN
# Abfrage ob Stringlaenge von id NULL ist
if [ ${#ID_VPN} == 0 ];
then id=0
fi
# id inkrementieren
let id=$id+1
# 255 Overflow verhindern
if [ $id -gt 254 ]
then id=0
fi
# Variable id fuer naechsten Durchlauf speichern
export ID_VPN=$id
# id HEX wandeln
hex=$(echo "obase=16; $id" |bc)
# Abfrage ob Strinlaenge von hex kleiner als 2
if [ ${#hex} -lt 2 ];
then hex=0$hex
fi
# Login-Daten aus Datenbank holen
credentials=$(./squidy $hex)
# Abfrage ob Datensatz leer :
zero="0"
if [ "$credentials" == ":" ];
then
. write_conf &
zero="1"
fi
if [ ${#credentials} == 0 ];
then
. write_conf &
zero="1"
fi
######################################################################################
# Config- Datei schreiben.
if [ $zero == "0" ]
then
echo "
# Squid config by h44z
# TAG: http_port
# Usage: port
# hostname:port
# 1.2.3.4:port
http_port 10.8.0.1:3128 transparent
http_port 10.8.0.1:8080
#https_port 10.8.0.1:8181 key=/etc/apache2/ssl/apache.pem
visible_hostname vpnrack
# TAG: icp_port
icp_port 0
# TAG: no_cache
acl QUERY urlpath_regex cgi-bin \\?
no_cache deny QUERY
# TAG: cache_mem (bytes)
cache_mem 32 MB
# TAG: cache_dir
cache_dir ufs /var/cache/squid 100 16 256
# TAG: cache_access_log
cache_access_log /var/log/squid/access.log
# TAG: cache_log
cache_log /var/log/squid/cache.log
# TAG: cache_store_log
cache_store_log /var/log/squid/store.log
# TAG: emulate_httpd_log on|off
emulate_httpd_log on
# TAG: pid_filename
pid_filename /var/run/squid.pid
# TAG: cache_mgr
cache_mgr christoph.haas2@students.htlinn.ac.at
http_access allow all
acl https port 443
http_access allow https
# TAG: http_reply_access
# Allow replies to client requests. This is complementary to http_access.
#http_reply_access allow all
cache_peer 192.168.195.101 parent 8080 7 no-query default no-digest login=$credentials
never_direct allow all
" > /etc/squid3/squid.conf
######################################################################################
#restart squid
killall -9 squid
squid -D -YC -f /etc/squid3/squid.conf
fi

View File

@ -0,0 +1,132 @@
#!/bin/bash
# Script um die cache_peer funktion von Squid upzudaten.
# V1.0
# 13.10.2010
# Stoeckholzer, Haas
if [ ${#1} == 0 ];
then
echo "USAGE: write_conf_file updatetime"
exit 0
fi
while [ "1" == "1" ] ;
do
sleep $1
zero="1"
while [ $zero == "1" ] ;
do
# Zaehlvariable einlesen
id=$(cat /var/vpn/vpnid)
# id inkrementieren
let id=$id+1
# 255 Overflow verhindern
if [ $id -gt 254 ]
then
id=0
fi
# Variable id fuer naechsten Durchlauf speichern
echo $id > /var/vpn/vpnid
# id HEX wandeln
hex=$(echo "obase=16; $id" |bc)
# Abfrage ob Strinlaenge von hex kleiner als 2
if [ ${#hex} -lt 2 ];
then
hex=0$hex
fi
black=$(cat /var/vpn/blacklist | grep $hex)
if [ ${#black} -lt 2 ];
then
# Login-Daten aus Datenbank holen
credentials=$(/home/christoph/squid_dynamic/squidy $hex)
# Abfrage ob Datensatz leer :
if [ ${#credentials} -gt 10 ];
then
zero="0"
fi
fi
done
echo "USING credentials: $credentials"
sudo killall -9 unlinkd
sudo killall -9 squid
sudo rm /etc/squid3/squid.conf
######################################################################################
# Config- Datei schreiben.
sudo echo -e -n "
# Squid config by h44z
# TAG: http_port
# Usage: port
# hostname:port
# 1.2.3.4:port
http_port 10.8.0.1:3128 transparent
http_port 10.8.0.1:8080
#https_port 10.8.0.1:8181 key=/etc/apache2/ssl/apache.pem
visible_hostname vpnrack
# TAG: icp_port
icp_port 0
# TAG: no_cache
acl QUERY urlpath_regex cgi-bin \\?
no_cache deny QUERY
# TAG: cache_mem (bytes)
cache_mem 32 MB
# TAG: cache_dir
cache_dir ufs /var/cache/squid 100 16 256
# TAG: cache_access_log
cache_access_log /var/log/squid/access.log
# TAG: cache_log
cache_log /var/log/squid/cache.log
# TAG: cache_store_log
cache_store_log /var/log/squid/store.log
# TAG: emulate_httpd_log on|off
emulate_httpd_log on
# TAG: pid_filename
pid_filename /var/run/squid.pid
# TAG: cache_mgr
cache_mgr christoph.haas2@students.htlinn.ac.at
#blubber
http_access allow all
acl https port 443
http_access allow https
# TAG: http_reply_access
# Allow replies to client requests. This is complementary to http_access.
#http_reply_access allow all
cache_peer 192.168.195.101 parent 8080 7 no-query default no-digest login=$credentials
never_direct allow all
" > /etc/squid3/squid.conf
echo "Written credentials: $credentials"
######################################################################################
#restart squid
sudo squid -D -YC -f /etc/squid3/squid.conf
done

View File

@ -0,0 +1,130 @@
#!/bin/bash
# Script um die cache_peer funktion von Squid upzudaten.
# V1.0
# 13.10.2010
# Stoeckholzer, Haas
if [ ${#1} == 0 ];
then
echo "USAGE: write_conf_file updatetime"
exit 0
fi
while [ "1" == "1" ] ; do
sleep $1
zero="1"
while [ $zero == "1" ] ; do
# Zaehlvariable einlesen
id=$(cat /var/vpn/vpnid)
# id inkrementieren
let id=$id+1
# 255 Overflow verhindern
if [ $id -gt 254 ]
then id=0
fi
# Variable id fuer naechsten Durchlauf speichern
echo $id > /var/vpn/vpnid
# id HEX wandeln
hex=$(echo "obase=16; $id" |bc)
# Abfrage ob Strinlaenge von hex kleiner als 2
if [ ${#hex} -lt 2 ];
then hex=0$hex
fi
# Login-Daten aus Datenbank holen
credentials=$(/home/christoph/squid_dynamic/squidy $hex)
# Abfrage ob Datensatz leer :
if [ ${#credentials} -gt 10 ];
then
zero="0"
fi
echo "Schleife zero: $zero"
echo "Schleife id: $id"
echo "Schleife hex: $hex"
done
echo "USING zero: $zero"
echo "USING id: $id"
echo "USING hex: $hex"
echo "USING credentials: $credentials"
sudo killall -9 unlinkd
sudo killall -9 squid
sudo rm /etc/squid3/squid.conf
######################################################################################
# Config- Datei schreiben.
sudo echo -e -n "
# Squid config by h44z
# TAG: http_port
# Usage: port
# hostname:port
# 1.2.3.4:port
http_port 10.8.0.1:3128 transparent
http_port 10.8.0.1:8080
#https_port 10.8.0.1:8181 key=/etc/apache2/ssl/apache.pem
visible_hostname vpnrack
# TAG: icp_port
icp_port 0
# TAG: no_cache
acl QUERY urlpath_regex cgi-bin \\?
no_cache deny QUERY
# TAG: cache_mem (bytes)
cache_mem 32 MB
# TAG: cache_dir
cache_dir ufs /var/cache/squid 100 16 256
# TAG: cache_access_log
cache_access_log /var/log/squid/access.log
# TAG: cache_log
cache_log /var/log/squid/cache.log
# TAG: cache_store_log
cache_store_log /var/log/squid/store.log
# TAG: emulate_httpd_log on|off
emulate_httpd_log on
# TAG: pid_filename
pid_filename /var/run/squid.pid
# TAG: cache_mgr
cache_mgr christoph.haas2@students.htlinn.ac.at
#blubber
http_access allow all
acl https port 443
http_access allow https
# TAG: http_reply_access
# Allow replies to client requests. This is complementary to http_access.
#http_reply_access allow all
cache_peer 192.168.195.101 parent 8080 7 no-query default no-digest login=$credentials
never_direct allow all
" > /etc/squid3/squid.conf
echo "Written credentials: $credentials"
######################################################################################
#restart squid
sudo squid -D -YC -f /etc/squid3/squid.conf
done

View File

@ -0,0 +1,183 @@
#!/bin/bash
# Script um die cache_peer funktion von Squid manuell von der Website aus upzudaten.
# V1.0
# 13.10.2010
# Stoeckholzer, Haas
while [ "1" == "1" ];
do
write=1
zero=0
# ueberpruefen ob file vpnid_man vorhanden
if [ -e /var/vpn/vpnid_man ];
then
echo 1
zero=1
fi
# ueberpruefen ob file vpnid_next vorhanden
if [ -e /var/vpn/vpnid_next ];
then
echo 2
zero=2
fi
if [ "$zero" == "1" ];
then
# Manuelle ID als hex einlesen einlesen
hex=$(cat /var/vpn/vpnid_man)
id=$(printf "%d\n" 0x$hex)
echo $id > /var/vpn/vpnid
rm /var/vpn/vpnid_man
echo $hex
# Login-Daten aus Datenbank holen
credentials=$(/home/christoph/squid_dynamic/squidy $hex)
fi
if [ "$zero" == "2" ];
then
schleife="1"
rm /var/vpn/vpnid_next
while [ $schleife == "1" ] ;
do
# Zaehlvariable einlesen
id_alt=$(cat /var/vpn/vpnid)
# alte id HEX wandeln zum BLacklisten
hex_alt=$(echo "obase=16; $id_alt" |bc)
# Abfrage ob Strinlaenge von hex kleiner als 2
if [ ${#hex_alt} -lt 2 ];
then
hex_alt=0$hex_alt
fi
# alte id BLacklisten
if [ $write == 1 ];
then
echo $hex_alt >> /var/vpn/blacklist
fi
# id inkrementieren
let id=$id_alt+1
# 255 Overflow verhindern
if [ $id -gt 254 ]
then
id=0
fi
# Variable id fuer naechsten Durchlauf speichern
echo $id > /var/vpn/vpnid
# id HEX wandeln
hex=$(echo "obase=16; $id" |bc)
# Abfrage ob Strinlaenge von hex kleiner als 2
if [ ${#hex} -lt 2 ];
then
hex=0$hex
fi
# hole id_hex aus BLacklist?
black=$(cat /var/vpn/blacklist|grep $hex)
# Abfrage ob id_hex in BLacklist
if [ ${#black} -lt 2 ];
then
# Login-Daten aus Datenbank holen
credentials=$(/home/christoph/squid_dynamic/squidy $hex)
# Abfrage ob Datensatz leer :
if [ ${#credentials} -gt 10 ];
then
schleife="0"
fi
else write=0
fi
done
fi
# Abfrage ob Datensatz leer (zur Sicherheit):
if [ ${#credentials} -gt 10 ] && [ $zero != "0" ];
then
# stop squid
sudo killall -9 unlinkd
sudo killall -9 squid
sudo rm /etc/squid3/squid.conf
######################################################################################
# Config- Datei schreiben.
sudo echo -e -n "
# Squid config by h44z
# TAG: http_port
# Usage: port
# hostname:port
# 1.2.3.4:port
http_port 10.8.0.1:3128 transparent
http_port 10.8.0.1:8080
#https_port 10.8.0.1:8181 key=/etc/apache2/ssl/apache.pem
visible_hostname vpnrack
# TAG: icp_port
icp_port 0
# TAG: no_cache
acl QUERY urlpath_regex cgi-bin \\?
no_cache deny QUERY
# TAG: cache_mem (bytes)
cache_mem 32 MB
# TAG: cache_dir
cache_dir ufs /var/cache/squid 100 16 256
# TAG: cache_access_log
cache_access_log /var/log/squid/access.log
# TAG: cache_log
cache_log /var/log/squid/cache.log
# TAG: cache_store_log
cache_store_log /var/log/squid/store.log
# TAG: emulate_httpd_log on|off
emulate_httpd_log on
# TAG: pid_filename
pid_filename /var/run/squid.pid
# TAG: cache_mgr
cache_mgr christoph.haas2@students.htlinn.ac.at
http_access allow all
acl https port 443
http_access allow https
# TAG: http_reply_access
# Allow replies to client requests. This is complementary to http_access.
#http_reply_access allow all
cache_peer 192.168.195.101 parent 8080 7 no-query default no-digest login=$credentials
never_direct allow all
" > /etc/squid3/squid.conf
######################################################################################
echo "Written: $credentials"
#start squid
squid -D -YC -f /etc/squid3/squid.conf
fi
sleep 2
done

View File

@ -0,0 +1,158 @@
#!/bin/bash
# Script um die cache_peer funktion von Squid manuell von der Website aus upzudaten.
# V1.0
# 13.10.2010
# Stoeckholzer, Haas
while [ "1" == "1" ];
do
zero=0
# ueberpruefen ob file vpnid_man vorhanden
if [ -e /var/vpn/vpnid_man ];
then
echo 1
zero=1
fi
# ueberpruefen ob file vpnid_next vorhanden
if [ -e /var/vpn/vpnid_next ];
then
echo 2
zero=2
fi
if [ "$zero" == "1" ];
then
# Manuelle ID als hex einlesen einlesen
hex=$(cat /var/vpn/vpnid_man)
id=$(printf "%d\n" $hex)
echo $id > /var/vpn/vpnid
rm /var/vpn/vpnid_man
echo $hex
# Login-Daten aus Datenbank holen
credentials=$(/home/christoph/squid_dynamic/squidy $hex)
fi
if [ "$zero" == "2" ];
then
schleife="1"
rm /var/vpn/vpnid_next
while [ $schleife == "1" ] ;
do
# Zaehlvariable einlesen
id=$(cat /var/vpn/vpnid)
# id inkrementieren
let id=$id+1
# 255 Overflow verhindern
if [ $id -gt 254 ]
then
id=0
fi
# Variable id fuer naechsten Durchlauf speichern
echo $id > /var/vpn/vpnid
# id HEX wandeln
hex=$(echo "obase=16; $id" |bc)
# Abfrage ob Strinlaenge von hex kleiner als 2
if [ ${#hex} -lt 2 ];
then
hex=0$hex
fi
# Login-Daten aus Datenbank holen
credentials=$(/home/christoph/squid_dynamic/squidy $hex)
# Abfrage ob Datensatz leer :
if [ ${#credentials} -gt 10 ];
then
schleife="0"
fi
done
fi
# Abfrage ob Datensatz leer (zur Sicherheit):
if [ ${#credentials} -gt 10 ] && [ $zero != "0" ];
then
# stop squid
sudo killall -9 unlinkd
sudo killall -9 squid
sudo rm /etc/squid3/squid.conf
######################################################################################
# Config- Datei schreiben.
sudo echo -e -n "
# Squid config by h44z
# TAG: http_port
# Usage: port
# hostname:port
# 1.2.3.4:port
http_port 10.8.0.1:3128 transparent
http_port 10.8.0.1:8080
#https_port 10.8.0.1:8181 key=/etc/apache2/ssl/apache.pem
visible_hostname vpnrack
# TAG: icp_port
icp_port 0
# TAG: no_cache
acl QUERY urlpath_regex cgi-bin \\?
no_cache deny QUERY
# TAG: cache_mem (bytes)
cache_mem 32 MB
# TAG: cache_dir
cache_dir ufs /var/cache/squid 100 16 256
# TAG: cache_access_log
cache_access_log /var/log/squid/access.log
# TAG: cache_log
cache_log /var/log/squid/cache.log
# TAG: cache_store_log
cache_store_log /var/log/squid/store.log
# TAG: emulate_httpd_log on|off
emulate_httpd_log on
# TAG: pid_filename
pid_filename /var/run/squid.pid
# TAG: cache_mgr
cache_mgr christoph.haas2@students.htlinn.ac.at
http_access allow all
acl https port 443
http_access allow https
# TAG: http_reply_access
# Allow replies to client requests. This is complementary to http_access.
#http_reply_access allow all
cache_peer 192.168.195.101 parent 8080 7 no-query default no-digest login=$credentials
never_direct allow all
" > /etc/squid3/squid.conf
######################################################################################
echo "Written: $credentials"
#start squid
squid -D -YC -f /etc/squid3/squid.conf
fi
sleep 2
done

5
Admin/Modules/Squid/startsquid Executable file
View File

@ -0,0 +1,5 @@
/home/christoph/stopsquid
#iptables -t nat -A PREROUTING -i tap0 -p tcp --dport 80 -j REDIRECT --to-ports 3128
#iptables -t nat -A PREROUTING -i tap0 -p tcp --dport 443 -j REDIRECT --to-ports 3128
squid -D -YC -f /etc/squid3/squid.conf

6
Admin/Modules/Squid/stopsquid Executable file
View File

@ -0,0 +1,6 @@
#iptables -t nat -D PREROUTING -i tap0 -p tcp --dport 80 -j REDIRECT --to-ports 3128
#iptables -t nat -D PREROUTING -i tap0 -p tcp --dport 443 -j REDIRECT --to-ports 3128
killall squid
killall squid
killall squid

View File

@ -0,0 +1,14 @@
<?php
session_start();
include ($_SERVER["DOCUMENT_ROOT"]."/Site/checkadmin.php");
include ($_SERVER["DOCUMENT_ROOT"]."/Config/_siteconfig_.php");
$id = $_REQUEST["id"];
$path = $_REQUEST["path"];
// Write to file vpnid_man
$myFile = db_getconfval("sqddir")."/vpnid_man";
$fh = fopen($myFile, 'w') or die("can't open file");
fwrite($fh, $id);
fclose($fh);
header ("Location: ".$path."&uebergabe=1");
?>

View File

@ -0,0 +1,9 @@
<?php
session_start();
$path = $_REQUEST["path"];
include ($_SERVER["DOCUMENT_ROOT"]."/Site/checkadmin.php");
include ($_SERVER["DOCUMENT_ROOT"]."/Site/mysql.php");
$ret = passthru("echo > ".db_getconfval("sqddir")."/blacklist");
echo $ret;
header ("Location: ".$path."&uebergabe=2");
?>

View File

@ -0,0 +1,66 @@
<?php
//include($_SERVER["DOCUMENT_ROOT"]."/Site/mysql.php");
// Change: your company name
$config['Company_Name'] = 'SchulVPN';
// Change: your company home page
$config['URL_Home_Page'] = 'http://10.10.63.60/index.php';
$config['AUTH_REALM'] = $config['Company_Name'] .' OpenVPN Web GUI v.0.3.2';
// What files to include into ZIP
$config['Download']['ZIP']['.pem'] = true;
$config['Download']['ZIP']['.key'] = true;
$config['Download']['ZIP']['.csr'] = false;
// All the following files should be placed into downloads folder
$config['Download']['ZIP']['Others'] = array ('readme.txt','ca.crt', 'schulvpn.ovpn', 'certinstall.sh');
//$config['Download']['ZIP']['Others'] = array ('readme.txt', 'install.cmd', 'tls-auth.key');
// Use the real absolute path here.
$config['PluginsAbsolutePath'] = $_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNConfig/plugins/";
// If there are no plugins
//$config['Plugins'] = NULL;
// Otherwise, follow this example:
//$config['Plugins']['PLUGINMANE']['Folder'] = 'FOLDERNAME';
// The post-install helper plugin. Shows if PHP5 has the neccessary functions available
$config['Plugins']['systemcheck']['Folder'] = 'systemcheck';
// OPENVPN ________________________________
// Change: the configuration directory
$config['openvpn']['folder'] = db_getconfval("ovpnconfdir")."/";
// Change: configuration and status file names
$config['openvpn']['config'] = $config['openvpn']['folder'].db_getconfval("ovpnconffile");
$config['openvpn']['status'] = $config['openvpn']['folder']."openvpn-status.log";
// OPENSSL ________________________________
// Change: openssl keys directory
$config['openssl']['folder'] = db_getconfval("ovpnkeydir")."/keys/";
// Change: different folders for Public Certificates, Certificate Requests and Private Keys.
// NOTE: openssl somehow respects only newpem folder (for Public Certificates).
$config['openssl']['pubfolder'] = $config['openssl']['folder'];
$config['openssl']['reqfolder'] = $config['openssl']['folder'];
$config['openssl']['prvfolder'] = $config['openssl']['folder'];
// Change: openssl CA private and public keys
$config['openssl']['CA']['priv'] = $config['openssl']['folder'] .'ca.key';
$config['openssl']['CA']['pub'] = $config['openssl']['folder'] .'ca.crt';
// Change: openssl serial file
$config['openssl']['serial'] = $config['openssl']['folder'] .'serial';
// Change: openssl database
$config['openssl']['database'] = $config['openssl']['folder'] .'index.txt';
// Change: openssl configuration
$config['openssl']['config'] = $config['openvpn']['folder'] .'openssl.cnf';
// NEW OPENSSL CERTIFICATE DEFAULTS _________
// Change all of them as it is done in your easy-rsa/vars
$config['openssl']['default']['expiration'] = 3560;
$config['openssl']['default']['countryName'] = 'AT';
$config['openssl']['default']['stateOrProvinceName'] = 'Tirol';
$config['openssl']['default']['localityName'] = 'Innsbruck';
$config['openssl']['default']['organizationName'] = 'HTL';
$config['openssl']['default']['organizationalUnitName'] = '';
$config['openssl']['default']['commonName'] = '';
$config['openssl']['default']['emailAddress'] = 'vpn@students.htlinn.ac.at';
?>

View File

@ -0,0 +1,251 @@
<?php
// ----------------------------------------------
function load_plugins ()
{
global $config;
if (isset ($config['Plugins']))
{
foreach ($config['Plugins'] as $PluginName => $PluginData)
{
// Check if the config.inc for a plugin exists
if (file_exists ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/plugins/". $PluginData['Folder'] ."/config.inc"))
{
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/plugins/". $PluginData['Folder'] ."/config.inc");
// Check if claimed inc files do exist
if (isset ($config['Plugins'][$PluginName]['Action']['Include']) &&
!file_exists ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/plugins/". $PluginData['Folder'] ."/".
$config['Plugins'][$PluginName]['Action']['Include']))
$config['Plugins'][$PluginName]['Action']['Include'] = NULL;
if (isset ($config['Plugins'][$PluginName]['Left']['Menu']) &&
!file_exists ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/plugins/". $PluginData['Folder'] ."/".
$config['Plugins'][$PluginName]['Left']['Menu']))
$config['Plugins'][$PluginName]['Left']['Menu'] = NULL;
if (isset ($config['Plugins'][$PluginName]['Left']['Status']) &&
!file_exists ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/plugins/". $PluginData['Folder'] ."/".
$config['Plugins'][$PluginName]['Left']['Status']))
$config['Plugins'][$PluginName]['Left']['Status'] = NULL;
}
}
}
}
// ----------------------------------------------
function seconds_string ($seconds, $periods = null)
{
$Wanted = '';
// Define time periods
if (!is_array ($periods))
{
$periods = array (
'years' => 31556926,
'months' => 2629743,
'weeks' => 604800,
'days' => 86400,
'hours' => 3600,
'minutes' => 60,
'seconds' => 1
);
}
// Wanted
if (empty ($seconds))
{ $Wanted = ''; }
else
{
// Loop
$seconds = (int) $seconds;
foreach ($periods as $period => $value)
{
$count = floor ($seconds / $value);
if ($count == 0)
continue;
elseif ($count == 1)
$Wanted .= ($count . ' ' . substr ($period, 0, strlen ($period) - 1) . ' ');
else
$Wanted .= ($count . ' ' . $period . ' ');
$seconds = $seconds % $value;
}
}
return rtrim ($Wanted);
}
// ----------------------------------------------
function chomp (&$string)
{
if (is_array ($string))
{
foreach ($string as $i => $val)
{ $endchar = chomp ($string[$i]); }
}
else
{
$endchar = substr ("$string", strlen("$string") - 1, 1);
if ($endchar == "\n")
{ $string = substr ("$string", 0, -1); }
}
return $endchar;
}
// ----------------------------------------------
function str_strip_spaces ($aline)
{
while (strpos ($aline, "\t") != FALSE) $aline = str_replace ("\t", ' ', $aline);
while (strpos ($aline, ' ') != FALSE) $aline = str_replace (' ', ' ', $aline);
return $aline;
}
// ----------------------------------------------
// Returns $afile only if it is the full name, or prefixed by $apath
function str_file_fullname ($apath, $afile)
{
if (substr ($afile, 0, 1) != '/')
$afile = ($apath . $afile);
return $afile;
}
// ----------------------------------------------
// Returns $afile only if it is the full name, or prefixed by $apath
function str_openssldata_to_string ($adata)
{
$Return = '';
$amonth = array ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
if (substr ($adata, -1, 1) == 'Z')
{
$Return = sprintf ("%s %d %s%02d, %02d:%02d:%02d",
$amonth [substr ($adata, 2, 2) - 1],
substr ($adata, 4, 2),
(substr ($adata, 0, 2) > 50 ? '19' : '20'),
substr ($adata, 0, 2),
substr ($adata, 6, 2),
substr ($adata, 8, 2),
substr ($adata, 10, 2));
}
return $Return;
}
// ----------------------------------------------
function str_get_sometag ($aline, $sometag)
{
if (eregi ($sometag, $aline, $anarray))
return $anarray[1];
else
return '';
}
// ----------------------------------------------
// Writes content into file
// Optionally sames old file into backup file.
// The Backup File has to reside on the same partition!
function writefile ($afile, $adata, $abackup = NULL)
{
// Move the old file into Backup one
if ($abackup != NULL)
{
if (file_exists ($afile))
{
if (file_exists ($abackup))
if (!unlink ($abackup))
exit;
if (!rename ($afile, $abackup))
exit;
}
}
$fp = fopen ($afile, "w", 0);
if (!$fp)
exit;
fputs ($fp, $adata);
fclose ($fp);
}
// ----------------------------------------------
// Guess the full file name
function if_file_exists (&$sFileName, $bFix = FALSE)
{
global $config;
if (strpos ($sFileName, '/') == FALSE)
{
$sLongFileName = $config['openvpn']['folder'] . $sFileName;
if (file_exists ($sLongFileName) && $bFix)
$sFileName = $sLongFileName;
}
return file_exists ($sFileName);
}
// ----------------------------------------------
function zlib_check_functions ()
{
$Result = '';
$ZLibs = array
(
'gzcompress'
);
foreach ($ZLibs as $Function)
{
$Result .= $Function . '<font color="black">:</font> ' . (function_exists ($Function) ?
'<font color="black">OK</font>' :
'<font color="red">DOES NOT EXIST</font>') . '<br>';
}
return $Result;
}
// ----------------------------------------------
function html_dump ($aname, $athing)
{
echo '<pre><b><font color="darkgreen">'. $aname .'</font></b>: ';
print_r ($athing);
echo "</pre><br>\n";
}
// ----------------------------------------------
function html_error ($amessage, $ifexit = true)
{
global $config;
echo $amessage;
if ($ifexit)
exit;
}
// ----------------------------------------------
function html_postredir ($url)
{
header ('HTTP/1.1 303 REDIRECT');
header ('Location: '. $url);
#header ('Status: 303'); // if 1st header generates 500, then commend it out and use this one as 2nd
}
// ----------------------------------------------
// ----------------------------------------------
function html_download ($sFile, $sName)
{
header ('Content-type: application/octet-stream');
header ('Content-Disposition: attachment; filename="'. $sName . '"');
readfile ($sFile);
}
// ----------------------------------------------
function html_download_data ($sData, $sName)
{
header ('Content-type: application/octet-stream');
header ('Content-Disposition: attachment; filename="'. $sName . '"');
echo $sData;
}
?>

View File

@ -0,0 +1,377 @@
<?php
// ----------------------------------------------
function openssl_check_functions ()
{
$Result = '';
$OpenSSLs = array
(
'openssl_csr_new',
'openssl_csr_sign',
'openssl_csr_export_to_file',
'openssl_pkey_new',
'openssl_pkey_get_private',
'openssl_pkey_export_to_file',
'openssl_x509_export_to_file'
);
foreach ($OpenSSLs as $Function)
{
$Result .= $Function . '<font color="black">:</font> ' . (function_exists ($Function) ?
'<font color="black">OK</font>' :
'<font color="red">DOES NOT EXIST</font>') . '<br>';
}
return $Result;
}
// ----------------------------------------------
function openssl_load_database ($afile = '')
{
global $config;
global $openssl;
$afile = ($afile == '' ? $config['openssl']['database'] : $afile);
$lines = file ($afile);
if (!is_array ($lines))
exit;
foreach ($lines as $line_num => $line)
{
chomp ($line);
$linetokens = explode ("\t", $line);
// Ensure that all the fields are set
if (count ($linetokens) == 6)
{
// Decode the openssl's database. See apps/apps.h
$openssl['Database'][] = array ('Status' => $linetokens[0],
'ExpDate' => $linetokens[1],
'RevDate' => $linetokens[2],
'Serial' => $linetokens[3],
'File' => $linetokens[4],
'Name' => $linetokens[5],
'Country' => openssl_get_country ($linetokens[5]),
'State' => openssl_get_state ($linetokens[5]),
'City' => openssl_get_city ($linetokens[5]),
'Company' => openssl_get_company ($linetokens[5]),
'Department' => openssl_get_department ($linetokens[5]),
'CN' => openssl_get_CN ($linetokens[5]),
'Email' => openssl_get_email ($linetokens[5])
);
}
}
}
// ----------------------------------------------
function openssl_write_database ($afile = '')
{
global $config;
global $openssl;
$afile = ($afile == '' ? $config['openssl']['database'] : $afile);
$atext = '';
for ($i = 0; $i < count ($openssl['Database']); $i++)
{
$atext .= ($atext == '' ? '' : "\n");
$atext .= $openssl['Database'][$i]['Status'] ."\t".
$openssl['Database'][$i]['ExpDate'] ."\t".
$openssl['Database'][$i]['RevDate'] ."\t".
$openssl['Database'][$i]['Serial'] ."\t".
$openssl['Database'][$i]['File'] ."\t".
$openssl['Database'][$i]['Name'];
}
writefile ($afile, $atext, $afile .'.old');
}
// ----------------------------------------------
function openssl_write_database_attr ($atext = '', $afile = '')
{
global $config;
global $openssl;
$afile = ($afile == '' ? $config['openssl']['database'] : $afile) .'.attr';
$atext = ($atext == '' ? "unique_subject = yes\n" : $atext);
if (file_exists ($afile))
{
ob_start ();
readfile ($afile);
$atext = ob_get_contents ();
ob_end_clean ();
}
writefile ($afile, $atext, $afile .'.old');
}
// ----------------------------------------------
// Returns the PEM file with spaces reduced and replaced to &nbsp;
function openssl_load_cert ($anid)
{
global $config;
do
{
$lines = file ($config['openssl']['pubfolder'] . $anid . '.pem');
if (!is_array ($lines))
{
$Return = '';
break;
}
foreach ($lines as $line_num => $line)
{
chomp ($line);
$Return[] = str_replace (' ', '&nbsp;', htmlspecialchars (str_replace (' ', ' ', $line)));
}
} while (FALSE);
return $Return;
}
// ----------------------------------------------
function openssl_load_serial ($afile = '')
{
global $config;
$afile = ($afile == '' ? $config['openssl']['serial'] : $afile);
$lines = file ($afile);
if (!is_array ($lines))
exit;
$Return = sscanf ($lines[0], "%X");
return $Return[0];
}
// ----------------------------------------------
function openssl_write_serial ($iNumber, $afile = '')
{
global $config;
$afile = ($afile == '' ? $config['openssl']['serial'] : $afile);
writefile ($afile, openssl_hex_serial ($iNumber) . "\n", $afile .'.old');
}
// ----------------------------------------------
// Supports up to 999,999 serials
function openssl_hex_serial ($iNumber)
{
if ($iNumber < 100)
$sString = sprintf ("%02X", $iNumber);
elseif ($iNumber < 10000)
$sString = sprintf ("%04X", $iNumber);
else
$sString = sprintf ("%06X", $iNumber);
return $sString;
}
// ----------------------------------------------
// Builds User Private Key, CSR and Public Certificate
function openssl_build_key (&$anoutput, $adn, $validdays = NULL)
{
global $config;
global $openssl;
$anoutput = '';
$Return = FALSE;
// Allow to override default value
$validdays = ($validdays == NULL ? $config['openssl']['default']['expiration'] : $validdays);
do
{
if (!isset ($adn) ||
!isset ($adn['countryName']) ||
!isset ($adn['stateOrProvinceName']) ||
!isset ($adn['localityName']) ||
!isset ($adn['organizationName']) ||
!isset ($adn['organizationalUnitName']) ||
!isset ($adn['commonName']) ||
!isset ($adn['emailAddress'])
)
{ $anoutput .= "- ERROR on ". __LINE__ ." line: incomplete DN information\n"; break; }
$anoutput .= "+ OK got the valid input\n";
// Get the new User Private Key
$UserPrivKey = openssl_pkey_new (array($config['openssl']['config'],0));
if ($UserPrivKey == FALSE)
{ $anoutput .= "- ERROR on ". (__LINE__ - 2) ." line (openssl_pkey_new):\n ". openssl_error_strings () ." (that might usually mean that the openssl.cnf file is unavailable)"; break; }
$anoutput .= "+ OK got the User Private Key\n";
// Generate the User Certificate Request
$UserReq = openssl_csr_new ($adn,
$UserPrivKey,
$config['openssl']['config']);
if ($UserReq == FALSE)
{ $anoutput .= "- ERROR on ". (__LINE__ - 4) ." line (openssl_csr_new):\n ". openssl_error_strings (); break; }
$anoutput .= "+ OK generated the User Certificate Request\n";
// Read the openssl serial
$CAserial = openssl_load_serial ($config['openssl']['serial']);
$anoutput .= "+ OK read current openssl serial (". openssl_hex_serial ($CAserial) .")\n";
$UserPubCertFile = $config['openssl']['pubfolder'] . openssl_hex_serial ($CAserial) .'.pem';
$UserCertReqFile = $config['openssl']['reqfolder'] . openssl_hex_serial ($CAserial) .'.csr';
$UserPrivKeyFile = $config['openssl']['prvfolder'] . openssl_hex_serial ($CAserial) .'.key';
// Read the openssl database
openssl_load_database ($config['openssl']['database']);
$anoutput .= "+ OK read the openssl database (". count ($openssl['Database']) ." items)\n";
// Get CA's Private Key
$CAPrivKey = openssl_pkey_get_private ($config['openssl']['CA']['priv']);
if ($CAPrivKey == FALSE)
{ $anoutput .= "- ERROR on ". (__LINE__ - 2) ." line (openssl_pkey_get_private)\n ". openssl_error_strings (); break; }
$anoutput .= "+ OK read the CA Private Key\n";
// Get a CA-signed cert that lasts for 1 year
$UserPubCert = openssl_csr_sign ($UserReq,
$config['openssl']['CA']['pub'],
$CAPrivKey,
$validdays,
$config['openssl']['config'],
$CAserial);
if ($UserPubCert == FALSE)
{ $anoutput .= "- ERROR on ". (__LINE__ - 7) ." line (openssl_csr_sign)\n ". openssl_error_strings (); break; }
$anoutput .= "+ OK signed the User Certificate Request with CA Private Key\n";
// Add the new row into openssl database
$openssl['Database'][] = array ('Status' => 'V',
'ExpDate' => date ('ymdHis',
time() +
date ('Z') +
($validdays * 24 * 60 * 60)) .'Z',
'RevDate' => '',
'Serial' => openssl_hex_serial ($CAserial),
'File' => openssl_hex_serial ($CAserial) .'.crt',
'Name' => openssl_make_name ($adn)
);
// Create files
$OldUMask = umask (0007);
// Write User Private Key
if (!openssl_pkey_export_to_file ($UserPrivKey, $UserPrivKeyFile, NULL, $config['openssl']['config']))
{ $anoutput .= "- ERROR on ". (__LINE__ - 1) ." line (openssl_pkey_export_to_file)\n ". openssl_error_strings () ." (That might mean that the key folder is not write enabled for www user)"; break; }
$anoutput .= "+ OK wrote User Private Key into file $UserPrivKeyFile\n";
// Write User Public Certificate
if (!openssl_x509_export_to_file ($UserPubCert, $UserPubCertFile, FALSE))
{ $anoutput .= "- ERROR on ". (__LINE__ - 1) ." line (openssl_x509_export_to_file)\n ". openssl_error_strings (); break; }
$anoutput .= "+ OK wrote User Public Certificate into file $UserPubCertFile\n";
// Write User Certificate Request
if (!openssl_csr_export_to_file ($UserReq, $UserCertReqFile))
{ $anoutput .= "- ERROR on ". (__LINE__ - 1) ." line (openssl_csr_export_to_file)\n ". openssl_error_strings (); break; }
$anoutput .= "+ OK wrote User Certificate Request into file $UserCertReqFile\n";
// Write new openssl database
openssl_write_database ($config['openssl']['database']);
openssl_write_database_attr ('', $config['openssl']['database']);
$anoutput .= "+ OK wrote new openssl database\n";
// Write new openssl serial
openssl_write_serial ($CAserial + 1, $config['openssl']['serial']);
$anoutput .= "+ OK wrote new openssl serial\n";
umask ($OldUMask);
$Return = openssl_hex_serial ($CAserial);
} while (FALSE);
return $Return;
}
// ----------------------------------------------
function openssl_error_strings ()
{
$sString = '';
while ($msg = openssl_error_string ())
$sString .= $msg ."\n";
return $sString;
}
// ----------------------------------------------
function openssl_make_name ($adn)
{
$sString = '';
if (strlen ($adn['countryName']) > 0) $sString .= '/C=' . $adn['countryName'];
if (strlen ($adn['stateOrProvinceName']) > 0) $sString .= '/ST=' . $adn['stateOrProvinceName'];
if (strlen ($adn['localityName']) > 0) $sString .= '/L=' . $adn['localityName'];
if (strlen ($adn['organizationName']) > 0) $sString .= '/O=' . $adn['organizationName'];
if (strlen ($adn['organizationalUnitName']) > 0) $sString .= '/OU=' . $adn['organizationalUnitName'];
if (strlen ($adn['commonName']) > 0) $sString .= '/CN=' . $adn['commonName'];
if (strlen ($adn['emailAddress']) > 0) $sString .= '/emailAddress='. $adn['emailAddress'];
return $sString;
}
// ----------------------------------------------
function openssl_get_country ($aline)
{ return str_get_sometag ($aline . '/', '\/C=([^/]*)\/'); }
// ----------------------------------------------
function openssl_get_state ($aline)
{ return str_get_sometag ($aline . '/', '\/ST=([^/]*)\/'); }
// ----------------------------------------------
function openssl_get_city ($aline)
{ return str_get_sometag ($aline . '/', '\/L=([^/]*)\/'); }
// ----------------------------------------------
function openssl_get_company ($aline)
{ return str_get_sometag ($aline . '/', '\/O=([^/]*)\/'); }
// ----------------------------------------------
function openssl_get_department ($aline)
{ return str_get_sometag ($aline . '/', '\/OU=([^/]*)\/'); }
// ----------------------------------------------
function openssl_get_CN ($aline)
{ return str_get_sometag ($aline . '/', '\/CN=([^/]*)\/'); }
// ----------------------------------------------
function openssl_get_email ($aline)
{ return str_get_sometag ($aline . '/', '\/emailAddress=([^/]*)\/'); }
// ----------------------------------------------
// Guess the full file name
function openssl_get_filename ($iSerial, $sExt)
{
global $config;
$sReturn = $config['openssl']['folder'] . openssl_hex_serial ($iSerial) . $sExt;
if (!file_exists ($sReturn))
{
$sReturn = $config['openssl']['pubfolder'] . openssl_hex_serial ($iSerial) . $sExt;
if (!file_exists ($sReturn))
{
$sReturn = $config['openssl']['reqfolder'] . openssl_hex_serial ($iSerial) . $sExt;
if (!file_exists ($sReturn))
{
$sReturn = $config['openssl']['prvfolder'] . openssl_hex_serial ($iSerial) . $sExt;
if (!file_exists ($sReturn))
{
$sReturn = '';
}
}
}
}
return $sReturn;
}
?>

View File

@ -0,0 +1,11 @@
<?php
session_start();
include ($_SERVER["DOCUMENT_ROOT"]."/Site/checkadmin.php");
include ($_SERVER["DOCUMENT_ROOT"]."/Config/_siteconfig_.php");
$path = $_REQUEST["path"];
// Write to file vpnid_man
exec("touch /var/vpn/squid_restart");
header ("Location: ".$path."&uebergabe=3");
?>

View File

@ -0,0 +1,11 @@
<?php
session_start();
include ($_SERVER["DOCUMENT_ROOT"]."/Site/checkadmin.php");
include ($_SERVER["DOCUMENT_ROOT"]."/Config/_siteconfig_.php");
$path = $_REQUEST["path"];
// Write to file vpnid_man
exec("touch /var/vpn/squid_start");
header ("Location: ".$path."&uebergabe=4");
?>

View File

@ -0,0 +1,11 @@
<?php
session_start();
include ($_SERVER["DOCUMENT_ROOT"]."/Site/checkadmin.php");
include ($_SERVER["DOCUMENT_ROOT"]."/Config/_siteconfig_.php");
$path = $_REQUEST["path"];
// Write to file vpnid_man
exec("touch /var/vpn/squid_stop");
header ("Location: ".$path."&uebergabe=5");
?>

297
Admin/Modules/Squid_old/index.php Executable file
View File

@ -0,0 +1,297 @@
<?php
include ($_SERVER["DOCUMENT_ROOT"]."/Site/checkadmin.php");
//include($_SERVER["DOCUMENT_ROOT"]."/Site/mysql.php");
include($_SERVER["DOCUMENT_ROOT"]."/Config/_dbconfig_.php");
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/Squid/include/config.inc");
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/Squid/include/functions.inc");
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/Squid/include/openssl-functions.inc");
openssl_load_database ();
@$y = mysql_connect($MYSQL_HOST,$MYSQL_USER,$MYSQL_PASS);
@$x = mysql_select_db($MYSQL_DATABASE);
if (empty($x))
{
echo "ERROR 0x01, Failed to connect to database!<br>";
exit;
}
$sort = mysql_real_escape_string($_POST["dirsort"]); //$_GET["sort"];
$by = mysql_real_escape_string($_POST["sortby"]); //$_GET["by"];
$userid = mysql_real_escape_string($_POST["userid"]); //$_GET["userid"];
$search = mysql_real_escape_string($_POST["search"]); //$_GET["search"];
$moduleurl = $_SERVER["REQUEST_URI"];
$urlcut = strpos($moduleurl, "&");
$moduleurl = substr($moduleurl,0,$urlcut);
?>
<!-- MAIN CONTENT BEGINN ################################################################################ -->
<h1><b>Squid Config</b></h1>
<?php
if(is_file("/var/run/squid.pid"))
{
echo "<b>Squid is currently: <font color=green>running</font></b><br />";
}
else
{
echo "<b>Squid is currently: <font color=red>stopped</font></b><br />";
}
if ($_REQUEST["uebergabe"]=="3")
{
echo "<b>Squid restarted successfully!</b>";
echo "<meta http-equiv=\"Refresh\" content=\"1; url=".$moduleurl."&uebergabe=0\">";
}
if ($_REQUEST["uebergabe"]=="4")
{
echo "<b>Squid started successfully!</b>";
echo "<meta http-equiv=\"Refresh\" content=\"1; url=".$moduleurl."&uebergabe=0\">";
}
if ($_REQUEST["uebergabe"]=="5")
{
echo "<b>Squid stopped successfully!</b>";
echo "<meta http-equiv=\"Refresh\" content=\"3; url=".$moduleurl."&uebergabe=0\">";
}
?>
<table>
<tr>
<td>
<form action="/Admin/Modules/Squid/include/restartsquid.php" method="post" >
<input type="hidden" name="path" size="50" value="<?php echo $moduleurl;?>" />
<input type="submit" value="Restart Squid" />
</form>
</td>
<?php
if(!is_file("/var/run/squid.pid"))
{
echo "
<td>
<form action=\"/Admin/Modules/Squid/include/startsquid.php\" method=\"post\" >
<input type=\"hidden\" name=\"path\" size=\"50\" value=\"".$moduleurl."\" />
<input type=\"submit\" value=\"Start Squid\" />
</form>
</td>";
}
?>
<?php
if(is_file("/var/run/squid.pid"))
{
echo "
<td>
<form action=\"/Admin/Modules/Squid/include/stopsquid.php\" method=\"post\" >
<input type=\"hidden\" name=\"path\" size=\"50\" value=\"".$moduleurl."\" />
<input type=\"submit\" value=\"Stop Squid\" />
</form>
</td>";
}
?>
</tr>
</table>
<br />
<h2>Change Proxy Account:</h2>
<?php
if ($_REQUEST["uebergabe"]=="1")
{
echo "<b>Changed Squid Account successfully!</b>";
}
?>
<br>
<p>
<form action="/Admin/Modules/Squid/changesquid.php" method="post" >
Squid ID (HEX):
<input type="text" name="id" size="3">
<input type="hidden" name="path" size="50" value="<?php echo $moduleurl;?>">
<input type="submit" value="Change Squid User">
</form>
</p>
<p>
Current Squid User:
<?php
function dec_to_hex($dec)
{
$sign = ""; // suppress errors
if( $dec < 0){ $sign = "-"; $dec = abs($dec); }
$hex = Array( 0 => 0, 1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5,
6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 'A',
11 => 'B', 12 => 'C', 13 => 'D', 14 => 'E',
15 => 'F' );
do
{
$h = $hex[($dec%16)] . $h;
$dec /= 16;
}
while( $dec >= 1 );
return $sign . $h;
}
$zeile = exec(escapeshellcmd("cat ".db_getconfval("sqddir")."/vpnid"));
$zeile = dec_to_hex($zeile);
//echo $zeile;
if(strlen ($zeile) <2)
{
$zeile = "0".$zeile;
}
if(strlen ($zeile) >2)
{
$zeile=substr($zeile, 0, -1);
}
@$y = mysql_connect($MYSQL_HOST,$MYSQL_USER,$MYSQL_PASS);
@$x = mysql_select_db($MYSQL_DATABASE);
if (empty($x))
{
echo "ERROR 0x01, Failed to connect to database!<br>";
exit;
}
$sql4 = "SELECT * FROM userdata WHERE VPNId = '".$zeile."';";
$result4 = mysql_query($sql4);
//echo $sql4;
$ar4=mysql_fetch_array($result4,MYSQL_ASSOC);
echo "<b>" . $ar4["Vorname"] . " " . $ar4["Nachname"] . "</b> VPNId: <b>" . $ar4["VPNId"]."</b>";
mysql_close();
?>
</p>
<br>
<h2>Blacklisted Accounts:</h2>
<?php
if ($_REQUEST["uebergabe"]=="2")
{
echo "<b>Blacklist cleared successfully!</b>";
}
?>
<table border=1>
<tr><td><b>Squid ID</b></td><td><b>Nickname</b></td><td><b>Vorname</b></td><td><b>Nachname</b></td></tr>
<?php
$thisFileContent = file(db_getconfval("sqddir")."/blacklist");
//echo db_getconfval("sqddir")."/blacklist";
$blindex = 0;
foreach ($thisFileContent as $zeile)
{
@$y = mysql_connect($MYSQL_HOST,$MYSQL_USER,$MYSQL_PASS);
@$x = mysql_select_db($MYSQL_DATABASE);
if (empty($x))
{
echo "ERROR 0x01, Failed to connect to database!<br>";
exit;
}
$hascontent = true;
if (strlen($zeile) >2)
{
$zeile=substr($zeile, 0, -1);
}
$sql3 = "SELECT * FROM userdata WHERE VPNId = '".$zeile."';";
$result3 = mysql_query($sql3);
$ar3=mysql_fetch_array($result3,MYSQL_ASSOC);
$nick = $ar3["Nickname"];
if($nick == "")
$hascontent=false;
$vor = $ar3["Vorname"];
if($vor == "")
$hascontent=false;
$nach = $ar3["Nachname"];
if($nach == "")
$hascontent=false;
if($hascontent == true)
{
$blindex = $blindex+1;
echo "<tr><td>".$zeile."</td><td>".$nick."</td><td>".$vor."</td><td>".$nach."</td></tr>";
}
mysql_close();
}
?>
</table>
<p> Blacklisted accounts:
<b>
<?php echo $blindex; ?></b> out of: <b>
<?php
if (count($openssl['Database']) == 0)
echo 'no certificates</b>';
elseif (count($openssl['Database'])-1 == 1)
{
echo '1</b> certificate';
}
elseif (count($openssl['Database'])-1 > 1)
{
echo '';
echo count($openssl['Database'])-1;
echo '</b> certificates';
}?>
</p>
<p>
<form action="/Admin/Modules/Squid/delbl.php" method="post" >
<input type="hidden" name="path" size="50" value="<?php echo $moduleurl;?>">
<input type="submit" value="Clear Blacklist">
</form>
</p>
<br>
<h2>User changed Proxy Accounts:</h2>
<form action="<?php echo $PHP_SELF; ?>" method="post">
<select name="dirsort" size=1>
<option <?php if($sort=="ASC") echo "selected";?> value="ASC">Up</option>
<option <?php if($sort=="DESC") echo "selected";?> value="DESC">Down</option>
</select>
<select name="sortby" size=1>
<option <?php if($by=="Id") echo "selected";?> value="Id">ID</option>
<option <?php if($by=="VPNId") echo "selected";?> value="VPNId">VPNId</option>
<option <?php if($by=="Time") echo "selected";?> value="Time">Time</option>
<option <?php if($by=="IP") echo "selected";?> value="IP">IP</option>
<option <?php if($by=="Nickname") echo "selected";?> value="Nickname">Nickname</option>
</select>
Search User:<input type="text" name="search" size="20" <?php if($search !="") echo "value=".$search;?> ></td>
<input type="submit" value="go!">
</form>
<!------ Sorting Leiste Start-->
<?php
@$y = mysql_connect($MYSQL_HOST,$MYSQL_USER,$MYSQL_PASS);
@$x = mysql_select_db($MYSQL_DATABASE);
if (empty($x))
{
echo "ERROR 0x01, Failed to connect to database!<br>";
exit;
}
// MYsql befehl basteln
if($by == "Nickname")
{
$sql = "SELECT * FROM proxyrepair;";
}
else
{
$sql = "SELECT * FROM proxyrepair ORDER BY $by $sort;";
}
$result = mysql_query($sql);
echo "<br><table border=1>";
echo "<tr><td><b>User ID</b></td><td><b>VPN Id</b></td><td><b>Nickname</b></td><td><b>Vorname</b></td><td><b>Nachname</b></td><td><b>Client IP</b></td><td><b>Time</b></td><td><b>Dead VPN ID</b></td></tr>\n";
// ------------------------------------------------ Mysql lesen
if ($result)
{
while ($ar=mysql_fetch_array($result,MYSQL_ASSOC))
{
$sql = "SELECT * FROM userdata WHERE Id = '".$ar["Id"]."' AND (Nickname LIKE '%".$search."%' OR Vorname LIKE '%".$search."%' OR Id LIKE '%".$search."%' OR VPNId LIKE '%".$search."%');";
$result2 = mysql_query($sql);
$ar2=mysql_fetch_array($result2,MYSQL_ASSOC);
if($ar2["Nickname"] != "")
echo "<tr><td>",$ar["Id"],"</td><td>",$ar["VPNId"],"</td><td>",$ar2["Nickname"],"</td><td>",$ar2["Vorname"],"</td><td>",$ar2["Nachname"],
"</td><td>", $ar["IP"],"</td><td>",$ar["Time"],"</td><td>",$ar["RepID"],"</td></tr>\n";
}
}
else
{
echo "<br>";
}
echo "</table>";
mysql_close();
?>

View File

@ -0,0 +1,3 @@
export CPATH=..:$HOME/include:/usr/local/include:/usr/include:/usr/include/mysql
needed: libmysqlclient-dev
gcc -l mysqlclient -o traffic Traffic.c

View File

@ -0,0 +1,4 @@
user: openvpn
passwd: openvpnlog
database: openvpn
host: localhost

View File

@ -0,0 +1,7 @@
#!/bin/bash
let x=0x3f
echo $x
let x=0xfffe
echo $x

View File

@ -0,0 +1,134 @@
/* OpenVPN - Squid Load Balancer*
*------------------------------*
* Version 1.0 *
* Written by Christoph Haas *
* License: LGPL *
* 12.10.2010 *
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <mysql/mysql.h>
#include <regex.h>
#include <string.h>
#define __MAX_LINE__ 100
#define __MAX_FIELD__ 255
#define false 0
#define true 1
MYSQL mysql;
int connect_db(char *config)
{
FILE *db_data = NULL;
regex_t reg;
char user[__MAX_LINE__] = "";
char passwd[__MAX_LINE__] = "";
char database[__MAX_LINE__] = "";
char host[__MAX_LINE__] = "";
int port = 0;
char tmp[__MAX_LINE__];
char buf[__MAX_LINE__];
int a, b;
int length;
if((db_data = fopen(config, "r")) == NULL)
{
fprintf(stderr, "Can't open %s for reading.\n", config);
return false;
}
regcomp(&reg, "^([a-zA-Z0-9:]+)[ ][a-zA-Z0-9]+$", REG_EXTENDED | REG_NEWLINE);
while(fgets(buf, __MAX_LINE__, db_data))
{
length = strlen(buf);
if(length < 3)continue;
if(length >= __MAX_LINE__)
{
fclose(db_data);
regfree(&reg);
fprintf(stderr, "To long line in config file.\n");
return false;
}
if(buf[0] == '#')continue;
if(regexec(&reg, buf, 0, 0, 0))
{
fclose(db_data);
regfree(&reg);
fprintf(stderr, "Syntax error in config file.\n");
return false;
}
for(a = 0, b = 0; a < strlen(buf); a++)
{
if(buf[a] == ' ')b++;
}
if(b != 1)
{
fclose(db_data);
regfree(&reg);
fprintf(stderr, "Syntax error in config file.\n");
return false;
}
if((strncmp(buf, "user: ", 6)) == 0)sscanf(buf, "%s %s", tmp, user);
if((strncmp(buf, "passwd: ", 8)) == 0)sscanf(buf, "%s %s", tmp, passwd);
if((strncmp(buf, "database: ", 10)) == 0)sscanf(buf, "%s %s", tmp, database);
if((strncmp(buf, "host: ", 6)) == 0)sscanf(buf, "%s %s", tmp, host);
if((strncmp(buf, "port: ", 6)) == 0)sscanf(buf, "%s %d", tmp, &port);
}
fclose(db_data);
regfree(&reg);
if((strlen(user) < 1) || (strlen(passwd) < 1) ||
(strlen(database) < 1) || (strlen(host) < 1))
{
fprintf(stderr, "One value for MySQL connection isn't set. \
Please set user, passwd, database and host.\n");
return false;
}
mysql_init(&mysql);
if((mysql_real_connect(&mysql, host, user, passwd, database, port, NULL, 0)) == NULL)
{
fprintf(stderr, "%s\n", mysql_error(&mysql));
return false;
}
return true;
}
int main(int argc, char **argv)
{
MYSQL_RES *result;
MYSQL_ROW row;
char Query[200]= "SELECT * FROM userdata WHERE VPNId = '\0";
if(argc == 2)
{
/*iID = atoi(argv[1]);
printf("Int:%d\n", iID);
sprintf(ID,"%-#10x",iID);
printf("String:%s\n", ID);*/
connect_db("/home/christoph/squid_dynamic/db.conf"); // Datenbank Verbindung aufbauen
strcat(Query, argv[1]); // Query builden
strcat(Query,"'"); //
mysql_query(&mysql, Query); // Query abschicken
result = mysql_store_result(&mysql); // Result speichern
while ((row = mysql_fetch_row(result))) // Alle Datensätze auslesen (in dem Fall eh nur einer)
{
printf("%s:%s\n", row[9], row[10]); // Feld 9 und 10 (login/pass) aus dem datensatz ausgeben
}
mysql_free_result(result); // Result wieder löschen
mysql_close(&mysql); // Datenbank Verbindung schliesen
}
else
{
printf("USAGE: sqidy xx | xx = VPNId\n"); // bei flascheingabe der Parameter
}
}

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1 @@
00

View File

@ -0,0 +1,115 @@
#!/bin/bash
# Zaehlvariable einlesen
id=$ID_VPN
# Abfrage ob Stringlaenge von id NULL ist
if [ ${#ID_VPN} == 0 ];
then id=0
fi
# id inkrementieren
let id=$id+1
# 255 Overflow verhindern
if [ $id -gt 254 ]
then id=0
fi
# Variable id fuer naechsten Durchlauf speichern
export ID_VPN=$id
# id HEX wandeln
hex=$(echo "obase=16; $id" |bc)
# Abfrage ob Strinlaenge von hex kleiner als 2
if [ ${#hex} -lt 2 ];
then hex=0$hex
fi
# Login-Daten aus Datenbank holen
credentials=$(./squidy $hex)
# Abfrage ob Datensatz leer :
zero="0"
if [ "$credentials" == ":" ];
then
. write_conf &
zero="1"
fi
if [ ${#credentials} == 0 ];
then
. write_conf &
zero="1"
fi
######################################################################################
# Config- Datei schreiben.
if [ $zero == "0" ]
then
echo "
# Squid config by h44z
# TAG: http_port
# Usage: port
# hostname:port
# 1.2.3.4:port
http_port 10.8.0.1:3128 transparent
http_port 10.8.0.1:8080
#https_port 10.8.0.1:8181 key=/etc/apache2/ssl/apache.pem
visible_hostname vpnrack
# TAG: icp_port
icp_port 0
# TAG: no_cache
acl QUERY urlpath_regex cgi-bin \\?
no_cache deny QUERY
# TAG: cache_mem (bytes)
cache_mem 32 MB
# TAG: cache_dir
cache_dir ufs /var/cache/squid 100 16 256
# TAG: cache_access_log
cache_access_log /var/log/squid/access.log
# TAG: cache_log
cache_log /var/log/squid/cache.log
# TAG: cache_store_log
cache_store_log /var/log/squid/store.log
# TAG: emulate_httpd_log on|off
emulate_httpd_log on
# TAG: pid_filename
pid_filename /var/run/squid.pid
# TAG: cache_mgr
cache_mgr christoph.haas2@students.htlinn.ac.at
http_access allow all
acl https port 443
http_access allow https
# TAG: http_reply_access
# Allow replies to client requests. This is complementary to http_access.
#http_reply_access allow all
cache_peer 192.168.195.101 parent 8080 7 no-query default no-digest login=$credentials
never_direct allow all
" > /etc/squid3/squid.conf
######################################################################################
#restart squid
killall -9 squid
squid -D -YC -f /etc/squid3/squid.conf
fi

View File

@ -0,0 +1,132 @@
#!/bin/bash
# Script um die cache_peer funktion von Squid upzudaten.
# V1.0
# 13.10.2010
# Stoeckholzer, Haas
if [ ${#1} == 0 ];
then
echo "USAGE: write_conf_file updatetime"
exit 0
fi
while [ "1" == "1" ] ;
do
sleep $1
zero="1"
while [ $zero == "1" ] ;
do
# Zaehlvariable einlesen
id=$(cat /var/vpn/vpnid)
# id inkrementieren
let id=$id+1
# 255 Overflow verhindern
if [ $id -gt 254 ]
then
id=0
fi
# Variable id fuer naechsten Durchlauf speichern
echo $id > /var/vpn/vpnid
# id HEX wandeln
hex=$(echo "obase=16; $id" |bc)
# Abfrage ob Strinlaenge von hex kleiner als 2
if [ ${#hex} -lt 2 ];
then
hex=0$hex
fi
black=$(cat /var/vpn/blacklist | grep $hex)
if [ ${#black} -lt 2 ];
then
# Login-Daten aus Datenbank holen
credentials=$(/home/christoph/squid_dynamic/squidy $hex)
# Abfrage ob Datensatz leer :
if [ ${#credentials} -gt 10 ];
then
zero="0"
fi
fi
done
echo "USING credentials: $credentials"
sudo killall -9 unlinkd
sudo killall -9 squid
sudo rm /etc/squid3/squid.conf
######################################################################################
# Config- Datei schreiben.
sudo echo -e -n "
# Squid config by h44z
# TAG: http_port
# Usage: port
# hostname:port
# 1.2.3.4:port
http_port 10.8.0.1:3128 transparent
http_port 10.8.0.1:8080
#https_port 10.8.0.1:8181 key=/etc/apache2/ssl/apache.pem
visible_hostname vpnrack
# TAG: icp_port
icp_port 0
# TAG: no_cache
acl QUERY urlpath_regex cgi-bin \\?
no_cache deny QUERY
# TAG: cache_mem (bytes)
cache_mem 32 MB
# TAG: cache_dir
cache_dir ufs /var/cache/squid 100 16 256
# TAG: cache_access_log
cache_access_log /var/log/squid/access.log
# TAG: cache_log
cache_log /var/log/squid/cache.log
# TAG: cache_store_log
cache_store_log /var/log/squid/store.log
# TAG: emulate_httpd_log on|off
emulate_httpd_log on
# TAG: pid_filename
pid_filename /var/run/squid.pid
# TAG: cache_mgr
cache_mgr christoph.haas2@students.htlinn.ac.at
#blubber
http_access allow all
acl https port 443
http_access allow https
# TAG: http_reply_access
# Allow replies to client requests. This is complementary to http_access.
#http_reply_access allow all
cache_peer 192.168.195.101 parent 8080 7 no-query default no-digest login=$credentials
never_direct allow all
" > /etc/squid3/squid.conf
echo "Written credentials: $credentials"
######################################################################################
#restart squid
sudo squid -D -YC -f /etc/squid3/squid.conf
done

View File

@ -0,0 +1,130 @@
#!/bin/bash
# Script um die cache_peer funktion von Squid upzudaten.
# V1.0
# 13.10.2010
# Stoeckholzer, Haas
if [ ${#1} == 0 ];
then
echo "USAGE: write_conf_file updatetime"
exit 0
fi
while [ "1" == "1" ] ; do
sleep $1
zero="1"
while [ $zero == "1" ] ; do
# Zaehlvariable einlesen
id=$(cat /var/vpn/vpnid)
# id inkrementieren
let id=$id+1
# 255 Overflow verhindern
if [ $id -gt 254 ]
then id=0
fi
# Variable id fuer naechsten Durchlauf speichern
echo $id > /var/vpn/vpnid
# id HEX wandeln
hex=$(echo "obase=16; $id" |bc)
# Abfrage ob Strinlaenge von hex kleiner als 2
if [ ${#hex} -lt 2 ];
then hex=0$hex
fi
# Login-Daten aus Datenbank holen
credentials=$(/home/christoph/squid_dynamic/squidy $hex)
# Abfrage ob Datensatz leer :
if [ ${#credentials} -gt 10 ];
then
zero="0"
fi
echo "Schleife zero: $zero"
echo "Schleife id: $id"
echo "Schleife hex: $hex"
done
echo "USING zero: $zero"
echo "USING id: $id"
echo "USING hex: $hex"
echo "USING credentials: $credentials"
sudo killall -9 unlinkd
sudo killall -9 squid
sudo rm /etc/squid3/squid.conf
######################################################################################
# Config- Datei schreiben.
sudo echo -e -n "
# Squid config by h44z
# TAG: http_port
# Usage: port
# hostname:port
# 1.2.3.4:port
http_port 10.8.0.1:3128 transparent
http_port 10.8.0.1:8080
#https_port 10.8.0.1:8181 key=/etc/apache2/ssl/apache.pem
visible_hostname vpnrack
# TAG: icp_port
icp_port 0
# TAG: no_cache
acl QUERY urlpath_regex cgi-bin \\?
no_cache deny QUERY
# TAG: cache_mem (bytes)
cache_mem 32 MB
# TAG: cache_dir
cache_dir ufs /var/cache/squid 100 16 256
# TAG: cache_access_log
cache_access_log /var/log/squid/access.log
# TAG: cache_log
cache_log /var/log/squid/cache.log
# TAG: cache_store_log
cache_store_log /var/log/squid/store.log
# TAG: emulate_httpd_log on|off
emulate_httpd_log on
# TAG: pid_filename
pid_filename /var/run/squid.pid
# TAG: cache_mgr
cache_mgr christoph.haas2@students.htlinn.ac.at
#blubber
http_access allow all
acl https port 443
http_access allow https
# TAG: http_reply_access
# Allow replies to client requests. This is complementary to http_access.
#http_reply_access allow all
cache_peer 192.168.195.101 parent 8080 7 no-query default no-digest login=$credentials
never_direct allow all
" > /etc/squid3/squid.conf
echo "Written credentials: $credentials"
######################################################################################
#restart squid
sudo squid -D -YC -f /etc/squid3/squid.conf
done

View File

@ -0,0 +1,183 @@
#!/bin/bash
# Script um die cache_peer funktion von Squid manuell von der Website aus upzudaten.
# V1.0
# 13.10.2010
# Stoeckholzer, Haas
while [ "1" == "1" ];
do
write=1
zero=0
# ueberpruefen ob file vpnid_man vorhanden
if [ -e /var/vpn/vpnid_man ];
then
echo 1
zero=1
fi
# ueberpruefen ob file vpnid_next vorhanden
if [ -e /var/vpn/vpnid_next ];
then
echo 2
zero=2
fi
if [ "$zero" == "1" ];
then
# Manuelle ID als hex einlesen einlesen
hex=$(cat /var/vpn/vpnid_man)
id=$(printf "%d\n" 0x$hex)
echo $id > /var/vpn/vpnid
rm /var/vpn/vpnid_man
echo $hex
# Login-Daten aus Datenbank holen
credentials=$(/home/christoph/squid_dynamic/squidy $hex)
fi
if [ "$zero" == "2" ];
then
schleife="1"
rm /var/vpn/vpnid_next
while [ $schleife == "1" ] ;
do
# Zaehlvariable einlesen
id_alt=$(cat /var/vpn/vpnid)
# alte id HEX wandeln zum BLacklisten
hex_alt=$(echo "obase=16; $id_alt" |bc)
# Abfrage ob Strinlaenge von hex kleiner als 2
if [ ${#hex_alt} -lt 2 ];
then
hex_alt=0$hex_alt
fi
# alte id BLacklisten
if [ $write == 1 ];
then
echo $hex_alt >> /var/vpn/blacklist
fi
# id inkrementieren
let id=$id_alt+1
# 255 Overflow verhindern
if [ $id -gt 254 ]
then
id=0
fi
# Variable id fuer naechsten Durchlauf speichern
echo $id > /var/vpn/vpnid
# id HEX wandeln
hex=$(echo "obase=16; $id" |bc)
# Abfrage ob Strinlaenge von hex kleiner als 2
if [ ${#hex} -lt 2 ];
then
hex=0$hex
fi
# hole id_hex aus BLacklist?
black=$(cat /var/vpn/blacklist|grep $hex)
# Abfrage ob id_hex in BLacklist
if [ ${#black} -lt 2 ];
then
# Login-Daten aus Datenbank holen
credentials=$(/home/christoph/squid_dynamic/squidy $hex)
# Abfrage ob Datensatz leer :
if [ ${#credentials} -gt 10 ];
then
schleife="0"
fi
else write=0
fi
done
fi
# Abfrage ob Datensatz leer (zur Sicherheit):
if [ ${#credentials} -gt 10 ] && [ $zero != "0" ];
then
# stop squid
sudo killall -9 unlinkd
sudo killall -9 squid
sudo rm /etc/squid3/squid.conf
######################################################################################
# Config- Datei schreiben.
sudo echo -e -n "
# Squid config by h44z
# TAG: http_port
# Usage: port
# hostname:port
# 1.2.3.4:port
http_port 10.8.0.1:3128 transparent
http_port 10.8.0.1:8080
#https_port 10.8.0.1:8181 key=/etc/apache2/ssl/apache.pem
visible_hostname vpnrack
# TAG: icp_port
icp_port 0
# TAG: no_cache
acl QUERY urlpath_regex cgi-bin \\?
no_cache deny QUERY
# TAG: cache_mem (bytes)
cache_mem 32 MB
# TAG: cache_dir
cache_dir ufs /var/cache/squid 100 16 256
# TAG: cache_access_log
cache_access_log /var/log/squid/access.log
# TAG: cache_log
cache_log /var/log/squid/cache.log
# TAG: cache_store_log
cache_store_log /var/log/squid/store.log
# TAG: emulate_httpd_log on|off
emulate_httpd_log on
# TAG: pid_filename
pid_filename /var/run/squid.pid
# TAG: cache_mgr
cache_mgr christoph.haas2@students.htlinn.ac.at
http_access allow all
acl https port 443
http_access allow https
# TAG: http_reply_access
# Allow replies to client requests. This is complementary to http_access.
#http_reply_access allow all
cache_peer 192.168.195.101 parent 8080 7 no-query default no-digest login=$credentials
never_direct allow all
" > /etc/squid3/squid.conf
######################################################################################
echo "Written: $credentials"
#start squid
squid -D -YC -f /etc/squid3/squid.conf
fi
sleep 2
done

View File

@ -0,0 +1,158 @@
#!/bin/bash
# Script um die cache_peer funktion von Squid manuell von der Website aus upzudaten.
# V1.0
# 13.10.2010
# Stoeckholzer, Haas
while [ "1" == "1" ];
do
zero=0
# ueberpruefen ob file vpnid_man vorhanden
if [ -e /var/vpn/vpnid_man ];
then
echo 1
zero=1
fi
# ueberpruefen ob file vpnid_next vorhanden
if [ -e /var/vpn/vpnid_next ];
then
echo 2
zero=2
fi
if [ "$zero" == "1" ];
then
# Manuelle ID als hex einlesen einlesen
hex=$(cat /var/vpn/vpnid_man)
id=$(printf "%d\n" $hex)
echo $id > /var/vpn/vpnid
rm /var/vpn/vpnid_man
echo $hex
# Login-Daten aus Datenbank holen
credentials=$(/home/christoph/squid_dynamic/squidy $hex)
fi
if [ "$zero" == "2" ];
then
schleife="1"
rm /var/vpn/vpnid_next
while [ $schleife == "1" ] ;
do
# Zaehlvariable einlesen
id=$(cat /var/vpn/vpnid)
# id inkrementieren
let id=$id+1
# 255 Overflow verhindern
if [ $id -gt 254 ]
then
id=0
fi
# Variable id fuer naechsten Durchlauf speichern
echo $id > /var/vpn/vpnid
# id HEX wandeln
hex=$(echo "obase=16; $id" |bc)
# Abfrage ob Strinlaenge von hex kleiner als 2
if [ ${#hex} -lt 2 ];
then
hex=0$hex
fi
# Login-Daten aus Datenbank holen
credentials=$(/home/christoph/squid_dynamic/squidy $hex)
# Abfrage ob Datensatz leer :
if [ ${#credentials} -gt 10 ];
then
schleife="0"
fi
done
fi
# Abfrage ob Datensatz leer (zur Sicherheit):
if [ ${#credentials} -gt 10 ] && [ $zero != "0" ];
then
# stop squid
sudo killall -9 unlinkd
sudo killall -9 squid
sudo rm /etc/squid3/squid.conf
######################################################################################
# Config- Datei schreiben.
sudo echo -e -n "
# Squid config by h44z
# TAG: http_port
# Usage: port
# hostname:port
# 1.2.3.4:port
http_port 10.8.0.1:3128 transparent
http_port 10.8.0.1:8080
#https_port 10.8.0.1:8181 key=/etc/apache2/ssl/apache.pem
visible_hostname vpnrack
# TAG: icp_port
icp_port 0
# TAG: no_cache
acl QUERY urlpath_regex cgi-bin \\?
no_cache deny QUERY
# TAG: cache_mem (bytes)
cache_mem 32 MB
# TAG: cache_dir
cache_dir ufs /var/cache/squid 100 16 256
# TAG: cache_access_log
cache_access_log /var/log/squid/access.log
# TAG: cache_log
cache_log /var/log/squid/cache.log
# TAG: cache_store_log
cache_store_log /var/log/squid/store.log
# TAG: emulate_httpd_log on|off
emulate_httpd_log on
# TAG: pid_filename
pid_filename /var/run/squid.pid
# TAG: cache_mgr
cache_mgr christoph.haas2@students.htlinn.ac.at
http_access allow all
acl https port 443
http_access allow https
# TAG: http_reply_access
# Allow replies to client requests. This is complementary to http_access.
#http_reply_access allow all
cache_peer 192.168.195.101 parent 8080 7 no-query default no-digest login=$credentials
never_direct allow all
" > /etc/squid3/squid.conf
######################################################################################
echo "Written: $credentials"
#start squid
squid -D -YC -f /etc/squid3/squid.conf
fi
sleep 2
done

View File

@ -0,0 +1,5 @@
/home/christoph/stopsquid
#iptables -t nat -A PREROUTING -i tap0 -p tcp --dport 80 -j REDIRECT --to-ports 3128
#iptables -t nat -A PREROUTING -i tap0 -p tcp --dport 443 -j REDIRECT --to-ports 3128
squid -D -YC -f /etc/squid3/squid.conf

View File

@ -0,0 +1,6 @@
#iptables -t nat -D PREROUTING -i tap0 -p tcp --dport 80 -j REDIRECT --to-ports 3128
#iptables -t nat -D PREROUTING -i tap0 -p tcp --dport 443 -j REDIRECT --to-ports 3128
killall squid
killall squid
killall squid

View File

@ -0,0 +1,119 @@
<?php
session_start();
include ($_SERVER["DOCUMENT_ROOT"]."/Site/checkadmin.php");
require($_SERVER["DOCUMENT_ROOT"]."/Site/mysql.php");
$ovpnkeydir = db_getconfval("ovpnkeydir");
$mserv = db_getconfval("mserv");
$muser = db_getconfval("muser");
$mpass = db_getconfval("mpass");
$mname = db_getconfval("mname");
$mrecv = db_getconfval("sitename");
$moduleurl = $_REQUEST["path"];
// Aufbau der Datenbankverbindung
require($_SERVER["DOCUMENT_ROOT"]."/Config/_dbconfig_.php");
@$y = mysql_connect($MYSQL_HOST,$MYSQL_USER,$MYSQL_PASS);
@$x = mysql_select_db($MYSQL_DATABASE);
if (empty($x))
{
die ("Could not connect to database!");
}
// Definition der Benutzer
$benutzer["IsAdmin"] = mysql_real_escape_string($_REQUEST["isadmin"]);
$benutzer["Email"] = mysql_real_escape_string(substr($_REQUEST["email"],0,39)); // safty xD
$benutzer["Nickname"] = mysql_real_escape_string($_REQUEST["nickname"]);
$benutzer["Kennwort"] = mysql_real_escape_string($_REQUEST["pwd"]);
$benutzer["Nachname"] = mysql_real_escape_string($_REQUEST["nachname"]);
$benutzer["Vorname"] = mysql_real_escape_string($_REQUEST["vorname"]);
$benutzer["VPN"] = mysql_real_escape_string($_REQUEST["vpn"]);
$benutzer["NovLogin"] = mysql_real_escape_string($_REQUEST["novlogin"]);
$benutzer["NovPass"] = mysql_real_escape_string($_REQUEST["novpass"]);
$benutzer["VPNId"] = "-";
// Sie können an dieser Stelle beliebig viele Benutzer anlegen.
// Achten Sie dabei nur auf die Fortführung der Nummer.
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
if($benutzer["VPN"] == "1")
{
//create certificate
//die($ovpnkeydir);
chdir ($ovpnkeydir);
$File = "keys/serial";
$fh = fopen($File, 'r');
$benutzer["VPNId"] = fread($fh, filesize($File));
fclose($fh);
exec(escapeshellcmd("./srcvar " .$benutzer["Email"]. " " .$benutzer["Nickname"]. " " .$benutzer["VPNId"]));
chdir ("/var/www/Admin/");
}
else
{
$benutzer["VPNId"] = "-";
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Daten eintragen
// SQL-Anweisung erstellen
$sql = "INSERT INTO ".
"userdata (IsAdmin, VPNId, Nickname, Kennwort, Nachname, Vorname, Email, NovLogin, NovPass) ".
"VALUES ('".$benutzer["IsAdmin"]."', '".
$benutzer["VPNId"]."', '".
$benutzer["Nickname"]."', '".
md5 ($benutzer["Kennwort"])."', '".
$benutzer["Nachname"]."', '".
$benutzer["Vorname"]."', '".
$benutzer["Email"]."', '".
$benutzer["NovLogin"]."', '".
$benutzer["NovPass"]."')";
//echo $sql;
mysql_query ($sql);
if (mysql_affected_rows ($y) > 0)
{
mysql_close();
// Send Confirmation Mail
if(db_getconfval("withmail") == "1")
{
require_once "Mail.php";
$from = $mrecv." <".$mname.">";
$to = $benutzer["Vorname"]." ".$benutzer["Nachname"]." <".$benutzer["Email"].">";
$subject = "VPN Account created!";
$body =
"Dear ".$benutzer["Vorname"]." ".$benutzer["Nachname"].",\n\nyour ".$mrecv." account has been created!\nYou can now login on with this credentials:\n\n#########################################################\nUsername: ".$benutzer["Nickname"]."\nPassword: ".$benutzer["Kennwort"]."\n#########################################################\nYou can change your password in the user section.\n\nAll files, programms and other stuff can be found on the homepage!\nTo start using your VPN Connection you have to download your config-file and your certificates!\nInstall everything as it is described in the README.txt!\n\nHave fun!!!\n\nIf you have questions write me an email!\n\n".$mrecv."\n";
$host = $mserv;
$username = $muser;
$password = $mpass;
$headers = array ( 'From' => $from,
'To' => $to,
'Subject' => $subject);
$smtp = Mail::factory('smtp',
array ( 'host' => $host,
'auth' => true,
'username' => $username,
'password' => $password));
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail))
{
// evt deaktivieren
echo("<p>" . $mail->getMessage() . "</p>");
}
}
// Finish
mysql_close();
header ("Location: ".$moduleurl."&uebergabe2=1");
}
else
{
mysql_close();
echo "Fehler beim Anlegen des Benutzers.<br>\n";
}
?>

View File

@ -0,0 +1,66 @@
<?php
include ($_SERVER["DOCUMENT_ROOT"]."/Site/checkadmin.php");
?>
<!-- MAIN CONTENT BEGINN ################################################################################ -->
<h1><b>User Management</b></h1>
<h2>Add new User:</h2>
<form action="/Admin/Modules/Usermanagement/include/adduser.php" method="post" onsubmit="return chkFormular()">
<input type="hidden" name="path" size="50" value="<?php echo $moduleurl;?>">
<table>
<tr>
<td>Admin:</td>
<td>
<select name="isadmin" size=1>
<option value="0">No</option>
<option value="1">Yes</option>
</select>
</td>
</tr>
<tr>
<td>With VPN:</td>
<td>
<select name="vpn" size=1>
<option value="0">No</option>
<option value="1">Yes</option>
</select>
</td>
</tr>
<tr>
<td>Nickname:</td>
<td><input type="text" name="nickname" size="40"><td>
</tr>
<tr>
<td>Vorname:</td>
<td><input type="text" name="vorname" size="40"><td>
</tr>
<tr>
<td>Nachname:</td>
<td><input type="text" name="nachname" size="40"><td>
</tr>
<tr>
<td>Email Address:</td>
<td><input type="text" name="email" size="40"><td>
<td>(max 40 Char!!)</td>
</tr>
<tr>
<td>Passwort:</td>
<td><input type="password" name="pwd" size="40"></td>
</tr>
<tr>
<td>Novell Login:</td>
<td><input type="text" name="novlogin" size="50"></td>
</tr>
<tr>
<td>Novell Password:</td>
<td><input type="password" name="novpass" size="50"></td>
</tr>
</table>
<input type="submit" value="Add User">
</form>
<p> <a href="<?php echo $moduleurl;?>"><b>Back</b></a></p>
<!-- MAIN CONTENT END ################################################################################### -->

View File

@ -0,0 +1,51 @@
<?php
session_start();
include ($_SERVER["DOCUMENT_ROOT"]."/Site/checkadmin.php");
require($_SERVER["DOCUMENT_ROOT"]."/Site/mysql.php");
$ovpnkeydir = db_getconfval("ovpnkeydir");
// Aufbau der Datenbankverbindung
require($_SERVER["DOCUMENT_ROOT"]."/Config/_dbconfig_.php");
@$y = mysql_connect($MYSQL_HOST,$MYSQL_USER,$MYSQL_PASS);
@$x = mysql_select_db($MYSQL_DATABASE);
if (empty($x))
{
die ("Could not connect to database!");
}
// Definition der Benutzer
$benutzer["Nickname"] = mysql_real_escape_string($_REQUEST["nickname"]);
$moduleurl = $_REQUEST["path"];
// Get VPN id
$sql = "SELECT VPNId FROM userdata WHERE Nickname='".$benutzer["Nickname"]."'";
$result = mysql_query ($sql);
$benutzer["VPNId"] = mysql_fetch_array($result,MYSQL_ASSOC);
//echo $sql;
//echo $benutzer["VPNId"]["VPNId"];
//revoke certificate
chdir ("$ovpnkeydir");
exec(escapeshellcmd("./revoke " .$benutzer["VPNId"]["VPNId"]));
chdir ("/var/www/Admin/");
// Daten eintragen
// SQL-Anweisung erstellen
$sql = "DELETE FROM userdata WHERE Nickname = '" . $benutzer["Nickname"]."'";
mysql_query ($sql);
if (mysql_affected_rows ($y) > 0)
{
mysql_close();
header ("Location: ".$moduleurl."&uebergabe2=3");
}
else
{
mysql_close();
echo "Fehler beim Loeschen des Benutzers.<br>\n";
}
?>

View File

@ -0,0 +1,21 @@
<?php
include ($_SERVER["DOCUMENT_ROOT"]."/Site/checkadmin.php");
?>
<!-- MAIN CONTENT BEGINN ################################################################################ -->
<h1><b>User Management</b></h1>
<h2>Delete User:</h2>
<form action="/Admin/Modules/Usermanagement/include/deleteuser.php" method="post">
<input type="hidden" name="path" size="50" value="<?php echo $moduleurl;?>">
<table>
<tr>
<td>Nickname:</td>
<td><input type="text" name="nickname" size="20"><td>
</tr>
</table>
<input type="submit" value="Delete User">
</form>
<p> <a href="<?php echo $moduleurl;?>"><b>Back</b></a></p>
<!-- MAIN CONTENT END ################################################################################### -->

View File

@ -0,0 +1,113 @@
<?php
session_start();
include ($_SERVER["DOCUMENT_ROOT"]."/Site/checkadmin.php");
$moduleurl = $_REQUEST["path"];
// Aufbau der Datenbankverbindung
require($_SERVER["DOCUMENT_ROOT"]."/Config/_dbconfig_.php");
@$y = mysql_connect($MYSQL_HOST,$MYSQL_USER,$MYSQL_PASS);
@$x = mysql_select_db($MYSQL_DATABASE);
if (empty($x))
{
die ("Could not connect to database!");
}
// Definition der Benutzer
$benutzer["IsAdmin"] = mysql_real_escape_string($_REQUEST["isadmin"]);
$benutzer["VPNId"] = mysql_real_escape_string($_REQUEST["vpnid"]);
$benutzer["Nickname"] = mysql_real_escape_string($_REQUEST["nickname"]);
$benutzer["Kennwort"] = mysql_real_escape_string($_REQUEST["pwd"]);
$benutzer["Nachname"] = mysql_real_escape_string($_REQUEST["nachname"]);
$benutzer["Vorname"] = mysql_real_escape_string($_REQUEST["vorname"]);
$benutzer["Email"] = mysql_real_escape_string($_REQUEST["email"]);
$benutzer["NovLogin"] = mysql_real_escape_string($_REQUEST["novlogin"]);
$benutzer["NovPass"] = mysql_real_escape_string($_REQUEST["novpass"]);
// Daten eintragen
// SQL-Anweisung erstellen
$strcount = 0;
$sql = "UPDATE userdata SET ";
if($benutzer["IsAdmin"] != "")
{
$sql = $sql . "IsAdmin='".$benutzer["IsAdmin"]."' ";
$strcount = 1;
}
if($benutzer["VPNId"] != "")
{
if(isset($strcount))
{
$sql = $sql . ",";
}
$sql = $sql . "VPNId='". $benutzer["VPNId"]."' ";
$strcount = 1;
}
if($benutzer["Kennwort"] != "")
{
if(isset($strcount))
{
$sql = $sql . ",";
}
$sql = $sql . "Kennwort='". md5 ($benutzer["Kennwort"])."' ";
$strcount = 1;
}
if($benutzer["Nachname"] != "")
{
if(isset($strcount))
{
$sql = $sql . ",";
}
$sql = $sql . "Nachname='". $benutzer["Nachname"]."' ";
$strcount = 1;
}
if($benutzer["Vorname"] != "")
{
if(isset($strcount))
{
$sql = $sql . ",";
}
$sql = $sql . "Vorname='". $benutzer["Vorname"]."' ";
$strcount = 1;
}
if($benutzer["Email"] != "")
{
if(isset($strcount))
{
$sql = $sql . ",";
}
$sql = $sql . "Email='". $benutzer["Email"]."' ";
$strcount = 1;
}
if($benutzer["NovLogin"] != "")
{
if(isset($strcount))
{
$sql = $sql . ",";
}
$sql = $sql . "NovLogin='". $benutzer["NovLogin"]."' ";
$strcount = 1;
}
if($benutzer["NovPass"] != "")
{
if(isset($strcount))
{
$sql = $sql . ",";
}
$sql = $sql . "NovPass='". $benutzer["NovPass"]."' ";
$strcount = 1;
}
$sql = $sql . "WHERE Nickname = '" . $benutzer["Nickname"]."'";
//die($sql);
mysql_query ($sql);
if (mysql_affected_rows ($y) > 0)
{
mysql_close();
header ("Location: ".$moduleurl."&uebergabe2=2");
}
else
{
mysql_close();
echo "Fehler beim Editieren des Benutzers. (Nothing changed?)<br>\n";
}
?>

View File

@ -0,0 +1,61 @@
<?php
include ($_SERVER["DOCUMENT_ROOT"]."/Site/checkadmin.php");
$nick = $_POST["nickname"];
?>
<!-- MAIN CONTENT BEGINN ################################################################################ -->
<h1><b>User Management</b></h1>
<h2>Edit User:</h2>
<form action="/Admin/Modules/Usermanagement/include/edituser.php" method="post">
<input type="hidden" name="path" size="50" value="<?php echo $moduleurl;?>">
<table>
<tr>
<td>Admin:</td>
<td>
<select name="isadmin" size=1>
<option value="0">No</option>
<option value="1">Yes</option>
</select>
</td>
</tr>
<tr>
<td>Nickname:</td>
<td><input type="text" name="nickname" <?php if($nick != "") echo " value=".$nick;?> size=" 50"><td>
<td>*</td>
</tr>
<tr>
<td>VPN Id:</td>
<td><input type="text" name="vpnid" size="50"><td>
</tr>
<tr>
<td>Vorname:</td>
<td><input type="text" name="vorname" size="50"><td>
</tr>
<tr>
<td>Nachname:</td>
<td><input type="text" name="nachname" size="50"><td>
</tr>
<tr>
<td>Email Address:</td>
<td><input type="text" name="email" size="50"><td>
</tr>
<tr>
<td>Passwort:</td>
<td><input type="password" name="pwd" size="50"></td>
</tr>
<tr>
<td>Novell Login:</td>
<td><input type="text" name="novlogin" size="50"><td>
</tr>
<tr>
<td>Novell Passwort:</td>
<td><input type="password" name="novpass" size="50"></td>
</tr>
</table>
<input type="submit" value="Edit User">
</form>
* = Required
<p> <a href="<?php echo $moduleurl;?>"><b>Back</b></a></p>
<!-- MAIN CONTENT END ################################################################################### -->

View File

@ -0,0 +1,95 @@
<?php
include ($_SERVER["DOCUMENT_ROOT"]."/Site/checkadmin.php");
include ($_SERVER["DOCUMENT_ROOT"]."/Config/_dbconfig_.php");
@mysql_connect($MYSQL_HOST,$MYSQL_USER,$MYSQL_PASS);
@$x=mysql_select_db($MYSQL_DATABASE);
if (empty($x))
{
echo "ERROR 0x01, Failed to connect to database!<br>";
exit;
}
$sort = mysql_real_escape_string($_POST["dirsort"]); //$_GET["sort"];
$by = mysql_real_escape_string($_POST["sortby"]); //$_GET["by"];
$search= mysql_real_escape_string($_POST["search"]);
if($sort== "") $sort = "DESC"; //$_GET["sort"];
if($by=="") $by = "Id"; //$_GET["by"];
?>
<!-- MAIN CONTENT BEGINN ################################################################################ -->
<form action="<?php echo $PHP_SELF; ?>" method="post">
<br>
<select name="dirsort" size=1>
<option <?php if($sort=="ASC") echo "selected";?> value="ASC">Up</option>
<option <?php if($sort=="DESC") echo "selected";?> value="DESC">Down</option>
</select>
<select name="sortby" size=1>
<option <?php if($by=="Id") echo "selected";?> value="Id">ID</option>
<option <?php if($by=="IsAdmin") echo "selected";?> value="IsAdmin">IsAdmin</option>
<option <?php if($by=="VPNId") echo "selected";?> value="VPNId">VPNId</option>
<option <?php if($by=="Vorname") echo "selected";?> value="Vorname">First Name</option>
<option <?php if($by=="Nachname") echo "selected";?> value="Nachname">Last Name</option>
<option <?php if($by=="Nickname") echo "selected";?> value="Nickname">Nickname</option>
<option <?php if($by=="Email") echo "selected";?> value="Email">Email Address</option>
</select>
Search User:<input type="text" name="search" size="20" <?php if($search !="") echo "value=".$search;?> ></td>
<input type="submit" value="go!">
</form>
<!------ Sorting Leiste Start-->
<?php
// MYsql befehl basteln
$sql = "SELECT * FROM userdata WHERE Id LIKE '%".$search."%' OR VPNId LIKE '%".$search."%' OR Nickname LIKE '%".$search."%' OR Vorname LIKE '%".$search."%' ORDER BY $by $sort;";
$result = mysql_query($sql);
echo "<br><table border=1>";
if($by != "")
{
echo "<tr><td>ID</td><td>IsAdmin</td><td>VPNId</td><td>Nickname</td><td>Firstname</td><td>Lastname</td><td>Email Address</td>
<td>Novell Login</td><td>Edit</td><td>Delete</td>
</tr>\n";
}
// ------------------------------------------------ Mysql lesen
if ($result)
{
while ($ar=mysql_fetch_array($result,MYSQL_ASSOC))
{
echo "<tr><td>", $ar["Id"],
"</td><td>",$ar["IsAdmin"],
"</td><td>",$ar["VPNId"],
"</td><td>",$ar["Nickname"],
"</td><td>",$ar["Vorname"],
"</td><td>",$ar["Nachname"],
"</td><td>",$ar["Email"],
"</td><td>",$ar["NovLogin"],
"</td>",
"<form action=".$moduleurl."&uebergabe=2 method=post>",
"<input type=hidden name=nickname value=".$ar["Nickname"]." size=20><td>",
"<input type=submit value=X>",
"</form>",
"<form action=/Admin/Modules/Usermanagement/include/deleteuser.php method=post>",
"<input type=hidden name=path value=".$moduleurl." size=20>",
"<input type=hidden name=nickname value=".$ar["Nickname"]." size=20><td bgcolor=#FA5858>",
"<input type=submit value=X>",
"</form>",
"</tr>\n";
}
}
else
{
echo "<br>";
}
echo "</table>";
mysql_close();
?>
<p> <a href="<?php echo $moduleurl;?>"><b>Back</b></a></p>
<!-- END CONTENT BEGINN ################################################################################# -->
<?php
include("footer.php");
?>

View File

@ -0,0 +1,64 @@
<?php
include ($_SERVER["DOCUMENT_ROOT"]."/Site/checkadmin.php");
$moduleurl = $_SERVER["REQUEST_URI"];
$urlcut = strpos($moduleurl, "&");
if($urlcut > 0)
{
$moduleurl = substr($moduleurl,0,$urlcut);
}
else
{
if(strpos($moduleurl, "?") == 0)
{
$moduleurl = $_SERVER["REQUEST_URI"]."?site=1";
}
}
$mode = $_REQUEST["uebergabe"];
$status = $_REQUEST["uebergabe2"];
echo" <p><a href=\"".$moduleurl."&uebergabe=0\">Home</a>
| <a href=\"".$moduleurl."&uebergabe=1\">Add new User</a>
| <a href=\"".$moduleurl."&uebergabe=2\">Edit User</a>
| <a href=\"".$moduleurl."&uebergabe=3\">Delete User</a>
| <a href=\"".$moduleurl."&uebergabe=4\">View Users</a></p><hr><br>";
switch($status)
{
case 1:
echo "<b>User added successfully!</b>";
break;
case 2:
echo "<b>User edited successfully!</b>";
break;
case 3:
echo "<b>User deleted successfully!</b>";
break;
default:
break;
}
switch($mode)
{
case 1:
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/Usermanagement/include/adduser_index.php");
break;
case 2:
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/Usermanagement/include/edituser_index.php");
break;
case 3:
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/Usermanagement/include/deleteuser_index.php");
break;
case 4:
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/Usermanagement/include/viewuser_index.php");
break;
default:
echo"<h1><b>User Management</b></h1>
<h2>Choose an action:</h2>
<p># <a href=\"".$moduleurl."&uebergabe=1\">Add new User</a></p>
<p># <a href=\"".$moduleurl."&uebergabe=2\">Edit User</a></p>
<p># <a href=\"".$moduleurl."&uebergabe=3\">Delete User</a></p>
<p># <a href=\"".$moduleurl."&uebergabe=4\">View Users</a></p><br>";
break;
}
?>

View File

@ -0,0 +1,66 @@
<?php
//include($_SERVER["DOCUMENT_ROOT"]."/Site/mysql.php");
// Change: your company name
$config['Company_Name'] = 'SchulVPN';
// Change: your company home page
$config['URL_Home_Page'] = 'http://10.10.63.60/index.php';
$config['AUTH_REALM'] = $config['Company_Name'] .' OpenVPN Web GUI v.0.3.2';
// What files to include into ZIP
$config['Download']['ZIP']['.pem'] = true;
$config['Download']['ZIP']['.key'] = true;
$config['Download']['ZIP']['.csr'] = false;
// All the following files should be placed into downloads folder
$config['Download']['ZIP']['Others'] = array ('readme.txt','ca.crt', 'schulvpn.ovpn', 'certinstall.sh');
//$config['Download']['ZIP']['Others'] = array ('readme.txt', 'install.cmd', 'tls-auth.key');
// Use the real absolute path here.
$config['PluginsAbsolutePath'] = $_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNConfig/plugins/";
// If there are no plugins
//$config['Plugins'] = NULL;
// Otherwise, follow this example:
//$config['Plugins']['PLUGINMANE']['Folder'] = 'FOLDERNAME';
// The post-install helper plugin. Shows if PHP5 has the neccessary functions available
$config['Plugins']['systemcheck']['Folder'] = 'systemcheck';
// OPENVPN ________________________________
// Change: the configuration directory
$config['openvpn']['folder'] = db_getconfval("ovpnconfdir")."/";
// Change: configuration and status file names
$config['openvpn']['config'] = $config['openvpn']['folder'].db_getconfval("ovpnconffile");
$config['openvpn']['status'] = $config['openvpn']['folder']."openvpn-status.log";
// OPENSSL ________________________________
// Change: openssl keys directory
$config['openssl']['folder'] = db_getconfval("ovpnkeydir")."/keys/";
// Change: different folders for Public Certificates, Certificate Requests and Private Keys.
// NOTE: openssl somehow respects only newpem folder (for Public Certificates).
$config['openssl']['pubfolder'] = $config['openssl']['folder'];
$config['openssl']['reqfolder'] = $config['openssl']['folder'];
$config['openssl']['prvfolder'] = $config['openssl']['folder'];
// Change: openssl CA private and public keys
$config['openssl']['CA']['priv'] = $config['openssl']['folder'] .'ca.key';
$config['openssl']['CA']['pub'] = $config['openssl']['folder'] .'ca.crt';
// Change: openssl serial file
$config['openssl']['serial'] = $config['openssl']['folder'] .'serial';
// Change: openssl database
$config['openssl']['database'] = $config['openssl']['folder'] .'index.txt';
// Change: openssl configuration
$config['openssl']['config'] = $config['openvpn']['folder'] .'openssl.cnf';
// NEW OPENSSL CERTIFICATE DEFAULTS _________
// Change all of them as it is done in your easy-rsa/vars
$config['openssl']['default']['expiration'] = 3560;
$config['openssl']['default']['countryName'] = 'AT';
$config['openssl']['default']['stateOrProvinceName'] = 'Tirol';
$config['openssl']['default']['localityName'] = 'Innsbruck';
$config['openssl']['default']['organizationName'] = 'HTL';
$config['openssl']['default']['organizationalUnitName'] = '';
$config['openssl']['default']['commonName'] = '';
$config['openssl']['default']['emailAddress'] = 'vpn@students.htlinn.ac.at';
?>

View File

@ -0,0 +1,86 @@
<?php
include ($_SERVER["DOCUMENT_ROOT"]."/Site/checkadmin.php");
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/config.inc");
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/include/functions.inc");
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/include/openvpn-functions.inc");
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/include/openssl-functions.inc");
openvpn_load_server_conf ();
if (!isset ($openvpn['Server'])) html_error ("The OpenVPN server has no configuration file");
openvpn_load_status ();
if (!isset ($openvpn['Server']['Title'])) html_error ("The OpenVPN server has no status file");
openssl_load_database ();
openvpn_find_connected ();
$openvpn["Certificates"] = $openssl["Database"];
?>
<table border="0" width="100%" cellspacing="0" cellpadding="4">
<tr valign="top">
<td style="border-bottom:1px groove gray; border-top:1px groove gray" bgcolor="#DDFFCC"><b>#</b></td>
<td style="border-bottom:1px groove gray; border-top:1px groove gray" width="1%">&nbsp;</td>
<td style="border-bottom:1px groove gray; border-top:1px groove gray"><b>Common Name</b></td>
<td style="border-bottom:1px groove gray; border-top:1px groove gray"><b>Department</b></td>
<td style="border-bottom:1px groove gray; border-top:1px groove gray"><b>e-mail</b></td>
<td style="border-bottom:1px groove gray; border-top:1px groove gray"><b>Serial</b></td>
<td style="border-bottom:1px groove gray; border-top:1px groove gray"><b>Status</b></td>
<td style="border-bottom:1px groove gray; border-top:1px groove gray" bgcolor="#DDFFCC" width="5%"><b>Download</b></td>
</tr>
<?php unset($openvpn['i']);
$openvpn['i']['name'] = 'i';
$openvpn['i']['loop'] = is_array($_loop=$openvpn['Certificates']) ? count($_loop) : max(0, (int)$_loop); unset($_loop);
$openvpn['i']['show'] = true;
$openvpn['i']['max'] = $openvpn['i']['loop'];
$openvpn['i']['step'] = 1;
$openvpn['i']['start'] = $openvpn['i']['step'] > 0 ? 0 : $openvpn['i']['loop']-1;
if ($openvpn['i']['show']) {
$openvpn['i']['total'] = $openvpn['i']['loop'];
if ($openvpn['i']['total'] == 0)
$openvpn['i']['show'] = false;
} else
$openvpn['i']['total'] = 0;
if ($openvpn['i']['show']):
for ($openvpn['i']['index'] = $openvpn['i']['start'], $openvpn['i']['iteration'] = 1;
$openvpn['i']['iteration'] <= $openvpn['i']['total'];
$openvpn['i']['index'] += $openvpn['i']['step'], $openvpn['i']['iteration']++):
$openvpn['i']['rownum'] = $openvpn['i']['iteration'];
$openvpn['i']['index_prev'] = $openvpn['i']['index'] - $openvpn['i']['step'];
$openvpn['i']['index_next'] = $openvpn['i']['index'] + $openvpn['i']['step'];
$openvpn['i']['first'] = ($openvpn['i']['iteration'] == 1);
$openvpn['i']['last'] = ($openvpn['i']['iteration'] == $openvpn['i']['total']);
?>
<tr valign="top"<?php echo ''; ?><?php if ($openvpn['Certificates'][$openvpn['i']['index']]['Status'] == 'R'): ?><?php echo ' bgcolor="#FFDFDF"'; ?><?php elseif ($openvpn['Certificates'][$openvpn['i']['index']]['Status'] == 'E'): ?><?php echo ' bgcolor="#DFDFDF"'; ?><?php elseif ($openvpn['Certificates'][$openvpn['i']['index']]['Connected']): ?><?php echo ' bgcolor="#DFDFFF"'; ?><?php endif; ?><?php echo ''; ?>
>
<td style="border-bottom:1px groove gray" nowrap width="1%" rowspan="1" align="right" bgcolor="#DDFFCC"><?php echo $openvpn['i']['iteration']; ?>
</td>
<?php echo '<td style="border-bottom:1px groove gray">'; ?><?php if ($openvpn['Certificates'][$openvpn['i']['index']]['Connected']): ?><?php echo '<a title="connected"><font color="black"><b>#</b></font></a>'; ?><?php else: ?><?php echo '&nbsp;'; ?><?php endif; ?><?php echo '</td>'; ?>
<?php echo '<td style="border-bottom:1px groove gray"><a href="'; ?><?php echo $moduleurl; ?><?php echo '&uebergabe=5&uebergabe2='; ?><?php echo $openvpn['Certificates'][$openvpn['i']['index']]['Serial']; ?><?php echo '" title=\'View this certificate\'>'; ?><?php echo $openvpn['Certificates'][$openvpn['i']['index']]['CN']; ?><?php echo '</td>'; ?>
<?php echo '<td style="border-bottom:1px groove gray">'; ?><?php echo $openvpn['Certificates'][$openvpn['i']['index']]['Department']; ?><?php echo '</td>'; ?>
<?php echo '<td style="border-bottom:1px groove gray">'; ?><?php if ($openvpn['Certificates'][$openvpn['i']['index']]['Email'] != ''): ?><?php echo '<a href="mailto:'; ?><?php echo $openvpn['Certificates'][$openvpn['i']['index']]['Email']; ?><?php echo '">'; ?><?php echo $openvpn['Certificates'][$openvpn['i']['index']]['Email']; ?><?php echo '</a>'; ?><?php else: ?><?php echo '&nbsp;'; ?><?php endif; ?><?php echo '</td>'; ?>
<?php echo '<td style="border-bottom:1px groove gray" nowrap width="1%" align="right">'; ?><?php echo $openvpn['Certificates'][$openvpn['i']['index']]['Serial']; ?><?php echo '</td>'; ?>
<?php echo '<td style="border-bottom:1px groove gray" nowrap width="1%" align="right">'; ?><?php if ($openvpn['Certificates'][$openvpn['i']['index']]['Status'] == 'V'): ?><?php echo 'Valid'; ?><?php elseif ($openvpn['Certificates'][$openvpn['i']['index']]['Status'] == 'R'): ?><?php echo 'Revoked'; ?><?php elseif ($openvpn['Certificates'][$openvpn['i']['index']]['Status'] == 'E'): ?><?php echo 'Expired'; ?><?php else: ?><?php echo ''; ?><?php endif; ?><?php echo '</td>'; ?>
<?php echo '<td style="border-bottom:1px groove gray" bgcolor="#DDFFCC" nowrap="nowrap">[<a href="/Admin/Modules/VPNconfig/include/getfile.php?Action=DownloadCertificate&id='; ?><?php echo $openvpn['Certificates'][$openvpn['i']['index']]['Serial']; ?><?php echo '&Type=ZIP" title=\'Download All files in one archive\'>zip</a>]'; ?>
<?php echo '[<a href="/Admin/Modules/VPNconfig/include/getfile.php?Action=DownloadCertificate&id='; ?><?php echo $openvpn['Certificates'][$openvpn['i']['index']]['Serial']; ?><?php echo '&Type=CRT" title=\'Download Public Certificate\'>crt</a>]'; ?>
<?php echo '[<a href="/Admin/Modules/VPNconfig/include/getfile.php?Action=DownloadCertificate&id='; ?><?php echo $openvpn['Certificates'][$openvpn['i']['index']]['Serial']; ?><?php echo '&Type=KEY" title=\'Download Private Key\'>key</a>]'; ?>
<?php echo '[<a href="/Admin/Modules/VPNconfig/include/getfile.php?Action=DownloadCertificate&id='; ?><?php echo $openvpn['Certificates'][$openvpn['i']['index']]['Serial']; ?><?php echo '&Type=CSR" title=\'Download Certificate Request\'>csr</a>]</td>'; ?>
<?php echo '</tr>'; ?>
<?php endfor; else: ?>
<tr><td colspan="2" align="center"><i>There are no certificates made at the minute</i></td></tr>
<?php endif; ?>
</table>

View File

@ -0,0 +1,98 @@
<?php
include ($_SERVER["DOCUMENT_ROOT"]."/Site/checkadmin.php");
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/config.inc");
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/include/functions.inc");
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/include/openvpn-functions.inc");
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/include/openssl-functions.inc");
openvpn_load_server_conf ();
if (!isset ($openvpn['Server'])) html_error ("The OpenVPN server has no configuration file");
openvpn_load_status ();
if (!isset ($openvpn['Server']['Title'])) html_error ("The OpenVPN server has no status file");
openssl_load_database ();
openvpn_find_connected ();
$openvpn["Certificates"] = $openssl["Database"];
?>
<table border="0" width="100%" cellspacing="0" cellpadding="4">
<tr valign="top">
<td style="border-bottom:1px groove gray; border-top:1px groove gray" bgcolor="#DDFFCC"><b>#</b></td>
<td style="border-bottom:1px groove gray; border-top:1px groove gray" width="1%">&nbsp;</td>
<td style="border-bottom:1px groove gray; border-top:1px groove gray"><b>Common Name</b></td>
<td style="border-bottom:1px groove gray; border-top:1px groove gray"><b>Department</b></td>
<td style="border-bottom:1px groove gray; border-top:1px groove gray"><b>e-mail</b></td>
<td style="border-bottom:1px groove gray; border-top:1px groove gray"><b>Serial</b></td>
<td style="border-bottom:1px groove gray; border-top:1px groove gray"><b>Status</b></td>
<td style="border-bottom:1px groove gray; border-top:1px groove gray" bgcolor="#DDFFCC" width="5%"><b>Download</b></td>
</tr>
<?php unset($openvpn['i']);
$openvpn['i']['name'] = 'i';
$openvpn['i']['loop'] = is_array($_loop=$openvpn['Certificates']) ? count($_loop) : max(0, (int)$_loop); unset($_loop);
$openvpn['i']['show'] = true;
$openvpn['i']['max'] = $openvpn['i']['loop'];
$openvpn['i']['step'] = 1;
$openvpn['i']['start'] = $openvpn['i']['step'] > 0 ? 0 : $openvpn['i']['loop']-1;
if ($openvpn['i']['show']) {
$openvpn['i']['total'] = $openvpn['i']['loop'];
if ($openvpn['i']['total'] == 0)
$openvpn['i']['show'] = false;
} else
$openvpn['i']['total'] = 0;
if ($openvpn['i']['show']):
for ($openvpn['i']['index'] = $openvpn['i']['start'], $openvpn['i']['iteration'] = 1;
$openvpn['i']['iteration'] <= $openvpn['i']['total'];
$openvpn['i']['index'] += $openvpn['i']['step'], $openvpn['i']['iteration']++):
$openvpn['i']['rownum'] = $openvpn['i']['iteration'];
$openvpn['i']['index_prev'] = $openvpn['i']['index'] - $openvpn['i']['step'];
$openvpn['i']['index_next'] = $openvpn['i']['index'] + $openvpn['i']['step'];
$openvpn['i']['first'] = ($openvpn['i']['iteration'] == 1);
$openvpn['i']['last'] = ($openvpn['i']['iteration'] == $openvpn['i']['total']);
?>
<tr valign="top"<?php echo ''; ?><?php if ($openvpn['Certificates'][$openvpn['i']['index']]['Status'] == 'R'): ?><?php echo ' bgcolor="#FFDFDF"'; ?><?php elseif ($openvpn['Certificates'][$openvpn['i']['index']]['Status'] == 'E'): ?><?php echo ' bgcolor="#DFDFDF"'; ?><?php elseif ($openvpn['Certificates'][$openvpn['i']['index']]['Connected']): ?><?php echo ' bgcolor="#DFDFFF"'; ?><?php endif; ?><?php echo ''; ?>
>
<td style="border-bottom:1px groove gray" nowrap width="1%" rowspan="1" align="right" bgcolor="#DDFFCC"><?php echo $openvpn['i']['iteration']; ?>
</td>
<?php
echo '<td style="border-bottom:1px groove gray">';
if ($openvpn['Certificates'][$openvpn['i']['index']]['Connected'] && $openvpn['Certificates'][$openvpn['i']['index']]['Status'] != 'R')
{
echo '<a title="connected"><font color="black"><b>#</b></font></a>';
}
else
{
echo '&nbsp;';
}
echo '</td>'; ?>
<?php echo '<td style="border-bottom:1px groove gray"><a href="'; ?><?php echo $moduleurl; ?><?php echo '&uebergabe=5&uebergabe2='; ?><?php echo $openvpn['Certificates'][$openvpn['i']['index']]['Serial']; ?><?php echo '" title=\'View this certificate\'>'; ?><?php echo $openvpn['Certificates'][$openvpn['i']['index']]['CN']; ?><?php echo '</td>'; ?>
<?php echo '<td style="border-bottom:1px groove gray">'; ?><?php echo $openvpn['Certificates'][$openvpn['i']['index']]['Department']; ?><?php echo '</td>'; ?>
<?php echo '<td style="border-bottom:1px groove gray">'; ?><?php if ($openvpn['Certificates'][$openvpn['i']['index']]['Email'] != ''): ?><?php echo '<a href="mailto:'; ?><?php echo $openvpn['Certificates'][$openvpn['i']['index']]['Email']; ?><?php echo '">'; ?><?php echo $openvpn['Certificates'][$openvpn['i']['index']]['Email']; ?><?php echo '</a>'; ?><?php else: ?><?php echo '&nbsp;'; ?><?php endif; ?><?php echo '</td>'; ?>
<?php echo '<td style="border-bottom:1px groove gray" nowrap width="1%" align="right">'; ?><?php echo $openvpn['Certificates'][$openvpn['i']['index']]['Serial']; ?><?php echo '</td>'; ?>
<?php echo '<td style="border-bottom:1px groove gray" nowrap width="1%" align="right">'; ?><?php if ($openvpn['Certificates'][$openvpn['i']['index']]['Status'] == 'V'): ?><?php echo 'Valid'; ?><?php elseif ($openvpn['Certificates'][$openvpn['i']['index']]['Status'] == 'R'): ?><?php echo 'Revoked'; ?><?php elseif ($openvpn['Certificates'][$openvpn['i']['index']]['Status'] == 'E'): ?><?php echo 'Expired'; ?><?php else: ?><?php echo ''; ?><?php endif; ?><?php echo '</td>'; ?>
<?php echo '<td style="border-bottom:1px groove gray" bgcolor="#DDFFCC" nowrap="nowrap">[<a href="/Admin/Modules/VPNconfig/include/getfile.php?Action=DownloadCertificate&id='; ?><?php echo $openvpn['Certificates'][$openvpn['i']['index']]['Serial']; ?><?php echo '&Type=ZIP" title=\'Download All files in one archive\'>zip</a>]'; ?>
<?php echo '[<a href="/Admin/Modules/VPNconfig/include/getfile.php?Action=DownloadCertificate&id='; ?><?php echo $openvpn['Certificates'][$openvpn['i']['index']]['Serial']; ?><?php echo '&Type=CRT" title=\'Download Public Certificate\'>crt</a>]'; ?>
<?php echo '[<a href="/Admin/Modules/VPNconfig/include/getfile.php?Action=DownloadCertificate&id='; ?><?php echo $openvpn['Certificates'][$openvpn['i']['index']]['Serial']; ?><?php echo '&Type=KEY" title=\'Download Private Key\'>key</a>]'; ?>
<?php echo '[<a href="/Admin/Modules/VPNconfig/include/getfile.php?Action=DownloadCertificate&id='; ?><?php echo $openvpn['Certificates'][$openvpn['i']['index']]['Serial']; ?><?php echo '&Type=CSR" title=\'Download Certificate Request\'>csr</a>]</td>'; ?>
<?php echo '</tr>'; ?>
<?php endfor; else: ?>
<tr><td colspan="2" align="center"><i>There are no certificates made at the minute</i></td></tr>
<?php endif; ?>
</table>

View File

@ -0,0 +1,41 @@
<?php
$moduleurl = $_SERVER["REQUEST_URI"];
$ovpnconfdir = db_getconfval("ovpnconfdir");
$sqddir = db_getconfval("sqddir");
$ovpnconffile = db_getconfval("ovpnconffile");
// echo $ovpnconfdir."/".$ovpnconffile;
echo "
Change the OpenVPN Config...";
if ($_REQUEST["uebergabe3"] == "1")
{
$check_ok = "<b><br /><br />Die Daten wurden erfolgreich gespeichert!</b>";
echo $check_ok;
}
if ($_REQUEST["submit"] == "Speichern")
{
$fp = fopen($ovpnconfdir."/".$ovpnconffile,"w");
$data =$_REQUEST["inhalt"];
$data = str_replace("\r","",$data);
fputs($fp,$data);
fclose($fp);
echo "<meta http-equiv=\"Refresh\" content=\"4; url=".$moduleurl."&uebergabe3=1\">";
$check_ok = "<font color = 'red'><br /><br />Ihre Daten wurden erfolgreich geändert!<br>Bitte warten sie bis die Daten aktualisiert werden.</font>";
echo $check_ok;
}
echo "<form action=\"".$_SERVER["REQUEST_URI"]."\" method =\"post\">
<textarea name=\"inhalt\" rows=30 cols=120 wrap=\"virtual\">
";
include($ovpnconfdir."/".$ovpnconffile);
echo "
</textarea><br />
<input name=\"submit\" type=\"submit\" id=\"submit\" value=\"Speichern\" />
<input type=\"reset\" name=\"Submit2\" value=\"Reset\" />
</form>";
?>

View File

@ -0,0 +1,149 @@
<?php
$moduleurl = $_SERVER["REQUEST_URI"];
include ($_SERVER["DOCUMENT_ROOT"]."/Site/checkadmin.php");
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/config.inc");
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/include/functions.inc");
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/include/openvpn-functions.inc");
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/include/openssl-functions.inc");
openvpn_load_server_conf ();
if (!isset ($openvpn['Server'])) html_error ("The OpenVPN server has no configuration file");
openvpn_load_status ();
if (!isset ($openvpn['Server']['Title'])) html_error ("The OpenVPN server has no status file");
openssl_load_database ();
if(is_file("/var/run/openvpn.server.pid"))
{
echo "<b>VPN Server is currently: <font color=green>running</font></b><br />";
}
else
{
echo "<b>VPN Server is currently: <font color=red>stopped</font></b><br />";
}
if ($_REQUEST["uebergabe3"]=="1")
{
echo "<b>VPN Server restarted successfully!</b>";
echo "<meta http-equiv=\"Refresh\" content=\"1; url=".$moduleurl."&uebergabe=2\">";
}
if ($_REQUEST["uebergabe3"]=="2")
{
echo "<b>VPN Server started successfully!</b>";
echo "<meta http-equiv=\"Refresh\" content=\"1; url=".$moduleurl."&uebergabe=2\">";
}
if ($_REQUEST["uebergabe3"]=="3")
{
echo "<b>VPN Server stopped successfully!</b>";
echo "<meta http-equiv=\"Refresh\" content=\"1; url=".$moduleurl."&uebergabe=2\">";
}
?>
<table>
<tr>
<td>
<form action="/Admin/Modules/VPNconfig/include/restartvpn.php" method="post" >
<input type="hidden" name="path" size="50" value="<?php echo $moduleurl;?>" />
<input type="submit" value="Restart VPN Server" />
</form>
</td>
<?php
if(!is_file("/var/run/openvpn.server.pid"))
{
echo "
<td>
<form action=\"/Admin/Modules/VPNconfig/include/startvpn.php\" method=\"post\" >
<input type=\"hidden\" name=\"path\" size=\"50\" value=\"".$moduleurl."\" />
<input type=\"submit\" value=\"Start VPN Server\" />
</form>
</td>";
}
?>
<?php
if(is_file("/var/run/openvpn.server.pid"))
{
echo "
<td>
<form action=\"/Admin/Modules/VPNconfig/include/stopvpn.php\" method=\"post\" >
<input type=\"hidden\" name=\"path\" size=\"50\" value=\"".$moduleurl."\" />
<input type=\"submit\" value=\"Stop VPN Server\" />
</form>
</td>";
}
?>
</tr>
</table>
<br />
<table border="0" width="100%" cellspacing="0" cellpadding="4">
<tr valign="top">
<td colspan="2" style="border-top:1px groove black; border-bottom:1px groove black"><b>Server Settings</b></td></tr>
<tr valign="top">
<td nowrap width="1%" align="right" bgcolor="#DDFFCC">Mode</td>
<td><font color="darkgreen"><?php echo $openvpn['Server']['Mode']; ?>
</font></td>
</tr>
<tr valign="top">
<td nowrap width="1%" align="right" bgcolor="#DDFFCC">Uses device</td>
<td><font color="darkgreen"><?php echo $openvpn['Server']['Dev']; ?>
</font></td>
</tr>
<tr valign="top">
<td nowrap width="1%" align="right" bgcolor="#DDFFCC">Listens on</td>
<td><font color="darkgreen"><?php echo $openvpn['Server']['Local']; ?>
: <?php echo $openvpn['Server']['Port']; ?>
(<?php echo $openvpn['Server']['Proto']; ?>
)</font></td>
</tr>
<tr valign="top">
<td nowrap width="1%" align="right" bgcolor="#DDFFCC">Maximum Clients</td>
<td><font color="darkgreen"><?php echo $openvpn['Server']['MaxClients']; ?>
</font></td>
</tr>
<tr valign="top"><td colspan="2" style="border-top:1px groove black; border-bottom:1px groove black"><b>Certificate Files</b></td></tr>
<tr valign="top">
<td nowrap width="1%" align="right" bgcolor="#DDFFCC">DH</td>
<td><font color="darkgreen"><?php echo $openvpn['Server']['DH']['File']; ?>
</font> <?php echo ''; ?><?php if ($openvpn['Server']['DH']['Exists'] == true): ?><?php echo '[<a href="'; ?><?php echo $moduleurl; ?><?php echo '?Action=DownloadConfigFile&id=DH" title=\'DH File\'>download</a>]'; ?><?php else: ?><?php echo '[<font color="red">does not exist</font>]'; ?><?php endif; ?><?php echo ''; ?>
</td>
</tr>
<tr valign="top">
<td nowrap width="1%" align="right" bgcolor="#DDFFCC">CA Certificate</td>
<td><font color="darkgreen"><?php echo $openvpn['Openssl']['CA']['File']; ?>
</font> <?php echo ''; ?><?php if ($openvpn['Openssl']['CA']['Exists'] == true): ?><?php echo '[<a href="'; ?><?php echo $moduleurl; ?><?php echo '?Action=DownloadConfigFile&id=CA" title=\'Certificate Authority Public Certificate\'>download</a>]'; ?><?php else: ?><?php echo '[<font color="red">does not exist</font>]'; ?><?php endif; ?><?php echo ''; ?>
</td>
</tr>
<tr valign="top">
<td nowrap width="1%" align="right" bgcolor="#DDFFCC">Server Certificate</td>
<td><font color="darkgreen"><?php echo $openvpn['Server']['Certificate']['File']; ?>
</font> <?php echo ''; ?><?php if ($openvpn['Server']['Certificate']['Exists'] == true): ?><?php echo '[<a href="'; ?><?php echo $moduleurl; ?><?php echo '?Action=DownloadConfigFile&id=CRT" title=\'Server Public Certificate\'>download</a>]'; ?><?php else: ?><?php echo '[<font color="red">does not exist</font>]'; ?><?php endif; ?><?php echo ''; ?>
</td>
</tr>
<tr valign="top">
<td nowrap width="1%" align="right" bgcolor="#DDFFCC">Server Private Key</td>
<td><font color="darkgreen"><?php echo $openvpn['Server']['Private_Key']['File']; ?>
</font> <?php echo ''; ?><?php if ($openvpn['Server']['Private_Key']['Exists'] == true): ?><?php echo '[<a href="'; ?><?php echo $_SERVER['PHP_SELF']; ?><?php echo '?Action=DownloadConfigFile&id=KEY" title=\'Server Private Key\'>download</a>]'; ?><?php else: ?><?php echo '[<font color="red">does not exist</font>]'; ?><?php endif; ?><?php echo ''; ?>
</td>
</tr>
<tr valign="top">
<td nowrap width="1%" align="right" bgcolor="#DDFFCC">TLS Authentication</td>
<td><font color="darkgreen"><?php echo $openvpn['Server']['TLS_Auth']['File']; ?>
</font><?php echo ''; ?><?php if ($openvpn['Server']['DH']['Exists'] == true): ?><?php echo ', '; ?><?php if ($openvpn['Server']['TLS_Auth']['Key'] == 0): ?><?php echo 'server '; ?><?php else: ?><?php echo 'client '; ?><?php endif; ?><?php echo 'side [<a href="'; ?><?php echo $moduleurl; ?><?php echo '?Action=DownloadConfigFile&id=TLS" title=\'Server TLS Key\'>download</a>]'; ?><?php else: ?><?php echo '&nbsp;[<font color="red">does not exist</font>]'; ?><?php endif; ?><?php echo ''; ?>
</td>
</tr>
<tr valign="top">
<td nowrap width="1%" align="right" bgcolor="#DDFFCC">CRL Verify File</td>
<td><font color="darkgreen"><?php echo $openvpn['Server']['CRL_Verify']['File']; ?>
</font> <?php echo ''; ?><?php if ($openvpn['Server']['CRL_Verify']['Exists'] == true): ?><?php echo '[<a href="'; ?><?php echo $moduleurl; ?><?php echo '?Action=DownloadConfigFile&id=CRL" title=\'OPENSSL Certificate Revocation List\'>download</a>]'; ?><?php else: ?><?php echo '[<font color="red">does not exist</font>]'; ?><?php endif; ?><?php echo ''; ?>
</td>
</tr>
</table>

View File

@ -0,0 +1,251 @@
<?php
// ----------------------------------------------
function load_plugins ()
{
global $config;
if (isset ($config['Plugins']))
{
foreach ($config['Plugins'] as $PluginName => $PluginData)
{
// Check if the config.inc for a plugin exists
if (file_exists ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/plugins/". $PluginData['Folder'] ."/config.inc"))
{
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/plugins/". $PluginData['Folder'] ."/config.inc");
// Check if claimed inc files do exist
if (isset ($config['Plugins'][$PluginName]['Action']['Include']) &&
!file_exists ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/plugins/". $PluginData['Folder'] ."/".
$config['Plugins'][$PluginName]['Action']['Include']))
$config['Plugins'][$PluginName]['Action']['Include'] = NULL;
if (isset ($config['Plugins'][$PluginName]['Left']['Menu']) &&
!file_exists ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/plugins/". $PluginData['Folder'] ."/".
$config['Plugins'][$PluginName]['Left']['Menu']))
$config['Plugins'][$PluginName]['Left']['Menu'] = NULL;
if (isset ($config['Plugins'][$PluginName]['Left']['Status']) &&
!file_exists ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/plugins/". $PluginData['Folder'] ."/".
$config['Plugins'][$PluginName]['Left']['Status']))
$config['Plugins'][$PluginName]['Left']['Status'] = NULL;
}
}
}
}
// ----------------------------------------------
function seconds_string ($seconds, $periods = null)
{
$Wanted = '';
// Define time periods
if (!is_array ($periods))
{
$periods = array (
'years' => 31556926,
'months' => 2629743,
'weeks' => 604800,
'days' => 86400,
'hours' => 3600,
'minutes' => 60,
'seconds' => 1
);
}
// Wanted
if (empty ($seconds))
{ $Wanted = ''; }
else
{
// Loop
$seconds = (int) $seconds;
foreach ($periods as $period => $value)
{
$count = floor ($seconds / $value);
if ($count == 0)
continue;
elseif ($count == 1)
$Wanted .= ($count . ' ' . substr ($period, 0, strlen ($period) - 1) . ' ');
else
$Wanted .= ($count . ' ' . $period . ' ');
$seconds = $seconds % $value;
}
}
return rtrim ($Wanted);
}
// ----------------------------------------------
function chomp (&$string)
{
if (is_array ($string))
{
foreach ($string as $i => $val)
{ $endchar = chomp ($string[$i]); }
}
else
{
$endchar = substr ("$string", strlen("$string") - 1, 1);
if ($endchar == "\n")
{ $string = substr ("$string", 0, -1); }
}
return $endchar;
}
// ----------------------------------------------
function str_strip_spaces ($aline)
{
while (strpos ($aline, "\t") != FALSE) $aline = str_replace ("\t", ' ', $aline);
while (strpos ($aline, ' ') != FALSE) $aline = str_replace (' ', ' ', $aline);
return $aline;
}
// ----------------------------------------------
// Returns $afile only if it is the full name, or prefixed by $apath
function str_file_fullname ($apath, $afile)
{
if (substr ($afile, 0, 1) != '/')
$afile = ($apath . $afile);
return $afile;
}
// ----------------------------------------------
// Returns $afile only if it is the full name, or prefixed by $apath
function str_openssldata_to_string ($adata)
{
$Return = '';
$amonth = array ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
if (substr ($adata, -1, 1) == 'Z')
{
$Return = sprintf ("%s %d %s%02d, %02d:%02d:%02d",
$amonth [substr ($adata, 2, 2) - 1],
substr ($adata, 4, 2),
(substr ($adata, 0, 2) > 50 ? '19' : '20'),
substr ($adata, 0, 2),
substr ($adata, 6, 2),
substr ($adata, 8, 2),
substr ($adata, 10, 2));
}
return $Return;
}
// ----------------------------------------------
function str_get_sometag ($aline, $sometag)
{
if (eregi ($sometag, $aline, $anarray))
return $anarray[1];
else
return '';
}
// ----------------------------------------------
// Writes content into file
// Optionally sames old file into backup file.
// The Backup File has to reside on the same partition!
function writefile ($afile, $adata, $abackup = NULL)
{
// Move the old file into Backup one
if ($abackup != NULL)
{
if (file_exists ($afile))
{
if (file_exists ($abackup))
if (!unlink ($abackup))
exit;
if (!rename ($afile, $abackup))
exit;
}
}
$fp = fopen ($afile, "w", 0);
if (!$fp)
exit;
fputs ($fp, $adata);
fclose ($fp);
}
// ----------------------------------------------
// Guess the full file name
function if_file_exists (&$sFileName, $bFix = FALSE)
{
global $config;
if (strpos ($sFileName, '/') == FALSE)
{
$sLongFileName = $config['openvpn']['folder'] . $sFileName;
if (file_exists ($sLongFileName) && $bFix)
$sFileName = $sLongFileName;
}
return file_exists ($sFileName);
}
// ----------------------------------------------
function zlib_check_functions ()
{
$Result = '';
$ZLibs = array
(
'gzcompress'
);
foreach ($ZLibs as $Function)
{
$Result .= $Function . '<font color="black">:</font> ' . (function_exists ($Function) ?
'<font color="black">OK</font>' :
'<font color="red">DOES NOT EXIST</font>') . '<br>';
}
return $Result;
}
// ----------------------------------------------
function html_dump ($aname, $athing)
{
echo '<pre><b><font color="darkgreen">'. $aname .'</font></b>: ';
print_r ($athing);
echo "</pre><br>\n";
}
// ----------------------------------------------
function html_error ($amessage, $ifexit = true)
{
global $config;
echo $amessage;
if ($ifexit)
exit;
}
// ----------------------------------------------
function html_postredir ($url)
{
header ('HTTP/1.1 303 REDIRECT');
header ('Location: '. $url);
#header ('Status: 303'); // if 1st header generates 500, then commend it out and use this one as 2nd
}
// ----------------------------------------------
// ----------------------------------------------
function html_download ($sFile, $sName)
{
header ('Content-type: application/octet-stream');
header ('Content-Disposition: attachment; filename="'. $sName . '"');
readfile ($sFile);
}
// ----------------------------------------------
function html_download_data ($sData, $sName)
{
header ('Content-type: application/octet-stream');
header ('Content-Disposition: attachment; filename="'. $sName . '"');
echo $sData;
}
?>

View File

@ -0,0 +1,74 @@
<?php
session_start();
include($_SERVER["DOCUMENT_ROOT"]."/Site/checkadmin.php");
include($_SERVER["DOCUMENT_ROOT"]."/Site/mysql.php");
include_once ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/config.inc");
include_once ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/include/functions.inc");
include_once ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/include/openssl-functions.inc");
include_once ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/include/openvpn-functions.inc");
//#################################################################################################################
openvpn_load_server_conf ();
if (!isset ($openvpn['Server'])) html_error ("The OpenVPN server has no configuration file");
openvpn_load_status ();
if (!isset ($openvpn['Server']['Title'])) html_error ("The OpenVPN server has no status file");
openssl_load_database ();
// Check permissions :)
// ...
$GETidDEC[0] =$_REQUEST['id'];
$sExt = '.pem';
if (isset ($_REQUEST['Type']))
if ($_REQUEST['Type'] == 'CRT') $sExt = '.pem';
elseif ($_REQUEST['Type'] == 'KEY') $sExt = '.key';
elseif ($_REQUEST['Type'] == 'CSR') $sExt = '.csr';
elseif ($_REQUEST['Type'] == 'ZIP') $sExt = '.zip';
if ($sExt == '.zip')
{
include_once ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/include/zip.lib.php");
$zipData = new zipfile ();
// Add the certificate files
foreach (array ('.pem', '.key', '.csr') as $Ext2zip)
{
if ($config['Download']['ZIP'][$Ext2zip])
{
$File2zip = openssl_get_filename ($GETidDEC[0], $Ext2zip);
$File2name = basename ($File2zip, '.pem');
// Cheat the extension
if ($Ext2zip == '.pem') $File2name .= '.crt';
if (is_file ($File2zip))
$zipData->addFile (implode ('', file ($File2zip)), $File2name);
}
}
// Add the extra files
foreach ($config['Download']['ZIP']['Others'] as $File2zip)
{
if (is_file (db_getconfval("publicdown")."/". $File2zip))
$zipData->addFile (implode ('', file (db_getconfval("publicdown")."/". $File2zip)), $File2zip);
}
// Flush the ZIP file to the client
html_download_data ($zipData -> file (), openssl_hex_serial ($GETidDEC[0]) .'.zip');
//echo "<a href=getfile.php?dir=$zipData -> file () target=_blank>Direktlink zur Datei</a>
}
else
{
// echo "ID: " .$GETidDEC[0] . "Ext: " .$sExt;
if (($sCertificateFile = openssl_get_filename ($GETidDEC[0], $sExt)) == '') html_error ("Can't find requested file..FU");
// Cheat the extension
if ($sExt == '.pem') $sExt = '.crt';
// Download
html_download ($sCertificateFile, openssl_hex_serial ($GETidDEC[0]) . $sExt);
//html_dump ('$GLOBALS', $GLOBALS);
}
?>

View File

@ -0,0 +1,41 @@
<?php
$moduleurl = $_SERVER["REQUEST_URI"];
$ovpnconfdir = db_getconfval("ovpnconfdir");
$sqddir = db_getconfval("sqddir");
$ovpnconffile = db_getconfval("ovpnconffile");
// echo $ovpnconfdir."/".$ovpnconffile;
echo "
Change the OpenVPN Client IP list...";
if ($_REQUEST["uebergabe3"] == "1")
{
$check_ok = "<b><br /><br />Die Daten wurden erfolgreich gespeichert!</b>";
echo $check_ok;
}
if ($_REQUEST["submit"] == "Speichern")
{
$fp = fopen($sqddir."/ipp.txt","w");
$data =$_REQUEST["inhalt"];
$data = str_replace("\r","",$data);
fputs($fp,$data);
fclose($fp);
echo "<meta http-equiv=\"Refresh\" content=\"4; url=".$moduleurl."&uebergabe3=1\">";
$check_ok = "<font color = 'red'><br /><br />Ihre Daten wurden erfolgreich geändert!<br>Bitte warten sie bis die Daten aktualisiert werden.</font>";
echo $check_ok;
}
echo "<form action=\"".$_SERVER["REQUEST_URI"]."\" method =\"post\">
<textarea name=\"inhalt\" rows=20 cols=100 wrap=\"virtual\">
";
include($ovpnconfdir."/ipp.txt");
echo "
</textarea><br />
<input name=\"submit\" type=\"submit\" id=\"submit\" value=\"Speichern\" />
<input type=\"reset\" name=\"Submit2\" value=\"Reset\" />
</form>";
?>

View File

@ -0,0 +1,377 @@
<?php
// ----------------------------------------------
function openssl_check_functions ()
{
$Result = '';
$OpenSSLs = array
(
'openssl_csr_new',
'openssl_csr_sign',
'openssl_csr_export_to_file',
'openssl_pkey_new',
'openssl_pkey_get_private',
'openssl_pkey_export_to_file',
'openssl_x509_export_to_file'
);
foreach ($OpenSSLs as $Function)
{
$Result .= $Function . '<font color="black">:</font> ' . (function_exists ($Function) ?
'<font color="black">OK</font>' :
'<font color="red">DOES NOT EXIST</font>') . '<br>';
}
return $Result;
}
// ----------------------------------------------
function openssl_load_database ($afile = '')
{
global $config;
global $openssl;
$afile = ($afile == '' ? $config['openssl']['database'] : $afile);
$lines = file ($afile);
if (!is_array ($lines))
exit;
foreach ($lines as $line_num => $line)
{
chomp ($line);
$linetokens = explode ("\t", $line);
// Ensure that all the fields are set
if (count ($linetokens) == 6)
{
// Decode the openssl's database. See apps/apps.h
$openssl['Database'][] = array ('Status' => $linetokens[0],
'ExpDate' => $linetokens[1],
'RevDate' => $linetokens[2],
'Serial' => $linetokens[3],
'File' => $linetokens[4],
'Name' => $linetokens[5],
'Country' => openssl_get_country ($linetokens[5]),
'State' => openssl_get_state ($linetokens[5]),
'City' => openssl_get_city ($linetokens[5]),
'Company' => openssl_get_company ($linetokens[5]),
'Department' => openssl_get_department ($linetokens[5]),
'CN' => openssl_get_CN ($linetokens[5]),
'Email' => openssl_get_email ($linetokens[5])
);
}
}
}
// ----------------------------------------------
function openssl_write_database ($afile = '')
{
global $config;
global $openssl;
$afile = ($afile == '' ? $config['openssl']['database'] : $afile);
$atext = '';
for ($i = 0; $i < count ($openssl['Database']); $i++)
{
$atext .= ($atext == '' ? '' : "\n");
$atext .= $openssl['Database'][$i]['Status'] ."\t".
$openssl['Database'][$i]['ExpDate'] ."\t".
$openssl['Database'][$i]['RevDate'] ."\t".
$openssl['Database'][$i]['Serial'] ."\t".
$openssl['Database'][$i]['File'] ."\t".
$openssl['Database'][$i]['Name'];
}
writefile ($afile, $atext, $afile .'.old');
}
// ----------------------------------------------
function openssl_write_database_attr ($atext = '', $afile = '')
{
global $config;
global $openssl;
$afile = ($afile == '' ? $config['openssl']['database'] : $afile) .'.attr';
$atext = ($atext == '' ? "unique_subject = yes\n" : $atext);
if (file_exists ($afile))
{
ob_start ();
readfile ($afile);
$atext = ob_get_contents ();
ob_end_clean ();
}
writefile ($afile, $atext, $afile .'.old');
}
// ----------------------------------------------
// Returns the PEM file with spaces reduced and replaced to &nbsp;
function openssl_load_cert ($anid)
{
global $config;
do
{
$lines = file ($config['openssl']['pubfolder'] . $anid . '.pem');
if (!is_array ($lines))
{
$Return = '';
break;
}
foreach ($lines as $line_num => $line)
{
chomp ($line);
$Return[] = str_replace (' ', '&nbsp;', htmlspecialchars (str_replace (' ', ' ', $line)));
}
} while (FALSE);
return $Return;
}
// ----------------------------------------------
function openssl_load_serial ($afile = '')
{
global $config;
$afile = ($afile == '' ? $config['openssl']['serial'] : $afile);
$lines = file ($afile);
if (!is_array ($lines))
exit;
$Return = sscanf ($lines[0], "%X");
return $Return[0];
}
// ----------------------------------------------
function openssl_write_serial ($iNumber, $afile = '')
{
global $config;
$afile = ($afile == '' ? $config['openssl']['serial'] : $afile);
writefile ($afile, openssl_hex_serial ($iNumber) . "\n", $afile .'.old');
}
// ----------------------------------------------
// Supports up to 999,999 serials
function openssl_hex_serial ($iNumber)
{
if ($iNumber < 100)
$sString = sprintf ("%02X", $iNumber);
elseif ($iNumber < 10000)
$sString = sprintf ("%04X", $iNumber);
else
$sString = sprintf ("%06X", $iNumber);
return $sString;
}
// ----------------------------------------------
// Builds User Private Key, CSR and Public Certificate
function openssl_build_key (&$anoutput, $adn, $validdays = NULL)
{
global $config;
global $openssl;
$anoutput = '';
$Return = FALSE;
// Allow to override default value
$validdays = ($validdays == NULL ? $config['openssl']['default']['expiration'] : $validdays);
do
{
if (!isset ($adn) ||
!isset ($adn['countryName']) ||
!isset ($adn['stateOrProvinceName']) ||
!isset ($adn['localityName']) ||
!isset ($adn['organizationName']) ||
!isset ($adn['organizationalUnitName']) ||
!isset ($adn['commonName']) ||
!isset ($adn['emailAddress'])
)
{ $anoutput .= "- ERROR on ". __LINE__ ." line: incomplete DN information\n"; break; }
$anoutput .= "+ OK got the valid input\n";
// Get the new User Private Key
$UserPrivKey = openssl_pkey_new (array($config['openssl']['config'],0));
if ($UserPrivKey == FALSE)
{ $anoutput .= "- ERROR on ". (__LINE__ - 2) ." line (openssl_pkey_new):\n ". openssl_error_strings () ." (that might usually mean that the openssl.cnf file is unavailable)"; break; }
$anoutput .= "+ OK got the User Private Key\n";
// Generate the User Certificate Request
$UserReq = openssl_csr_new ($adn,
$UserPrivKey,
$config['openssl']['config']);
if ($UserReq == FALSE)
{ $anoutput .= "- ERROR on ". (__LINE__ - 4) ." line (openssl_csr_new):\n ". openssl_error_strings (); break; }
$anoutput .= "+ OK generated the User Certificate Request\n";
// Read the openssl serial
$CAserial = openssl_load_serial ($config['openssl']['serial']);
$anoutput .= "+ OK read current openssl serial (". openssl_hex_serial ($CAserial) .")\n";
$UserPubCertFile = $config['openssl']['pubfolder'] . openssl_hex_serial ($CAserial) .'.pem';
$UserCertReqFile = $config['openssl']['reqfolder'] . openssl_hex_serial ($CAserial) .'.csr';
$UserPrivKeyFile = $config['openssl']['prvfolder'] . openssl_hex_serial ($CAserial) .'.key';
// Read the openssl database
openssl_load_database ($config['openssl']['database']);
$anoutput .= "+ OK read the openssl database (". count ($openssl['Database']) ." items)\n";
// Get CA's Private Key
$CAPrivKey = openssl_pkey_get_private ($config['openssl']['CA']['priv']);
if ($CAPrivKey == FALSE)
{ $anoutput .= "- ERROR on ". (__LINE__ - 2) ." line (openssl_pkey_get_private)\n ". openssl_error_strings (); break; }
$anoutput .= "+ OK read the CA Private Key\n";
// Get a CA-signed cert that lasts for 1 year
$UserPubCert = openssl_csr_sign ($UserReq,
$config['openssl']['CA']['pub'],
$CAPrivKey,
$validdays,
$config['openssl']['config'],
$CAserial);
if ($UserPubCert == FALSE)
{ $anoutput .= "- ERROR on ". (__LINE__ - 7) ." line (openssl_csr_sign)\n ". openssl_error_strings (); break; }
$anoutput .= "+ OK signed the User Certificate Request with CA Private Key\n";
// Add the new row into openssl database
$openssl['Database'][] = array ('Status' => 'V',
'ExpDate' => date ('ymdHis',
time() +
date ('Z') +
($validdays * 24 * 60 * 60)) .'Z',
'RevDate' => '',
'Serial' => openssl_hex_serial ($CAserial),
'File' => openssl_hex_serial ($CAserial) .'.crt',
'Name' => openssl_make_name ($adn)
);
// Create files
$OldUMask = umask (0007);
// Write User Private Key
if (!openssl_pkey_export_to_file ($UserPrivKey, $UserPrivKeyFile, NULL, $config['openssl']['config']))
{ $anoutput .= "- ERROR on ". (__LINE__ - 1) ." line (openssl_pkey_export_to_file)\n ". openssl_error_strings () ." (That might mean that the key folder is not write enabled for www user)"; break; }
$anoutput .= "+ OK wrote User Private Key into file $UserPrivKeyFile\n";
// Write User Public Certificate
if (!openssl_x509_export_to_file ($UserPubCert, $UserPubCertFile, FALSE))
{ $anoutput .= "- ERROR on ". (__LINE__ - 1) ." line (openssl_x509_export_to_file)\n ". openssl_error_strings (); break; }
$anoutput .= "+ OK wrote User Public Certificate into file $UserPubCertFile\n";
// Write User Certificate Request
if (!openssl_csr_export_to_file ($UserReq, $UserCertReqFile))
{ $anoutput .= "- ERROR on ". (__LINE__ - 1) ." line (openssl_csr_export_to_file)\n ". openssl_error_strings (); break; }
$anoutput .= "+ OK wrote User Certificate Request into file $UserCertReqFile\n";
// Write new openssl database
openssl_write_database ($config['openssl']['database']);
openssl_write_database_attr ('', $config['openssl']['database']);
$anoutput .= "+ OK wrote new openssl database\n";
// Write new openssl serial
openssl_write_serial ($CAserial + 1, $config['openssl']['serial']);
$anoutput .= "+ OK wrote new openssl serial\n";
umask ($OldUMask);
$Return = openssl_hex_serial ($CAserial);
} while (FALSE);
return $Return;
}
// ----------------------------------------------
function openssl_error_strings ()
{
$sString = '';
while ($msg = openssl_error_string ())
$sString .= $msg ."\n";
return $sString;
}
// ----------------------------------------------
function openssl_make_name ($adn)
{
$sString = '';
if (strlen ($adn['countryName']) > 0) $sString .= '/C=' . $adn['countryName'];
if (strlen ($adn['stateOrProvinceName']) > 0) $sString .= '/ST=' . $adn['stateOrProvinceName'];
if (strlen ($adn['localityName']) > 0) $sString .= '/L=' . $adn['localityName'];
if (strlen ($adn['organizationName']) > 0) $sString .= '/O=' . $adn['organizationName'];
if (strlen ($adn['organizationalUnitName']) > 0) $sString .= '/OU=' . $adn['organizationalUnitName'];
if (strlen ($adn['commonName']) > 0) $sString .= '/CN=' . $adn['commonName'];
if (strlen ($adn['emailAddress']) > 0) $sString .= '/emailAddress='. $adn['emailAddress'];
return $sString;
}
// ----------------------------------------------
function openssl_get_country ($aline)
{ return str_get_sometag ($aline . '/', '\/C=([^/]*)\/'); }
// ----------------------------------------------
function openssl_get_state ($aline)
{ return str_get_sometag ($aline . '/', '\/ST=([^/]*)\/'); }
// ----------------------------------------------
function openssl_get_city ($aline)
{ return str_get_sometag ($aline . '/', '\/L=([^/]*)\/'); }
// ----------------------------------------------
function openssl_get_company ($aline)
{ return str_get_sometag ($aline . '/', '\/O=([^/]*)\/'); }
// ----------------------------------------------
function openssl_get_department ($aline)
{ return str_get_sometag ($aline . '/', '\/OU=([^/]*)\/'); }
// ----------------------------------------------
function openssl_get_CN ($aline)
{ return str_get_sometag ($aline . '/', '\/CN=([^/]*)\/'); }
// ----------------------------------------------
function openssl_get_email ($aline)
{ return str_get_sometag ($aline . '/', '\/emailAddress=([^/]*)\/'); }
// ----------------------------------------------
// Guess the full file name
function openssl_get_filename ($iSerial, $sExt)
{
global $config;
$sReturn = $config['openssl']['folder'] . openssl_hex_serial ($iSerial) . $sExt;
if (!file_exists ($sReturn))
{
$sReturn = $config['openssl']['pubfolder'] . openssl_hex_serial ($iSerial) . $sExt;
if (!file_exists ($sReturn))
{
$sReturn = $config['openssl']['reqfolder'] . openssl_hex_serial ($iSerial) . $sExt;
if (!file_exists ($sReturn))
{
$sReturn = $config['openssl']['prvfolder'] . openssl_hex_serial ($iSerial) . $sExt;
if (!file_exists ($sReturn))
{
$sReturn = '';
}
}
}
}
return $sReturn;
}
?>

View File

@ -0,0 +1,176 @@
<?php
// ----------------------------------------------
function openvpn_load_server_conf ()
{
global $config;
global $openvpn;
global $openssl;
$lines = file ($config['openvpn']['config']);
if (!is_array ($lines))
exit;
foreach ($lines as $line_num => $line)
{
chomp ($line);
$linetokens = explode (' ', str_strip_spaces ($line));
switch (strtolower ($linetokens[0]))
{
case 'local': $openvpn['Server']['Local'] = $linetokens[1]; break;
case 'proto': $openvpn['Server']['Proto'] = $linetokens[1]; break;
case 'port': $openvpn['Server']['Port'] = $linetokens[1]; break;
case 'dev': $openvpn['Server']['Dev'] = $linetokens[1]; break;
case 'mode': $openvpn['Server']['Mode'] = $linetokens[1]; break;
case 'max-clients': $openvpn['Server']['MaxClients'] = $linetokens[1]; break;
case 'status':
$openvpn['Server']['Status']['Exists'] = if_file_exists ($linetokens[1], true);
$openvpn['Server']['Status']['File'] = $linetokens[1];
break;
case 'status-version': $openvpn['Server']['Status']['Version'] = $linetokens[1]; break;
case 'ca':
$openssl['Server']['CA']['Exists'] = if_file_exists ($linetokens[1], true);
$openssl['Server']['CA']['File'] = $linetokens[1];
break;
case 'dh':
$openvpn['Server']['DH']['Exists'] = if_file_exists ($linetokens[1], true);
$openvpn['Server']['DH']['File'] = $linetokens[1];
break;
case 'cert':
$openvpn['Server']['Certificate']['Exists'] = if_file_exists ($linetokens[1], true);
$openvpn['Server']['Certificate']['File'] = $linetokens[1];
break;
case 'key':
$openvpn['Server']['Private_Key']['Exists'] = if_file_exists ($linetokens[1], true);
$openvpn['Server']['Private_Key']['File'] = $linetokens[1];
break;
case 'tls-auth':
$openvpn['Server']['TLS_Auth']['Exists'] = if_file_exists ($linetokens[1], true);
$openvpn['Server']['TLS_Auth']['File'] = $linetokens[1];
$openvpn['Server']['TLS_Auth']['Key'] = $linetokens[2];
break;
case 'crl-verify':
$openvpn['Server']['CRL_Verify']['Exists'] = if_file_exists ($linetokens[1], true);
$openvpn['Server']['CRL_Verify']['File'] = $linetokens[1];
break;
}
}
}
// ----------------------------------------------
function openvpn_load_status ()
{
global $config;
global $openvpn;
$stop_reading = FALSE;
if (!isset ($openvpn['Server']['Status']['File']))
{
echo "Config file not found";
exit;
}
$lines = file (str_file_fullname ($config['openvpn']['folder'], $openvpn['Server']['Status']['File']));
if (!is_array ($lines))
{
echo "Status file empty";
exit;
}
foreach ($lines as $line_num => $line)
{
chomp ($line);
$linetokens = explode (',', $line);
if ($linetokens[0] == 'TITLE')
$openvpn['Server']['Title'] = $linetokens[1];
else if ($linetokens[0] == 'TIME')
{
$openvpn['Server']['DateTime'] = $linetokens[1];
$openvpn['Server']['Time'] = $linetokens[2];
}
else if ($linetokens[0] == 'HEADER' && $linetokens[1] == 'CLIENT_LIST')
{
// We will need to know what field is what ?
}
else if ($linetokens[0] == 'HEADER' && $linetokens[1] == 'ROUTING_TABLE')
{
// We will need to know what field is what ?
}
else if ($linetokens[0] == 'CLIENT_LIST')
{
$openvpn['Client'][] = array ('CN' => str_replace ('_', ' ', $linetokens[1]),
'REALADDR' => $linetokens[2],
'VIRTADDR' => $linetokens[3],
'BYTESRCV' => $linetokens[4],
'BYTESSND' => $linetokens[5],
'SINCE' => $linetokens[6],
'SINCEUT' => $linetokens[7],
'Seconds_Ago' => seconds_string (time () - $linetokens[7])
);
}
else if ($linetokens[0] == 'ROUTING_TABLE')
{
$openvpn['Routing'][] = array ('VIRTADDR' => $linetokens[1],
'CN' => str_replace ('_', ' ', $linetokens[2]),
'REALADDR' => $linetokens[3],
'LAST' => $linetokens[4],
'Seconds_Ago' => seconds_string (time () - $linetokens[4])
);
}
}
}
// ----------------------------------------------
/*function openvpn_find_connected ()
{
global $openvpn;
global $openssl;
// find who is connected
if (isset ($openvpn['Client']))
$cnconnected = count ($openvpn['Client']);
else
$cnconnected = 0;
$cntotal = count ($openssl['Database']);
if ($cnconnected > 0)
for ($i = 0; $i < $cnconnected; $i++)
for ($j = 0; $j < $cntotal; $j++)
if ($openvpn['Client'][$i]['CN'] == $openssl['Database'][$j]['CN'])
{
$openssl['Database'][$j]['Connected'] = true;
break;
}
}*/
function openvpn_find_connected ()
{
global $openvpn;
global $openssl;
// find who is connected
if (isset ($openvpn['Client']))
$cnconnected = count ($openvpn['Client']);
else
$cnconnected = 0;
$cntotal = count ($openssl['Database']);
if ($cnconnected > 0)
{
for ($i = 0; $i < $cntotal; $i++)
{
for ($j = 0; $j < $cnconnected; $j++)
{
if ($openvpn['Client'][$j]['CN'] == $openssl['Database'][$i]['CN'] && $openssl['Database'][$i]['Status'] != "R")
{
$openssl['Database'][$i]['Connected'] = true;
// break;
}
}
}
}
}
?>

View File

@ -0,0 +1,11 @@
<?php
session_start();
include ($_SERVER["DOCUMENT_ROOT"]."/Site/checkadmin.php");
include ($_SERVER["DOCUMENT_ROOT"]."/Config/_siteconfig_.php");
$path = $_REQUEST["path"];
// Write to file vpnid_man
exec("touch /var/vpn/openvpn_restart");
header ("Location: ".$path."&uebergabe=2&uebergabe3=1");
?>

View File

@ -0,0 +1,11 @@
<?php
session_start();
include ($_SERVER["DOCUMENT_ROOT"]."/Site/checkadmin.php");
include ($_SERVER["DOCUMENT_ROOT"]."/Config/_siteconfig_.php");
$path = $_REQUEST["path"];
// Write to file vpnid_man
exec("touch /var/vpn/openvpn_start");
header ("Location: ".$path."&uebergabe=2&uebergabe3=2");
?>

View File

@ -0,0 +1,108 @@
<?php
include ($_SERVER["DOCUMENT_ROOT"]."/Site/checkadmin.php");
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/config.inc");
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/include/functions.inc");
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/include/openvpn-functions.inc");
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/include/openssl-functions.inc");
openvpn_load_server_conf ();
if (!isset ($openvpn['Server'])) html_error ("The OpenVPN server has no configuration file");
openvpn_load_status ();
if (!isset ($openvpn['Server']['Title'])) html_error ("The OpenVPN server has no status file");
openssl_load_database ();
?>
<table border="0" cellspacing="0" cellpadding="0">
<colgroup>
<col width="200">
<col>
</colgroup>
<tr>
<td valign="top" width="200">
<table border="0" cellpadding="10" cellspacing="0">
<tr>
<td style="border-top:1px groove black; border-bottom:1px groove black;border-left:1px groove black;border-right:1px groove black;">
<b>Server Status</b>
</td>
</tr>
<tr>
<td style="border-right:1px groove black; border-left:1px groove black;">
The OpenVPN server version is <b><font color="darkgreen"><?php echo $openvpn['Server']['Title'];?></font></b><br>
</td>
</tr>
<tr>
<td style="border-right:1px groove black; border-left:1px groove black;">
The last status was recorded at <b><font color="darkgreen"><?php echo $openvpn['Server']['DateTime'];?> </font></b>
</td>
</tr>
<tr>
<td style="border-right:1px groove black; border-left:1px groove black;" nowrap width="5%">
<?php echo '';
if ($openvpn['Client'] == 0)
echo 'No clients connected</b>';
elseif ($openvpn['Client'] == 1)
echo 'Connected <b><font color="darkgreen">1</font></b> client';
elseif ($openvpn['Client'] > 1)
{
echo 'Connected <b><font color="darkgreen">';
echo count($openvpn['Client']);
echo '</font></b> clients';
}?>
</td>
</tr>
<tr>
<td style="border-right:1px groove black; border-bottom:1px groove black; border-left:1px groove black;">
OpenSSL has <b><font color="darkgreen">
<?php
if (count($openssl['Database']) == 0)
echo 'no certificates</font></b>';
elseif (count($openssl['Database']) == 1)
{
echo '1</font></b> <a href="';
echo $moduleurl;
echo '&uebergabe=3">certificate</a>';
}
elseif (count($openssl['Database']) > 1)
{
echo '';
echo count($openssl['Database']);
echo '</font></b> <a href="';
echo $moduleurl;
echo '&uebergabe=3">certificates</a>';
}?>
</b>
</td>
</tr>
</table>
</td>
<td valign="top">
<table border="0" width="90%" cellspacing="0" cellpadding="4" align="center">
<tr valign="top">
<td style="border-bottom:1px groove gray; border-top:1px groove gray" bgcolor="#DDFFCC"><b>#</b></td>
<td style="border-bottom:1px groove gray; border-top:1px groove gray" nowrap><b>Common Name</td>
<td style="border-bottom:1px groove gray; border-top:1px groove gray" nowrap><b>Connected since</td>
<td style="border-bottom:1px groove gray; border-top:1px groove gray" nowrap><b>Connected Time</td>
<td style="border-bottom:1px groove gray; border-top:1px groove gray" nowrap><b>Virtual Address</b></td>
<td style="border-bottom:1px groove gray; border-top:1px groove gray" nowrap><b>Real Address</b></td>
<td style="border-bottom:1px groove gray; border-top:1px groove gray" nowrap><b>Upload</b></td>
<td style="border-bottom:1px groove gray; border-top:1px groove gray" nowrap><b>Download</b></td>
</tr>
<?php
$count = 0;
foreach ($openvpn['Client'] as $client)
{
$count++;
echo '<tr>
<td>'.$count.'</td>
<td>'.$client["CN"].'</td>
<td>'.$client["SINCE"].'</td>
<td>'.$client["Seconds_Ago"].'</td>
<td>'.$client["VIRTADDR"].'</td>
<td>'.$client["REALADDR"].'</td>
<td>'.$client["BYTESRCV"].'</td>
<td>'.$client["BYTESSND"].'</td>
</tr>';
}
?>
</table>
</td>
</tr>
</table>

View File

@ -0,0 +1,11 @@
<?php
session_start();
include ($_SERVER["DOCUMENT_ROOT"]."/Site/checkadmin.php");
include ($_SERVER["DOCUMENT_ROOT"]."/Config/_siteconfig_.php");
$path = $_REQUEST["path"];
// Write to file vpnid_man
exec("touch /var/vpn/openvpn_stop");
header ("Location: ".$path."&uebergabe=2&uebergabe3=3");
?>

View File

@ -0,0 +1,31 @@
<?php
include ($_SERVER["DOCUMENT_ROOT"]."/Site/checkadmin.php");
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/config.inc");
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/include/functions.inc");
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/include/openvpn-functions.inc");
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/include/openssl-functions.inc");
openvpn_load_server_conf ();
if (!isset ($openvpn['Server'])) html_error ("The OpenVPN server has no configuration file");
openvpn_load_status ();
if (!isset ($openvpn['Server']['Title'])) html_error ("The OpenVPN server has no status file");
openssl_load_database ();
openvpn_find_connected ();
?>
<table border="0" width="100%" cellspacing="0" cellpadding="4">
<tr valign="top">
<td colspan="2" style="border-top:1px groove black; border-bottom:1px groove black"><b>PHP Libraries</b></td></tr>
<tr valign="top">
<td nowrap width="1%" align="right" bgcolor="#DDFFCC" style="border-bottom:1px groove black">PHP5 OpenSSL Functions</td>
<td style="border-bottom:1px groove black"><font color="darkgreen"><?php echo openssl_check_functions (); ?>
</font></td>
</tr>
<tr valign="top">
<td nowrap width="1%" align="right" bgcolor="#DDFFCC" style="border-bottom:1px groove black">PHP5 ZLib Functions</td>
<td style="border-bottom:1px groove black"><font color="darkgreen"><?php echo zlib_check_functions ();?>
</font></td>
</tr>
</table>

View File

@ -0,0 +1,128 @@
<?php
include ($_SERVER["DOCUMENT_ROOT"]."/Site/checkadmin.php");
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/config.inc");
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/include/functions.inc");
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/include/openvpn-functions.inc");
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/include/openssl-functions.inc");
openvpn_load_server_conf ();
if (!isset ($openvpn['Server'])) html_error ("The OpenVPN server has no configuration file");
openvpn_load_status ();
if (!isset ($openvpn['Server']['Title'])) html_error ("The OpenVPN server has no status file");
openssl_load_database ();
openvpn_find_connected ();
$openvpn["Certificates"] = $openssl["Database"];
$openvpn["Seconds_Ago"] = time () - $openvpn['Server']['Time'];
$cntotal = count ($openssl['Database']);
$GETid = $cert;
$GETidDEC = sscanf ($GETid, '%X');
for ($j = 0; $j < $cntotal; $j++)
if ($openssl['Database'][$j]['Serial'] == $GETid)
{
$openssl['Database'][$j]['ExpDate'] = str_openssldata_to_string ($openssl['Database'][$j]['ExpDate']);
$openssl['Database'][$j]['RevDate'] = str_openssldata_to_string ($openssl['Database'][$j]['RevDate']);
$openvpn['Certificate'] = $openssl['Database'][$j];
$openvpn['CertificateFileCRT'] = openssl_get_filename ($GETidDEC[0], '.pem');
$openvpn['CertificateFileKEY'] = openssl_get_filename ($GETidDEC[0], '.key');
$openvpn['CertificateFileCSR'] = openssl_get_filename ($GETidDEC[0], '.csr');
break;
}
?>
<table border="0" width="100%" cellspacing="0" cellpadding="4">
<tr valign="top"><td colspan="2" style="border-top:1px groove black; border-bottom:1px groove black"><b>Certificate Information</b></td></tr>
<tr valign="top">
<td nowrap width="1%" align="right" bgcolor="#DDFFCC">Serial</td>
<td><font color="blue"><?php echo $openvpn['Certificate']['Serial']; ?>
</font></td>
</tr>
<tr valign="top">
<td nowrap width="1%" align="right" bgcolor="#DDFFCC">Status</td>
<?php echo '<td><font color="blue">'; ?><?php if ($openvpn['Certificate']['Status'] == 'V'): ?><?php echo 'Valid'; ?><?php elseif ($openvpn['Certificate']['Status'] == 'R'): ?><?php echo 'Revoked'; ?><?php elseif ($openvpn['Certificate']['Status'] == 'E'): ?><?php echo 'Expired'; ?><?php endif; ?><?php echo ''; ?><?php if ($openvpn['Certificate']['Connected']): ?><?php echo ', Now connected'; ?><?php endif; ?><?php echo '</font></td>'; ?>
</tr>
<tr valign="top">
<td nowrap width="1%" align="right" bgcolor="#DDFFCC" style="border-bottom:1px groove black"><?php echo ''; ?><?php if ($openvpn['Certificate']['Status'] == 'V'): ?><?php echo 'Expiration'; ?><?php elseif ($openvpn['Certificate']['Status'] == 'R'): ?><?php echo 'Revoked'; ?><?php else: ?><?php echo '&nbsp;'; ?><?php endif; ?><?php echo '</td>'; ?>
<td style="border-bottom:1px groove black"><font color="darkgreen"><?php echo ''; ?><?php if ($openvpn['Certificate']['Status'] == 'V'): ?><?php echo ''; ?><?php echo $openvpn['Certificate']['ExpDate']; ?><?php echo ''; ?><?php elseif ($openvpn['Certificate']['Status'] == 'R'): ?><?php echo ''; ?><?php echo $openvpn['Certificate']['RevDate']; ?><?php echo ''; ?><?php else: ?><?php echo '&nbsp;'; ?><?php endif; ?><?php echo '</font></td>'; ?>
</tr>
<tr valign="top">
<td nowrap width="1%" align="right" bgcolor="#DDFFCC">Common Name</td>
<td><font color="blue"><?php echo $openvpn['Certificate']['CN']; ?>
</font></td>
</tr>
<tr valign="top">
<td nowrap width="1%" align="right" bgcolor="#DDFFCC" style="border-bottom:1px groove black">e-mail</td>
<td style="border-bottom:1px groove black"><font color="darkgreen"><?php echo ''; ?><?php if ($openvpn['Certificate']['Email'] != ''): ?><?php echo '<a href="mailto:'; ?><?php echo $openvpn['Certificate']['Email']; ?><?php echo '">'; ?><?php echo $openvpn['Certificate']['Email']; ?><?php echo '</a>'; ?><?php else: ?><?php echo '&nbsp;'; ?><?php endif; ?><?php echo '</font></td>'; ?>
</tr>
<tr valign="top">
<td nowrap width="1%" align="right" bgcolor="#DDFFCC">Country</td>
<td><font color="darkgreen"><?php echo $openvpn['Certificate']['Country']; ?>
</font></td>
</tr>
<tr valign="top">
<td nowrap width="1%" align="right" bgcolor="#DDFFCC">State or Province</td>
<td><font color="darkgreen"><?php echo $openvpn['Certificate']['State']; ?>
</font></td>
</tr>
<tr valign="top">
<td nowrap width="1%" align="right" bgcolor="#DDFFCC">City</td>
<td><font color="darkgreen"><?php echo $openvpn['Certificate']['City']; ?>
</font></td>
</tr>
<tr valign="top">
<td nowrap width="1%" align="right" bgcolor="#DDFFCC">Company</td>
<td><font color="darkgreen"><?php echo $openvpn['Certificate']['Company']; ?>
</font></td>
</tr>
<tr valign="top">
<td nowrap width="1%" align="right" bgcolor="#DDFFCC">Department</td>
<td><font color="darkgreen"><?php echo $openvpn['Certificate']['Department']; ?>
</font></td>
</tr>
<tr valign="top"><td colspan="2" style="border-top:1px groove black; border-bottom:1px groove black"><b>Certificate Files</b></td></tr>
<tr valign="top">
<td nowrap width="1%" align="right" bgcolor="#DDFFCC">Public Certificate</td>
<td><?php echo ''; ?><?php if ($openvpn['CertificateFileCRT'] != ''): ?><?php echo '<a href="/Admin/Modules/VPNconfig/include/getfile.php?Action=DownloadCertificate&id='; ?><?php echo $openvpn['Certificate']['Serial']; ?><?php echo '&Type=CRT" title=\'Download Public Certificate\'>Download</a>'; ?><?php else: ?><?php echo '&lt;File not found&gt;'; ?><?php endif; ?><?php echo ''; ?>
</td>
</tr>
<tr valign="top">
<td nowrap width="1%" align="right" bgcolor="#DDFFCC">Private Key</td>
<td><?php echo ''; ?><?php if ($openvpn['CertificateFileKEY'] != ''): ?><?php echo '<a href="g/Admin/Modules/VPNconfig/include/getfile.php?Action=DownloadCertificate&id='; ?><?php echo $openvpn['Certificate']['Serial']; ?><?php echo '&Type=KEY" title=\'Download Private Key\'>Download</a>'; ?><?php else: ?><?php echo '&lt;File not found&gt;'; ?><?php endif; ?><?php echo ''; ?>
</td>
</tr>
<tr valign="top">
<td style="border-bottom:1px groove black" nowrap width="1%" align="right" bgcolor="#DDFFCC">Certificate Request</td>
<td style="border-bottom:1px groove black"><?php echo ''; ?><?php if ($openvpn['CertificateFileCSR'] != ''): ?><?php echo '<a href=/Admin/Modules/VPNconfig/include/getfile.php?Action=DownloadCertificate&id='; ?><?php echo $openvpn['Certificate']['Serial']; ?><?php echo '&Type=CSR" title=\'Download Certificate Request\'>Download</a>'; ?><?php else: ?><?php echo '&lt;File not found&gt;'; ?><?php endif; ?><?php echo ''; ?>
</td>
</tr>
<tr valign="top">
<td style="border-bottom:1px groove black" nowrap width="1%" align="right" bgcolor="#DDFFCC">Archive</td>
<td style="border-bottom:1px groove black"><?php echo ''; ?><?php if ($openvpn['CertificateFileCRT'] != '' || $openvpn['CertificateFileKEY'] != '' || $openvpn['CertificateFileCSR'] != ''): ?><?php echo '<a href="/Admin/Modules/VPNconfig/include/getfile.php?Action=DownloadCertificate&id='; ?><?php echo $openvpn['Certificate']['Serial']; ?><?php echo '&Type=ZIP" title=\'Download all files in one archive\'>Download</a>'; ?><?php else: ?><?php echo '&lt;File not found&gt;'; ?><?php endif; ?><?php echo ''; ?>
</td>
</tr>
</table>

View File

@ -0,0 +1,113 @@
<?php
/*
* Copyrights are following:
*
* Eric Mueller <eric@themepark.com>
* http://www.zend.com/codex.php?id=535&single=1
*
* Denis125 <webmaster@atlant.ru>
* http://www.zend.com/codex.php?id=470&single=1
*
* Peter Listiak <mlady@users.sourceforge.net>
*
* PK ZIP
* http://www.pkware.com/appnote.txt
*/
class zipfile
{
var $datasec = array ();
var $ctrl_dir = array ();
var $eof_ctrl_dir = "\x50\x4b\x05\x06\x00\x00\x00\x00";
var $old_offset = 0;
function unix2DosTime ($unixtime = 0)
{
$timearray = ($unixtime == 0) ?
getdate () :
getdate ($unixtime);
if ($timearray['year'] < 1980)
{
$timearray['year'] = 1980;
$timearray['mon'] = 1;
$timearray['mday'] = 1;
$timearray['hours'] = 0;
$timearray['minutes'] = 0;
$timearray['seconds'] = 0;
}
return (($timearray['year'] - 1980) << 25) |
($timearray['mon'] << 21) |
($timearray['mday'] << 16) |
($timearray['hours'] << 11) |
($timearray['minutes'] << 5) |
($timearray['seconds'] >> 1);
}
function addFile ($data, $name, $time = 0)
{
$name = str_replace ('\\', '/', $name);
$dtime = dechex ($this->unix2DosTime ($time));
$hexdtime = '\x' . $dtime[6] . $dtime[7] .
'\x' . $dtime[4] . $dtime[5] .
'\x' . $dtime[2] . $dtime[3] .
'\x' . $dtime[0] . $dtime[1];
eval ('$hexdtime = "' . $hexdtime . '";');
$unc_len = strlen ($data);
$crc = crc32 ($data);
$zdata = gzcompress ($data);
$zdata = substr (substr ($zdata, 0, strlen ($zdata) - 4), 2);
$c_len = strlen ($zdata);
$fr = "\x50\x4b\x03\x04\x14\x00\x00\x00\x08\x00" .
$hexdtime .
pack ('V', $crc) .
pack ('V', $c_len) .
pack ('V', $unc_len) .
pack ('v', strlen ($name)) .
pack ('v', 0) .
$name .
$zdata .
pack ('V', $crc) .
pack ('V', $c_len) .
pack ('V', $unc_len);
$this -> datasec[] = $fr;
$cdrec = "\x50\x4b\x01\x02\x00\x00\x14\x00\x00\x00\x08\x00" .
$hexdtime .
pack ('V', $crc) .
pack ('V', $c_len) .
pack ('V', $unc_len) .
pack ('v', strlen ($name)) .
pack ('v', 0 ) .
pack ('v', 0 ) .
pack ('v', 0 ) .
pack ('v', 0 ) .
pack ('V', 32 ) .
pack ('V', $this -> old_offset ) .
$name;
$this -> old_offset += strlen ($fr);
$this -> ctrl_dir[] = $cdrec;
}
function file ()
{
$data = implode ('', $this -> datasec);
$ctrldir = implode ('', $this -> ctrl_dir);
return $data .
$ctrldir .
$this -> eof_ctrl_dir .
pack ('v', sizeof ($this -> ctrl_dir)) .
pack ('v', sizeof ($this -> ctrl_dir)) .
pack ('V', strlen ($ctrldir)) .
pack ('V', strlen ($data)) .
"\x00\x00";
}
}
?>

View File

@ -0,0 +1,65 @@
<?php
$moduleurl = $_SERVER["REQUEST_URI"];
$urlcut = strpos($moduleurl, "&");
if($urlcut > 0)
{
$moduleurl = substr($moduleurl,0,$urlcut);
}
else
{
if(strpos($moduleurl, "?") == 0)
{
$moduleurl = $_SERVER["REQUEST_URI"]."?site=1";
}
}
include ($_SERVER["DOCUMENT_ROOT"]."/Site/checkadmin.php");
//include_once ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/config.inc");
//include_once ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/include/functions.inc");
$mode = $_REQUEST["uebergabe"];
$cert = $_REQUEST["uebergabe2"];
echo" <p><a href=\"".$moduleurl."&uebergabe=0\">Home</a>
| <a href=\"".$moduleurl."&uebergabe=1\">Status</a>
| <a href=\"".$moduleurl."&uebergabe=2\">Config</a>
| <a href=\"".$moduleurl."&uebergabe=3\">Certificates</a>
| <a href=\"".$moduleurl."&uebergabe=6\">IP-List</a>
| <a href=\"".$moduleurl."&uebergabe=7\">Config-Editor</a>
| <a href=\"".$moduleurl."&uebergabe=4\">Systemcheck</a><hr /><br />";
switch($mode)
{
case 1:
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/include/status.php");
break;
case 2:
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/include/config.php");
break;
case 3:
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/include/certs.php");
break;
case 4:
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/include/sys.php");
break;
case 5:
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/include/viewcert.php");
break;
case 6:
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/include/ipp.php");
break;
case 7:
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/VPNconfig/include/config-edit.php");
break;
default:
echo"<h1><b>VPN Configuration</b></h1>
<h2>Choose an action:</h2>
<p># <a href=\"".$moduleurl."&uebergabe=1\">Status</a></p>
<p># <a href=\"".$moduleurl."&uebergabe=2\">Config</a></p>
<p># <a href=\"".$moduleurl."&uebergabe=3\">Certificates</a></p>
<p># <a href=\"".$moduleurl."&uebergabe=6\">IP-List</a></p>
<p># <a href=\"".$moduleurl."&uebergabe=7\">Config Editor</a></p>
<p># <a href=\"".$moduleurl."&uebergabe=4\">Systemcheck</a></p><br />";
break;
}
?>

50
Admin/index.php Executable file
View File

@ -0,0 +1,50 @@
<?php
include ("../Site/admin_header.php");
$page = $_REQUEST["site"];
$page_footer = $_REQUEST["bsite"];
$uebergabe = $_REQUEST["uebergabe"];
$uebergabe2 = $_REQUEST["uebergabe2"];
$uebergabe3 = $_REQUEST["uebergabe3"];
$uebergabe4 = $_REQUEST["uebergabe4"];
$count = 0;
while (list ($attr, $value) = each ($_REQUEST))
{
$params[$count] = $attr."=".$value;
$count++;
}
if (isset($page))
{
if($page == "lf")
{
include ("../Site/login_formular_admin.php");
}
else
{
$modul = $SITE_MODULES_ADMIN[$page-1];
$len = strlen($modul);
$cut = strpos($modul, "#");
$modpage = substr($modul,$cut+1, $len-$cut);
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/".$modpage."/index.php");
}
}
else if (isset($page_footer))
{
$modul = $SITE_MODULES_FOOTER[$page_footer-1];
$len = strlen($modul);
$cut = strpos($modul, "#");
$modpage = substr($modul,$cut+1, $len-$cut);
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/".$modpage."/index.php");
}
else
{
$modul = $SITE_MODULES[0];
$len = strlen($modul);
$cut = strpos($modul, "#");
$modpage = substr($modul,$cut+1, $len-$cut);
include ($_SERVER["DOCUMENT_ROOT"]."/Admin/Modules/".$modpage."/index.php");
}
include ("../Site/footer.php");
?>

5
Config/_dbconfig_.php Executable file
View File

@ -0,0 +1,5 @@
<?php
$MYSQL_HOST="localhost";
$MYSQL_USER="vpnmanager";
$MYSQL_PASS="849XpCHBffKWvNaJ";
$MYSQL_DATABASE="vpnmanager";?>

48
Config/_siteconfig_.php Executable file
View File

@ -0,0 +1,48 @@
<?php
include ($_SERVER["DOCUMENT_ROOT"]."/Site/mysql.php");
//Configure your Site Layout/Modules
//
//Style:
//Tab Name#Modulefolder
//##############################################################################
//Add your changes here:
//Header Modules -----------------------------
$SITE_MODULES[0]="Home#Home"; // Home Module required!
$SITE_MODULES[1]="Contact#Contact";
$SITE_MODULES[2]="Services#Services";
$SITE_MODULES[3]="Server Traffic#ServerTraffic";
$SITE_MODULES[4]="Downloads#Downloads";
$SITE_MODULES[5]="Forum#Forum";
$SITE_MODULES[6]="Userinfo#UserControl";
//Header Modules Admin -----------------------
$SITE_MODULES_ADMIN[0]="Home#Home"; // Home Module required!
//$SITE_MODULES_ADMIN[1]="Munin#Munin";
//$SITE_MODULES_ADMIN[2]="Squid Config#Squid";
$SITE_MODULES_ADMIN[1]="User Log#Logviewer";
$SITE_MODULES_ADMIN[2]="User Management#Usermanagement";
$SITE_MODULES_ADMIN[3]="VPN Management#VPNconfig";
$SITE_MODULES_ADMIN[4]="Settings#Settings";
//Footer Modules -----------------------------
$SITE_MODULES_FOOTER[0]="Contact Us#Contact";
$SITE_MODULES_FOOTER[1]="Termes of Use#TermesOfUse";
$SITE_MODULES_FOOTER[2]="Privacy Statement#Privacy";
//##############################################################################
//Do not change the values below!
//--------------------------------------------------
$SITE_TITLE= db_getconfval("sitename");
$SITE_SUBTITLE= db_getconfval("subname");
$SITE_ADRESS=db_getconfval("adress");
$SITE_ADMIN=db_getconfval("admin");
$SITE_MAIL_SERV=db_getconfval("mserv");
$SITE_MAIL_USER=db_getconfval("muser");
$SITE_MAIL_PASS=db_getconfval("mpass");
$SITE_MAIL_NAME=db_getconfval("mname");
$SITE_INFO=db_getconfval("siteinfo");
$SITE_THEME=db_getconfval("sitetheme");
?>

BIN
Images/BlockContent-h.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 B

BIN
Images/BlockContent-s.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 B

BIN
Images/BlockContent-v.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 81 B

BIN
Images/BlockContentBullets.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 119 B

BIN
Images/BlockHeaderIcon.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 258 B

BIN
Images/Button.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

BIN
Images/Footer.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

BIN
Images/Header.jpg Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 111 KiB

BIN
Images/Header_.jpg Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 111 KiB

BIN
Images/Header_old.jpg Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

BIN
Images/MenuItem.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
Images/Page-BgSimpleGradient.jpg Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 672 B

BIN
Images/PostBullets.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 226 B

BIN
Images/PostQuote.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 402 B

BIN
Images/Sheet-h.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 162 B

Some files were not shown because too many files have changed in this diff Show More