Results 1 to 9 of 9

Thread: 12212156 code reverse engineering project in Ghidra

  1. #1
    Fuel Injected!
    Join Date
    Jan 2012
    Location
    Poland
    Posts
    147

    12212156 code reverse engineering project in Ghidra

    Hi!
    I have ported my work on 12212156 OS from IDA to Ghidra, although there's no support for CPU32 tblu commands yet so the disassembly is incomplete, but the C decompiler view is an amazing help with figuring things out.
    Have a look a the project here: https://github.com/dzidaV8/12212156_...ng/tree/master

  2. #2
    Fuel Injected!
    Join Date
    Jan 2018
    Posts
    57
    This is really cool! I heard about Ghidra a while ago but this is what I needed to finally install it and try it. :)

    The C view is great, I always find myself trying to picture C code in my head when looking at assembly in IDA, and having it generated automatically will be a HUGE help.


    I wrote some scripts for IDA that label addresses based on the contents of XDF files, and I think it would be very useful to have equivalents for Ghidra. For example the functions with names like PID_0004 and PID_0005 could have names like PID_CalculatedLoad and PID_EngineCoolantTemperature, and the tables could be named as well. Ghidra is apparently very script-able so I'm sure the same thing is possible.

    My IDA utilities are in the Scripts subdirectory here...
    https://github.com/LegacyNsfw/12593358
    ...and there's a PidList.txt file in the Reference directory.

    If you want to take a shot at making those PowerShell scripts generate something that Ghidra can use, go for it. If not, I'll try it myself in a few days.

  3. #3
    Fuel Injected!
    Join Date
    Jan 2012
    Location
    Poland
    Posts
    147
    Ugh, scripts... Not my kind of thing really.

    I'm trying to figure out the SLEIGH language to add missing CPU32 opcodes, but it makes my head explode...

  4. #4
    Carb and Points!
    Join Date
    Dec 2019
    Posts
    3
    Awesome to see you were posting on here. I stumbled across your request on Ghidra for adding CPU32 support and pointed NSFW towards it too. I was playing with your SLEIGH file for cpu32 and didn't have much luck myself getting it to compile. It would be extremely helpful to get this working with us.

    NSFW, I'll take a look at your powershell scripts. I'm not familiar with powershell but I'm a big linux user, hopefully can figure some of it out, but I've never used IDA PRO lol

    Is there a reason you chose powershell over a platform agnostic scripting language?

  5. #5
    Carb and Points!
    Join Date
    Dec 2019
    Posts
    3
    Few things:
    1) All my XDFs seem to be encrypted, opening them in a text viewer shows nothing but gibberish.

    2) I'm not sure how to export a label list from Ghidra so that I can see the syntax of the file. Not even sure what they call that file at all... I can handle creating a script to port between idc and whatever ghidra uses. Just need to figure out how to export my list of labels I've done on my own decompiling....

    However, with some searching, I stumbled across what looks like someone has already done the work: https://gist.github.com/hax0kartik/e...534aa8de84817c


    If you go to Window -> Script Manager -> ImportSymbolsScript.py, it looks like it'll import a text file in the format for:
    "SYMBOLNAME 0xADDRESS" where each line is a different symbol. Not sure about labeling functions, but I guess we're really just looking for labeling certain labels. Weird that I can't define a type...


    EDIT:

    I apologize for the rubber ducky debugging I do, but I figure some of it might help.
    I figured out how to export symbols in Ghidra.
    Window -> Symbol Table (Command-T is the short cut)
    Select the symbols you want to export, right click, and select export -> CSV file
    Last edited by jonofmac; 01-13-2020 at 07:00 AM.

  6. #6
    Fuel Injected!
    Join Date
    Jan 2018
    Posts
    57
    Quote Originally Posted by jonofmac View Post
    Is there a reason you chose powershell over a platform agnostic scripting language?
    I don't understand the question. :)

    https://docs.microsoft.com/en-us/pow...w=powershell-7

    Also, it's just what I'm familiar with. And it has pretty good support for XML, so parsing XDFs was easy.

  7. #7
    Carb and Points!
    Join Date
    Dec 2019
    Posts
    3
    Quote Originally Posted by NSFW View Post
    I don't understand the question. :)

    https://docs.microsoft.com/en-us/pow...w=powershell-7

    Also, it's just what I'm familiar with. And it has pretty good support for XML, so parsing XDFs was easy.
    I did not realize it was ported to Linux. Never used it on anything but Windows.

    Also as a note, I'm jlvaldez over on pcmhacking, didn't keep my names the same. I'd change them to be consistent if it were possible lol.

    Anyway, I started writing a new script for Ghidra to import the .csv files that it exports symbols in. No idea why it cannot import its own exports out of the box... Anyway, it's not complete, not close to complete, but I got to call it a night and figured it'll get someone going.

    The path to install it is <Ghidra_root>/Features/Python/ghidra_scripts/

    Then go to Window -> Script Manager, select "ImportSymbolsCSV.py" and run it, select a .csv file (I zipped an example .csv file that has 2 symbols for some P59 OS I have). It successfully adds the symbols and changes the data type. This may be something I should get up on some GitHub repository..

    Here's the API I was referring to. Apparently the python interpreter implements jython as well so the APIs are visible to python. Kinda cool.
    From some comments I found on GitHub, FlatProgramAPI and GhidraScript are the two classes that get imported automatically. Seems to be an early python implementation too. Python 2.7ish? 3+ syntax is not working for it.

    https://ghidra.re/ghidra_docs/api/gh...rogramAPI.html
    Attached Files Attached Files
    Last edited by jonofmac; 01-13-2020 at 08:58 AM.

  8. #8
    Fuel Injected!
    Join Date
    Jan 2018
    Posts
    57
    This script will produce a CSV file with all of the names and addresses from an XDF.
    Attached Files Attached Files

  9. #9
    Fuel Injected!
    Join Date
    Jan 2018
    Posts
    57
    This script, with this PidList.txt file, will generate labels for the functions that get the values of all of the pids. I've also included output for the '2156 bin file that I have, however I'm not sure I used the right number of parameters when I ran the script.

    I ran it like this:

    .\Generate-PidLabels.ps1 -Path .\12212156.bin -TableAddress 1F64 -ParameterCount 308 > pidlabels.csv
    Attached Files Attached Files

Similar Threads

  1. 2002 OS 12212156 .xdf
    By dzidaV8 in forum TunerPro OBDII
    Replies: 36
    Last Post: 08-20-2023, 06:01 PM
  2. Help!! 93 Lt1 6M Reverse lockout
    By noeysuarez in forum GM EFI Systems
    Replies: 3
    Last Post: 09-14-2017, 08:17 AM
  3. Replies: 5
    Last Post: 07-07-2016, 11:05 PM
  4. 4l60e reverse boost valve location and procedure
    By JTodd in forum Introductions
    Replies: 1
    Last Post: 04-19-2013, 01:20 AM
  5. T56 reverse lockout options with TBI PCM
    By CDeeZ in forum GM EFI Systems
    Replies: 1
    Last Post: 02-26-2013, 05:06 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •