美文网首页Sublime Text
Sublime Text crack using shell s

Sublime Text crack using shell s

作者: Henry606 | 来源:发表于2018-05-16 19:18 被阅读8次

    最近在学习 Linux 操作系统和 shell 编程,看完这组 视频教程 后感觉非常不错,在此也推荐给有意向学习 Linux 的读者。

    作为一名程序猿,光看不练可不是我的风格,于是花了一天时间实现了这个 Sublime Text crack 脚本,可将 Sublime 注册为 Unlimited User License。

    Unlimited User License

    脚本涉及输入输出、路径和文件处理、字符串处理、正则表达式、条件判断和分支控制等知识点,是对 shell 编程的一个小小的综合实践,放在这里以备忘和继续学习。脚本内容在文章末尾,可翻到页面底部查看。

    声明:

    1. 实现破解并非本文的初衷,请大家多多支持正版,切勿传播。
    2. 破解方法搜集自 这里,并非我原创,我的工作主要是把简单的命令整合成可交互、方便使用的脚本。

    使用方法

    本脚本只面向 Windows 64 位环境(PS:其他平台欢迎自己动手,这也就是写这篇分享的初衷了)。理论上 shell 脚本是跨平台的,MacOSX 和 Linux 环境可仿照此脚本自行整合 该网站 给出的破解命令。

    1. 保存脚本

    不含中文的路径下新建一个空文件,命名为 sublime_text_crack.sh。将文章底部的代码拷贝到脚本中,保存。

    2. 确保已安装 Git

    Windows 环境下默认是不支持运行 shell 脚本的。但是 Git for Windows 可以在 Windows 下创建一个微 Linux 环境,可运行 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...
    

    出现类似的结果即表明 crack 完成。

    此时,打开 Sublime Text,选择菜单 "Help->About Sublime Text",会出现以下字样:

            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..."
    
    

    相关文章

      网友评论

        本文标题:Sublime Text crack using shell s

        本文链接:https://www.haomeiwen.com/subject/ayjmdftx.html