Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 9 additions & 13 deletions app/src/main/java/moe/ono/creator/GetChannelArkDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import com.lxj.xpopup.core.BottomPopupView;
import com.lxj.xpopup.util.XPopupUtils;

import org.json.JSONException;
import org.json.JSONObject;

import java.io.IOException;
Expand All @@ -38,6 +37,7 @@
import moe.ono.hooks.item.developer.GetCookie;
import moe.ono.ui.CommonContextWrapper;
import moe.ono.util.AppRuntimeHelper;
import moe.ono.util.ContextUtils;
import moe.ono.util.Logger;
import moe.ono.util.Session;
import moe.ono.util.SyncUtils;
Expand Down Expand Up @@ -154,24 +154,20 @@ public void onResponse(@NonNull Call call, @NonNull Response response) {
String result = response.body().string();

SyncUtils.runOnUiThread(() -> {
JSONObject json = null;
try {
json = new JSONObject(result);
} catch (JSONException e) {
Toasts.error(v.getContext(), "JSON 解析失败");
}
assert json != null;
String base64 = Objects.requireNonNull(json.optJSONObject("data")).optString("signed_ark");
byte[] decodedBytes = Base64.getDecoder().decode(base64);
String ark = new String(decodedBytes);
try {
JSONObject json = new JSONObject(result);
String base64 = Objects.requireNonNull(json.optJSONObject("data")).optString("signed_ark");
byte[] decodedBytes = Base64.getDecoder().decode(base64);
String ark = new String(decodedBytes);
PacketHelperDialog.send_ark_msg(ark, Session.getContact());
} catch (JSONException e) {
Toasts.error(v.getContext(), "发送失败");
} catch (Exception e) {
Logger.e(e);
Toasts.error(ContextUtils.getCurrentActivity(), "发生错误, 请检查参数是否完整");
}
});
} catch (Exception e) {
Logger.e(e);
Toasts.error(ContextUtils.getCurrentActivity(), "发生错误, 请检查参数是否完整");
}
}
});
Expand Down
22 changes: 22 additions & 0 deletions app/src/main/java/moe/ono/creator/PacketHelperDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,15 @@
import moe.ono.R;
import moe.ono.bridge.Nt_kernel_bridge;
import moe.ono.bridge.kernelcompat.ContactCompat;
import moe.ono.hooks.base.api.QQMsgRespHandler;
import moe.ono.hooks.protocol.QPacketHelperKt;
import moe.ono.hooks.base.util.Toasts;
import moe.ono.util.AppRuntimeHelper;
import moe.ono.ui.CommonContextWrapper;
import moe.ono.util.Logger;
import moe.ono.util.SafUtils;
import moe.ono.util.SyncUtils;
import moe.ono.util.Utils;

@SuppressLint({"ResourceType", "StaticFieldLeak"})
public class PacketHelperDialog extends BottomPopupView {
Expand Down Expand Up @@ -260,6 +262,11 @@ protected void onCreate() {
mRgSendBy.setVisibility(GONE);
forwardConfig.setVisibility(GONE);
break;
case "xml":
editText.setHint("Xml...");
mRgSendBy.setVisibility(GONE);
forwardConfig.setVisibility(GONE);
break;
case "text":
editText.setHint("纯文本...");
mRgSendBy.setVisibility(GONE);
Expand Down Expand Up @@ -300,6 +307,21 @@ protected void onCreate() {
} else if (send_type.equals("text")){
send_text_msg(text, contactCompat);
return;
} else if (send_type.equals("xml")) {
try {
String hex = Utils.bytesToHex(QQMsgRespHandler.Companion.compressData(text));
String pb = "{\n" +
" \"12\": {\n" +
" \"1\": \"hex->"+hex+"\",\n" +
" \"2\": 35\n" +
" }\n" +
"}";
setContentForLongmsg(pb);
} catch (Exception e) {
Toasts.error(getContext(), "发生错误");
Logger.e(e);
}
return;
}

// protobuf
Expand Down
41 changes: 20 additions & 21 deletions app/src/main/java/moe/ono/hooks/base/api/QQMsgRespHandler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import com.tencent.qqnt.kernel.nativeinterface.PushExtraInfo
import de.robv.android.xposed.XposedHelpers.callMethod
import kotlinx.io.core.ByteReadPacket
import kotlinx.io.core.readBytes
import kotlinx.serialization.json.*
import moe.ono.R
import moe.ono.bridge.ntapi.RelationNTUinAndUidApi.getUinFromUid
import moe.ono.common.CheckUtils
Expand Down Expand Up @@ -46,8 +45,6 @@ import org.json.JSONObject
import java.io.ByteArrayOutputStream
import java.util.UUID
import java.util.zip.Deflater
import kotlin.random.Random
import kotlin.random.nextUInt

@HookItem(path = "API/QQMsgRespHandler")
class QQMsgRespHandler : ApiHookItem() {
Expand Down Expand Up @@ -445,25 +442,27 @@ class QQMsgRespHandler : ApiHookItem() {

}

private fun compressData(data: String): ByteArray {
val inputBytes = data.toByteArray(Charsets.UTF_8)
val deflater = Deflater(Deflater.DEFAULT_COMPRESSION, false)
deflater.setInput(inputBytes)
deflater.finish()

val outputStream = ByteArrayOutputStream()
val buffer = ByteArray(1024)
while (!deflater.finished()) {
val count = deflater.deflate(buffer)
outputStream.write(buffer, 0, count)
}
deflater.end()
val compressedBytes = outputStream.toByteArray()
val result = ByteArray(compressedBytes.size + 1)
result[0] = 0x01
System.arraycopy(compressedBytes, 0, result, 1, compressedBytes.size)
companion object {
fun compressData(data: String): ByteArray {
val inputBytes = data.toByteArray(Charsets.UTF_8)
val deflater = Deflater(Deflater.DEFAULT_COMPRESSION, false)
deflater.setInput(inputBytes)
deflater.finish()

val outputStream = ByteArrayOutputStream()
val buffer = ByteArray(1024)
while (!deflater.finished()) {
val count = deflater.deflate(buffer)
outputStream.write(buffer, 0, count)
}
deflater.end()
val compressedBytes = outputStream.toByteArray()
val result = ByteArray(compressedBytes.size + 1)
result[0] = 0x01
System.arraycopy(compressedBytes, 0, result, 1, compressedBytes.size)

return result
return result
}
}

fun appendToContentArray(original: JSONObject, newContent: Any) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ package moe.ono.hooks.item.profile
import OidbSvcTrpcTcp0Xfe12
import android.annotation.SuppressLint
import android.app.Activity
import android.content.ClipData
import android.content.ClipboardManager
import android.content.Context
import android.os.Bundle
import android.os.Handler
import android.os.Looper
Expand All @@ -20,7 +17,6 @@ import io.noties.markwon.Markwon
import moe.ono.hooks._base.BaseSwitchFunctionHookItem
import moe.ono.hooks._core.annotation.HookItem
import moe.ono.hooks.base.util.Toasts
import moe.ono.hooks.base.util.Toasts.TYPE_INFO
import moe.ono.service.QQInterfaces.Companion.receive
import moe.ono.service.QQInterfaces.Companion.sendOidbSvcTrpcTcp
import moe.ono.ui.CommonContextWrapper
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/res/layout/element_sender_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@
android:textSize="15sp"
/>

<RadioButton
android:id="@+id/rb_xml"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="xml"
android:textSize="15sp"
/>

<RadioButton
android:id="@+id/rb_text"
android:layout_width="wrap_content"
Expand Down