Skip to content
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

scanf/printf - detect small strings like "%s" #173

Open
Maijin opened this issue Jun 30, 2019 · 16 comments
Open

scanf/printf - detect small strings like "%s" #173

Maijin opened this issue Jun 30, 2019 · 16 comments

Comments

@Maijin
Copy link
Collaborator

Maijin commented Jun 30, 2019

Actually not sure if regression or if it always happened but notice the scanf when doing aaa / pdd in crackme0x00.exe (r2r/bins/pe/ioli)

scanf (0x404024);

Instead should be:

scanf ("%s", &s1);
@wargio
Copy link
Owner

wargio commented Jul 1, 2019

Hmm maybe a regression. I'll check later

@wargio
Copy link
Owner

wargio commented Jul 2, 2019

fixed scanf with commit 9b27dfd

[0x00401310]> Cs 3 @ 0x404024
[0x00401310]> pdd
/* r2dec pseudo code output */
/* ~/radare2-regressions/bins/pe/crackme0x00.exe @ 0x401310 */
#include <stdint.h>
 
int32_t main (void) {
    int32_t var_1ch;
    char * s1;
    char * s2;
    eax = 0;
    eax += 0xf;
    eax += 0xf;
    eax >>= 4;
    eax <<= 4;
    var_1ch = eax;
    fcn_00402c70 ();
    _main ();
    printf ("IOLI Crackme Level 0x00\n");
    printf ("Password: ");
    eax = &s1;
    scanf ("%s", eax);
    eax = &s1;
    eax = _strcmp (eax, "250382");
    if (eax != 0) {
        printf ("Invalid Password!\n");
    } else {
        printf ("Password OK :)\n");
    }
    eax = 0;
    return eax;
}

@wargio wargio closed this as completed Jul 2, 2019
@Maijin
Copy link
Collaborator Author

Maijin commented Jul 2, 2019

Hum, I still have scanf (0x404024, eax);

@Maijin Maijin reopened this Jul 2, 2019
@radare
Copy link
Contributor

radare commented Jul 2, 2019 via email

@Maijin
Copy link
Collaborator Author

Maijin commented Jul 2, 2019

same result both.

@wargio
Copy link
Owner

wargio commented Jul 3, 2019

@Maijin Cs 3 @ 0x404024
the string is too short to be detected with default options

@Maijin
Copy link
Collaborator Author

Maijin commented Jul 3, 2019

those %XX should be handled by either r2dec or radare2, I think in radare2 it will be hard because of this default option, but r2dec could automatically have some routines to detect %XX strings no?

@wargio
Copy link
Owner

wargio commented Jul 3, 2019

yes i could, but i would like to let the user to choose what to do.

@Maijin
Copy link
Collaborator Author

Maijin commented Jul 3, 2019

Hum how would that be useful for a user to not show scanf/printf format strings 🤔

@wargio
Copy link
Owner

wargio commented Jul 3, 2019

hmmm... i could add that logic, but not so sure how to handle it. for example how about native android logger? should i support that too? it might be complex..

@Maijin
Copy link
Collaborator Author

Maijin commented Jul 3, 2019

Can always start small and enhance later, worth giving it a shot imho because those are very prevalent.

@wargio
Copy link
Owner

wargio commented Jul 3, 2019

okok.

@wargio wargio changed the title scanf display regression in crackme0x00.exe scanf/printf - detect small strings like "%s" Jul 3, 2019
@elicn
Copy link
Contributor

elicn commented Jul 3, 2019

I agree with @wargio, this is a r2 configuration that should be tweaked per user preference.

@Maijin
Copy link
Collaborator Author

Maijin commented Jul 3, 2019

But changing this introduce tons of false positives on radare2 and inherently r2dec side though.

@wargio
Copy link
Owner

wargio commented Jul 3, 2019

what i mean is also on other decompilers you have the user to choose to try to convert an address to string, etc..

@Maijin
Copy link
Collaborator Author

Maijin commented Jul 3, 2019

Sure but those scanf/printf cases work out of the boxes in all other decompilers :p

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants