The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,854 other subscribers

Need to write a bookmarklet that strips a Twitter URL down to the canonical form without s= and t= parameters (or maybe easier: no parameters at all)

Posted by jpluimers on 2023/12/12

Based on these tweets, I want to write a bookmarklet that at least removes the s= and t= parameters from Twitter URLs, maybe even all parameters (TODO: figure out if there are useful Twitter URL parameters first):

Even Jack Dorsey didn’t know they were introduced when he was still Twitter CEO. From the tweets below:

  1. The s parameter seems to have to have to do with both the kind of sharing and the type of client used.
  2. The t parameter could correlate with the user ID.

There is a sort of bookmarklet below which goes through an external web-site (search for “unfurl”), but I want to do it purely client-side.

On the t parameter

On the s parameter

Observed values from the above tweets:

  • s=10
  • s=19 from Android mobile devices
  • s=20 from Windows devices
  • s=21 from iOS devices
  • s=42
  • s=46 from iPhone (copy)

Full s value list and better idea on the t parameter

From the “gopher” link above you can see that [Wayback/Archive] Unfurl v2022.11: Social Media Edition has a full list of all the s= values:

S PARAMETER SHARED FROM
01 an Android using SMS
02 an Android using Email
03 an Android using Gmail
04 an Android using Facebook
05 an Android using WeChat
06 an Android using Line
07 an Android using FBMessenger
08 an Android using WhatsApp
09 an Android using Other
10 iOS using Messages or SMS
11 iOS using Email
12 iOS using Other
13 an Android using Download
14 iOS using Download
15 an Android using Hangouts
16 an Android using Twitter DM
17 Twitter Web using Email
18 Twitter Web using Download
19 an Android using Copy
20 Twitter Web using Copy
21 iOS using Copy
22 iOS using Snapchat
23 an Android using Snapchat
24 iOS using WhatsApp
25 iOS using FBMessenger
26 iOS using Facebook
27 iOS using Gmail
28 iOS using Telegram
29 iOS using Line
30 iOS using Viber
31 an Android using Slack
32 an Android using Kakao
33 an Android using Discord
34 an Android using Reddit
35 an Android using Telegram
36 an Android using Instagram
37 an Android using Daum
38 iOS using Instagram
39 iOS using LinkedIn
40 an Android using LinkedIn
41 Gryphon using Copy
42 an iPhone using SMS
43 an iPhone using Email
44 an iPhone using Other
45 an iPhone using Download
46 an iPhone using Copy
47 an iPhone using Snapchat
48 an iPhone using WhatsApp
49 an iPhone using FBMessenger
50 an iPhone using Facebook
51 an iPhone using Gmail
52 an iPhone using Telegram
53 an iPhone using Line
54 an iPhone using Viber
55 an iPhone using Instagram
56 an iPhone using LinkedIn
57 an iPad using SMS
58 an iPad using Email
59 an iPad using Other
60 an iPad using Download
61 an iPad using Copy
62 an iPad using Snapchat
63 an iPad using WhatsApp
64 an iPad using FBMessenger
65 an iPad using Facebook
66 an iPad using Gmail
67 an iPad using Telegram
68 an iPad using Line
69 an iPad using Viber
70 an iPad using Instagram
71 an iPad using LinkedIn

and also has this (which correlates with the reverse engineering below):

I don’t think anyone outside of Twitter knows exactly how the t parameter is constructed, but from my observations it appears consistent per device for a time. I shared tweets via numerous methods in August from my phone and the t was consistently the same. I did similar tests again in November, and the t value was again the same for different sharing methods, but it was different than from August. Maybe a software update or some other change on the device caused a change in the t “fingerprint”? With this in mind, I think seeing the same t values on multiple links suggests the same device was the sharing source. However, different t values could still be from the same device, just over a longer time period.

Reverse engineering to understand the URL parameters

This is a cool start of a long thread: [Wayback/Archive] 闩长丂廾闩ㄚ on Twitter: “Let’s reverse Twitter App (LIVE)” / Twitter

[Wayback/Archive] Ian Coldwater on Twitter: “it’s Saturday morning so I’m reverse engineering Twitter for funsies, as one does” / Twitter

The full thread is at [Wayback/Archive] Thread by @onosmosis_ on Thread Reader App, with some highlights (and especially links to tools used):

  • Let’s look at an actual Twitter Share link from my web client: twitter.com/64_BlT/status/1573724090816667648?s=20&t=KEFyG5hyGQnxyUuILUGbDw
  • We could reverse the Twitter web app with relative ease, but I decided to go with the Android app as I’ve worked with them in the past. I have downloaded the latest Twitter app (APK) and used JadX and loaded the APK.
  • JadX is a dex to java ‘decompiler’ that works equally well for APK files:
  • On L#68. we can see the match. This looks promising because it appears to be the one we’re looking for (syntax-wise).
  • We also got a clue that ‘t’ must correspond to the ‘timecode’
  • Now that we know that ‘t’ must be a timecode, we can search for ‘timecode’ or similar strings. However, it being a generic term, I’ll skip it for now, but will revisit this once I’ve explored it further.
  • The numbers t/3600, t × 3600/60 and %60 are coincidentally the math one would do to convert a value to seconds, minutes and hours.
  • Clue/Inference #3: This ‘t’ value corresponds to some timestamp value encoded via a possibly reversible way such that Twitter can when the tweet was shared (externally) and when it is being viewed.
  • After all, this provides 2 valuable pieces of information to Twitter:
  • By seeing when the Tweet was shared outside and when the Tweet is being viewed and comparing the time (at the server-side), Twitter can know:
    1. a) when a Tweet goes viral,
    2. b) Which tweets are popular,
    3. c) If an old or new tweet that’s getting some attention and using share time.
  • *3 pieces of information

So it might be that the t= parameter is just an obfuscated time code to correlate session timestamps and for instance optimise timeline generation.

Stripping the URL parameters (some solutions work for any URL with parameters)

In addition to the above Python script by Nat Friedman (which only works on MacOS as it depends on [Wayback/Archive] pasteboard · PyPI) many replies to the above tweets included tips or tools for stripping URL parameters. Some of them (including Nat’s one):

[Wayback/Archive] Unfurl v2022.11: Social Media Edition

[Wayback/Archive] Twitter parser – full list for the sharing code parameter · Issue #162 · obsidianforensics/unfurl

[Wayback/Archive] abs.twimg.com/responsive-web/client-web/main.ea5f3cf9.js (search for ,71:)

  • [Wayback/Archive] obsidianforensics/unfurl: Extract and Visualize Data from URLs using Unfurl

    1. There is an online version at https://dfir.blog/unfurl. Visit that page, enter the URL in the form, and click ‘Unfurl!’.
    2. You can also access the online version using a bookmarklet – create a new bookmark and paste javascript:window.location.href='https://dfir.blog/unfurl/?url='+window.location.href; as the location. Then when on any page with an interesting URL, you can click the bookmarklet and see the URL “unfurled”.

    Note I modified the Bookmarklet into javascript:open('https://dfir.blog/unfurl/?url='+window.location.href); which translates twitter.com/64_BlT/status/1573724090816667648?s=20&t=KEFyG5hyGQnxyUuILUGbDw into https://dfir.blog/unfurl/?url=https://twitter.com/onosmosis_/status/1573724090816667648?s=20&t=KEFyG5hyGQnxyUuILUGbDw.

  • [Wayback/Archive] dfir.blog/unfurl

More generic comments on URL parameters and privacy

Queries

–jeroen


Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.