Skip to content

Instantly share code, notes, and snippets.

@onewayticket255
Last active February 20, 2020 04:39
Show Gist options
  • Save onewayticket255/82e4fce01a9cbd04df8b1c494512a4ec to your computer and use it in GitHub Desktop.
Save onewayticket255/82e4fce01a9cbd04df8b1c494512a4ec to your computer and use it in GitHub Desktop.
Bypass Twitter's link analysis
#import <dlfcn.h>
#import "substrate.h"
int custom_verify_callback_that_does_not_validate(void *ssl, uint8_t *out_alert){
return 0;
}
void (*original_SSL_set_custom_verify)(void *ssl, int mode, int (*callback)(void *ssl, uint8_t *out_alert));
void replaced_SSL_set_custom_verify(void *ssl, int mode, int (*callback)(void *ssl, uint8_t *out_alert)){
original_SSL_set_custom_verify(ssl, mode, custom_verify_callback_that_does_not_validate);
}
__attribute__((constructor)) static void initialize() {
void* boringssl_handle = dlopen("/usr/lib/libboringssl.dylib", RTLD_NOW);
void* SSL_set_custom_verify = dlsym(boringssl_handle, "SSL_set_custom_verify");
if (SSL_set_custom_verify){
MSHookFunction(SSL_set_custom_verify, replaced_SSL_set_custom_verify, (void **)&original_SSL_set_custom_verify);
}
}
//{ Filter = { Bundles = ( "com.atebits.Tweetie2" ); }; }
//https://api.twitter.com/1.1/dm/user_updates.json
let body = $response.body
body = JSON.parse(body)
if (body['inbox_initial_state']) {
body['inbox_initial_state']['entries'].forEach(element => {
let tmp = element['message']['message_data']['entities']
if (tmp && tmp['urls'] && tmp['urls'].length > 0) {
tmp['urls'].forEach(element2 => {
if (element2['expanded_url']) {
console.log(element2['expanded_url'])
element2['url'] = element2['expanded_url']
}
})
}
})
}
body = JSON.stringify(body)
$done({ body })
//https://api.twitter.com/2/timeline/
let body = $response.body
body = JSON.parse(body)
let tweets = body['globalObjects']['tweets']
let users = body['globalObjects']['users']
//links in tweets
if (Object.keys(tweets).length > 0) {
for (let key in tweets){
//remove ad
if(tweets[key]['source']&&tweets[key]['source']==`<a href="https://ads-api.twitter.com" rel="nofollow">Twitter for Advertisers</a>`){
delete tweets[key]
continue
}
//links
if(tweets[key]['entities']&&tweets[key]['entities']['urls']&&tweets[key]['entities']['urls'].length>0){
tweets[key]['entities']['urls'].forEach(element => {
//exclude retweet
if (element['expanded_url']&&!element['expanded_url'].match("twitter")){
console.log(element['expanded_url'])
element['url'] = element['expanded_url']
}
})
}
}
}
//links in profile
if (Object.keys(users).length > 0) {
for (let key in users){
// link filed
if(users[key]['entities']&&users[key]['entities']['url']){
let realurl=users[key]['entities']['url']['urls'][0]['expanded_url']
console.log("RealURL "+realurl)
users[key]['entities']['url']['urls'][0]['url']=users[key]['entities']['url']['urls'][0]['expanded_url']
users[key]['url']=realurl
}
// links in description
if(users[key]['entities']&&users[key]['entities']['description']&&users[key]['entities']['description']['urls'] && users[key]['entities']['description']['urls'].length > 0){
users[key]['entities']['description']['urls'].forEach(element=>{
if (element['expanded_url']) {
console.log(element['expanded_url'])
element['url'] = element['expanded_url']
}
})
}
}
}
body = JSON.stringify(body)
$done({ body })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment