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 


How i can Protect Trainer from decryption
Goto page Previous  1, 2, 3
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
samy_grecu
!BEWARE! Deletes post on answer
Reputation: 0

Joined: 30 Dec 2016
Posts: 12
Location: Italy

PostPosted: Tue Jan 23, 2018 3:00 am    Post subject: Reply with quote

I can not encode, what's wrong?
I followed exactly the steps the corroder mentioned above(or at least so I believe)
but there is an error when running the trainer in stand alone



1.I copied the entire Lua script Table (which is to be encoded and saved as mycodetable.lua)

2.Removed All Line Breaks Here
https :// www . textfixer. com/ tools/ remove-line-breaks. php

3.Then encoded in BASE 32 CIPHERTEXT
here
https :// www .dcode . fr/ base-32-encoding

4.The script once encoded I added here and saved as mycodetable.lua

Code:
function obivius()
  local base32Alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"
  local base32PadMap = { "", "======", "====", "===", "=" }

  function basexx.from_base32( str, ignore )
   str = ignore_set( str, ignore )
   return from_basexx( string.upper( str ), base32Alphabet, 5 )
  end

  function basexx.to_base32( str )
   return to_basexx( str, base32Alphabet, 5, base32PadMap[ #str % 5 + 1 ] )
  end

obser = "NV4WG33EMUQHOYLTEBQWIZDFMQQGQZLSMU======"
vation = basexx.from_base32(obser)
end


5.Added mycodetable.lua to CE > Table > Add File


6.Finally i added this part in the Lua script cheat table

Code:
getLuaEngine().cbShowOnPrint.Checked=false
getLuaEngine().hide()

---- Call Code
function loadTableCode(n2)
 local t2 = findTableFile(n2)
 if t2 ~= nil then
 local s2 = t2.Stream
 local c2 = readStringLocal(s2.Memory,s2.Size)
 return c2 ~= nil and loadstring(c2) -- return a function
 end
end
--
local f2 = loadTableCode('mycodetable.lua')
print(type(f2))
if type(f2) == 'function' then f2() else print('not loaded') end

---- Run the function
obivius()
a = tostring(vation)

-- Defining a string to use as function later
funcStr = a
func = loadstring(funcStr)
func()


Saved The trainer in exe ,the execution comes with this error



2018-01-23 09_52_34-.png
 Description:
 Filesize:  91.59 KB
 Viewed:  6076 Time(s)

2018-01-23 09_52_34-.png



2018-01-23 09_49_53-Cheat Engine 6.7.png
 Description:
 Filesize:  36.86 KB
 Viewed:  6076 Time(s)

2018-01-23 09_49_53-Cheat Engine 6.7.png



2018-01-23 09_48_47-.png
 Description:
 Filesize:  56.3 KB
 Viewed:  6076 Time(s)

2018-01-23 09_48_47-.png



2018-01-23 09_03_50-Universal Nou.png
 Description:
 Filesize:  5.83 KB
 Viewed:  6076 Time(s)

2018-01-23 09_03_50-Universal Nou.png


Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Tue Jan 23, 2018 4:13 am    Post subject: Reply with quote

samy_grecu wrote:
I can not encode, what's wrong?


3.Then encoded in BASE 32 CIPHERTEXT
here
https :// www .dcode . fr/ base-32-encoding
..
..


because you not use full function of basexx.base 32, so here is complete function basexx.lua :

Code:
local function divide_string( str, max, fillChar )
   fillChar = fillChar or ""
   local result = {}

   local start = 1
   for i = 1, #str do
      if i % max == 0 then
         table.insert( result, str:sub( start, i ) )
         start = i + 1
      elseif i == #str then
         table.insert( result, str:sub( start, i ) )
      end
   end

   return result
end

local function number_to_bit( num, length )
   local bits = {}

   while num > 0 do
      local rest = math.floor( math.fmod( num, 2 ) )
      table.insert( bits, rest )
      num = ( num - rest ) / 2
   end

   while #bits < length do
      table.insert( bits, "0" )
   end

   return string.reverse( table.concat( bits ) )
end

local function ignore_set( str, set )
   if set then
      str = str:gsub( "["..set.."]", "" )
   end
   return str
end

local function pure_from_bit( str )
   return ( str:gsub( '........', function ( cc )
               return string.char( tonumber( cc, 2 ) )
            end ) )
end

--------------------------------------------------------------------------------

local basexx = {}

--------------------------------------------------------------------------------
-- base2(bitfield) decode and encode function
--------------------------------------------------------------------------------

local bitMap = { o = "0", i = "1", l = "1" }

function basexx.from_bit( str, ignore )
   str = ignore_set( str, ignore )
   str = string.lower( str )
   str = str:gsub( '[ilo]', function( c ) return bitMap[ c ] end )
   local wrong = str:match( "[^01]" )
   if wrong then return nil, wrong end

   return pure_from_bit( str )
end

function basexx.to_bit( str )
   return ( str:gsub( '.', function ( c )
               local byte = string.byte( c )
               local bits = {}
               for i = 1,8 do
                  table.insert( bits, byte % 2 )
                  byte = math.floor( byte / 2 )
               end
               return table.concat( bits ):reverse()
            end ) )
end

--------------------------------------------------------------------------------
-- base16(hex) decode and encode function
--------------------------------------------------------------------------------

function basexx.from_hex( str, ignore )
   str = ignore_set( str, ignore )
   local wrong = str:match( "[^%x]" )
   if wrong then return nil, wrong end

   return ( str:gsub( '..', function ( cc )
               return string.char( tonumber( cc, 16 ) )
            end ) )
end

function basexx.to_hex( str )
   return ( str:gsub( '.', function ( c )
               return string.format('%02X', string.byte( c ) )
            end ) )
end

--------------------------------------------------------------------------------
-- generic function to decode and encode base32/base64
--------------------------------------------------------------------------------

local function from_basexx( str, alphabet, bits )
   local result = {}
   for i = 1, #str do
      local c = string.sub( str, i, i )
      if c ~= '=' then
         local index = string.find( alphabet, c, 1, true )
         if not index then
            return nil, c
         end
         table.insert( result, number_to_bit( index - 1, bits ) )
      end
   end

   local value = table.concat( result )
   local pad = #value % 8
   return pure_from_bit( string.sub( value, 1, #value - pad ) )
end

local function to_basexx( str, alphabet, bits, pad )
   local bitString = basexx.to_bit( str )

   local chunks = divide_string( bitString, bits )
   local result = {}
   for key,value in ipairs( chunks ) do
      if ( #value < bits ) then
         value = value .. string.rep( '0', bits - #value )
      end
      local pos = tonumber( value, 2 ) + 1
      table.insert( result, alphabet:sub( pos, pos ) )
   end

   table.insert( result, pad )
   return table.concat( result )
end

--------------------------------------------------------------------------------
-- rfc 3548
--------------------------------------------------------------------------------

local base32Alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"
local base32PadMap = { "", "======", "====", "===", "=" }

function basexx.from_base32( str, ignore )
   str = ignore_set( str, ignore )
   return from_basexx( string.upper( str ), base32Alphabet, 5 )
end

function basexx.to_base32( str )
   return to_basexx( str, base32Alphabet, 5, base32PadMap[ #str % 5 + 1 ] )
end

--------------------------------------------------------------------------------
-- crockford
--------------------------------------------------------------------------------

local crockfordAlphabet = "0123456789ABCDEFGHJKMNPQRSTVWXYZ"
local crockfordMap = { O = "0", I = "1", L = "1" }

function basexx.from_crockford( str, ignore )
   str = ignore_set( str, ignore )
   str = string.upper( str )
   str = str:gsub( '[ILOU]', function( c ) return crockfordMap[ c ] end )
   return from_basexx( str, crockfordAlphabet, 5 )
end

function basexx.to_crockford( str )
   return to_basexx( str, crockfordAlphabet, 5, "" )
end

--------------------------------------------------------------------------------
-- base64 decode and encode function
--------------------------------------------------------------------------------

local base64Alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"..
                       "abcdefghijklmnopqrstuvwxyz"..
                       "0123456789+/"
local base64PadMap = { "", "==", "=" }

function basexx.from_base64( str, ignore )
   str = ignore_set( str, ignore )
   return from_basexx( str, base64Alphabet, 6 )
end

function basexx.to_base64( str )
   return to_basexx( str, base64Alphabet, 6, base64PadMap[ #str % 3 + 1 ] )
end

--------------------------------------------------------------------------------
-- URL safe base64 decode and encode function
--------------------------------------------------------------------------------

local url64Alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"..
                      "abcdefghijklmnopqrstuvwxyz"..
                      "0123456789-_"

function basexx.from_url64( str, ignore )
   str = ignore_set( str, ignore )
   return from_basexx( str, url64Alphabet, 6 )
end

function basexx.to_url64( str )
   return to_basexx( str, url64Alphabet, 6, "" )
end

--------------------------------------------------------------------------------
--
--------------------------------------------------------------------------------

local z85Decoder = { 0x00, 0x44, 0x00, 0x54, 0x53, 0x52, 0x48, 0x00,
                     0x4B, 0x4C, 0x46, 0x41, 0x00, 0x3F, 0x3E, 0x45,
                     0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
                     0x08, 0x09, 0x40, 0x00, 0x49, 0x42, 0x4A, 0x47,
                     0x51, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A,
                     0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32,
                     0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A,
                     0x3B, 0x3C, 0x3D, 0x4D, 0x00, 0x4E, 0x43, 0x00,
                     0x00, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10,
                     0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
                     0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20,
                     0x21, 0x22, 0x23, 0x4F, 0x00, 0x50, 0x00, 0x00 }

function basexx.from_z85( str, ignore )
   str = ignore_set( str, ignore )
   if ( #str % 5 ) ~= 0 then return nil, #str % 5 end

   local result = {}

   local value = 0
   for i = 1, #str do
      local index = string.byte( str, i ) - 31
      if index < 1 or index >= #z85Decoder then return nil, index end
      value = ( value * 85 ) + z85Decoder[ index ]
      if ( i % 5 ) == 0 then
         local divisor = 256 * 256 * 256
         while divisor ~= 0 do
            local b = math.floor( value / divisor ) % 256
            table.insert( result, string.char( b ) )
            divisor = math.floor( divisor / 256 )
         end
         value = 0
      end
   end

   return table.concat( result )
end

local z85Encoder = "0123456789"..
                   "abcdefghijklmnopqrstuvwxyz"..
                   "ABCDEFGHIJKLMNOPQRSTUVWXYZ"..
                   ".-:+=^!/*?&<>()[]{}@%$#"

function basexx.to_z85( str )
   if ( #str % 4 ) ~= 0 then return nil, #str, 4 end

   local result = {}

   local value = 0
   for i = 1, #str do
      local b = string.byte( str, i )
      value = ( value * 256 ) + b
      if ( i % 4 ) == 0 then
         local divisor = 85 * 85 * 85 * 85
         while divisor ~= 0 do
            local index = ( math.floor( value / divisor ) % 85 ) + 1
            table.insert( result, z85Encoder:sub( index, index ) )
            divisor = math.floor( divisor / 85 )
         end
         value = 0
      end
   end

   return table.concat( result )
end


put that basexx code under function obivius() and try again what you've done

EDIT :
Remember, you need use same library for decode / encode function. It's mean if you encoding your code by using a tool from a site, then the decode function also must be there. It shall little bit different if you use other function from other sites or libraries even they have same base.

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
samy_grecu
!BEWARE! Deletes post on answer
Reputation: 0

Joined: 30 Dec 2016
Posts: 12
Location: Italy

PostPosted: Tue Jan 23, 2018 5:49 am    Post subject: Reply with quote

thank you corroder

now I'm trying..

i encode my code from a site because I do not know any other solution
to encode the aobs I had a ct that did this in base64,if you have something similar to base32 or anything else that would be great



base64.png
 Description:
 Filesize:  47.79 KB
 Viewed:  6053 Time(s)

base64.png


Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Tue Jan 23, 2018 7:54 am    Post subject: Reply with quote

samy_grecu wrote:
thank you corroder

now I'm trying..

i encode my code from a site because I do not know any other solution
to encode the aobs I had a ct that did this in base64,if you have something similar to base32 or anything else that would be great


Yeah, I am not surprise with your encode/decode function.
That combining base64 encode/decode function with caesar-chiper text decode/encode function. Try take look here :

http://forum.cheatengine.org/viewtopic.php?t=602580

That method usually use by facech*** braz** and some others to hide their codes inside their trainers. But I knew someone name vcl who easy break their trainers and hide codes.

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
movss
Cheater
Reputation: 0

Joined: 10 Feb 2018
Posts: 38

PostPosted: Sat Feb 10, 2018 3:00 pm    Post subject: Reply with quote

When I create windows, I load a DLL to detect disassembly tools, such as OD and DLL, which contain encrypted assembler code, and trainer has encryption function.
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
Goto page Previous  1, 2, 3
Page 3 of 3

 
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