Saturday, June 29, 2019

Fix: The Diagnostic Service Host service failed to start due to the following error. [ solved, no kidding ]

Lots of these Messages about the Diagnostic Service Host in the System Log

On Windows 7 Machines Attached to A Domain

The Diagnostic Service Host service failed to start due to the following error:
A privilege that the service requires to function properly does not exist in the service account configuration. You may use the Services Microsoft Management Console (MMC) snap-in (services.msc) and the Local Security Settings MMC snap-in (secpol.msc) to view the service configuration and the account configuration.  The good news is that you can fix it using active directory group policy or the Local Security Policy and just adding a few things to the Local Policies. 

Here's How to Fix It

You see this in your system logs repeatedly, and its dragging down your computer and making it run slow.  Startup is slow, and there are no real diagnostics. Plus it's difficult to search your event logs. This is one of the items to fix in our blog entry on making your computer run faster. There are lots of blog entries about how to fix this, plus many paid fix-it services such as experts-exchange say they have the fix, and even put [SOLVED] in the title.
Lot of messages about the Diagnostic Service Host repeatedly

How to Fix It with Group Policy

The first thing to do is to open a group policy object that applies to your desktop and server computers.  Hopefully you can edit your Domain group policy.  You have to adjust the following items:  Bypass Traverse Checking, Impersonate a Client After Authentication, and Profile System Performance by granting certain users permission.  

In the registry, you will see this:
Required privileges of the Diagnostic Service Host 
The registry shows what privileges are needed. You need to grant them to the service users.

SeChangeNotifyPrivilege  -- Bypass Traverse Checking
SeImpersonatePrivilege -- Impersonate a Client After Authentication
SeSystemProfilePrivilege  -- Profile System Performance

All in Computer Configuration -> Windows Settings -> Security Settings -> Local Policies

Edit the User Rights Assignment Policy Object, when done it will look like this.

by granting each one:

All need to have:
BUILTIN\Administrators
LOCAL SERVICE
NT SERVICE\WdiServiceHost
plus
SERVICE
Administrators

Just like this for each one
When fixed, you will see this in services.msc
Finally, go to each machine and reboot it.

References:
https://blogs.technet.microsoft.com/markrussinovich/2005/10/19/the-bypass-traverse-checking-or-is-it-the-change-notify-privilege/

https://support.microsoft.com/en-us/help/821546/overview-of-the-impersonate-a-client-after-authentication-and-the-crea

http://setspn.blogspot.com/2010/09/fim-2010-sspr-diagnostic-service-host.html




Thursday, June 27, 2019

How to setup Rabbit SVN client in Ubuntu 14.04 LTS

RabbitVCS is a graphical front-end for version control systems available on Linux. It integrates into file managers to provide file context menu access to version control repositories. The project was originally called NautilusSvn, but due to the desire to support file managers in addition to Nautilus and more version control systems, it was renamed to RabbitVCS.

Step 1: Open your Terminal press Ctrl+Alt+T.
Step 2: Run the following commands one by one

RabbitVCS team also maintaining PPA for Ubuntu and Debian systems. Use the followings commands to add RabbitVCS ppa in your system install required packages.
$ sudo add-apt-repository ppa:rabbitvcs/ppa
$ sudo apt-get update
$ sudo apt-get install rabbitvcs-cli rabbitvcs-core rabbitvcs-gedit rabbitvcs-nautilus3

Step 3: Restart your ubuntu desktop.

You have successfully installed Rabbit SVN Enjoy.

To remove Rabbit SVN client

Step 1: Open your Terminal
Step 2: Run the following command.

sudo apt-get remove rabbitvcs-cli rabbitvcs-core rabbitvcs-gedit rabbitvcs-nautilus3 nemo-rabbitvcs

Step 3: Restart your desktop.

Enjoy...

Wednesday, June 26, 2019

Useful Web Development Hacks and Useful Tips

Javascript, HTML and PHP Tips and Shortcuts

Change the URL in the browser address bar.  A useful hack to so that when you have an <A HREF="#" > and an OnClick handler, your browser addressbar will get cleaned up.

Changing only what's after hash - old browsers
document.location.hash = 'lookAtMeNow';
Changing full URL. Chrome, Firefox, IE10+
history.pushState('data to be passed', 'Title of the page', '/test');
The above will add a new entry to the history so you can press Back button to go to the previous state. To change the URL in place without adding a new entry to history use
history.replaceState('data to be passed', 'Title of the page', '/test');

Sunday, June 23, 2019

How to Make A Keymaker in C-Sharp

You can reverse engineer .Net programs to find out how other software developers protect their applications.  It is a good exercise that will teach you how to make a better software protection scheme.  The first thing to do is get a good set of reverse engineering programs. I recommend dotPeek32. DotPeek32 can open up a .Net program and show you the source code.  Dot.net programs are merely interpreted and not true machine code. They are Microsoft's famous JustInTime compiled with CLR run time code. Using DotPeek or RedGate .Net Reflector, you can easily reverse engineer any application.  My simple keymaker serves as an example of how you can make keymakers using one that I found inside an obscure industrial service application.  You could use the same things in your own application, although I would recommend extending it to 32 characters.

The Simple keymaker UI
the code shown below is the called Sample_Keygen.Form1. It is the event handler for the "Get Key" button.  It works by taking a four digit customer number and 2 digit major version number as inputs, then applying an offset to the customer number strings and version number strings and spreading them over nine (9) characters of an char array.  The second and fourth characters are just random characters that are not used.   In actual operation, the output is stored in TextBox3 and is then given to the customer to use in his own application.  This same function is used in the protected application, and the second and fourth characters are not compared against the inputted key value.  It is a simple and effective way to protect an application against software piracy.


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.VisualBasic;
using Microsoft.VisualBasic.CompilerServices;

// using this dll
// C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0
//
namespace Sample_Keygen
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            int num1;
            object obj1;
            int num2;
            int CustNum = 0;
            int VersionAPP = 1;
            string Num, Ver;
            char[] chArray = new char[9];
            Num = textBox1.Text.ToString();
            Ver = textBox2.Text.ToString();
            if (!Int32.TryParse(Num, out NumNaja))
            {
                NumNaja = 0;
            }
            if (!Int32.TryParse(Ver, out VersionAPP))
            {
                VersionAPP = 1;
            }

            VBMath.Randomize();
            string str1 = Microsoft.VisualBasic.Strings.Format((object)(double)CustNum, "0000");
            string str2 = Microsoft.VisualBasic.Strings.Format((object)(double)VersionAPP, "00");
            chArray[0] = Microsoft.VisualBasic.Strings.Chr(checked((int)Math.Round(unchecked(Conversions.ToDouble(Microsoft.VisualBasic.Strings.Mid(str1, 1, 1)) * 2.0 + 65.0))));
            chArray[1] = Microsoft.VisualBasic.Strings.Chr(checked((int)Math.Round(unchecked((double)VBMath.Rnd() * 26.0 + 65.0))));
            chArray[2] = Microsoft.VisualBasic.Strings.Chr(checked((int)Math.Round(unchecked(Conversions.ToDouble(Microsoft.VisualBasic.Strings.Mid(str1, 3, 1)) * 2.0 + 65.0))));
            chArray[3] = Microsoft.VisualBasic.Strings.Chr(checked((int)Math.Round(unchecked((double)VBMath.Rnd() * 26.0 + 65.0))));
            chArray[4] = Microsoft.VisualBasic.Strings.Chr(checked((int)Math.Round(unchecked(Conversions.ToDouble(Microsoft.VisualBasic.Strings.Mid(str1, 2, 1)) * 2.0 + 65.0))));
            chArray[5] = Microsoft.VisualBasic.Strings.Chr(checked((int)Math.Round(unchecked(Conversions.ToDouble(Microsoft.VisualBasic.Strings.Mid(str1, 4, 1)) * 2.0 + 65.0))));
            chArray[6] = Microsoft.VisualBasic.Strings.Chr(checked((int)Math.Round(unchecked(Conversions.ToDouble(Microsoft.VisualBasic.Strings.Mid(str2, 1, 1)) * 2.0 + 65.0))));
            chArray[7] = Microsoft.VisualBasic.Strings.Chr(checked((int)Math.Round(unchecked(Conversions.ToDouble(Microsoft.VisualBasic.Strings.Mid(str2, 2, 1)) * 4.0 + 65.0))));
            chArray[8] = Microsoft.VisualBasic.Strings.Chr(checked(unchecked(checked(Microsoft.VisualBasic.Strings.Asc(chArray[0]) - 65 + Microsoft.VisualBasic.Strings.Asc(chArray[1]) - 65 + Microsoft.VisualBasic.Strings.Asc(chArray[2]) - 65 + Microsoft.VisualBasic.Strings.Asc(chArray[3]) - 65 + Microsoft.VisualBasic.Strings.Asc(chArray[4]) - 65 + Microsoft.VisualBasic.Strings.Asc(chArray[5]) - 65) % 26) + 65));
            obj1 = (object)(Conversions.ToString(chArray[0]) + Conversions.ToString(chArray[1]) + Conversions.ToString(chArray[2]) + Conversions.ToString(chArray[3]) + Conversions.ToString(chArray[4]) + Conversions.ToString(chArray[5]) + Conversions.ToString(chArray[6]) + Conversions.ToString(chArray[7]) + Conversions.ToString(chArray[8]));

            textBox3.Text = obj1.ToString();
        }
    }
}

Wednesday, June 19, 2019

Shoretel Read-Only VB.Net Database Connect Strings for custom CDR Applications

Shoretel read-only Database Passwords

Shoretel Logo
Have you ever wanted to write your own custom Shoretel/Mitel CDR database reporting application?  If you need root access to the database for read-write operations see this blog entry.   In visual basic dot net, the connect string would look like this:

Dim conn1Str As String = "server=shoretel64;user=st_cdrreport;database=shorewarecdr;port=4309;password=passwordcdrreport;"
Dim conn2Str As String = "server=shoretel64;user=st_configread;database=shoreware;port=4308;password=passwordconfigread;"

Pretty Formatted:

Dim conn1Str As String = "server=shoretel64;user=st_cdrreport;database=shorewarecdr;port=4309;password=passwordcdrreport;"
Dim conn2Str As String = "server=shoretel64;user=st_configread;database=shoreware;port=4308;password=passwordconfigread;"

Assuming your server is just called shoretel64

Tuesday, June 18, 2019

Sudden Magento Failure - The session id is too long or contains illegal characters + Can't retrieve entity config

Magento Failure

You'll be cooking soon.
Suddenly, your magento starts showing error reports instead of shopping carts. Your product pages just show an error exception. And you cannot logon. One of the basic skills that a good Magento cart builder needs to know is how to recover their server from near death.  We are quite skilled at all things Magento. Here's how to fix it by deleting the cache and session pool, once you do this, you will be cooking with gas again.

So, you look in var/report and find the report file, and the first things it says is:

a:5:{i:0;s:46:"Can't retrieve entity config: sales/quote_item";i:1;s:4545:"#0 /home/needfulthings/public_html/app/code/core/Mage/Core/Model/Resource.php(282): Mage::throwException('Can't retrieve ...')
#1 /home/needfulthings/public_html/app/code/core/Mage/Core/Model/Resource/Db/Abstract.php(276): Mage_Core_Model_Resource->getTableName('sales/quote_ite...')

Plus in ./var/log/system.log, you see this:

...
2019-06-17T02:49:35+00:00 ERR (3): Warning: session_start(): The session id is too long or contains illegal characters, valid characters are a-z, A-Z, 0-9 and '-,'  in /home/needfulthings/public_html/app/code/core/Mage/Core/Model/Session/Abstract/Varien.php on line 134
2019-06-17T02:49:35+00:00 ERR (3): Warning: session_start(): The session id is too long or contains illegal characters, valid characters are a-z, A-Z, 0-9 and '-,'  in /home/needfulthings/public_html/app/code/core/Mage/Core/Model/Session/Abstract/Varien.php on line 134

It happens because there is junk in the magento cache.
clean out your cache and delete your sessions from:

Delete the contents of the following directories, assuming your magento is installed in ~/

~/public_html/var/cache
~/public_html/var/session



Tuesday, June 4, 2019

Using The Shoretel 90V Serial Console to Factory Reset

How to Connect to the Shoretel 90V Serial Console Like a Boss

You just bought a pre-owned Shoretel 90V from a grey market source, and now you find that you cannot logon anymore as anonymous.  Shoretel is full of hidden and secret passwords, including a secret CDR database with its own passwords. The Shoretel switch is no exception.  You may need to factory reset it, or you just need to set the root password.  Well, here are some ways to get in.  First step is to get a RS232 serial port added to your computer. You can use a USB to Serial adapter or you can just use the built in port. On most computers, it looks like a DB9 connector. Here are some pictures that will help you get in.  I buy and sell these grey market Shoretel switches all the time and this is often the first thing you need to do to clear them out and get them ready for the next user.  There is no user called anonymous, that was a feature from the previous generation of switches. The user is called "root" and his password is "ShoreTel"  The previous generation used Wind River VXWorks, The 90V runs Linux.  Curiously enough, there is removable compact flash drive inside the 90V that contains the ext4 file system. You can always remove it and mount it in ubuntu and them edit the /etc/shadow file

root@Default:/root# fdisk -l /dev/kcfa

Disk /dev/kcfa: 2096 MB, 2096898048 bytes

16 heads, 63 sectors/track, 4063 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Disk identifier: 0xdbe3ac07

    Device Boot      Start         End      Blocks   Id  System

/dev/kcfa1               1        4063     2047720+  83  Linux


how to factory reset:  reboot, then use the option to stop auto boot, (press a key) and then type:
> bootc static flash vxworks
> saveenv
> reset

or just change the IP address and set to DHCP
All tests passed
Hit any key to stop autoboot:  0
=> printenv
serial#=90VF13152E94F4
ethaddr=00:10:49:2E:94:F4
bootdelay=3
user=anonymous
pass=tsk
autoload=FLASH
partition=nand0,1
flags=0x0000
gatewayip=10.90.2.1
ipaddr=10.90.2.30
netmask=255.255.255.0
serverip=10.70.2.32
cntrlsrv=10.70.2.32
bootfile=vImage
bootcmd=jboot;bootm

Environment size: 267/492 bytes
=> setenv flags 0x40
=> setenv host 10.0.11.45
=> setenv serverip 10.0.11.45
=> saveenv
Saving Environment to EEPROM...


Use a Cisco DB9 to RJ45 Cable with a Null Modem

Connect it to the bottom port /maint port using a gender changer

Set your RS232 port to 19200 Baud,8 bits, 1 stop bit, no parity

Use Putty with the serial port option

Power up your 90V, press a key when prompted to stop in env console

Logon as root, with password ShoreTel

As you can see, it just runs Wind River Linux
Thats all you need to do. I recommend pressing the reset button and holding it for 10 seconds to reset the root password back to ShoreTel.  If you found this bit of advice useful or if you know of more ways to get in, please leave us a comment.

Saturday, June 1, 2019

SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data

SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data

Suddenly it happens, your PHP page shows this message in red: "SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data" and you don't know why.

Somewhere in your code, you were using curl and were playing with the headers. You must have inserted this command:

header('Content-Type: application/json'); 

To Fix this error: you need to insert this statement right after you are done with JSON.

header('Content-Type: text/html; charset=utf-8');



Install a SSL Certificate into Remote Desktop / Terminal Server using MMC

How to Install a SSL Certificate into Remote Desktop / Terminal Server

Step 1 convert it from PEM to PKFS/12,
Step 2 Open MMC, add the Certificates plugin, as Computer Account
Step 3 Import the new certificate into your Personal Store
Step 4 Copy the new certificate into the Remote Desktop Branch
Step 5 Use this magic command to finalize it

Get the thumbprint from the certificate. It will look like this:
‎3b a2 15 ac 85 a3 ee 56 9b 2e 55 73 de 22 55 29 cb d4 8a 05

Put the thumbprint without spaces in the following command below. Be sure to use PowerShell wmic /namespace:\\root\CIMV2\TerminalServices PATH Win32_TSGeneralSetting Set SSLCertificateSHA1Hash="PUT-the-THUMB-print-HERE"  copy this command to a administrative command prompt or powershell and hit enter. It should say successful and will now use the certificate you choose.

Screenshots from the import a SSL certificate process
Here's a great video that shows the process.

Get A Free SSL Certificate and Use Free Conversion Tools

How to Get A Free SSL Certificate

A Free SSL? Really?

SSL is so expensive, but now there is a free option. It's called SSLForFree.com
https://www.sslforfree.com You can get 90 day certificates and a handy reminder to help you remember to renew it.  This is one of the first things you need to do while building your business website.

SSL For Free
SSL For Free? Finally.

Discounted SSL

There are some websites that sell discounted SSLs from Comodo.

SSL2BUY
https://www.ssl2buy.com/

SSL Decoder
https://www.sslshopper.com/certificate-decoder.html

SSL Converter
To convert your certificate from a Standard PEM to a PFX/PKCS#12.  You will need your private key and certificate file from SSLFORFREE.com