@@ -42,6 +42,17 @@ def _should_return_as_string(args) -> bool:
42
42
return len (args ) > 0 and '--return-string' in args
43
43
44
44
45
+ def _should_interpret_inline_js (args ) -> bool :
46
+ """
47
+ Check if we have the --inline flag
48
+
49
+ :param args:
50
+ :return:
51
+ """
52
+
53
+ return len (args ) > 0 and '--inline' in args
54
+
55
+
45
56
def instances (args : list ) -> None :
46
57
"""
47
58
Asks the agent to print the currently live instances of a particular class
@@ -173,19 +184,30 @@ def evaluate(args: list) -> None:
173
184
"""
174
185
175
186
if len (args ) < 1 :
176
- click .secho ('Usage: ios heap execute js <pointer> (eg: 0x600001130660)' , bold = True )
187
+ click .secho ('Usage: ios heap execute js <pointer> (eg: 0x600001130660) ' +
188
+ '(optional: --inline) (optional: <JavaScript source>)' , bold = True )
177
189
return
178
190
179
191
target_pointer = args [0 ]
180
192
181
- js = prompt (
182
- click .secho ('(The pointer at `{pointer}` will be available as the `ptr` variable.)n' .format (
183
- pointer = target_pointer
184
- ), dim = True ),
185
- multiline = True , lexer = PygmentsLexer (JavascriptLexer ),
186
- bottom_toolbar = 'JavaScript edit mode. [ESC] and then [ENTER] to accept. [CTRL] + C to cancel.' ).strip ()
193
+ # adding the --inline flag would trigger reading the line contents
194
+ # as JavaScript sources
195
+ if _should_interpret_inline_js (args ):
196
+ args .remove ('--inline' )
197
+ js = '' .join (args [1 :])
198
+
199
+ click .secho ('Reading inline JavaScript for evaluation...' , dim = True )
200
+ click .secho ('{}\n ' .format (js ), fg = 'green' , dim = True )
201
+
202
+ else :
203
+ js = prompt (
204
+ click .secho ('(The pointer at `{pointer}` will be available as the `ptr` variable.)n' .format (
205
+ pointer = target_pointer
206
+ ), dim = True ),
207
+ multiline = True , lexer = PygmentsLexer (JavascriptLexer ),
208
+ bottom_toolbar = 'JavaScript edit mode. [ESC] and then [ENTER] to accept. [CTRL] + C to cancel.' ).strip ()
187
209
188
- click .secho ('JavaScript capture complete. Evaluating...' , dim = True )
210
+ click .secho ('JavaScript capture complete. Evaluating...' , dim = True )
189
211
190
212
api = state_connection .get_api ()
191
213
api .ios_heap_evaluate_js (target_pointer , js )
0 commit comments