{"id":14638087,"url":"https://github.com/c10udlnk/myReverseExps","last_synced_at":"2025-09-07T06:32:17.274Z","repository":{"id":196214194,"uuid":"316007906","full_name":"c10udlnk/myReverseExps","owner":"c10udlnk","description":"Some common reverse exps in CTF.自己总结编写的一些逆向常用脚本\u0026\u0026常见加密/编码的实现源码和比赛时用的处理脚本。","archived":false,"fork":false,"pushed_at":"2024-01-09T02:36:43.000Z","size":76,"stargazers_count":20,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-09-11T03:44:28.063Z","etag":null,"topics":["crypto","ctf","reverse"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/c10udlnk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2020-11-25T17:21:45.000Z","updated_at":"2024-06-11T15:53:53.000Z","dependencies_parsed_at":"2023-09-23T10:27:21.020Z","dependency_job_id":null,"html_url":"https://github.com/c10udlnk/myReverseExps","commit_stats":null,"previous_names":["c10udlnk/myreverseexps"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/c10udlnk%2FmyReverseExps","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/c10udlnk%2FmyReverseExps/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/c10udlnk%2FmyReverseExps/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/c10udlnk%2FmyReverseExps/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/c10udlnk","download_url":"https://codeload.github.com/c10udlnk/myReverseExps/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232183056,"owners_count":18484727,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["crypto","ctf","reverse"],"created_at":"2024-09-10T02:01:42.603Z","updated_at":"2025-01-02T10:31:29.794Z","avatar_url":"https://github.com/c10udlnk.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# myReverseExps\n\n\u003e By c10udlnk(https://github.com/c10udlnk)\n\n自己总结编写的一些逆向常用脚本\u0026\u0026常见加密/编码的实现源码和比赛时用的处理脚本。\n\nP.S. 鲁棒性不强，请保证使用时都是规范的，不然输出有问题就不是我的锅（逃。\n\n对于各部分，readme按照其各子部分的首字母顺序进行排序。\n\n持续更新ing...\n\n## 逆向\n\n### Angr\n\n运用[angr](https://c10udlnk.top/2020/11/11/logFor-Angr-CTF/)爆破某些二进制文件（极简用法。\n\n- `myAngr.py`：angr脚本，需修改path_to_binary（文件路径）和相应参数（比如find_address之类的）。\n\n### Brainfuck\n\n将[Brainfuck](https://en.wikipedia.org/wiki/Brainfuck)源码转换为易懂的高级语言代码，在`bfCode.bf`中输入brainfuck代码，运行相应的文件即可。\n\n需修改`brainfuck2HLPL_c.py`中`set_HLPL_syntax()`函数中的配置以适应所需语言的语法。\n\n- `bfCode.bf`：Brainfuck源码。\n\n- `brainfuck2HLPL_c.py`：将Brainfuck转换为高级语言代码，以C语言为例，存入`res.c`中。\n\n- `res.c`：上述处理的结果输出。\n\n- `brainfuck2HLPL_py.py`：将Brainfuck转换为高级语言代码，以Python为例，存入`res.py`中。\n\n- `res.py`：上述处理的结果输出。\n\n### IDAprocess\n\n#### aProcOfManyEquals\n\n还原代码中乱序赋值的数组，支持形如`list[6] = 22`、`v11 = 0x3`的赋值整理。\n\n- `aProcOfManyEquals/aProcOfManyEquals.txt`：一些连续赋值的变量（实际上是为了混淆而拆开的数组）。\n- `aProcOfManyEquals/aProcOfManyEquals.py`：输出由`aProcOfManyEquals.txt`还原的数组，支持多数组整合。\n\n#### IDAPython｜patch_SMC\n\n处理xor的SMC文件时的patch脚本，在IDA中File-\u003eScript file，导入脚本运行即可。\n\n- `IDAPython/patch_SMC.py`：需修改相应的codeStart（smc起始地址）、codeLen（长度）和xorData（用来xor的key）。运行后在函数首地址按`p`转函数即可。\n\n#### IDAPython｜nop_JunkCode\n\nNop花指令时的patch脚本，在IDA中File-\u003eScript file，导入脚本运行即可。\n\n- `IDAPython/nop_JunkCode.py`：需将l修改成相应的花指令类型，并按需修改start_addr和end_addr。运行后在函数首地址按`p`转函数即可。\n\n### VMprotect\n\nvm（虚拟机）题的辅助翻译机，在分析完各opcode的作用以后填入python文件中，生成伪代码。\n\n- `VMinterpreter.py`：将各opcode的作用语句按格式填入ins_set中，再将程序中获得的opcode填入opcode列表中，运行即可。如有需要特殊处理的opcode，请填入elif中。最后伪代码输出到`assembly.txt`。\n\n- `assembly.txt`：上述处理的结果输出。\n\n- `printf_VMinterpreter.py`：翻译[自定义printf](https://www.gnu.org/software/libc/manual/html_node/Customizing-Printf.html)的printf虚拟机，将fm赋值为程序中的格式字符串，各格式占位符的作用语句填入ins_set中。如有特殊符号正则没有提取到，按需修改ptn。try中对参数的选取也要按题目实现进行修改，本例中的参数选择题目中的伪代码为：\n\n  ```c\n  __int64 __fastcall func(FILE *stream, const struct printf_info *info, const void *const *args)\n  {\n    // ...\n    width = info-\u003ewidth;\n    prec = info-\u003eprec;\n    if ( (*((_BYTE *)info + 12) \u0026 0x20) != 0 ) //info -\u003e left\n    {\n      v6 = \u0026format[width];\n    }\n    else if ( (*((_BYTE *)info + 12) \u0026 0x40) != 0 ) //info -\u003e showsign\n    {\n      v6 = \u0026format[reg[width]];\n    }\n    else\n    {\n      v6 = (char *)\u0026reg[width];\n    }\n    v7 = 0LL;\n    if ( (*((_BYTE *)info + 13) \u0026 2) != 0 ) //info-\u003eis_char\n    {\n      v7 = *(int *)\u0026format[prec];\n    }\n    else if ( (*((_BYTE *)info + 12) \u0026 2) != 0 ) //info-\u003eis_short\n    {\n      v7 = *(int *)\u0026format[reg[prec]];\n    }\n    else if ( (*((_BYTE *)info + 12) \u0026 1) != 0 ) //info-\u003eis_long_double\n    {\n      v7 = prec;\n    }\n    else if ( (*((_BYTE *)info + 12) \u0026 4) != 0 ) //info-\u003eis_long\n    {\n      v7 = reg[prec];\n    }\n    // opcode, e.g. movq\n    *(_QWORD *)v6 = v7;\n    return 0LL;\n  }\n  ```\n\n  最后伪代码输出到`printf_assembly.txt`。\n\n- `printf_assembly.txt`：上述处理的结果输出。\n\n### =Others=\n\n其他一些稀奇古怪的小脚本。\n\n- `printOpcode.py`：输出当前Python版本所有的opcode及对应助记符。\n- `bin2db.py`：64位二进制转double（小数）。\n- `myPwn.py`：自用PWN交互脚本。\n- `pexpect_Ix.py`：使用pexpect进行批量交互，可以在打开文件后持续输入输出（类似pwntools）。\n- `maze_bfs.py`：maze（迷宫题）的BFS解法。使用前需修改迷宫地图属性（地图maze、行r、列c）、起点和终点（start、end）、行走控制字符（FLAG_CHAR）、可通过条件。\n- ……\n\n## 各种编码\u0026哈希\u0026密码\n\n相关脚本存放于`./_CRYPTO_`文件夹中，以下仍然按照字母排序。\n\n一些工具：\n\n- `Generate_inv_SBox.py`：S盒被魔改时，可用于生成逆S盒。\n\n### 编码算法\n\n#### Base64\n\n- `Base64/transBase64.py`：Base64标准编码/解码，增加换表功能。换表需要将myTable修改成使用的表，如不需要换表则可以在调用trans_Ba64encode/trans_Ba64decode时第二个参数留空。\n\n### 哈希算法\n\n#### MD5\n\n\u003e 参考链接：\n\u003e\n\u003e 1. [C语言实现md5函数代码\\_xhhjin的专栏-CSDN博客_c语言md5](https://blog.csdn.net/xhhjin/article/details/8450686)\n\u003e2. [pod32g/MD5: C implementation of the MD5 algorithm](https://github.com/pod32g/MD5)\n\n- `MD5/MD5.c`：日常逆向最常见到的MD5写法（参考链接-1）。\n- `MD5/MD5`：由`MD5.c`编译而来，可以用IDA pro打开以对比逆向代码。\n- `MD5/MD5_std.c`：常规MD5写法（参考链接-2）。\n- `MD5/MD5_std`：由`MD5_std.c`编译而来，可以用IDA pro打开以对比逆向代码。\n- `MD5/MD5.py`：使用封装的MD5函数进行MD5值计算。\n\n\n\n### 现代密码算法\n\n#### DES\n\n\u003e 参考链接：\n\u003e\n\u003e [DES算法实例详解-码农场](http://www.hankcs.com/security/des-algorithm-illustrated.html)\n\n- `DES/DES.cpp`：DES加解密算法实现源码。\n- `DES/DES.py`：使用封装的DES函数进行加解密。\n- `DES/DES`：由`DES.cpp`编译而来，可以用IDA pro打开以对比逆向代码。\n\n#### RC4\n\n\u003e 参考链接：\n\u003e\n\u003e [恶意代码分析之 RC4 算法学习 - 知乎](https://zhuanlan.zhihu.com/p/102245260)\n\n- `RC4/RC4.cpp`：RC4加解密算法实现源码。\n- `RC4/RC4.py`：使用封装的RC4函数进行加解密。\n- `RC4/RC4`：由`RC4.cpp`编译而来，可以用IDA pro打开以对比逆向代码","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fc10udlnk%2FmyReverseExps","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fc10udlnk%2FmyReverseExps","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fc10udlnk%2FmyReverseExps/lists"}