 |
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
noobes Advanced Cheater
Reputation: 0
Joined: 17 Dec 2018 Posts: 89
|
Posted: Fri May 31, 2019 7:04 am Post subject: Lua string code (Text) into Binary |
|
|
I have a question. Is it possible to convert a text into a binary code? I need the code for the convertion. Someone know? And it in Cheat Engine lua.
Ex: 'im XOR' -> 01010101010110101
|
|
Back to top |
|
 |
Corroder Grandmaster Cheater Supreme
Reputation: 75
Joined: 10 Apr 2015 Posts: 1668
|
Posted: Fri May 31, 2019 8:36 am Post subject: |
|
|
First, I want to know from where:
'im XOR' = 01010101010110101 ?
Because in my opinion, string 'im XOR' = 11010010110110100100000010110000100111101010010
in little-endian DWord.
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL |
|
Back to top |
|
 |
noobes Advanced Cheater
Reputation: 0
Joined: 17 Dec 2018 Posts: 89
|
Posted: Sat Jun 01, 2019 2:45 am Post subject: |
|
|
Corroder wrote: | First, I want to know from where:
'im XOR' = 01010101010110101 ?
Because in my opinion, string 'im XOR' = 11010010110110100100000010110000100111101010010
in little-endian DWord. |
I just gave a example. But you know how?
|
|
Back to top |
|
 |
Corroder Grandmaster Cheater Supreme
Reputation: 75
Joined: 10 Apr 2015 Posts: 1668
|
Posted: Sat Jun 01, 2019 4:51 am Post subject: |
|
|
noobesgt wrote: |
I just gave a example. But you know how? |
Yes, please give an example with reasonable logic. You can check in the string to binary online converter. But the way:
Code: | --String to binary
-- 1. Convert String to HEX
function string.tohex(str)
return (str:gsub('.', function (c)
return string.format('%02X', string.byte(c)) end))
end
-- 2. Helper function to covert base n number
function basen(n,b)
n = math.floor(n)
if not b or b == 10 then return tostring(n) end
local digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
local t = {}
local sign = ""
if n < 0 then sign = "-" n = -n end
repeat local d = (n % b) + 1 n = math.floor(n / b)
table.insert(t, 1, digits:sub(d,d)) until n == 0
return sign .. table.concat(t,"")
end
-- 3. Function to convert Hex to bin
function hex2bin(s)
dec = tonumber(s,16)
return tostring(basen(dec,2))
end
--- testing
str = 'im XOR'
s = string.tohex(str)
print(s) -- = 696D20584F52
bin = hex2bin(s)
print(bin) -- = 11010010110110100100000010110000100111101010010 |
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL |
|
Back to top |
|
 |
noobes Advanced Cheater
Reputation: 0
Joined: 17 Dec 2018 Posts: 89
|
Posted: Sat Jun 01, 2019 7:24 am Post subject: |
|
|
Corroder wrote: | noobesgt wrote: |
I just gave a example. But you know how? |
Yes, please give an example with reasonable logic. You can check in the string to binary online converter. But the way:
Code: | --String to binary
-- 1. Convert String to HEX
function string.tohex(str)
return (str:gsub('.', function (c)
return string.format('%02X', string.byte(c)) end))
end
-- 2. Helper function to covert base n number
function basen(n,b)
n = math.floor(n)
if not b or b == 10 then return tostring(n) end
local digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
local t = {}
local sign = ""
if n < 0 then sign = "-" n = -n end
repeat local d = (n % b) + 1 n = math.floor(n / b)
table.insert(t, 1, digits:sub(d,d)) until n == 0
return sign .. table.concat(t,"")
end
-- 3. Function to convert Hex to bin
function hex2bin(s)
dec = tonumber(s,16)
return tostring(basen(dec,2))
end
--- testing
str = 'im XOR'
s = string.tohex(str)
print(s) -- = 696D20584F52
bin = hex2bin(s)
print(bin) -- = 11010010110110100100000010110000100111101010010 |
|
By the way i needed this to make a obfuscation method. How can i make it to loadstring?
|
|
Back to top |
|
 |
Corroder Grandmaster Cheater Supreme
Reputation: 75
Joined: 10 Apr 2015 Posts: 1668
|
Posted: Sat Jun 01, 2019 9:49 am Post subject: |
|
|
So, so far your goal is to make binary obfuscation?. Just to let you know writing binary string format usually present as an example: 027\114\033\.. and so on. In Lua able to use string.bytes(char) to get a byte of a character.
With this format, to reverse 'binary format' to the readable characters can use reverse function and then use loadstring(). Anyhow when using hex editor it's still possible to view those readable characters.
I don't know or (maybe don't want to try) to make some functions to reverse binary to string and then use loadstring() to read it.
Anyhow, the simple way to obfuscating Lua script or strings is use CE Encode/Decode functions. Or use Lua built-in function, for example:
Code: | function f () print "im XOR" end
s = string.dump (f)
print(s)
assert (loadstring (s)) () --> im XOR |
I don't understand why peoples desperately trying to hiding, obfuscating or encoding their hack code/script event they not trying to make their code become commercial by selling it at all. Meanwhile, on other sides peoples share their code/script for free without any obfuscating sh*t. Event DB with his complex CE source code, shared it openly and free. Ahh..talk too much.
So, whatever. If you want to encode/decode string to BIT format, below is the functions and next try to make a function to load decode script using loadstring() as you wish by yourself.
Code: | 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 function unexpected_char_error( str, pos )
local c = string.sub( str, pos, pos ) return string.format( "unexpected character at position %d: '%s'", pos, c ) end
local basexx = {} 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 pos = string.find(str,"[^01]") if pos then return nil,unexpected_char_error(str,pos)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 _ = 1,8 do table.insert( bits, byte%2) byte = math.floor(byte/2) end
return table.concat(bits):reverse() end))end;
text = [[
Lorem ipsum dolor sit amet, consectetur adipiscing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco
laboris nisi ut aliquip ex ea commodo consequat
]]
encodebit = basexx.to_bit(text)
decodebit = basexx.from_bit(encodebit)
print(encodebit)
print(decodebit) |
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL |
|
Back to top |
|
 |
|
|
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
|
|