• 大小: 13.92M
    文件类型: .xz
    金币: 1
    下载: 0 次
    发布日期: 2023-07-02
  • 语言: 其他
  • 标签: 其他  

资源简介

subl3207_Linux64.tar.xz

资源截图

代码片段和文件信息

#!/usr/bin/env python3
#coding=utf-8
import os
import sys

def isRoot():
    return os.getuid()==0

def getSudoUid():
    if os.environ[‘SUDO_UID‘]:
        return int(os.environ[‘SUDO_UID‘])
    return 0

def getSudoGid():
    if os.environ[‘SUDO_GID‘]:
        return int(os.environ[‘SUDO_GID‘])
    return 0        

def createSubl():
    # data=[‘#!/bin/sh\n‘‘LD_PRELOAD=‘+currentPath+‘/sublime_text_fcitx.so exec ‘+currentPath+‘/sublime_text “$@“‘]
    # fsubl=open(sublPath‘w‘)
    # fsubl.writelines(data)
    # fsubl.close()
    # os.chmod(sublPath0o755)
    # os.chown(sublPathmyuidmygid)
    os.system(‘sudo ln -f -s ‘+currentPath+‘/sublime_text ‘+sublPath)

def createDesktop():
    fdesk=open(desktopFile‘w‘)
    fdesk.writelines(‘‘‘[Desktop Entry]
Version=1.0
Type=Application
Name=Sublime Text
GenericName=Text Editor
Comment=Sophisticated text editor for code markup and prose
Exec=‘‘‘+sublPath+‘‘‘ %F
Terminal=false
MimeType=text/plain;
Icon=‘‘‘+currentPath+‘‘‘/Icon/128x128/sublime-text.png
Categories=TextEditor;Development;
StartupNotify=true
Actions=Window;Document;

[Desktop Action Window]
Name=New Window
Exec=‘‘‘+sublPath+‘‘‘ -n
OnlyShowIn=Unity;

[Desktop Action Document]
Name=New File
Exec=‘‘‘+sublPath+‘‘‘ --command new_file
OnlyShowIn=Unity;‘‘‘)
    fdesk.close()
    os.chown(desktopFilemyuidmygid)

def uninstall():
    os.remove(sublPath)
    os.remove(desktopFile)

def addtoHOSTS():
    denyList=[
        ‘www.sublimetext.com‘
        ‘license.sublimehq.com‘
        ‘45.55.255.55‘
        ‘45.55.41.223‘
    ]

    hostlines=[]
    fhosts=open(‘/etc/hosts‘‘r+‘)
    hostlines=fhosts.readlines()
    for url in denyList:
        has=False
        for row in hostlines:
            if url in row.lower():
                has=True
                break
        if not has:
            fhosts.writelines(‘127.0.0.1 ‘+url+‘\n‘)
    fhosts.close()

def crack():
    pos=-1
    mainprogram=‘sublime_text‘
    with open(mainprogram‘rb+‘) as f:
        pos=f.read().find(bytes([0x97 0x94 0x0D 0x00 0x4F 0xB4 0x0D 0x00 0xAF 0xC5 0x0D]))
        if pos>=0:
            print(‘破解程序\t‘end=‘‘)
            with open(mainprogram‘rb+‘) as f:
                f.seek(pos0)
                f.write(bytes([000]))
            print(‘完成‘)

if __name__==‘__main__‘:
    if not isRoot():
        print(‘请尝试运行 sudo‘__file__)
        sys.exit(-1)

    if len(sys.argv)>1 and sys.argv[1]==‘-u‘:
        uninstall()
        sys.exit(0)

    if not os.path.exists(‘./sublime_text‘):
        print(‘请将此脚本放在sublime_text执行程序所在目录中‘)
        sys.exit(-1)
    crack()

    currentPath=os.getcwd()
    homedir=os.environ[‘HOME‘]
    desktopFile=homedir+‘/.local/share/applications/sublime_text.desktop‘
    os.makedirs(homedir+‘/.local/share/applications/‘exist_ok=True)
    sublPath=‘/usr/local/bin/subl‘
    os.makedirs(‘/usr/local/bin/‘exist_ok=True)
    myuid=getSudoUid()
    mygid=getSudoGid()
    addtoHOSTS()

    createSubl()
    createDesktop()
    

评论

共有 条评论