Ludwig Advanced Cheater Reputation: 0
Joined: 10 Jan 2016 Posts: 68
|
Posted: Tue Apr 25, 2017 12:40 pm Post subject: searching and replacing strings with magic characters in fil |
|
|
Good day...
ive got a minor issue in a de-obfuscating//renaming script im working on...
basically, it takes the As bytecode..reads the files into arrays..then searches the files<arrays> which is in memory for certain strings to be replaced
example of a file array with some line arrays..<each line a seperate array>
Code: | cinit
refid "-_--------_-_-/class/init"
body
maxstack 4
localcount 1
initscopedepth 3
maxscopedepth 4
code
getlocal0
pushscope
findproperty QName(PrivateNamespace("*", "-_--------_-_-/class"), "_giftsAccepted")
newarray 0
setproperty QName(PrivateNamespace("*", "-_--------_-_-/class"), "_giftsAccepted")
findproperty QName(PrivateNamespace("*", "-_--------_-_-/class"), "---_-_-___--_")
pushbyte 255
setproperty QName(PrivateNamespace("*", "-_--------_-_-/class"), "---_-_-___--_")
findproperty QName(PrivateNamespace("*", "-_--------_-_-/class"), "-__-_-_-___-__")
pushnull
setproperty QName(PrivateNamespace("*", "-_--------_-_-/class"), "-__-_-_-___-__")
findproperty QName(PrivateNamespace("*", "-_--------_-_-/class"), "_enterFrameResource")
findpropstrict QName(PackageNamespace(""), "xxxdb62fe1f6f224638b6024282874b1661")
getlex QName(PrivateNamespace("*", "-_--------_-_-/class"), "-_-_---__--__--")
getlex QName(PackageNamespace(""), "xxxf45bdca742ea4188a74161fa94ccf864")
getproperty QName(PackageNamespace(""), "----_--___----")
constructprop QName(PackageNamespace(""), "xxxdb62fe1f6f224638b6024282874b1661"), 2
setproperty QName(PrivateNamespace("*", "-_--------_-_-/class"), "_enterFrameResource")
returnvoid
end ; code
end ; body
|
now...search strings examples:
"_enterFrameResource"
"xxxf45bdca742ea4188a74161fa94ccf864"
"-__-_-_-___-__"
which i usaly use newstring=gsub(linearray, search, replace)
works great for most of the strings, but the moment it contains magic characters like "-__-_-_-___-__" it can give me strange replaces...
example:
a:5 of:6338 aa:11 of searches:2268 "------_---_--_" searchin: "-_-____--_-_-_-" replacing: "xxx6873d62edc8546d3b2bdf395b7498800"
original
getproperty QName(PackageNamespace(""), "-_--_-______-")
new
getproperty QName(PackageNamespace(""), "-_--_-"xxx6873d62edc8546d3b2bdf395b7498800")
it found the wrong search string..because of the"-" characters in the search and replace strings, and then did an incorrect replace...
i understand i have to use % as escape..but how to implement it in different length line array string, search strings, and replace strings?
regards
ludwig
--edit--
fixed..by using the c, d = string.find(file_array_b_rab[at][rr],read,1,true)
command, it searches the string in plain format, and returns start and end position of found string,,then by using string.sub, it can be replased
|
|