Sublime Text crack using shell script

最近在學(xué)習(xí) Linux 操作系統(tǒng)和 shell 編程,看完這組 視頻教程 后感覺非常不錯,在此也推薦給有意向?qū)W習(xí) Linux 的讀者。

作為一名程序猿,光看不練可不是我的風(fēng)格,于是花了一天時間實現(xiàn)了這個 Sublime Text crack 腳本,可將 Sublime 注冊為 Unlimited User License。

Unlimited User License

腳本涉及輸入輸出、路徑和文件處理、字符串處理、正則表達式、條件判斷和分支控制等知識點,是對 shell 編程的一個小小的綜合實踐,放在這里以備忘和繼續(xù)學(xué)習(xí)。腳本內(nèi)容在文章末尾,可翻到頁面底部查看。

聲明:

  1. 實現(xiàn)破解并非本文的初衷,請大家多多支持正版,切勿傳播。
  2. 破解方法搜集自 這里,并非我原創(chuàng),我的工作主要是把簡單的命令整合成可交互、方便使用的腳本。

使用方法

本腳本只面向 Windows 64 位環(huán)境(PS:其他平臺歡迎自己動手,這也就是寫這篇分享的初衷了)。理論上 shell 腳本是跨平臺的,MacOSX 和 Linux 環(huán)境可仿照此腳本自行整合 該網(wǎng)站 給出的破解命令。

1. 保存腳本

不含中文的路徑下新建一個空文件,命名為 sublime_text_crack.sh。將文章底部的代碼拷貝到腳本中,保存。

2. 確保已安裝 Git

Windows 環(huán)境下默認(rèn)是不支持運行 shell 腳本的。但是 Git for Windows 可以在 Windows 下創(chuàng)建一個微 Linux 環(huán)境,可運行 bash 腳本,支持 ls, cp, mv, git, cat, vim, grep, wget, curl 等大量常用的 Linux 命令。

因此,運行腳本前請確保本機安裝了 Git for Windows。

3. 運行腳本

有兩種方式可以運行 shell 腳本:

  1. 右鍵腳本,在打開方式中選擇 "git-bash"。

  2. 在腳本所在的目錄右鍵,選擇 "Git Bash Here"。在打開的 git-bash 窗口中輸入 bash sublime_text_crack.sh。

打開腳本后按照提示進行操作即可。

例如,這是我在本機上的操作記錄:

$ bash sublime_text_crack.sh

This crack script supports only:
    Platform: Windows x64
    Sublime versions: 3176 3170 3157 3156 3153 3143 3135 3070 3068 3065

Do you want to continue? [y/n]: y
Checking sublime path ...

Please input sublime_text installed path (the directory contains sublime_text.exe):
> C:\Program Files\Sublime Text 3

Checking sublime version ...

Detected sublime version *3176*, is it right? [y/n]: y

Running backup: copy "sublime_text.exe" to "sublime_text.bak.exe" ...


Crack start ...
Crack completed.

Press any key to continue...

出現(xiàn)類似的結(jié)果即表明 crack 完成。

此時,打開 Sublime Text,選擇菜單 "Help->About Sublime Text",會出現(xiàn)以下字樣:

        Registered to
    Unlimited User License

說明 crack 成功。

附:sublime_text_crack.sh

##!/bin/bash

echo
support_versions='3176 3170 3157 3156 3153 3143 3135 3070 3068 3065'

echo -e "This crack script supports only: \n    Platform: Windows x64\n    Sublime versions: $support_versions\n"
read -p 'Do you want to continue? [y/n]: ' f
if [ -n $f ] && [ $f != "y" ]; then
    exit 1
fi


# check sublime installed path
echo -e 'Checking sublime path ...\n'
if [[ -f './sublime_text.exe' ]]; then
    p='.'
else
    read -r -p "Please input sublime_text installed path (the directory contains sublime_text.exe): `echo $'\n> '`" p
    if [[ ! -d "$p" ]]; then
        echo "Error: \"$p\" is not a directory"
        exit 11
    fi
    if [[ ! -f "$p/sublime_text.exe" ]]; then
        echo "Error: \"$p\" is not a sublime_text installed path"
        exit 12
    fi
    # replace "\" with "/"
    p=$(echo $p | sed 's/\\/\//g')
    # trim trailing "/"
    p=${p%/}
fi
echo


# detect sublime version
echo -e 'Checking sublime version ...\n'
if [[ -f "$p/changelog.txt" ]]; then
    v=$(cat "$p/changelog.txt" | grep -P -o '^<h2>.*Build \d{4}' | grep -P -o '\d{4}' | head -n 1)
    read -p "Detected sublime version *$v*, is it right? [y/n]: " flag
    if [[ -n "$flag" ]]; then
        case $flag in
            "y" )
                ;;
            "n" )
                # input version number manually
                read -p "Please input your sublime version (supported versions are [$support_versions]): `echo $'\n> '`" v
                ;;
            * )
                echo "Invalid input: \"$flag\""
                exit 21
        esac
    fi
else
    echo 'Fail detecting sublime version'
    read -p "Please input your sublime version manually (supported versions are [$support_versions]): `echo $'\n> '`" v
fi
# check if the version is supported
if [[ ! $support_versions = *"$v"* ]]; then
    echo "Error: version \"$v\" is not in support list: [$support_versions]"
    exit 22
fi
echo


# backup
echo -e 'Running backup: copy "sublime_text.exe" to "sublime_text.bak.exe" ...\n'
cp -i "$p/sublime_text.exe" "$p/sublime_text.bak.exe"
echo


# crack
echo 'Crack start ...'
case $v in
    "3176" )
        printf '\xEB' | dd seek=$((0x76A0C)) conv=notrunc bs=1 of="$p/sublime_text.exe" &> /dev/null
        printf '\x2A' | dd seek=$((0x76A0D)) conv=notrunc bs=1 of="$p/sublime_text.exe" &> /dev/null
        printf '\x75' | dd seek=$((0x76A2A)) conv=notrunc bs=1 of="$p/sublime_text.exe" &> /dev/null
        printf '\x85' | dd seek=$((0xB27D9)) conv=notrunc bs=1 of="$p/sublime_text.exe" &> /dev/null
        printf '\x75' | dd seek=$((0x23FF18)) conv=notrunc bs=1 of="$p/sublime_text.exe" &> /dev/null
        ;;
    "3170" )
        printf '\xEB' | dd seek=$((0x76608)) conv=notrunc bs=1 of="$p/sublime_text.exe" &> /dev/null
        printf '\x75' | dd seek=$((0x23F89C)) conv=notrunc bs=1 of="$p/sublime_text.exe" &> /dev/null
        printf '\x75' | dd seek=$((0x76626)) conv=notrunc bs=1 of="$p/sublime_text.exe" &> /dev/null
        printf '\x85' | dd seek=$((0xB23C9)) conv=notrunc bs=1 of="$p/sublime_text.exe" &> /dev/null
        printf '\x2A' | dd seek=$((0x76609)) conv=notrunc bs=1 of="$p/sublime_text.exe" &> /dev/null
        ;;
    "3157" )
        printf '\x00\x01' | dd seek=$((0x39A47)) conv=notrunc bs=1 of="$p/sublime_text.exe" &> /dev/null
        ;;
    "3156" )
        printf '\x00\x01' | dd seek=$((0x39A47)) conv=notrunc bs=1 of="$p/sublime_text.exe" &> /dev/null
        ;;
    "3153" )
        printf '\x00\x01' | dd seek=$((0x3888F)) conv=notrunc bs=1 of="$p/sublime_text.exe" &> /dev/null
        ;;
    "3143" )
        printf '\x85' | dd seek=$((0xB60F6)) conv=notrunc bs=1 of="$p/sublime_text.exe" &> /dev/null
        printf '\x75' | dd seek=$((0x233F49)) conv=notrunc bs=1 of="$p/sublime_text.exe" &> /dev/null
        printf '\x75' | dd seek=$((0x7691A)) conv=notrunc bs=1 of="$p/sublime_text.exe" &> /dev/null
        printf '\xEB' | dd seek=$((0x768FC)) conv=notrunc bs=1 of="$p/sublime_text.exe" &> /dev/null
        printf '\x2A' | dd seek=$((0x768FD)) conv=notrunc bs=1 of="$p/sublime_text.exe" &> /dev/null
        ;;
    "3135" )
        printf '\x74' | dd seek=$((0x3A3F6)) conv=notrunc bs=1 of="$p/sublime_text.exe" &> /dev/null
        printf '\x95' | dd seek=$((0x3A458)) conv=notrunc bs=1 of="$p/sublime_text.exe" &> /dev/null
        ;;
    "3070" )
        printf '\x3B' | dd seek=$((0xE0ABF)) conv=notrunc bs=1 of="$p/sublime_text.exe" &> /dev/null
        ;;
    "3068" )
        printf '\x3B' | dd seek=$((0xDE8D7)) conv=notrunc bs=1 of="$p/sublime_text.exe" &> /dev/null
        ;;
    "3065" )
        printf '\x3B' | dd seek=$((0xDC98F)) conv=notrunc bs=1 of="$p/sublime_text.exe" &> /dev/null
        ;;
    * )
        echo "Error: version error"
        ;;
esac
echo 'Crack completed.'
echo
read -n 1 -p "Press any key to continue..."

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容