Search This Blog
Monday, May 17, 2021
Powershell - Create New CentOS Workstation VM
Thursday, October 1, 2020
Windows 10 Firewall Ports
From time to time I have to open a port to do something and close it back up when I'm done. As I do this fairly often (but not often enough to memorize) I created this recipe. There is an example using Docker below.
Background Information...
How to do this by the Windows user Interface (UI)
https://www.google.com/search?q=windows+10+firewall+enable+localhost%3A80+traffic
How to do this with Powershell
https://www.google.com/search?q=powershell+TCP+Port+80+in+Windows+Firewall
https://docs.microsoft.com/en-us/powershell/module/netsecurity/new-netfirewallrule?view=win10-ps
https://serverfault.com/questions/883266/powershell-how-open-a-windows-firewall-port
Powershell
Open the port
New-NetFirewallRule -DisplayName "Allow inbound TCP port 81" -Direction inbound -LocalPort 81 -Protocol TCP -Action Allow
Name : {af16f2f3-3221-4191-8c5a-f44a5f60ca58}
DisplayName : Allow inbound TCP port 81
Test (while something is listening on the port)
Get-NetFirewallRule -Name '{af16f2f3-3221-4191-8c5a-f44a5f60ca58}'
** You can also see this in the Windows firewall inbound rules![]()
$tcp = New-Object System.Net.Sockets.TcpClient
$tcp.Connect("localhost","81")
$tcp.Connected
True
Close the port back up
** If you test again, you should get a failure (or, your listening port was not blocked already). And, the control panel, on refresh, will show the rule is missing.
You're done!
Example
As a semi-practical example, Start a Docker container, test and clean up. For this to be a real example, you would have to imagine that port 81 was the blocked port. On port 80, I got stuff running there already. So, I did this on port 81.
Open the Port
Start the getting-started container
6d44c9240e688b69a212fe24e58d2302b658bfcbcee787030943b04f12cde38b
Test that the container is running and on the proper port.
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6d44c9240e68 docker/getting-started "/docker-entrypoint.…" 6 seconds ago Up 4 seconds 0.0.0.0:81->80/tcp goofy_elion
Test the port via Powershell
(New-Object System.Net.Sockets.TCPClient –Argument "localhost","81").Connected
True
Open page in local browser http://localhost:81
Hooray! It works! : )
Clean up the container
6d44c9240e68
Remove the firewall rule by Powershell
You're done again!
Thursday, September 10, 2020
SMTP Telnet
I was working an issue with a Microsoft Edge Transport server where the content of the email was getting truncated after 6 lines. I was able to create a test and get show the delivery of the message through the Edge server to the destination mailboxes. But My test did not include the attached file of the messages that were failing. as the file was a really small csv I took up the challenge of generating the email with an attachment through a telnet session.
Steps:
Get the csv attachment.
Generate the mime for the attachment
Modify the text of the telnet session to generate the message
Check the results.
I created a small csv using a text editor
Company,Address,City,State,Zip
CareWorks Technologies,,Dublin,Ohio,43016
CTG,55 Public Square,Cleveland,Ohio,44113
"State Industrial Products, Inc.",3100 Hamilton Avenue,Cleveland,Ohio,44114
"Finast Supermarkets, Inc.",17000 Rockside Road,Maple Heights,Ohio,44137
Q29tcGFueSxBZGRyZXNzLENpdHksU3RhdGUsWmlwDQpDYXJlV29ya3MgVGVjaG5vbG9naWVzLCxEdWJsaW4sT2hpbyw0MzAxNg0KQ1RHLDU1IFB1YmxpYyBTcXVhcmUsQ2xldmVsYW5kLE9oaW8sNDQxMTMNCiJTdGF0ZSBJbmR1c3RyaWFsIFByb2R1Y3RzLCBJbmMuIiwzMTAwIEhhbWlsdG9uIEF2ZW51ZSxDbGV2ZWxhbmQsT2hpbyw0NDExNA0KIkZpbmFzdCBTdXBlcm1hcmtldHMsIEluYy4iLDE3MDAwIFJvY2tzaWRlIFJvYWQsTWFwbGUgSGVpZ2h0cyxPaGlvLDQ0MTM3DQo=
telnet 10.0.0.10 25HELO lesley.mycompany.comMAIL FROM: <lesley@mycompany.com>RCPT To: <lesleyphillips@yahoo.com>DATAsubject: TLX21MLC1 : PCC LOADER JOB COMPLETEDMIME-Version: 1.0Content-Type: multipart/mixed; boundary=border--borderContent-Type: text/plainA short list of companies I've worked at-Lesley--borderContent-Type: application/octet-streamContent-Transfer-Encoding: base64;Content-Disposition: attachment;filename="Companies.CSV"Q29tcGFueSxBZGRyZXNzLENpdHksU3RhdGUsWmlwDQpDYXJlV29ya3MgVGVjaG5vbG9naWVzLCxEdWJsaW4sT2hpbyw0MzAxNg0KQ1RHLDU1IFB1YmxpYyBTcXVhcmUsQ2xldmVsYW5kLE9oaW8sNDQxMTMNCiJTdGF0ZSBJbmR1c3RyaWFsIFByb2R1Y3RzLCBJbmMuIiwzMTAwIEhhbWlsdG9uIEF2ZW51ZSxDbGV2ZWxhbmQsT2hpbyw0NDExNA0KIkZpbmFzdCBTdXBlcm1hcmtldHMsIEluYy4iLDE3MDAwIFJvY2tzaWRlIFJvYWQsTWFwbGUgSGVpZ2h0cyxPaGlvLDQ0MTM3DQo=--border--.quit
Friday, July 24, 2020
Python - Has Your Password Been Pwned?
And, when you use a password 'R\Ts)-f]'
Here's what is happening...
Putting in the password of '12345' generates the following hash...
'8CB2237D0679CA88DB6464EAC60DA96345513964'
Breaking that in to two parts get me a query part: '8CB22'
And, a search part: '37D0679CA88DB6464EAC60DA96345513964'
I get the results from https://api.pwnedpasswords.com/range/8cb22 (notice the query part at the end) and scan for the search part which points me to line 121. You should go to that page and look at the results.
'37D0679CA88DB6464EAC60DA96345513964:2389787'From which I get the number of hits at the end as: 2389787
The front end of the pwned passwords web site is: https://haveibeenpwned.com/Passwords
If you are looking for good passwords, try the folks at Gibson Research. They have some good information on what makes a good password.
Lastly, 2600 is available at https://2600.com
Sunday, June 28, 2020
Python Gmail BCC SMPT
It's not perfect, but it is a good starting place....
And here is the important part of the header...

