Ripping OAuth tokens out of Twitter apps
timetobleed.com
timetobleed.com
The real meat is the 3rd party's consumer secret (the secret key that goes with their consumer key.) If you're finding those then someone needs to make a South Park ski instructor meme.
The more important thing is the consumer secret itself, which is discussed here: http://stackoverflow.com/questions/4419915/how-to-keep-the-o...
#!/usr/sbin/dtrace
pid$1:$2:free:entry
{
printf("%s: %x\n", probefunc, arg0);
}
would do the trick, I think. dtrace -n 'pid$target::free:entry { printf("%s: %s", probefunc, copyinstr(arg0)); }' -p <pid> invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object v0
invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v0
// Added logging
const-string v1, "PrivateKey"
invoke-static {v1, v0}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I
const-string v1, "UTF8"
invoke-virtual {v0, v1}, Ljava/lang/String;->getBytes(Ljava/lang/String;)[B
move-result-object v0
new-instance v1, Ljavax/crypto/spec/SecretKeySpec;
const-string v2, "HmacSHA1"
invoke-direct {v1, v0, v2}, Ljavax/crypto/spec/SecretKeySpec;-><init>([BLjava/lang/String;)V
D/PrivateKey(18590): XXXXXX
D/Auth Header(18590): OAuth realm="http://api.twitter.com/", oauth_version="1.0", oauth_nonce="2404904914329321765488437936138011", oauth_timestamp="1345512606", oauth_signature="gEvQOcGWO7aPCYTemRy%2BkYH3oFM%3D", oauth_consumer_key="3nVuSoBZnx6U4vzUxf5w", oauth_signature_method="HMAC-SHA1" >>> key = 'Bcs59EFbbsdF6Sl9Ng71smgStWEGwXXKSjYvPVt7qys'
>>> oauth_consumer_key = '3nVuSoBZnx6U4vzUxf5w'
>>> import tweepy
>>> auth = tweepy.OAuthHandler(oauth_consumer_key, key)
>>> auth.get_xauth_access_token('armooo', <password>)
<tweepy.oauth.OAuthToken object at 0x110985810>
>>> api = tweepy.API(auth)
>>> api.update_status('This is an update %s:%s' % (oauth_consumer_key, key))
<tweepy.models.Status object at 0x110985c90>This, for example, goes fishing for MD5 hashes:
/Applications> find *.app/Contents/MacOS -maxdepth 1 -perm 755 -type f -print0 | \
xargs -0 strings | grep '^[0-9a-f]\{32\}$'Which is ridiculous, this being Twitter and all...
Thinking of oauth on the client as any kind of security measure on the client side is absurd anyways, at best it keeps honest people honest and maybe cuts down on signal/noise for the lowest of the low budget spammers.
By its nature, the only way to combat this class of attack is security by obscurity - hence, it should be assumed that OAuth client tokens and client secrets do not provide true protection against unauthorized client applications.
Of course the tokens can be obfuscated, but at some point the tokens must be used in plain-text to sign the OAuth request, and on a device like an iPhone where complete control of execution flow and full address space access is possible (via kernel exploits / jailbreak and a debugger), it's literally impossible to prevent this attack.
Issuing unique per-device device tokens would be an interesting approach, but then a trusted side-band would be necessary to issue the tokens to the device, and a lot of the point of OAuth is moot.
OAuth is still quite useful for user authentication (as to steal per-user tokens requires access to the user's device anyway). Plus, in the other common OAuth use-case (backend to backend), if the consumer token is stolen, your client probably has a larger security issue on their hands that would have allowed the attacker to pose as them anyway.
This is interesting in that it may allow unscrupulous app developers to evade Twitter's new API limits by posing as the Twitter for iOS or Android applications, but I suspect these uses will not be widespread as Twitter can quite probably send a Cease and Desist to Apple or Google and have the offending app removed from the market.
The developer dashboard also makes it really easy to generate an OAuth token for your account, for the application you have created. So just inputting the OAuth token is also an option.
Even if these options are not opened up by an existing Twitter client of choice, one could just use code injection to force this behavior customization.
Twitter can't really filter new applications based on the number of users, either, because I'm sure that there are a number of blogs that use a custom Twitter application to tweet new posts, with the sole user being the website.
Twitter really doesn't have a good way of enforcing its new Display Requirements, or any such policy.
The TOS of all these APIs all say that "you have to keep your Secret secret, or else!", but fundamentally there's no way to really do that, is there?
However, OAuth is indeed a bad way to authenticate for applications that run on devices in the possession of third parties.
Also great for spambots: Twitter can't ban the app because then they had to ban their official Twitter clients.
/edit: have fun
'key': 'Fpl5UUVwvaczUzzpVJ8Rlw'
'secret': 'z73HF21zCz5CaxzDM6M0OPeaCBYGfHUG3FYBgcMB2Y'
'key': '3rJOl1ODzm9yZy63FACdg'
'secret': '5jPoQ5kQvMJFDYRNE8bQ4rHuds4xJqhvgNJM4awaE8'
One is for tweetie 1.0 and the other is for the official twitter client.