Author Archives: artandfact_admin

Sorting a list of CIDR IP addresses

You may have a list of IP addresses which follow CIDR format, i.e. 111.12.23.45/16 and which you wish to sort. Here is an algorithm to do so in Microsoft Excel:

Step 1. Paste all IP addresses in to a single column A in your Excel sheet.

Step 2. Remove the CIDR part of the IP address in column A by applying the following formula to the first row in Column B:

=LEFT(A1,FIND("/",A1)-1)

This will turn an IP address, such as 111.12.23.45/16 in to 111.12.23.45.

Step 3. Once you get a valid IP address in Column B, double click on the bottom-right corner of the cell to propagate for formula to the rest of the rows in Column B.

Step 4. Select the entire Column B and then paste again using Paste Special… Values. This will remove all the formulas and retain only the IP values.

Step 5. Apply the following formula in Column C in order to make sure each octet of your IP address has three digits:

=TEXT(LEFT(B1,FIND(".",B1,1)-1),"000") & "." & TEXT(MID(B1,FIND( ".",B1,1)+1,FIND(".",B1,FIND(".",B1,1)+1)-FIND(".",B1,1)-1),"000") & "." & TEXT(MID(B1,FIND(".",B1,FIND(".",B1,1)+1)+1,FIND(".",B1, FIND(".",B1,FIND(".",B1,1)+1)+1)-FIND(".",B1,FIND(".",B1,1)+1)-1), "000") & "." & TEXT(RIGHT(B1,LEN(B1)-FIND(".",B1,FIND(".",B1,FIND( ".",B1,1)+1)+1)),"000")
[*] https://www.extendoffice.com/documents/excel/4946-excel-sort-ip-address.html

This will convert all your IPs (without CIDR notation) in to a set of numbers with the following format: XXX.XXX.XXX.XXX. That is to say, each octet will contain exactly three digits. In cases where an octet originally has only two digits, then a zero will be prepended. In the case where the octet originally has only one digit, then two zeros will be prepended.

For example, our original IP: 111.12.23.45/16 will now look like: 111.012.023.045

Step 5. Apply the same thing you did in Step 4. but to this new column C, so that only the values remain.

You should now have three columns in your Excel sheet. The first column is a list of your original IPs in CIDR format. The second is a list of the same IPs without the CIDR notation. The third is a list of the same IPs where each octet has precisely three digits.

Step 6. The final step is to sort the list by column 3: Select the whole sheet by clicking on the top-right corner of the sheet where the rows and columns meet. Go to Menu Item: ‘Data’… click on the ‘Sort’ icon, and select Column 3.

One caveat for using this algorithm:

This algorithm does not take into account the CIDR values when sorting.

‘Check WordPress Update’ plugin for Nagios — PHP 8 compatibility

If you’re using Nagios to monitor your WordPress installations, you may be using the ‘Check WordPress Update’ plugin by jinjie found here:

https://exchange.nagios.org/directory/Plugins/CMS-and-Blog-Software/Wordpress/Check-WordPress-Update/details

We recently updated our PHP version on some of our servers to version 8, and this broke the old version of the plugin. The new plugin has been updated and is compatible with PHP version 8.

The incompatibility was with the last line in the code:

echo $status . '#' . implode(';', $text);

The issue arises because of the order of the arguments for the implode function. The old signature, used for PHP versions up to 7.4 was:

implode(array $array, string $separator): string

whereas the new signature for PHP versions greater than 7.4 is:

implode(string $separator, array $array): string

If you’re on a machine which hosts multiple PHP versions and want to just use one version of the plugin, you can use this little modification to check the current PHP version:

//Test if we're using php version 8 or greater.  This fix is needed or a fatal error will occur.
if (version_compare(phpversion(), '8', '<')) {
    // php version is below 8
    echo $status . '#' . implode($text, ';');
} else {
    echo $status . '#' . implode(';', $text);
}

Windows Keyboard Shortcuts!

I just came across this Tweet by @Rainmaker1973, which is sharing a video by someone called lklogic on TikTok. I found it very useful. I’ve used most of these, but didn’t know about Control D to set to the Default Font Set or that you could align text via a shortcut with Control L and R.

You may want the text version, so I recreated it here:

  • Control A = Select All
  • Control B = Bold
  • Control C = Copy
  • Control D = Default Font Set
  • Control E = Center
  • Control F = Find
  • Control G = Go to
  • Control H = Replace
  • Control I = Italic
  • Control J = Justify
  • Control K = Hyperlink
  • Control L = Alight Text to Left
  • Control M = Hanging Indent
  • Control N = New Document
  • Control O = Open
  • Control P = Print
  • Control Q = Add Space after Paragraph
  • Control R = Align Text to Right
  • Control S = Save As
  • Control T = Left Indent
  • Control U = Underline
  • Control V = Paste
  • Control W = Close
  • Control X = Cut
  • Control Y = Repeat / Undo
  • Control Z = Undo

PureText Plugin: Paste raw text only!

Hey folks. One of my Windows pet peeves is that it always copies formatting whenever you use Control-C to copy text. I almost never want to paste formatting anywhere. In fact, sometimes the formatting interferes and it wastes time because I have to either remove it, or remember to first paste in TextPad and then copy again from there.

I was thinking of writing a Windows plugin to only paste raw-text, but it looks like someone named Steve Miller has already come up with one. It’s called PureText. You can download it here:

https://stevemiller.net/puretext/

It’s available from the Microsoft Store, or from that link.

Unfortunately, you can’t replace Control-V as the standard Hotkey for PureText, as this conflicts with Windows. You can use Win or Alt.

Be sure to check out the Options!…

Using grep to query the nameservers of a list of domains

Let’s say you have a text file containing a list of domains you want to query using whois. Our goal is to query each domain in the list an extract the nameservers for each domain.

This can be achieved using a bash script with a combination of whois, grep, and tr.

Examine the following code:

#!/bin/bash
input="domainlist.txt"
while IFS= read -r line
do
        WHOISOUTPUT=$(whois $line | grep "Name Server" | tr -d '\n')
        echo "$line," "$WHOISOUTPUT"
        sleep 3
done < "$input"

This script instructs bash to run a whois command on each line of the input file. The variable $line will contain the domain name, grep will pick out the lines containing “Name Server”, and tr -d ‘\n’ will remove the new lines from the preceding text in the pipe so the output will appear on one line.

So your output will look something like:

domain.com,    Name Server: ns1.nameserver.com    Name Server: ns2.nameserver.com
domain2.com,    Name Server: NS1.MYDNS.com    Name Server: ns2.MYDNS.com

We are Grepping “Name Server” because that follows the output format outlined by ICANN https://www.icann.org/resources/pages/approved-with-specs-2013-09-17-en#whois

Please be aware that sometimes whois servers can return non-standard formats.

The ‘Sleep 3’ statement is there just to be polite and not hammer nameservers.

If you pipe the output of this script to a text file and save it, you can open it as a CSV file.

A non-prescription cure for Athlete’s Foot that works

I’ve had Athlete’s Foot (tinea pedis) on and off between my pinky toe and the next toe for the past several years. I’ve tried lots of prescription anti-fungal treatments, but none of them really worked. They would reduce the severity of the infection, but never completely get rid of it.

Athlete’s Foot can be pretty resistant to treatment. My GP said that it is difficult to know which combination of anti-fungal drugs will work best with an individual infection. For me, none of them seem to get rid of it completely.

In this post I am going to discuss treating Athlete’s Foot with a combination of Hydrogen Peroxide and Iodine. Both Hydrogen Peroxide and Iodine are well-known substances for treating skin infections, and are strongly anti-septic: anti-bacterial and anti-fungal.

Iodine

Iodine is a potent anti-fungal agent that…

rapidly penetrates through the walls of the cells of the microorganisms and disrupts the nucleic acid along with the structure and synthesis of protein, thereby leading to the death of germs.

https://clinicinus.com/does-iodine-kill-fungus/

You can apply Iodine topically using cotton pads on an infected toe-nail or in-between toes and it will get to work deep within the tissue right away. It is also cheap and fairly widely available at any chemist or pharmacist.

Side-effects are rare, but include: Blistering, crusting, irritation, itching, or reddening of skin. [1]

Hydrogen Peroxide

Hydrogen Peroxide is a mild anti-septic and is typically used topically to treat the surface of the skin to prevent infection of minor cuts and wounds. It should not be used to treat deep wounds, serious burns or injuries.

There is a low risk of side-effects, although mild irritation can occur. Peroxide is widely available and can be found at supermarkets, chemists, and pharmacists.

Combining the two treatments

Each of these substances are anti-fungal and each have been used on their own in order to treat Athlete’s Foot, however, one substance on its own may not be enough to get rid of your infection. I am across an interesting paper called:

Co-operative inhibitory effects of hydrogen peroxide and iodine against bacterial and yeast species

by Elena I Zubko1 and Mikhajlo K Zubko1

The paper can be found here. It discusses the effectiveness of each of these substances in fighting fungal growth (in vitro) compared with the synergistic, additive effect of using both on the same fungal specimen.

The results state:

Synergistic or additive inhibitory effects were shown for hydrogen peroxide and iodine mixtures against all 19 species used in the study. 

And the conclusion:

Iodine and hydrogen peroxide used concurrently interact synergistically or additively against a range of prokaryotic and eukaryotic microorganisms.

Personal Experience

In my personal experience, a combination of these two substances completely got rid of my Athlete’s Foot where other prescription anti-fungal treatments failed. I used Hydrogen Peroxide at 3% by volume, and an Iodine ointment at 10% applied topically. I would try alternating days using one and then the other. I stopped after three weeks of treatment

If anyone has a treatment-resistant infection, they could try combining these two treatments. I would suggest people read more about these substances and their potential side-effects. (also: Iodine will stain your clothes!)

Ask your doctor or pharmacists for guidance

I am not a doctor, and suffice to say that you should always ask a medical professional for the suitability of any treatment for you. Every individual’s circumstances are different.