Java: Start profiler

Add the following options to the java: -Dcom.sun.management.jmxremote-Dcom.sun.management.jmxremote.port=8010-Dcom.sun.management.jmxremote.local.only=false-Dcom.sun.management.jmxremote.authenticate=false-Dcom.sun.management.jmxremote.ssl=false

Read More

Linux: Clear systemd log

You can use the following command, as superuser, to clear the systemd logs: Keep the last 7 days: journalctl –vacuum-time=7d Keep the last 100Mb: journalctl –vacuum-size=100M      

Read More

Powershell: Check when a LOCAL user was last logged in.

Within Powershell you can also see when a LOCAL user was last logged in.This can be done with the following one-liner: $([ADSI]”WinNT://$env:COMPUTERNAME”).Children | where {$_.SchemaClassName -eq ‘user’} | ft name,lastlogin example output: name lastlogin —- ——— {localadmin} {28/09/2016 08:57:19} {nx} {05/01/2017 19:52:58} {Visitor}      

Read More

Powershell: Find files larger than XXX

With Powershell you can also find files which are larger than a certain size.This can be accomplished with the command below.In this example we are looking for files larger than 100MB, on the C drive. Get-ChildItem c:\ -Recurse | Where-Object {$_.Length -gt 100MB}  

Read More

Powershell: Open TCP listener port

If you want to test a firewall rule, while the application isn’t ready yet, you can start that port on the Windows server using Powershell.This way you can test the firewall functionality.Those actions can be done with the following commands: $Listener = [System.Net.Sockets.TcpListener]4444; $Listener.Start(); Where “4444” is the TCP port…

Read More

Powershell: get TCP counters for IPv4

Performance issues. Everybody had them once, and more 🙂If you are using Windows 2012+ and Powershell, you can use the Get-Counter command in order to provide you more information regarding the TCP connections.In the example below, we are getting the counters for IPv4 TCP:   Get-Counter -Counter \TCPv4\*   This…

Read More

Powershell: Set global dns searchlist

  If you want to configure the DNS suffix search list on Windows 2012+, you can use the set-DnsclientGlobalSetting command, as shown in the example below.This will set the DNS search list to “domain.local”: set-DnsClientGlobalSetting -SuffixSearchList  @(“domain.local”)    

Read More

Powershell: Change binding order network interfaces

Sometimes there are some applications which take the ‘first network card’ in order to send/receive traffic.If you have multiple network cards, this can be problematic of course.In case you want to resolve that, you can change the order of the network cards.In order to do that, first get the interface…

Read More

Postfix: Clear postfix mail queue

Is your postfix mail queue full of spam? You are not the only one 🙂 In that case it could be interesting to clear your queue, before the spam gets send out. In order to remove all mail from the postfix queue, execute the following command as superuser: #> postsuper…

Read More

PowerShell: Stop and/or Start a command at certain date/time

Hello, In addition to “PowerShell: Run command at certain date/time”, we got the request to include a start time also.In the script below, we are doing such thing. (write-host commands are in Dutch tho). In case the user specifies a valid start date/time, the script will start the program. (example program).If the user…

Read More

PowerShell: Stop command at certain date/time

Sometimes it can be handy to automatically stop a process at a certain time.I did this using the following powershell script. The script will first ask at what time it needs to be stopped. You can specify seconds if needed, but not required, or you can specify a date. Even milliseconds,…

Read More

Fail2ban: show active jails

Fail2ban is a daemon that can be used to monitor the logs of services and ban clients that based on incorrect behaviour.A must have on your Linux system.But sometimes you can forget enabling the correct jails, therefore always check the active jails on your system.This can be done with the…

Read More

ModSecurity: Access denied with code 403 (phase 2). Woocommerce

If you are using WordPress & Woocommerce in combination with mod_security2, you may have some false positives.In case you are having issues, you can use the Apache (.htaccess for example) “whitelist” below. This of course as an example.   <LocationMatch “/”>   SecRuleRemoveById 910006 # Google robot activity – Useful in…

Read More