-
Notifications
You must be signed in to change notification settings - Fork 6
How to find 'debug_logger' function? #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I searched for |
Unfortunately, there isn't a direct way to do that that I know of
That's right, but you only need to find one named function (any will do), and then using that named function you can find Is this a bootloader image or an If it's an If Defined strings is empty, make sure you unpacked it properly with |
image1.out is actual In Window > Defined strings, I tried strings that looks like a function name, there are many potential candidates (GetSingletonInstance, BcmAgentCoreHelper, BcmAmdFlashDevice, BcmArpFilterSnoop, getAPExpAlgInfo), but in all cases when right-click on the string name, and click References > Show references to (name), there are only "Show Reference To Address", not to function name.
As far I understand, it's because Name of public class must match the name of .java file in which it is placed (like public class Foo{} must be placed in Foo.java file). So either I should to rename file from Also, what's not clear with image1.out in Ghidra: part of functions not shown in Symbol Tree pane "Functions" Label: there are misssing FUN_007 label. Why it missing and where is these functions? |
Is there also an
That should probably work as well, try that. If it doesn't work, you can try searching for the function names you see now (see my first comment)
That's exactly what I did, and it fixed it for me too (and the script successfully extracted the function names, so there aren't any other issues). It's probably because the scripts are for an old Ghidra version |
Yes, there is image2. Same size, but different md5. Normally, the second image in cable modem is used as a backup if something happens with image1. I figured they should be identical. But not in this case: they are differs in MD5, and image2 has SIP in its name . I decompressed it |
I didn't know that, for me it's a different size so maybe it varies by router |
I find two functions, |
Ah, I think that's been the issue all along. I found the instructions confusing too, and the screenshots on the page were extremely helpful (albeit still confusing). Here's how I did it:
Once all these are set, hopefully it will finally tell you where those strings are referenced |
I'm confused in the 4 step
Should I select and split here the recos instruction says "Once that’s done, we can add new regions. We can add the BSS as an overlay"? |
Start by splitting
That only exists in the
Here's what I have: Here's the
Your screen looks mostly correct, but there's an off-by-one error, "length" should be what you see in |
I'm not sure if ram length should be specified |
@mediotex The screenshots in the recos article show end, not length, being one off from the |
Ok, got it. I adjusted Memory Map and re-analyzed image. I find function What if that logging function is not available in the code? For example, I can't find in code any strings called |
There are available functions
It's not clear at all what should be renamed there. |
Sorry for the delay, I forgot to check my GitHub notifications
There isn't actually a After you find that one function, then these Judging from your screenshot, you're 99% of the way there - just right-click on |
I don't think so, I got hundreds of functions. Can you show what the function names are on the symbol tree? It should be under
Yes, you can just execute it after they're renamed (but I'm not sure that it worked correctly) |
Not sure, how to expand functions tree to show all. Window > Functions: I have total 31813 functions, but they were already present there (just after I've analyzed image), before I ran the script. From the recos author's web pages appears that there are a few debug_loggers (up to 5?). Also, I have a lot of |
I used the ghidra loader for ecos, and it does all the work. The problem is, When I try to load it using angr framewrok, i could not get the same functions addresses. have anyone of you face the same issue? |
Not sure what you mean...
I meant under "Symbol Tree" (shown in your screenshot), there should be something you can expand called "Labels" The function in your screenshot ( |
From document, chapter "Automated Function Renaming", we can see that there are a few 'debug_logger' names - debug_logger2, debug_logger5, in next pics debug_logger3, debug_logger4: not sure what this mean, but @ecos-wtf explanations are unclear in this point. Here is a function tree expanded. |
Hi ! I was AFK for the last 3 months, I'll look into this in the coming days :) |
btw thanks for making these tools! They've been really helpful for modding my router |
You can put the FIDB files under
All the |
I don't think there were lots of changes between revisions 3.0 and 3.0.2 so most standard functions will be matched by Function ID. The FIDB is built for MIPS targets so make sure that's what your firmware is running on. |
These are just logging functions that were manually renamed during the reversing process. They're named differently because they have different signatures (which the Ghidra script needs to know since it's resolving the log string argument using Ghidra's API). |
Can you expand on that ? Any specific reason you want to use angr rather than Ghidra for this ? |
@mediotex do you need more help with this ? Otherwise I'll close the ticket. |
I will try to rename function tomorrow and answer. |
I'm back to the issue. First of all, there are a vast number of functions designated as FID_conflict:_xxx So I tried to rename function FUN_802da918 BcmAmdFlashDEvice to "debug_logger", then I ran the BcmDebugLogsRenameFunctions script: it renamed 36 functions. Is this what I am supposed to get from these actions? What is the benefit and convenience of this renaming? What did it give me? |
Small or inlined functions can be recognized as corresponding to multiple FIDB signatures, which leads to conflicts. It's not really problematic as it should not affect main standard functions.
Yes. The script renames functions calling debug loggers based on the function name located in the debug string provided to the debug logger. You can double check that this function is indeed called 36 times by tracing cross-references to the now renamed debug_logger. There are other debug logging functions. The more you spot, the more you'll be able to rename functions and understand what's going on.
All reverse engineering work, whether you're looking at raw embedded firmwares or malware starts by renaming functions, renaming variables, infering function signatures, and reconstructing structs. This is done to reduce the cognitive load on the reverser that's trying to understand code paths. From my own experience (and @Anonymous941 apparently), both FIDB and renaming scripts allows for the recovery of approximately 5000 functions (function name and the VTable they're linked to). This leads to easier understanding and analysis of large embedded firmwares. Without this, you're basically trying to find something within 50.000 obfuscated functions. |
@mediotex I think it would help if you could explain what you're trying to achieve with your firmware image and this toolkit. Do you have any experience with reverse engineering ? |
Generally, following this logic, now I need to search for UcdMsgEvent function (as example), find the references to it and rename FUN again? Then search again for some functions, containing debug logging events and repeat. But what if the specific function I'm interested in isn't related to debug logging in any way: these renames just narrow the search by excluding logging functions?
I'm trying to make the firmware more handy by tweaking some features. I have no much experience in reverse engineering, I'm just at the very beginning of my journey. About assigning memory regions in the Memory Map: are there a special cases where we also need to define locations of vectors (common vector, stub entry vector, debug vector, vsr_table, virtual vector table), in addition to .text, .data, .bss and stack? Are their Start / End addresses same for Broadcom chips? |
You misunderstand: whether functions have to do with debug logging doesn't affect this. For testing, certain functions (not sure what decides which functions are included) have strings in them, which are used for crashes. So it makes it easier for Broadcom engineers to debug crashes during development, because it would say, for example, something like
No, rename functions only if you can manually figure out what they do. Then it makes it easier to understand other things
Yes, that's correct
Do you mind making this open source if you end up doing it? I'd be interested to see (kind of) the first softmod for eCos routers, and might even port it to my DDW36C. Also here's an article that might be useful (written by @qkaiser actually), it could be used to give you remote access, and also is an example of modifying this firmware image
I doubt it, these are probably just for other platforms that have these things
I recommend trying this on a smaller scale first, try finding example binaries like in this article and seeing if you can figure out the password. You can also try compiling open source projects and seeing how things correspond to the original source code. This will hopefully give you a better idea of why function names are useful |
Where should be placed the FIDB files (ecos-mips.be.32.fidb and ecos-mips.le.32.fidb) in Ghidra directory?
Also about eCOS Broadcom Function Auto-Renaming (Ghidra) -
BcmDebugLogsRenameFunctions.java
script: how to find 'debug_logger' function in firmware for auto-renaming?The text was updated successfully, but these errors were encountered: