未知 的大頭貼

Global shortcut key to create new iTerm window

I’ve always liked GNOME’s (and probably on other Linux desktops as well) feature of launching a terminal window anywhere with a global shortcut key Ctrl+Alt+T , and have configured my MacOS to achieve the same using Apptivate since a long time ago. Somehow it stopped working last week so I looked to fix it and refine the implementation.

I originally used this script /New-iTerm-Window.scpt with Apptivate, but it seems to break with the latest iTerm (iTerm2 3.2.0beta9) in multiple places.

New implementation

Follow the steps in “Creating System-Wide Keyboard Shortcut To Launch Applications" on StackOverflow, replace Step 4 with the following:

  1. Search for “AppleScript", create a “Run AppleScript" action.

  2. Paste the AppleScript as follows:

on run {input, parameters}
    if application "iTerm" is running then
        tell application "iTerm"
            create window with default profile command "/bin/bash -l"
        end tell
    else
        activate application "iTerm"
    end if
end run

Then continue to follow the steps from the Stackoverflow answer.

Now you can remove Apptivate! It’s not needed anymore.

References that have helped me throughout the process:

Bonus: Open new Finder window

Same step as above, but different script:

on run {input, parameters}
    tell application "Finder"
        activate
        set new_window to make new Finder window to home
    end tell
end run

Reference:

Github

These 2 workflows are on Github: https://github.com/pellaeon/Dotfiles/tree/master/workflow

未知 的大頭貼

中國 Android app 常見的混淆方案

最近遇到有趣的 android app 就會用 Mobile Security Framework 來逆向看看,一直以來很少遇到有溷肴的 app ,這次遇到了第一個: https://play.google.com/store/apps/details?id=com.fobwifi.transocks

一開始對他用了什麼溷肴完全沒頭緒,到 lib/ 底下把 native library 的檔名一個一個丟去搜尋就搜尋到東西了,原來用的是騰訊的樂固加殼

至於要怎麼反溷肴(脫殼),大概查到兩種方法。

http://www.holdheart.com/archives/33.html 這篇用 IDA 動態 attach 到運行中的應用程式來 debug ,看起來挺複雜的,原理雖然是大概看得懂但實在懶得自己操作一次。

另一個方法是利用 Xposed 去 hook 解密之後要載入的 dex 檔,有兩個相關專案,支援不同的溷肴方案:

也是第一次聽過 Frida 框架,蠻酷的,各個平臺都可以 instrumentation 。

然後還找到一些相關的資料:

找資料途中遇到有趣但比較不相關的東西:

未知 的大頭貼

臉書動態消息演算法的小測試

我平常用 SocialFixer 插件,可以標示fb文章為已讀,然後下次再顯示的時候就會自動隱藏。剛剛做了點測試: 我一直重複重新整理+標示所有文章為已讀,大概 6 次以後 fb 就幾乎只能不斷顯示已讀的文章,即使我去檢查我其他有按讚的專頁,在最近一天之內有我沒看過的文章,我仍然在動態消息上看不到。

然後我就隨便挑了一個有按讚的粉專的貼文讚,發現動態消息仍然沒有新東西。

所以我推測 fb 的動態消息演算法的運作方式:

  1. 每隔一段時間挑選貼文,加到一個 queue 裡面,這個速率大概是每5分鐘挑選一篇沒看過的貼文
  2. queue 的大小是有限的,也就是說太舊的沒看過的貼文也會被移出 queue
  3. 在平臺上面產生任何互動行為(按讚、留言、分享等等),似乎並不會直接立即影響到動態消息所挑選的內容
  4. 挑選貼文的演算法有些盲點,即使粉專最近有發文,也不一定會被挑選到
  5. 強烈偏好真人帳號產生的內容,朋友發文、回應等等

不過當然實際的運作應該不會這麼簡單。

未知 的大頭貼

不讓 Firefox 一啟動就載入所有分頁

上次評測各種分頁群組相關套件已經有兩個月左右了,後來我開了新的 Firefox Quantum 的 profile 測試 Experimental Simple Tab Groups 插件,沒什麼大問題,就逐漸很習慣地使用 Firefox Quantum 了。事隔兩個月再來做一個盤點,最近到底在用什麼插件。

Experimental Simple Tab Groups -> Simple Tab Groups

沒注意到,後來 Experimental Simple Tab Groups (ESTG) 就停止維護了, addons.mozilla.org 的套件頁面也刪掉了,看來也該轉移到新的 Simple Tab Groups (STG) 了,原本打算用匯出分頁群組的功能備份,然後再匯入新的 Simple Tab Groups ,但不知道為什麼點了匯出沒反應,可能是 user.js 我加了某些特殊設定的關係。

研究了一下,最後發現可以直接到 ESTG 插件的資料夾,把 storage.js 複製到 STG 的資料夾就可以了,兩個資料夾都在 profile 資料夾裡面的 browser-extension-data/ 裡面。(當然要記得備份 profile 資料夾免得出事。

LoadTabOnSelect

STG 還是有個麻煩地方,雖然可以設定離開分頁群組的時候自動 unload 裡面的分頁,但是只要進到某個分頁群組,裡面的所有分頁就會開始自動載入,一次吃掉大量資源。搜尋了一下,找到 STG 的 github 上面有相關的 issue ,推薦 LoadTabOnSelect 這個插件,就點開來安裝了。