-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add symbols.unredact config variable #144
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,8 @@ const config = { | |
'stalker.timeout': 5 * 60, | ||
'stalker.in': 'raw', | ||
'hook.backtrace': true, | ||
'hook.verbose': true | ||
'hook.verbose': true, | ||
'symbols.unredact': true | ||
}; | ||
|
||
const configHelp = { | ||
|
@@ -17,7 +18,8 @@ const configHelp = { | |
'stalker.timeout': configHelpStalkerTimeout, | ||
'stalker.in': configHelpStalkerIn, | ||
'hook.backtrace': configHelpHookBacktrace, | ||
'hook.verbose': configHelpHookVerbose | ||
'hook.verbose': configHelpHookVerbose, | ||
'symbols.unredact': configHelpSymbolsUnredact | ||
}; | ||
|
||
const configValidator = { | ||
|
@@ -26,7 +28,8 @@ const configValidator = { | |
'stalker.timeout': configValidateStalkerTimeout, | ||
'stalker.in': configValidateStalkerIn, | ||
'hook.backtrace': configValidateHookBacktrace, | ||
'hook.verbose': configValidateHookVerbose | ||
'hook.verbose': configValidateHookVerbose, | ||
'symbols.unredact': configValidateSymbolsUnredact | ||
}; | ||
|
||
function configHelpSearchIn () { | ||
|
@@ -112,6 +115,14 @@ function configHelpStalkerIn () { | |
`; | ||
} | ||
|
||
function configHelpSymbolsUnredact () { | ||
return `Try to get symbol names from debug symbols when they're "redacted": | ||
|
||
true try to unredact (the default) | ||
false do not attempt to unredact | ||
`; | ||
} | ||
|
||
function configValidateHookVerbose (val) { | ||
if (typeof (val) === 'boolean') { | ||
return true; | ||
|
@@ -127,6 +138,13 @@ function configValidateStalkerIn (val) { | |
return ['raw', 'app', 'modules'].indexOf(val) !== -1; | ||
} | ||
|
||
function configValidateSymbolsUnredact (val) { | ||
if (typeof (val) === 'boolean') { | ||
return true; | ||
} | ||
return ['true', 'false'].indexOf(val) !== -1; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what about |
||
} | ||
|
||
function isTrue (x) { | ||
return (x === true || x === 1 || x === 'true'); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,7 @@ const allocPool = {}; | |
const pendingCmds = {}; | ||
const pendingCmdSends = []; | ||
let sendingCommand = false; | ||
const insaneSet = new Set(['`', '$', '{', '}', '~', '|', ';', '#', '@', '&', '<', '>', ' ', '(', ')']); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. a single string is probably faster imho. const specialChars = "`${}~|;#...". and then use |
||
|
||
function numEval (expr) { | ||
return new Promise((resolve, reject) => { | ||
|
@@ -836,17 +837,41 @@ function listSymbols (args) { | |
|
||
function listSymbolsR2 (args) { | ||
return listSymbolsJson(args) | ||
.filter(({ address }) => !address.isNull()) | ||
.map(({ type, name, address }) => { | ||
return ['f', 'sym.' + type.substring(0, 3) + '.' + name, '=', address].join(' '); | ||
return ['f', 'sym.' + type.substring(0, 3) + '.' + sanitizeString(name), '=', address].join(' '); | ||
}) | ||
.join('\n'); | ||
} | ||
|
||
function sanitizeString (str) { | ||
const result = []; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what about using map/filter for this?
|
||
|
||
for (const c of str) { | ||
if (insaneSet.has(c)) { | ||
result.push('_'); | ||
} else { | ||
result.push(c); | ||
} | ||
} | ||
|
||
return result.join(''); | ||
} | ||
|
||
function listSymbolsJson (args) { | ||
const currentModule = (args.length > 0) | ||
? Process.getModuleByName(args[0]) | ||
: Process.getModuleByAddress(offset); | ||
return Module.enumerateSymbols(currentModule.name); | ||
const symbols = Module.enumerateSymbols(currentModule.name); | ||
return symbols.map(sym => { | ||
if (config.getBoolean('symbols.unredact') && sym.name.indexOf('redacted') !== -1) { | ||
const dbgSym = DebugSymbol.fromAddress(sym.address); | ||
if (dbgSym !== null) { | ||
sym.name = dbgSym.name; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. uhm, when we find the symbol we dont need to continue searching , right? maybe good to use a for loop to break it here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we're not searching here, it's just iterating over all the results of |
||
} | ||
} | ||
return sym; | ||
}); | ||
} | ||
|
||
function lookupDebugInfo (args) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be set to false outside iOS (and maybe macOS) too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ohh ok