Monday, September 1, 2025

Windows services listing

 list all non Microsoft services:


Get-WmiObject win32_service | Where-Object {

    $_.Caption -notmatch "Windows" -and

    $_.PathName -notmatch "Windows" -and

    $_.PathName -notmatch "Microsoft" -and

    $_.PathName -notmatch "policyhost.exe" -and

    $_.Name -ne "LSM" -and

    $_.PathName -notmatch "OSE.EXE" -and

    $_.PathName -notmatch "OSPPSVC.EXE" -and

    $_.PathName -notmatch "Microsoft Security Client"

} | Select-Object Name, DisplayName, PathName, StartName



Display user names for services:
Get-WmiObject -Class Win32_Service | Select-Object Name, StartName

Friday, August 22, 2025

Expand disk

Step 2: Expand the Partition

From your fdisk output, I can see that /dev/sda1 (your root partition) is only using 29.9G of the available 128 GiB disk space. You need to expand this partition:

1.       Check current partition layout:

sudo lsblk

2.      Use growpart to expand the partition:

sudo growpart /dev/sda 1

This command expands partition 1 on /dev/sda to use all available space.[1]

3.      If growpart is not installed, install it first:

# For Ubuntu/Debian:
sudo apt update && sudo apt install cloud-guest-utils

# For CentOS/RHEL:
sudo yum install cloud-utils-growpart

Step 3: Resize the Filesystem

After expanding the partition, you need to resize the filesystem to use the new space:

1.       For ext4 filesystem (most common):

sudo resize2fs /dev/sda1

2.      For XFS filesystem:

sudo xfs_growfs /

Step 4: Verify the Changes

Check that the filesystem now shows the expanded size:

df -h


Wednesday, August 20, 2025

disable onedrive personal sync

 New-Item -Path "HKCU:\Software\Policies\Microsoft" -Name "OneDrive" -Force

Set-ItemProperty -Path "HKCU:\Software\Policies\Microsoft\OneDrive" -Name "DisablePersonalSync" -Value 0 -Type DWord -Force


organize your files based on creation time

 # PowerShell script to organize files into date-based folders

# Creates folders in format: YYYY-MM-DD


# Set the source directory (current directory by default)

$sourceDirectory = Get-Location


# Get all files in the source directory

$files = Get-ChildItem -Path $sourceDirectory -File


Write-Host "Starting file organization..." -ForegroundColor Green

Write-Host "Source directory: $sourceDirectory" -ForegroundColor Yellow


foreach ($file in $files) {

    try {

        # Get the file's creation date and format it as YYYY-MM-DD

        #$fileDate = $file.CreationTime

        $fileDate = $file.LastWriteTime

        $folderName = $fileDate.ToString("yyyy-MM-dd")

        

        # Create the target folder path

        $targetFolder = Join-Path -Path $sourceDirectory -ChildPath $folderName

        

        # Create the folder if it doesn't exist

        if (-not (Test-Path -Path $targetFolder)) {

            New-Item -Path $targetFolder -ItemType Directory -Force | Out-Null

            Write-Host "Created folder: $folderName" -ForegroundColor Cyan

        }

        

        # Move the file to the target folder

        $targetPath = Join-Path -Path $targetFolder -ChildPath $file.Name

        

        # Check if file already exists in target location

        if (Test-Path -Path $targetPath) {

            Write-Host "File already exists in target: $($file.Name) -> $folderName" -ForegroundColor Yellow

        } else {

            Move-Item -Path $file.FullName -Destination $targetPath

            Write-Host "Moved: $($file.Name) -> $folderName" -ForegroundColor Green

        }

        

    } catch {

        Write-Host "Error processing file $($file.Name): $($_.Exception.Message)" -ForegroundColor Red

    }

}


Write-Host "File organization complete!" -ForegroundColor Green


# Display summary of created folders

$createdFolders = Get-ChildItem -Path $sourceDirectory -Directory | Sort-Object Name

Write-Host "`nCreated folders:" -ForegroundColor Yellow

foreach ($folder in $createdFolders) {

    $fileCount = (Get-ChildItem -Path $folder.FullName -File).Count

    Write-Host "  $($folder.Name) ($fileCount files)" -ForegroundColor White

}


Monday, July 7, 2025

Create a cert from certreq

 1. Create a .inf file for your cert req


[Version]

Signature="$Windows NT$"


[NewRequest]

;Change to your,country code, company name and common name

Subject = "C=JP, O=SOME Logistics Co. Ltd., L=Shinagawa-Ku, S=Tokyo, CN=something.example.com"



KeySpec = 1

KeyLength = 4096

Exportable = TRUE

MachineKeySet = TRUE

SMIME = False

PrivateKeyArchive = FALSE

UserProtected = FALSE

UseExistingKeySet = FALSE

ProviderName = "Microsoft RSA SChannel Cryptographic Provider"

ProviderType = 12

RequestType = PKCS10

KeyUsage = 0xa0


[EnhancedKeyUsageExtension]

OID=1.3.6.1.5.5.7.3.1 ; this is for Server Authentication / Token Signing

OID=1.3.6.1.5.5.7.3.2




MachineKeySet - TRUE means it will be stored in Machine "Certificate Enrolment Requests" folder.


2. Request it:

certreq -new .\request_scapp_test.inf .\request_scapp_test.csr

3. Check it

openssl req -in .\request_scapp_test.csr -noout -text | clip


Saturday, April 26, 2025

security scanner - draft

 1. https://greenbone.github.io/docs/latest/22.4/container/index.html

2, Nessus essentials: https://medium.com/@harrmahar/installing-tenable-nessus-essentials-free-in-30-minutes-using-docker-aa668a1620a0

testing against an vulnerable app: https://www.vulnhub.com/entry/damn-vulnerable-web-application-dvwa-107,43/


DevSevOps guidelines: https://owasp.org/www-project-devsecops-guideline/latest/



git config

 settings in git:




system specific configs are not very often in use. Those are useful if some binary that git is dependent is missing.


Global config is for most of your preferences 

local config - for one-off special case changes.


Reading: git config --global user.name

Setting: git config --global user.name "User Name"


settings written to ~/.gitconfig


List all configs: git config --list

verbose: git config --list --show-origin

more verbose: git config --list --show-origin --show-scope


Unset: git config --local --unset user.name 


.gitattributes

*.js text

*.ps1 eol=crlf

*.sh eol=lf


Filters in fit allow you to securely store secret data in git when pushing and restore it when data is pulled.