Last active
June 22, 2025 18:21
-
-
Save dumpvn/6d075f39c79870fca0eece2b99652039 to your computer and use it in GitHub Desktop.
setup repos ps
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <# | |
| . ${{file}} | |
| - vscode | |
| - git scm | |
| #> | |
| winget install --id Git.Git -e --source winget | |
| git config --global core.sshCommand "C:/Windows/System32/OpenSSH/ssh.exe" | |
| $env:GIT_SSH_COMMAND="ssh -o StrictHostKeyChecking=no" | |
| mkdir \tmp | |
| mkdir \REPOS | |
| mkdir (Join-Path $env:USERPROFILE '.ssh') | |
| function get-MasterPassword {'mYSuperSecret'} | |
| if (-not (Get-Module -Name PoShKeePass -ListAvailable)) { Install-Module -Name PoShKeePass -MinimumVersion 2.1.3.0 -Force -Confirm -Scope CurrentUser } | |
| Invoke-WebRequest -UserAgent "Wget" -Uri https://sourceforge.net/projects/keepass/files/KeePass%202.x/2.58/KeePass-2.58.zip/download -OutFile \tmp\KeePass-2.58.zip | |
| Expand-Archive -Path \tmp\KeePass-2.58.zip -Destination (Join-Path $env:USERPROFILE 'KeePass') -Force | |
| explorer (Join-Path $env:USERPROFILE 'KeePass') | |
| if (Test-Path (Join-Path $env:USERPROFILE 'Database.kdbx')) {} else { & (Join-Path $env:USERPROFILE 'KeePass\KeePass.exe') } | |
| function Convert-HexStringToByteArray { | |
| param ( | |
| [Parameter(Mandatory = $true)] | |
| [string]$HexString | |
| ) | |
| # Remove spaces and ensure even length | |
| $cleanHex = $HexString -replace '\s+', '' | |
| if ($cleanHex.Length % 2 -ne 0) { | |
| throw "Hex string must have an even number of characters." | |
| } | |
| # Convert pairs of hex characters to bytes | |
| [byte[]]$bytes = for ($i = 0; $i -lt $cleanHex.Length; $i += 2) { | |
| [Convert]::ToByte($cleanHex.Substring($i, 2), 16) | |
| } | |
| return $bytes | |
| } | |
| function Decrypt-HexStringToTextFile { | |
| param ( | |
| [Parameter(Mandatory=$true)][string]$InputFile, | |
| [Parameter(Mandatory=$true)][string]$Password, | |
| [Parameter(Mandatory=$true)][string]$OutputFile | |
| ) | |
| # Read hex string | |
| $hexString = Get-Content -Path $InputFile -Raw | |
| $hexString = $hexString.trim() | |
| $bytes = Convert-HexStringToByteArray $hexString | |
| $bytes = [byte[]]$bytes | |
| # Extract salt (first 16 bytes), and ciphertext (rest) | |
| $salt = $bytes[0..15] | |
| $cipherBytes = $bytes[16..($bytes.Length - 1)] | |
| # Derive AES key & IV using PBKDF2 | |
| $keyDeriver = New-Object System.Security.Cryptography.Rfc2898DeriveBytes ($Password, $salt, 100000) | |
| $key = $keyDeriver.GetBytes(32) | |
| $iv = $keyDeriver.GetBytes(16) | |
| # Decrypt the ciphertext | |
| $aes = [System.Security.Cryptography.Aes]::Create() | |
| $aes.Key = $key | |
| $aes.IV = $iv | |
| $decryptor = $aes.CreateDecryptor() | |
| $plainBytes = $decryptor.TransformFinalBlock($cipherBytes, 0, $cipherBytes.Length) | |
| $plainText = [System.Text.Encoding]::UTF8.GetString($plainBytes) | |
| # Write plaintext to output file | |
| Set-Content -Path $OutputFile -Value $plainText | |
| Write-Output "Decryption complete. Plain text written to $OutputFile." | |
| } | |
| set-content -path 'c:\tmp\devwithpower-cipher.hex' -value '7d8ddc131d387bfe43aa76890933843f82c8ae03c1e2566d8073c8b5fa0c0428e6e3782f64d57307b9e0137c23290fc4a1afa295fb8fa420f5f4df582b4454307da70b672e4d17e21e7a5f93926bb0772a209eceb7c116e1cb7cc933fd10521a53b7d7b3c20d34acf4f5e9112971a39538a16577333aa11a176538f8ac135cd928bdf38c02e4b494c707d1324d0829649779d3274b25be27e08ff98d25031d18e53e94c1e835d0ffb637efe23d371b97ef97977bcbdd5a69e62c32a5a53b02300008149d7e9c723dff7d301c7516e0a4439a3f4dd1899f263fbf69f2dcad8a340547a89850a48d47c37b36e58bb0e1ba752bc8921b7795c915617de51eece279959daa16f5824ed8153e67816696a83c572547304ee41a98a66485c24149892fd8f7b4a84e129b67a1ddf8dc446028937823c2989b384693c8fc66dbe3a6389228a1a6a15526a371d5ede8cac42263026c3a88f90e900f4e503e17aeb159235240ba1f452d79cda0efb362f23868a1449a30b94695a23db3e2d72214762aa0a2f56e36dc39fa5c6c2b3609b00773437068e43cb788bf12cd15c04224c9b5e2c1371ceb7413d2d9f028bda9187c42344b6295d6b3896325b2509536e37382bddf' | |
| set-content -path 'c:\tmp\devwithpower-pub-cipher.hex' -value '289e5b59f7684bb8979f030731beb8157f7cd35afc65393666329ea5ca45fb2fe8301c7dbddd21d12584fc9ca403ab7534a8417f8e3a4fb0f143d398c97427e605d461da489efdb890e4f435b12a20483a1f8df66cf46121e8a1408659c488bf414a55e9e06f294cd5672df2aca3470f0d8910bf3f9767c77f79036b2dfcac34' | |
| set-content -path 'c:\tmp\config-cipher.hex' -value 'b12edfd879fb1500bbe0fa9859fba4e4188dfb296a872730625328e028bef13924d0d9c7702c5e244ef957b5b80ed4631c7094b4b5697512bc7dbcfe67e230fa9f7c2ae7f5a01737952cf0a80f3ca39b5c784ea30cf84abda91b940a8b8a2a36b72ddb78e790b3a22fbb9cf09275d11d6e987cfebfccff6d30028d8e1fe09fd981393b39ed2450b093f5b37658af4796ea0731e8a3b6502dce1f49a1551e92eacfdf86938dc83b0c2df719fb7e94acd92a94f4bd3e2f634dd4499504780f4fb0297fad4ec7392d0c79a298ba3e21d86b5671e531c565598534e776ecd6a424ad7a91a96b3036bdb4c7bdba706251260e2d593f54a8f18753b7fd18864cd02b48f61a6df157f427318f1c3435abe8973a78341a487b1b10b572b79906215c192b86d3e36a7dfef04c5e58c90474c86ee758964e0bbd163da66b3d2b9c15f948fa95ca782e425dea7750e47a4573bffc77bd661fcc369d718aa1c84940bb74a1836140c704b8abf9b5b7bbe9c363729ac14d9457138ea289e2f5916f26f5b9c0b3801e231c078e1bd010cb824f72333d75be36e7b4d1b386449688660ea82e634de17874feacc5cbb6d5d80c657368c275e1be8d1bf814d6c3e3c97e131b1b3fb5ade4b9d9a89a0888fcd70da04b08b29d640da057122e6ad83e4c2b887ba6e1cc3c25d1542fbed496ced7df0d747da3afb9e1b2608a6ec0ab29dbb6559815030d204795ab6c0e1d5c29ff7e6a877efafa4e13a444b27c1b4ee50d1b0d51a9179defcc408e4cfdb71dae99a4a1d999e02df5388b7c18e43cc1c3d7fc97b22b88005342da6f962b99ad823bef231f98011cfca995b29071d3baff315b8030c5e1304736d70573a3d150eb88365c46914464b99d4806f1b44c04aabf693701a1e2eb2d1bc1d192f6f82acf453deeeba5abdf4988bbd7c8427d22817b4fc6213b78650357ed239e7f9b1dda7590fe4b6e07c2108a5503bd6c1981d856fd4b5ccec8c81ff4501241b96a3c96eb69dbb25801851789a9a594e571f3e92ca34d348b798f9da881ae18cb3438fe99ecbdfb5c19d13072a6df6fc05da1d413bbf9820cfa94a68696d946fb30d1efb2feba5cbf5255758ff61da5d8a463847084abb1b794b7576a86f6be018d81a29e51b7bc8d1fdf8dd8e23e1b7d126fa39ddaf3465ae62dd4e2603e79a134a3cbe5894b760bd4de4316fc0aa2a40539d0b6387fb953f371f9aa383fe339b30635f1a1c1768b500a8cc68713dd5c4f19c3940da4e66af251878f0c417cef65e8241f426dc37a4cca4d194b7329d62a2348a9575dd3055c3160f3349084c1ce5a75ac98daeda7769328106e946abeed3003322ea0910e6b720d57ad4bd44c0fa7301d9fd8089e34c3d53965ceef695a9a9867634088318325b0523c1e9d458db2fb520dfb7c85c63d53030279044747860c929f7ecc45eb28f950216a48a13bd8ea46dcfd86140401902a85a07eafa5c9ea61386c1896d428bcaac86b6f0972d59555eb336f030382edebccbf2f7ab81ce2740ffad8980ffc623a189d329f41d822b971a13dc02992af7e12dcd96a559160eb7c28579b4b6cd834a61db355d9c70e5e2f687cca0232753747e1492b1b895eaed65643608e4bedc280ffd38eab25924325f89501f125446c8a0105f0367753a7bb6172d74c22d981b2aa15eb60ee3d62b4fb7d734aeaf8655005a93ca371291ebe03cc99c135' | |
| Decrypt-HexStringToTextFile -InputFile 'c:\tmp\devwithpower-cipher.hex' -Password (Get-MasterPassword -ClearText) -OutputFile (Join-Path $env:userprofile '.ssh\devwithpower') | |
| Decrypt-HexStringToTextFile -InputFile 'c:\tmp\devwithpower-pub-cipher.hex' -Password (Get-MasterPassword -ClearText) -OutputFile (Join-Path $env:userprofile '.ssh\devwithpower.pub') | |
| Decrypt-HexStringToTextFile -InputFile 'c:\tmp\config-cipher.hex' -Password (Get-MasterPassword -ClearText) -OutputFile (Join-Path $env:userprofile '.ssh\config') | |
| cd c:\repos | |
| git clone [email protected]:dev4power/xxxxxx.git | |
| code $Profile |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment