Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


searching and replacing strings with magic characters in fil

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Ludwig
Advanced Cheater
Reputation: 0

Joined: 10 Jan 2016
Posts: 68

PostPosted: Tue Apr 25, 2017 12:40 pm    Post subject: searching and replacing strings with magic characters in fil Reply with quote

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
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites