├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .assets ├── image-20231010131805227.png ├── image-20231010131850918.png ├── image-20231010132015761.png ├── image-20231010132304258.png ├── image-20231010132429622.png ├── image-20231010132626519.png └── image-20231010132700553.png ├── .idea ├── kotlinc.xml ├── vcs.xml ├── inspectionProfiles │ └── Project_Default.xml ├── misc.xml ├── gradle.xml ├── artifacts │ └── iCrypto_jar.xml └── uiDesigner.xml ├── src └── main │ ├── kotlin │ ├── net │ │ └── ankio │ │ │ └── icrypto │ │ │ ├── rule │ │ │ ├── CommandType.kt │ │ │ ├── Rule.kt │ │ │ ├── Config.kt │ │ │ └── Execution.kt │ │ │ ├── registers │ │ │ ├── MessageEditorTabFactory.kt │ │ │ ├── MessageEditorTab.kt │ │ │ └── HttpListener.kt │ │ │ ├── http │ │ │ ├── HttpAgreement.kt │ │ │ ├── HttpAgreementRequest.kt │ │ │ ├── HttpAgreementResponse.kt │ │ │ └── Cache.kt │ │ │ └── BurpExtender.kt │ └── Main.kt │ └── java │ └── net │ └── ankio │ └── icrypto │ └── ui │ ├── MainGUI.jfd │ └── MainGUI.java ├── settings.gradle ├── examples └── SM4加解密 │ ├── package.json │ └── sm4.cjs ├── .gitignore ├── License ├── gradlew.bat ├── README.md └── gradlew /gradle.properties: -------------------------------------------------------------------------------- 1 | kotlin.code.style=official 2 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dreamncn/iCrypto/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /.assets/image-20231010131805227.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dreamncn/iCrypto/HEAD/.assets/image-20231010131805227.png -------------------------------------------------------------------------------- /.assets/image-20231010131850918.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dreamncn/iCrypto/HEAD/.assets/image-20231010131850918.png -------------------------------------------------------------------------------- /.assets/image-20231010132015761.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dreamncn/iCrypto/HEAD/.assets/image-20231010132015761.png -------------------------------------------------------------------------------- /.assets/image-20231010132304258.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dreamncn/iCrypto/HEAD/.assets/image-20231010132304258.png -------------------------------------------------------------------------------- /.assets/image-20231010132429622.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dreamncn/iCrypto/HEAD/.assets/image-20231010132429622.png -------------------------------------------------------------------------------- /.assets/image-20231010132626519.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dreamncn/iCrypto/HEAD/.assets/image-20231010132626519.png -------------------------------------------------------------------------------- /.assets/image-20231010132700553.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dreamncn/iCrypto/HEAD/.assets/image-20231010132700553.png -------------------------------------------------------------------------------- /.idea/kotlinc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/main/kotlin/net/ankio/icrypto/rule/CommandType.kt: -------------------------------------------------------------------------------- 1 | package net.ankio.icrypto.rule 2 | 3 | enum class CommandType { 4 | RequestFromClient, 5 | RequestToServer, 6 | ResponseFromServer, 7 | ResponseToClient 8 | } 9 | -------------------------------------------------------------------------------- /src/main/kotlin/Main.kt: -------------------------------------------------------------------------------- 1 | import net.ankio.icrypto.ui.MainGUI 2 | 3 | import javax.swing.SwingUtilities 4 | 5 | 6 | 7 | 8 | fun main(){ 9 | 10 | SwingUtilities.invokeLater { 11 | val gui = MainGUI() 12 | gui.root.isVisible = true 13 | } 14 | } -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | mavenCentral() 4 | gradlePluginPortal() 5 | } 6 | } 7 | 8 | plugins { 9 | id 'org.gradle.toolchains.foojay-resolver-convention' version '0.5.0' 10 | } 11 | 12 | rootProject.name = 'iCrypto' -------------------------------------------------------------------------------- /examples/SM4加解密/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "sm4", 3 | "version": "1.0.0", 4 | "description": "", 5 | "type": "module", 6 | "scripts": { 7 | "start": "node sm4.cjs" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "sm-crypto": "^0.3.12" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /src/main/kotlin/net/ankio/icrypto/rule/Rule.kt: -------------------------------------------------------------------------------- 1 | package net.ankio.icrypto.rule 2 | 3 | import kotlinx.serialization.Serializable 4 | 5 | @Serializable 6 | data class Rule(var name:String, var url:String, val command:String){ 7 | override fun toString(): String { 8 | return name 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /src/main/kotlin/net/ankio/icrypto/registers/MessageEditorTabFactory.kt: -------------------------------------------------------------------------------- 1 | package net.ankio.icrypto.registers 2 | 3 | import burp.IMessageEditorController 4 | import burp.IMessageEditorTab 5 | import burp.IMessageEditorTabFactory 6 | 7 | class MessageEditorTabFactory : IMessageEditorTabFactory { 8 | override fun createNewInstance(iMessageEditorController: IMessageEditorController, b: Boolean): IMessageEditorTab { 9 | return MessageEditorTab(iMessageEditorController, b) 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 15 | 16 | -------------------------------------------------------------------------------- /src/main/kotlin/net/ankio/icrypto/http/HttpAgreement.kt: -------------------------------------------------------------------------------- 1 | package net.ankio.icrypto.http 2 | 3 | abstract class HttpAgreement { 4 | fun subByte(b: ByteArray?, off: Int, length: Int): ByteArray { 5 | val b1 = ByteArray(length) 6 | if (b != null) { 7 | System.arraycopy(b, off, b1, 0, length) 8 | } 9 | return b1 10 | } 11 | 12 | fun byteMerger(bt1: ByteArray, bt2: ByteArray): ByteArray { 13 | val bt3 = ByteArray(bt1.size + bt2.size) 14 | System.arraycopy(bt1, 0, bt3, 0, bt1.size) 15 | System.arraycopy(bt2, 0, bt3, bt1.size, bt2.size) 16 | return bt3 17 | } 18 | } -------------------------------------------------------------------------------- /.idea/artifacts/iCrypto_jar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | $PROJECT_DIR$/out/artifacts/iCrypto_jar 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | build/ 3 | !gradle/wrapper/gradle-wrapper.jar 4 | !**/src/main/**/build/ 5 | !**/src/test/**/build/ 6 | 7 | ### IntelliJ IDEA ### 8 | .idea/modules.xml 9 | .idea/jarRepositories.xml 10 | .idea/compiler.xml 11 | .idea/libraries/ 12 | *.iws 13 | *.iml 14 | *.ipr 15 | out/ 16 | !**/src/main/**/out/ 17 | !**/src/test/**/out/ 18 | 19 | ### Eclipse ### 20 | .apt_generated 21 | .classpath 22 | .factorypath 23 | .project 24 | .settings 25 | .springBeans 26 | .sts4-cache 27 | bin/ 28 | !**/src/main/**/bin/ 29 | !**/src/test/**/bin/ 30 | 31 | ### NetBeans ### 32 | /nbproject/private/ 33 | /nbbuild/ 34 | /dist/ 35 | /nbdist/ 36 | /.nb-gradle/ 37 | 38 | ### VS Code ### 39 | .vscode/ 40 | 41 | ### Mac OS ### 42 | .DS_Store -------------------------------------------------------------------------------- /License: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Ankio 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 | -------------------------------------------------------------------------------- /src/main/kotlin/net/ankio/icrypto/rule/Config.kt: -------------------------------------------------------------------------------- 1 | import kotlinx.serialization.Serializable 2 | import kotlinx.serialization.decodeFromString 3 | import kotlinx.serialization.encodeToString 4 | import kotlinx.serialization.json.Json 5 | import net.ankio.icrypto.BurpExtender 6 | import net.ankio.icrypto.rule.Rule 7 | 8 | @Serializable 9 | data class Config(var auto: Boolean, var list: ArrayList) { 10 | ///usr/local/bin/node /Users/ankio/Downloads/debug_-1298305117_2_-1209654144/sm4.cjs 11 | companion object { 12 | fun load(): Config { 13 | try { 14 | val jsonString = BurpExtender.callbacks.loadExtensionSetting("Setting") 15 | 16 | if (jsonString.isNotBlank()) { // 添加空字符串检查 17 | return Json.decodeFromString(jsonString) 18 | } 19 | } catch (e: Exception) { 20 | // 在此处理反序列化时可能出现的异常 21 | e.printStackTrace() 22 | BurpExtender.stderr.println("配置加载失败") 23 | BurpExtender.stderr.println(e) 24 | } 25 | return Config(false, ArrayList()) 26 | } 27 | fun save(config: Config){ 28 | val jsonString = Json.encodeToString(config) 29 | BurpExtender.callbacks.saveExtensionSetting("Setting", jsonString) 30 | } 31 | } 32 | 33 | 34 | 35 | 36 | fun add(rule: Rule){ 37 | BurpExtender.stdout.println("保存"+rule.name) 38 | val r = list.find { it.command == rule.command } 39 | if(r===null){ 40 | BurpExtender.stdout.println("新增"+rule.name) 41 | list.add(rule) 42 | }else{ 43 | BurpExtender.stdout.println("更新"+rule.name) 44 | r.name = rule.name 45 | r.url = rule.url 46 | } 47 | 48 | save(this) 49 | } 50 | 51 | fun del(index:Int){ 52 | list.removeAt(index) 53 | save(this) 54 | } 55 | 56 | fun find(url: String): Rule? { 57 | return list.find { url.contains(it.url) } 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /examples/SM4加解密/sm4.cjs: -------------------------------------------------------------------------------- 1 | var v = "257624b6edf725c09eb79e2d51705f67", g = "7a2d05c2b810c55555e817d0f9a0a1b5"; 2 | const RequestFromClient = "0";// 日志/Interrupt收到请求(请求包解密) 3 | const RequestToServer = "1";// Repeater/Interrupt发出请求(请求包加密) 4 | const ResponseFromServer = "2";// 日志/Repeater/Interrupt收到响应(响应包解密) 5 | const ResponseToClient = "3";// Repeater/Interrupt发出响应(响应包加密) 6 | 7 | //从命令行获取参数 8 | var args = process.argv.slice(2); 9 | if(args.length!==2){ 10 | throw "错误,至少有两个参数!" 11 | } 12 | 13 | //数据 14 | var path = args[1]; 15 | const fs = require('fs'); 16 | const {sm4} = require("sm-crypto"); 17 | 18 | //获取 19 | function getRequestBody() { 20 | return fs.readFileSync(path + '/body.txt').toString(); 21 | } 22 | //设置 23 | function setRequestBody(data) { 24 | fs.writeFileSync(path + '/body.txt',data); 25 | } 26 | 27 | function getResponseBody() { 28 | return fs.readFileSync(path + '/response_body.txt').toString(); 29 | } 30 | //设置 31 | function setResponseBody(data) { 32 | fs.writeFileSync(path + '/response_body.txt',data); 33 | } 34 | 35 | function encrypt(msg) { 36 | const sm4 = require('sm-crypto').sm4 37 | 38 | return sm4.encrypt(msg, v,{ 39 | mode: "cbc", 40 | iv: g 41 | }) // 加密,默认输出 16 进制字符串,默认使用 pkcs#7 填充(传 pkcs#5 也会走 pkcs#7 填充) 42 | 43 | } 44 | 45 | function decrypt(msg) { 46 | const sm4 = require('sm-crypto').sm4 47 | 48 | return sm4.decrypt(msg, v,{ 49 | mode: "cbc", 50 | iv: g 51 | }) // 加密,默认输出 16 进制字符串,默认使用 pkcs#7 填充(传 pkcs#5 也会走 pkcs#7 填充) 52 | 53 | } 54 | 55 | 56 | 57 | if(args[0]===RequestFromClient){ 58 | setRequestBody(decrypt(getRequestBody())); 59 | } 60 | 61 | if(args[0]===RequestToServer){ 62 | setRequestBody(encrypt(getRequestBody())); 63 | } 64 | 65 | if(args[0]===ResponseFromServer){ 66 | let body = JSON.parse(getResponseBody()); 67 | body.data = JSON.parse(decrypt(body.data)); 68 | setResponseBody(JSON.stringify(body)); 69 | } 70 | 71 | if(args[0]===ResponseToClient){ 72 | let body = JSON.parse(getResponseBody()); 73 | body.data = encrypt(JSON.stringify(body.data)); 74 | setResponseBody(JSON.stringify(body)); 75 | } 76 | 77 | //最后一定要输出 success 78 | console.log("success") 79 | -------------------------------------------------------------------------------- /src/main/kotlin/net/ankio/icrypto/BurpExtender.kt: -------------------------------------------------------------------------------- 1 | package net.ankio.icrypto 2 | 3 | import Config 4 | import burp.IBurpExtender 5 | import burp.IBurpExtenderCallbacks 6 | import burp.ITab 7 | import net.ankio.icrypto.registers.HttpListener 8 | import net.ankio.icrypto.registers.MessageEditorTabFactory 9 | import net.ankio.icrypto.ui.MainGUI 10 | import java.awt.Component 11 | import java.io.IOException 12 | import java.io.PrintWriter 13 | 14 | class BurpExtender : IBurpExtender,ITab { 15 | override fun registerExtenderCallbacks(callbacks: IBurpExtenderCallbacks) { 16 | Companion.stdout = PrintWriter(callbacks.stdout, true) 17 | Companion.stderr = PrintWriter(callbacks.stderr, true) 18 | Companion.callbacks = callbacks 19 | Companion.config = Config.load() 20 | 21 | callbacks.setExtensionName("$extensionName $version") 22 | 23 | 24 | try { 25 | callbacks.registerHttpListener(HttpListener()) 26 | callbacks.registerProxyListener(HttpListener()) 27 | callbacks.registerMessageEditorTabFactory(MessageEditorTabFactory()) 28 | callbacks.addSuiteTab(this@BurpExtender) 29 | stdout.println( 30 | """[+] $extensionName is loaded 31 | [+] ^_^ 32 | [+] 33 | [+] ##################################### 34 | [+] $extensionName v$version 35 | [+] author: ankio 36 | [+] email: admin@ankio.net 37 | [+] github: https://github.com/dreamncn 38 | [+] ####################################""" 39 | ) 40 | } catch (e: IOException) { 41 | stdout.println("初始化异常:" + e.message) 42 | e.printStackTrace() 43 | } 44 | } 45 | 46 | 47 | companion object { 48 | 49 | lateinit var callbacks: IBurpExtenderCallbacks 50 | lateinit var config: Config 51 | lateinit var stdout: PrintWriter 52 | lateinit var stderr: PrintWriter 53 | const val version: String = "1.0.0" 54 | const val extensionName: String = "iCrypto" 55 | 56 | } 57 | 58 | override fun getTabCaption(): String { 59 | return extensionName 60 | } 61 | 62 | override fun getUiComponent(): Component { 63 | val gui = MainGUI() 64 | return gui.root 65 | } 66 | 67 | fun finalize(){ 68 | Config.save(config) 69 | } 70 | } -------------------------------------------------------------------------------- /src/main/kotlin/net/ankio/icrypto/http/HttpAgreementRequest.kt: -------------------------------------------------------------------------------- 1 | package net.ankio.icrypto.http 2 | 3 | import burp.IRequestInfo 4 | import com.google.common.base.Splitter 5 | import com.google.common.collect.Lists 6 | import net.ankio.icrypto.BurpExtender 7 | import java.io.IOException 8 | 9 | class HttpAgreementRequest(requestData: ByteArray?,cache:Cache?) : HttpAgreement() { 10 | var method = "" 11 | var path = "" 12 | var version = "" 13 | var headers = "" 14 | var body: ByteArray = byteArrayOf() 15 | constructor() : this(null,null) { 16 | 17 | } 18 | 19 | init { 20 | if (requestData != null) { 21 | val requestInfo: IRequestInfo = BurpExtender.callbacks.helpers.analyzeRequest(requestData) 22 | val split: Iterable = Splitter.on("\r\n").split(String(requestData)) 23 | val strings: ArrayList = Lists.newArrayList(split) 24 | val path = strings[0].split(" ".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray() //首行是请求头 25 | method = path[0] 26 | this.path = path[1] 27 | version = path[2] 28 | headers = "" 29 | val s = StringBuilder() 30 | var i: Int = 1 31 | while (i < strings.size - 2) { 32 | s.append(strings[i]).append("\r\n") 33 | i++ 34 | } 35 | headers = s.toString().trim { it <= ' ' } 36 | body = subByte(requestData, requestInfo.bodyOffset, requestData.size - requestInfo.bodyOffset) 37 | if (cache != null) { 38 | cache.set("method", method) 39 | cache.set("path", this.path) 40 | cache.set("version", version) 41 | cache.set("headers", headers) 42 | cache.setRaw("body", body) 43 | } 44 | } 45 | } 46 | 47 | fun toRequest(): ByteArray { 48 | return toRequest(null) 49 | } 50 | 51 | 52 | fun toRequest(cache:Cache?): ByteArray { 53 | val stringBuilder = StringBuilder() 54 | var length = 0 55 | if (cache != null) { 56 | method = cache.get("method") 57 | path = cache.get("path") 58 | version = cache.get("version") 59 | headers = cache.get("headers") 60 | body = cache.getRaw("body") 61 | length = body.size 62 | } 63 | 64 | headers = headers.replace("Content-Length: \\d+".toRegex(), "Content-Length: $length") 65 | //更新headers 66 | stringBuilder.append(method).append(" ").append(path).append(" ").append(version).append("\r\n") 67 | stringBuilder.append(headers).append("\r\n") 68 | stringBuilder.append("\r\n") 69 | val bytes = stringBuilder.toString().toByteArray() 70 | return byteMerger(bytes, body) 71 | } 72 | } -------------------------------------------------------------------------------- /src/main/kotlin/net/ankio/icrypto/http/HttpAgreementResponse.kt: -------------------------------------------------------------------------------- 1 | package net.ankio.icrypto.http 2 | 3 | import burp.IResponseInfo 4 | import com.google.common.base.Splitter 5 | import com.google.common.collect.Lists 6 | import net.ankio.icrypto.BurpExtender 7 | 8 | class HttpAgreementResponse(responseData: ByteArray?, cache:Cache?): HttpAgreement() { 9 | var response_version = "" 10 | var state = "" 11 | var state_msg = "" 12 | var response_headers = "" 13 | lateinit var response_body: ByteArray 14 | 15 | constructor():this(null,null){ 16 | 17 | } 18 | 19 | 20 | init { 21 | if (responseData != null) { 22 | val split = Splitter.on("\r\n").split(String(responseData)) 23 | val strings = Lists.newArrayList(split) 24 | val path = strings[0].split(" ".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray() //首行是请求头 25 | var i: Int 26 | state = path[1] 27 | state_msg = path[2] 28 | response_version = path[0] 29 | response_headers = "" 30 | val s = StringBuilder() 31 | i = 1 32 | while (i < strings.size - 2) { 33 | s.append(strings[i]).append("\r\n") 34 | i++ 35 | } 36 | response_headers = s.toString().trim { it <= ' ' } 37 | val responseInfo: IResponseInfo = BurpExtender.callbacks.helpers.analyzeResponse(responseData) 38 | response_body = subByte(responseData, responseInfo.bodyOffset, responseData.size - responseInfo.bodyOffset) 39 | if (cache != null) { 40 | cache.set("state", state) 41 | cache.set("state_msg", state_msg) 42 | cache.set("response_version", response_version) 43 | cache.set("response_headers", response_headers) 44 | cache.setRaw("response_body", response_body) 45 | } 46 | } 47 | } 48 | 49 | 50 | 51 | fun toResponse(): ByteArray { 52 | return toResponse(null) 53 | } 54 | 55 | fun toResponse(cache:Cache?): ByteArray { 56 | val stringBuilder = StringBuilder() 57 | if (cache != null) { 58 | state = cache.get("state") 59 | state_msg = cache.get("state_msg") 60 | response_version = cache.get("response_version") 61 | response_headers = cache.get("response_headers") 62 | response_body = cache.getRaw("response_body") 63 | } 64 | stringBuilder.append(response_version).append(" ").append(state).append(" ").append(state_msg).append("\r\n") 65 | stringBuilder.append(response_headers).append("\r\n") 66 | stringBuilder.append("\r\n") 67 | val bytes = stringBuilder.toString().toByteArray() 68 | return byteMerger(bytes, response_body) 69 | } 70 | 71 | } -------------------------------------------------------------------------------- /src/main/kotlin/net/ankio/icrypto/rule/Execution.kt: -------------------------------------------------------------------------------- 1 | package net.ankio.icrypto.rule 2 | 3 | import net.ankio.icrypto.BurpExtender 4 | import java.io.BufferedReader 5 | import java.io.InputStreamReader 6 | 7 | object Execution { 8 | 9 | fun run(command: String, type: CommandType?, file: String?): Boolean { 10 | val stringBuilder = StringBuilder() 11 | stringBuilder.append(command).append(" ") 12 | when (type) { 13 | CommandType.RequestFromClient -> stringBuilder.append(0) 14 | CommandType.RequestToServer -> stringBuilder.append(1) 15 | CommandType.ResponseToClient -> stringBuilder.append(3) 16 | else -> stringBuilder.append(2) 17 | } 18 | stringBuilder.append(" ").append(file) 19 | val result: String = exec(stringBuilder.toString()).trim { it <= ' ' } 20 | return "success" == result 21 | } 22 | 23 | fun exec(command: String): String { 24 | try { 25 | BurpExtender.stdout.println("执行命令:$command") 26 | // 创建一个 ProcessBuilder 对象来执行系统命令 27 | val processBuilder = ProcessBuilder(command.split(" ")) 28 | 29 | // 设置工作目录(可选) 30 | // processBuilder.directory(File("path/to/working/directory")) 31 | 32 | // 启动进程 33 | val process = processBuilder.start() 34 | 35 | // 读取进程的输入流 36 | val inputStream = process.inputStream 37 | val reader = BufferedReader(InputStreamReader(inputStream)) 38 | 39 | // 读取进程的错误流(如果需要) 40 | val errorStream = process.errorStream 41 | val errorReader = BufferedReader(InputStreamReader(errorStream)) 42 | 43 | val errOutput = StringBuilder() 44 | var errLine: String? 45 | while (errorReader.readLine().also { errLine = it } != null) { 46 | errOutput.append(errLine).append("\n") 47 | } 48 | errorReader.close() 49 | if(errOutput.isNotEmpty()){ 50 | BurpExtender.stderr.println("执行错误:$errOutput") 51 | } 52 | // 读取输入流的内容 53 | val output = StringBuilder() 54 | var line: String? 55 | while (reader.readLine().also { line = it } != null) { 56 | output.append(line).append("\n") 57 | } 58 | if(output.isEmpty()){ 59 | BurpExtender.stderr.println("执行错误:输出内容为空") 60 | } 61 | 62 | // 如果需要,等待进程执行完成 63 | val exitCode = process.waitFor() 64 | BurpExtender.stdout.println("执行结束:$exitCode") 65 | 66 | // 关闭读取器和进程 67 | reader.close() 68 | process.destroy() 69 | 70 | return output.toString() 71 | } catch (e: Exception) { 72 | e.printStackTrace() 73 | BurpExtender.stderr.println("执行异常:${e.message}") 74 | return e.message ?: "" 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%"=="" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%"=="" set DIRNAME=. 29 | @rem This is normally unused 30 | set APP_BASE_NAME=%~n0 31 | set APP_HOME=%DIRNAME% 32 | 33 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 34 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 35 | 36 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 37 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 38 | 39 | @rem Find java.exe 40 | if defined JAVA_HOME goto findJavaFromJavaHome 41 | 42 | set JAVA_EXE=java.exe 43 | %JAVA_EXE% -version >NUL 2>&1 44 | if %ERRORLEVEL% equ 0 goto execute 45 | 46 | echo. 47 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 48 | echo. 49 | echo Please set the JAVA_HOME variable in your environment to match the 50 | echo location of your Java installation. 51 | 52 | goto fail 53 | 54 | :findJavaFromJavaHome 55 | set JAVA_HOME=%JAVA_HOME:"=% 56 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 57 | 58 | if exist "%JAVA_EXE%" goto execute 59 | 60 | echo. 61 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 62 | echo. 63 | echo Please set the JAVA_HOME variable in your environment to match the 64 | echo location of your Java installation. 65 | 66 | goto fail 67 | 68 | :execute 69 | @rem Setup the command line 70 | 71 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 72 | 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if %ERRORLEVEL% equ 0 goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | set EXIT_CODE=%ERRORLEVEL% 85 | if %EXIT_CODE% equ 0 set EXIT_CODE=1 86 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% 87 | exit /b %EXIT_CODE% 88 | 89 | :mainEnd 90 | if "%OS%"=="Windows_NT" endlocal 91 | 92 | :omega 93 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 |

3 | 4 |

5 | 6 | 7 | ## 项目简介 8 | 9 | 做一些app测试经常会遇到加密、签名的问题,这个插件可以帮助你进行重新签名、数据包解密、偷天换日... 10 | 11 | | 解密前 | 解密后 | 12 | | ------------------------------------------------------------ | ------------------------------------------------------------ | 13 | | ![image-20231010131805227](.assets/image-20231010131805227.png) | ![image-20231010131850918](.assets/image-20231010131850918.png) | 14 | 15 | 16 | 17 | ## 使用 18 | 19 | - 启用插件 20 | - [编写你的脚本](#脚本编写指南) 21 | 22 | 23 | 24 | ### 自动加解密 25 | 26 | 只需勾上`自动执行脚本`,并在指定脚本添加监控URL即可(**只支持域名**) 27 | 28 | ![image-20231010132015761](.assets/image-20231010132015761.png) 29 | 30 | 自动加解密的结果可以在`History`、`Repeater`中查看 31 | 32 | ![image-20231010132304258](.assets/image-20231010132304258.png) 33 | 34 | ![image-20231010132429622](.assets/image-20231010132429622.png) 35 | 36 | 37 | ### 手动加解密 38 | 自动加解密可能存在一些性能问题,有时候可以尝试手动加解密: 39 | 40 | ![image-20231010132626519](.assets/image-20231010132626519.png) 41 | 42 | 43 | 44 | ## 脚本编写指南 45 | 46 | 插件调用脚本为: 47 | 48 | ```shell 49 | 执行命令 请求类型 临时文件夹 50 | ``` 51 | 52 | 其中,第一个参数为 `请求类型`,一共有四种类型: 53 | 54 | ```js 55 | const RequestFromClient = "0";// 日志/Interrupt收到请求(请求包解密) 56 | const RequestToServer = "1";// Repeater/Interrupt发出请求(请求包加密) 57 | const ResponseFromServer = "2";// 日志/Repeater/Interrupt收到响应(响应包解密) 58 | const ResponseToClient = "3";// Repeater/Interrupt发出响应(响应包加密 59 | ``` 60 | 61 | 可以根据burp的生命周期来理解这四种类型: 62 | 63 | ![image-20231010132700553](.assets/image-20231010132700553.png) 64 | 65 | 第二个参数为临时文件夹,数据如下: 66 | 67 | | 名称 | 解释 | 举例 | 在哪种请求下存在 | 68 | | :------------------- | ------------------------ | --------------------- | ---------------- | 69 | | body.txt | 请求包的body部分 | id=1 | Request/Response | 70 | | headers.txt | 请求包的headers部分 | Host: 127.0.0.1 等 | Request/Response | 71 | | method.txt | 请求包的请求方法 | GET | Request/Response | 72 | | path.txt | 请求包的请求路径 | /index.php | Request/Response | 73 | | version.txt | 请求包使用的Http协议版本 | HTTP/2 | Request/Response | 74 | | response_body.txt | 响应包的body部分 | {"body":"sssss"} | Response | 75 | | response_headers.txt | 响应包的headers部分 | Set-cookle: www=12333 | Response | 76 | | response_version.txt | 响应包的Http协议版本 | HTTP/2 | Response | 77 | | state.txt | 响应包的响应代码 | 404 | Response | 78 | | state_msg.txt | 响应包的响应消息 | Not Found |Response| 79 | 80 | 脚本在收到请求后,去修改对应临时文件夹的数据,处理成功,必须输出`success`字样 81 | 82 | ## 脚本调试指南 83 | 84 | - 多关注`Extender`中`iCrypto`的`output`内容,如果脚本生效,则会在这里输出处理的请求包响应包等。 85 | - 如果你发现脚本未生效,也可以复制`CustomCrypto`输出的命令内容,直接在命令行进行测试,以便于调试脚本。 86 | 87 | ## 案例&模板 88 | 89 | - [Sm4](./examples/SM4加解密) 90 | 91 | ## 协议 92 | 93 | MIT 94 | 95 | -------------------------------------------------------------------------------- /src/main/kotlin/net/ankio/icrypto/http/Cache.kt: -------------------------------------------------------------------------------- 1 | package net.ankio.icrypto.http 2 | 3 | import net.ankio.icrypto.BurpExtender 4 | import java.io.IOException 5 | import java.nio.file.* 6 | import java.nio.file.attribute.BasicFileAttributes 7 | 8 | /** 9 | * 交互 10 | */ 11 | class Cache { 12 | var temp = "" 13 | 14 | init { 15 | //创建临时文件存储数据 16 | val tmpCustomPrefix = Files.createTempDirectory("CustomCrypto") 17 | temp = tmpCustomPrefix.toString() 18 | //BurpExtender.stdout.println(String.format("临时会话文件夹[ %s ]创建成功", temp)) 19 | } 20 | 21 | /** 22 | * 设置值 23 | * @param key String 24 | * @param value String 25 | */ 26 | operator fun set(key: String, value: String) { 27 | try { 28 | Files.write(Paths.get("$temp/$key.txt"), value.toByteArray()) 29 | //BurpExtender.stdout.println(String.format("写入文件(%s)数据:%s", key, value)) 30 | } catch (e: IOException) { 31 | e.printStackTrace() 32 | BurpExtender.stderr.println(String.format("错误:%s", e.message)) 33 | BurpExtender.stderr.println(String.format("写入文件失败:%s", "$temp/$key.txt")) 34 | } 35 | } 36 | 37 | /** 38 | * 获取值 39 | * @param key String 40 | */ 41 | operator fun get(key: String): String { 42 | try { 43 | // BurpExtender.stdout.println("读取:$temp/$key.txt") 44 | return String(Files.readAllBytes(Paths.get("$temp/$key.txt"))).trim { it <= ' ' } 45 | } catch (e: IOException) { 46 | e.printStackTrace() 47 | BurpExtender.stderr.println(String.format("错误:%s", e.message)) 48 | BurpExtender.stderr.println(String.format("读取文件失败:%s", "$temp/$key.txt")) 49 | } 50 | return "" 51 | } 52 | 53 | fun getRaw(key: String): ByteArray { 54 | try { 55 | BurpExtender.stdout.println("读取:$temp/$key.txt") 56 | return Files.readAllBytes(Paths.get("$temp/$key.txt")) 57 | } catch (e: IOException) { 58 | e.printStackTrace() 59 | BurpExtender.stderr.println(String.format("错误:%s", e.message)) 60 | BurpExtender.stderr.println(String.format("读取文件失败:%s", "$temp/$key.txt")) 61 | } 62 | return byteArrayOf() 63 | } 64 | 65 | fun setRaw(key: String, value: ByteArray) { 66 | try { 67 | Files.write(Paths.get("$temp/$key.txt"), value) 68 | } catch (e: IOException) { 69 | e.printStackTrace() 70 | BurpExtender.stderr.println(String.format("错误:%s", e.message)) 71 | BurpExtender.stderr.println(String.format("写入文件失败:%s", "$temp/$key.txt")) 72 | } 73 | } 74 | 75 | fun destroy() { 76 | try { 77 | val path: Path = Paths.get(temp) 78 | Files.walkFileTree(path, 79 | object : SimpleFileVisitor() { 80 | // 先去遍历删除文件 81 | @Throws(IOException::class) 82 | override fun visitFile(file: Path?, attrs: BasicFileAttributes?): FileVisitResult { 83 | if (file != null) { 84 | Files.delete(file) 85 | } 86 | // System.out.printf("文件被删除 : %s%n", file) 87 | return FileVisitResult.CONTINUE 88 | } 89 | 90 | // 再去遍历删除目录 91 | @Throws(IOException::class) 92 | override fun postVisitDirectory(dir: Path?, exc: IOException?): FileVisitResult { 93 | if (dir != null) { 94 | Files.delete(dir) 95 | } 96 | /// System.out.printf("文件夹被删除: %s%n", dir) 97 | return FileVisitResult.CONTINUE 98 | } 99 | } 100 | ) 101 | // BurpExtender.stdout.println(String.format("临时文件夹[ %s ]已删除", temp)) 102 | } catch (ignored: IOException) { 103 | } 104 | } 105 | 106 | @Throws(Throwable::class) 107 | protected fun finalize() { 108 | destroy() 109 | } 110 | 111 | 112 | } 113 | -------------------------------------------------------------------------------- /src/main/java/net/ankio/icrypto/ui/MainGUI.jfd: -------------------------------------------------------------------------------- 1 | JFDML JFormDesigner: "8.1.1.0.298" Java: "17.0.8" encoding: "UTF-8" 2 | 3 | new FormModel { 4 | contentType: "form/swing" 5 | root: new FormRoot { 6 | add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class java.awt.BorderLayout ) ) { 7 | name: "panel1" 8 | add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class org.jdesktop.layout.GroupLayout ) { 9 | "$horizontalGroup": "par l {seq l {space :::p, comp autoRun:::p:800:p, space :::x}}" 10 | "$verticalGroup": "par l {seq l {comp autoRun:::p:36:p, space :0:0:x}}" 11 | } ) { 12 | name: "panel7" 13 | "border": new javax.swing.border.TitledBorder( "插件配置" ) 14 | add( new FormComponent( "javax.swing.JCheckBox" ) { 15 | name: "autoRun" 16 | "text": "自动执行脚本" 17 | addEvent( new FormEvent( "javax.swing.event.ChangeListener", "stateChanged", "autoRunStateChanged", true ) ) 18 | } ) 19 | }, new FormLayoutConstraints( class java.lang.String ) { 20 | "value": "North" 21 | } ) 22 | add( new FormContainer( "javax.swing.JSplitPane", new FormLayoutManager( class javax.swing.JSplitPane ) ) { 23 | name: "splitPane1" 24 | "dividerLocation": 200 25 | add( new FormComponent( "javax.swing.JList" ) { 26 | name: "watchList" 27 | "maximumSize": new java.awt.Dimension( 200, 62 ) 28 | "fixedCellWidth": 200 29 | "border": new javax.swing.border.LineBorder( sfield java.awt.Color black, 1, false ) 30 | "selectionMode": 0 31 | auxiliary() { 32 | "JavaCodeGenerator.typeParameters": "String" 33 | } 34 | addEvent( new FormEvent( "javax.swing.event.ListSelectionListener", "valueChanged", "watchListValueChanged", true ) ) 35 | }, new FormLayoutConstraints( class java.lang.String ) { 36 | "value": "left" 37 | } ) 38 | add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class org.jdesktop.layout.GroupLayout ) { 39 | "$horizontalGroup": "par l {seq l {space :::p, comp watchDel:::p::p, space s:::p, comp watchSave:::p::p, space ::627:x}, seq {par l {comp panel4:::::x, comp panel3::l:::x}, space :::p}}" 40 | "$verticalGroup": "par l {seq {comp panel4:::p::p, space s:::p, comp panel3:::p:74:p, space s:::p, par b {comp watchDel::b:p::p, comp watchSave::b:::x}, space ::171:x}}" 41 | } ) { 42 | name: "panel2" 43 | "border": new javax.swing.border.EmptyBorder( 20, 20, 20, 20 ) 44 | add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class org.jdesktop.layout.GroupLayout ) { 45 | "$horizontalGroup": "par l {seq {space :p:11:p, comp label2:::p::p, space u:::p, comp watchUrlInclude::::699:x, space :::p}}" 46 | "$verticalGroup": "par l {seq t {space :::x, par b {comp label2::b:p::p, comp watchUrlInclude::b:p::p}, space :p:128:p}}" 47 | } ) { 48 | name: "panel3" 49 | "border": new javax.swing.border.TitledBorder( "监控参数(自动执行脚本需要配置)" ) 50 | add( new FormComponent( "javax.swing.JTextField" ) { 51 | name: "watchUrlInclude" 52 | } ) 53 | add( new FormComponent( "javax.swing.JLabel" ) { 54 | name: "label2" 55 | "text": "URL包含" 56 | } ) 57 | } ) 58 | add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class org.jdesktop.layout.GroupLayout ) { 59 | "$horizontalGroup": "par l {seq l {space :::p, par l {seq l {comp label8:::p::p, space :::p, comp watchCustom::::553:x}, seq l {comp label7:::p::p, space :::p, comp watchName:::::x}}, space :::p}}" 60 | "$verticalGroup": "par l {seq {space :p:8:p, par b {comp label7::b:p::p, comp watchName::b:p::p}, space u:::p, par b {comp label8::b:p::p, comp watchCustom::b:p::p}, space :0:0:x}}" 61 | } ) { 62 | name: "panel4" 63 | "border": new javax.swing.border.TitledBorder( "脚本配置" ) 64 | add( new FormComponent( "javax.swing.JTextField" ) { 65 | name: "watchCustom" 66 | } ) 67 | add( new FormComponent( "javax.swing.JLabel" ) { 68 | name: "label8" 69 | "text": "执行命令(可执行程序完整路径):" 70 | } ) 71 | add( new FormComponent( "javax.swing.JLabel" ) { 72 | name: "label7" 73 | "text": "配置名称:" 74 | } ) 75 | add( new FormComponent( "javax.swing.JTextField" ) { 76 | name: "watchName" 77 | } ) 78 | } ) 79 | add( new FormComponent( "javax.swing.JButton" ) { 80 | name: "watchSave" 81 | "text": "保存" 82 | addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "watchSave", true ) ) 83 | } ) 84 | add( new FormComponent( "javax.swing.JButton" ) { 85 | name: "watchDel" 86 | "text": "删除" 87 | addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "watchDel", true ) ) 88 | } ) 89 | }, new FormLayoutConstraints( class java.lang.String ) { 90 | "value": "right" 91 | } ) 92 | }, new FormLayoutConstraints( class java.lang.String ) { 93 | "value": "Center" 94 | } ) 95 | add( new FormComponent( "javax.swing.JLabel" ) { 96 | name: "label1" 97 | "text": " 神说:要解密,于是就有了iCrypto。Powered by Ankio" 98 | }, new FormLayoutConstraints( class java.lang.String ) { 99 | "value": "South" 100 | } ) 101 | }, new FormLayoutConstraints( null ) { 102 | "location": new java.awt.Point( 0, 0 ) 103 | "size": new java.awt.Dimension( 1040, 505 ) 104 | } ) 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /src/main/kotlin/net/ankio/icrypto/registers/MessageEditorTab.kt: -------------------------------------------------------------------------------- 1 | package net.ankio.icrypto.registers 2 | 3 | import burp.IMessageEditorController 4 | import burp.IMessageEditorTab 5 | import burp.ITextEditor 6 | import net.ankio.icrypto.BurpExtender 7 | import net.ankio.icrypto.http.Cache 8 | import net.ankio.icrypto.http.HttpAgreementRequest 9 | import net.ankio.icrypto.http.HttpAgreementResponse 10 | import net.ankio.icrypto.rule.CommandType 11 | import net.ankio.icrypto.rule.Execution 12 | import net.ankio.icrypto.rule.Rule 13 | import java.awt.BorderLayout 14 | import java.awt.Component 15 | import java.awt.Dimension 16 | import java.awt.event.ActionEvent 17 | import java.awt.event.ActionListener 18 | import javax.swing.* 19 | import javax.swing.event.ListDataListener 20 | 21 | class MessageEditorTab internal constructor(iMessageEditorController: IMessageEditorController?, b: Boolean) : 22 | IMessageEditorTab { 23 | private var messageEditor: ITextEditor 24 | private var isRequest = false 25 | private var iMessageEditorController: IMessageEditorController? = null 26 | var httpAgreementRequest: HttpAgreementRequest? = null 27 | var httpAgreementResponse: HttpAgreementResponse? = null 28 | private fun selectItem(e: ActionEvent) { 29 | val rule: Rule = (selectBox.selectedItem as Rule) 30 | if (rule.command == "") { 31 | return 32 | } 33 | val cache = Cache() 34 | httpAgreementRequest = HttpAgreementRequest(iMessageEditorController?.request, cache) 35 | httpAgreementResponse = HttpAgreementResponse(iMessageEditorController?.response, cache) 36 | 37 | val commandType = when { 38 | rule.name.contains("(收到请求/响应)") -> { 39 | if (isRequest) CommandType.RequestFromClient else CommandType.ResponseFromServer 40 | } 41 | else -> { 42 | if (isRequest) CommandType.RequestToServer else CommandType.ResponseToClient 43 | } 44 | } 45 | 46 | if (Execution.run(rule.command, commandType, cache.temp)) { 47 | val message = if (isRequest) { 48 | httpAgreementRequest!!.toRequest(cache) 49 | } else { 50 | httpAgreementResponse!!.toResponse(cache) 51 | } 52 | setMessage(message, isRequest) 53 | } else { 54 | setMessage("加解密失败,详情请看日志".toByteArray(), isRequest) 55 | } 56 | } 57 | 58 | private val rootPanel: JSplitPane 59 | private val selectBox: JComboBox 60 | 61 | init { 62 | this.iMessageEditorController = iMessageEditorController 63 | messageEditor = BurpExtender.callbacks.createTextEditor() 64 | messageEditor.setEditable(b) 65 | val EditorComponent: Component = messageEditor.component 66 | rootPanel = JSplitPane() 67 | val panel1 = JPanel() 68 | val label1 = JLabel() 69 | selectBox = JComboBox() 70 | 71 | //======== splitPane1 ======== 72 | rootPanel.setOrientation(JSplitPane.VERTICAL_SPLIT) 73 | //======== panel1 ======== 74 | panel1.preferredSize = Dimension(0, 30) 75 | panel1.maximumSize = Dimension(2147483647, 30) 76 | panel1.setLayout(BorderLayout()) 77 | //---- label1 ---- 78 | label1.setText("\u8bf7\u9009\u62e9\u811a\u672c ") 79 | panel1.add(label1, BorderLayout.WEST) 80 | 81 | //---- comboBox1 ---- 82 | selectBox.addActionListener(ActionListener { e: ActionEvent -> selectItem(e) }) 83 | selectBox.preferredSize = Dimension(0, 30) 84 | panel1.add(selectBox, BorderLayout.CENTER) 85 | class Model : ComboBoxModel { 86 | private var arrayList: ArrayList = ArrayList() 87 | private var rule: Rule? = null 88 | init { 89 | arrayList = ArrayList() 90 | for (item in BurpExtender.config.list) { 91 | val newItem1 = item.copy() // 创建第一个副本 92 | newItem1.name += "(收到请求/响应)" 93 | arrayList.add(newItem1) 94 | 95 | val newItem2 = item.copy() // 创建第二个副本 96 | newItem2.name += "(发出请求/响应)" 97 | arrayList.add(newItem2) 98 | } 99 | } 100 | 101 | override fun getSize(): Int { 102 | return arrayList.size 103 | } 104 | 105 | override fun getElementAt(index: Int): Rule { 106 | return arrayList[index] 107 | } 108 | 109 | override fun addListDataListener(l: ListDataListener) {} 110 | override fun removeListDataListener(l: ListDataListener) {} 111 | override fun setSelectedItem(anItem: Any?) { 112 | rule = anItem as Rule 113 | } 114 | 115 | override fun getSelectedItem(): Rule? { 116 | return rule 117 | } 118 | } 119 | selectBox.setModel(Model()) 120 | rootPanel.topComponent = panel1 121 | rootPanel.bottomComponent = EditorComponent 122 | } 123 | 124 | 125 | override fun getTabCaption(): String { 126 | return BurpExtender.extensionName 127 | } 128 | 129 | override fun getUiComponent(): Component { 130 | return rootPanel 131 | } 132 | 133 | override fun isEnabled(bytes: ByteArray, b: Boolean): Boolean { 134 | return true 135 | } 136 | 137 | override fun setMessage(content: ByteArray, isRequest: Boolean) { 138 | this.isRequest = isRequest 139 | messageEditor.text = content 140 | } 141 | 142 | override fun getMessage(): ByteArray { 143 | return messageEditor.text 144 | } 145 | 146 | override fun isModified(): Boolean { 147 | return messageEditor.isTextModified 148 | } 149 | 150 | override fun getSelectedData(): ByteArray { 151 | return messageEditor.selectedText 152 | } 153 | 154 | } 155 | -------------------------------------------------------------------------------- /src/main/kotlin/net/ankio/icrypto/registers/HttpListener.kt: -------------------------------------------------------------------------------- 1 | package net.ankio.icrypto.registers 2 | 3 | import burp.IHttpListener 4 | import burp.IHttpRequestResponse 5 | import burp.IInterceptedProxyMessage 6 | import burp.IProxyListener 7 | import net.ankio.icrypto.BurpExtender 8 | import net.ankio.icrypto.http.Cache 9 | import net.ankio.icrypto.http.HttpAgreementRequest 10 | import net.ankio.icrypto.http.HttpAgreementResponse 11 | import net.ankio.icrypto.rule.CommandType 12 | import net.ankio.icrypto.rule.Execution 13 | import java.io.IOException 14 | import java.util.* 15 | 16 | 17 | class HttpListener internal constructor() : IHttpListener, IProxyListener { 18 | var httpAgreementRequest: HttpAgreementRequest? = null 19 | var httpAgreementResponse: HttpAgreementResponse? = null 20 | /** 21 | * 检查是否需要拦截 22 | * 23 | */ 24 | @Throws(IOException::class) 25 | private fun analyze( 26 | request: IHttpRequestResponse, 27 | messageIsRequest: Boolean, 28 | cmd: Array, 29 | cache: Cache? 30 | ): Boolean { 31 | if (!BurpExtender.config.auto) { 32 | return false 33 | } 34 | val url = request.httpService.protocol + "://" + request.httpService.host 35 | val rule = BurpExtender.config.find(url) ?: return false 36 | // 先查找脚本 37 | if (messageIsRequest) { 38 | httpAgreementRequest = HttpAgreementRequest(request.request, cache) 39 | } else { 40 | httpAgreementRequest = HttpAgreementRequest(request.request, cache) 41 | httpAgreementResponse = HttpAgreementResponse(request.response, cache) 42 | } 43 | 44 | BurpExtender.stdout.println(java.lang.String.format("脚本: %s 执行", rule.name)) 45 | if (rule.command == "") return false 46 | cmd[0] = rule.command // 将 rule.command 的值放入 cmd 数组 47 | return true 48 | } 49 | 50 | 51 | /** 52 | * 当即将发出HTTP请求以及收到HTTP响应时,会调用此方法。 53 | * 54 | * @param toolFlag 指示发出请求的Burp工具的flag。 55 | * Burp工具 flags 定义在 `IBurpExtenderCallbacks` 接口. 56 | * @param messageIsRequest 是否为请求。 57 | * @param messageInfo 要处理的请求/回复的详细信息。 扩展可以调用此对象上的setter方法来更新当前消息,从而修改Burp的行为。 58 | */ 59 | override fun processHttpMessage(toolFlag: Int, messageIsRequest: Boolean, messageInfo: IHttpRequestResponse) { 60 | val cmd = arrayOfNulls(1) 61 | //使用引用传递获取需要执行的命令 62 | //返回值标识是否需要拦截 63 | 64 | try { 65 | val cache = Cache() 66 | //不需要处理直接返回 67 | if (!analyze(messageInfo, messageIsRequest, cmd, cache)) { 68 | cache.destroy() 69 | return 70 | } 71 | BurpExtender.stdout.println("=================================================") 72 | if (messageIsRequest) { 73 | BurpExtender.stdout.println("======> 发送给服务端") 74 | cmd[0]?.let { requestOut(messageInfo, cache, it) } //发送请求 75 | } else { 76 | BurpExtender.stdout.println("======> 收到服务端") 77 | cmd[0]?.let { responseIn(messageInfo, cache, it) } //收到响应 78 | } 79 | } catch (e: IOException) { 80 | e.printStackTrace() 81 | BurpExtender.stderr.println("错误信息:" + e.message) 82 | } 83 | BurpExtender.stdout.println("=================================================") 84 | } 85 | 86 | /** 87 | * 当代理处理HTTP消息时,会调用此方法。 88 | * 89 | * @param messageIsRequest 是否为请求。 90 | * @param message 扩展可用于查询和更新消息的详细信息,并控制消息是否应拦截并显示给用户进行手动审查或修改。 91 | */ 92 | override fun processProxyMessage(messageIsRequest: Boolean, message: IInterceptedProxyMessage) { 93 | val cmd = arrayOfNulls(1) 94 | //使用引用传递获取需要执行的命令 95 | //返回值标识是否需要拦截\ 96 | try { 97 | val cache = Cache() 98 | if (!analyze(message.messageInfo, messageIsRequest, cmd, cache)) { 99 | cache.destroy() 100 | return 101 | } 102 | BurpExtender.stdout.println("=================================================") 103 | if (messageIsRequest) { 104 | BurpExtender.stdout.println("======> 发送给客户端") 105 | cmd[0]?.let { requestIn(message, cache, it) } //收到请求 106 | } else { 107 | BurpExtender.stdout.println("======> 收到客户端") 108 | cmd[0]?.let { responseOut(message, cache, it) } //发送响应 109 | } 110 | } catch (e: IOException) { 111 | e.printStackTrace() 112 | BurpExtender.stdout.println("错误信息:" + e.message) 113 | } 114 | BurpExtender.stdout.println("=================================================") 115 | } 116 | 117 | /** 118 | * requestIn阶段,收到客户端发送的加密request,进行解密并替换requestBody,使得BurpSuite中显示明文request; 119 | * 120 | */ 121 | private fun requestIn(message: IInterceptedProxyMessage, cache:Cache, cmd: String) { 122 | if (Execution.run(cmd, CommandType.RequestFromClient, cache.temp)) { 123 | message.messageInfo.request = httpAgreementRequest?.toRequest(cache) ?: byteArrayOf() 124 | } 125 | } 126 | 127 | //requestOut阶段,即将发送request到服务端,读取明文的request,重新进行加密(包括签名、编码、更新时间戳等),使得服务端正常解析; 128 | private fun requestOut(messageInfo: IHttpRequestResponse, cache:Cache, cmd: String) { 129 | if (Execution.run(cmd, CommandType.RequestToServer, cache.temp)) { 130 | messageInfo.request = httpAgreementRequest?.toRequest(cache) ?: byteArrayOf() 131 | } 132 | } 133 | 134 | //responseIn阶段,收到加密response,进行解密并替换responseBody,使得BurpSuite中显示明文response; 135 | private fun responseIn(messageInfo: IHttpRequestResponse, cache:Cache, cmd: String) { 136 | if (Execution.run(cmd, CommandType.ResponseFromServer, cache.temp)) { 137 | messageInfo.response = httpAgreementResponse?.toResponse(cache) ?: byteArrayOf() 138 | } 139 | } 140 | 141 | //responseOut阶段,即将发送response到客户端,读取明文的response,重新进行加密,使得客户端正常解析。 142 | private fun responseOut(message: IInterceptedProxyMessage, cache:Cache, cmd: String) { 143 | if (Execution.run(cmd, CommandType.ResponseToClient, cache.temp)) { 144 | message.messageInfo.response = httpAgreementResponse?.toResponse(cache) ?: byteArrayOf() 145 | } 146 | } 147 | } 148 | -------------------------------------------------------------------------------- /.idea/uiDesigner.xml: -------------------------------------------------------------------------------- 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 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # Copyright © 2015-2021 the original authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | # 21 | # Gradle start up script for POSIX generated by Gradle. 22 | # 23 | # Important for running: 24 | # 25 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is 26 | # noncompliant, but you have some other compliant shell such as ksh or 27 | # bash, then to run this script, type that shell name before the whole 28 | # command line, like: 29 | # 30 | # ksh Gradle 31 | # 32 | # Busybox and similar reduced shells will NOT work, because this script 33 | # requires all of these POSIX shell features: 34 | # * functions; 35 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}», 36 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»; 37 | # * compound commands having a testable exit status, especially «case»; 38 | # * various built-in commands including «command», «set», and «ulimit». 39 | # 40 | # Important for patching: 41 | # 42 | # (2) This script targets any POSIX shell, so it avoids extensions provided 43 | # by Bash, Ksh, etc; in particular arrays are avoided. 44 | # 45 | # The "traditional" practice of packing multiple parameters into a 46 | # space-separated string is a well documented source of bugs and security 47 | # problems, so this is (mostly) avoided, by progressively accumulating 48 | # options in "$@", and eventually passing that to Java. 49 | # 50 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, 51 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; 52 | # see the in-line comments for details. 53 | # 54 | # There are tweaks for specific operating systems such as AIX, CygWin, 55 | # Darwin, MinGW, and NonStop. 56 | # 57 | # (3) This script is generated from the Groovy template 58 | # https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt 59 | # within the Gradle project. 60 | # 61 | # You can find Gradle at https://github.com/gradle/gradle/. 62 | # 63 | ############################################################################## 64 | 65 | # Attempt to set APP_HOME 66 | 67 | # Resolve links: $0 may be a link 68 | app_path=$0 69 | 70 | # Need this for daisy-chained symlinks. 71 | while 72 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path 73 | [ -h "$app_path" ] 74 | do 75 | ls=$( ls -ld "$app_path" ) 76 | link=${ls#*' -> '} 77 | case $link in #( 78 | /*) app_path=$link ;; #( 79 | *) app_path=$APP_HOME$link ;; 80 | esac 81 | done 82 | 83 | # This is normally unused 84 | # shellcheck disable=SC2034 85 | APP_BASE_NAME=${0##*/} 86 | APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit 87 | 88 | # Use the maximum available, or set MAX_FD != -1 to use that value. 89 | MAX_FD=maximum 90 | 91 | warn () { 92 | echo "$*" 93 | } >&2 94 | 95 | die () { 96 | echo 97 | echo "$*" 98 | echo 99 | exit 1 100 | } >&2 101 | 102 | # OS specific support (must be 'true' or 'false'). 103 | cygwin=false 104 | msys=false 105 | darwin=false 106 | nonstop=false 107 | case "$( uname )" in #( 108 | CYGWIN* ) cygwin=true ;; #( 109 | Darwin* ) darwin=true ;; #( 110 | MSYS* | MINGW* ) msys=true ;; #( 111 | NONSTOP* ) nonstop=true ;; 112 | esac 113 | 114 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 115 | 116 | 117 | # Determine the Java command to use to start the JVM. 118 | if [ -n "$JAVA_HOME" ] ; then 119 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 120 | # IBM's JDK on AIX uses strange locations for the executables 121 | JAVACMD=$JAVA_HOME/jre/sh/java 122 | else 123 | JAVACMD=$JAVA_HOME/bin/java 124 | fi 125 | if [ ! -x "$JAVACMD" ] ; then 126 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 127 | 128 | Please set the JAVA_HOME variable in your environment to match the 129 | location of your Java installation." 130 | fi 131 | else 132 | JAVACMD=java 133 | if ! command -v java >/dev/null 2>&1 134 | then 135 | die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 136 | 137 | Please set the JAVA_HOME variable in your environment to match the 138 | location of your Java installation." 139 | fi 140 | fi 141 | 142 | # Increase the maximum file descriptors if we can. 143 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then 144 | case $MAX_FD in #( 145 | max*) 146 | # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. 147 | # shellcheck disable=SC3045 148 | MAX_FD=$( ulimit -H -n ) || 149 | warn "Could not query maximum file descriptor limit" 150 | esac 151 | case $MAX_FD in #( 152 | '' | soft) :;; #( 153 | *) 154 | # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. 155 | # shellcheck disable=SC3045 156 | ulimit -n "$MAX_FD" || 157 | warn "Could not set maximum file descriptor limit to $MAX_FD" 158 | esac 159 | fi 160 | 161 | # Collect all arguments for the java command, stacking in reverse order: 162 | # * args from the command line 163 | # * the main class name 164 | # * -classpath 165 | # * -D...appname settings 166 | # * --module-path (only if needed) 167 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. 168 | 169 | # For Cygwin or MSYS, switch paths to Windows format before running java 170 | if "$cygwin" || "$msys" ; then 171 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) 172 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) 173 | 174 | JAVACMD=$( cygpath --unix "$JAVACMD" ) 175 | 176 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 177 | for arg do 178 | if 179 | case $arg in #( 180 | -*) false ;; # don't mess with options #( 181 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath 182 | [ -e "$t" ] ;; #( 183 | *) false ;; 184 | esac 185 | then 186 | arg=$( cygpath --path --ignore --mixed "$arg" ) 187 | fi 188 | # Roll the args list around exactly as many times as the number of 189 | # args, so each arg winds up back in the position where it started, but 190 | # possibly modified. 191 | # 192 | # NB: a `for` loop captures its iteration list before it begins, so 193 | # changing the positional parameters here affects neither the number of 194 | # iterations, nor the values presented in `arg`. 195 | shift # remove old arg 196 | set -- "$@" "$arg" # push replacement arg 197 | done 198 | fi 199 | 200 | 201 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 202 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 203 | 204 | # Collect all arguments for the java command; 205 | # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of 206 | # shell script including quotes and variable substitutions, so put them in 207 | # double quotes to make sure that they get re-expanded; and 208 | # * put everything else in single quotes, so that it's not re-expanded. 209 | 210 | set -- \ 211 | "-Dorg.gradle.appname=$APP_BASE_NAME" \ 212 | -classpath "$CLASSPATH" \ 213 | org.gradle.wrapper.GradleWrapperMain \ 214 | "$@" 215 | 216 | # Stop when "xargs" is not available. 217 | if ! command -v xargs >/dev/null 2>&1 218 | then 219 | die "xargs is not available" 220 | fi 221 | 222 | # Use "xargs" to parse quoted args. 223 | # 224 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed. 225 | # 226 | # In Bash we could simply go: 227 | # 228 | # readarray ARGS < <( xargs -n1 <<<"$var" ) && 229 | # set -- "${ARGS[@]}" "$@" 230 | # 231 | # but POSIX shell has neither arrays nor command substitution, so instead we 232 | # post-process each arg (as a line of input to sed) to backslash-escape any 233 | # character that might be a shell metacharacter, then use eval to reverse 234 | # that process (while maintaining the separation between arguments), and wrap 235 | # the whole thing up as a single "set" statement. 236 | # 237 | # This will of course break if any of these variables contains a newline or 238 | # an unmatched quote. 239 | # 240 | 241 | eval "set -- $( 242 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | 243 | xargs -n1 | 244 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | 245 | tr '\n' ' ' 246 | )" '"$@"' 247 | 248 | exec "$JAVACMD" "$@" 249 | -------------------------------------------------------------------------------- /src/main/java/net/ankio/icrypto/ui/MainGUI.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Created by JFormDesigner on Mon Sep 19 12:24:48 CST 2022 3 | */ 4 | 5 | package net.ankio.icrypto.ui; 6 | 7 | 8 | 9 | import jdk.nashorn.internal.runtime.regexp.joni.Config; 10 | import net.ankio.icrypto.BurpExtender; 11 | import net.ankio.icrypto.rule.Rule; 12 | 13 | import javax.swing.*; 14 | import javax.swing.border.EmptyBorder; 15 | import javax.swing.border.LineBorder; 16 | import javax.swing.border.TitledBorder; 17 | import javax.swing.event.ChangeEvent; 18 | import javax.swing.event.ListSelectionEvent; 19 | import java.awt.*; 20 | import java.awt.event.ActionEvent; 21 | import java.util.ArrayList; 22 | 23 | 24 | /** 25 | * 插件的GUI实现 26 | * @author ankio 27 | */ 28 | public class MainGUI { 29 | 30 | /** 31 | * 构造函数 32 | */ public MainGUI() { 33 | //初始化UI 34 | initComponents(); 35 | //初始化数据 36 | initData(); 37 | } 38 | 39 | 40 | public void initData(){ 41 | //list填充 42 | autoRun.setSelected(BurpExtender.config.getAuto()); 43 | ArrayList arrayList = new ArrayList<>(); 44 | for (Rule rule :BurpExtender.config.getList()) { 45 | arrayList.add(rule.getName()); 46 | } 47 | watchList.setListData(arrayList.toArray(new String[0])); 48 | initTable(); 49 | 50 | } 51 | 52 | private void initTable(){ 53 | 54 | watchName.setText(""); 55 | watchCustom.setText(""); 56 | watchUrlInclude.setText(""); 57 | } 58 | 59 | private int select = -1; 60 | 61 | /** 62 | * 显示错误信息 63 | */ 64 | private void showMsg(String msg){ 65 | JOptionPane.showMessageDialog(null, msg, "错误", 66 | JOptionPane.ERROR_MESSAGE); 67 | } 68 | private void watchSave(ActionEvent e) { 69 | 70 | if(watchName.getText().isEmpty()){ 71 | showMsg("必须填写脚本名称"); 72 | return; 73 | } 74 | if(watchCustom.getText().isEmpty()){ 75 | showMsg("必须填写脚本执行命令"); 76 | return; 77 | } 78 | Rule rule = new Rule(watchName.getText(),watchUrlInclude.getText(),watchCustom.getText()); 79 | BurpExtender.config.add(rule); 80 | initData(); 81 | } 82 | 83 | private void watchDel(ActionEvent e) { 84 | if(select!=-1){ 85 | BurpExtender.config.del(select); 86 | select = -1; 87 | initData(); 88 | } 89 | } 90 | 91 | /** 92 | * 获取根View 93 | */ 94 | public JPanel getRoot(){ 95 | return panel1; 96 | } 97 | 98 | private void autoRunStateChanged(ChangeEvent e) { 99 | BurpExtender.config.setAuto(autoRun.isSelected()); 100 | } 101 | 102 | private void watchListValueChanged(ListSelectionEvent e) { 103 | select = watchList.getSelectedIndex(); 104 | if (select == -1) return; 105 | 106 | Rule rule = BurpExtender.config.getList().get(select); 107 | if(rule==null)return; 108 | initTable(); 109 | watchName.setText(rule.getName()); 110 | watchCustom.setText(rule.getCommand()); 111 | watchUrlInclude.setText(rule.getUrl()); 112 | } 113 | 114 | 115 | 116 | 117 | 118 | 119 | private void initComponents() { 120 | // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents 121 | panel1 = new JPanel(); 122 | panel7 = new JPanel(); 123 | autoRun = new JCheckBox(); 124 | splitPane1 = new JSplitPane(); 125 | watchList = new JList<>(); 126 | panel2 = new JPanel(); 127 | panel3 = new JPanel(); 128 | watchUrlInclude = new JTextField(); 129 | label2 = new JLabel(); 130 | panel4 = new JPanel(); 131 | watchCustom = new JTextField(); 132 | label8 = new JLabel(); 133 | label7 = new JLabel(); 134 | watchName = new JTextField(); 135 | watchSave = new JButton(); 136 | watchDel = new JButton(); 137 | label1 = new JLabel(); 138 | 139 | //======== panel1 ======== 140 | { 141 | panel1.setLayout(new BorderLayout()); 142 | 143 | //======== panel7 ======== 144 | { 145 | panel7.setBorder(new TitledBorder("\u63d2\u4ef6\u914d\u7f6e")); 146 | 147 | //---- autoRun ---- 148 | autoRun.setText("\u81ea\u52a8\u6267\u884c\u811a\u672c"); 149 | autoRun.addChangeListener(e -> autoRunStateChanged(e)); 150 | 151 | GroupLayout panel7Layout = new GroupLayout(panel7); 152 | panel7.setLayout(panel7Layout); 153 | panel7Layout.setHorizontalGroup( 154 | panel7Layout.createParallelGroup() 155 | .addGroup(panel7Layout.createSequentialGroup() 156 | .addContainerGap() 157 | .addComponent(autoRun, GroupLayout.PREFERRED_SIZE, 800, GroupLayout.PREFERRED_SIZE) 158 | .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 159 | ); 160 | panel7Layout.setVerticalGroup( 161 | panel7Layout.createParallelGroup() 162 | .addGroup(panel7Layout.createSequentialGroup() 163 | .addComponent(autoRun, GroupLayout.PREFERRED_SIZE, 36, GroupLayout.PREFERRED_SIZE) 164 | .addGap(0, 0, Short.MAX_VALUE)) 165 | ); 166 | } 167 | panel1.add(panel7, BorderLayout.NORTH); 168 | 169 | //======== splitPane1 ======== 170 | { 171 | splitPane1.setDividerLocation(200); 172 | 173 | //---- watchList ---- 174 | watchList.setMaximumSize(new Dimension(200, 62)); 175 | watchList.setFixedCellWidth(200); 176 | watchList.setBorder(LineBorder.createBlackLineBorder()); 177 | watchList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); 178 | watchList.addListSelectionListener(e -> watchListValueChanged(e)); 179 | splitPane1.setLeftComponent(watchList); 180 | 181 | //======== panel2 ======== 182 | { 183 | panel2.setBorder(new EmptyBorder(20, 20, 20, 20)); 184 | 185 | //======== panel3 ======== 186 | { 187 | panel3.setBorder(new TitledBorder("\u76d1\u63a7\u53c2\u6570\uff08\u81ea\u52a8\u6267\u884c\u811a\u672c\u9700\u8981\u914d\u7f6e\uff09")); 188 | 189 | //---- label2 ---- 190 | label2.setText("URL\u5305\u542b"); 191 | 192 | GroupLayout panel3Layout = new GroupLayout(panel3); 193 | panel3.setLayout(panel3Layout); 194 | panel3Layout.setHorizontalGroup( 195 | panel3Layout.createParallelGroup() 196 | .addGroup(panel3Layout.createSequentialGroup() 197 | .addGap(11, 11, 11) 198 | .addComponent(label2) 199 | .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) 200 | .addComponent(watchUrlInclude, GroupLayout.DEFAULT_SIZE, 699, Short.MAX_VALUE) 201 | .addContainerGap()) 202 | ); 203 | panel3Layout.setVerticalGroup( 204 | panel3Layout.createParallelGroup() 205 | .addGroup(GroupLayout.Alignment.TRAILING, panel3Layout.createSequentialGroup() 206 | .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 207 | .addGroup(panel3Layout.createParallelGroup(GroupLayout.Alignment.BASELINE) 208 | .addComponent(label2) 209 | .addComponent(watchUrlInclude, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) 210 | .addGap(128, 128, 128)) 211 | ); 212 | } 213 | 214 | //======== panel4 ======== 215 | { 216 | panel4.setBorder(new TitledBorder("\u811a\u672c\u914d\u7f6e")); 217 | 218 | //---- label8 ---- 219 | label8.setText("\u6267\u884c\u547d\u4ee4\uff08\u53ef\u6267\u884c\u7a0b\u5e8f\u5b8c\u6574\u8def\u5f84\uff09\uff1a"); 220 | 221 | //---- label7 ---- 222 | label7.setText("\u914d\u7f6e\u540d\u79f0\uff1a"); 223 | 224 | GroupLayout panel4Layout = new GroupLayout(panel4); 225 | panel4.setLayout(panel4Layout); 226 | panel4Layout.setHorizontalGroup( 227 | panel4Layout.createParallelGroup() 228 | .addGroup(panel4Layout.createSequentialGroup() 229 | .addContainerGap() 230 | .addGroup(panel4Layout.createParallelGroup() 231 | .addGroup(panel4Layout.createSequentialGroup() 232 | .addComponent(label8) 233 | .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) 234 | .addComponent(watchCustom, GroupLayout.DEFAULT_SIZE, 553, Short.MAX_VALUE)) 235 | .addGroup(panel4Layout.createSequentialGroup() 236 | .addComponent(label7) 237 | .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) 238 | .addComponent(watchName))) 239 | .addContainerGap()) 240 | ); 241 | panel4Layout.setVerticalGroup( 242 | panel4Layout.createParallelGroup() 243 | .addGroup(panel4Layout.createSequentialGroup() 244 | .addGap(8, 8, 8) 245 | .addGroup(panel4Layout.createParallelGroup(GroupLayout.Alignment.BASELINE) 246 | .addComponent(label7) 247 | .addComponent(watchName, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) 248 | .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) 249 | .addGroup(panel4Layout.createParallelGroup(GroupLayout.Alignment.BASELINE) 250 | .addComponent(label8) 251 | .addComponent(watchCustom, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) 252 | .addGap(0, 0, Short.MAX_VALUE)) 253 | ); 254 | } 255 | 256 | //---- watchSave ---- 257 | watchSave.setText("\u4fdd\u5b58"); 258 | watchSave.addActionListener(e -> watchSave(e)); 259 | 260 | //---- watchDel ---- 261 | watchDel.setText("\u5220\u9664"); 262 | watchDel.addActionListener(e -> watchDel(e)); 263 | 264 | GroupLayout panel2Layout = new GroupLayout(panel2); 265 | panel2.setLayout(panel2Layout); 266 | panel2Layout.setHorizontalGroup( 267 | panel2Layout.createParallelGroup() 268 | .addGroup(panel2Layout.createSequentialGroup() 269 | .addContainerGap() 270 | .addComponent(watchDel) 271 | .addGap(18, 18, 18) 272 | .addComponent(watchSave) 273 | .addContainerGap(627, Short.MAX_VALUE)) 274 | .addGroup(panel2Layout.createSequentialGroup() 275 | .addGroup(panel2Layout.createParallelGroup() 276 | .addComponent(panel4, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 277 | .addComponent(panel3, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 278 | .addContainerGap()) 279 | ); 280 | panel2Layout.setVerticalGroup( 281 | panel2Layout.createParallelGroup() 282 | .addGroup(panel2Layout.createSequentialGroup() 283 | .addComponent(panel4, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) 284 | .addGap(18, 18, 18) 285 | .addComponent(panel3, GroupLayout.PREFERRED_SIZE, 74, GroupLayout.PREFERRED_SIZE) 286 | .addGap(18, 18, 18) 287 | .addGroup(panel2Layout.createParallelGroup(GroupLayout.Alignment.BASELINE) 288 | .addComponent(watchDel) 289 | .addComponent(watchSave, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 290 | .addContainerGap(171, Short.MAX_VALUE)) 291 | ); 292 | } 293 | splitPane1.setRightComponent(panel2); 294 | } 295 | panel1.add(splitPane1, BorderLayout.CENTER); 296 | 297 | //---- label1 ---- 298 | label1.setText(" \u795e\u8bf4\uff1a\u8981\u89e3\u5bc6\uff0c\u4e8e\u662f\u5c31\u6709\u4e86iCrypto\u3002Powered by Ankio"); 299 | panel1.add(label1, BorderLayout.SOUTH); 300 | } 301 | // JFormDesigner - End of component initialization //GEN-END:initComponents 302 | } 303 | 304 | 305 | // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables 306 | private JPanel panel1; 307 | private JPanel panel7; 308 | private JCheckBox autoRun; 309 | private JSplitPane splitPane1; 310 | private JList watchList; 311 | private JPanel panel2; 312 | private JPanel panel3; 313 | private JTextField watchUrlInclude; 314 | private JLabel label2; 315 | private JPanel panel4; 316 | private JTextField watchCustom; 317 | private JLabel label8; 318 | private JLabel label7; 319 | private JTextField watchName; 320 | private JButton watchSave; 321 | private JButton watchDel; 322 | private JLabel label1; 323 | // JFormDesigner - End of variables declaration //GEN-END:variables 324 | } 325 | --------------------------------------------------------------------------------