Commit 6110cf8f authored by Him188's avatar Him188

Remove `mirai-debug`

parent 9ea6b289
plugins {
id("application")
id("org.openjfx.javafxplugin") version "0.0.8"
kotlin("jvm")
java
id("kotlinx-serialization")
}
javafx {
version = "11"
modules = listOf("javafx.controls")
//mainClassName = "Application"
}
application {
mainClassName = "Application"
}
val kotlinVersion: String by rootProject.ext
val atomicFuVersion: String by rootProject.ext
val coroutinesVersion: String by rootProject.ext
val kotlinXIoVersion: String by rootProject.ext
val coroutinesIoVersion: String by rootProject.ext
val serializationVersion: String by rootProject.ext
val klockVersion: String by rootProject.ext
val ktorVersion: String by rootProject.ext
kotlin {
sourceSets {
all {
languageSettings.enableLanguageFeature("InlineClasses")
languageSettings.useExperimentalAnnotation("kotlin.Experimental")
}
}
}
fun kotlinx(id: String, version: String) = "org.jetbrains.kotlinx:kotlinx-$id:$version"
fun ktor(id: String, version: String) = "io.ktor:ktor-$id:$version"
dependencies {
runtimeOnly(files("../mirai-core/build/classes/kotlin/jvm/main")) // IDE bug
runtimeOnly(files("../mirai-core-qqandroid/build/classes/kotlin/jvm/main")) // IDE bug
implementation(project(":mirai-core-qqandroid"))
// runtimeOnly(files("../mirai-core/build/classes/kotlin/jvm/main")) // classpath is not added correctly by IDE
implementation("org.bouncycastle:bcprov-jdk15on:1.64")
implementation("org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion")
implementation("org.pcap4j:pcap4j-distribution:1.8.2")
implementation("no.tornado:tornadofx:1.7.17")
implementation(group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-javafx", version = "1.3.2")
implementation(kotlin("stdlib", kotlinVersion))
implementation("org.jetbrains.kotlinx:atomicfu:$atomicFuVersion")
implementation(kotlinx("io-jvm", kotlinXIoVersion))
implementation(kotlinx("io", kotlinXIoVersion))
implementation(kotlinx("coroutines-io", coroutinesIoVersion))
implementation(kotlinx("coroutines-core", coroutinesVersion))
implementation(kotlinx("serialization-runtime", serializationVersion))
implementation(ktor("http-cio", ktorVersion))
implementation(ktor("http", ktorVersion))
implementation(ktor("client-core-jvm", ktorVersion))
implementation(ktor("client-cio", ktorVersion))
implementation(ktor("client-core", ktorVersion))
implementation(ktor("network", ktorVersion))
testImplementation(kotlin("test-annotations-common"))
testImplementation(kotlin("test"))
testImplementation(kotlin("test-junit"))
testImplementation(kotlin("script-runtime"))
}
\ No newline at end of file
package japttest;
@SuppressWarnings("unused")
public class SuspendTest {
public static void main(String[] args) {
// TODO: 2019/12/6 Kotlin or IDE bug here
// Uncomment the following line.
// boolean bool = JaptTestKt.getLoginResult() == LoginResult.YOU_CAN_WRITE_ANY_THING;
System.out.println("Hello world");
}
}
/*
* Copyright 2020 Mamoe Technologies and contributors.
*
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
*
* https://github.com/mamoe/mirai/blob/master/LICENSE
*/
@file:Suppress("UNUSED_VARIABLE")
import net.mamoe.mirai.utils.io.encodeToString
import net.mamoe.mirai.utils.io.hexToBytes
import net.mamoe.mirai.utils.io.toUHexString
import java.io.ByteArrayInputStream
import java.io.ByteArrayOutputStream
import java.util.*
import java.util.zip.GZIPInputStream
fun main() {
val short: Short = 0x8b1f.toShort()
// 7字节相同| |18字节向东
val bytes =
"AA 02 56 30 01 3A 40 53 4B 4B 2F 6F 59 33 42 39 2F 68 56 54 45 4B 65 6A 5A 39 35 45 4D 7A 68 5A 2F 6F 4A 42 79 35 36 61 6F 50 59 32 6E 51 49 77 41 67 37 47 51 33 34 65 72 43 4C 41 72 50 4B 56 39 35 43 76 65 34 64 9A 01 0F 80 01 01 C8 01 00 F0 01 00 F8 01 00 90 02 00"
.hexToBytes()
println(bytes.encodeToString())
val string = bytes.encodeToString()
// println("53 4B 4B 2F 6F 59 33 42 39 2F 68 56 54 45 4B 65 6A 5A 39 35 45 4D 7A 68 5A 2F 6F 4A 42 79 35 36 61 6F 50 59 32 6E 51 49 77 41 67 37 47 51 33 34 65 72 43 4C 41 72 50 4B 56 39 35 43 76 65 34 64".hexToBytes().encodeToString())
println("53 4B 4B 2F 6F 59 33 42 39 2F 68 56 54 45 4B 65 6A 5A 39 35 45 4D 7A 68 5A 2F 6F 4A 42 79 35 36 61 6F 50 59 32 6E 51 49 77 41 67 37 47 51 33 34 65 72 43 4C 41 72 50 4B 56 39 35 43 76 65 34 64"
.hexToBytes().unbase64().encodeToString()
)
println("53 4B 4B 2F 6F 59 33 42 39 2F 68 56 54 45 4B 65 6A 5A 39 35 45 4D 7A 68 5A 2F 6F 4A 42 79 35 36 61 6F 50 59 32 6E 51 49 77 41 67 37 47 51 33 34 65 72 43 4C 41 72 50 4B 56 39 35 43 76 65 34 64"
.hexToBytes().unbase64().toUHexString())
//base64解密结果 48 A2 BF A1 8D C1 F7 F8 55 4C 42 9E 8D 9F 79 10 CC E1 67 FA 09 07 2E 7A 6A 83 D8 DA 74 08 C0 08 3B 19 0D F8 7A B0 8B 02 B3 CA 57 DE 42 BD EE 1D
println()
println()
println(Base64.getEncoder().encodeToString(".".repeat(1000).toByteArray()))
// 01 78
val data2 =
"9C CD 92 BB 4E C3 30 14 86 77 9E C2 32 23 4A 73 69 D3 76 48 52 25 25 BD 48 84 56 54 15 97 05 85 C4 09 2E B9 A8 4E D2 92 6E DD 10 0C 88 81 0D 84 90 60 40 42 C0 C4 D6 C7 69 E8 63 E0 94 22 46 46 F8 2D 59 F2 B1 7F 9F E3 EF 58 AA 9D FA 1E 18 21 12 E1 30 90 21 5F E0 20 40 81 15 DA 38 70 65 98 C4 0E 53 85 35 65 0D 50 49 7E E4 82 23 82 91 23 C3 C2 3F 17 04 FE A1 83 3D B4 6D FA 48 86 42 45 2F F3 82 58 64 CA A2 2E 32 25 AD 51 66 54 AD 21 32 AA AA AB 1C 5F 15 04 AE 5E F9 76 F4 F0 84 3A 28 05 D3 8A 97 48 46 18 8D 8D C4 8B B1 11 B9 10 38 9E 49 B9 14 21 88 10 19 61 0B B5 37 E9 4A CC CD 04 45 D8 96 E1 38 ED B7 BA 9D 81 53 2F A5 7B A1 A8 B1 29 6E 69 EE C4 68 75 DB FE 46 C7 76 3B 27 BA 67 F4 93 DD 83 DE 7E 33 16 06 CD B2 C6 0F 35 42 D8 52 63 C7 DE 1A 0E 86 1A 04 0A 90 70 8C 7C E0 99 69 98 C4 B4 27 90 46 62 1C 7B 48 01 7F CD F5 37 01 89 5D 55 0A A4 63 A2 48 2C 9D 56 C5 03 2B F4 42 22 C3 F5 2A 97 0F FA A8 EC EE F1 E3 E6 82 CF 6E EF 17 B3 E7 F9 E5 55 F6 7E 96 4D 5F C1 CF 1D 12 9B 83 50 A4 28 4C 88 85 40 B0 6C E6 62 7A 3E 7F 78 5A BC BC CD 67 D7 90 66 F8 DA CC 0F D3 FF A9 7C 02 73 51 C1 65".replace(
" ",
" "
)
.hexToBytes()
println(data2.size)
println(data2.unbase64().toUHexString())
}
fun ByteArray.unbase64() = Base64.getDecoder().decode(this)
fun ByteArray.ungzip(): ByteArray {
val out = ByteArrayOutputStream()
val `in` = ByteArrayInputStream(this)
val ungzip = GZIPInputStream(`in`)
val buffer = ByteArray(256)
var n: Int
while (ungzip.read(buffer).also { n = it } >= 0) {
out.write(buffer, 0, n)
}
return out.toByteArray()
}
\ No newline at end of file
/*
* Copyright 2020 Mamoe Technologies and contributors.
*
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
*
* https://github.com/mamoe/mirai/blob/master/LICENSE
*/
@file:Suppress("EXPERIMENTAL_API_USAGE")
import javafx.geometry.Pos
import javafx.scene.control.TextArea
import javafx.scene.control.TextField
import javafx.scene.layout.Region
import javafx.scene.paint.Color
import javafx.scene.text.FontWeight
import kotlinx.coroutines.*
import kotlinx.io.core.readUByte
import kotlinx.io.core.readUInt
import kotlinx.io.core.readUShort
import net.mamoe.mirai.utils.io.encodeToString
import net.mamoe.mirai.utils.io.hexToBytes
import net.mamoe.mirai.utils.io.read
import net.mamoe.mirai.utils.io.readUVarInt
import tornadofx.*
import java.awt.Toolkit
import java.awt.datatransfer.DataFlavor
/**
* How to run:
*
* `gradle :mirai-debug:run`
*/
class Application : App(HexDebuggerGui::class, Styles::class)
class Styles : Stylesheet() {
companion object {
// Define css classes
val heading by cssclass()
// Define colors
val mainColor = c("#bdbd22")
}
init {
heading {
textFill = mainColor
fontSize = 20.px
fontWeight = FontWeight.BOLD
}
button {
padding = box(vertical = 5.px, horizontal = 15.px)
fontWeight = FontWeight.BOLD
fontSize = 16.px
}
label {
padding = box(vertical = 5.px, horizontal = 15.px)
fontSize = 16.px
}
textField {
padding = box(vertical = 5.px, horizontal = 15.px)
}
textArea {
fontSize = 18.px
}
val flat = mixin {
backgroundInsets += box(0.px)
borderColor += box(Color.DARKGRAY)
}
s(button, textInput) {
+flat
}
}
}
class HexDebuggerGui : View("Mirai Hex Debugger") {
private lateinit var input: TextArea
private lateinit var outSize: TextField
private lateinit var outUVarInt: TextField
private lateinit var outShort: TextField
private lateinit var outUInt: TextField
private lateinit var outString: TextArea
private lateinit var outBits: TextField
private val clip = Toolkit.getDefaultToolkit().systemClipboard
private val clipboardContent: String?
get() {
val trans = clip.getContents(null)
if (trans?.isDataFlavorSupported(DataFlavor.stringFlavor) == true) {
return try {
trans.getTransferData(DataFlavor.stringFlavor) as String
} catch (e: Exception) {
e.printStackTrace()
null
}
}
return null
}
init {
GlobalScope.launch {
var last = clipboardContent
while (true) {
delay(100)
val current = try {
clipboardContent
} catch (e: Exception) {
e.printStackTrace()
null
}
try {
if (current != last) {
withContext(Dispatchers.Main) {
input.text = current
updateOutputs(
current?.lineSequence()
?.map { it.substringBefore("//") }
?.joinToString(" ")
.toString()
.replace("UVarInt", "", ignoreCase = true)
.replace("[", "")
.replace("]", "")
.replace("(", "")
.replace(")", "")
.replace(" ", " ")
.replace(" ", " ")
.replace(" ", " ")
.replace("_", "")
.replace(",", "")
.replace("`", "")
.replace("\"", "")
.replace("'", "")
.replace("*", "")
.replace("\\", "")
.replace("/", "")
.replace("-", "")
)
}
}
} finally {
last = current
}
}
}
}
private fun updateOutputs(value: String) {
outUVarInt.text = runOrNull {
value.hexToBytes().read {
readUVarInt().toString()
}
}
outShort.text = runOrNull {
value.hexToBytes().read {
readShort().toString()
}
}
outUInt.text = runOrNull {
value.hexToBytes().read {
readUInt().toString()
}
}
outSize.text = runOrNull {
value.hexToBytes().size.toString()
}
outBits.text = runOrNull {
value.hexToBytes().read {
when (remaining.toInt()) {
0 -> null
1 -> readUByte().toString(2)
2 -> readUShort().toString(2)
4 -> readUInt().toString(2)
else -> ""
}
}
}
outString.text = runOrNull {
value.hexToBytes().encodeToString()
}
}
override val root = hbox {
//prefWidth = 735.0
minHeight = 300.0
prefHeight = minHeight
input = textarea {
promptText = "Input"
paddingVertical = 10
prefWidth = 150.0
minWidth = 100.0
//maxWidth = 150.0
fitToHeight(this@hbox)
}
vbox(10) {
label(" => ") {
alignment = Pos.CENTER
spacing = 10.0
}
button("_") {
paddingAll = 0.0
setOnMouseClicked {
if (primaryStage.isAlwaysOnTop) {
primaryStage.isAlwaysOnTop = false
text = "_"
} else {
primaryStage.isAlwaysOnTop = true
text = "↑"
}
}
}
alignment = Pos.CENTER
fitToHeight(this@hbox)
}
vbox(10) {
paddingTop = 10
alignment = Pos.TOP_RIGHT
label("size")
label("UVarInt")
label("short")
label("uint")
label("bits")
label("string")
children.filterIsInstance<Region>().forEach {
it.fitToParentWidth()
}
}
vbox(20) {
alignment = Pos.CENTER_RIGHT
outSize = textfield {
promptText = "Size"
isEditable = false
}
outUVarInt = textfield {
promptText = "UVarInt"
isEditable = false
}
outShort = textfield {
promptText = "Short"
isEditable = false
}
outUInt = textfield {
promptText = "UInt"
isEditable = false
}
outBits = textfield {
promptText = "Bits"
isEditable = false
}
outString = textarea {
promptText = "String"
isEditable = false
maxWidth = 100.0
minHeight = 30.0
}
children.filterIsInstance<Region>().forEach {
it.fitToParentWidth()
}
}
input.textProperty().onChange {
if (it == null) {
return@onChange
}
updateOutputs(it)
}
}
}
private inline fun <T> runOrNull(block: () -> T?): T? {
return try {
block()
} catch (e: Exception) {
null
}
}
\ No newline at end of file
This diff is collapsed.
/*
* Copyright 2020 Mamoe Technologies and contributors.
*
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
*
* https://github.com/mamoe/mirai/blob/master/LICENSE
*/
package test
import kotlin.reflect.KProperty
data class Info(
var value: Int
) {
operator fun getValue(c: C, property: KProperty<*>): Int {
return value
}
}
class C(var info: Info) {
val value by info
}
fun main() {
val info = Info(1)
val c = C(info)
println(c.value) //1
info.value = 2
println(c.value) //2
c.info = Info(3)
println(c.value) //2
}
\ No newline at end of file
/*
* Copyright 2020 Mamoe Technologies and contributors.
*
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
*
* https://github.com/mamoe/mirai/blob/master/LICENSE
*/
package test
@Suppress("RedundantSuspendModifier")
suspend fun suspendPrintln(arg: String) = println(arg)
suspend fun main() {
suspendPrintln("Hello")
suspendPrintln(" World!")
}
\ No newline at end of file
package jce.jce;
import java.io.UnsupportedEncodingException;
public class HexUtil {
private static final char[] digits = new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
public static final byte[] emptybytes = new byte[0];
public static String byte2HexStr(byte var0) {
char var1 = digits[var0 & 15];
var0 = (byte) (var0 >>> 4);
return new String(new char[]{digits[var0 & 15], var1});
}
public static String bytes2HexStr(byte[] var0) {
if (var0 != null && var0.length != 0) {
char[] var3 = new char[var0.length * 2];
for (int var1 = 0; var1 < var0.length; ++var1) {
byte var2 = var0[var1];
var3[var1 * 2 + 1] = digits[var2 & 15];
var2 = (byte) (var2 >>> 4);
var3[var1 * 2 + 0] = digits[var2 & 15];
}
return new String(var3);
} else {
return null;
}
}
public static byte char2Byte(char var0) {
if (var0 >= '0' && var0 <= '9') {
return (byte) (var0 - 48);
} else if (var0 >= 'a' && var0 <= 'f') {
return (byte) (var0 - 97 + 10);
} else {
return var0 >= 'A' && var0 <= 'F' ? (byte) (var0 - 65 + 10) : 0;
}
}
public static byte hexStr2Byte(String var0) {
byte var2 = 0;
byte var1 = var2;
if (var0 != null) {
var1 = var2;
if (var0.length() == 1) {
var1 = char2Byte(var0.charAt(0));
}
}
return var1;
}
public static byte[] hexStr2Bytes(String var0) {
if (var0 != null && !var0.equals("")) {
byte[] var4 = new byte[var0.length() / 2];
for (int var3 = 0; var3 < var4.length; ++var3) {
char var1 = var0.charAt(var3 * 2);
char var2 = var0.charAt(var3 * 2 + 1);
var4[var3] = (byte) (char2Byte(var1) * 16 + char2Byte(var2));
}
return var4;
} else {
return emptybytes;
}
}
public static void main(String[] var0) {
try {
byte[] var2 = "Hello WebSocket World?".getBytes("gbk");
System.out.println(bytes2HexStr(var2));
} catch (UnsupportedEncodingException var1) {
var1.printStackTrace();
}
}
}
package jce.jce;
public class JceDecodeException extends RuntimeException {
public JceDecodeException(String var1) {
super(var1);
}
}
package jce.jce;
public class JceEncodeException extends RuntimeException {
public JceEncodeException(String var1) {
super(var1);
}
}
package jce.jce;
public class JceInputStream$HeadData {
public int tag;
public byte type;
public void clear() {
this.type = 0;
this.tag = 0;
}
}
This diff is collapsed.
This diff is collapsed.
package jce.jce;
import java.io.Serializable;
public abstract class JceStruct implements Serializable {
public static final byte BYTE = 0;
public static final byte DOUBLE = 5;
public static final byte FLOAT = 4;
public static final byte INT = 2;
public static final int JCE_MAX_STRING_LENGTH = 104857600;
public static final byte LIST = 9;
public static final byte LONG = 3;
public static final byte MAP = 8;
public static final byte SHORT = 1;
public static final byte SIMPLE_LIST = 13;
public static final byte STRING1 = 6;
public static final byte STRING4 = 7;
public static final byte STRUCT_BEGIN = 10;
public static final byte STRUCT_END = 11;
public static final byte ZERO_TAG = 12;
public static String toDisplaySimpleString(JceStruct var0) {
if (var0 == null) {
return null;
} else {
StringBuilder var1 = new StringBuilder();
var0.displaySimple(var1, 0);
return var1.toString();
}
}
public boolean containField(String var1) {
return false;
}
public void display(StringBuilder var1, int var2) {
}
public void displaySimple(StringBuilder var1, int var2) {
}
public Object getFieldByName(String var1) {
return null;
}
public JceStruct newInit() {
return null;
}
public abstract void readFrom(JceInputStream var1);
public void recyle() {
}
public void setFieldByName(String var1, Object var2) {
}
public byte[] toByteArray() {
JceOutputStream var1 = new JceOutputStream();
this.writeTo(var1);
return var1.toByteArray();
}
public byte[] toByteArray(String var1) {
JceOutputStream var2 = new JceOutputStream();
var2.setServerEncoding(var1);
this.writeTo(var2);
return var2.toByteArray();
}
public String toString() {
StringBuilder var1 = new StringBuilder();
this.display(var1, 0);
return var1.toString();
}
public abstract void writeTo(JceOutputStream var1);
}
This diff is collapsed.
package jce.jce;
import java.nio.ByteBuffer;
public interface OnIllegalArgumentException {
void onException(IllegalArgumentException var1, ByteBuffer var2, int var3, int var4);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment