Skip to content

Instantly share code, notes, and snippets.

View tommytri's full-sized avatar
🎯
be stronger

Tommy Tri tommytri

🎯
be stronger
  • Hanoi, Vietnam
View GitHub Profile
@tommytri
tommytri / newsletter.md
Created November 13, 2024 02:17 — forked from unixsysadmin/newsletter.md
Sysadmin and DevOps Newsletters

DevOps

  • DevOpsish - DevOps’ish is a weekly newsletter assembled by open source contributor, DevOps veteran, and CNCF Ambassador Chris Short.

  • DevOpsLinks - DevOpsLinks is a community of aspiring DevOps professionals and practicioners from all over the world.

  • DevOps Weekly - weekly devops news from Gareth Rushgrove.

  • WebOps Weekly - A weekly newsletter on Web operations, infrastructure, performance, the backend, and tooling, from the browser down to the metal.

@tommytri
tommytri / checkhiddensvc.ps1
Created January 11, 2025 06:49 — forked from joswr1ght/checkhiddensvc.ps1
Identify Hidden Windows Services
Compare-Object -ReferenceObject (Get-Service | Select-Object -ExpandProperty Name | % { $_ -replace "_[0-9a-f]{2,8}$" } ) -DifferenceObject (gci -path hklm:\system\currentcontrolset\services | % { $_.Name -Replace "HKEY_LOCAL_MACHINE\\","HKLM:\" } | ? { Get-ItemProperty -Path "$_" -name objectname -erroraction 'ignore' } | % { $_.substring(40) }) -PassThru | ?{$_.sideIndicator -eq "=>"}
@tommytri
tommytri / ubuntu-server-hardening.md
Created February 8, 2025 02:59 — forked from mirajehossain/ubuntu-server-hardening.md
ubuntu-server-hardening checklist

Ubuntu-Server-Hardening

1. Secure Shared Memory

What is shared memory?

Shared memory is an efficient means of passing data between programs. Because two or more processes can use the same memory space, it has been discovered that, since shared memory is, by default, mounted as read/write, the /run/shm space can be easily exploited. That translates to a weakened state of security.

If you’re unaware, shared memory can be used in an attack against a running service. Because of this, you’ll want to secure that portion of system memory.

@tommytri
tommytri / bash_update_time.sh
Created June 11, 2025 09:02
Update time from web service online (not using ntp service). Use for update time when ntp service is blocked by firewall
#!/bin/bash
# Get the system's current timezone
TIMEZONE=$(timedatectl show --property=Timezone --value)
# Fetch the current time from TimeAPI.io for the detected timezone
TIME_DATA=$(curl -s "https://timeapi.io/api/Time/current/zone?timeZone=$TIMEZONE" | jq -r '.dateTime')
# Extract the date and time
CURRENT_TIME=$(echo "$TIME_DATA" | awk -F. '{print $1}' | sed 's/T/ /')
# Get current time zone
$TIMEZONE = (Get-TimeZone).Id
$TIMEZONE = "Asia/Saigon"
# Fetch the correct time from TimeAPI.io using Invoke-WebRequest
$RESPONSE = Invoke-WebRequest -Uri "https://timeapi.io/api/Time/current/zone?timeZone=$TIMEZONE"
$TIME_DATA = $RESPONSE.Content | ConvertFrom-Json
# Format dateTime as "dd/MM/yyyy HH:mm:ss"
$CURRENT_TIME = "{0:D2}/{1:D2}/{2} {3:D2}:{4:D2}:{5:D2}" -f $TIME_DATA.day, $TIME_DATA.month, $TIME_DATA.year, $TIME_DATA.hour, $TIME_DATA.minute, $TIME_DATA.seconds
@echo off
setlocal enabledelayedexpansion
:: Get current time zone
for /f "tokens=2 delims==" %%A in ('wmic timezone get Description /value') do set TIMEZONE=%%A
:: Get current time for the detected timezone
for /f %%A in ('curl -s "https://timeapi.io/api/Time/current/zone?timeZone=!TIMEZONE!"') do set TIME_DATA=%%A
:: Extract Date and Time
@tommytri
tommytri / AccessChk.bat
Created July 7, 2025 11:26 — forked from api0cradle/AccessChk.bat
AppLocker hardening
accesschk -w -s -u Users "C:\Program Files" >> programfiles.txt
accesschk -w -s -u Everyone "C:\Program Files" >> programfiles.txt
accesschk -w -s -u "Authenticated Users" "C:\Program Files" >> programfiles.txt
accesschk -w -s -u Interactive "C:\Program Files" >> programfiles.txt
accesschk -w -s -u "This Organization" "C:\Program Files" >> programfiles.txt
accesschk -w -s -u "Authentication authority asserted identity" "C:\Program Files" >> programfiles.txt
accesschk -w -s -u "Mandatory Label\Medium Mandatory Level" "C:\Program Files" >> programfiles.txt
accesschk -w -s -u %username% "C:\Program Files" >> programfiles.txt
accesschk -w -s -u Users "C:\Program Files (x86)" >> programfilesx86.txt