FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
jeb-samplecode/scripts/ReplaceStringsInJavaAST.py at master · pnfsoftware/jeb-samplecode · GitHub
pnfsoftware
jeb-samplecode
Repository navigation
Code
Pull requests
3
(3)
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
jeb-samplecode
/
scripts
/
ReplaceStringsInJavaAST.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
36 lines (29 loc) · 1.15 KB
Breadcrumbs
jeb-samplecode
/
scripts
/
ReplaceStringsInJavaAST.py
Copy path
File metadata and controls
36 lines (29 loc) · 1.15 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#?description=Find the first decompiled Java unit and replace String immediates by random string
#?shortcut=
import
time
from
com
.
pnfsoftware
.
jeb
.
client
.
api
import
IScript
from
com
.
pnfsoftware
.
jeb
.
core
.
units
.
code
.
java
import
IJavaSourceUnit
,
IJavaClass
,
IJavaConstant
"""
Sample script for JEB Decompiler.
"""
class
ReplaceStringsInJavaAST
(
IScript
):
def
run
(
self
,
ctx
):
prj
=
ctx
.
getMainProject
()
assert
prj
,
'Need a project'
src
=
prj
.
findUnit
(
IJavaSourceUnit
)
assert
src
,
'Need a java source unit (decompiled)'
print
(
'Processing %s'
%
src
)
elt
=
src
.
getASTElement
()
if
not
isinstance
(
elt
,
IJavaClass
):
return
self
.
replcnt
=
0
self
.
cstbuilder
=
src
.
getDecompiler
().
getHighLevelContext
().
getConstantFactory
()
for
m
in
elt
.
getMethods
():
self
.
checkElement
(
None
,
m
)
print
(
'Replaced %d strings'
%
self
.
replcnt
)
src
.
notifyGenericChange
()
def
checkElement
(
self
,
parent
,
e
):
if
isinstance
(
e
,
IJavaConstant
)
and
e
.
isString
():
parent
.
replaceSubElement
(
e
,
self
.
cstbuilder
.
createString
(
'blah_'
+
str
(
time
.
time
())))
self
.
replcnt
+=
1
for
subelt
in
e
.
getSubElements
():
self
.
checkElement
(
e
,
subelt
)
Back
|
FazBrowse Home
|
New Git URL