|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
Game Hacking Dojo Expert Cheater Reputation: 1
Joined: 17 Sep 2023 Posts: 110
|
Posted: Thu May 02, 2024 6:22 am Post subject: Fixing Signature Pattern Maker |
|
|
I am working on porting my C++ code to Lua. Since I have very little knowledge of Lua I used the help of ChatGPT (So fucking stupid let me tell you. Once I got a reply of "I couldn't count the letters they were hard to see" after me giving a signature pattern and asked to count the letters)
I got this code but it does not work at all.
The premise is that it is given some bytes like in inputText and gives back a perfect signature pattern:
48xxxxxxxx48xxxxxxxxxx48xxxxxx33xxC7xxxxxxxxxxxxxxxxxx33xxC7xxxxxxxxxxxxxxxxxx0FA244xxxx33xx44xxxx41xxxxxxxxxxxx41xxxxxxxxxxxx44xxxx8Bxx33xx8Dxxxx45xxxx0FA241xxxxxxxxxxxx89xxxx
Could you please help me fix it?
Code: | -- Function to generate signature byte pattern
function generateSignatureBytePattern(inputText)
local signatureStream = {}
local lines = inputText:split("\n")
for _, line in ipairs(lines) do
-- Find the position of the hyphen
local hyphenPos = line:find(" - ")
if not hyphenPos then
io.stderr:write("Error: Invalid input format - missing hyphen.\n")
goto continue
end
-- Extract the bytes part after the hyphen
local bytesPart = line:sub(hyphenPos + 3)
-- Remove anything after the bytes part
local bytesEndPos = bytesPart:find(" - ")
if bytesEndPos then
bytesPart = bytesPart:sub(1, bytesEndPos - 1)
end
-- Process bytes part to extract individual bytes
local bytesStream = bytesPart:gmatch("%S+")
local isFirstByte = true
-- Remove spaces
bytesPart = bytesPart:gsub(" ", "")
for byte in bytesStream do
-- Mask the byte if it's not the first byte on the line
if not isFirstByte then
signatureStream[#signatureStream + 1] = ("x"):rep(#byte)
else
if #bytesPart == 2 then
signatureStream[#signatureStream + 1] = "xx"
else
-- Keep the first byte
local firstByte = byte:sub(1, 2)
signatureStream[#signatureStream + 1] = firstByte
end
end
isFirstByte = false
end
-- Output the length of the line (this part is not clear in the original code)
-- signatureStream;
::continue::
end
return table.concat(signatureStream)
end
inputText = [[
ModuleName+9D5A38 - 48 89 5C 24 10 - mov [rsp+10],rbx
ModuleName+9D5A3D - 48 89 74 24 18 - mov [rsp+18],rsi
ModuleName+9D5A42 - 57 - push rdi
ModuleName+9D5A43 - 48 83 EC 10 - sub rsp,10
ModuleName+9D5A47 - 33 C0 - xor eax,eax
ModuleName+9D5A49 - C7 05 D1EF5900 02000000 - mov [ModuleName+F74A24],00000002
ModuleName+9D5A53 - 33 C9 - xor ecx,ecx
ModuleName+9D5A55 - C7 05 C1EF5900 01000000 - mov [ModuleName+F74A20],00000001
ModuleName+9D5A5F - 0FA2 - cpuid
ModuleName+9D5A61 - 44 8B C1 - mov r8d,ecx
ModuleName+9D5A64 - 33 FF - xor edi,edi
ModuleName+9D5A66 - 44 8B CB - mov r9d,ebx
ModuleName+9D5A69 - 41 81 F0 6E74656C - xor r8d,6C65746E
ModuleName+9D5A70 - 41 81 F1 47656E75 - xor r9d,756E6547
ModuleName+9D5A77 - 44 8B D2 - mov r10d,edx
ModuleName+9D5A7A - 8B F0 - mov esi,eax
ModuleName+9D5A7C - 33 C9 - xor ecx,ecx
ModuleName+9D5A7E - 8D 47 01 - lea eax,[rdi+01]
ModuleName+9D5A81 - 45 0B C8 - or r9d,r8d
ModuleName+9D5A84 - 0FA2 - cpuid
ModuleName+9D5A86 - 41 81 F2 696E6549 - xor r10d,49656E69
ModuleName+9D5A8D - 89 04 24 - mov [rsp],eax
]] |
|
|
Back to top |
|
|
AylinCE Grandmaster Cheater Supreme Reputation: 33
Joined: 16 Feb 2017 Posts: 1330
|
Posted: Thu May 02, 2024 8:30 am Post subject: |
|
|
Code: | inputText = [[
ModuleName+9D5A38 - 48 89 5C 24 10 - mov [rsp+10],rbx
ModuleName+9D5A3D - 48 89 74 24 18 - mov [rsp+18],rsi
ModuleName+9D5A42 - 57 - push rdi
ModuleName+9D5A43 - 48 83 EC 10 - sub rsp,10
ModuleName+9D5A47 - 33 C0 - xor eax,eax
ModuleName+9D5A49 - C7 05 D1EF5900 02000000 - mov [ModuleName+F74A24],00000002
ModuleName+9D5A53 - 33 C9 - xor ecx,ecx
ModuleName+9D5A55 - C7 05 C1EF5900 01000000 - mov [ModuleName+F74A20],00000001
ModuleName+9D5A5F - 0FA2 - cpuid
ModuleName+9D5A61 - 44 8B C1 - mov r8d,ecx
ModuleName+9D5A64 - 33 FF - xor edi,edi
ModuleName+9D5A66 - 44 8B CB - mov r9d,ebx
ModuleName+9D5A69 - 41 81 F0 6E74656C - xor r8d,6C65746E
ModuleName+9D5A70 - 41 81 F1 47656E75 - xor r9d,756E6547
ModuleName+9D5A77 - 44 8B D2 - mov r10d,edx
ModuleName+9D5A7A - 8B F0 - mov esi,eax
ModuleName+9D5A7C - 33 C9 - xor ecx,ecx
ModuleName+9D5A7E - 8D 47 01 - lea eax,[rdi+01]
ModuleName+9D5A81 - 45 0B C8 - or r9d,r8d
ModuleName+9D5A84 - 0FA2 - cpuid
ModuleName+9D5A86 - 41 81 F2 696E6549 - xor r10d,49656E69
ModuleName+9D5A8D - 89 04 24 - mov [rsp],eax
]]
-- Function to generate signature byte pattern
function generateSignatureBytePattern(inputText)
local signatureStream = {}
local lines = {}
sl=createStringList()
sl.Text=inputText
for i=0, sl.count -1 do
lines[#lines + 1] = sl[i]
end
sl.Destroy()
for _, line in ipairs(lines) do
hyphenPos1 = line:find(" - ") + 3
hyphenPos3 = line:sub(tonumber(hyphenPos1), hyphenPos1+100)
hyphenPos2 = hyphenPos3:find("-") - 3
hyphenPos4 = line:sub(hyphenPos1, hyphenPos1 + hyphenPos2)
bytesPart = hyphenPos4:sub(1,3)
if bytesPart:find(" ") then
bytesPart1 = hyphenPos4:gsub(" ", "")
byte = #bytesPart1 - 2
signatureStream[#signatureStream + 1] = hyphenPos4:sub(1,2)
signatureStream[#signatureStream + 1] = ("x"):rep(byte)
else
bytesPart1 = hyphenPos4:gsub(" ", "")
signatureStream[#signatureStream + 1] = hyphenPos4:gsub(" ", "")
end
end
return table.concat(signatureStream)
end
aa1 = generateSignatureBytePattern(inputText)
print(aa1) |
result:
48xxxxxxxx48xxxxxxxx5748xxxxxx33xxC7xxxxxxxxxxxxxxxxxx33xxC7xxxxxxxxxxxxxxxxxx0FA244xxxx33xx44xxxx41xxxxxxxxxxxx41xxxxxxxxxxxx44xxxx8Bxx33xx8Dxxxx45xxxx0FA241xxxxxxxxxxxx89xxxx
_________________
|
|
Back to top |
|
|
Game Hacking Dojo Expert Cheater Reputation: 1
Joined: 17 Sep 2023 Posts: 110
|
Posted: Thu May 02, 2024 9:06 am Post subject: |
|
|
Thank you, that is so much better. But there is a one-byte difference. In my version, I masked every single-byte line (push, ret, etc..)
Mine: 48xxxxxxxx48xxxxxxxxxx48xxxxxx33xx
Your: 48xxxxxxxx48xxxxxxxx5748xxxxxx33xx
Could you specify that a single-byte line should also be masked?
I am planning to add this to the "Copy to clipboard" menu option. Do you know how I could do that too?
I want to combine the first option "Bytes+Opcode" with this function in a new entry "Signature Pattern" and get sig copied to the clipboard
Thank you in advance
Description: |
|
Filesize: |
9.07 KB |
Viewed: |
818 Time(s) |
|
|
|
Back to top |
|
|
AylinCE Grandmaster Cheater Supreme Reputation: 33
Joined: 16 Feb 2017 Posts: 1330
|
Posted: Thu May 02, 2024 9:59 am Post subject: |
|
|
Skip a single byte and copy the output OK.
However, since I do not use asm code, I cannot make the contents you add to the other copy.
Maybe you can add it to the copy code or tell me where it is (Bytes+opcodes).
Code: | inputText = [[
ModuleName+9D5A38 - 48 89 5C 24 10 - mov [rsp+10],rbx
ModuleName+9D5A3D - 48 89 74 24 18 - mov [rsp+18],rsi
ModuleName+9D5A42 - 57 - push rdi
ModuleName+9D5A43 - 48 83 EC 10 - sub rsp,10
ModuleName+9D5A47 - 33 C0 - xor eax,eax
ModuleName+9D5A49 - C7 05 D1EF5900 02000000 - mov [ModuleName+F74A24],00000002
ModuleName+9D5A53 - 33 C9 - xor ecx,ecx
ModuleName+9D5A55 - C7 05 C1EF5900 01000000 - mov [ModuleName+F74A20],00000001
ModuleName+9D5A5F - 0FA2 - cpuid
ModuleName+9D5A61 - 44 8B C1 - mov r8d,ecx
ModuleName+9D5A64 - 33 FF - xor edi,edi
ModuleName+9D5A66 - 44 8B CB - mov r9d,ebx
ModuleName+9D5A69 - 41 81 F0 6E74656C - xor r8d,6C65746E
ModuleName+9D5A70 - 41 81 F1 47656E75 - xor r9d,756E6547
ModuleName+9D5A77 - 44 8B D2 - mov r10d,edx
ModuleName+9D5A7A - 8B F0 - mov esi,eax
ModuleName+9D5A7C - 33 C9 - xor ecx,ecx
ModuleName+9D5A7E - 8D 47 01 - lea eax,[rdi+01]
ModuleName+9D5A81 - 45 0B C8 - or r9d,r8d
ModuleName+9D5A84 - 0FA2 - cpuid
ModuleName+9D5A86 - 41 81 F2 696E6549 - xor r10d,49656E69
ModuleName+9D5A8D - 89 04 24 - mov [rsp],eax
]]
-- Function to generate signature byte pattern
function generateSignatureBytePattern(inputText)
local signatureStream = {}
local lines = {}
sl=createStringList()
sl.Text=inputText
for i=0, sl.count -1 do
lines[#lines + 1] = sl[i]
end
sl.Destroy()
for _, line in ipairs(lines) do
hyphenPos1 = line:find(" - ") + 3
hyphenPos3 = line:sub(tonumber(hyphenPos1), hyphenPos1+100)
hyphenPos2 = hyphenPos3:find("-") - 3
hyphenPos4 = line:sub(hyphenPos1, hyphenPos1 + hyphenPos2)
bytesPart = hyphenPos4:sub(1,3)
if bytesPart:find(" ") then
bytesPart1 = hyphenPos4:gsub(" ", "")
byte = #bytesPart1 - 2
if #bytesPart1<3 then
signatureStream[#signatureStream + 1] = ("x"):rep(2)
else
signatureStream[#signatureStream + 1] = hyphenPos4:sub(1,2)
signatureStream[#signatureStream + 1] = ("x"):rep(byte)
end
else
bytesPart1 = hyphenPos4:gsub(" ", "")
signatureStream[#signatureStream + 1] = hyphenPos4:gsub(" ", "")
end
end
return table.concat(signatureStream)
end
aa1 = generateSignatureBytePattern(inputText)
writeToClipboard(aa1) -- copy code
--print(aa1) |
_________________
|
|
Back to top |
|
|
Game Hacking Dojo Expert Cheater Reputation: 1
Joined: 17 Sep 2023 Posts: 110
|
Posted: Thu May 02, 2024 10:05 am Post subject: |
|
|
Hahhaha, now you know what I am talking about.
Edit:
I tweaked it a bit to make it get from the clipboard and output to the clipboard and made a button with a shortcut for it in the main form. But I want to make a new entry in the context menu contained in the "Copy to clipboard" option.
But I don't know how to call "Copy Bytes+Opcodes" and make a wrapper to wrap both functions together to give a "Signature Pattern"
Code: | -- Function to generate signature byte pattern
function generateSignatureBytePattern(inputText)
inputText = readFromClipboard()
local signatureStream = {}
local lines = {}
sl=createStringList()
sl.Text=inputText
for i=0, sl.count -1 do
lines[#lines + 1] = sl[i]
end
sl.Destroy()
for _, line in ipairs(lines) do
hyphenPos1 = line:find(" - ") + 3
hyphenPos3 = line:sub(tonumber(hyphenPos1), hyphenPos1+100)
hyphenPos2 = hyphenPos3:find("-") - 3
hyphenPos4 = line:sub(hyphenPos1, hyphenPos1 + hyphenPos2)
bytesPart = hyphenPos4:sub(1,3)
if bytesPart:find(" ") then
bytesPart1 = hyphenPos4:gsub(" ", "")
byte = #bytesPart1 - 2
if #bytesPart1<3 then -- Mask single-byte lines
signatureStream[#signatureStream + 1] = ("x"):rep(2)
else
signatureStream[#signatureStream + 1] = hyphenPos4:sub(1,2)
signatureStream[#signatureStream + 1] = ("x"):rep(byte)
end
else
bytesPart1 = hyphenPos4:gsub(" ", "")
signatureStream[#signatureStream + 1] = hyphenPos4:gsub(" ", "")
end
end
return writeToClipboard(table.concat(signatureStream)) -- copy result
end |
Description: |
|
Filesize: |
212.82 KB |
Viewed: |
796 Time(s) |
|
|
|
Back to top |
|
|
AylinCE Grandmaster Cheater Supreme Reputation: 33
Joined: 16 Feb 2017 Posts: 1330
|
Posted: Thu May 02, 2024 11:51 am Post subject: |
|
|
I leave the rest to you.
I took "Opcode" from the first line.
Run the code and see the result.
Code: | inputText = [[
ModuleName+9D5A38 - 48 89 5C 24 10 - mov [rsp+10],rbx
ModuleName+9D5A3D - 48 89 74 24 18 - mov [rsp+18],rsi
ModuleName+9D5A42 - 57 - push rdi
ModuleName+9D5A43 - 48 83 EC 10 - sub rsp,10
ModuleName+9D5A47 - 33 C0 - xor eax,eax
ModuleName+9D5A49 - C7 05 D1EF5900 02000000 - mov [ModuleName+F74A24],00000002
ModuleName+9D5A53 - 33 C9 - xor ecx,ecx
ModuleName+9D5A55 - C7 05 C1EF5900 01000000 - mov [ModuleName+F74A20],00000001
ModuleName+9D5A5F - 0FA2 - cpuid
ModuleName+9D5A61 - 44 8B C1 - mov r8d,ecx
ModuleName+9D5A64 - 33 FF - xor edi,edi
ModuleName+9D5A66 - 44 8B CB - mov r9d,ebx
ModuleName+9D5A69 - 41 81 F0 6E74656C - xor r8d,6C65746E
ModuleName+9D5A70 - 41 81 F1 47656E75 - xor r9d,756E6547
ModuleName+9D5A77 - 44 8B D2 - mov r10d,edx
ModuleName+9D5A7A - 8B F0 - mov esi,eax
ModuleName+9D5A7C - 33 C9 - xor ecx,ecx
ModuleName+9D5A7E - 8D 47 01 - lea eax,[rdi+01]
ModuleName+9D5A81 - 45 0B C8 - or r9d,r8d
ModuleName+9D5A84 - 0FA2 - cpuid
ModuleName+9D5A86 - 41 81 F2 696E6549 - xor r10d,49656E69
ModuleName+9D5A8D - 89 04 24 - mov [rsp],eax
]]
local opcd = ""
-- Function to generate signature byte pattern
function generateSignatureBytePattern(inputText)
local signatureStream = {}
local lines = {}
sl=createStringList()
sl.Text=inputText
for i=0, sl.count -1 do
lines[#lines + 1] = sl[i]
end
sl.Destroy()
for _, line in ipairs(lines) do
hyphenPos1 = line:find(" - ") + 3
hyphenPos3 = line:sub(tonumber(hyphenPos1), hyphenPos1+100)
hyphenPos2 = hyphenPos3:find("-") - 3
hyphenPos4 = line:sub(hyphenPos1, hyphenPos1 + hyphenPos2)
if _==1 then
op1 = line:find("+")
op2 = line:find(" - ") -1
opcd = line:sub(op1, op2):gsub(" ", "")
opcd = opcd.." - "..hyphenPos4:gsub(" ", "")
end
bytesPart = hyphenPos4:sub(1,3)
if bytesPart:find(" ") then
bytesPart1 = hyphenPos4:gsub(" ", "")
byte = #bytesPart1 - 2
if #bytesPart1<3 then
signatureStream[#signatureStream + 1] = ("x"):rep(2)
else
signatureStream[#signatureStream + 1] = hyphenPos4:sub(1,2)
signatureStream[#signatureStream + 1] = ("x"):rep(byte)
end
else
bytesPart1 = hyphenPos4:gsub(" ", "")
signatureStream[#signatureStream + 1] = hyphenPos4:gsub(" ", "")
end
end
return table.concat(signatureStream)
end
aa1 = generateSignatureBytePattern(inputText)
opcde = process..opcd
print("Opcode:\n"..opcd)
writeToClipboard(aa1) -- copy code
print("Codes:\n"..aa1)
res = "("..opcde..","..aa1..")"
--writeToClipboard(res)
print("Result1:\n"..res)
-- or
res1 = opcde:match("(.-) %-")
res1 = "("..res1..","..aa1..")"
print("Result2:\n"..res1)
--writeToClipboard(res1) -- copy code |
_________________
|
|
Back to top |
|
|
Game Hacking Dojo Expert Cheater Reputation: 1
Joined: 17 Sep 2023 Posts: 110
|
Posted: Thu May 02, 2024 12:03 pm Post subject: |
|
|
Thank you very much for your help.
I just wonder where can I find information like classes and their objects.
I found that this context menu is an object of the getMemoryViewForm() class and it goes like this:
Code: | getMemoryViewForm().DisassemblerView.PopupMenu |
But I want to know where this is documented. Because I want to get deeper and get more options.
Tell me, if you know.
|
|
Back to top |
|
|
AylinCE Grandmaster Cheater Supreme Reputation: 33
Joined: 16 Feb 2017 Posts: 1330
|
Posted: Thu May 02, 2024 12:33 pm Post subject: |
|
|
copy code: 0~6 options do click
Code: | getMemoryViewForm().DisassemblerView.PopupMenu.Items[11][0].DoClick() |
paste:
chrome.exe+D8220 - E8 05000000 - call chrome.exe+D822A
_________________
|
|
Back to top |
|
|
Game Hacking Dojo Expert Cheater Reputation: 1
Joined: 17 Sep 2023 Posts: 110
|
Posted: Thu May 02, 2024 1:20 pm Post subject: |
|
|
Okay, cool, that did it. But where the hell did you get this information from?
And if I want to add a button like this, what do I do then?
To put my button under "Bytes+Opcodes"
I need documentation so I don't bother you with such things
(Yes, I know this is in the main form)
Code: | local SignuturePatternBtn = createMenuItem(MainForm)
SignuturePatternBtn.Name = 'SignuturePatternBtn'
SignuturePatternBtn.Caption = 'Get Signuture'
SignuturePatternBtn.OnClick = function ()
generateSignatureBytePattern()
end
miExtensions.add(SignuturePatternBtn) |
I did this and it adds it to the main context menu
Code: | local contextMenuClipboardOption = getMemoryViewForm().DisassemblerView.PopupMenu |
This doesn't make CE launch. And probably because the place is not allocated
Code: | local contextMenuClipboardOption = getMemoryViewForm().DisassemblerView.PopupMenu.Items[11][7] |
|
|
Back to top |
|
|
AylinCE Grandmaster Cheater Supreme Reputation: 33
Joined: 16 Feb 2017 Posts: 1330
|
Posted: Thu May 02, 2024 6:07 pm Post subject: |
|
|
Code: | local exsign2 = getMemoryViewForm().DisassemblerView.PopupMenu
local exsign2addrMenuItems=exsign2.Items
if SignuturePatternBtn then SignuturePatternBtn.Destroy() end
SignuturePatternBtn = createMenuItem(exsign2)
SignuturePatternBtn.Name = 'SignuturePatternBtn'
SignuturePatternBtn.Caption = 'Get Signuture'
SignuturePatternBtn.OnClick = function ()
--generateSignatureBytePattern()
getMemoryViewForm().DisassemblerView.PopupMenu.Items[11][0].DoClick()
end
exsign2addrMenuItems.insert(exsign2addrMenuItems.Count-17,SignuturePatternBtn) |
_________________
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 460
Joined: 09 May 2003 Posts: 25330 Location: The netherlands
|
Posted: Fri May 03, 2024 2:28 am Post subject: |
|
|
Code: |
getMemoryViewForm().DisassemblerView.PopupMenu.Items[11][0].DoClick()
|
......
this will break the second another lua script inserts a menuitem to the popupmenu, or when I move stuff around for next version
there's a simpler way:
first get the name of the menuitem:
Code: |
print(getMemoryViewForm().DisassemblerView.PopupMenu.Items[11][0].Name)
|
which in this case returns "copyBytesAndOpcodes" (at least for me)
and that means that you can do:
Code: |
getMemoryViewForm().copyBytesAndOpcodes.DoClick()
|
instead, and won't break as soon as anything changes
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
|
Game Hacking Dojo Expert Cheater Reputation: 1
Joined: 17 Sep 2023 Posts: 110
|
Posted: Fri May 03, 2024 4:44 am Post subject: |
|
|
Thank you guys that worked, of course.
I just don't know where you bring that info from. Funny
Quote: | Code: | getMemoryViewForm().copyBytesAndOpcodes.DoClick() |
|
|
|
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
|
|