Gmail SSL Proxy

Everybody loves Gmail, but if you are trying to integrate other system i.e a ticket system that does not support ssl it might be a pain.

You can use http://www.delegate.org/delegate/ as a proxy to connect your application to gmail.

  • Download and install delegate
  • run the command below(it will setup delegate to be a pop ssl proxy on port 110.)
delegated -P110 SERVER=POP FSV=sslway admin=<your email>

In your application the pop server is localhost and your username is myuser%[email protected]:995(since the proxy is generic, the username has the additional connection information so you can poll multiple accounts witht he same proxy) and the password is your usual gmail password

WHMCS Ahsay Plugin

<?php /* V1.0 Lite Version; Only Support suspend and unsuspend.  Installation and Setup -copy this file into <whmcsroot>/modules/servers/ahsayosb. You will have to create the folder ahsayosb in lower case.

-Add a new server and in Server Details select Ahsayosb as the type and put in your system administrator username and password. The Access Hash is not used and might be used for advanced settings in the future.
-If you select Secure the module will use ssl for connections (Highly Recommended)
-You can ignore all the Nameservers settings.

-Create a new product or modify an existing osb product and under module settings set the Modlue Name to Ahsayosb
-There are options for Language/Client Type/Bandwidth. These all can be ignored right now because this version only supports Suspend and Unsuspend.

-In the user account under the Products/Services make sure the correct username is listed the password can be ignored.

*/
$apiurl = "/obs/api/";

$auth = "AuthUser.do";
$adduser = "AddUser.do";
$moduser = "ModifyUser.do";
$removeuser = "RemoveUser.do";
$listuser = "ListUsers.do";
$getuser = "GetUser.do";

function ahsayosb_ConfigOptions() {
 # Should return an array of the module options for each product - maximum of 24
    $configarray = array(
  "Default Language" => array("Type" => "dropdown", "Options" => "English-en, Czech-cs, Danish-da, German-de, Spanish-es, French-fr,Finnish-fi,Icelandic-is,Italian-it,Japanese-ja,Lithuanian-lt,Dutch-nl,Norwegian-no,Portuguese-pt_PT, Slovenian-sl, Swedish-sv, Chinese(Simplified)-zh_CN, Chinese(Traditional)-zh_TW"),
  "Client Type" => array("Type" => "dropdown", "Options" => "OBM, ACB", "Description" => ""),
  "Bandwidth" => array("Type" => "text", "Size" => "5", "Description" => "MB, 0 = Unlimited"),
  "Fast Terminate" => array("Type" => "yesno", "Description" => "If enabled accounts will be instantly terminated"),
  "Add Group" => array("Type" => "text", "Size" => "7", "Description" => "Ad group name.(Only for ACB)"),
  //"Package Name" => array( "Type" => "text", "Size" => "25", ),
  //"Web Space Quota" => array( "Type" => "text", "Size" => "5", "Description" => "MB" ),
  //"FTP Access" => array( "Type" => "yesno", "Description" => "Tick to grant access" ),
     //"Subdomains" => array( "Type" => "dropdown", "Options" => "1,2,5,10,25,50,Unlimited"),
 );
 return $configarray;
}

function ahsayosb_CreateAccount($params) {

    # ** The variables listed below are passed into all module functions **

    $serviceid = $params["serviceid"]; # Unique ID of the product/service in the WHMCS Database
    $pid = $params["pid"]; # Product/Service ID
    $producttype = $params["producttype"]; # Product Type: hostingaccount, reselleraccount, server or other
    $domain = $params["domain"];
 $username = $params["username"];
 $password = $params["password"];
    $clientsdetails = $params["clientsdetails"]; # Array of clients details - firstname, lastname, email, country, etc...
    $customfields = $params["customfields"]; # Array of custom field values for the product
    $configoptions = $params["configoptions"]; # Array of configurable option values for the product

    # Product module option settings from ConfigOptions array above
    $configoption1 = $params["configoption1"];
    $configoption2 = $params["configoption2"];
    $configoption3 = $params["configoption3"];
    $configoption4 = $params["configoption4"];

    # Additional variables if the product/service is linked to a server
    $server = $params["server"]; # True if linked to a server
    $serverid = $params["serverid"];
    $serverip = $params["serverip"];
    $serverusername = $params["serverusername"];
    $serverpassword = $params["serverpassword"];
    $serveraccesshash = $params["serveraccesshash"];
    $serversecure = $params["serversecure"]; # If set, SSL Mode is enabled in the server config

 # Code to perform action goes here...

 if ($successful) {
  $result = "success";
 } else {
  $result = "Error Message Goes Here...";
 }
 #return $result;
 return "Not Implemented";
}

function ahsayosb_TerminateAccount($params) {

 # Code to perform action goes here...

    if ($successful) {
  $result = "success";
 } else {
  $result = "Error Message Goes Here...";
 }
 #return $result;
 return "Not Implemented";
}

function ahsayosb_SuspendAccount($params) {
 if ($params["serversecure"] == 'on')
 {
  $conn = "https://";
 }
 else
 {
  $conn = "http://";
 }

 $adminAuth = "?SysUser=" . $params["serverusername"]."&SysPwd=".$params["serverpassword"]. "&";
 #getRemoteData($conn, $server, $cmd, $getcmd = NULL)

 $response = getRemoteData($conn, $params["serverhostname"], $GLOBALS["moduser"], $adminAuth . "LoginName=" . $params["username"] . "&Status=SUSPENDED");

 #$moduser, $adminAuth . "LoginName=$user&Status=ENABLE");

 if ($response == "<ok/>") {
  $result = "success";
 } else {
  $result = "Error: The return was " . $response;
 }
 return $result;
}

function ahsayosb_UnsuspendAccount($params) {
 if ($params["serversecure"] == 'on')
 {
  $conn = "https://";
 }
 else
 {
  $conn = "http://";
 }

 $adminAuth = "?SysUser=" . $params["serverusername"]."&SysPwd=".$params["serverpassword"]. "&";
 #getRemoteData($conn, $server, $cmd, $getcmd = NULL)

 $response = getRemoteData($conn, $params["serverhostname"], $GLOBALS["moduser"], $adminAuth . "LoginName=" . $params["username"] . "&Status=ENABLE");

 #$moduser, $adminAuth . "LoginName=$user&Status=ENABLE");

 if ($response == "<ok/>") {
  $result = "success";
 } else {
  $result = "Error: The return was " . $response;
 }
 return $result;
}

function ahsayosb_ChangePassword($params) {

 # Code to perform action goes here...

    if ($successful) {
  $result = "success";
 } else {
  $result = "Error Message Goes Here...";
 }
 #return $result;
 return "Not Implemented";
}

function ahsayosb_ChangePackage($params) {

 # Code to perform action goes here...

    if ($successful) {
  $result = "success";
 } else {
  $result = "Error Message Goes Here...";
 }
 #return $result;
 return "Not Implemented";
}

function ahsayosb_ClientArea($params) {
 $code = '<form action="http://'.$serverip.'/controlpanel" method="post" target="_blank">
<input type="hidden" name="user" value="'.$params[">
<input type="hidden" name="pass" value="'.$params[">
<input type="submit" value="Login to Control Panel">
<input type="button" value="Login to Webmail" onclick="window.open(\'http://'.$serverip.'/webmail\')">
</form>';
 return $code;
}

function ahsayosb_AdminLink($params) {
 if ($params["serversecure"] == 'on')
 {
  $conn = "https://";
 }
 else
 {
  $conn = "http://";
 }

 $code = '<form action="'. $conn .$params[" method="post" target="_blank">
<input type="hidden" name="systemLoginName" value="'.$params[">
<input type="hidden" name="systemPassword" value="'.$params[">
<input type="submit" value="OSB Admin">
</form>';
 return $code;
}

function ahsayosb_LoginLink($params) {
 if ($params["serversecure"] == 'on')
 {
  $conn = "https://";
 }
 else
 {
  $conn = "http://";
 }
 echo "<a href="\" loginname=".$params[" target="\" style="\">login to control panel</a>";

}

function ahsayosb_AdminCustomButtonArray() {
 # This function can define additional functions your module supports, the example here is a reboot button and then the reboot function is defined below
    $buttonarray = array(
  #"Reboot Server" => "reboot",
 );
 return $buttonarray;
}

function ahsayosb_reboot($params) {

 # Code to perform action goes here...

    if ($successful) {
  $result = "success";
 } else {
  $result = "Error Message Goes Here...";
 }
 return $result;
}

#Inernal Functions ONLY
function getRemoteData($conn, $server, $cmd, $getcmd = NULL)
{
 $response = '';
 if (ini_get('allow_url_fopen') == '1')
 {
  $response = file_get_contents($conn . $server . $GLOBALS['apiurl'] . $cmd . $getcmd);

  //use filegetcontects
 }
 else
 {
  print "Have to use curl";
 }
 return $response;
}

?>

Here is a a module/plugin for whmcs that controls an Ahsay off-site backup server.

http://www.whmcs.com
http://www.ahsay.com

It will automatically suspend and un-suspend off-site backup accounts.

Perl POP3 collector

This collects multiple pop3 email accounts and sends them to an smtp server. I wrote this as an exchange pop3 collector.

Setup:
1. Set $inserver to your incoming mail server to collect the pop3 email from. If you need to collect from multiple pop3 servers just copy the script and run them separately.
2. Set $outserver to the server that you would like to move the email to. It does not have to be a local server.
3. Set the %accounts array with the pop3 account you would like to collect.
If you are collect multiple pop3 accounts %accounts might look like this.

%accounts = (
            '[email protected]' => {'password' =>  'pop3_pass','sendto' =>  'demo@demo_exchange.local',},
             '[email protected]' => {'password' =>  'demo2_pass','sendto' =>  'demo2@demo_exchange.local',},
            ); 
#Usage: Run this as a scheduled task to collect external pop3 email and move them into exchange.
use Net::POP3;
use Net::SMTP;

#1 = turn debug on || 0 = turn debug off
#to check for errors run the this from the command line. Example:
# perl exchangepop.pl 1>>expop.log 2>>expop.log
$debug=0;

$inserver="mail.gmail.com"; #email server to get email from

$outserver="localhost"; #Exchange Server, this is usually localhost.

#Accounts to Collect e-mail from, Example:
# 'Pop3 user name' => {'password' =>  'Pop3 Password','sendto' =>  'Exchange E-mail Address',},
%accounts = (
           '[email protected]' => {'password' =>  'pop3_pass','sendto' =>  'demo@demo_exchange.local',},
           );

foreach $accnt (keys %accounts)
{
#print "User: $accnt password:", $accounts{$accnt} -> {"password"}, " sendto: ",$accounts{$accnt} -> {"sendto"}," \n";

  $pop = Net::POP3->new($inserver,Timeout => 60, Debug => $debug);
   if ($pop->login($accnt, $accounts{$accnt} -> {"password"}) > 0)
   {
       my $msgnums = $pop->list;
       foreach my $msgnum (keys %$msgnums)
       {
           my $msg = $pop->get($msgnum);
           $smtp = Net::SMTP->new($outserver, Timeout => 60, Debug =>$debug);
           $smtp->mail($accnt);
           $smtp->to($accounts{$accnt} -> {"sendto"});
           $smtp->data();
           $smtp->datasend(@$msg);
           $smtp->dataend();
           $smtp->quit;
           $pop->delete($msgnum);
       }
   }
   $pop->quit;
}
print "done!";

Whatsup Vmware ESXi monitor

–These directions assume some whatsup knowledge.
–ESXi does not support SNMP gets, only TRAPS.

Setup

  • Install Python 2.6.x
  • Install pywbem
  • Download check_esx_wbem.py put it into c:\python26
  • In Whatsup create new windows credentials, for the domain use esx. For example use esx\root for the username and the input the password.
  • On the node make sure that its configured to use those credentials.
  • Create a new active script monitor and paste the code below.
  • Assign the active script monitor to your node and your all set.

I didn’t write the python script, if you have any problem please first test the python script from the command line. You have to use the windows installer for pywbem the latest version has a dependency that does not work in windows.

I have tested the script on IBM servers. Please let me know if you make any modifications to the script i would love to see them.

'Wbem ESX Monitor
'Stephen

Context.SetResult 0, "No Error"

sysAddress = Context.GetProperty("Address")
sysAdminUser = Context.GetProperty("CredWindows:DomainAndUserid")
sysAdminPass = Context.GetProperty("CredWindows:Password")
sysAdminUser = replace(sysAdminUser,"esx\","")
sysAddress = "https://" & sysAddress & ":5989"

esxcheck = "c:\python26\check_esx_wbem.py"

Set objShell = CreateObject("Wscript.Shell")
command = "python " & esxcheck & " " & sysAddress & " " &  sysAdminUser & " " & sysAdminPass
returncode = objShell.run(command ,0 , True)

Select Case returncode
 Case 0
  context.SetResult 0, "OK! Return Code:" & returncode
 Case 1
  context.SetREsult 1, "Warning!! Return Code:" & returncode
 Case 2
  context.SetResult 1,  "Critical!!! Return Code:" & returncode
 Case 3
  context.SetResult 1,  "Unknown!!! Return Code:" & returncode
End select

Here is my ClassesToCheck block, I added Fan and power supply.

# define classes to check 'OperationStatus' instance
ClassesToCheck = [
 'CIM_ComputerSystem',
 'CIM_NumericSensor',
 'CIM_Memory',
 'CIM_Processor',
 'CIM_RecordLog',
 'OMC_DiscreteSensor',
 'OMC_Fan',
 'OMC_PowerSupply',
 'VMware_StorageExtent',
 'VMware_Controller',
 'VMware_StorageVolume',
 'VMware_Battery',
 'VMware_SASSATAPort'
]

Active directory web password reset

This is a simple webform that asks for the username and when you click submit it will generate a random password.

default.htm






FIT Password Reset






FIT Username:








All usage is monitored and logged.





fitPassReset.pl