Skip to content

Instantly share code, notes, and snippets.

@newyear2006
newyear2006 / SMTPStartTLS.PS1
Created August 23, 2015 22:09
Beispiel wie man eine einfache Verbindung zu einem SMTP-Server aufbauen kann, zum Prüfen, ob er erreichbar ist, anschließend STARTTLS aktiviert um auf eine sichere Verbindung zu kommen und dann den Benutzer mit Passwort abzufragen, ob dieser angemeldet werden kann.
# Verbindung zu Web.de aufbauen
$c=Test-NetConnection smtp.web.de -Port 587
# Antwort vom SMTP-Server holen und ausgeben
[byte[]]$buffer= @(0) * $c.TcpClientSocket.Available
$c.TcpClientSocket.Receive($buffer)
[System.Text.Encoding]::ASCII.GetString($buffer)
# Begrüßung durchführen
$buffer=[System.Text.Encoding]::ASCII.GetBytes("EHLO $Env:Computername`r`n")
@newyear2006
newyear2006 / Format-Hex.PS1
Last active August 29, 2015 14:12
Format-Hex
# Format-Hex based on http://www.leeholmes.com/blog/2009/11/23/hex-dumper-in-powershell/
# Extended with additional parameters and fixed some formatting issues.
##############################################################################
##
## Format-Hex
##
## From Windows PowerShell Cookbook (O’Reilly)
## by Lee Holmes (http://www.leeholmes.com/guide)
##
$SFTCode = @"
[DllImport("kernel32")] public static extern uint EnumSystemFirmwareTables (uint FirmwareTableProviderSignature, IntPtr pFirmwareTableBuffer, uint BufferSize);
[DllImport("kernel32")] public static extern uint GetSystemFirmwareTable (uint FirmwareTableProviderSignature, uint FimrwareTableID, IntPtr pFirmwareTableBuffer, uint BufferSize);
"@
$SFT = Add-Type -MemberDefinition $SFTCode -Name "SFTKlasse" -Language CSharp -UsingNamespace "System.Reflection", "System.Diagnostics", "System.Collections.Generic" -PassThru
# 0×41435049=ACPI ? https://github.com/michaelforney/coreboot/blob/master/src/include/cbmem.h
@newyear2006
newyear2006 / TestDatei.ps1
Last active January 2, 2016 05:29
Nochmal der Versuch eine Beschreibung hinzuzufügen
$conn = New-Object system.net.sockets.tcpclient($host, $port)
$stream = New-Object system.net.security.sslstream($conn.getstream(), $null, {
Write-Host $args[2].ChainElements[0].Certificate.Subject;
Write-Host "PolicyErrors: $($args[3])";
# Immer True zurückgeben, damit alle Zertifikate auch mit Fehler akzeptiert werden.
$true;
})
$result = $stream.authenticateasclient("chocolatey.org")
$conn.Close()
$conn = New-Object system.net.sockets.tcpclient($host, $port)
$stream = New-Object system.net.security.sslstream($conn.getstream(), $null, {
Write-Host $args[2].ChainElements[0].Certificate.Subject;
Write-Host "PolicyErrors: $($args[3])";
})
$result = $stream.authenticateasclient("chocolatey.org")
$conn.Close()