Title: IDA Pro helper functions Post by: prj on January 25, 2018, 03:14:28 AM Convert range to code (e.g. processrom(0x10000, 0x20000))
Code: import idc Load a2l (e.g. a2l("C:\my.a2l")): Code: def a2l(filename): Parse tricore indirect registers. Will replace ram+offset with actual value, so it can be crossreferenced and maps to a2l (e.g. indirect("a0", 0xDA80)): Code: def indirect(register, address): Should be useful to those who know what they are doing. Title: Re: IDA Pro helper functions Post by: _nameless on January 25, 2018, 06:25:57 AM Thanks
Title: Re: IDA Pro helper functions Post by: gt-innovation on January 25, 2018, 08:03:29 AM This will save so much time. Thanks PRJ. Will this work on any Ida ? 6.8? 7?
Title: Re: IDA Pro helper functions Post by: prj on January 25, 2018, 10:37:34 AM It's python, so ... I think pretty much any version.
Title: Re: IDA Pro helper functions Post by: superglitch on January 25, 2018, 11:18:23 AM This will help greatly! Thank you.
Title: Re: IDA Pro helper functions Post by: IamwhoIam on January 25, 2018, 01:43:27 PM wow!
Title: Re: IDA Pro helper functions Post by: vwaudiguy on January 25, 2018, 02:56:46 PM Thanks, D!
Title: Re: IDA Pro helper functions Post by: jcsbanks on January 25, 2018, 04:31:17 PM Superb, thanks.
The first one in particular solves a big problem :) Title: Re: IDA Pro helper functions Post by: Teitek on January 29, 2018, 04:32:05 PM Great work, thank you prj.
Title: Re: IDA Pro helper functions Post by: prj on February 05, 2018, 08:00:56 AM Realized I posted an old version of the indirect function, updated with newer one - it actually does something now.
Title: Re: IDA Pro helper functions Post by: prj on February 07, 2018, 05:33:16 AM Needed to load some older stuff, so wrote this:
Code: def dam(filename): Title: Re: IDA Pro helper functions Post by: Polo35580 on March 06, 2019, 04:31:34 AM Hello
Great work prj !! I had a "can't rename tail byte" with some measurements. So I added a small Code: idc.MakeUnKnown(int(addr, 0), 1, idaapi.DOUNK_SIMPLE) Code: idc.MakeNameEx(int(addr, 0), name, 1) ps: You need to import idaapi also. Best regards Polo Title: Re: IDA Pro helper functions Post by: fluke9 on October 17, 2019, 12:55:50 PM sorry for threadjacking, dumping my hack also here:
Rudimentary damos parer which will output a python script which can be executed in the ida console, this thing will label variables, also it will create enums for bitfields and apply them to the correct locations. Also names the variables with repeatable comments, your disassembly will then look something like this: Code: 843214 loc_843214: ; CODE XREF: sub_842C26+46E↑j script here, which will generate namebytes.py : Code: #!/usr/bin/python run with: parsedamos.py file.dam > namebytes.py After generating the namebytes.py copy to your ida project dir and execute in the ida console with: execfile("namebytes.py") Title: Re: IDA Pro helper functions Post by: Chipburn on October 28, 2019, 10:20:38 AM Hello there guys,
Im not so good with IDA and python and im a bit puzzled of how exactly i can run the scripts. For example for the first one how can i define min and max ? Does IDA support any interactive way where you can type the variables ? Kind regards. Title: Re: IDA Pro helper functions Post by: nyet on October 28, 2019, 10:40:13 AM Does IDA support any interactive way where you can type the variables ? Yes, of course you can. But the whole point of the tools is to avoid having to do it via UI because GUIs suck for handling large amounts of data that is best handled by automation. Title: Re: IDA Pro helper functions Post by: fluke9 on October 28, 2019, 10:42:53 AM Hello there guys, Im not so good with IDA and python and im a bit puzzled of how exactly i can run the scripts. For example for the first one how can i define min and max ? Does IDA support any interactive way where you can type the variables ? Kind regards. copy script to a file in your disassembly directory as for example script.py then type: execfile("script.py") in the IDA python console afterwards type the functionname and arguments in the console, for example: processrom(0x80000, 0x80FFFF) Title: Re: IDA Pro helper functions Post by: Chipburn on October 28, 2019, 12:53:22 PM Thanks for the replies guys :)
I will try those. I guess i can load them as snippets as well for faster access. Title: Re: IDA Pro helper functions Post by: Chipburn on October 28, 2019, 03:57:54 PM Yes, of course you can. But the whole point of the tools is to avoid having to do it via UI because GUIs suck for handling large amounts of data that is best handled by automation. Thanks Nyet, i was doing the address naming manually etc. What i was asking about "interactive" if you can use a command in the python script that actually popup a window in IDA to define e.g. min max or load a "file" For now i followed fluke9 guide and works marvelous. :D Title: Re: IDA Pro helper functions Post by: sonflasch on October 22, 2020, 12:01:01 PM sorry for threadjacking, dumping my hack also here: Rudimentary damos parer which will output a python script which can be executed in the ida console, this thing will label variables, also it will create enums for bitfields and apply them to the correct locations. Also names the variables with repeatable comments, your disassembly will then look something like this: Code: 843214 loc_843214: ; CODE XREF: sub_842C26+46E↑j script here, which will generate namebytes.py : Code: #!/usr/bin/python run with: parsedamos.py file.dam > namebytes.py After generating the namebytes.py copy to your ida project dir and execute in the ida console with: execfile("namebytes.py") Hello I have a little question. everything works so far but the bit fields are not displayed to me. Enum screen all ok but in the IDA-View i don't see a name your example 843224 jnb word_FD20.B_atmtpk, loc_843270 843228 jnb word_FD7C.B_sa, loc_843270 me look jpg. Title: Re: IDA Pro helper functions Post by: locon on October 22, 2020, 09:25:55 PM Move to address 0xFD70 and press 'M' to assign an Enum entry. Select enum_FD70.
Title: Re: IDA Pro helper functions Post by: sonflasch on October 22, 2020, 10:17:53 PM Move to address 0xFD70 and press 'M' to assign an Enum entry. Select enum_FD70. Ok thanks:-) yes but shouldn't the script do it itself? Title: Re: IDA Pro helper functions Post by: prj on October 23, 2020, 07:53:02 AM Maybe you think the script should give blowjobs too? ;D
Improve it to do that if you want it to do it, and post here the result. Title: Re: IDA Pro helper functions Post by: noice on October 23, 2020, 11:03:33 AM Ok thanks:-) yes but shouldn't the script do it itself? op_enum(0xFD70, 0, get_enum("enum_fd70"), 0) Title: Re: IDA Pro helper functions Post by: browny23 on October 25, 2021, 07:27:29 AM thread revival
hey guys im trying to load a .a2l using the script and i keep getting a line 1 nonetype error Title: Re: IDA Pro helper functions Post by: flamy on November 03, 2022, 08:19:25 AM Here a short script to copy or move bytes from one address to another.
Usage: - Load script via Alt + F7 - Execute script by function call "moveCode(eas, eae, eat, erase)" in Python console Function description: - eas: Start address of code - eae: End address of code - eat: Target address where to put code - erase: 0 = Keep source address space as it is, 1 = Overwrite source address space with "0xFF" Hint: - Make sure that target address space can be overwritten. Function does not check, whether there is already code existing, or not! Title: Re: IDA Pro helper functions Post by: fragolas on November 07, 2022, 04:46:22 PM small script based on prj dam loader, but written to work with ida 7.5
Code: fp = open(r"C:\Users\XXXXXXXXX\MY.dam", errors="ignore") Title: Re: IDA Pro helper functions Post by: flamy on November 08, 2022, 02:55:35 PM Maybe useful for those of you using Keil µVision, I wrote a script to import *.H86 HEX-Files to IDApro.
Usage: - Go to "Hex View" or "IDA View" - Click on the address where to put the content of your *.H86 file - Load script via Alt + F7 - Confirm target address - Select *.H86-file to import Title: Re: IDA Pro helper functions Post by: Blazius on November 08, 2022, 04:17:04 PM Maybe useful for those of you using Keil µVision, I wrote a script to import *.H86 HEX-Files to IDApro. Usage: - Go to "Hex View" or "IDA View" - Click on the address where to put the content of your *.H86 file - Load script via Alt + F7 - Confirm target address - Select *.H86-file to import This might be good. Cheers. Title: Re: IDA Pro helper functions Post by: fragolas on April 05, 2023, 04:46:28 AM i dont know where to put this and i didnt want to start a new thread only because of this so here it goes.
Most of the time the a2l/damos is in german, and when you import it in winols it cumbersome to manualy translate it, so i wrote a simple python script that translates a csv defenition file (from winols export) based on another csv(this could be from a similiar ecu, etc) it needs some work but for the most part it works. Hope its usefull for someone. Code: import csv also for the folder name( this one i have to work a bit more) Code: import csv Title: Re: IDA Pro helper functions Post by: fknbrkn on February 15, 2024, 04:22:55 PM del
Title: Re: IDA Pro helper functions Post by: fknbrkn on February 15, 2024, 04:24:16 PM Ive made a script to find and parse MED17 registers values / addresing and so on
IDA 7.4+ / ida_python required Howto: -load bin with start address, loading address = 0x80000000, tricore cpu -make autoanalyse of pflash segment to get raw code -file -> script file Whats inside: -searching for global registers values (simply assignment) -parse em in code, converts to offset (based on prjs indirect() script) -searching for a9 global register offset -parse direct addressing mode (sometimes not) -handle double pointer offset // this part might be buggy (offset applies until target register assignment with some other value or 'rets') Initial code Code: PFLASH:800F0076 st32.b byte_D000209F, d15 After script apply Code: PFLASH:800F0076 st32.b byte_D000209F, d15 Title: Re: IDA Pro helper functions Post by: fknbrkn on March 06, 2024, 02:27:43 AM Added a2l parser with maps / params / bitfields
Still room of imporvement ofc but no time for that Moved to git https://github.com/fknbrkn/IDA-PRO---MED17-python-script Title: Re: IDA Pro helper functions Post by: prj on March 06, 2024, 04:34:43 AM Bitfields not very useful on tricore because the ones outside the dedicated memory it just uses shifting and extr.u to access them.
So to track them you need a full blown pseudocode generator/decompiler like hexrays or ghidra. Title: Re: IDA Pro helper functions Post by: fknbrkn on March 06, 2024, 07:02:23 AM Bitfields not very useful on tricore because the ones outside the dedicated memory it just uses shifting and extr.u to access them. So to track them you need a full blown pseudocode generator/decompiler like hexrays or ghidra. Well i might be wrong at naming here, i mean bit params b_xxx and mapping it as enums Code: PFLASH:8011479A ld.hu d15, mdns_w ; "Nachstartmoment" Title: Re: IDA Pro helper functions Post by: prj on March 06, 2024, 07:05:20 AM It covers only direct access to bit, not much but something Only a very small amount of memory on TriCore is bit addressable.The rest is not. On modern ECU's there are much more bitfields than can ever fit into the small bit addressable memory. Because of this it needs to do a load, and then using extr.u shift and extract the result. IDA can not follow this at all and there is no hexrays plugin for tricore. Ghidra can with the decompiler... It becomes even worse between two software revisions if some bitfields are moved around. Then the code to access them is different. Of course it's still useful to load the bitfields as enums, but not as useful as it seems on first glance. Title: Re: IDA Pro helper functions Post by: fknbrkn on March 06, 2024, 07:54:31 AM Only a very small amount of memory on TriCore is bit addressable. The rest is not. On modern ECU's there are much more bitfields than can ever fit into the small bit addressable memory. Because of this it needs to do a load, and then using extr.u shift and extract the result. IDA can not follow this at all and there is no hexrays plugin for tricore. Ghidra can with the decompiler... It becomes even worse between two software revisions if some bitfields are moved around. Then the code to access them is different. Of course it's still useful to load the bitfields as enums, but not as useful as it seems on first glance. Ghidra decompiler looks promising Just a bit tricky for ida user, thanks for the input Title: Re: IDA Pro helper functions Post by: prj on March 06, 2024, 08:16:19 AM For fast work IDA is still the best by far.
Ghidra is really clunky to use for many things, but in case of more complex usage, the decompiler is pretty invaluable. Reversing headers and other stuff becomes trivial. Title: Re: IDA Pro helper functions Post by: prometey1982 on September 12, 2024, 04:27:42 PM IDC function for adding indirection XRefs to memory with DPP and extp
Code: static makexrefauto() Title: Re: IDA Pro helper functions Post by: Artemisia on September 23, 2024, 11:21:10 PM A script that generate patterns that can help to identify variable addresses on a slightly different file
You input the segment name in which to search for the variable. The script will load all references of that variable, load 5 instructions before and after each instance. Then it applies wildcards to dynamic operands while keeping the opcode. Generated patterns / sequences are output to the console Works for IDA 7.5, Python 3.8.2 Output example: Code:
Title: Re: IDA Pro helper functions Post by: prometey1982 on October 10, 2024, 12:39:07 AM Updated script to load A2L to IDA. Also contains function to disassemble memory region instead of repeating Ctrl+U C.
Usage: Code: processrom(0x0, 0x80000) # try to disassemble memory from 0x0 to 0x80000 Title: Re: IDA Pro helper functions Post by: prj on October 10, 2024, 03:28:52 AM Updated script to load A2L to IDA. Also contains function to disassemble memory region instead of repeating Ctrl+U C. Usage: Code: processrom(0x0, 0x80000) # try to disassemble memory from 0x0 to 0x80000 I am not sure what you did besides copy-pasting my script form first post into a .py file? Title: Re: IDA Pro helper functions Post by: prometey1982 on October 10, 2024, 06:00:07 AM I am not sure what you did besides copy-pasting my script form first post into a .py file? I'm maintaining this script to support new IDA versions. Also was added functionality to define enums for c167 CPUs. And function to define code and functions by one line command. And this script defines maps too instead of original function. It works well with PowerPC and c167 ECUs. |