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 


Encode Decode Problem

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Tue Jul 05, 2016 9:17 am    Post subject: Encode Decode Problem Reply with quote

Hi There,

From old topic in this forum, one of decode function as below :

Code:

local b='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'

function bec(data)
    return ((data:gsub('.', function(x)
        local r,b='',x:byte()
        for i=8,1,-1 do r=r..(b%2^i-b%2^(i-1)>0 and '1' or '0') end
        return r;
    end)..'0000'):gsub('%d%d%d?%d?%d?%d?', function(x)
        if (#x < 6) then return '' end
        local c=0
        for i=1,6 do c=c+(x:sub(i,i)=='1' and 2^(6-i) or 0) end
        return b:sub(c+1,c+1)
    end)..({ '', '==', '=' })[#data%3+1])
end

function bdc(data)
    data = string.gsub(data, '[^'..b..'=]', '')
    return (data:gsub('.', function(x)
        if (x == '=') then return '' end
        local r,f='',(b:find(x)-1)
        for i=6,1,-1 do r=r..(f%2^i-f%2^(i-1)>0 and '1' or '0') end
        return r;
    end):gsub('%d%d%d?%d?%d?%d?%d?%d?', function(x)
        if (#x ~= 8) then return '' end
        local c=0
        for i=1,8 do c=c+(x:sub(i,i)=='1' and 2^(8-i) or 0) end
        return string.char(c)
    end))
end

-- Testing
word="This is test for decoding"
deco=bec(word)
print(deco)

---give result :
VGhpcyBpcyB0ZXN0IGZvciBkZWNvZGluZw==

---- now when try to reverse it back
words='
VGhpscyBpcyB0ZXN0IGZvciBkZWNvZGluZw== '
reve=bdc(wprds)
print(reve)

--- result : Thi?́?́ѕ?Ё?ȁ??



is there any mistakes in the function above ?

Thanks for hints or solve the problem
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Tue Jul 05, 2016 9:52 am    Post subject: Reply with quote

Seems you just can't copy and paste correctly...
Code:
local b='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'

function bec(data)
    return ((data:gsub('.', function(x)
        local r,b='',x:byte()
        for i=8,1,-1 do r=r..(b%2^i-b%2^(i-1)>0 and '1' or '0') end
        return r;
    end)..'0000'):gsub('%d%d%d?%d?%d?%d?', function(x)
        if (#x < 6) then return '' end
        local c=0
        for i=1,6 do c=c+(x:sub(i,i)=='1' and 2^(6-i) or 0) end
        return b:sub(c+1,c+1)
    end)..({ '', '==', '=' })[#data%3+1])
end

function bdc(data)
    data = string.gsub(data, '[^'..b..'=]', '')
    return (data:gsub('.', function(x)
        if (x == '=') then return '' end
        local r,f='',(b:find(x)-1)
        for i=6,1,-1 do r=r..(f%2^i-f%2^(i-1)>0 and '1' or '0') end
        return r;
    end):gsub('%d%d%d?%d?%d?%d?%d?%d?', function(x)
        if (#x ~= 8) then return '' end
        local c=0
        for i=1,8 do c=c+(x:sub(i,i)=='1' and 2^(8-i) or 0) end
        return string.char(c)
    end))
end

-- Testing
word="This is test for decoding"
deco=bec(word)
print(deco)

---- now when try to reverse it back
words='VGhpcyBpcyB0ZXN0IGZvciBkZWNvZGluZw=='
reve=bdc(words)
print(reve)
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Tue Jul 05, 2016 6:38 pm    Post subject: Reply with quote

Ah,,,i see, thank Zanzer.
Some character has changed it self while copy the scripts to notepad++.
Thanks for correction..
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Wed Jul 06, 2016 5:32 am    Post subject: Reply with quote

Zanzer sir,

by use same encode / decode function, why decode function give wrong result when try to reverse back the code ?

From old post in this forum
http://cheatengine.org/forum/viewtopic.php?p=5659431&sid=c3ccb9b553007ff9abeb78b90186b87c


Code:

local b='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'

function bec(data)
    return ((data:gsub('.', function(x)
        local r,b='',x:byte()
        for i=8,1,-1 do r=r..(b%2^i-b%2^(i-1)&gt;0 and '1' or '0') end
        return r;
    end)..'0000'):gsub('%d%d%d?%d?%d?%d?', function(x)
        if (#x &lt; 6) then return '' end
        local c=0
        for i=1,6 do c=c+(x:sub(i,i)=='1' and 2^(6-i) or 0) end
        return b:sub(c+1,c+1)
    end)..({ '', '==', '=' })[#data%3+1])
end

function bdc(data)
    data = string.gsub(data, '[^'..b..'=]', '')
    return (data:gsub('.', function(x)
        if (x == '=') then return '' end
        local r,f='',(b:find(x)-1)
        for i=6,1,-1 do r=r..(f%2^i-f%2^(i-1)&gt;0 and '1' or '0') end
        return r;
    end):gsub('%d%d%d?%d?%d?%d?%d?%d?', function(x)
        if (#x ~= 8) then return '' end
        local c=0
        for i=1,8 do c=c+(x:sub(i,i)=='1' and 2^(8-i) or 0) end
        return string.char(c)
    end))
end

---- already Encrypted Data

deco=bdc('NjAgOUIgMDMgNjYgNDAgNjUgMDEgNkMgMDYgNjUgMDEgNkMgMDUgNjUgMDEgNkMgMDggNjUgMDEgNkMgMDk=') 

print(deco)
--- result : 60 9B 03 66 40 65 01 6C 06 65 01 6C 05 65 01 6C 08 65 01 6C 09

deco2=bdc('SUp4REJDPT0= ')
print(deco2)
-- result : IJxDBC==



Is the second code use other method while encoding ?
Is it same base64 encoding system ?

Regards
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Wed Jul 06, 2016 7:29 pm    Post subject: Reply with quote

Where did you get 'SUp4REJDPT0=' from?
What is it supposed to decode into?
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Fri Jul 08, 2016 6:52 am    Post subject: Reply with quote

Actually that from Critical Ops. trainer made by Cyber Hack

save[5]=bdc(SUp4REJDPT0=)

this is not follow the function bdc(data)
I think it given wrong decode because of this :

Code:

local function browser(text, key)
   return text:gsub("%a", function(t)
         local base = (t:lower() == t and string.byte('a') or string.byte('A'))

         local r = t:byte() - base
         r = r + key
         r = r%26 -- works correctly even if r is negative
         r = r + base
         return string.char(r)
      end)
end

local function PIDD(text, key)
   return browser(text, -key)
end

Scanning = {
   browser = browser,
   PIDD = PIDD,
}

--- and also
function scan(enter, exit)
pretemp1 =Scanning.PIDD(enter,12)
pretemp2 =Scanning.PIDD(exit,12)
temp1 = bdc(pretemp1)
temp2 = bdc(pretemp2)
temp3 = Scanning.PIDD(temp1,12)
temp4 = Scanning.PIDD(temp2,12)
search = bdc(temp3)
change = bdc(temp4)
     aobs = AOBScan(search, "+W")
     if(aobs == nil) then
      scanCheck=false
    else
       j = stringlist_getCount(aobs)
      for i = 1, j do
          address=stringlist_getString(aobs,i-1)
          for i = 1, string.len(change), 3 do
             z = string.sub(change, i, i+2)
             x, y = string.find(z, "%?+")
              if (x == nil) then
                script=[[
                ]]..address.."+"..(DEC_HEX((i-1)/3))..[[:
                db ]]..z..[[
                ]]
                autoAssemble(script)
             end
          end
       end
      object_destroy(aobs);
      aobs=nil
      scanCheck=true
   end
end



of course i can see AOB code by insert print() statement at :
Code:

...
search = bdc(temp3)
print(search)
change = bdc(temp4)
print(change)
...


Anyhow AOB is not important. Which I am curious is about encode decode system using temp (maybe store in memory) and then load it with function scan and change.

This is very good (to make leecher / steal code hardest).
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

Joined: 09 May 2003
Posts: 25262
Location: The netherlands

PostPosted: Fri Jul 08, 2016 7:25 am    Post subject: Reply with quote

I don't think it makes leachers/stealers any harder

They just copy it including the encoded strings without understanding what it does

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Sat Jul 09, 2016 9:16 am    Post subject: Reply with quote

You are right DB and I think you also part f group Cyber Hack or Cyber Terminator if I am not wrong..
Back to top
View user's profile Send private message
Hello all
How do I cheat?
Reputation: 0

Joined: 14 Dec 2015
Posts: 9

PostPosted: Sun Oct 23, 2016 9:58 am    Post subject: Reply with quote

Hello please help Me how I can protect your table from the fraud, I use Cheat angineh 6.6 as mene encode text
inside the table that would be through the program Cheat angineh 6.6 could not find any that functions, such as bullets, life, or <CheatTable Cheat Engine Table Version = "and remove all the table, as the exchange or to code than please help.

sorry for my English

through the program Cheat angineh I can pull out of the Trainer script of life ammunition, in general, all the table, tell Me how to encode the text in the script, it was impossible to see from the code, I beg you help me, I use Cheat angineh 6.6.

sorry for my English

sorry for my English
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Sun Oct 23, 2016 7:01 pm    Post subject: Reply with quote

If the trainer is not a online trainer,
decode function must be there inside the trainer script.
Check it out..
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