|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
panraven Grandmaster Cheater Reputation: 55
Joined: 01 Oct 2008 Posts: 942
|
Posted: Thu Jul 02, 2015 11:39 am Post subject: |
|
|
Where the internet url on calling cmdHttpGet function?
cmdHttpGet is to obtain an internet file and return the content as a string. The filename as 1st parameter is optional, to save a copy on the local disk storage. If local save is not necessary, give it a 'nil' parameter.
Then the 2nd parameter is the internet url, which is necessary. More url can be supplied in case previous url failed to download. This seems only useful for special need.
eg. attempt to download the ce forum page as a string without local copy:
Code: | local cepage = cmdHttpGet(nil,[[forum.cheatengine.org]]) |
--
Refer Zanzer's code if you work with a local file.
You can load the text file as string and split the text string to an array of string.
http://lua-users.org/wiki/SplitJoin
eg.
Code: |
local lines = [=[
[[[game.exe+002F15D8]+19c]+14]+26
[[[game.exe+002F15D8]+19c]+14]+36
[[[game.exe+002F15D8]+19c]+14]+46
[[[game.exe+002F15D8]+19c]+14]+56
]=]
local p = {} -- array to hold each pointer lines
for l in lines:gmatch( '[^\n]+') do
print(l) -- or do thing on each pointer lines respectively
p[1+#p]=l
end
|
bye~
_________________
- Retarded. |
|
Back to top |
|
|
RandName Newbie cheater Reputation: 0
Joined: 19 Jun 2015 Posts: 22
|
Posted: Sun Jul 05, 2015 9:34 pm Post subject: |
|
|
I also used this idea to locate some data on github.
I modified it a bit though.
Anyway, you can use this method to also store entire functions on a server.
It is even possible to create a table/list/array of functions.
I mainly use it for function storing.
A function table would look somewhat like this.
Code: |
return {
myFunc1 = function(version)
print(version)
end,
myFunc2 = function()
return 0xDEADBEEF
end
}
|
The more challenging part is the loading of the functions.
I solved it by creating a "loadData" function.
Code: |
function loadData(dataname)
local file = datadir .. "data.txt" -- data file name and directory
if (exist(file)) then -- checking whether an offline version is available
local dataTable = loadstring(readFile(file))() -- reading the file contents and executing the resulting string
local data = dataTable[dataname] -- getting the saved function from the data table (e.g. myFunc1)
return data -- returning the function
else -- else the data will be downloaded from the given url
local dataTable = loadstring(cmdHttpGet(dataUrl, file))() -- downloading data and saving it into the specified directory
local data = dataTable[dataname]
return data
end
end
|
Calling it would look something like this:
Code: |
myFunc1 = loadData('myFunc1')
myFunc1('v1.0')
--> v1.0
myFunc2 = loadData('myFunc2')
print(string.format('%X', myFunc2()))
--> 0xDEADBEEF
|
I hope that this is from help for someone out there.
|
|
Back to top |
|
|
faizangmc Expert Cheater Reputation: 0
Joined: 12 Nov 2013 Posts: 167
|
Posted: Wed Jul 08, 2015 3:51 pm Post subject: |
|
|
RandName wrote: |
I hope that this is from help for someone out there. |
Hey, where do I exacly put the url in the above code?
can you give a complete lua script for the above example with this url :
http://faizan.ucoz.com/icc2015/data.txt
I have copy pasted this information in data.txt file :
Quote: | return {
myFunc1 = function(version)
print(version)
end,
myFunc2 = function()
return 0xDEADBEEF
end
} |
Also,
Suppose I have this file called 'addresses.txt' in which I have all pointers stored one below the other :
Quote: | ammo = [[[game.exe+002F15D8]+19c]+14]+26
hp = [[[game.exe+002F15D8]+19c]+14]+36
strenght = [[[game.exe+002F15D8]+19c]+14]+46
mana = [[[game.exe+002F15D8]+19c]+14]+56
|
and url of addresses.txt is
now i would like to have this data as it is in cheat engines lua
so that i can use these scripts
Quote: | writeInteger (ammo,100)
writeInteger (hp,100)
|
how can i achieve this?
using the below code simply prints the data as "strings" but doesnt assign the address to variable called hp, ammo, etc...
Code: | function exist(f) return type(f)=='string' and os.rename(f,f) and true or false end
function readFile(f,mode) local r = io.open(f,mode or 'rb') local ret = r:read('*all') r:close() return ret end
function cmdHttpGet(file,url,...)
assert(type(url)=='string','has to specific url string')
local useTmp,ok,response,result = type(file)~='string'
if useTmp then file = os.tmpname() end
local cmd = string.format([[powershell -command "& { (New-Object Net.WebClient).DownloadFile('%s', '%s') }"]],url,file)
ok,cmd = pcall(io.popen,cmd,'r')
if not ok then return nil,cmd end -- cmd is err msg if not ok else the command pipe line object
response = cmd:read('*all')
local requestGood = response:len() == 0 -- assume the powershell return nothing on CONSOLE if the download is success
cmd:close()
if requestGood then
ok,response = pcall(readFile,file)
result = ok and response or nil
else -- web error
if select('#',...)>0 then result,response = cmdHttpGet(file,...) end -- try next url if provided
end
if useTmp and exist(file) then os.remove(file) end -- clean tmp file
return result,response
end
-- test start
function test()
local r,errmsg = cmdHttpGet(nil,[[http://faizan.ucoz.com/icc2015/addresses.txt]],[[http://faizan.ucoz.com/icc2015/http://faizan.ucoz.com/icc2015/pRetire.txt]])
if r ~= nil then
print(r)
else
print('error:',errmsg)
end
end
test() |
sorry for taking this long, but im a newbie
|
|
Back to top |
|
|
RandName Newbie cheater Reputation: 0
Joined: 19 Jun 2015 Posts: 22
|
Posted: Mon Aug 10, 2015 12:46 pm Post subject: |
|
|
faizangmc wrote: | RandName wrote: |
I hope that this is from help for someone out there. |
Hey, where do I exacly put the url in the above code?
can you give a complete lua script for the above example with this url :
data.txt
I have copy pasted this information in data.txt file :
Quote: | return {
myFunc1 = function(version)
print(version)
end,
myFunc2 = function()
return 0xDEADBEEF
end
} |
Also,
Suppose I have this file called 'addresses.txt' in which I have all pointers stored one below the other :
Quote: | ammo = [[[game.exe+002F15D8]+19c]+14]+26
hp = [[[game.exe+002F15D8]+19c]+14]+36
strenght = [[[game.exe+002F15D8]+19c]+14]+46
mana = [[[game.exe+002F15D8]+19c]+14]+56
|
and url of addresses.txt is
now i would like to have this data as it is in cheat engines lua
so that i can use these scripts
Quote: | writeInteger (ammo,100)
writeInteger (hp,100)
|
how can i achieve this?
using the below code simply prints the data as "strings" but doesnt assign the address to variable called hp, ammo, etc...
Code: | function exist(f) return type(f)=='string' and os.rename(f,f) and true or false end
function readFile(f,mode) local r = io.open(f,mode or 'rb') local ret = r:read('*all') r:close() return ret end
function cmdHttpGet(file,url,...)
assert(type(url)=='string','has to specific url string')
local useTmp,ok,response,result = type(file)~='string'
if useTmp then file = os.tmpname() end
local cmd = string.format([[powershell -command "& { (New-Object Net.WebClient).DownloadFile('%s', '%s') }"]],url,file)
ok,cmd = pcall(io.popen,cmd,'r')
if not ok then return nil,cmd end -- cmd is err msg if not ok else the command pipe line object
response = cmd:read('*all')
local requestGood = response:len() == 0 -- assume the powershell return nothing on CONSOLE if the download is success
cmd:close()
if requestGood then
ok,response = pcall(readFile,file)
result = ok and response or nil
else -- web error
if select('#',...)>0 then result,response = cmdHttpGet(file,...) end -- try next url if provided
end
if useTmp and exist(file) then os.remove(file) end -- clean tmp file
return result,response
end
-- test start
function test()
local r,errmsg = cmdHttpGet(nil,[[addresses.txt]],[[pRetire.txt]])
if r ~= nil then
print(r)
else
print('error:',errmsg)
end
end
test() |
sorry for taking this long, but im a newbie |
Sorry for the late answer but I didn't notice that you posted here.
So, I put together a code but I had to delete the urls since I can't post them yet.
Not all the code is necessary because I copied most parts from another project of mine.
Anyway, here it is:
Code: |
function exists(name)
if (type(name) ~= "string") then return false end
return os.rename(name, name) and true or false
end
function isFile(name)
if type(name) ~= "string" then return false end
if (not exists(name)) then return false end
local f = io.open(name)
if (f) then
f:close()
return true
end
return false
end
function isDir(name)
return (exists(name) and not isFile(name))
end
function readFile(f, mode) local r = io.open(f, mode or 'rb') local ret = r:read('*all') r:close() return ret end
function writeFile(f, mode, str) local r = io.open(f, mode or 'w+') r:write(str) r:close() end
function httpGet(url, file)
assert(type(url) == 'string', 'has to be an url')
local tmpfile = "_tmp.data"
file = type(file) == 'string' and file or tmpfile
local result = string.format("printDual('ERROR: %s --> %s')", url, file)
local cmd = string.format([[powershell -windowstyle hidden -command "& { (New-Object Net.WebClient).DownloadFile('%s', '%s') }"]], url, tmpfile)
cmd = assert(io.popen(cmd, 'r'))
local response = cmd:read('*a')
cmd:close()
if (response:len() == 0) then
result = readFile(tmpfile)
writeFile(file, "w+", result)
if (isFile(tmpfile)) then
os.remove(tmpfile)
end
else
if (isFile(file)) then
result = readFile(file)
print(string.format("Couldn't update data! Using saved data!"))
else
print(string.format("Couldn't update data! No saved data found!"))
end
end
return result
end
function loadDataFromFile(dataname, file, url)
if (isFile(file)) then
local dataTable = loadstring(readFile(file))()
local data = dataTable[dataname]
return data
else
local newData = httpGet(url)
local dataTable = loadstring(newData)()
local data = dataTable[dataname]
return data
end
end
function loadDataFromString(dataname, string)
local dataTable = loadstring(string)()
return dataTable[dataname]
end
function test()
local url = [[data url]]
local dataString = httpGet(url) -- add a path to a file if you want to save the downloaded string
myFunc1 = loadDataFromString("myFunc1", dataString)
myFunc2 = loadDataFromString("myFunc2", dataString)
myFunc1(1.5)
deadbeef = myFunc2()
print(string.format("0x%X", deadbeef))
--
local url2 = [[address url]]
--local dataString2 = httpGet(url2)
--loadstring(dataString2)
--print(ammo)
end
test()
|
Regarding your second request.
The file on your server is wrong. It should be like this, else it will generate an error:
Code: |
ammo = '[[[game.exe+002F15D8]+19c]+14]+26'
hp = '[[[game.exe+002F15D8]+19c]+14]+36'
strenght = '[[[game.exe+002F15D8]+19c]+14]+46'
mana = '[[[game.exe+002F15D8]+19c]+14]+56'
|
I commented the code out, else it would throw an error.
|
|
Back to top |
|
|
samy_grecu !BEWARE! Deletes post on answer Reputation: 0
Joined: 30 Dec 2016 Posts: 12 Location: Italy
|
Posted: Fri Dec 30, 2016 9:14 am Post subject: please help |
|
|
Hi everyone!
anyone can share a tutorial with steps on how to receives cheat table from a hosted location?maybe a ct example!thanks in advance
|
|
Back to top |
|
|
Zanzer I post too much Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
|
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
|
|