-
-
Save duckimann/9061c2efabeba7f0818083e278016d5f to your computer and use it in GitHub Desktop.
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
$sublpath="C:\Program Files\Sublime Text" | |
$hostspath="C:\Windows\System32\drivers\etc\hosts" | |
$licpath="" | |
$subtp="" | |
$torm="Text" | |
$license=@" | |
----- BEGIN LICENSE ----- | |
Member J2TeaM | |
Single User License | |
EA7E-1011316 | |
D7DA350E 1B8B0760 972F8B60 F3E64036 | |
B9B4E234 F356F38F 0AD1E3B7 0E9C5FAD | |
FA0A2ABE 25F65BD8 D51458E5 3923CE80 | |
87428428 79079A01 AA69F319 A1AF29A4 | |
A684C2DC 0B1583D4 19CBD290 217618CD | |
5653E0A0 BACE3948 BB2EE45E 422D2C87 | |
DD9AF44B 99C49590 D2DBDEE1 75860FD2 | |
8C8BB2AD B2ECE5A4 EFC08AF2 25A9B864 | |
------ END LICENSE ------ | |
"@ | |
$hostsBlock=@" | |
127.0.0.1 www.sublimetext.com | |
127.0.0.1 license.sublimehq.com | |
"@ | |
Function Get-Folder($initialDirectory="") { | |
[System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms")|Out-Null | |
$foldername = New-Object System.Windows.Forms.FolderBrowserDialog | |
$foldername.Description = "Select sublime_text.exe / sublime_merge.exe directory" | |
$foldername.rootfolder = "MyComputer" | |
$foldername.SelectedPath = $initialDirectory | |
if ($foldername.ShowDialog() -eq "OK") { | |
$folder += $foldername.SelectedPath | |
} | |
$sublpath = $folder | |
Check-Path | |
} | |
Function Check-Path { | |
$subl=Test-Path "$sublpath\sublime_text.exe"; | |
$subl_merge=Test-Path "$sublpath\sublime_merge.exe"; | |
if (-Not($subl -Or $subl_merge) -And [bool]$sublpath) { | |
Get-Folder; | |
} | |
if ($subl) { | |
$torm = "Text" | |
} | |
if ($subl_merge) { | |
$torm = "Merge" | |
} | |
if (-Not(Test-Path "$sublpath\Data")) { | |
$licpath="${env:appdata}/Sublime $torm/Local/License.sublime_license"; | |
$subtp="Installed"; | |
} else { | |
$licpath="$sublpath/Data/Local/License.sublime_license"; | |
$subtp="Portable"; | |
} | |
Main | |
} | |
Function Show-Menu { | |
cls | |
$start=@" | |
===== Sublime Text / Merge Utilities by duckimann @github ===== | |
$subtp | Current dir: $sublpath | |
1. Patch Sublime $torm | |
2. Restore Sublime $torm | |
3. Block Sublime License Check Using Hosts file | |
4. Unblock Sublime License Check Using Hosts file | |
5. Append License @ $licpath | |
6. Delete License @ $licpath | |
7. Set sublime directory | |
8. Exit | |
"@ | |
Write-Host $start | |
} | |
Function Main { | |
Show-Menu | |
# $Choices = [System.Management.Automation.Host.ChoiceDescription[]] @("&1", "&2", "&3", "&4", "&5", "&6", "&7", "&8") | |
# $Choice = $host.UI.PromptForChoice($start, "Enter your choice: ", $Choices, 7) | |
$Choice = Read-Host "Enter Your Choice" | |
# Action based on the choice | |
switch($Choice) { | |
1 { # Patch Sublime | |
# Credit | |
# https://gist.github.com/JerryLokjianming/71dac05f27f8c96ad1c8941b88030451 | |
# https://gist.github.com/maboloshi/feaa63c35f4c2baab24c9aaf9b3f4e47#how-to-crack-sublime-merge-2050-with-hex-editor--win64--with-license- | |
if ($subl) { | |
copy "$sublpath\sublime_text.exe" "$sublpath\sublime_text.exe.bak"; | |
$bytes = [System.IO.File]::ReadAllBytes("$sublpath\sublime_text.exe"); | |
$rep= @{ # Addr in decimal = 0x value | |
1024 = 0xC3 | |
28970 = 0x90 | |
28971 = 0x90 | |
28972 = 0x90 | |
28973 = 0x90 | |
28974 = 0x90 | |
28995 = 0x90 | |
28996 = 0x90 | |
28997 = 0x90 | |
28998 = 0x90 | |
28999 = 0x90 | |
672853 = 0xC3 | |
673762 = 0x48 | |
673763 = 0x31 | |
673764 = 0xC0 | |
673765 = 0xC3 | |
680665 = 0x48 | |
680666 = 0x31 | |
680667 = 0xC0 | |
680669 = 0xFF | |
680670 = 0xC0 | |
680671 = 0xC3 | |
} | |
$rep.Keys | %{ $bytes[$_] = $rep.Item($_) } | |
[System.IO.File]::WriteAllBytes("$sublpath\sublime_text.exe", $bytes); | |
} | |
if ($subl_merge) { | |
copy "$sublpath\sublime_merge.exe" "$sublpath\sublime_merge.exe.bak"; | |
$bytes = [System.IO.File]::ReadAllBytes("$sublpath\sublime_merge.exe"); | |
$rep= @{ # Addr in decimal = 0x value | |
134248 = 0xC3 | |
144331 = 0xC3 | |
145272 = 0x48 | |
145273 = 0xC7 | |
145274 = 0xC0 | |
145275 = 0x19 | |
145276 = 0x01 | |
145277 = 0x00 | |
145278 = 0x00 | |
145279 = 0xC3 | |
150483 = 0x48 | |
150484 = 0x31 | |
150485 = 0xC0 | |
150487 = 0xFF | |
150488 = 0xC0 | |
150489 = 0xC3 | |
156155 = 0x90 | |
156156 = 0x90 | |
156157 = 0x90 | |
156158 = 0x90 | |
156159 = 0x90 | |
156180 = 0x90 | |
156181 = 0x90 | |
156182 = 0x90 | |
156183 = 0x90 | |
156184 = 0x90 | |
} | |
$rep.Keys | %{ $bytes[$_] = $rep.Item($_) } | |
[System.IO.File]::WriteAllBytes("$sublpath\sublime_merge.exe", $bytes); | |
} | |
$license | Out-File (New-Item $licpath -Force); | |
break | |
} | |
2 { # Un-Patch Sublime | |
$lower = $($torm.ToLower()) | |
Remove-Item "$sublpath\sublime_$lower.exe"; | |
move "$sublpath\sublime_$lower.exe.bak" "$sublpath\sublime_$lower.exe" | |
break | |
} | |
3 { # Block license check using hosts | |
Add-Content -Path "$hostspath" $hostsBlock; | |
break | |
} | |
4 { # Unblock license check using hosts | |
Set-Content -Path "$hostspath" -Value (Get-Content -Path "$hostspath" | Select-String -Pattern 'www.sublimetext.com' -NotMatch | Select-String -Pattern 'license.sublimehq.com' -NotMatch); | |
break | |
} | |
5 { # Append License | |
$license | Out-File (New-Item $licpath -Force); | |
break | |
} | |
6 { # Delete License | |
Remove-Item $licpath; | |
break | |
} | |
7 { # Set directory | |
Get-Folder; | |
break | |
} | |
8 { | |
exit | |
} | |
} | |
timeout 3; | |
Main; | |
} | |
Check-Path; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment