├── .github └── ISSUE_TEMPLATE │ └── bug_report.yml ├── .gitignore ├── LICENSE ├── README.md ├── docs ├── img │ ├── bashDemo.png │ ├── newImg.png │ └── runShell.png └── ish语法.md ├── main.py ├── misc ├── Color.py ├── Error.py ├── Info.py └── Logo.py ├── models ├── alias.py ├── bash.py ├── calculator.py ├── client.py ├── dellib.py ├── demo.ish ├── downlib.py ├── help │ └── main.py ├── man.conf ├── models.py ├── print.py ├── scan.py ├── shell.py └── trojan │ └── main.py ├── ssr ├── config.ssr └── startup.ish └── tools ├── Phraser.py ├── SelfCheck.py ├── alias.conf └── iPrint.py /.github/ISSUE_TEMPLATE/bug_report.yml: -------------------------------------------------------------------------------- 1 | name: Bug report 2 | description: 提交 Bug 反馈 3 | labels: [ bug ] 4 | assignees: lanbinshijie 5 | body: 6 | - type: markdown 7 | id: preface 8 | attributes: 9 | value: | 10 | 你好!首先感谢你对IceShell的支持,同时也感谢你愿意花一些时间填写此错误报告!在开始之前,我们非常推荐阅读一遍[《开源最佳实践》](https://github.com/LinuxSuRen/open-source-best-practice),这会在很大程度上提高我们彼此的效率。 11 | - type: markdown 12 | id: environment 13 | attributes: 14 | value: "## 冰壳的环境" 15 | - type: input 16 | id: version 17 | validations: 18 | required: true 19 | attributes: 20 | label: "是什么版本出现了此问题?" 21 | description: "您可以通过查看misc中的Info获取版本号!" 22 | - type: markdown 23 | id: details 24 | attributes: 25 | value: "## 详细信息" 26 | - type: textarea 27 | id: what-happened 28 | attributes: 29 | label: "请描述一下这个bug" 30 | description: "发生了什么?这个bug是什么样的?" 31 | validations: 32 | required: true 33 | - type: textarea 34 | id: solve 35 | attributes: 36 | label: "解决方法" 37 | description: "您是否尝试自行解决这个Bug?" 38 | - type: textarea 39 | id: additional-information 40 | attributes: 41 | label: "附加信息" 42 | description: "如果你还有其他需要提供的信息,可以在这里填写(可以提供截图、视频等)。" 43 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | pip-wheel-metadata/ 24 | share/python-wheels/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | MANIFEST 29 | 30 | # PyInstaller 31 | # Usually these files are written by a python script from a template 32 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 33 | *.manifest 34 | *.spec 35 | 36 | # Installer logs 37 | pip-log.txt 38 | pip-delete-this-directory.txt 39 | 40 | # Unit test / coverage reports 41 | htmlcov/ 42 | .tox/ 43 | .nox/ 44 | .coverage 45 | .coverage.* 46 | .cache 47 | nosetests.xml 48 | coverage.xml 49 | *.cover 50 | *.py,cover 51 | .hypothesis/ 52 | .pytest_cache/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | target/ 76 | 77 | # Jupyter Notebook 78 | .ipynb_checkpoints 79 | 80 | # IPython 81 | profile_default/ 82 | ipython_config.py 83 | 84 | # pyenv 85 | .python-version 86 | 87 | # pipenv 88 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 89 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 90 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 91 | # install all needed dependencies. 92 | #Pipfile.lock 93 | 94 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 95 | __pypackages__/ 96 | 97 | # Celery stuff 98 | celerybeat-schedule 99 | celerybeat.pid 100 | 101 | # SageMath parsed files 102 | *.sage.py 103 | 104 | # Environments 105 | .env 106 | .venv 107 | env/ 108 | venv/ 109 | ENV/ 110 | env.bak/ 111 | venv.bak/ 112 | 113 | # Spyder project settings 114 | .spyderproject 115 | .spyproject 116 | 117 | # Rope project settings 118 | .ropeproject 119 | 120 | # mkdocs documentation 121 | /site 122 | 123 | # mypy 124 | .mypy_cache/ 125 | .dmypy.json 126 | dmypy.json 127 | 128 | # Pyre type checker 129 | .pyre/ 130 | 131 | .vscode 132 | .vscode/* 133 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Lanbin 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |
5 |
Ice Shell [aɪs ʃɛl],一个Python编写的脚本运行框架,支持扩展模块
8 | 9 | 14 | 15 | --- 16 | 17 | # 介绍 18 | Ice Shell(简称IShell,中文名“冰壳”),是一个Python编写的脚本运行框架,支持扩展模块。 19 | 20 | **2024,回归更新咕咕咕!** 21 | 22 | ## IShell设计初衷 23 | 往往我们在用Python完成某个小功能时,我们都会直接新建单个Python文件,写完之后就放在一个不知名的小角落,然后使用的时候直接双击运行。 24 | 25 | 但是这个操作往往会出现很多问题。如果你的程序很复杂,封装了很多的函数,用传统的方式就会造成一些困难,比如依赖问题或是变量问题。而且,当你想要将文件发布出去时,不仅孤零零的一小撮文件不太好看,而且如果他人要想使用这个Python,往往会因为依赖等的问题而无法运行。 26 | 27 | 同时,IShell也为Shell类程序提供了良好的开发平台。您可以给予IShell开发您自己的程序(如远控,木马)等。 28 | 29 | IShell的核心组件是插件(或者叫做模块),这些模块使用子进程,支持热插拔,随时更新随时运行。 30 | 31 | **!如果您有开发远程控制、远程桌面、反弹shell等需求,请使用IceShell** 32 | 33 | ## 碎语 34 | Iceshell时隔一年,马上要过生日了,清理磁盘的时候发现了这个小项目。觉得当时的我还挺可爱的,写了这样一个好玩的程序。特别是很多我当时写的代码都不知道逻辑时什么意思了,所以我打算捡起它,继续完成我未完成的梦想。感谢一路走来支持的那些好兄弟,感谢另一个一直watch开发进度的人!谢谢你们! 35 | 36 | —— Lanbin 2024年1月7日00:36:40 37 | 38 | 39 | --- 40 | 41 | 42 | Iceshell马上要出1.0版本了,还是很激动的。 43 | 44 | Iceshell项目其实只是我一下心血来潮,主要目的是为接下来的项目打个基础,顺便学习一下git工作流,同时也方便自己日常生活和开发。 45 | 46 | 希望能够得到更多人的支持,也为有这方面想法的同学投石问路、抛砖引玉。欢迎大家Fork和Star,谢谢大家对我的鼓励! 47 | 48 | —— Lanbin 2023年1月15日18:04:39 49 | 50 | 51 | ## IShell功能 52 | 53 | - [X] 自定义模块功能与命令 54 | - [ ] 捕获报错信息 55 | - [X] 依赖检测与安装 56 | - [ ] 一键配置程序信息 57 | - [ ] 一键配置程序依赖 58 | - [ ] 一键发布程序 59 | - [X] 模块参数自定义 60 | 61 | 更多功能敬请期待~ 62 | 63 | 有什么问题和建议可以直接提Issue或者P 64 | 65 | ## IShell自带功能 66 | IShell本质上作为一个模块化Shell,装载了一些小工具。 67 | 68 | - [X] print - 打印Helloworld 69 | - [X] downlib - 自动下载所需的依赖库 70 | - [X] dellib - 手动删除某个依赖库 71 | - [X] scan - 端口扫描器,使用方法:scan host -st startPort -np endPort 72 | - [X] bash - 一款Lanbin自己写的简易编程语言,仿Shell 73 | - [ ] stress - 压力测试器 74 | - [ ] demo - 内置98%API,可以作为开发手册使用 75 | 76 | **!以上功能正在实现中** 77 | 78 | ## IShell插件 79 | 80 | - [ ] remote - 集成远程控制电脑屏幕功能 81 | - [ ] trojan - 集成生成木马程序、监听木马程序和控制电脑一体的工具 82 | - [ ] airport - 搜索在线的clash节点池(待定) 83 | - [ ] news - 获取今日新闻(有点鸡肋说实话) 84 | - [ ] baidu - 我来帮你百度一下 85 | - [ ] bigbug - 常见漏洞集成库 86 | - [ ] spider - 可视化爬取网站页面(大工程!) 87 | 88 | **!以上功能正在策划中** 89 | 90 | ## IShell亮点 91 | 92 | - 模块化编程,更易拓展 93 | - 更加完整的错误系统 94 | - 主代码和模块分开 95 | - 报错易寻找具体位置 96 | ...... 97 | 98 | # 使用方法 99 | 100 | 1. 下载最新版Release [点我前往Release](https://github.com/lanbinshijie/IceShell/releases) 101 | 102 | 2. 下载源代码并解压到本地 103 | 104 | 3. 运行`python main.py` 105 | 106 | 4. 添加拓展模块 107 | 108 | **注意!不推荐直接在CMD里运行,推荐找专业终端体验全部功能(如VSCode的终端)** 109 | 110 | 运行效果如图所示 111 | 112 |  113 | 114 | 115 | 新版截图(时隔一年,VSCode都换主题了) 116 | 117 |  118 | 119 | 120 | Demo输出 121 | 122 |  123 | 124 | # 参与开发 125 | 126 | 您可以联系我的 127 | - 邮箱:[me@lanbin.top](mailto:me@lanbin.top) 128 | 129 | 或者直接提交issue 130 | 131 | ## 近期任务 132 | 133 | - [X] 一键检测依赖并询问是否安装 134 | - [X] 将模块部分从主程序中剥离出来 135 | - [ ] 重构难看的Logo 136 | - [ ] 完善报错信息 137 | - [ ] 更新更多标准库 138 | 139 | ## 代码提交标准(给自己看的) 140 | - feat:新功能 141 | - fix:修补bug 142 | - docs:修改文档 143 | - style: 格式化代码结构(不影响代码运行的变动) 144 | - refactor:重构(即不是新增功能,也不是修改bug的代码变动,比如重命名变量 145 | - chore:构建过程或辅助工具的变动(不会影响代码运行) 146 | 147 | # 后记 148 | 149 | - Logo链接 150 | 1. https://s1.ax1x.com/2023/01/13/pSK4gln.png 151 | 2. https://s1.ax1x.com/2023/01/13/pSK42yq.png 152 | 3. https://s1.ax1x.com/2023/01/15/pSQqlRK.png [新版1] 153 | 4. https://s1.ax1x.com/2023/01/15/pSQqJqH.png [新版2] 154 | -------------------------------------------------------------------------------- /docs/img/bashDemo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lanbinshijie/IceShell/b8cd583e49449d6e22c9fec6851147c2a84ed3bd/docs/img/bashDemo.png -------------------------------------------------------------------------------- /docs/img/newImg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lanbinshijie/IceShell/b8cd583e49449d6e22c9fec6851147c2a84ed3bd/docs/img/newImg.png -------------------------------------------------------------------------------- /docs/img/runShell.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lanbinshijie/IceShell/b8cd583e49449d6e22c9fec6851147c2a84ed3bd/docs/img/runShell.png -------------------------------------------------------------------------------- /docs/ish语法.md: -------------------------------------------------------------------------------- 1 | # Ish语法 2 | 3 | ISH的语法与Bash的语法相似,但是有一些不同。 4 | 5 | ## 变量 6 | 7 | 8 | ### 变量定义 9 | Bash中定义变量是: 10 | 11 | ```bash 12 | var="value" 13 | ``` 14 | 15 | 而在ISH中定义变量是: 16 | 17 | ```bash 18 | $var="value" 19 | ``` 20 | 21 | ### 变量调用 22 | Bash中调用变量和ISH中调用变量是一样的: 23 | 24 | ```bash 25 | echo $var 26 | ``` 27 | 28 | ### 变量类型 29 | ISH中的变量类型支持Python中的所有类型,包括`int`、`float`、`str`、`bool`、`list`、`dict`、`tuple`、`set`、`None`。 30 | 31 | ### 变量赋值 32 | ISH中变量不仅支持赋值,也支持加减乘除等运算。具体如下: 33 | 34 | ```bash 35 | $a=1 36 | $b=$a+1 37 | $c=$a+$b 38 | ``` 39 | 40 | ## 流程控制 41 | 42 | ### if语句 43 | Bash中的if语句是: 44 | 45 | ```bash 46 | if [ $a -eq 1 ]; then 47 | echo "a=1" 48 | elif [ $a -eq 2 ]; then 49 | echo "a=2" 50 | else 51 | echo "a!=1 and a!=2" 52 | fi 53 | ``` 54 | 55 | Ish沿袭了Bash的语法,但是增加了一些新的语法,如下: 56 | 57 | ```cpp 58 | !if ($a==1) 59 | > echo "a=1" 60 | > echo "This is more than one line" 61 | !elseif ($a==2) 62 | > echo "a=2" 63 | !else 64 | > echo "a!=1 and a!=2" 65 | !endif 66 | ``` 67 | 您会发现,在Ish中,if语句的语法是以`!if`开始,以`!endif`结束,每一行的语句都必须以`>`开始,`!elseif`和`!else`也是以`>`开始。 68 | 69 | 也就是说,在ISH中的流程语句的关键字(条件语句)必须以`!`开头,如`!if`、`!else`、`!elseif`、`!endif`等。 70 | 71 | ### for语句 72 | Bash中的for语句是: 73 | 74 | ```bash 75 | for i in {1..10} 76 | do 77 | echo $i 78 | done 79 | ``` 80 | 81 | 基于上面提到的规则,Ish中的for语句是: 82 | 83 | ```cpp 84 | !for ($i;1,10,1) 85 | > echo $i 86 | !endfor 87 | // 输出1-10 88 | ``` 89 | 90 | 我们不难发现,for循环的条件(括号内的内容)是以`;`分隔,分隔后的内容分别是变量名($i)、起始值、结束值、步长。 91 | 92 | ### while语句 93 | Bash中的while语句是: 94 | 95 | ```bash 96 | while [ $a -lt 10 ] 97 | do 98 | echo $a 99 | a=$a+1 100 | done 101 | ``` 102 | 103 | Ish中的while语句是: 104 | 105 | ```cpp 106 | !while ($a<10) 107 | > echo $a 108 | > $a=$a+1 109 | !endwhile 110 | // 输出1-10 111 | ``` 112 | 113 | ### 函数 114 | Bash中的函数是: 115 | 116 | ```bash 117 | function func() 118 | { 119 | echo "This is a function" 120 | } 121 | ``` 122 | 123 | Ish中的函数是: 124 | 125 | ```cpp 126 | !dec func() 127 | > echo "This is a function" 128 | !enddec 129 | ``` 130 | 131 | ## 其他 132 | 133 | ### 注释 134 | Bash中的注释是: 135 | 136 | ```bash 137 | # This is a comment 138 | ``` 139 | 140 | Ish中的注释是: 141 | 142 | ```txt 143 | # This is a comment 144 | 或者 145 | ; This is a comment 146 | ``` 147 | 中间都要有一个空格,且注释占一整行,注释标识符要放在第一位。 148 | -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3.7 2 | # -*- coding: utf-8 -*- 3 | # @Author : Lanbin 4 | # @Software: Vscode 5 | # @Time : 2023-1-13 18:49 6 | 7 | import os, sys 8 | from misc.Color import Colors 9 | from misc.Logo import Logo 10 | from tools.SelfCheck import SelfCheck 11 | from misc.Info import ProgramInfo 12 | from misc.Info import SSR_Reader 13 | from misc.Error import Error 14 | from tools.Phraser import PS1 15 | from tools.Phraser import alias 16 | from misc.Info import StartAction 17 | # from models.bash import Ish 18 | 19 | ALIAS = alias() 20 | # ish = Ish() 21 | 22 | def ExecuteModel(args, moduleName): 23 | if SelfCheck.CheckModel(moduleName): 24 | os.chdir(rf"{ProgramInfo.basedir}/models") 25 | if os.path.exists(f"{moduleName}.py"): 26 | command = sys.executable + f" ./{moduleName}.py " + args 27 | elif os.path.exists(f"./{moduleName}/main.py"): 28 | os.chdir(rf"./{moduleName}") 29 | command = sys.executable + f" ./main.py " + args 30 | else: 31 | if ALIAS.exsist(moduleName): 32 | command = ALIAS.get(moduleName) 33 | command = sys.executable + f" ./{command}.py " + args 34 | os.system(command) 35 | os.chdir(rf"{ProgramInfo.basedir}") 36 | # elif moduleName in 37 | else: 38 | # 因为 checkModel 会给出提示信息,所以就不用给出了 39 | ... 40 | 41 | def IceShell(): 42 | extra = "" 43 | commandN = input(Colors.RED + extra + PS1.paraphraser() + Colors.END) 44 | command = commandN.split(" ") 45 | if command[0] == "q": 46 | print("Bye~") 47 | exit(0) 48 | elif command[0] in ProgramInfo.registered_modules or "*" in ProgramInfo.registered_modules: 49 | ExecuteModel(" ".join(command[1:]), command[0]) 50 | else: 51 | Error.printError(10000) 52 | 53 | if __name__ == "__main__": 54 | # 程序从这里开始 55 | SelfCheck.WelcomeStart() # 显示Logo 56 | SelfCheck.LibCheck() 57 | 58 | ssr = SSR_Reader() 59 | startup_name = "startup.ish" 60 | mdls_stp = "../ssr/" + startup_name 61 | mfol_stp = "./ssr/" + startup_name 62 | if os.path.exists(mfol_stp): 63 | ExecuteModel(mdls_stp, "bash") 64 | print(Colors.BLUE + Logo.div_line_n_m + Colors.END + "\n") 65 | 66 | while True: 67 | try: 68 | IceShell() 69 | except KeyboardInterrupt: 70 | print("\nBye~") 71 | exit(0) 72 | 73 | -------------------------------------------------------------------------------- /misc/Color.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3.7 2 | # -*- coding: utf-8 -*- 3 | # @Author : Cr4y0n 4 | # @Software: PyCharm 5 | # @Time : 2020/8/16 8:09 6 | 7 | """ 8 | RED :报错、错误信息、失败信息 9 | GREEN :成功、重要发现 10 | YELLOW :警告、重要提示 11 | BLUE :保留 12 | PURPLE :保留 13 | CYAN :次要提示 14 | """ 15 | 16 | class Colors: 17 | RED = "\033[91m" 18 | GREEN = "\033[32m" 19 | YELLOW = "\033[93m" 20 | BLUE = "\033[94m" 21 | PURPLE = "\033[95m" 22 | CYAN = "\033[96m" 23 | END = "\033[0m" 24 | BOLD = "\033[1m" 25 | UNDERLINE = "\033[4m" 26 | 27 | def colorTestPrint(self): 28 | print(Colors.RED + "RED" + Colors.END) 29 | print(Colors.GREEN + "GREEN" + Colors.END) 30 | print(Colors.YELLOW + "YELLOW" + Colors.END) 31 | print(Colors.BLUE + "BLUE" + Colors.END) 32 | print(Colors.PURPLE + "PURPLE" + Colors.END) 33 | print(Colors.CYAN + "CYAN" + Colors.END) 34 | -------------------------------------------------------------------------------- /misc/Error.py: -------------------------------------------------------------------------------- 1 | 2 | from tools.iPrint import * 3 | 4 | class Error: 5 | error_list = { 6 | 10000: { 7 | "typer": "error", 8 | "model": "models", 9 | "title": "Invalid or Unregisted model(s).", 10 | "solve": "" 11 | }, 12 | 20001: { 13 | "typer": "error", 14 | "model": "Dellib", 15 | "title": "Deleting error!", 16 | "solve": "Please check pip\'s environment" 17 | }, 18 | } 19 | def printError(code: int): 20 | err = Error.error_list[code] 21 | model = err["model"] 22 | title = err["title"] 23 | solve = err["solve"] 24 | typer = err["typer"] 25 | iPrintLog(title,modelName=model,typer=typer) 26 | if solve: iPrintLog(solve,modelName=model,typer="info") 27 | -------------------------------------------------------------------------------- /misc/Info.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3.7 2 | # -*- coding: utf-8 -*- 3 | # @Author : Lanbin 4 | # @Software: Vscode 5 | # @Time : 2023-1-13 14:18 6 | 7 | import os 8 | 9 | class ProgramInfo: 10 | # Program Version 11 | version = "v1.0.0-alphav1.2.1" 12 | author = "Lanbin" 13 | using_libs = ["os", "sys"] 14 | models_path = r"./models/" 15 | registered_modules = ["print", "downlib", "dellib", "scan", "models", "shell", "alias", "bash", "*"] 16 | debug_mode = True 17 | ssr_path = r"./ssr/" 18 | basedir = os.path.abspath(os.path.dirname(os.path.dirname(__file__))).replace("\\", "/") 19 | 20 | class SSR_Reader: 21 | # Shell System Resource Reader 22 | # 用来读取IceShell的配置文件和调用的系统资源信息 23 | # 主要是配置 24 | 25 | # Init 函数,检查ProgramInfo中对应的配置文件是否存在,如果不存在则创建 26 | # 地址为ProgramInfo.ssr_path 27 | def __init__(self): 28 | # 检查配置文件夹是否存在 29 | if not os.path.exists(ProgramInfo.ssr_path): 30 | os.mkdir(ProgramInfo.ssr_path) 31 | # 检查配置文件是否存在 32 | if not os.path.exists(ProgramInfo.ssr_path + "config.ssr"): 33 | with open(ProgramInfo.ssr_path + "config.ssr", "w") as f: 34 | # 写入默认配置(如现在ProgramInfo中的配置) 35 | # 写入的内容要用双引号括起来,这样读取时可以直接eval 36 | f.write("version=\"" + ProgramInfo.version + "\"\n") 37 | f.write("author=\"" + ProgramInfo.author + "\"\n") 38 | f.write("using_libs=" + str(ProgramInfo.using_libs) + "\n") 39 | f.write("models_path=\"" + ProgramInfo.models_path + "\"\n") 40 | f.write("registered_modules=" + str(ProgramInfo.registered_modules) + "\n") 41 | f.write("debug_mode=" + str(ProgramInfo.debug_mode) + "\n") 42 | f.write("ssr_path=\"" + ProgramInfo.ssr_path + "\"\n") 43 | 44 | # 读取配置文件 45 | self.config = self.paraphraser(ProgramInfo.ssr_path + "config.ssr") 46 | # 更新配置 47 | # self.update_config() 48 | 49 | 50 | # 解码器:将配置文件中的格式转化成字典 51 | # 格式示例(都是合法的): 52 | # key=value 53 | # key = value 54 | # 请注意,“#”是注释符号,不会被解析,一般独占一行的开头 55 | # 请注意,如果value中有“=”号,那么value中的“=”号不会被解析为=号而是作为普通字符 56 | 57 | def paraphraser(self, config_file: str = ProgramInfo.ssr_path + "config.ssr"): 58 | # 返回值:配置字典 59 | # 读取文件 60 | with open(config_file, "r") as f: 61 | config = f.read() 62 | # 解析文件 63 | config = config.split("\n") 64 | config_dict = {} 65 | for line in config: 66 | if line != "": 67 | if line[0] != "#": 68 | line = line.split("=") 69 | # 去除空格 70 | line[0] = line[0].strip() 71 | line[1] = line[1].strip() 72 | # 添加到字典 73 | config_dict[line[0]] = eval(line[1]) 74 | return config_dict 75 | 76 | # 写入器:将字典写入配置文件 77 | def writer(self, config_file: str, config_dict: dict): 78 | # 返回值:Bool 是否成功 79 | # 捕捉错误 80 | try: 81 | # 打开文件 82 | with open(config_file, "w") as f: 83 | # 写入 84 | for key in config_dict: 85 | f.write(key + "=" + config_dict[key] + "\n") 86 | return True 87 | except: 88 | return False 89 | 90 | 91 | class StartAction: 92 | def __init__(self, path): 93 | self.grub = ProgramInfo.basedir + "/ssr/" + path 94 | def return_action(self): 95 | with open(self.grub, "r") as f: 96 | return f.read() 97 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /misc/Logo.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3.7 2 | # -*- coding: utf-8 -*- 3 | # @Author : Lanbin 4 | # @Software: Vscode 5 | # @Time : 2023-1-13 14:29 6 | 7 | class Logo: 8 | normal_logo = r''' 9 | _____ _____ _ _ _ 10 | |_ _/ ___| | | | | 11 | | | \ `--.| |__ ___| | | 12 | | | `--. \ '_ \ / _ \ | | 13 | _| |_/\__/ / | | | __/ | | 14 | \___/\____/|_| |_|\___|_|_| (Ice Shell) 15 | ''' 16 | div_line_b = "====================================" 17 | div_line_n = "------------------------------------" 18 | div_line_b_l = "=================================================================" 19 | div_line_n_l = "-----------------------------------------------------------------" 20 | div_line_b_m = "=================================================" 21 | div_line_n_m = "-------------------------------------------------" 22 | div_line_b_s = "==================" 23 | div_line_n_s = "------------------" 24 | 25 | -------------------------------------------------------------------------------- /models/alias.py: -------------------------------------------------------------------------------- 1 | import sys,os 2 | from argparse import ArgumentParser 3 | pa = os.getcwd() 4 | sys.path.append("..") 5 | 6 | from tools.Phraser import alias 7 | 8 | os.chdir(pa+r"\..\tools") 9 | ALIAS = alias("alias.conf") 10 | from misc.Info import ProgramInfo 11 | 12 | class Aliaser: 13 | """ 14 | This class manages command aliases stored in a configuration file. 15 | """ 16 | def __init__(self, path=ProgramInfo.basedir + "/tools/alias.conf"): 17 | self.path = path 18 | self.alias = alias(path) 19 | 20 | def _update_file(self, config): 21 | """Writes the updated configuration to the file.""" 22 | with open(self.path, "w") as f: 23 | for alias, command in config.items(): 24 | f.write(f"{alias}={command}\n") 25 | 26 | def add(self, alias, command): 27 | """Adds a new alias.""" 28 | if self.alias.exist(alias): 29 | print(f"Alias {alias} already exists!") 30 | return 31 | with open(self.path, "a") as f: 32 | f.write(f"\n{alias}={command}") 33 | 34 | def set(self, alias, command): 35 | """Sets an existing alias to a new command.""" 36 | if not self.alias.exist(alias): 37 | print(f"Alias {alias} does not exist!") 38 | return 39 | config = self.alias.getAll() 40 | config[alias] = command 41 | self._update_file(config) 42 | 43 | def delete(self, alias): 44 | """Deletes an existing alias.""" 45 | if not self.alias.exist(alias): 46 | print(f"Alias {alias} does not exist!") 47 | return 48 | config = self.alias.getAll() 49 | del config[alias] 50 | self._update_file(config) 51 | 52 | def print_aliases(aliases): 53 | """Prints all available aliases.""" 54 | print("Alias\tRunable") 55 | print('----------------') 56 | for alias, command in aliases.items(): 57 | print(f"{alias}\t-> {command}") 58 | 59 | def main(): 60 | parser = ArgumentParser() 61 | parser.add_argument("-a", "--add", help="Add a new alias in the format alias=command") 62 | parser.add_argument("-s", "--set", help="Set an existing alias to a new command") 63 | parser.add_argument("-d", "--delete", help="Delete an existing alias") 64 | parser.add_argument("-f", "--flush", action="store_true", help="Flush alias configuration") 65 | 66 | args = parser.parse_args() 67 | aliaser = Aliaser() 68 | 69 | if args.flush: 70 | aliaser.alias.reRead() 71 | return 72 | 73 | if args.add: 74 | alias, command = args.add.split("=") 75 | aliaser.add(alias, command) 76 | elif args.set: 77 | alias, command = args.set.split("=") 78 | aliaser.set(alias, command) 79 | elif args.delete: 80 | aliaser.delete(args.delete) 81 | else: 82 | print_aliases(aliaser.alias.getAll()) 83 | return 84 | 85 | # Refresh and display updated aliases 86 | aliaser.alias.reRead() 87 | print_aliases(aliaser.alias.getAll()) 88 | 89 | if __name__ == "__main__": 90 | main() 91 | -------------------------------------------------------------------------------- /models/bash.py: -------------------------------------------------------------------------------- 1 | # Ish 执行模块 2 | # 功能:执行一个.sh文件中的所有命令 3 | # 语法参见:ish语法.md 4 | 5 | import os 6 | import sys 7 | import re 8 | 9 | sys.path.append("..") 10 | 11 | from misc.Color import Colors 12 | from misc.Logo import Logo 13 | 14 | from argparse import ArgumentParser 15 | from main import ExecuteModel 16 | 17 | # ALIAS = alias(path="alias.conf") 18 | 19 | # 新建一个Class,每个运行的sh程序都是在这个对象里的 20 | 21 | class Ish: 22 | # 要预留程序定义变量的地方(可以用字典储存) 23 | def __init__(self): 24 | self.kernel = ["Ish 1.0.0"] 25 | self.variables = {} 26 | self.functions = {} 27 | self.commands = { 28 | "uname": self.fun_uname, 29 | "echo": self.fun_echo, 30 | } 31 | self.doing_if = False 32 | self.doing_for = False 33 | # 正则表达式,匹配开头为Color.*的规则 34 | self.system_plugin = re.compile(r"Color\.[a-zA-Z0-9_]+") 35 | # self.run() 36 | 37 | def run(self): 38 | try: 39 | # 新建一个argparse的参数解析器,解析path参数 40 | parser = ArgumentParser() 41 | parser.add_argument("path", help="要执行的.sh文件路径") 42 | args = parser.parse_args() 43 | # breakpoint() 44 | # 读取文件 45 | with open(args.path, "r", encoding="utf-8-sig") as f: 46 | for line in f.readlines(): 47 | self.run_file(line) 48 | 49 | except EOFError: 50 | print("\nBye~") 51 | exit(0) 52 | except KeyboardInterrupt: 53 | print("\nBye~") 54 | exit(0) 55 | 56 | 57 | # 变量定义 58 | def var_define(self, var, value): 59 | self.variables[var] = value 60 | 61 | # 变量调用 62 | def var_call(self, var): 63 | return self.variables[var] 64 | 65 | # 变量赋值 66 | def var_assign(self, var, value): 67 | self.variables[var] = value 68 | 69 | # 变量加减乘除 70 | def var_add(self, var, value): 71 | self.variables[var] += value 72 | 73 | def var_sub(self, var, value): 74 | self.variables[var] -= value 75 | 76 | def var_mul(self, var, value): 77 | self.variables[var] *= value 78 | 79 | def var_div(self, var, value): 80 | self.variables[var] /= value 81 | 82 | 83 | # if语句 84 | def if_statement(self, condition, command): 85 | if condition: 86 | ... 87 | 88 | # for语句 89 | def for_statement(self, start, end, step, command): 90 | for i in range(start, end, step): 91 | ... 92 | return i 93 | 94 | # while语句 95 | def while_statement(self, condition, command): 96 | while condition: 97 | ... 98 | 99 | # 函数定义 100 | def func_define(self, func_name, args, command): 101 | self.functions[func_name] = {"args": args, "command": command} 102 | ... 103 | 104 | # 函数调用 105 | def func_call(self, func_name, args): 106 | ... 107 | 108 | # 函数删除 109 | def func_delete(self, func_name): 110 | self.functions.pop(func_name) 111 | 112 | # 运行命令 113 | def run_command(self, command): 114 | commandS = command.split(" ") 115 | 116 | if command[0] in self.commands: 117 | self.commands[command]() 118 | else: 119 | # 当没有内置命令时,执行模块,传入参数 120 | ExecuteModel(commandS[1:], commandS[0]) 121 | 122 | def run_file(self, file): 123 | file = file.splitlines() 124 | for line in file: 125 | self.run_line(line) 126 | 127 | def run_line(self, line): 128 | # 将所有的[space]或者[SPACE]替换为一个空格 129 | line = line.replace("[space]", " ") 130 | line = line.replace("[SPACE]", " ") 131 | 132 | line_split = line.split(" ") 133 | # 跳过空行 134 | if line == "": 135 | return 136 | if line[0] == "#" or line[0] == ";": 137 | return # 跳过注释 138 | elif line[0] == "$": 139 | variable = line.split("=") 140 | variable[0] = variable[0][1:] # 去掉$符号 141 | # 去掉两个首尾的空格(如:$ var = 100) 142 | variable[0] = variable[0].strip() 143 | variable[1] = variable[1].strip() 144 | self.var_define(variable[0], self.replace_var(variable[1])) 145 | elif line[0] == "!": 146 | # 特殊语句 147 | # if 148 | '''示例代码 149 | !if (1==1) 150 | > echo 1==1 151 | > echo IF成立 152 | !endif 153 | ''' 154 | condition = line[1:].strip() 155 | if condition[0:2] == "if": 156 | # print("有if语句") 157 | condition = condition[3:] 158 | if eval( 159 | self.replace_commands( 160 | self.only_replace_var(condition) 161 | ) 162 | ): 163 | # print("if成立") 164 | self.doing_if = True 165 | else: 166 | # print("if不成立") 167 | self.doing_if = False 168 | # endif 169 | elif condition[0:6] == "endif": 170 | self.doing_if = False 171 | # else 172 | elif condition[0:4] == "else": 173 | self.doing_if = not self.doing_if 174 | 175 | elif line[0] == ">": 176 | # 特殊代码块 177 | # print("特殊代码块") 178 | condition = line[1:].strip() 179 | # 如果是if块内 180 | if self.doing_if: 181 | # print("if块内") 182 | self.run_line(condition) 183 | 184 | # 当有以%%开头的单词时(不一定是行的开始),如echo %%uname%% 185 | # 将其替换为commands中的函数执行的结果 186 | elif "%%" in line: 187 | # 找到两个%%之间的字符串并将其替换为commands中的函数执行的结果 188 | # 重复执行直到没有%%为止 189 | self.run_line(self.replace_commands(line)) 190 | 191 | 192 | else: 193 | if line_split[0] in self.commands: 194 | self.commands[line_split[0]](line_split[1:]) 195 | else: 196 | # 当没有内置命令时,执行模块,传入参数 197 | # ExecuteModel(line_split[1:], line_split[0]) 198 | print("".join(line_split[1:]), line_split[0]) 199 | ExecuteModel("".join(line_split[1:]), line_split[0]) 200 | 201 | def fun_echo(self, args): 202 | # print("||".join(args)) 203 | for arg in args: 204 | # 判断是否是系统内嵌语句 205 | if self.system_plugin.match(arg): 206 | # 当参数为变量时,输出变量的值 207 | print(self.deal_var(arg), end="") 208 | else: 209 | print(self.deal_var(arg), end=" ") 210 | print() 211 | 212 | def fun_uname(self, args=0, inline=False): 213 | if not inline: print(self.kernel[0]) 214 | else: return self.kernel[0] 215 | 216 | def deal_var(self, var): 217 | # 返回一个式子的值(先判断是否是变量,再判断是否是列表,最后判断是否是字典) 218 | # 如果一个变量什么都不加,就是直接输出变量的值 219 | # 列表:$var->index 220 | # 字典:$var->key 221 | if self.is_var(var): 222 | # 变量名要去除前面的$ 223 | var = var[1:] 224 | # print("var",var) 225 | if "->" in var: 226 | var = var.split("->") 227 | if var[0] in self.variables: 228 | if type(self.var_call(var[0])) == list: 229 | return self.read_list(var[0], int(var[1])) 230 | elif type(self.var_call(var[0])) == dict: 231 | return self.read_dict(var[0], var[1]) 232 | else: 233 | return self.var_call(var[0]) 234 | else: 235 | return var 236 | else: 237 | return self.var_call(var) 238 | elif var in ["Color.red", "Color.green", "Color.blue", "Color.yellow", "Color.purple", "Color.cyan", "Color.end", "Color.bold", "Color.underline"]: 239 | c = var.split(".") 240 | c = c[1].upper() 241 | return getattr(Colors, c) 242 | elif var in ["Logo.line_b", "Logo.line_n", "Logo.line_b_l", "Logo.line_n_l", "Logo.line_b_m", "Logo.line_n_m", "Logo.line_b_s", "Logo.line_n_s"]: 243 | c = var.split(".") 244 | c = c[1].lower() 245 | return getattr(Logo, "div_"+c) 246 | else: 247 | return var 248 | # 替换一个命令中的所有变量为它的值,然后返回计算结果 249 | def replace_var(self, command): 250 | # 替换所有$开头的变量 251 | for var in self.variables: 252 | command = command.replace("$" + var, str(self.var_call(var))) 253 | # 计算表达式的值 254 | return eval(command) 255 | 256 | def replace_commands(self, line): 257 | while "%%" in line: 258 | start = line.find("%%") 259 | end = line.find("%%", start+2) 260 | line = line.replace(line[start:end+2], str(self.commands[line[start+2:end]](inline=True))) 261 | return line 262 | 263 | def only_replace_var(self, command): 264 | # 替换所有$开头的变量 265 | for var in self.variables: 266 | command = command.replace("$" + var, str(self.var_call(var))) 267 | return command 268 | 269 | # 当变量是列表时,读取列表中的值 270 | def read_list(self, var, index): 271 | return self.var_call(var)[index] 272 | 273 | # 当变量是字典时,读取字典中的值 274 | def read_dict(self, var, key): 275 | return self.var_call(var)[key] 276 | 277 | # 识别是否是一个变量 278 | def is_var(self, var): 279 | if var[0] == "$": 280 | return True 281 | else: 282 | return False 283 | 284 | # 识别是否是一个列表 285 | def is_list(self, var): 286 | if var[0] == "[" and var[-1] == "]": 287 | return True 288 | else: 289 | return False 290 | 291 | # 识别是否是一个字典 292 | def is_dict(self, var): 293 | if var[0] == "{" and var[-1] == "}": 294 | return True 295 | else: 296 | return False 297 | 298 | if __name__ == "__main__": 299 | Ish().run() -------------------------------------------------------------------------------- /models/calculator.py: -------------------------------------------------------------------------------- 1 | #! IcePlugin.v1 2 | #! PluginName: Calculator 3 | #! Author: Lanbin 4 | #! Description: A simple calculator 5 | #! Version: 1.0.0 6 | #! LastEdit: 2024-1-7 00:05:41 7 | 8 | while True: 9 | a = input(">>> ") 10 | if a == "q": 11 | print("Bye~") 12 | exit(0) 13 | print(eval(a)) -------------------------------------------------------------------------------- /models/client.py: -------------------------------------------------------------------------------- 1 | # 远程控制系统:客户端 2 | # 作者:Lanbin 3 | 4 | import socket 5 | import subprocess 6 | 7 | 8 | def create_client_socket(address, port): 9 | client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 10 | client_socket.connect((address, port)) 11 | return client_socket 12 | 13 | 14 | def run_client(): 15 | # 创建客户端套接字 16 | client_socket = create_client_socket('127.0.0.1', 8888) 17 | 18 | # 接收唯一识别码 19 | unique_id = int(client_socket.recv(1024).decode()) 20 | print(f"已连接到服务端,唯一识别码为:{unique_id}") 21 | 22 | try: 23 | while True: 24 | data = client_socket.recv(1024) 25 | if not data: 26 | break 27 | command = data.decode() 28 | print(f"接收到来自服务端的命令:{command}") 29 | 30 | if command.startswith('msg'): 31 | # 显示消息文本 32 | print(command[4:]) 33 | elif command.startswith('ping'): 34 | # 执行Ping命令并返回结果 35 | result = subprocess.Popen(command[4:], shell=True, stdout=subprocess.PIPE) 36 | output = result.stdout.read().decode() 37 | client_socket.send(output.encode()) 38 | print(f"已向服务端发送结果:{output}") 39 | else: 40 | # 未知命令 41 | print("Unknown command") 42 | 43 | except KeyboardInterrupt: 44 | client_socket.close() 45 | print("客户端已关闭") 46 | return 47 | 48 | 49 | if __name__ == '__main__': 50 | run_client() 51 | 52 | -------------------------------------------------------------------------------- /models/dellib.py: -------------------------------------------------------------------------------- 1 | 2 | import os 3 | import sys 4 | 5 | sys.path.append("..") 6 | 7 | from tools.iPrint import * 8 | 9 | from argparse import ArgumentParser 10 | from misc.Error import Error 11 | 12 | parser = ArgumentParser() 13 | parser.add_argument("libname", help="The name of the lib which you want to delete.") 14 | args = parser.parse_args() 15 | if args.libname == None: 16 | iPrintLog("Nothing to delete", "Dellib", "Main", "warning") 17 | exit(0) 18 | 19 | try: 20 | os.system("pip uninstall "+args.libname) 21 | except: 22 | Error.printError(20001) 23 | -------------------------------------------------------------------------------- /models/demo.ish: -------------------------------------------------------------------------------- 1 | echo Logo.line_b 2 | echo Shall Me 3 | echo Logo.line_b 4 | 5 | $var="hello" 6 | $app=1+1 7 | echo app $app 8 | 9 | $app=$app+1 10 | echo Var APP += 1 11 | echo app $app 12 | 13 | $ah="meme" 14 | $num1=1 15 | echo 1 16 | echo $var 17 | 18 | # 这是TMP临时变量 19 | $% = "temp" 20 | 21 | # 这是注释 22 | ; 这也是注释 23 | 24 | # 变量可以储存列表 25 | $stu=[1,2,3] 26 | echo $stu 27 | echo $stu->0 28 | 29 | # 输出颜色,支持的颜色: 30 | # Color.red Color.green Color.blue Color.yellow Color.purple Color.cyan Color.end Color.bold Color.underline 31 | 32 | echo Color.red Red Color.end 33 | echo Color.blue Blue Color.end 34 | echo Color.green Green Color.end 35 | echo Color.yellow Yellow Color.end 36 | echo Color.purple Purple Color.end 37 | echo Color.cyan Cyan Color.end 38 | echo Color.bold Bold Color.end 39 | echo Color.underline Underline Color.end 40 | 41 | # 可以混搭 42 | echo Color.red Red Color.blue Blue Color.end 43 | echo Color.red Red Color.blue Blue Color.end Color.bold Bold Color.end 44 | 45 | # if语句 46 | $condition=True 47 | !if ($condition) 48 | > echo Condition为 $condition 49 | > echo IF成立 50 | !else 51 | > echo Condition为 $condition 52 | > echo IF不成立 53 | !endif 54 | 55 | # 空条件,相当于False 56 | !if () 57 | > echo IF2成立 58 | !else 59 | > echo IF2不成立 60 | !endif 61 | 62 | # not可以成为判断式的一部分 63 | # 此时,$condition为True, 64 | # 但是not $condition为False 65 | 66 | !if (not $condition) 67 | > echo IF3成立 68 | !else 69 | > echo IF3不成立 70 | !endif 71 | 72 | echo %%uname%% 73 | uname 74 | 75 | # 如果uname是Windows,那么就输出Windows 76 | !if ("%%uname%%" == "Windows") 77 | > echo Windows 78 | !else 79 | > echo Linux 80 | !endif -------------------------------------------------------------------------------- /models/downlib.py: -------------------------------------------------------------------------------- 1 | 2 | import os 3 | import sys 4 | 5 | sys.path.append("..") 6 | 7 | from tools.SelfCheck import SelfCheck 8 | from tools.iPrint import * 9 | 10 | 11 | unready = SelfCheck.LibCheckNative() 12 | 13 | if len(unready) == 0: 14 | iPrintLog("Nothing to download", "Downlib", "Main", "warning") 15 | exit(0) 16 | 17 | iPrintLog("Ready to download", "Downlib", "Main", "info") 18 | for lib in unready: 19 | os.system("pip install "+lib) 20 | iPrintLog(lib + " download!", "Downlib", "Main", "success") 21 | 22 | iPrintLog("Download Finish!", "Downlib", "Main", "success") 23 | -------------------------------------------------------------------------------- /models/help/main.py: -------------------------------------------------------------------------------- 1 | import sys 2 | sys.path.append("../../") 3 | 4 | from tools.iPrint import * 5 | 6 | # 读取配置文件 7 | # 格式:print=a function which print "helloworld" 8 | def read_man_conf(): 9 | with open("../man.conf", "r") as f: 10 | conf = f.read() 11 | 12 | conf = conf.split("\n") 13 | conf_dict = {} 14 | author_dict = {} 15 | for line in conf: 16 | if line != "": 17 | line = line.split("=") 18 | aut = line[1].split("%%") 19 | conf_dict[line[0]] = aut[0] 20 | author_dict[line[0]] = aut[1] 21 | return conf_dict, author_dict 22 | 23 | config, author = read_man_conf() 24 | 25 | # 打印帮助信息 26 | print("Man Help\tAuthor\tMan") 27 | print('--------------------------------------') 28 | for man in config: 29 | if len(man) <= 8: 30 | print(f"{man}\t\t{author[man]}\t{config[man]}") 31 | else: 32 | print(f"{man}\t{author[man]}\t{config[man]}") 33 | -------------------------------------------------------------------------------- /models/man.conf: -------------------------------------------------------------------------------- 1 | print=A function which print "helloworld"%%Lanbin 2 | dellib=A function which delete a library%%Lanbin 3 | downlib=A function which download a library%%Lanbin 4 | models=A function which show all models%%Lanbin 5 | scan=A function which scan the network port%%Lanbin 6 | shell=A function which open a shell%%Lanbin 7 | alias=A function which show all alias%%Lanbin 8 | bash=A explainer of Ish%%Lanbin 9 | help=A function which show all help%%Lanbin 10 | shell=A function which open a shell%%Lanbin 11 | calculator=A function which open a calculator%%Lanbin 12 | trojan=A function which install a trojan%%Lanbin 13 | -------------------------------------------------------------------------------- /models/models.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | import argparse 4 | import re 5 | 6 | sys.path.append("..") 7 | 8 | from tools.iPrint import iPrintLog 9 | from misc.Info import ProgramInfo 10 | from misc.Logo import Logo 11 | 12 | class DisplayAllModules: 13 | def __init__(self): 14 | self.lists = os.listdir(".") 15 | self.model_info = {} 16 | 17 | def filter_lists(self): 18 | # 保留所有后缀名为.py的文件或者不以'__'开头的文件夹 19 | self.lists = [i for i in self.lists if i.endswith(".py") or ("." not in i and not i.startswith("__"))] 20 | for i in range(len(self.lists)): 21 | if not self.lists[i].endswith(".py"): 22 | self.lists[i] += "/main.py" 23 | 24 | def parse_plugin_info(self): 25 | # 获取插件信息 26 | for i in range(len(self.lists)): 27 | with open(self.lists[i], "r", encoding="utf-8") as f: 28 | content = f.read() 29 | if content.startswith("#! IcePlugin.v1"): 30 | plugin_name = content.split("PluginName: ")[1].split("\n")[0] 31 | author = content.split("Author: ")[1].split("\n")[0] 32 | description = content.split("Description: ")[1].split("\n")[0] 33 | version = content.split("Version: ")[1].split("\n")[0] 34 | last_edit = content.split("LastEdit: ")[1].split("\n")[0] 35 | self.model_info[self.lists[i]] = { 36 | "name": plugin_name, 37 | "author": author, 38 | "description": description, 39 | "version": version, 40 | "last_edit": last_edit, 41 | } 42 | 43 | def display_all(self): 44 | print("\nModels Found\t\tAuthor") 45 | print(Logo.div_line_n) 46 | for it in self.lists: 47 | tabs = "\t\t\t" if len(it) < 8 else "\t\t" 48 | author = self.model_info.get(it, {}).get("author", "None") 49 | print(f"{it}{tabs}{author}") 50 | 51 | print("\nCommands Found\t\tAuthor") 52 | print(Logo.div_line_n) 53 | for it in ProgramInfo.registered_modules: 54 | if it != "*": 55 | print(f"{it}\t\t\tNone") 56 | print() 57 | total_model = len(self.lists) 58 | if total_model == 0: 59 | iPrintLog("No models were found.", modelName="models", typer="error") 60 | return 61 | if len(ProgramInfo.registered_modules)-int("*" in ProgramInfo.registered_modules) == total_model: 62 | # 注册的模型数量与实际模型数量相等 63 | iPrintLog(f"Found {total_model} models. And {len(ProgramInfo.registered_modules)-1} models were registered.", modelName="models", typer="success") 64 | else: 65 | iPrintLog(f"Found {total_model} models. But only {len(ProgramInfo.registered_modules)} models were registered.", modelName="models", typer="warning") 66 | 67 | 68 | def add_spaces_for_chinese_characters(value): 69 | # 使用正则表达式找到所有中文字符 70 | chinese_characters = re.findall(r'[\u4e00-\u9fff]', value) 71 | num_chinese_characters = len(chinese_characters) 72 | 73 | # 在字符串后面添加相应数量的空格 74 | return value + '1' * num_chinese_characters 75 | 76 | def display_module_info(input_name, all_modules): 77 | found = False 78 | input_name_lower = input_name.lower() 79 | 80 | # 检查是否有匹配的模块(不区分大小写) 81 | for path, info in all_modules.model_info.items(): 82 | name_lower = info['name'].lower() 83 | path_lower = path.lower() 84 | if name_lower == input_name_lower or path_lower.endswith(input_name_lower + '.py'): 85 | found = True 86 | # 以表格形式打印信息 87 | print(f"+{'-'*18}+{'-'*40}+") 88 | print(f"| {'Attribute':^16} | {'Value':^38} |") 89 | print(f"+{'-'*18}+{'-'*40}+") 90 | for key, value in info.items(): 91 | value = add_spaces_for_chinese_characters(value) 92 | print(f"| {key.capitalize():<16} | {value:<38} |") 93 | print(f"+{'-'*18}+{'-'*40}+") 94 | break 95 | 96 | if not found: 97 | # print(f"Module '{input_name}' not found.") 98 | print(f"+{'-'*18}+{'-'*40}+") 99 | print(f"| {'Attribute':^16} | {'Value':^38} |") 100 | print(f"+{'-'*18}+{'-'*40}+") 101 | key = "Error" 102 | value = "Module doesn't exsist or has no MetaInfo." 103 | print(f"| {key.capitalize():<16} | {value:<38} |") 104 | print(f"+{'-'*18}+{'-'*40}+") 105 | 106 | def main(): 107 | parser = argparse.ArgumentParser() 108 | parser.add_argument("module", nargs="?", help="Module name or path to display its information.") 109 | args = parser.parse_args() 110 | 111 | all_modules = DisplayAllModules() 112 | all_modules.filter_lists() 113 | all_modules.parse_plugin_info() 114 | 115 | if args.module: 116 | display_module_info(args.module, all_modules) 117 | else: 118 | all_modules.display_all() 119 | 120 | if __name__ == "__main__": 121 | main() 122 | iPrintLog(f"Models end!", modelName="models", typer="info") 123 | -------------------------------------------------------------------------------- /models/print.py: -------------------------------------------------------------------------------- 1 | from argparse import ArgumentParser 2 | parser = ArgumentParser() 3 | parser.add_argument("echo", help="add some") 4 | args = parser.parse_args() 5 | echo = args.echo 6 | print(echo) -------------------------------------------------------------------------------- /models/scan.py: -------------------------------------------------------------------------------- 1 | import threading 2 | import socket 3 | import sys 4 | from argparse import ArgumentParser 5 | sys.path.append("..") 6 | 7 | from tools.iPrint import * 8 | from misc.Color import Colors 9 | 10 | 11 | pts = [] 12 | now = 0 13 | 14 | def get_input(): 15 | parser = ArgumentParser() 16 | parser.add_argument("host", help="The host") 17 | parser.add_argument("-sp", help="The start port", required=True) 18 | parser.add_argument("-np", help="The end port", required=True) 19 | args = parser.parse_args() 20 | ip = args.host 21 | start_port = int(args.sp) 22 | end_port = int(args.np) 23 | return ip, start_port, end_port 24 | 25 | def scan_port(ip, port): 26 | global now 27 | s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 28 | try: 29 | s.connect((ip, port)) 30 | print(' ',end='\r') 31 | iPrintLog(f'Port {port} is open',"SuperScan", typer="success") 32 | pts.append(port) 33 | except: 34 | pass 35 | finally: 36 | now += 1 37 | s.close() 38 | 39 | print(Colors.CYAN + ''' 40 | ======================================================== 41 | _____ _____ 42 | / ____| / ____| 43 | | (___ _ _ _ __ ___ _ __ | (___ ___ __ _ _ __ 44 | \___ \| | | | '_ \ / _ \ '__| \___ \ / __/ _` | '_ \ 45 | ____) | |_| | |_) | __/ | ____) | (_| (_| | | | | 46 | |_____/ \__,_| .__/ \___|_| |_____/ \___\__,_|_| |_| 47 | | | 48 | |_| 49 | ======================================================== 50 | 阉割版 | Author: Lanbin | Github: lanbinshijie 51 | ========================================================'''+Colors.END) 52 | 53 | ip, start_port, end_port = get_input() 54 | iPrintLog(f"Scan is ready to start.", "SuperScan", typer="info") 55 | iPrintLog(f"Target: {ip}", "SuperScan", typer="info") 56 | iPrintLog(f"Start Port: {start_port}", "SuperScan", typer="info") 57 | iPrintLog(f"End Port: {end_port}", "SuperScan", typer="info") 58 | iPrintLog(f"========================================================", "SuperScan", typer="info") 59 | 60 | total_ports = end_port - start_port + 1 61 | ports_scanned = 0 62 | print(' \r',end='') 63 | for port in range(start_port, end_port + 1): 64 | t = threading.Thread(target=scan_port, args=(ip, port)) 65 | t.start() 66 | ports_scanned += 1 67 | if(ports_scanned % 25 == 0): 68 | iPrintLogNative(f'Scanned {len(pts)} Open Ports ({now}/{ports_scanned}/{total_ports})\r',"SuperScan", typer="info") 69 | while now != total_ports: 70 | if(now % 2 == 0): 71 | iPrintLogNative(f'Scanned {len(pts)} Open Ports ({now}/{ports_scanned}/{total_ports})\r',"SuperScan", typer="info") 72 | print(" \r") 73 | iPrintLog("========================================================","SuperScan", typer="warning") 74 | iPrintLog("Scanned Finish!","SuperScan", typer="warning") 75 | iPrintLog("There aren't any Result.","SuperScan", typer="warning") 76 | iPrintLog("========================================================","SuperScan", typer="warning") 77 | 78 | 79 | -------------------------------------------------------------------------------- /models/shell.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | import os,sys 4 | 5 | sys.path.append("..") 6 | 7 | from tools.iPrint import * 8 | from misc.Color import Colors 9 | 10 | class Shell: 11 | def __init__(self) -> None: 12 | self.runShell() 13 | 14 | def runShell(self): 15 | while True: 16 | try: 17 | command = input(Colors.RED + "IShell ~$shell> " + Colors.END) 18 | if command in ["q", "quit", "exit", "exit()"]: 19 | return 0 20 | else: 21 | os.system(command) 22 | except KeyboardInterrupt: 23 | return 0 24 | except Exception as e: 25 | print(Colors.RED + "[!]" + Colors.END + "Error: " + e) 26 | 27 | Shell() 28 | 29 | -------------------------------------------------------------------------------- /models/trojan/main.py: -------------------------------------------------------------------------------- 1 | # 远程控制系统:服务端 2 | # 作者:Lanbin 3 | 4 | import socket 5 | 6 | 7 | def create_server_socket(address, port): 8 | server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 9 | server_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) 10 | server_socket.bind((address, port)) 11 | server_socket.listen(5) 12 | return server_socket 13 | 14 | 15 | def accept_client(server_socket): 16 | client_socket, client_address = server_socket.accept() 17 | print(f"已连接客户端:{client_address}") 18 | return client_socket, client_address 19 | 20 | 21 | def generate_unique_id(clients_dict): 22 | return len(clients_dict) 23 | 24 | 25 | def send_command_to_client(client_socket, command): 26 | client_socket.send(command.encode()) 27 | 28 | 29 | def run_server(): 30 | # 创建服务器套接字 31 | server_socket = create_server_socket('127.0.0.1', 8888) 32 | 33 | # 创建保存已连接客户端套接字的字典 34 | clients_dict = {} 35 | try: 36 | while True: 37 | try: 38 | # 接受客户端连接请求 39 | client_socket, client_address = accept_client(server_socket) 40 | 41 | # 生成唯一识别码 42 | unique_id = generate_unique_id(clients_dict) 43 | 44 | # 将客户端套接字保存到字典中,其唯一识别码是它的索引 45 | clients_dict[unique_id] = client_socket 46 | 47 | # 向客户端发送生成的唯一识别码 48 | client_socket.send(str(unique_id).encode()) 49 | 50 | # 建立连接 51 | while True: 52 | data = client_socket.recv(1024) 53 | if not data: 54 | break 55 | print(f"来自客户端[{unique_id}]:{data.decode()}") 56 | 57 | # 向客户端发送指令 58 | command = input("请输入指令:") 59 | send_command_to_client(client_socket, command) 60 | except ConnectionResetError: 61 | print(f"客户端[{unique_id}]已断开连接") 62 | del clients_dict[unique_id] 63 | continue 64 | except Exception as e: 65 | print(f"服务器出现错误:{str(e)}") 66 | continue 67 | 68 | except KeyboardInterrupt: 69 | answer = input("是否关闭服务器?(y/n)") 70 | if answer == 'y': 71 | server_socket.close() 72 | print("服务器已关闭") 73 | return 74 | 75 | 76 | if __name__ == '__main__': 77 | run_server() 78 | -------------------------------------------------------------------------------- /ssr/config.ssr: -------------------------------------------------------------------------------- 1 | version="v1.0.0-alphav1.2.1" 2 | author="Lanbin" 3 | using_libs=['os', 'sys'] 4 | models_path="./models/" 5 | registered_modules=['print', 'downlib', 'dellib', 'scan', 'models', 'shell', '*'] 6 | debug_mode=True 7 | ssr_path="./ssr/" 8 | -------------------------------------------------------------------------------- /ssr/startup.ish: -------------------------------------------------------------------------------- 1 | # 启动程序,会在Shell启动时自动执行 2 | # 请将需要启动的程序或需要执行的命令放在这里 3 | # 请注意,这里的命令不会被记录到日志中 4 | 5 | # 输出绿色的字:这是来自startup.ish的输出 6 | # echo Color.green [!][Truely][Yeah]这是来自startup.ish的输出 Color.end 7 | # 它可以是红色的 8 | # echo Color.red [!][Truely][Yeah]它可以是红色的 Color.end 9 | # 也可以是蓝色的 10 | # echo Color.blue [!][Truely][Yeah]也可以是蓝色的 Color.end 11 | # 也可以是黄色的 12 | # echo Color.yellow [!][Truely][Yeah]也可以是黄色的 Color.end 13 | 14 | 15 | # 你可以在这里执行任何命令 16 | ; !if ("%%uname%%" == "Windows") 17 | ; > echo Color.red [!][Truely][Yeah]你正在使用Windows Color.end 18 | ; !else 19 | ; > echo Color.green [!][Truely][Yeah]你正在使用不是Windows的系统 Color.end 20 | 21 | echo Color.red [!][Info] 要编辑这个文件,你需要找到ssr配置中的startup.ish文件 Color.end 22 | echo Color.yellow [!][Info] 这个文件会在开启Shell时被调用 Color.end 23 | echo Color.green [!][Info] 你可以在这里写任何你想要的命令 Color.end 24 | echo Color.blue [!][Info] 你也可以用这个文件调用任何其他启动文件 Color.end 25 | echo Color.cyan [!][Info] 尝试输入"sh ../ssr/startup.ish"来调用本文件 Color.end 26 | echo [!][Info] You are using %%uname%% kernel. -------------------------------------------------------------------------------- /tools/Phraser.py: -------------------------------------------------------------------------------- 1 | 2 | # 字符替换工具 3 | 4 | from misc.Info import ProgramInfo 5 | 6 | class PS1: 7 | def paraphraser(prompt="[IShell] %u> "): 8 | # 返回值:替换后的字符串 9 | # 将prompt中的特殊字符替换成对应的内容 10 | # 特殊字符: 11 | # %n 程序名:默认为IShell 12 | # %v 版本号:默认为ProgramInfo.version 13 | # %u 用户:默认为Lanbin 14 | 15 | # 替换 16 | prompt = prompt.replace("%n", "IShell") 17 | prompt = prompt.replace("%v", ProgramInfo.version) 18 | prompt = prompt.replace("%u", "Lanbin") 19 | return prompt 20 | 21 | class alias: 22 | def __init__(self, path=ProgramInfo.basedir + "/tools/alias.conf"): 23 | with open(path, "r") as f: 24 | conf = f.read() 25 | 26 | conf = conf.split("\n") 27 | self.conf_dict = {} 28 | self.author_dict = {} 29 | for line in conf: 30 | if line != "": 31 | line = line.split("=") 32 | self.conf_dict[line[0]] = line[1] 33 | 34 | def get(self, key): 35 | return self.conf_dict[key] 36 | 37 | def exsist(self, key): 38 | if key in self.conf_dict: 39 | return True 40 | else: 41 | return False 42 | 43 | def getAll(self): 44 | self.reRead() 45 | return self.conf_dict 46 | 47 | def reRead(self, path="../tools/alias.conf"): 48 | with open(path, "r") as f: 49 | conf = f.read() 50 | 51 | conf = conf.split("\n") 52 | self.conf_dict = {} 53 | self.author_dict = {} 54 | for line in conf: 55 | if line != "": 56 | line = line.split("=") 57 | self.conf_dict[line[0]] = line[1] -------------------------------------------------------------------------------- /tools/SelfCheck.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3.7 2 | # -*- coding: utf-8 -*- 3 | # @Author : Lanbin 4 | # @Software: Vscode 5 | # @Time : 2023-1-13 14:29 6 | from misc.Info import ProgramInfo 7 | from misc.Color import Colors 8 | from misc.Logo import Logo 9 | from tools.iPrint import * 10 | from tools.Phraser import alias 11 | import os 12 | 13 | class SelfCheck: 14 | def WelcomeStart(): 15 | print(Colors.CYAN + Logo.normal_logo + Colors.END) 16 | print(Colors.BLUE + Logo.div_line_b_m + Colors.END) 17 | print(Colors.BLUE+"Welcome Use IShell...\n"+Colors.END) 18 | 19 | def LibCheck(): 20 | iPrintLog("Start Self Check...", processName="SelfCheck", modelName="Import", typer="info") 21 | total, success, error = 0,0,0 22 | uninstall = [] 23 | for lib in ProgramInfo.using_libs: 24 | total += 1 25 | try: 26 | __import__(lib) 27 | success += 1 28 | except: 29 | iPrintLog("Importing Lib \""+lib+"\" Error.", processName="SelfCheck", modelName="Import", typer="error") 30 | uninstall.append(lib) 31 | error += 1 32 | iPrintLog(f"Libs Check Finish. {total} in total, {success} success, {error} error. ", processName="SelfCheck", modelName="Import", typer="success") 33 | if error > 0: 34 | iPrintLog("检测到有依赖库未安装,请按照上方提示安装对应库!", processName="SelfCheck", modelName="Import", typer="info") 35 | iPrintLog("您可以通过运行downlib来安装这些模块。", processName="SelfCheck", modelName="Import", typer="info") 36 | iPrintLog("是否前往安装? “Y”前往IShell / “N”手动安装", processName="SelfCheck", modelName="Import", typer="info") 37 | ans = input(Colors.RED + "您的输入:> " + Colors.END) 38 | if ans == "Y": 39 | iPrintLog("为了避免不必要的报错,请您立刻运行downlib命令安装依赖库!", processName="SelfCheck", modelName="Import", typer="warning") 40 | return 41 | else: 42 | exit(0) 43 | else: 44 | iPrintLog("您可以正常运行本程序!", processName="SelfCheck", modelName="Import", typer="info") 45 | SelfCheck.ModelCheck() 46 | 47 | 48 | def ModelCheck(): 49 | if "*" in ProgramInfo.registered_modules: 50 | iPrintLog("模块注册包含通配符\"*\",请不要在生产环境中使用!", processName="SelfCheck", modelName="Model", typer="warning") 51 | if ProgramInfo.debug_mode: 52 | iPrintLog("开发者模式开启!", processName="SelfCheck", modelName="Debug", typer="warning") 53 | 54 | def LibCheckNative(): 55 | uninstall = [] 56 | for lib in ProgramInfo.using_libs: 57 | try: 58 | __import__(lib) 59 | except: 60 | uninstall.append(lib) 61 | return uninstall 62 | 63 | def CheckModel(modelName): 64 | # iPrintLog("Checking model \""+modelName+"\"...", processName="SelfCheck", modelName="Models", typer="info") 65 | ali = alias() 66 | if os.path.exists(ProgramInfo.models_path + modelName +".py"): 67 | # iPrintLog("Model \""+modelName+"\" is exists. ", processName="SelfCheck", modelName="Models", typer="success") 68 | return True 69 | elif os.path.exists(ProgramInfo.models_path + modelName + "/main.py"): 70 | return True 71 | elif ali.exsist(modelName): 72 | return True 73 | else: 74 | iPrintLog("Model \""+modelName+"\" is NOT exists! Please Check `main.py` and `"+ modelName +".py`", processName="SelfCheck", modelName="Models", typer="error") 75 | return False 76 | 77 | -------------------------------------------------------------------------------- /tools/alias.conf: -------------------------------------------------------------------------------- 1 | sh=bash 2 | al=alias 3 | 4 | cal=calculator -------------------------------------------------------------------------------- /tools/iPrint.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3.7 2 | # -*- coding: utf-8 -*- 3 | # @Author : Lanbin 4 | # @Software: Vscode 5 | # @Time : 2023-1-13 14:45 6 | 7 | from misc.Color import Colors 8 | 9 | def iPrint_Error(text: str): 10 | return Colors.RED + text + Colors.END 11 | 12 | def iPrint_Success(text: str): 13 | return Colors.GREEN + text + Colors.END 14 | 15 | def iPrint_Warning(text: str): 16 | return Colors.YELLOW + text + Colors.END 17 | 18 | def iPrint_Notice(text: str): 19 | return Colors.CYAN + text + Colors.END 20 | 21 | def iPrint_Info(text: str): 22 | return Colors.BLUE + text + Colors.END 23 | 24 | def iPrint_Bold(text: str): 25 | return Colors.BOLD + text + Colors.END 26 | 27 | def iPrintLog(text: str, processName="IShell",modelName="Main",typer:str ="info"): 28 | print(iPrint(f"[!][{typer.upper()}][{modelName}] {text}", typer)) 29 | 30 | def iPrintLogNative(text: str, processName="IShell",modelName="Main",typer:str ="info"): 31 | print(iPrint(f"[!][{typer.upper()}][{modelName}] {text}", typer), end="") 32 | 33 | def iPrint(text: str, typer: str, bold: bool = False): 34 | res = text 35 | if typer == "error": res = iPrint_Error(res) 36 | elif typer == "success": res = iPrint_Success(res) 37 | elif typer == "warning": res = iPrint_Warning(res) 38 | elif typer == "notice": res = iPrint_Notice(res) 39 | elif typer == "info": res = iPrint_Info(res) 40 | if bold: res = iPrint_Bold(res) 41 | return res 42 | 43 | --------------------------------------------------------------------------------