Skip to content

Instantly share code, notes, and snippets.

@riverar
Last active July 9, 2019 09:55
Show Gist options
  • Save riverar/b9e0013e3ff6f1e34b2a2f62eaaf5cc1 to your computer and use it in GitHub Desktop.
Save riverar/b9e0013e3ff6f1e34b2a2f62eaaf5cc1 to your computer and use it in GitHub Desktop.
Frida agent, using Xamarin Mono APIs to access a static field and dump its value
import { MonoApiHelper, MonoApi } from 'frida-mono-api'
const domain = MonoApi.mono_get_root_domain()
// Get a handle to the SeeingAI.Core assembly
let coreAssembly = MonoApi.mono_assembly_load_with_partial_name(Memory.allocUtf8String("SeeingAI.Core"), NULL)
let coreImage = MonoApi.mono_assembly_get_image(coreAssembly)
// Retrieve class metadata
let helperClass = MonoApiHelper.ClassFromName(coreImage, "SeeingAI.Network.SignatureHelper")
// Retrieve field metadata and value
let secretField = MonoApiHelper.ClassGetFieldFromName(helperClass, "Secret")
let secretValue = MonoApiHelper.FieldGetValueObject(secretField, NULL, domain)
// Dump array to screen
var secretValueLength = MonoApi.mono_array_length(secretValue)
console.log(hexdump(MonoApi.mono_array_addr_with_size(secretValue, 1, 0), { length: secretValueLength }))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment