; 详细说明:https://www.autohotkey.com/boards/viewtopic.php?f=6&t=80645 ; 示例一:未注册上传示例 file := "C:\Windows\explorer.exe" ComObjError(false) SetBatchLines -1 Gui, -border -caption +hwndhGui Gui, Show, w0 h0 percents := 0 SetTimer, uploadPercent, 300 f := FileOpen(file, "r") FileSize := f.length SplitPath, file, FileName HTTP := ComObjCreate("WinHTTP.WinHTTPRequest.5.1") HTTP.Open("GET", "https://api.fex.net/api/v1/anonymous/upload-token", true) HTTP.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko") HTTP.SetRequestHeader("Content-Type", "application/json") HTTP.SetRequestHeader("Pragma", "no-cache") HTTP.SetRequestHeader("Cache-Control", "no-cache, no-store") HTTP.SetRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT") HTTP.Send() HTTP.WaitForResponse() RegexMatch(HTTP.ResponseText, "s)""token"":""(.+?)""", match) token := match1 HTTP.Open("POST", "https://api.fex.net/api/v1/anonymous/file", true) HTTP.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko") HTTP.SetRequestHeader("Content-Type", "application/json") HTTP.SetRequestHeader("Authorization","Bearer " token) HTTP.SetRequestHeader("Pragma", "no-cache") HTTP.SetRequestHeader("Cache-Control", "no-cache, no-store") HTTP.SetRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT") HTTP.Send("{""directory_id"":null,""size"":" FileSize ",""name"":""" FileName """}") HTTP.WaitForResponse() if (HTTP.Status = 400) { if InStr(HTTP.ResponseText, """size""") msgbox, file is bigger than 10 gb. else if InStr(HTTP.ResponseText, "<title>400 Bad Request</title>") msgbox, file does not exist. else msgbox % HTTP.ResponseText ExitApp } RegexMatch(HTTP.ResponseText, "s)""anon_upload_link"":""(.+?)"".+?""location"":""(https:.+?):.+?(/.+?)""", match) uploadLink := "https://fex.net/s/" match1, uploadLocation := match2 match3 HTTP.Open("POST", uploadLocation, true) HTTP.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko") HTTP.SetRequestHeader("Content-Type", "application/json") HTTP.SetRequestHeader("Authorization","Bearer " token) HTTP.SetRequestHeader("Fsp-FileName", FileName) HTTP.SetRequestHeader("Fsp-Size", FileSize) HTTP.SetRequestHeader("Fsp-Version", "1.0.0") HTTP.SetRequestHeader("Pragma", "no-cache") HTTP.SetRequestHeader("Cache-Control", "no-cache, no-store") HTTP.SetRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT") HTTP.Send() HTTP.WaitForResponse() chunksize := 4194304 chunks := Ceil(FileSize/chunksize) LastChunkSize := Mod(FileSize, chunksize) loop % chunks { offset := chunksize*(A_Index-1) If (A_Index = chunks) and (LastChunkSize != 0) chunksize := LastChunkSize safeArr := ComObjArray(0x11, chunksize) ; Create SAFEARRAY = VT_ARRAY|VT_UI1 pvData := NumGet(ComObjValue(safeArr) + 12 + (A_PtrSize==8 ? 4 : 0)) ; get pvData memeber f.RawRead(pvData + 0, chunksize) loop { HTTP.Open("PATCH", uploadLocation, true) HTTP.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko") HTTP.SetRequestHeader("Authorization","Bearer " token) HTTP.SetRequestHeader("Content-Type", "application/offset+octet-stream") HTTP.SetRequestHeader("Fsp-FileName", FileName) HTTP.SetRequestHeader("Fsp-Offset", offset) HTTP.SetRequestHeader("Fsp-Version", "1.0.0") HTTP.SetRequestHeader("Pragma", "no-cache") HTTP.SetRequestHeader("Cache-Control", "no-cache, no-store") HTTP.SetRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT") HTTP.Send(safeArr) HTTP.WaitForResponse() if (HTTP.Status = 200) or (HTTP.Status = 204) break if (HTTP.Status = 500) { sleep 1000 continue } loop { HTTP.Open("POST", "https://api.fex.net/api/v1/anonymous/file", true) HTTP.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko") HTTP.SetRequestHeader("Content-Type", "application/json") HTTP.SetRequestHeader("Authorization","Bearer " token) HTTP.SetRequestHeader("Pragma", "no-cache") HTTP.SetRequestHeader("Cache-Control", "no-cache, no-store") HTTP.SetRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT") HTTP.Send("{""directory_id"":null,""size"":" FileSize ",""name"":""" FileName """}") HTTP.WaitForResponse() if (HTTP.Status = 200) break sleep 50 } } count+=100/chunks percents := Format("{1:0.2f}", count) } safeArr := "" f.Close() if InStr(HTTP.ResponseText, "download_url") msgbox % "已存入剪贴板:`n" clipboard := uploadLink else msgbox % "Error`n" HTTP.ResponseText ExitApp uploadPercent: if StrLen(title) > 5 title := "" else title .= "." WinSetTitle, ahk_id %hGui%,, % percents "%" title return ; ========= 示例二:假注册示例(等待确认注册的信件 - waitingTime := 10 秒) ========= file := "C:\Windows\explorer.exe" waitingTime := 10000 ComObjError(false) setbatchlines -1 Gui, -border -caption +hwndhGui Gui, Show, w0 h0 percents := 0 SetTimer, uploadPercent, 300 f := FileOpen(file, "r") FileSize := f.length SplitPath, file, FileName loop { HTTP := ComObjCreate("WinHTTP.WinHTTPRequest.5.1") HTTP.Open("GET", "https://generator.email", true) HTTP.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko") HTTP.SetRequestHeader("Pragma", "no-cache") HTTP.SetRequestHeader("Cache-Control", "no-cache, no-store") HTTP.SetRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT") HTTP.Send() HTTP.WaitForResponse() RegexMatch(HTTP.ResponseText, "s)var gasmurl=""(.+?)"".+?""email_ch_text"">(.+?)<", match) fakeLinkEmail := "https://generator.email" match1, fakeEmail := match2 HTTP.Open("POST", "https://api.fex.net/api/v1/auth/registration-email", true) HTTP.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko") HTTP.SetRequestHeader("Content-Type", "application/json") HTTP.SetRequestHeader("Pragma", "no-cache") HTTP.SetRequestHeader("Cache-Control", "no-cache, no-store") HTTP.SetRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT") HTTP.Send("{""email"":""" fakeEmail """,""password"":""password"",""first_name"":""first_name""}") HTTP.WaitForResponse() if (HTTP.Status = 200) { time := A_TickCount loop { HTTP.Open("GET", fakeLinkEmail, true) HTTP.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko") HTTP.SetRequestHeader("Pragma", "no-cache") HTTP.SetRequestHeader("Cache-Control", "no-cache, no-store") HTTP.SetRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT") HTTP.Send() HTTP.WaitForResponse() RegexMatch(HTTP.ResponseText, "s)https%3A%2F%2Ffex\.net%2Fconfirm%2F(.+?)&", match) if (match1 != "") break 2 if ((A_TickCount - time) > waitingTime) break sleep 50 } } } HTTP.Open("POST", "https://api.fex.net/api/v1/auth/confirm-email/" match1, true) HTTP.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko") HTTP.SetRequestHeader("Content-Type", "application/json") HTTP.SetRequestHeader("Pragma", "no-cache") HTTP.SetRequestHeader("Cache-Control", "no-cache, no-store") HTTP.SetRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT") HTTP.Send() HTTP.WaitForResponse() RegexMatch(HTTP.GetResponseHeader("Set-Cookie"), "s)token=(.+?);", match) token := match1 HTTP.Open("GET", "https://api.fex.net/api/v2/file", true) HTTP.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko") HTTP.SetRequestHeader("Content-Type", "application/json") HTTP.SetRequestHeader("Authorization","Bearer " token) HTTP.SetRequestHeader("Pragma", "no-cache") HTTP.SetRequestHeader("Cache-Control", "no-cache, no-store") HTTP.SetRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT") HTTP.Send() HTTP.WaitForResponse() RegexMatch(HTTP.ResponseText, "s)""id"":(.+?),", match) directory_id := match1 HTTP.Open("POST", "https://api.fex.net/api/v1/file/upload", true) HTTP.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko") HTTP.SetRequestHeader("Content-Type", "application/json") HTTP.SetRequestHeader("Authorization","Bearer " token) HTTP.SetRequestHeader("Pragma", "no-cache") HTTP.SetRequestHeader("Cache-Control", "no-cache, no-store") HTTP.SetRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT") HTTP.Send("{""directory_id"":" directory_id ",""size"":" FileSize ",""name"":""" FileName """}") HTTP.WaitForResponse() if (HTTP.Status = 400) { if InStr(HTTP.ResponseText, """size""") msgbox, file is bigger than 50 gb. else if InStr(HTTP.ResponseText, "<title>400 Bad Request</title>") msgbox, file does not exist. else msgbox % HTTP.ResponseText ExitApp } RegexMatch(HTTP.ResponseText, "s)""location"":""(https:.+?):.+?(/.+?)""", match) uploadLocation := match1 match2 HTTP.Open("POST", uploadLocation, true) HTTP.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko") HTTP.SetRequestHeader("Content-Type", "application/json") HTTP.SetRequestHeader("Authorization","Bearer " token) HTTP.SetRequestHeader("Fsp-FileName", FileName) HTTP.SetRequestHeader("Fsp-Size", FileSize) HTTP.SetRequestHeader("Fsp-Version", "1.0.0") HTTP.SetRequestHeader("Pragma", "no-cache") HTTP.SetRequestHeader("Cache-Control", "no-cache, no-store") HTTP.SetRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT") HTTP.Send() HTTP.WaitForResponse() chunksize := 4194304 chunks := Ceil(FileSize/chunksize) LastChunkSize := Mod(FileSize, chunksize) loop % chunks { offset := chunksize*(A_Index-1) If (A_Index = chunks) and (LastChunkSize != 0) chunksize := LastChunkSize safeArr := ComObjArray(0x11, chunksize) ; Create SAFEARRAY = VT_ARRAY|VT_UI1 pvData := NumGet(ComObjValue(safeArr) + 12 + (A_PtrSize==8 ? 4 : 0)) ; get pvData memeber f.RawRead(pvData + 0, chunksize) loop { HTTP.Open("PATCH", uploadLocation, true) HTTP.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko") HTTP.SetRequestHeader("Authorization","Bearer " token) HTTP.SetRequestHeader("Content-Type", "application/offset+octet-stream") HTTP.SetRequestHeader("Fsp-FileName", FileName) HTTP.SetRequestHeader("Fsp-Offset", offset) HTTP.SetRequestHeader("Fsp-Version", "1.0.0") HTTP.SetRequestHeader("Pragma", "no-cache") HTTP.SetRequestHeader("Cache-Control", "no-cache, no-store") HTTP.SetRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT") HTTP.Send(safeArr) HTTP.WaitForResponse() if (HTTP.Status = 204) break if (HTTP.Status = 200) { RegexMatch(HTTP.ResponseText, "s)""id"":(.+?),.+?""name"":""(.+?)""", match) files_ids := match1, title := match2 break } if (HTTP.Status = 500) { sleep 1000 continue } loop { HTTP.Open("POST", "https://api.fex.net/api/v1/file/upload", true) HTTP.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko") HTTP.SetRequestHeader("Content-Type", "application/json") HTTP.SetRequestHeader("Authorization","Bearer " token) HTTP.SetRequestHeader("Pragma", "no-cache") HTTP.SetRequestHeader("Cache-Control", "no-cache, no-store") HTTP.SetRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT") HTTP.Send("{""directory_id"":" directory_id ",""size"":" FileSize ",""name"":""" FileName """}") HTTP.WaitForResponse() if (HTTP.Status = 200) break sleep 50 } } count+=100/chunks percents := Format("{1:0.2f}", count) } safeArr := "" f.Close() HTTP.Open("POST", "https://api.fex.net/api/v1/file/share", true) HTTP.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko") HTTP.SetRequestHeader("Content-Type", "application/json") HTTP.SetRequestHeader("Authorization","Bearer " token) HTTP.SetRequestHeader("Pragma", "no-cache") HTTP.SetRequestHeader("Cache-Control", "no-cache, no-store") HTTP.SetRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT") HTTP.Send("{""files_ids"":[" files_ids "],""title"":""" title """}") HTTP.WaitForResponse() RegexMatch(HTTP.ResponseText, "s)""link"":""(.+?)""", match) uploadLink := "https://fex.net/s/" match1 msgbox % clipboard := uploadLink ExitApp /* uploadPercent: if StrLen(title) > 5 title := "" else title .= "." WinSetTitle, ahk_id %hGui%,, % percents "%" title return */
声明:站内资源为整理优化好的代码上传分享与学习研究,如果是开源代码基本都会标明出处,方便大家扩展学习路径。请不要恶意搬运,破坏站长辛苦整理维护的劳动成果。本站为爱好者分享站点,所有内容不作为商业行为。如若本站上传内容侵犯了原著者的合法权益,请联系我们进行删除下架。
评论(0)