Thursday, June 30, 2016

View SSL/TLS Certificate Info with OpenSSL Command

You can simply check the SSL/TLS certificate information which is listening at non-http port (like STMP) by using the OpenSSL tool. All you need to know is to the port that uses encrypted connection. For example, I view the certificate info at CentOS website & TLS certificate used for smtp connection. With WSL, OpenSSL already installed and you're ready to go.

For example here, I check the CentOS website & TLS certificate which is used for smtp connection.

For SSL connection:
openssl s_client -showcerts -connect www.centos.org:443

For TLS connection:
openssl s_client -connect mail.centos.org:25 -starttls smtp



                                              Figure-1: Checking SSL certificate info




                                               Figure-2: Checking TLS certificate info

Friday, June 17, 2016

Creating Active Directory Users in the Nested OUs

It is the powershell script that will automatically create AD users. What makes it unique is that all the necessary OUs (even nested OUs) are created in advance before users creation. So, you won’t need a separate script for both tasks. Here, I give the screenshot of my testing domain, with example users defined in my csv file.

You must include these properties as the csv file headers (See Fig-2). But leave the values blank if some users do not have these properties.

EmployeeID, DisplayName, OU, Description, Name, GivenName, SurName, SamAccountName, Title, Departement, Domain, Office, OfficePhone, Company, EmailAddress, Password

It takes only 3 min to create 1500 users for me, Cheers!



                         Figure-1: Creating users in my testing domain

Thursday, June 9, 2016

Powershell: Find When Active Directory Users' Memership, OU and Creation Date

It's a one-liner command that I use to find the most common AD attributes including the Creation date, Member Of and OU location. I attached the screenshot as example.

Command:

Get-ADUser -filter * -property name,displayname,MemberOf,description,Title,TelephoneNumber,CanonicalName,whencreated,emailaddress| select Name,
Displayname, @{Name="MemberOf";Exp={ ((-join (($_.memberof.split(',')) -like "*cn=*") ) -replace 'CN=',",").TrimStart(",")  }}, Description, Title, TelephoneNumber, @{Name="OU";Exp={ $_.CanonicalName.Remove($_.CanonicalName.LastIndexOf($_.Name)-1)  }}, Whencreated, Emailaddress

You can export to CSV file with the following commands.

Get-ADUser -filter * -property name,displayname,MemberOf,description,Title,TelephoneNumber,CanonicalName,whencreated,emailaddress| select Name,
Displayname, @{Name="MemberOf";Exp={ ((-join (($_.memberof.split(',')) -like "*cn=*") ) -replace 'CN=',",").TrimStart(",")  }}, Description, Title, TelephoneNumber, @{Name="OU";Exp={ $_.CanonicalName.Remove($_.CanonicalName.LastIndexOf($_.Name)-1)  }}, Whencreated, Emailaddress| export-csv -NoTypeInformation ADuser_Properties.csv




Friday, June 3, 2016

Powershell: Find Which Running Processes are Connecting to the Internet

These days, I have been looking for a way to find which running processes on my machines are accessing the internet without my consent. And fortunately, I found a script from TechNet Gallery written by Cookie.Monster. The script extract the connection info from netstat command and create Custom Object for further processing. So, I just changed the by adding some regx to find the public IP addresses. For testing purpose, I use the TeamViewer on my machine. Note: You need to enable Remote Powershell to execute on multiple computers. If you are new to powershell, check here how to make powershell remoting.