Friday, 29 September 2017

制造 fb live 时光机







如视频所示, 我可以下载打开 fb 直播之前的 15 分钟剧情 (从少林足球比赛进行中, 倒退 15 分钟 , 能看到刚刚开始集合的剧情。)

有时你打开直播, miss 掉之前重要的画面, 直播后也可能被隐藏或删除, 所以这招很有用。

Bash代码:


# rf: https://stackoverflow.com/questions/12498304/using-bash-to-display-a-progress-working-indicator
progressBarWidth=20
# Function to draw progress bar
progressBar () {

  taskCount="$1"
  tasksDone="$2"
  # Calculate number of fill/empty slots in the bar
  progress=$(echo "$progressBarWidth/$taskCount*$tasksDone" | bc -l)  
  fill=$(printf "%.0f\n" $progress)
  if [ $fill -gt $progressBarWidth ]; then
    fill=$progressBarWidth
  fi
  empty=$(($fill-$progressBarWidth))

  # Percentage Calculation
  percent=$(echo "100/$taskCount*$tasksDone" | bc -l)
  percent=$(printf "%0.2f\n" $percent)
  if [ $(echo "$percent>100" | bc) -gt 0 ]; then
    percent="100.00"
  fi

  # Output to screen
  printf "\r["
  printf "%${fill}s" '' | tr ' ' '#'
  printf "%${empty}s" '' | tr ' ' ' '
  printf "] $percent%% - $text "
}

fb_live_backward () 
{ 
    echo lili;
    ##no nid care if `firefox -no-remote -ProfileManager` then create lolo.default collision, overkill
    cookie_f='/tmp/fb_cookie';
    printf ".mode tabs \n
select host, case when host glob '.*' then 'TRUE' else 'FALSE' end, path, case when isSecure then 'TRUE' else 'FALSE' end, expiry, name, value
from moz_cookies where host = '.facebook.com';" | sqlite3 ~/.mozilla/firefox/*.default/cookies.sqlite > "$cookie_f";
    echo "$cookie_f";
    #echo > "$cookie_f";
    #curl -b "$cookie_f" -vLk "https://www.facebook.com/video/playback/playlist.m3u8?v=$vid" -H 'Host: www.facebook.com' -H 'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:53.0) Gecko/20100101 Firefox/53.0' -H 'Accept: */*' -H 'Accept-Language: en-US,en;q=0.5' --compressed -H 'Referer: https://www.facebook.com/live' -H 'Connection: keep-alive'
    #curl -b "$cookie_f" -vLk 'https://video.fkul8-1.fna.fbcdn.net/hvideo-prn1/v/rvgvfRr3mfgtrG9-5YYe0/live-md/320741391732419.m3u8?_nc_rl=AfACJUPO37BnG6-k&oh=ca49b289cfe55cc22554f06974a11197&oe=597BC9DD'
    vid="$1";
    url="$(curl -b "$cookie_f" -s "https://www.facebook.com/video/playback/playlist.m3u8?v=$vid" -H 'Host: www.facebook.com' -H 'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:53.0) Gecko/20100101 Firefox/53.0' -H 'Accept: */*' -H 'Accept-Language: en-US,en;q=0.5' --compressed -H 'Referer: https://www.facebook.com/live' -H 'Connection: keep-alive'  | tail -1)";
    if [[ $url != http* ]]; then
        echo "url failed";
    else
        curl -b "$cookie_f" -s "$url" | awk '/^#EXTINF/,/ts$/' > /tmp/tss;
        awk 'NR==2' /tmp/tss > /tmp/ts;
        awk 'NR==1 {first = $0} END {print}' /tmp/tss > /tmp/ts2;
        endI2="$(awk 'NR > 1 {print $1}' RS='__-' FS='.ts' /tmp/ts2 | tail -1)";
        endI="$(awk 'NR > 1 {print $1}' RS='__-' FS='.ts' /tmp/ts |  tail -1)";
        echo '###';
        echo "$endI";
        echo "$endI2";
        echo '#####';
        if [[ -z "$endI" || -z "$endI2" ]]; then
            echo "Abort.";
        else
            startI=$(($endI - 300)); #Backward up to 15 minutes * 60 seconds 
            if [ "$startI" -lt "0" ]; then
                startI=0;
            fi;
        fi;
        furl="$(awk -F'__-' '{print $1}' /tmp/ts)";
        startURL="${url%/*}";
        endURL="$(echo "${url##*/}" | awk -F? '{print $NF}')";
        rm /tmp/$vid.mp4 2> /dev/null;
        for n in `seq "$startI" "$endI2"`;
        do
            text=$(echo "Saving to /tmp/$vid.mp4 ..." `ls -lah /tmp/$vid.mp4 2>/dev/null | awk -F " " {'print $5'}` );
            progressBar $(($endI2 - $startI)) $(($n - $startI)) "$text";
            curl -b "$cookie_f" -s "$startURL"'/'"$furl"'__-'"$n"'.ts?'"$endURL" -H 'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:53.0) Gecko/20100101 Firefox/53.0' -H 'Accept: */*' -H 'Accept-Language: en-US,en;q=0.5' --compressed -H 'Referer: https://www.facebook.com/live' -H 'Connection: keep-alive' >> /tmp/$vid.mp4;
        done;
        echo "Download completed :)";
    fi
}



我的一些相关笔记:




虽然这 2017 年的招已经 deprecated, 我也没时间研究 fb 新招, 不过希望可以带给你一点 idea 关于倒退直播的可能性 :D

Wednesday, 30 August 2017

如何 crash 掉你朋友的 facebook app


#国庆日快乐 今天教大家如何 crash 掉你朋友的 facebook app :)


注: 请确保 update 最新的 facebook app (太旧版的没效)   至于 Android 版本, either nougat 和 lollipop 都中, 手头上没 marshmallow test 不过理论上应该一样中。


至于那条 link 是怎样拿的, 就留一手不公开了 :p 自己想 :)

Wednesday, 17 May 2017

在 fb 分享 app 链接的误区。

看到人家在 fb 推介自己的 app,突然间觉得有些话想说。




你按进去看到的不是 google play app, 而是 fb web browser。




解决方法是有的,让我们来做个实验。




按第一条 link(不是按图),你进到的就是 fb web browser。




按 "Install" 就会要求你 login, 不过我发现就算 login 了按 Install 也没反应。(按多几次出现叫我 install 在别的 device 的 dialog... 总之不稳定就是了)
[更新] 现在可以在右上角选在 play store 打开,不过仍然是麻烦, 多了一个步骤。




然而,如果按第二条 link, 就会先跳去 fb web browser 一秒, 再重定向去 google play app。




区别是什么 ? 分享链接的 https 的 s 字啦,丢掉它就可以 liao la。

还有一点,按预览图会直接跑 app(如果已安装),但如果你的目的是希望用户更新,那就应该把预览图关掉。

Tuesday, 16 May 2017

How to fixed - Not able to decompile apk in Ubuntu 17.04

I already knew that Oracle JDK is prefer over than OpenJDK long time ago, and now it give the solution of unable to decompile apk in Ubuntu 17.04.

xb@dnxb:~/Downloads$ java -jar ClassyShark.jar -open app-release.apk 
Exception in thread "main" java.lang.ExceptionInInitializerError
        at java.base/javax.crypto.JceSecurityManager.(JceSecurityManager.java:66)
        at java.base/javax.crypto.Cipher.getConfiguredPermission(Cipher.java:2610)
        at java.base/javax.crypto.Cipher.getMaxAllowedKeyLength(Cipher.java:2634)
        at java.base/sun.security.ssl.CipherSuite$BulkCipher.isUnlimited(CipherSuite.java:602)
        at java.base/sun.security.ssl.CipherSuite$BulkCipher.(CipherSuite.java:574)
        at java.base/sun.security.ssl.CipherSuite$BulkCipher.(CipherSuite.java:460)
        at java.base/sun.security.ssl.CipherSuite.(CipherSuite.java:1074)
        at java.base/sun.security.ssl.SSLContextImpl.getApplicableSupportedCipherSuiteList(SSLContextImpl.java:354)
        at java.base/sun.security.ssl.SSLContextImpl.access$100(SSLContextImpl.java:42)
        at java.base/sun.security.ssl.SSLContextImpl$AbstractTLSContext.(SSLContextImpl.java:590)
        at java.base/java.lang.Class.forName0(Native Method)
        at java.base/java.lang.Class.forName(Class.java:292)
        at java.base/java.security.Provider$Service.getImplClass(Provider.java:1844)
        at java.base/java.security.Provider$Service.newInstance(Provider.java:1820)
        at java.base/sun.security.jca.GetInstance.getInstance(GetInstance.java:236)
        at java.base/sun.security.jca.GetInstance.getInstance(GetInstance.java:164)
        at java.base/javax.net.ssl.SSLContext.getInstance(SSLContext.java:169)
        at okhttp3.OkHttpClient.(OkHttpClient.java:176)
        at okhttp3.OkHttpClient.(OkHttpClient.java:151)
        at retrofit2.Retrofit$Builder.build(Retrofit.java:551)
        at com.google.classyshark.updater.networking.NetworkManager.getGitHubApi(NetworkManager.java:29)
        at com.google.classyshark.updater.networking.AbstractDownloader.checkNewVersion(AbstractDownloader.java:35)
        at com.google.classyshark.updater.UpdateManager.checkVersion(UpdateManager.java:49)
        at com.google.classyshark.updater.UpdateManager.checkVersionGui(UpdateManager.java:45)
        at com.google.classyshark.gui.GuiMode.with(GuiMode.java:42)
        at com.google.classyshark.Main.main(Main.java:44)
Caused by: java.lang.SecurityException: Can not initialize cryptographic mechanism
        at java.base/javax.crypto.JceSecurity.(JceSecurity.java:118)
        ... 26 more
Caused by: java.lang.SecurityException: Can't read cryptographic policy directory: unlimited
        at java.base/javax.crypto.JceSecurity.setupJurisdictionPolicies(JceSecurity.java:324)
        at java.base/javax.crypto.JceSecurity.access$000(JceSecurity.java:73)
        at java.base/javax.crypto.JceSecurity$1.run(JceSecurity.java:109)
        at java.base/javax.crypto.JceSecurity$1.run(JceSecurity.java:106)
        at java.base/java.security.AccessController.doPrivileged(Native Method)
        at java.base/javax.crypto.JceSecurity.(JceSecurity.java:105)
        ... 26 more
xb@dnxb:~/Downloads$ echo $JAVA_HOME #useless :(
/usr/lib/jvm/java-1.9.0-openjdk-amd64
xb@dnxb:~/Downloads$ l /usr/lib/jvm/
total 32K
8792676 lrwxrwxrwx   1 root root ?   24 Mei  25  2016 default-java -> java-1.8.0-openjdk-amd64/
8792674 lrwxrwxrwx   1 root root ?   20 Mac   4 01:46 java-1.8.0-openjdk-amd64 -> java-8-openjdk-amd64/
8792533 -rw-r--r--   1 root root ? 2.7K Mac  17 07:09 .java-1.9.0-openjdk-amd64.jinfo
8792634 lrwxrwxrwx   1 root root ?   20 Mac  17 07:09 java-1.9.0-openjdk-amd64 -> java-9-openjdk-amd64/
8792534 drwxr-xr-x   8 root root ? 4.0K Apr  18 22:31 java-9-openjdk-amd64/
8792677 -rw-r--r--   1 root root ? 2.6K Mei   2 10:51 .java-1.8.0-openjdk-amd64.jinfo
8792673 drwxr-xr-x   7 root root ? 4.0K Mei  12 15:38 java-8-openjdk-amd64/
8792532 drwxr-xr-x   4 root root ? 4.0K Mei  12 15:38 ./
8650757 drwxr-xr-x 169 root root ?  12K Mei  17 02:53 ../
xb@dnxb:~/Downloads$ 
xb@dnxb:~/Downloads$ sudo tar xvzf jdk-8u131-linux-x64.tar.gz -C /usr/lib/jvm #download latest oracle jdk from http://www.oracle.com/technetwork/java/javase/downloads/
jdk1.8.0_131/
jdk1.8.0_131/javafx-src.zip
...
xb@dnxb:~/Downloads$ cat /etc/environment #add JAVA_HOME="/usr/lib/jvm/Your_jdk_directory_name/"
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
JAVA_HOME="/usr/lib/jvm/jdk1.8.0_131/"
xb@dnxb:~/Downloads$ grep '/etc/environment' ~/.bashrc #ensure got `source /etc/environment`, if no, `sudo vim /etc/environment` add that line.
source /etc/environment
xb@dnxb:~/Downloads$ . ~/.bashrc #reload ~/.bashrc
xb@dnxb:~/Downloads$ echo $JAVA_HOME #ensure $JAVA_HOME is printable
/usr/lib/jvm/jdk1.8.0_131/
xb@dnxb:~/Downloads$ sudo update-alternatives --install /usr/bin/java java ${JAVA_HOME%*/}/bin/java 20000 #credit: https://askubuntu.com/a/764914/265303
update-alternatives: using /usr/lib/jvm/jdk1.8.0_131/bin/java to provide /usr/bin/java (java) in auto mode
xb@dnxb:~/Downloads$ sudo update-alternatives --install /usr/bin/javac javac ${JAVA_HOME%*/}/bin/javac 20000
update-alternatives: using /usr/lib/jvm/jdk1.8.0_131/bin/javac to provide /usr/bin/javac (javac) in auto mode
xb@dnxb:~/Downloads$ sudo update-alternatives --config java
There are 3 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                            Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/jdk1.8.0_131/bin/java               20000     auto mode
  1            /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java   1081      manual mode
  2            /usr/lib/jvm/java-9-openjdk-amd64/bin/java       1091      manual mode
  3            /usr/lib/jvm/jdk1.8.0_131/bin/java               20000     manual mode

Press  to keep the current choice[*], or type selection number: 0
xb@dnxb:~/Downloads$ java -version #now it did changed to "1.8.0_131", originally is "9-Ubuntu"
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)
xb@dnxb:~/Downloads$ java -jar ClassyShark.jar -open app-release.apk #now it should works, cheers :)
...
xb@dnxb:~/Downloads$ java -jar /opt/jd-gui/jd-gui-1.4.0.jar <Your class file> #is working too

[UPDATE]: I found this thread, he's right, if I select downgraded version
/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java on `sudo update-alternatives --config java` above, can solve the problem too.