Coding page 1 of 3 for 15 posts

Had an idea to extract all the unique words from my blog post titles and sort and rank them by frequency. I used MySQL, sed, tr, grep, cat and a little bash script hacked together to do this. Here's the top 10 unique words in my blog post titles. Here's how I got to this... SQL Query select id,post_title from wp_posts where post_type='post' and post_status='publish' Bash Script The script splits each word into a new line and also removes any non-alphanumeric characters sh Continue Reading...

Could not establish trust relationship for the SSL/TLS secure channel.

Working with some older Cisco ASA devices, I'm trying to access the ASDM interface. The browser isn't giving me luck, so I turned to PowerShell to help me, but I get the following error when trying an Invoke-WebRequest to grab the asdm.jnlp file I need. The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel. Eh, ok. My first thought was to somehow avoid a certificate check but I did not see a native way of doing this with Invoke-WebRequest Continue Reading...

Get Enabled AD Users with Last Logon Time and Organizational Unit Information

This PowerShell script retrieves information about enabled Active Directory (AD) users, including their SAM account name, last logon time, and organizational unit (OU). The script makes use of several cmdlets and concepts that are common in PowerShell, including filtering, selecting, sorting, and transforming data. Get-ADUser -Filter * -Properties lastLogon | Where-Object { $_.Enabled -eq $True } | Select-Object samaccountname, @{ Name="lastLogon"; Expression={[datetime]::FromFileTime($_.lastLogon)} Continue Reading...

Writing a portscan utility in .NET

I'm working on a side project that is a portscan utility written in VB.net. Here's my progress so far, and it is working. portscan v0.9.2 scanning my server up to port 1024 with a 25ms timeout There's some way to go on this little project. I think I can optimize it further, clean up the code, and fix my logic for many of the options. See an earlier post about handling command line arguments I wrote which is what class I use for handling the arguments. Continue Reading...

Handling Commandline Arguments in VB.NET

Handling commandline arguments in VB.NET (or really anything) can be tricky. I came across the following class the other day while looking for a drop-in solution to a RAD I was developing. Here's what my usage shows for my application, thanks to the .NET class. portscan.exe portscan 0.9.2 by Rich Kreider Usage: portscan -h <host> -s <startport> -e <endport> -f -d -t <timeoutms> Options: -h Host. IP address or hostname. -s Start port. Continue Reading...

Bulk change PHP memory_limit across all installed PHP versions

On my server, I have PHP 5.6 to 8.1 installed and use the versions for various testing purposes. To change the memory_limit across all versions as simply as possible instead of editing each file, I use the following command. find /etc/php -iname 'php.ini' -exec sed -i 's/memory_limit = .*/memory_limit = 512M/g' {} \; Continue Reading...

Check Windows Servers Activation Status

I needed a quick way to check activation status of Windows Servers in a domain. This is the solution I came up with using PowerShell to run the slmgr.vbs script for output. I'm not great with PowerShell, and I'm sure this can be cleaned up or made more efficient, but this 'hack' worked for me. $computers = get-adcomputer -filter "OperatingSystem -Like '*Windows Server*' -and Enabled -eq 'True'" | select-object name foreach($computer in $computers) { write-host $computer.name Invoke-Command Continue Reading...

FileSystemWatcher – LastAccess Not Working

To have System.IO.FileSystemWatcher LastAccess work, the system must have access logging enabled with the following command. fsutil behavior set DisableLastAccess 0 After setting this, reboot, and you can successfully use the FileSystemWatcher to monitor LastAccess of files (sorta). Example Code FileSystemWatcher lWatcher = new FileSystemWatcher(@"C:\windows\temp", "*.*"); lWatcher.NotifyFilter = NotifyFilters.LastAccess; lWatcher.EnableRaisingEvents = Continue Reading...

Pennsylvania COVID-19 Data Scraping with Python

Over the last few weeks I've been using Python to scrape the Pennsylvania Department of Health's Coronavirus page. Over time the page has evolved and even split into sub-pages which contain table date of cases, deaths and other statistics. I've decided to put my Python script on GitHub for public consumption. Initially when I had created the script, it was used to send me alerts when the reported numbers changed as there was no set time during the day that the website was updated, so I wanted Continue Reading...

Login to WordPress from Python

I've been trying to learn some Python and have been tinkering with the requests module. Here is how I am able to log into a webpage, such as WordPress. import requests url = "https://techish.net/wp-login.php" redirect_to = "https://techish.net/wp-admin/" with requests.Session() as session: post = session.post(url, data={ 'log': 'admin', 'pwd': 'password', 'redirect_to': redirect_to }, allow_redirects=True) get = session.get(redirect_to, cookies=post.cookies) Continue Reading...