Jump to content
Daisy123

Reverse of memory dump.

Recommended Posts

Hello everyone. I knew that gg have dumpmemory feature which can copy content of a memory region to a binary file. I wonder if there are any way for copy a binary file to a region of memory. Is is possible to write a lua script with can do this? Thank you very much.
 

b44a40b7f92840500ec5e0b782cd8232.png

Share this post


Link to post
Share on other sites

Yes. You can write script for that.

Share this post


Link to post
Share on other sites
Posted (edited)

Maybe this would be useful,
 

function rwmem(Address, SizeOrBuffer)
	assert(Address ~= nil, "[rwmem]: error, provided address is nil.")
	_rw = {}
	if type(SizeOrBuffer) == "number" then
		_ = ""
		for _ = 1, SizeOrBuffer do _rw[_] = {address = (Address - 1) + _, flags = gg.TYPE_BYTE} end
		for v, __ in ipairs(gg.getValues(_rw)) do _ = _ .. string.format("%02X", __.value & 0xFF) end
		return _
	end
	Byte = {} SizeOrBuffer:gsub("..", function(x) 
		Byte[#Byte + 1] = x _rw[#Byte] = {address = (Address - 1) + #Byte, flags = gg.TYPE_BYTE, value = x .. "h"} 
	end)
	gg.setValues(_rw)
end

-- Usage:
readedMem = rwmem(0xAABBCCDD, 128) -- Read 0xAABBCCDD with 128 size.
rwmem(0xDDCCBBAA, readedMem) -- Write readedMem memory into 0xDDCCBBAA.

 

Edited by saiaapiz

Share this post


Link to post
Share on other sites
Posted (edited)
10 hours ago, saiaapiz said:

Maybe this would be useful,
 


function rwmem(Address, SizeOrBuffer)
	assert(Address ~= nil, "[rwmem]: error, provided address is nil.")
	_rw = {}
	if type(SizeOrBuffer) == "number" then
		_ = ""
		for _ = 1, SizeOrBuffer do _rw[_] = {address = (Address - 1) + _, flags = gg.TYPE_BYTE} end
		for v, __ in ipairs(gg.getValues(_rw)) do _ = _ .. string.format("%02X", __.value & 0xFF) end
		return _
	end
	Byte = {} SizeOrBuffer:gsub("..", function(x) 
		Byte[#Byte + 1] = x _rw[#Byte] = {address = (Address - 1) + #Byte, flags = gg.TYPE_BYTE, value = x .. "h"} 
	end)
	gg.setValues(_rw)
end

-- Usage:
readedMem = rwmem(0xAABBCCDD, 128) -- Read 0xAABBCCDD with 128 size.
rwmem(0xDDCCBBAA, readedMem) -- Write readedMem memory into 0xDDCCBBAA.

 

Thank you very much for this awesome script. I will try to make it work with a binary file as input.

Edited by Daisy123

Share this post


Link to post
Share on other sites

The script will work. The idea is not.
The desired address may not be allocated, or allocated for other needs.
You cannot cut off your hand, then attach it back and hope that it will work as before.

Share this post


Link to post
Share on other sites
3 hours ago, Enyby said:

The script will work. The idea is not.
The desired address may not be allocated, or allocated for other needs.
You cannot cut off your hand, then attach it back and hope that it will work as before.

I dont know if it work or not. I just try doing it. My full idea is: 
In game memory, there are some region to save game code. For example, in a unity game there were a special memory range (which wont change) allocated for Assembly-CSharp.dll. I just search that address for one time only. And then extract that file from game package, edit and reserve dump it to the address which I found before. I completed the lua script for that but the problem now is: that script work fine with small file. But for the bigger file (20MB) GG will crash. Can you give me some cue to increase script performance? I actually want to try doing it even after all it will not work. Please help me. Is the problem at file:read("*a") when read a large file?

reverse_dump.lua

Share this post


Link to post
Share on other sites

Yes. You can not expect read big file to memory completely. Read and write by small chunks.

Share this post


Link to post
Share on other sites
Posted (edited)
13 minutes ago, Enyby said:

Yes. You can not expect read big file to memory completely. Read and write by small chunks.

Thank for your reply .When I try to read and write one by one byte it take really more time for do it even with a small binary file. I need read a bigger chunks than 1 byte but how many is the best choice? 

This is the edited script for read and write one by one byte.

reverse_dump.lua

Edited by Daisy123

Share this post


Link to post
Share on other sites

1 byte is waste of time and resources.

Usually amount must be even 8 or 4 kb.

So try 4096 or 8192, maybe more, like 2*8192.

Share this post


Link to post
Share on other sites

Thank for help me. Finally I wrote a working script. Its still slow when work with large binary file. Please tell me if there are any thing can improve script speed.

reverse_dump.lua

Share this post


Link to post
Share on other sites

Use QWORD, not BYTE, for write data. Write it on every 8 bytes.

You use very inefficient ways to convert string to bytes. One byte per once. Convert all string chunk to table with bytes. And iterate it on loop.

And you do not close files after use, so create resource leak.

Also you do not need gmatch.

[added 0 minutes later]

And you need format code more proper make indent in all possible place or it is hard to read and hard to help you.

[added 1 minute later]
(string.format("%02X",t[i]) .. "h")}

useless part only slow down you.

You can set decimal code to value.

[added 4 minutes later]

And you not clear table t on each iteration.

[added 4 minutes later]

And other vars too.

Share this post


Link to post
Share on other sites
function reverseDump(file, start_address)
	local inp=io.open(file, 'rb')	
	local ad=start_address-1
	while true do
		local _rw={}
		local data=inp:read(8192)
		if data == nil then break end
		local t = data:byte(1, data:len())
		for i=1,#t do
			_rw[i]={address = ad + i, flags = gg.TYPE_BYTE, value=t[i]}
		end
		ad = ad + #t
		gg.setValues(_rw)
		gg.toast(ad-start_address)
	end
	inp:close()
end

Something like that. Not tested.

Share this post


Link to post
Share on other sites
Posted (edited)
33 minutes ago, Enyby said:

local t = data:byte(1, data:len())

I got problem at this. It is not a table. It is a number. Should I put a loop to assign the value to table or are there any better choice?

Edited by Daisy123

Share this post


Link to post
Share on other sites
local t = {data:byte(1, data:len())}

Try this.

Share this post


Link to post
Share on other sites
3 minutes ago, Enyby said:

local t = {data:byte(1, data:len())}

Try this.

Oh it worked. I actually save much time than use loop.

[added 3 minutes later]
48 minutes ago, Enyby said:

Use QWORD, not BYTE, for write data. Write it on every 8 bytes.

If we use 4 byte what happend if the binary have size which is not divide by all for 8?

[added 4 minutes later]

and in that case can I use data:long()

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Similar Content

    • By nfsgamer120
      I just got banned from NFS no limits because I just use a gold hack.I found some YouTubers trying to hack gold in NFS no limits.They use GG to hack NFS NL.Maybe you already know this trick.I am talking about the loading screen hack on NFS NL.If you don't know,you can easily learn this trick by googling.This trick gives you more than 9 million gold to your NFS NL account.So I just found this trick some months ago, but everytime I try it didn't get success so about 5 days ago I just got succeed and I got 7,777,77 million gold on my account.so I played the game without any issue for 5 days and today when I launch the game it says "YOU ARE BANNED" and I just figured out I just got banned from this game.I tried multiple accounts I have but it didn't work.I just try to reinstall the game by apk file that I backup before and even the system doesn't allow me to install it.I just got error saying "app not installed".So I went to play store and installed NFS NL successfully.I didn't download the game data again because I backup it before uninstallation.After the installation done I just moved my backed up game data folder to NFS NL game folder.After that I launched the game and it still saying "YOU ARE BANNED".I tried parallel space with multiple accounts but it still gives me this message.At this point I just feel now it's enough.Does any one know how can I get my account unbanned.I really need my saved data.Please help me if anyone know how to solve this issue, thanks.Sorry if my english is bad.🙂
       
      🔽More Info🔽
      Device: Xiaomi Mi A2 64GB,4GB 
      OperatingSystem: Androidone Android 9.0 Pie with November 5 security update 2019.
      Game: Need For Speed No Limits Version 4.0.3 (58551)
      Reason: Banned Account to get unban.
      Date: 2019 Dec 4                                            ________________________________________
    • By ItsKatelynKate
      So I've been trying to hack a game on Roblox called "Royale High", i was trying to hack the game in order to give myself diamonds but whenever i search a random value (because idk what value the diamonds have) the game either freezes as in i can't move my character and camera but everything else is fine, or there are multiple values ans not the right one.
      Can someone help me please?? ;-;
    • By RkR25
      Hey! 
      I playing the game "panther online" I download game guardian, and parallel space. But i don't know how do a cods, free colldown skills. Can you help me, explain me how do a cods, hackers there tell me with cods can't need download a apk mod, in game guardian wab, but i not find. 
      Waiting for answer. Thank you!  
    • By 5G_Controller
      I have the code
      prompt = gg.prompt({"infor1","infor2"},nil,{"number","number"})
      I do a searchNumber for 'infor1' and modify it to 'infor2'
      after i launched the script, how could I save the numbers that I put in 'infor1' and 'infor2' in the prompt?
      Tks
    • By 5G_Controller
      how to create a script that can open URLs in chorm browser 
       
×
×
  • Create New...