Last active
January 6, 2021 15:29
-
-
Save numbnet/e0877e0284eee962cd48a53cc5cfeb42 to your computer and use it in GitHub Desktop.
script.RunAsAdmin
This file contains 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
#==== ins.WinGet.OpenSSH.Win.ps1 ====# | |
##=== Install WinGet, OpenSSH Win10=== | |
# Invoke-WebRequest -Uri "https://gist.githubusercontent.com/numbnet/d0604532adb8fd7c3d6c03bfc7fd4058/raw/97189159cc3572595bc21bd3188733f0c2c156bd/InstallWinGet.ps1" -OutFile "C:\PS\WinInstallWinGet.ps1" | ". "$env:SystemDrive\PS\InstallWinGet.ps1" | |
####================================== | |
#### Create folder location | |
#New-Item -Path $env:Temp -Name "OpenSSH" -ItemType Directory -force; | |
New-Item -Path $env:SYSTEMDRIVE -Name "PS" -ItemType Directory -force; | |
##================================== | |
## install WinGet | |
Invoke-WebRequest -Uri "https://github.com/microsoft/winget-cli/releases/download/v0.2.2941-preview/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.appxbundle" -OutFile "C:\PS\WinGet.appxbundle" | Add-AppxPackage "C:\PS\WinGet.appxbundle" | |
####==================================================== | |
#### install Wget | |
winget install "GnuWin32.Wget" | |
{ | |
####==================================================== | |
### Download OpenSSH x64 or x86 | |
if ((Get-WmiObject win32_operatingsystem | select osarchitecture).osarchitecture -like "64*") | |
Write "Windows x64"; # OpenSSH --x64 | |
#### ---------v7.9.0.0p1-Beta----------- | |
#(New-Object System.Net.WebClient).DownloadFile('https://github.com/PowerShell/Win32-OpenSSH/releases/download/v7.9.0.0p1-Beta/OpenSSH-Win64.zip','$env:SYSTEMDRIVE\PS\OpenSSH-Win64.zip'); | |
(New-Object System.Net.WebClient).DownloadFile('https://github.com/PowerShell/Win32-OpenSSH/releases/download/v8.1.0.0p1-Beta/OpenSSH-Win64.zip','$env:SYSTEMDRIVE\PS\OpenSSH\OpenSSH-Win64.zip'); | |
#### ---------v8.1.0.0p1-Beta----------- | |
} else | |
{ | |
Write "Windows x86"; # OpenSSH --x32 | |
#### --------v7.9.0.0p1-Beta------------ | |
#(New-Object System.Net.WebClient).DownloadFile('https://github.com/PowerShell/Win32-OpenSSH/releases/download/v7.9.0.0p1-Beta/OpenSSH-Win32.zip','$env:SYSTEMDRIVE\PS\OpenSSH\OpenSSH-Win64.zip'); | |
#### --------v8.1.0.0p1-Beta------------ | |
(New-Object System.Net.WebClient).DownloadFile('https://github.com/PowerShell/Win32-OpenSSH/releases/download/v8.1.0.0p1-Beta/OpenSSH-Win32.zip','$env:SYSTEMDRIVE\PS\OpenSSH\OpenSSH-Win32.zip'); | |
} | |
####===================================== | |
#### Unzip the files | |
Expand-Archive -Path "$env:SYSTEMDRIVE\PS\OpenSSH\OpenSSH-Win64.Zip" -DestinationPath "$env:ProgramFiles\OpenSSH\"; | |
####==================================================== | |
#### Copy \OpenSSH\OpenSSH-Win64\ \OpenSSH | |
copy '$env:ProgramFiles\OpenSSH\OpenSSH-Win64\*' '$env:ProgramFiles\OpenSSH'; | |
####==================================================== | |
#### Install service | |
. "$env:ProgramFiles\OpenSSH\install-sshd.ps1"; | |
####==================================================== | |
#### Set firewall permissions | |
New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22; | |
####==================================================== | |
#### Set service startup END | |
Set-Service sshd -StartupType Automatic; | |
Start-Service sshd; | |
####==================================================== | |
#### Set Authentication to public key | |
((Get-Content -path $env:ProgramData\ssh\sshd_config -Raw) ` -replace '#PubkeyAuthentication yes','PubkeyAuthentication yes' ` -replace '#PasswordAuthentication yes','PasswordAuthentication yes' ` -replace 'Match Group administrators','#Match Group administrators' ` -replace 'AuthorizedKeysFile __PROGRAMDATA__/ssh/administrators_authorized_keys','#AuthorizedKeysFile __PROGRAMDATA__/ssh/administrators_authorized_keys') | Set-Content -Path $env:ProgramData\ssh\sshd_config; | |
####==================================================== | |
#### Restart after changes | |
Restart-Service sshd; | |
####==================================================== | |
#### force file creation | |
New-item -Path $env:USERPROFILE -Name .ssh -ItemType Directory -force; | |
####==================================================== | |
#### Gen SSH-KEY: | |
#ssh-keygen -t ed25519 -C "$env:USERNAME" -f $env:USERPROFILE\.ssh\$env:COMPUTERNAME.$(Get-Random).ed25519.key | Out-File $env:USERPROFILE\.ssh\file.log -Encoding ascii; | |
ssh-keygen -t ed25519 -C "$env:USERNAME" -f "$env:USERPROFILE\.ssh\$env:COMPUTERNAME.$env:USERNAME.ed25519.key" | Out-File $env:USERPROFILE\.ssh\file.log -Encoding ascii; | |
####==================================================== | |
#### Copy SSH-KEY V1: | |
# echo "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKp3bxeApwQec9N6DaIP1Iq3o7Ks4jcL66wHi1YdqkFC root" | Out-File $env:USERPROFILE\.ssh\authorized_keys -Encoding ascii; | |
#### Copy SSH-KEY V2: | |
cat $env:USERPROFILE\.ssh\*$env:COMPUTERNAME.$env:USERNAME.ed25519.key.pub | Out-File $env:USERPROFILE\.ssh\authorized_keys -Encoding ascii; | |
####==================================================== | |
#### Cleaning Dir | |
Remove-Item -Path $env:ProgramFiles\OpenSSH\OpenSSH-Win64 -Recurse; | |
# Remove-Item -Path $env:Temp\OpenSSH -Recurss | |
####================================= | |
exit |
This file contains 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
REM ===============KitKatDeodexer.bat================= | |
@echo off | |
java -version | |
if errorlevel 1 goto javaerror | |
if exist %~dp0 goto menu | |
REM ======================================== | |
REM | |
:menu | |
echo ======================================== | |
echo KitKat Deodexer | |
echo ---------------------------------------- | |
echo Main Menu | |
echo ---------------------------------------- | |
echo 1 : Create working directory | |
echo 2 : Pull files from your device | |
echo 3 : Deodex all files | |
echo 4 : Add deodexed files to zip | |
echo ---------------------------------------- | |
echo x : Exit | |
echo i : Info | |
echo ======================================== | |
set /p NUM="Choice :" | |
if "%NUM%"=="1" goto wodir | |
if "%NUM%"=="2" goto pfile | |
if "%NUM%"=="3" goto dex | |
if "%NUM%"=="4" goto azip | |
if "%NUM%"=="x" goto quit | |
if "%NUM%"=="i" goto info | |
:wodir | |
cls | |
@echo Creating working directory and system\app system\framework system\priv-app folders... | |
@echo app | |
mkdir system | |
mkdir system\app | |
mkdir system\priv-app | |
mkdir system\framework | |
mkdir work | |
pause | |
cls | |
goto menu | |
:pfile | |
cls | |
cmd\adb wait-for-device | |
@echo Pulling files from your device... | |
cmd\adb pull /system/app system\app | |
cmd\adb pull /system/priv-app system\priv-app | |
cmd\adb pull /system/framework system\framework | |
pause | |
cls | |
goto menu | |
:dex | |
cls | |
@echo; | |
@echo Starting deodex... | |
for %%i in (system\app\*.apk) do ( | |
if exist system\app\%%~ni.odex ( | |
java -jar cmd\baksmali.jar -d system\framework -x system\app\%%~ni.odex -o work\%%~ni | |
java -jar cmd\smali.jar work\%%~ni -o classes.dex | |
cmd\7za a -tzip %%i classes.dex | |
del classes.dex | |
rmdir /Q /S work\%%~ni | |
del system\app\%%~ni.odex | |
) | |
) | |
for %%i in (system\priv-app\*.apk) do ( | |
if exist system\priv-app\%%~ni.odex ( | |
java -jar cmd\baksmali.jar -d system\framework -x system\priv-app\%%~ni.odex -o work\%%~ni | |
java -jar cmd\smali.jar work\%%~ni -o classes.dex | |
cmd\7za a -tzip %%i classes.dex | |
del classes.dex | |
rmdir /Q /S work\%%~ni | |
del system\priv-app\%%~ni.odex | |
) | |
) | |
for %%i in (system\framework\*.apk) do ( | |
if exist system\framework\%%~ni.odex ( | |
java -jar cmd\baksmali.jar -d system\framework -x system\framework\%%~ni.odex -o work\%%~ni | |
java -jar cmd\smali.jar work\%%~ni -o classes.dex | |
cmd\7za a -tzip %%i classes.dex | |
del classes.dex | |
rmdir /Q /S work\%%~ni | |
del system\framework\%%~ni.odex | |
) | |
) | |
for %%i in (system\framework\*.jar) do ( | |
if exist system\framework\%%~ni.odex ( | |
java -jar cmd\baksmali.jar -d system\framework -x system\framework\%%~ni.odex -o work\%%~ni | |
java -jar cmd\smali.jar work\%%~ni -o classes.dex | |
cmd\7za a -tzip %%i classes.dex | |
del classes.dex | |
rmdir /Q /S work\%%~ni | |
del system\framework\%%~ni.odex | |
) | |
) | |
@echo; | |
@echo deodexed files are stored in system\app, system\priv-app, system\framework folder. | |
pause | |
cls | |
goto menu | |
:azip | |
cls | |
@echo; | |
@echo Adding deodexed files to deodex_install.zip | |
cmd\7za a -tzip deodex_install.zip system | |
@echo Completed. | |
pause | |
:info | |
cls | |
echo ======================== INFO ======================= | |
echo This is a deodexer for KitKat Roms | |
echo This tool is based on Kamome deodexer for Xperia 4.4 | |
echo May work on all odexed kitkat roms | |
echo Always do a nandroid backup before installing | |
echo Do with your own risk | |
echo ===================================================== | |
pause | |
cls | |
goto menu | |
:javaerror | |
cls | |
echo Java is not installed, please install java to deodex | |
echo If you dont install java, maybe some error will occur | |
pause | |
cls | |
goto menu | |
:quit |
This file contains 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
REM =============== script.asAdmin.bat =============== | |
@echo off | |
reg.exe query "HKU\S-1-5-19">nul 2>&1 | |
if %errorlevel% equ 1 goto UACPrompt | |
color 0a | |
chcp 1251 | |
REM TIMEOUT /T 5 /NOBREAK | |
goto KOD | |
:KOD | |
cls | |
ECHO "========== START KOD =========="; | |
ECHO ". ."; | |
ECHO ". ."; | |
ECHO "========== START KOD =========="; | |
pause | |
cls | |
goto EXIT | |
:UACPrompt | |
mshta "vbscript:CreateObject("Shell.Application").ShellExecute("%~fs0", "", "","runas", 1) & Close()" | |
exit /b | |
cmd | |
:EXIT | |
echo ===== END KOD ====== | |
TIMEOUT /T 5 /NOBREAK; | |
exit /b | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment