Hacking/Modding Love Games

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
User avatar
Inny
Party member
Posts: 652
Joined: Fri Jan 30, 2009 3:41 am
Location: New York

Hacking/Modding Love Games

Post by Inny »

Just for fun, I decided I'd give a try at hacking a Lua game. My mark was veethree's 'Flappy Love', though we really can do this to any game we care to. Here's the code I started with:

Code: Select all

-- conf.lua
function love.conf(t)
  t.title = "hacking-flappylove"
  t.author = "Inny"
  t.version = "0.9.0"
  -- I don't need to paste the rest of this
end

Code: Select all

-- main.lua
local function mydump(mydump, f, t, i, sp)
  if i <= 0 then return end
  for k, v in pairs(t) do
    f:write(sp.."K:"..k.."\n")
    if type(v) == "table" then
	  mydump(mydump, f, v, i-1, sp..' ')
	else
	  f:write(sp.."V:"..tostring(v)..'\n')
	end
  end
end

local function watchme(f)
  love.filesystem.mount("Flappy Love.love", "themark", true)
  local old_require = require
  _G.require = function(m)
    old_require('themark.'..m)
  end
  pcall(require, 'main')
  mydump(mydump, f, _G, 10, '')
end

local f = io.open("example.txt", 'w')
setfenv(watchme, setmetatable({}, { __index = _G }))
print(pcall(watchme, f))
io.close(f)
With the 'Flappy Love.love' file put in my ~\AppData\Roaming\LOVE\hacking-flappylove directory, I was able to dump a bunch of the global environment. At least the names of everything. I bet if I wanted to I could go the step further and gain access to the key names and some values of the local environment using love's debug.getlocal. Also I was looking at chunkspy to see if I could output some code from string.dump outputs.

Anyway, this was my lazy half-hour attempt. I ran out of pizza and lost the will to continue with this.
User avatar
Karai17
Party member
Posts: 930
Joined: Sun Sep 02, 2012 10:46 pm

Re: Hacking/Modding Love Games

Post by Karai17 »

So you executed a love app from within your own love app, and copied out the global environment?

Assuming Flappy Love is not compiled to bytecode, then that exercise is a bit pointless since you already have full access to the source. You should try this on a love app that IS compiled and see if you get any useful data at all.
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+

Dev Blog | GitHub | excessive ❤ moé
User avatar
Inny
Party member
Posts: 652
Joined: Fri Jan 30, 2009 3:41 am
Location: New York

Re: Hacking/Modding Love Games

Post by Inny »

Karai17 wrote:that exercise is a bit pointless since you already have full access to the source. You should try this on a love app that IS compiled and see if you get any useful data at all.
I actually haven't looked at the source of the game yet. I had reached the point where the console was outputting the art assets it was failing at loading, that would be my next logical step: to extract out the images. I was kind of demonstrating some of Lua's basic sandboxing features that we have access to and how they can be used. If you have a suggestion for a closed-source app I can attack, and an author who would grant such permission to me to do so, then yeah, I'd give that a try.
User avatar
Karai17
Party member
Posts: 930
Joined: Sun Sep 02, 2012 10:46 pm

Re: Hacking/Modding Love Games

Post by Karai17 »

I'm unsure of any particular game,s but you're welcome to grab LOVE und PANZER off of my GitHub and compile it to bytecode yourself to test. :)
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+

Dev Blog | GitHub | excessive ❤ moé
User avatar
BulbaMander
Citizen
Posts: 65
Joined: Sat Dec 15, 2012 7:00 pm

Re: Hacking/Modding Love Games

Post by BulbaMander »

Karai17 wrote:So you executed a love app from within your own love app, and copied out the global environment?

Assuming Flappy Love is not compiled to bytecode, then that exercise is a bit pointless since you already have full access to the source. You should try this on a love app that IS compiled and see if you get any useful data at all.
It wouldn't be too pointless if he wanted to make a script that automated play. Let's say the game had an online highscore table somewhere. Instead of trying to get the the table, wouldn't it be theoreticly possible for someone to write a script that monitored global variables, then dumped fake input to stdin (or wherever love takes input) to simulate play, and then get an insanely high score?
It takes an idiot to do cool things. Thats why they're cool. :emo:
User avatar
Karai17
Party member
Posts: 930
Joined: Sun Sep 02, 2012 10:46 pm

Re: Hacking/Modding Love Games

Post by Karai17 »

BulbaMander wrote:
Karai17 wrote:So you executed a love app from within your own love app, and copied out the global environment?

Assuming Flappy Love is not compiled to bytecode, then that exercise is a bit pointless since you already have full access to the source. You should try this on a love app that IS compiled and see if you get any useful data at all.
It wouldn't be too pointless if he wanted to make a script that automated play. Let's say the game had an online highscore table somewhere. Instead of trying to get the the table, wouldn't it be theoreticly possible for someone to write a script that monitored global variables, then dumped fake input to stdin (or wherever love takes input) to simulate play, and then get an insanely high score?
If you have the source for the game, then you can just hard code your score to 99999999999. This "hack" is only useful when you do not have access to code, which is why I suggested trying it on something that is compiled to bytecode.
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+

Dev Blog | GitHub | excessive ❤ moé
User avatar
Doctory
Party member
Posts: 441
Joined: Fri Dec 27, 2013 4:53 pm

Re: Hacking/Modding Love Games

Post by Doctory »

I have been attempting to do this, but this is just.. :rofl: (YAAAAAAA AWESOME)
Post Reply

Who is online

Users browsing this forum: No registered users and 179 guests