Connecting to Informix in .NET

Imports IBM.Data.Informix

Dim ifxConnection As IfxConnection = New IfxConnection

dbname   = "mydb"
dbserver = "ifx1"
dbhost   = "192.168.1.10"
dbuid    = "dbuser"
dbpwd    = "password"
dbproto  = "onsoctcp"
dbsvc    = "ifx1"

ifxConnection.ConnectionString = "database=" & dbname & ";" & _
				 "server=" & dbserver & ";" & _
				 "host=" & dbhost & ";" & _
				 "uid=" & dbuid & ";" & _
				 "pwd=" & dbpwd & ";" & _
				 "protocol=" & dbproto & ";" & _
				 "service=" & dbsvc & ";"

	Try
		ifxConnection.Open()
		Console.Write("Success!")
		ifxConnection.Close()
	Catch ex As Exception
		Console.Write("Error: " & ex.Message)
	End Try

Can’t view VSphere 5.5 Web Interface in Microsoft Edge

I couldn’t find my notes and I came across this again, so I’ll document it here.

To resolve the issue,

  1. Add the vcenter server to your trusted sites (Control > Internet Options > Sites > Trusted Sites)
  2. Navigate to the vCenter web interface, excluding port (9443 default
  3. Click on the certificate next to Edge’s URL bar and click View Certificate.
  4. That will open the certificate on the right-hand side of the Edge screen; at the bottom, click Export and save it to your computer.
  5. Right click on the saved certificate and choose Install.
  6. Install it to Computer > Trusted Root Certificate Authority
  7. Right click on the saved certificate again and choose Install
  8. Install it to Computer > Trusted People

Go back to your vSphere Web UI https://vcenter:9443/ and login.

Note that the integration plugin does not work, but at least you can get into the web UI now.

Enable or Disable smb1protocol using PowerShell

Windows Server 2012 R2 & 2016: PowerShell methods

SMB v1
Detect:Get-WindowsFeature FS-SMB1
Disable:Disable-WindowsOptionalFeature -Online -FeatureName smb1protocol
Enable:Enable-WindowsOptionalFeature -Online -FeatureName smb1protocol
SMB v2/v3
Detect:Get-SmbServerConfiguration | Select EnableSMB2Protocol
Disable:Set-SmbServerConfiguration -EnableSMB2Protocol $false
Enable:Set-SmbServerConfiguration -EnableSMB2Protocol $true

Windows 8.1 and Windows 10: PowerShell methods

SMB v1 Protocol
Detect:Get-WindowsOptionalFeature –Online –FeatureName SMB1Protocol
Disable:Disable-WindowsOptionalFeature -Online -FeatureName SMB1Protocol
Enable:Enable-WindowsOptionalFeature -Online -FeatureName SMB1Protocol
SMB v2/v3 Protocol
Detect:Get-SmbServerConfiguration | Select EnableSMB2Protocol
Disable:Set-SmbServerConfiguration –EnableSMB2Protocol $false
Enable:Set-SmbServerConfiguration –EnableSMB2Protocol $true

Windows 8 and Windows Server 2012

SMB v1 on SMB Server
Detect:Get-SmbServerConfiguration | Select EnableSMB1Protocol
Disable:Set-SmbServerConfiguration -EnableSMB1Protocol $false
Enable:Set-SmbServerConfiguration -EnableSMB1Protocol $true
SMB v2/v3 on SMB Server
Detect:Get-SmbServerConfiguration | Select EnableSMB2Protocol
Disable:Set-SmbServerConfiguration -EnableSMB2Protocol $false
Enable:Set-SmbServerConfiguration -EnableSMB2Protocol $true

Source: https://support.microsoft.com/en-us/help/2696547/how-to-detect-enable-and-disable-smbv1-smbv2-and-smbv3-in-windows-and

Windows Update running for 24 hours

Started a Windows Update process on a fresh install of Windows 7 yesterday afternoon.  It’s still going.  The ISO was a Windows 7 x64 SP1 base image, so I knew it was missing plenty of updates — 177 (1.5GB) to be precise.  I also know there will be more to come when I finally get to reboot from this first pass.

These are being done on an old Lenovo X120e, 2GB RAM, 5400RPM SATA disk and an AMD E-240 1.5GHz processor.

Glad I wasn’t in a hurry.  *shrug*

Update 1/31/2019 4PM

I think I’m on the last round… it’s been about a dozen or so reboots, over the course of 2 days.  WOO HOO!

Run Kali Linux on Windows 10

Kali Linux is a Debian-derived Linux distribution designed for digital forensics and penetration testing. Thanks to the Windows Subsystem for Linux (WSL), we can actually run Kali Linux in Windows, including a desktop environment (xfce4). Here’s how.

Enable Windows Subsystem for Linux

Skip this step if you have already setup Windows Subsystem for Linux.

If you have not already enabled Windows Subsystem for Linux, from an elevated PowerShell console.

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

This will require a reboot.

Install Kali Linux from Windows Store

Launch the Microsoft Store app and search for Kali Linux and install it.

Launch Kali Linux

Once Kali Linux is installed from the Microsoft Store, open a Windows command prompt and type kali.

This will begin the setup of Kali Linux. It will ask for a Linux username to create and a password. Once completed, you’ll be at a command prompt in Kali.

Install xfce4 Desktop Environment

To install a desktop environment that will allow you to remote desktop into your Kali Linux system, a few packages need installed.  To make this easier, grab a script to install xfce4 desktop environment and all the necessary dependencies.

wget http://kali.sh/xfce4.sh

Set the script executable and then run it.

You looked at the code before executing it, right?  😉

rkreider@CTCRK-10:~$ cat xfce4.sh
#!/bin/bash
echo "[+] Installing XFCE4, this will take a while"
apt-get update
apt-get dist-upgrade -y --force-yes
apt-get --yes --force-yes install kali-desktop-xfce xorg xrdp
echo "[+] Configuring XRDP to listen on port 3390 (but not starting the service)..."
sed -i 's/port=3389/port=3390/g' /etc/xrdp/xrdp.ini

Looks ok, so I’ll set execute permission on the script and then run it. (This will take time!)

rkreider@CTCRK-10:~$ chmod +x xfce4.sh
rkreider@CTCRK-10:~$ sudo ./xfce4.sh

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

    #1) Respect the privacy of others.
    #2) Think before you type.
    #3) With great power comes great responsibility.

[sudo] password for rkreider:

When prompted, enter your password you created when initializing Kali Linux.

After a few minutes, you’ll be prompted to choose a Keyboard layout.  After that, it will continue with installation.

Connect with Remote Desktop

Start xrdp server once installation completes.  The script (xfce4.sh) configured XRDP server to listen on port 3390.  To change the port, modify /etc/xrdp/xrdp.ini to your liking.

rkreider@CTCRK-10:~$ sudo /etc/init.d/xrdp start

Now back in Windows, launch Remote Desktop client and connect to 127.0.0.1:3390.

Supply your Kali Linux username and password, and login.

Happy pentesting.

Delete all WordPress posts in a category via MySQL

Quick note on deleting all posts in a category in a WordPress website.

Review

This will select the items that will be removed, but not remove them. Good for reviewing your work before actually deleting.

Replace the X in the last line with your category ID.

SELECT *
FROM wp_posts a
LEFT JOIN wp_term_relationships b ON ( a.ID = b.object_id )
LEFT JOIN wp_postmeta c ON ( a.ID = c.post_id )
LEFT JOIN wp_term_taxonomy d ON ( d.term_taxonomy_id = b.term_taxonomy_id )
LEFT JOIN wp_terms e ON ( e.term_id = d.term_id )
WHERE e.term_id = X

Delete

This will delete data! Replace X in the last line with your category ID.

delete a,b,c,d
FROM wp_posts a
LEFT JOIN wp_term_relationships b ON ( a.ID = b.object_id )
LEFT JOIN wp_postmeta c ON ( a.ID = c.post_id )
LEFT JOIN wp_term_taxonomy d ON ( d.term_taxonomy_id = b.term_taxonomy_id )
LEFT JOIN wp_terms e ON ( e.term_id = d.term_id )
WHERE e.term_id = X;

MySQL 8 and WordPress – Unable to connect to database

MySQL 8 (actually, even back to MySQL 5.7) changed the default authentication from mysql_native_password to caching_sha2_password.  This creates a problem in my environment of PHP 7.3 and MySQL 8.

First, I’d like to say is that this is a new setup for WordPress so I did not have  existing users or databases.

Here’s a typical setup I’d run through on the database server to get the database and user created.

mysql> create database wordpress;
mysql> create user 'wpuser'@'localhost' identified by 'password';
mysql> grant all privileges on wordpress.* to 'wpuser'@'localhost';

Next, I’d head over to my website and start the WordPress installation through the web interface.  Problem is, I’m getting an error when establishing connection to the database.

I confirmed access from the command line already, so I know it isn’t an actual user/permission error.  Seems to be authentication since it can’t even connect to my database server.

mysql> select host,user,plugin from mysql.user where user='wpuser' \G
*************************** 1. row ***************************
  host: localhost
  user: wpuser
plugin: caching_sha2_password
1 row in set (0.00 sec)

Since MySQL  changed the default authentication plugin to caching_sha2_password, my login is failing.

Changing default_authentication_plugin in my.ini configuration in the [mysqld] section, I restarted MySQL and then recreated my user thinking it would automatically use the mysql_native_password in lieu of caching_sha2_password.

Changing the default authentication plugin does not change users already created in MySQL.  I had to update my already created MySQL user by changing the plugin.  Moving forward, if you create a new user, it will automatically use the mysql_native_password plugin.

mysql> alter user 'wpuser'@'localhost' identified with mysql_native_password by 'password';

Now, a quick look at my user again and I see the plugin is updated to the mysql_native_password.

mysql> select host,user,plugin from mysql.user where user='wpuser' \G
*************************** 1. row ***************************
  host: localhost
  user: wpuser
plugin: mysql_native_password
1 row in set (0.00 sec)

Heading back to my web installer, I try again and it succeeds.

In conclusion, if you have upgraded to MySQL 8 (or 5.7+), you can simply update the users for your WordPress database by using the ALTER command above for those specific users and you’ll also need to remember to use the following when creating a new user.

mysql> create user 'wpuser'@'localhost' identified with mysql_native_password by 'password';

If you decide you do not want to use the default authentication plugin at all and change the my.ini configuration (in the [mysqld] section) to reflect mysql_native_password as your default, then any new users created in the future will be set with the mysql_native_password plugin type.

Using Webgrind to analyze Xdebug2

Grab Xdebug that matches your PHP installation.  Make sure Webgrind is not publicly accessible.  It allows anyone with access to it to get access to your local file system.

Webgrind Legend

The basic output lists all the different functions, methods, and included/required files.

  • Invocation Count: The number of times the function has been called
  • Total Self Cost: The total time it took to execute the raw php in this function (time taken to execute your other custom functions is excluded.)
  • Total Inclusive Cost: Total time, including any other functions called (PHP internal, or your functions)
  • What the different colours mean?
    • Blue are PHP internal functions
    • Green are your class methods
    • Orange are procedural functions
    • Grey is time taken to include, or require .php files.
  • What the coloured bar means? Graphical display of breakdown of time for each type as above.
  • For the last ones, I assume you’ve clicked the arrow to open a particular function?
    • Calls: The functions/methods called in executing this function
    • Total Call Cost: The total time executing this function, when called from the parent function
    • Count: Number of times the parent calls the child.