Last active
September 12, 2022 22:52
-
-
Save Armatix/e4d4e12ceec38448466a09f569cbb7a2 to your computer and use it in GitHub Desktop.
Frida http post request from java/android
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function javaPost(url, data) { | |
const thread = Java.use("java.lang.Thread").$new(); | |
const Tjava = Java.ClassFactory.get(thread.getContextClassLoader()); | |
const Url = Tjava.use("java.net.URL").$new(url); | |
let connection = Url.openConnection(); | |
connection = Java.cast(connection, Tjava.use("java.net.HttpURLConnection")); | |
connection.setRequestMethod("POST"); | |
connection.setDoOutput(true); | |
connection.setRequestProperty("Content-Type", "application/json;"); | |
const postData = Tjava.use("java.lang.String").$new(data); | |
connection.getOutputStream().write(postData.getBytes()); | |
const stream = connection.getInputStream(); | |
const utf8 = Tjava.use("java.nio.charset.StandardCharsets").UTF_8.value; | |
const isreader = Tjava.use("java.io.InputStreamReader").$new(stream, utf8); | |
const bufReader = Tjava.use("java.io.BufferedReader").$new(isreader); | |
const res = bufReader.lines().collect(Tjava.use("java.util.stream.Collectors").joining(Tjava.use("java.lang.String").$new("\n"))); | |
return res; | |
} | |
console.log(javaPost("http://example.com", "hi")); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment