Jere's Techblog

Nextcloud Client multiple Proxy Settings

First of all I would like to explain that the tinkering which was made is possibly not supported. I couldn’t find an article about it in the NextCloud documentation.

I recently had the problem that my Nextcloud accounts in the corporate network had no connection to the backend.

The reason for this is of course the proxy, depending on which storage/webhoster the Nextcloud server was hosted at, it was blocked by the default system proxy of the client running NextCloudClient. With another proxy entry I could unlock other backends but the others were blocked again…. It was a neverending blocking story…. in principle I just had to put 2 proxy systems in the Nextcloud client configuration.

This is very easy in principle. You configure the proxy e.g. a manual HTTPS proxy and copy the content of %appdata%\Nextcloud\nextcloud.cfg into the clipboard.

Then close the file and set another proxy setting in the NextCloud Client GUI, e.g. “Use System Proxy”.
Then you have to open the file %appdata%\Nextcloud\nextcloud.cfg again and add the entry.

If now something is changed in the proxy/settings, then the made Config setting flies away. The same happens when the NextCloud client is restarted. But you could solve this by doing a startup script which replaces the config file after starting the NextCloudClient. Or even better just edit those Proxyentries, so the Userconfiguration will not be affected.

Continue reading...

Get Data from Bluecat DNS Server with REST API

Here is an example how you can use the REST API on the BluecatDNSServer to query data via the workflow interface (alternatively you could use its API directly).
I am sure that you can use this concept for other web interfaces.

The script is a translation of a CURL request. It shows how to query the token and use this “BASIC Token” for further queries.

#BY J.Kühnis
#Invoke Webrequest/RestMethod to get IP Adress & Mac-Adress from Bluecat API
#translation of CURL Commands

############################
#   CURL sample
#
#Get TOKEN
#curl -k https://URL/rest_login -X POST -H "Content-Type: application/json" --data "{\"username\":\"your USERNAME\",\"password\":\"your USERNAME\"}"
#
#GET Request:
#curl -k https://URL/get_ip_infos/get_ip_infos_endpoint -X GET -H "auth: Basic ****SOME TOKEN****" -H "Content-Type: application/json" --data "{\"host\":\"SERVERNAME\"}"
#
#
#result:
#{
#  "ip": "some ip",
#  "mac": "some mac"
#}
############################




#Trust SelfSigned SSL/TLS Channel
add-type @"
    using System.Net;
    using System.Security.Cryptography.X509Certificates;
    public class TrustAllCertsPolicy : ICertificatePolicy {
        public bool CheckValidationResult(
            ServicePoint srvPoint, X509Certificate certificate,
            WebRequest request, int certificateProblem) {
            return true;
        }
    }
"@ 
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy


#Generate Web Token (Basic Token)
Function Get-WebTokenBasic{

    [CmdletBinding()]
    Param(
    [Parameter(Mandatory = $true)][string]$Username,
    [Parameter(Mandatory = $true)][string]$Password
    )

$json=ConvertTo-Json (@{"username"="$Username";"password"="$Password";})
$token = (Invoke-WebRequest -Uri "https://URL/rest_login"  -Body $json -ContentType "application/json" -Method POST).content | Out-String | ConvertFrom-Json

$token = $token.access_token
$global:headers = @{auth="Basic $token"}

}

#Get IP or Mac from Servername
Function Get-DNSBluecatValues{
[CmdletBinding()]
Param(
    [Parameter(Mandatory = $true)][string]$ServerName
    
)

$json4= (@{"host"="$servername";}) | ConvertTo-Json

Try
{
    Get-WebTokenBasic
    $result = Invoke-WebRequest -Uri "https://URL/get_ip_infos/get_ip_infos_endpoint" -Headers $headers -Body $json4 -Method Post -ContentType "application/json"
    $global:result = $result | ConvertFrom-Json
    return $global:result
}
Catch
{
    $ErrorMessage = $_.Exception.Message
    $FailedItem = $_.Exception.ItemName
    Write-Warning "Failed Authentication or Webrequest"
    Break
}


}
Continue reading...

Test TCP Networkports with Powershell

http://portquiz.net/ is a great Website to test any outbound TCP Port.

Of course there are a lot Programm who can check which TCP Ports are open. But i’ll show you a way how you can test the Ports with Powershell.
$16bitint = 1..65535 
foreach ($port in $16bitint) {
    IF (Test-NetConnection -ComputerName portquiz.net -InformationLevel Quiet -Port $port){
          Write-Host $port 
    } 
}

Continue reading...