Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@riverar
Created July 26, 2015 09:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save riverar/5b58f93509a32ead8023 to your computer and use it in GitHub Desktop.
Save riverar/5b58f93509a32ead8023 to your computer and use it in GitHub Desktop.
My first Frida script to fix up Skype's ShellExecuteExW usage
var g_openVerbString = Memory.allocUtf16String("open");
var fn = Module.findExportByName("shell32.dll", "ShellExecuteExW");
Interceptor.attach(fn, {
onEnter: function(args) {
// Right now, SHELLEXECUTEINFO presumably looks like:
// ...
// lpVerb = nullptr
// lpFile = RUNDLL32.EXE
// lpParamaters = Shell32.dll,OpenAs_RunDLL [path to image]
// lpDirectory = nullptr
// ...
var verbPtr = args[0].add(12);
var filePtr = args[0].add(16);
var paramsPtr = args[0].add(20);
// Only fix up if we're dealing with funky OpenAs calls
var params = Memory.readPointer(paramsPtr);
if(!params.isNull() && Memory.readUtf16String(params).indexOf("OpenAs_RunDLL") > -1) {
// Add "open" verb
Memory.writePointer(verbPtr, g_openVerbString);
// Replace filePtr with image path sans OpenAs_RunDll mess
Memory.writePointer(filePtr, params.add(52));
// Null out paramsPtr
Memory.writeUInt(paramsPtr, 0);
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment