 |
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
rahat How do I cheat?
Reputation: 0
Joined: 11 May 2015 Posts: 9
|
Posted: Mon May 11, 2015 10:16 am Post subject: Trainer That Receives Cheat Table from Remote Server. |
|
|
Hi,
Made a custom trainer for myself and couple of other friends. But sending them updated trainer each time game gets updated is a pain.
I want my trainer to receive cheat table from a hosted location (a dropbox location would be awesome but anything would work). That's all. No authentication or anything.
NoOb Alert: An example trainer doing this task would be much much appreciated. |
|
Back to top |
|
 |
panraven Grandmaster Cheater
Reputation: 61
Joined: 01 Oct 2008 Posts: 958
|
Posted: Mon May 11, 2015 11:28 am Post subject: |
|
|
try get a socket/http dll compiled for ce lua.
or try this, if your windows installed powershell:
Code: | --
function cmdHttpGet(url,file)
assert(type(url)=='string','has to specific url string')
file = type(file)=='string' and file or '_dummy.tmp'
local cmd = string.format([[powershell -command "& { (New-Object Net.WebClient).DownloadFile('%s', '%s') }"]],url,file)
cmd = assert(io.popen(cmd,'r'))
cmd:read('*all')
cmd:close()
cmd = assert(io.open(file,'rb'))
local result = cmd:read('*all')
cmd:close()
return result
end
local r = cmdHttpGet([[http://cheatengine.org]])
print(tyep(r),#r) -- |
it will popup then close a console while calling. |
|
Back to top |
|
 |
justa_dude Grandmaster Cheater
Reputation: 23
Joined: 29 Jun 2010 Posts: 891
|
Posted: Mon May 11, 2015 1:52 pm Post subject: Re: Trainer That Receives Cheat Table from Remote Server. |
|
|
Why add this layer of unnecessary complexity? Just give them the Dropbox URL and done. _________________
A nagy kapu mellett, mindig van egy kis kapu.
----------------------
Come on... |
|
Back to top |
|
 |
rahat How do I cheat?
Reputation: 0
Joined: 11 May 2015 Posts: 9
|
Posted: Mon May 11, 2015 2:21 pm Post subject: Re: Trainer That Receives Cheat Table from Remote Server. |
|
|
panraven wrote: | try get a socket/http dll compiled for ce lua.
or try this, if your windows installed powershell:
Code: | --
function cmdHttpGet(url,file)
assert(type(url)=='string','has to specific url string')
file = type(file)=='string' and file or '_dummy.tmp'
local cmd = string.format([[powershell -command "& { (New-Object Net.WebClient).DownloadFile('%s', '%s') }"]],url,file)
cmd = assert(io.popen(cmd,'r'))
cmd:read('*all')
cmd:close()
cmd = assert(io.open(file,'rb'))
local result = cmd:read('*all')
cmd:close()
return result
end
local r = cmdHttpGet([[http://cheatengine.org]])
print(tyep(r),#r) -- |
it will popup then close a console while calling. |
Thnx dear, I'll try to figure it out this way.
justa_dude wrote: | Why add this layer of unnecessary complexity? Just give them the Dropbox URL and done. |
There could be various reasons for this, such as, maybe not wanting friends to bother for checking/downloading new exe each time, instead one person (me) just updating the cheat table and everything is set for them.
Or learning maybe? As stated in this Section's description: (Want Cheat Engine to do something specific and no idea how to do that, ask here. (From simple scripts to full trainers and extensions)
Again, there could be various reasons... Question is, whether you have the answer or not, if yes, would be generous to share, if no... explains alot :p |
|
Back to top |
|
 |
Rydian Grandmaster Cheater Supreme
Reputation: 31
Joined: 17 Sep 2012 Posts: 1358
|
Posted: Tue May 19, 2015 8:30 pm Post subject: |
|
|
I don't think that insulting other people here is conducive to you getting help. Not only will it turn them away, but it'll turn people like me who read replies before posting away as well.
Have you written a trainer at all before in CE? Unless you're literally just updating static entries in the table in-place*, then it's going to need LUA form edits as well, in which case you'd probably just use a launcher program of sorts that launches your actual trainer.
And that brings into question how it would know when it's time to update. Are you going to stick a text file with a version check on the dropbox server (for the launcher to parse) or something, or just waste all your bandwidth having all of their copies needlessly redownload the current version every time they launch?
These questions are being asked because it seems like a simple thing, but it's not, and we want to make sure you're aware of what you're getting into. (Also I don't know if Dropbox would appreciate you doing this but that's your own risk.)
* - And if you are doing this manually each time the game updates, you could probably make AOB scans for code edits that will survive longer and save yourself some effort.
http://forum.cheatengine.org/viewtopic.php?t=570083 _________________
|
|
Back to top |
|
 |
rahat How do I cheat?
Reputation: 0
Joined: 11 May 2015 Posts: 9
|
Posted: Wed May 20, 2015 6:01 am Post subject: |
|
|
First of all, let me confess that I'm not familiar with lua scripting.
Secondly, I have generated a working trainer with ease using DaSpammer's awesome tool (thnx DaSpammer). But resulting exe trainer is ~4 MB.
Issue is: If I share a download link of trainer, it would require on each update:
1: Re-generating trainer exe.
2: Uploading it.
3: Would require them to download ~4Mb executable
4: Adding it again to antivirus exception.
Not that its impossible or anything, but its extra headache for them and for me.
Instead, I wanted to modify the trainer in a way that It just get the AOBs from a text file that is hosted online.
This way, I just have to update the couple lines of an online file using filezilla and everything is set up.
no need generating trainer again and again.
no need uploading and distributing link.
no need for them to download a new exe each time.
no need for them to add new exe into av exception.
You are right that dropbox wont work for this purpose. Instead I used an online website hosting's free service to host that text file.
Also version check is not important since we actively play the game and we'll know when game is updated and AOBs (hosted text file) needs to be updated
(hope i explained well)
Many thanks to panraven, who generously took time and shared a function that reads the file containing AOBs, from a given url from inside the trainer. This so far saved me and my friends tons of efforts.
p.s: Never meant to insult anyone, it just appeared to me a mean comment instead of constructive one, so i responded in same manner. If it was not a mean comment, my deep apologies to justa_dude. |
|
Back to top |
|
 |
daspamer Grandmaster Cheater Supreme
Reputation: 54
Joined: 13 Sep 2011 Posts: 1588
|
Posted: Wed May 20, 2015 6:12 am Post subject: |
|
|
if you don't own a website, I'd recommend using a url shortener and incase you change or move the file, so you could simply update the url destination.
And you're correct its better to update couple of lines using filezilla instead of downloading everytime the trainer. _________________
I'm rusty and getting older, help me re-learn lua. |
|
Back to top |
|
 |
rahat How do I cheat?
Reputation: 0
Joined: 11 May 2015 Posts: 9
|
Posted: Wed May 20, 2015 7:18 am Post subject: |
|
|
Now second challenge for me (in order to make it more flexible) I want to populate whole hacktable dynamically
So, instead of this:
Code: |
ammo = cmdHttpGet([[tiny-url/ammo.txt]])
hp = cmdHttpGet([[tiny-url/hp.txt]])
self.hacktable = {
{'UnlimitedAmmo',[[luacall(AobswapC(]].. ammo..[[))]],[[]],[[]], 'false'},
{'UnlimitedHP',[[luacall(AobswapC(]].. hp..[[))]],[[]],[[]], 'false'}
}; |
I want to get all hacktable elements from text file. So, online text file may contain this data:
Code: | {'UnlimitedAmmo',[[luacall(AobswapC('01 01 01','11 11 11'))]],[[]],[[]], 'false'},
{'UnlimitedHP',[[luacall(AobswapC('02 02 02','22 22 22'))]],[[]],[[]], 'false'} |
This way, it would be easy to add new hacks, also wont splash powershell window again and again.
Problem is, I have no idea how to accomplish this, did following, but its not working.
Code: | tbl = cmdHttpGet([[tiny-url/table.txt]])
function CreateTrainer()
local HackData = {};
function HackData:HacksData()
self.trainer.form.Caption = [[trainer]]
self.trainer.title.Caption = [[trainer]]
self.trainer.credits.Caption = [[by anonymous]]
self.hacktable = {};
hacktable.insert('tbl'); |
Any ideas? |
|
Back to top |
|
 |
daspamer Grandmaster Cheater Supreme
Reputation: 54
Joined: 13 Sep 2011 Posts: 1588
|
Posted: Wed May 20, 2015 7:55 am Post subject: |
|
|
Simply save in your server a table format data, like in this format:
global table like hacktable is, we'll just replace it.
Code: | return {
{'UnlimitedAmmo',[[luacall(AobswapC('01 01 01','11 11 11'))]],[[]],[[]], 'false'},
{'UnlimitedHP',[[luacall(AobswapC('02 02 02','22 22 22'))]],[[]],[[]], 'false'}
} |
Then load it up using loadstring,pay attention loadstring will return a function, and because we added the return {...} the function output will be your hack data
Example:
Code: |
local hData = cmdHttpGet([[tiny-url/data.txt]])
function CreateTrainer()
local HackData = {};
function HackData:HacksData()
self.trainer.form.Caption = [[trainer]]
self.trainer.title.Caption = [[trainer]]
self.trainer.credits.Caption = [[by anonymous]]
self.hacktable = loadstring(hData)(); -- call the function returned by loadstring
...
end
-- more secure method incase you dont want it to throw error if you didn't set it up correctly
function sLoadstring(str,callback,escape)
local _status, _func, _error = pcall(loadstring,str)
if (_error) then
return escape(_error);
else
-- load it up
return callback(_func)
end
end
local hData = cmdHttpGet([[tiny-url/data.txt]])
function CreateTrainer()
local HackData = {};
function HackData:HacksData()
self.trainer.form.Caption = [[trainer]]
self.trainer.title.Caption = [[trainer]]
self.trainer.credits.Caption = [[by anonymous]]
self.hacktable = sLoadstring(hData,function (func) return func() end, function (data) print("ERROR FOUND",data) end);
...
end |
_________________
I'm rusty and getting older, help me re-learn lua. |
|
Back to top |
|
 |
rahat How do I cheat?
Reputation: 0
Joined: 11 May 2015 Posts: 9
|
Posted: Wed May 20, 2015 8:46 am Post subject: |
|
|
Thnx very much, works like charm. |
|
Back to top |
|
 |
panraven Grandmaster Cheater
Reputation: 61
Joined: 01 Oct 2008 Posts: 958
|
Posted: Fri May 22, 2015 1:48 pm Post subject: |
|
|
Saw these before got deleted...
rahat wrote: | hmmm,
ran into one short problem with "var = cmdHttpGet([[tiny-url/ammo.txt]])". That, if for some reason host is down, trainer doesn't load while throwing error.
Is there any way to modify it a bit, so if cmdHttpGet function does not get to specified url OR returning output is other then "return{*" then it should check for another url.
Thnx in advance |
...so new code:
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://cheapengine.net]],[[http://cheatengine.org]])
if r ~= nil then
print(type(r),#r)
else
print('error:',errmsg)
end
end
test()
-- test end
-- seperate manual online data loading and default local file loading
function getDataOnline(filename)
return cmdHttpGet(filename,[[your]],[[url]],[[list]])
end
function getDataLocal(filename)
if exist(filename) then
local ok,result = pcall(readFile,filename)
if ok then return result else return nil, result end
end
return getDataOnline(filename)
end |
Last 2 functions is to address Rydian's concern, that probably the trainer should minimize online access.
For example, a [mauanl online load] button is made to load online data only when necessary, while the trainer should load data from a local file by default.
On error handling, these functions should return a string if success, or nil with 2nd return value as error message on something wrong (see test example). |
|
Back to top |
|
 |
rahat How do I cheat?
Reputation: 0
Joined: 11 May 2015 Posts: 9
|
Posted: Tue May 26, 2015 3:28 am Post subject: |
|
|
Code worked at first, then i changed urls to forum.cheatengine/robot.txt & forum.cheatengine/robots.txt and it started throwing error.
I'm trying to accomplish that:
if 1st url does not exist
or take more then 5 sec timeout
or does not contain a certain string in it,
cmdHttpGet should go look 2nd url.
If 2nd url too takes 5+ sec to load or does not have a certain string in it, show a network error.
Also bandwidth isn't a big concern because the hosted table is only a 2kb text file
I removed the question after posting because I wanted to give it hard try myself first and did not wanted to abuse the good help you guys are giving out.
Deeply appreciate the answer tho . |
|
Back to top |
|
 |
panraven Grandmaster Cheater
Reputation: 61
Joined: 01 Oct 2008 Posts: 958
|
Posted: Wed Jul 01, 2015 5:00 pm Post subject: |
|
|
Sorry, not checked this thread.
Add back an 'assert' on opening file in 'readfile', this should make the cmdhttpget script handle common i/o error. But if the error occurs during debugging, it is likely caused by some typo or syntax error... eg. forum.cheatengine/robots.txt is not a proper url.
Add a 'wipefile' function in case the downloaded file need to manually clean up. (set file parameter to nil should not need this)
Code: | function exist(f) return type(f)=='string' and os.rename(f,f) and true or false end
function readFile(f,mode) local r = assert(io.open(f,mode or 'rb')) local ret = r:read('*all') r:close() return ret end
function wipeFile(f) if exist(f) then os.remove(f) 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
-- seperate manual online data loading and default local file loading
function getDataOnline(filename)
return cmdHttpGet(filename,[[your]],[[url]],[[list]])
end
function getDataLocal(filename)
if exist(filename) then
local ok,result = pcall(readFile,filename)
if ok then return result else return nil, result end
end
return getDataOnline(filename)
end |
Quote: | I'm trying to accomplish that:
if 1st url does not exist
or take more then 5 sec timeout
or does not contain a certain string in it,
cmdHttpGet should go look 2nd url. |
Probably a proper socket or http library is better to handle timeout. Currently the script consider there is a network error only if the power-script return some text (it is not reliable).
The following add a check function base on cmdHttpGet
Code: | function cmdHttpGetWithCheck(file,check,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
---------- change start
if type(check) == 'function' then
if check(result) ~= true then
if select('#',...)>0 then result,response = cmdHttpGetWithCheck(file,check...) end
end
end
---------- change end
else -- web error
if select('#',...)>0 then result,response = cmdHttpGetWithCheck(file,check...) end -- try next url if provided
end
if useTmp and exist(file) then os.remove(file) end -- clean tmp file
return result,response
end |
Now the 'check' should be a function, otherwise cmdHttpGetWithCheck should work as cmdHttpGet (with different parameter placement on calling)
The 'check' should be a function taking one string parameter (the result) and return true ONLY if all check is ok.
eg.
Code: |
function checkResult(s)
if type(s)~= 'string' then return false end -- invalidate if not a string
if string.len(s)== 0 then return false end -- empty string
if string.sub(s,1,5)~='Hello' then return false end -- not start with certain characters
if not string.match(s,'Hello') then return false end -- not contains some string
... etc.
return true -- pass all check
end
-- call usage:
local codes = cmdHttpGetWithCheck(nil,checkResult,[[forum.cheatengine.org/robots.txt]],[[forum.cheapengine.org/robot.txt]])
|
bye~ _________________
- Retarded. |
|
Back to top |
|
 |
faizangmc Expert Cheater
Reputation: 0
Joined: 12 Nov 2013 Posts: 167
|
Posted: Thu Jul 02, 2015 6:06 am Post subject: |
|
|
hi, I have been following this thread too. I created a trainer using lua with multilevel pointers. Using the 2nd post in this thread, I added one multilevel pointer of say ammo to a notepad file.
eg
"[[[game.exe+002F15D8]+19c]+14]+26"
I saved this exactly in ammo.txt
then in my trainer script i wrote
ammo = cmdHttpGet([[tiny-url/ammo.txt]])
now i used ammo where i need to read or writeInteger
It worked flawless
No I have 7 other multilevel pointers say for eg hp, weight, height, strenght etc etc
For each one of it have to create seperate txt files. Is there a way, I can upload all mutilevel pointers in just one notepad file?
like for eg
"[[[game.exe+002F15D8]+19c]+14]+26"
"[[[game.exe+002F15D8]+19c]+14]+36"
"[[[game.exe+002F15D8]+19c]+14]+46"
"[[[game.exe+002F15D8]+19c]+14]+56"
and save this data in text file called pointers.txt and upload it n website.
In the above txt 1st line is ammo pointer, 2nd line is hp pointer, 3rd line is strength pointer.
now i use this script in trainer
ammo = cmdHttpGet([[tiny-url/pointers.txt]])
hp = cmdHttpGet([[tiny-url/pointers.txt]])
how do I get lua to set ammo read from 1st line of pointers.txt
and hp to read from 2nd line and strenght to read from 3rd line of the pointers.txt?
Thanks
It will save me from uploading multiple text files for each pointer. |
|
Back to top |
|
 |
Zanzer I post too much
Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Thu Jul 02, 2015 9:58 am Post subject: |
|
|
Code: | for line in io.lines(filename) do
-- some stuff
end |
|
|
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
|
|