Fast OneDrive Index - A Serverless OneDrive Index Setup - NETSEC

Latest

Learning, Sharing, Creating

Cybersecurity Memo

Tuesday, May 26, 2020

Fast OneDrive Index - A Serverless OneDrive Index Setup

In my previous post 'Using Cloudflare Workers to Deploy A Free Google Drive Directory Indexer in 5 Minutes', I showed a GitHub project GDINDEX. In this post, I am going to show another similar project, but it is for OneDrive - FODI (Fast OneDrive Index) at Github.

It is a serverless program using GitHub page as frontend and using Cloudflare as backend to list your OneDrive files and folders.



I did a quick testing and used it to list my own OneDrive files and folders. Here are some features I like:
1. Fast - listing files and folders is super fast.
2. You can assign it to only show a specific folder.
3. You can add a password on any assigned folder
4. It can preview txt file, photos, audios and videos. (only those popular formats)
5. No need a server (VPS). (You only need a Github account and a Cloudflare account)

Here are all steps we can follow:

    Backend - Cloudflare Workers

    Create a Workers
    Create a workers and paste following contents from https://raw.githubusercontent.com/vcheckzen/FODI/master/back-end-cf/index.js

    Only things you will need to change later are following two:

    • EXPOSE_PATH= ""
    • ONEDRIVE_REFRESHTOKEN = ""

    * EXPOSE_PATH:One Drive folder name which you would like to list. If it is whole folder, you can keep it as is. Else, you need to put it as /music, /video , this kind of format.
    * ONEDRIVE_REFRESHTOKEN: refresh_token which you will get it later. It will be used to log into your OneDrive account.

    Fetch Refresh_Token

    Click this address https://service-36wivxsc-1256127833.ap-hongkong.apigateway.myqcloud.com/release/scf_onedrive_filelistor(Not working anymore)

    New link to get code: https://logi.im/fodi/get-code/. Unfortunately it is only valid for three months. After that, you will get a white screen page from your OneIndex page. You will need to regenerate code and copy them into your Cloudflare workers. This regeneration code step can be finished by Github action. (Please refer this link: https://github.com/spencerwooo/onedrive-cf-index/blob/main/.github/workflows/main.yml)


    You will need to log into your OneDrive and authorize SCF to access your OneDrive.
    You might get an error page once you clicked link. But keep clicking to the link: Get a refresh token
    You will re-direct to a O365 login page. Login in with your O365 account which you want to access its one drive. Accept the premission request frm one_scf.



    Eventually, you will be re-direct to a message page with a refresh_token in a textbox, as shown below.


    Now you can copy this whole refresh_token into your Workers. Save and deploy your workers with a customized name. Write down the workers url , such as https://onedrive.51sec.workers.dev. It will be added into front_end page.



      FrontEnd - Github Page

      Fork FODI project into your Github repository.

      Edit the front_end page , change SCF_GATEWAY to your workers address, which is https://onedrive.51sec.workers.dev

      Publish this page. You are good to go. The web page url will be something like: https://51sec.github.io/FODI/front-end/




        Add Password for a specific folder

        在某个文件夹下添加 .password 文件,里面写入密码,即可加密该文件夹。注意文件必须以 UTF8NoBOM 编码,且密码前后不能有空格或空行,Windows 下可通过以下方式生成:

        在待加密文件夹下按住 Shift 键的同时,鼠标右击文件夹空白处,选择 在此处打开 Powershell 窗口(S),接着执行以下命令,其中 1234 便是密码。
        copy
        • '1234' | Out-File -FilePath .password -Encoding ascii -NoNewline
        YouTube video:




        References












        No comments:

        Post a Comment