Monthly Archives: November 2019

Test SMTP TLS with OpenSSL with Auth

On a linux box type these two commands

echo -ne '[email protected]' | base64
echo -ne 'password' | base64

The command will return with the username and password in base64 format.
Example:

root@Linux-homeserver:~# echo -ne '[email protected]' | base64
dXNlcm5hbWVAZG9tYWluLnByZWZpeA==
root@Linux-homeserver:~# echo -ne 'password' | base64
cGFzc3dvcmQ=

So now you need to telnet with OpenSSL to the mailserver:

openssl s_client -debug -starttls smtp -crlf -connect mailserver.kennethdalbjerg.dk:465

After you have connection, you need to present yourself
Example:

ehlo host.kennethdalbjerg.dk

Some mailserver, do check if the ehlo is you corrert PTR record, for the IP address you are coming from, but most do not.

The mail server will return with:
250 mailserver.kennethdalbjerg.dk Hello dell1 [10.10.10.10]

You will now try to authenticated you self, if you don’t need to AUTH, please go to last code example in this blog.

AUTH LOGIN

And the mailserver will return with:
VXNlcm5hbWU6

Here you type you username in base64 format

dXNlcm5hbWVAZG9tYWluLnByZWZpeA==

And the mailserver will return with:
UGFzc3dvcmQ6

Please now type you password in base64 format

cGFzc3dvcmQ=

The server should now return with:
235 2.7.0 Authentication successful

After this you type normal email request to send an email
Example: (You should not type the line starting with a >, it are what the mailserver return to you.

mail from: [email protected]
> 250 2.1.0 Sender OK
rcpt to: [email protected]
> 250 2.1.5 Recipient OK
data
> 354 Start mail input; end with <CRLF>.<CRLF>
test
.
> 250 2.6.0 <604863cb-3dcc-4cee-9c1a-77fb6d951d43@mailserver.kennethdalbjerg.dk> [InternalId=9753870729240, Hostname=mailserver.kennethdalbjerg.dk] 1203 bytes in 1.581, 0,743 KB/sec Queued mail for delivery
quit
>221 2.0.0 Service closing transmission channel

Match Veeam replicas folder with VM

If you need to see what VM, that match to a VEEAM Replica folder on the disk system, this can be the solution
The veeam replica folder looks like this:

Let say that you need to find the VM, behind the folder “1cd328dbde6b42569a18b156570cb589”
Run this command on you SCVMM Powershell

get-vm | where location -like "*1cd328dbde6b42569a18b156570cb589*" | select name

This will give you the name of the VM behind the folder “1cd328dbde6b42569a18b156570cb589”

SQL Agent Job history – T SQL

Here are a Script, that you can use to extract the SQL Agent Job History

select 
 j.name as 'JobName',
 msdb.dbo.agent_datetime(run_date, run_time) as 'RunDateTime',
 ((run_duration/10000*3600 + (run_duration/100)%100*60 + run_duration%100 + 31 ) / 60) 
         as 'RunDurationMinutes'
From msdb.dbo.sysjobs j 
INNER JOIN msdb.dbo.sysjobhistory h 
 ON j.job_id = h.job_id 
where j.enabled = 1   --Only Enabled Jobs
--and j.name = 'TestJob' --Uncomment to search for a single job
/*
and msdb.dbo.agent_datetime(run_date, run_time) 
BETWEEN '12/08/2012' and '12/10/2012'  --Uncomment for date range queries
*/
order by JobName, RunDateTime desc

This will also tell you the job steps

select 
 j.name as 'JobName',
 s.step_id as 'Step',
 s.step_name as 'StepName',
 msdb.dbo.agent_datetime(run_date, run_time) as 'RunDateTime',
 ((run_duration/10000*3600 + (run_duration/100)%100*60 + run_duration%100 + 31 ) / 60) 
         as 'RunDurationMinutes'
From msdb.dbo.sysjobs j 
INNER JOIN msdb.dbo.sysjobsteps s 
 ON j.job_id = s.job_id
INNER JOIN msdb.dbo.sysjobhistory h 
 ON s.job_id = h.job_id 
 AND s.step_id = h.step_id 
 AND h.step_id <> 0
where j.enabled = 1   --Only Enabled Jobs
--and j.name = 'TestJob' --Uncomment to search for a single job
/*
and msdb.dbo.agent_datetime(run_date, run_time) 
BETWEEN '12/08/2012' and '12/10/2012'  --Uncomment for date range queries
*/
order by JobName, RunDateTime desc

Thanks to Chad Churchwell  – https://www.mssqltips.com/sqlservertip/2850/querying-sql-server-agent-job-history-data/