Skip to content

Instantly share code, notes, and snippets.

@Oliver-ke
Last active July 23, 2020 07:45
Show Gist options
  • Save Oliver-ke/f43e3c329edf4912dd0805d7071d6a15 to your computer and use it in GitHub Desktop.
Save Oliver-ke/f43e3c329edf4912dd0805d7071d6a15 to your computer and use it in GitHub Desktop.

This gist contains useful code, packagesS, script, commands for computer networking and systems admins

Scripts

Type: (powershell)
Purpose: Provides users file access to admin on login
$user = "presidential\wheel"
$paths = @($env:userprofile)
$folders = @(
    "AppData",
    "Local AppData",
    "Desktop",
    "Start Menu",
    "Personal",
    "My Pictures",
    "My Music",
    "My Video",
    "Favorites",
    "{56784854-C6CB-462B-8169-88E350ACB882}",
    "{374DE290-123F-4565-9164-39C4925E467B}",
    "{BFB9D5E0-C6A9-404C-B2B2-AE6DB6AF4968}",
    "{7D1D3A04-DEBB-4115-95CF-2F29DA2920DA}",
    "{4C5C32FF-BB9D-43B0-B5B4-2D72E54EAAA4}"
)
foreach ($folder in $folders) {
    $paths += $(Get-ItemPropertyValue 'HKCU:\software\microsoft\windows\currentversion\explorer\shell folders\' -Name $folder)
}

foreach ($path in $paths) { 
    $acl = Get-Acl $path
    if (!($acl.Access | ?{$.IdentityReference -match [regex]::escape($user) -and $.FileSystemRights -match "FullControl"}))
    { 
        $InheritanceFlag = [System.Security.AccessControl.InheritanceFlags]::ContainerInherit -bor [System.Security.AccessControl.InheritanceFlags]::ObjectInherit
        $PropagationFlag = [System.Security.AccessControl.PropagationFlags]::None
        $objType = [System.Security.AccessControl.AccessControlType]::Allow 
        $permission = $user, "FullControl", $InheritanceFlag, $PropagationFlag, $objType      
        $AccessRule = New-Object System.Security.AccessControl.FileSystemAccessRule $permission
        $acl.SetAccessRule($AccessRule)
        (Get-Item $path).SetAccessControl($acl)
        Write-Host "Done it"
    } else {
        Write-Host "Nothing to do"
    }
}

Parkage/utils

Type: linux parkage (virsh) Description: linux virtualization package

  • List running virtual machine
$ virsh list
  • List all virtual machine
$ virsh list --all

. . .

type: virt-manager Purpose: Starts up the vietualization manager

$ virt-manager

How to's

Type: Reset ubuntu password Purpose: Reset ubuntu user password [Source Link)[https://itsfoss.com/how-to-hack-ubuntu-password/]

  1. Boot into recovery mode
  2. Drop to root shell prompt
  3. Remount the root with write access
$ mount -rw -o remount /
  1. Reset username or password
$ ls /home
$ passwd username

Commands

Type: SSH Purpose: Connecting to a remote computer with port 22

  • Connect with X11 forwarding
$ ssh -X <userName>@<address>
# e.g
$ ssh -X [email protected]
$ ssh -X [email protected]
  • Generate public private key pairs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment