<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Заливка файлов на fex.net]]></title>
	<link rel="self" href="http://forum.script-coding.com/extern.php?action=feed&amp;tid=17668&amp;type=atom" />
	<updated>2023-03-12T03:13:44Z</updated>
	<generator>PunBB</generator>
	<id>http://forum.script-coding.com/viewtopic.php?id=17668</id>
		<entry>
			<title type="html"><![CDATA[AHK: Заливка файлов на fex.net]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=157105#p157105" />
			<content type="html"><![CDATA[<p>Размер файлов до 10 гигов без регистрации и до 50 гигов с регистрацией.<br />Файл лежит на хостинге 7 дней.<br />Пример без регистрации:<br /></p><div class="codebox"><pre><code>file := &quot;D:\Sequence 06.mp4&quot;

ComObjError(false)
setbatchlines -1
Gui,  -border -caption +hwndhGui
Gui, Show, w0 h0
percents := 0
SetTimer, uploadPercent, 300
f := FileOpen(file, &quot;r&quot;)
FileSize := f.length
SplitPath, file, FileName

HTTP := ComObjCreate(&quot;WinHTTP.WinHTTPRequest.5.1&quot;)
HTTP.Open(&quot;GET&quot;, &quot;https://api.fex.net/api/v1/anonymous/upload-token&quot;, true)
HTTP.SetRequestHeader(&quot;User-Agent&quot;, &quot;Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko&quot;)
HTTP.SetRequestHeader(&quot;Content-Type&quot;, &quot;application/json&quot;)
HTTP.SetRequestHeader(&quot;Pragma&quot;, &quot;no-cache&quot;)
HTTP.SetRequestHeader(&quot;Cache-Control&quot;, &quot;no-cache, no-store&quot;)
HTTP.SetRequestHeader(&quot;If-Modified-Since&quot;, &quot;Sat, 1 Jan 2000 00:00:00 GMT&quot;)
HTTP.Send()
HTTP.WaitForResponse()
RegexMatch(HTTP.ResponseText, &quot;s)&quot;&quot;token&quot;&quot;:&quot;&quot;(.+?)&quot;&quot;&quot;, match)
token := match1

HTTP.Open(&quot;POST&quot;, &quot;https://api.fex.net/api/v1/anonymous/file&quot;, true)
HTTP.SetRequestHeader(&quot;User-Agent&quot;, &quot;Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko&quot;)
HTTP.SetRequestHeader(&quot;Content-Type&quot;, &quot;application/json&quot;)
HTTP.SetRequestHeader(&quot;Authorization&quot;,&quot;Bearer &quot; token)
HTTP.SetRequestHeader(&quot;Pragma&quot;, &quot;no-cache&quot;)
HTTP.SetRequestHeader(&quot;Cache-Control&quot;, &quot;no-cache, no-store&quot;)
HTTP.SetRequestHeader(&quot;If-Modified-Since&quot;, &quot;Sat, 1 Jan 2000 00:00:00 GMT&quot;)
HTTP.Send(&quot;{&quot;&quot;directory_id&quot;&quot;:null,&quot;&quot;size&quot;&quot;:&quot; FileSize &quot;,&quot;&quot;name&quot;&quot;:&quot;&quot;&quot; FileName &quot;&quot;&quot;}&quot;)
HTTP.WaitForResponse()
if (HTTP.Status = 400)
{
   if InStr(HTTP.ResponseText, &quot;&quot;&quot;size&quot;&quot;&quot;)
      msgbox, file is bigger than 10 gb.
   else if InStr(HTTP.ResponseText, &quot;&lt;title&gt;400 Bad Request&lt;/title&gt;&quot;)
      msgbox, file does not exist.
   else
      msgbox % HTTP.ResponseText
   ExitApp
}
RegexMatch(HTTP.ResponseText, &quot;s)&quot;&quot;anon_upload_link&quot;&quot;:&quot;&quot;(.+?)&quot;&quot;.+?&quot;&quot;location&quot;&quot;:&quot;&quot;(https:.+?):.+?(/.+?)&quot;&quot;&quot;, match)
uploadLink := &quot;https://fex.net/s/&quot; match1, uploadLocation := match2 match3

HTTP.Open(&quot;POST&quot;, uploadLocation, true)
HTTP.SetRequestHeader(&quot;User-Agent&quot;, &quot;Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko&quot;)
HTTP.SetRequestHeader(&quot;Content-Type&quot;, &quot;application/json&quot;)
HTTP.SetRequestHeader(&quot;Authorization&quot;,&quot;Bearer &quot; token)
HTTP.SetRequestHeader(&quot;Fsp-FileName&quot;, FileName)
HTTP.SetRequestHeader(&quot;Fsp-Size&quot;, FileSize)
HTTP.SetRequestHeader(&quot;Fsp-Version&quot;, &quot;1.0.0&quot;)
HTTP.SetRequestHeader(&quot;Pragma&quot;, &quot;no-cache&quot;)
HTTP.SetRequestHeader(&quot;Cache-Control&quot;, &quot;no-cache, no-store&quot;)
HTTP.SetRequestHeader(&quot;If-Modified-Since&quot;, &quot;Sat, 1 Jan 2000 00:00:00 GMT&quot;)
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(&quot;PATCH&quot;, uploadLocation, true)
      HTTP.SetRequestHeader(&quot;User-Agent&quot;, &quot;Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko&quot;)
      HTTP.SetRequestHeader(&quot;Authorization&quot;,&quot;Bearer &quot; token)
      HTTP.SetRequestHeader(&quot;Content-Type&quot;, &quot;application/offset+octet-stream&quot;)
      HTTP.SetRequestHeader(&quot;Fsp-FileName&quot;, FileName)
      HTTP.SetRequestHeader(&quot;Fsp-Offset&quot;, offset)
      HTTP.SetRequestHeader(&quot;Fsp-Version&quot;, &quot;1.0.0&quot;)
      HTTP.SetRequestHeader(&quot;Pragma&quot;, &quot;no-cache&quot;)
      HTTP.SetRequestHeader(&quot;Cache-Control&quot;, &quot;no-cache, no-store&quot;)
      HTTP.SetRequestHeader(&quot;If-Modified-Since&quot;, &quot;Sat, 1 Jan 2000 00:00:00 GMT&quot;)
      HTTP.Send(safeArr)
      HTTP.WaitForResponse()
      if (HTTP.Status = 200) or (HTTP.Status = 204)
         break
      if (HTTP.Status = 500)
      {
         sleep 1000
         continue
      }
      loop
      {
         HTTP.Open(&quot;POST&quot;, &quot;https://api.fex.net/api/v1/anonymous/file&quot;, true)
         HTTP.SetRequestHeader(&quot;User-Agent&quot;, &quot;Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko&quot;)
         HTTP.SetRequestHeader(&quot;Content-Type&quot;, &quot;application/json&quot;)
         HTTP.SetRequestHeader(&quot;Authorization&quot;,&quot;Bearer &quot; token)
         HTTP.SetRequestHeader(&quot;Pragma&quot;, &quot;no-cache&quot;)
         HTTP.SetRequestHeader(&quot;Cache-Control&quot;, &quot;no-cache, no-store&quot;)
         HTTP.SetRequestHeader(&quot;If-Modified-Since&quot;, &quot;Sat, 1 Jan 2000 00:00:00 GMT&quot;)
         HTTP.Send(&quot;{&quot;&quot;directory_id&quot;&quot;:null,&quot;&quot;size&quot;&quot;:&quot; FileSize &quot;,&quot;&quot;name&quot;&quot;:&quot;&quot;&quot; FileName &quot;&quot;&quot;}&quot;)
         HTTP.WaitForResponse()
         if (HTTP.Status = 200)
            break
         sleep 50
      }
   }
   count+=100/chunks
   percents := Format(&quot;{1:0.2f}&quot;, count)
}
safeArr := &quot;&quot;
f.Close()
if InStr(HTTP.ResponseText, &quot;download_url&quot;)
   msgbox % clipboard := uploadLink
else
   msgbox % &quot;Error`n&quot; HTTP.ResponseText
ExitApp


uploadPercent:
if StrLen(title) &gt; 5
   title := &quot;&quot;
else
   title .= &quot;.&quot;
WinSetTitle, ahk_id %hGui%,, % percents &quot;%&quot; title
return</code></pre></div><p>Пример с фейковой регистрацией (время ожидания письма с подтверждением регистрации - waitingTime := 10 секунд.):<br /></p><div class="codebox"><pre><code>file := &quot;D:\Sequence 06.mp4&quot;

waitingTime := 10000
ComObjError(false)
setbatchlines -1
Gui,  -border -caption +hwndhGui
Gui, Show, w0 h0
percents := 0
SetTimer, uploadPercent, 300
f := FileOpen(file, &quot;r&quot;)
FileSize := f.length
SplitPath, file, FileName

loop
{
   HTTP := ComObjCreate(&quot;WinHTTP.WinHTTPRequest.5.1&quot;)
   HTTP.Open(&quot;GET&quot;, &quot;https://generator.email&quot;, true)
   HTTP.SetRequestHeader(&quot;User-Agent&quot;, &quot;Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko&quot;)
   HTTP.SetRequestHeader(&quot;Pragma&quot;, &quot;no-cache&quot;)
   HTTP.SetRequestHeader(&quot;Cache-Control&quot;, &quot;no-cache, no-store&quot;)
   HTTP.SetRequestHeader(&quot;If-Modified-Since&quot;, &quot;Sat, 1 Jan 2000 00:00:00 GMT&quot;)
   HTTP.Send()
   HTTP.WaitForResponse()
   RegexMatch(HTTP.ResponseText, &quot;s)var gasmurl=&quot;&quot;(.+?)&quot;&quot;.+?&quot;&quot;email_ch_text&quot;&quot;&gt;(.+?)&lt;&quot;, match)
   fakeLinkEmail := &quot;https://generator.email&quot; match1, fakeEmail := match2

   HTTP.Open(&quot;POST&quot;, &quot;https://api.fex.net/api/v1/auth/registration-email&quot;, true)
   HTTP.SetRequestHeader(&quot;User-Agent&quot;, &quot;Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko&quot;)
   HTTP.SetRequestHeader(&quot;Content-Type&quot;, &quot;application/json&quot;)
   HTTP.SetRequestHeader(&quot;Pragma&quot;, &quot;no-cache&quot;)
   HTTP.SetRequestHeader(&quot;Cache-Control&quot;, &quot;no-cache, no-store&quot;)
   HTTP.SetRequestHeader(&quot;If-Modified-Since&quot;, &quot;Sat, 1 Jan 2000 00:00:00 GMT&quot;)
   HTTP.Send(&quot;{&quot;&quot;email&quot;&quot;:&quot;&quot;&quot; fakeEmail &quot;&quot;&quot;,&quot;&quot;password&quot;&quot;:&quot;&quot;password&quot;&quot;,&quot;&quot;first_name&quot;&quot;:&quot;&quot;first_name&quot;&quot;}&quot;)
   HTTP.WaitForResponse()
   if (HTTP.Status = 200)
   {
      time := A_TickCount
      loop
      {
         HTTP.Open(&quot;GET&quot;, fakeLinkEmail, true)
         HTTP.SetRequestHeader(&quot;User-Agent&quot;, &quot;Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko&quot;)
         HTTP.SetRequestHeader(&quot;Pragma&quot;, &quot;no-cache&quot;)
         HTTP.SetRequestHeader(&quot;Cache-Control&quot;, &quot;no-cache, no-store&quot;)
         HTTP.SetRequestHeader(&quot;If-Modified-Since&quot;, &quot;Sat, 1 Jan 2000 00:00:00 GMT&quot;)
         HTTP.Send()
         HTTP.WaitForResponse()
         RegexMatch(HTTP.ResponseText, &quot;s)https%3A%2F%2Ffex\.net%2Fconfirm%2F(.+?)&amp;&quot;, match)
         if (match1 != &quot;&quot;)
            break 2
         if ((A_TickCount - time) &gt; waitingTime)
            break
         sleep 50
      }
   }
}

HTTP.Open(&quot;POST&quot;, &quot;https://api.fex.net/api/v1/auth/confirm-email/&quot; match1, true)
HTTP.SetRequestHeader(&quot;User-Agent&quot;, &quot;Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko&quot;)
HTTP.SetRequestHeader(&quot;Content-Type&quot;, &quot;application/json&quot;)
HTTP.SetRequestHeader(&quot;Pragma&quot;, &quot;no-cache&quot;)
HTTP.SetRequestHeader(&quot;Cache-Control&quot;, &quot;no-cache, no-store&quot;)
HTTP.SetRequestHeader(&quot;If-Modified-Since&quot;, &quot;Sat, 1 Jan 2000 00:00:00 GMT&quot;)
HTTP.Send()
HTTP.WaitForResponse()
RegexMatch(HTTP.GetResponseHeader(&quot;Set-Cookie&quot;), &quot;s)token=(.+?);&quot;, match)
token := match1

HTTP.Open(&quot;GET&quot;, &quot;https://api.fex.net/api/v2/file&quot;, true)
HTTP.SetRequestHeader(&quot;User-Agent&quot;, &quot;Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko&quot;)
HTTP.SetRequestHeader(&quot;Content-Type&quot;, &quot;application/json&quot;)
HTTP.SetRequestHeader(&quot;Authorization&quot;,&quot;Bearer &quot; token)
HTTP.SetRequestHeader(&quot;Pragma&quot;, &quot;no-cache&quot;)
HTTP.SetRequestHeader(&quot;Cache-Control&quot;, &quot;no-cache, no-store&quot;)
HTTP.SetRequestHeader(&quot;If-Modified-Since&quot;, &quot;Sat, 1 Jan 2000 00:00:00 GMT&quot;)
HTTP.Send()
HTTP.WaitForResponse()
RegexMatch(HTTP.ResponseText, &quot;s)&quot;&quot;id&quot;&quot;:(.+?),&quot;, match)
directory_id := match1

HTTP.Open(&quot;POST&quot;, &quot;https://api.fex.net/api/v1/file/upload&quot;, true)
HTTP.SetRequestHeader(&quot;User-Agent&quot;, &quot;Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko&quot;)
HTTP.SetRequestHeader(&quot;Content-Type&quot;, &quot;application/json&quot;)
HTTP.SetRequestHeader(&quot;Authorization&quot;,&quot;Bearer &quot; token)
HTTP.SetRequestHeader(&quot;Pragma&quot;, &quot;no-cache&quot;)
HTTP.SetRequestHeader(&quot;Cache-Control&quot;, &quot;no-cache, no-store&quot;)
HTTP.SetRequestHeader(&quot;If-Modified-Since&quot;, &quot;Sat, 1 Jan 2000 00:00:00 GMT&quot;)
HTTP.Send(&quot;{&quot;&quot;directory_id&quot;&quot;:&quot; directory_id &quot;,&quot;&quot;size&quot;&quot;:&quot; FileSize &quot;,&quot;&quot;name&quot;&quot;:&quot;&quot;&quot; FileName &quot;&quot;&quot;}&quot;)
HTTP.WaitForResponse()
if (HTTP.Status = 400)
{
   if InStr(HTTP.ResponseText, &quot;&quot;&quot;size&quot;&quot;&quot;)
      msgbox, file is bigger than 50 gb.
   else if InStr(HTTP.ResponseText, &quot;&lt;title&gt;400 Bad Request&lt;/title&gt;&quot;)
      msgbox, file does not exist.
   else
      msgbox % HTTP.ResponseText
   ExitApp
}
RegexMatch(HTTP.ResponseText, &quot;s)&quot;&quot;location&quot;&quot;:&quot;&quot;(https:.+?):.+?(/.+?)&quot;&quot;&quot;, match)
uploadLocation := match1 match2

HTTP.Open(&quot;POST&quot;, uploadLocation, true)
HTTP.SetRequestHeader(&quot;User-Agent&quot;, &quot;Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko&quot;)
HTTP.SetRequestHeader(&quot;Content-Type&quot;, &quot;application/json&quot;)
HTTP.SetRequestHeader(&quot;Authorization&quot;,&quot;Bearer &quot; token)
HTTP.SetRequestHeader(&quot;Fsp-FileName&quot;, FileName)
HTTP.SetRequestHeader(&quot;Fsp-Size&quot;, FileSize)
HTTP.SetRequestHeader(&quot;Fsp-Version&quot;, &quot;1.0.0&quot;)
HTTP.SetRequestHeader(&quot;Pragma&quot;, &quot;no-cache&quot;)
HTTP.SetRequestHeader(&quot;Cache-Control&quot;, &quot;no-cache, no-store&quot;)
HTTP.SetRequestHeader(&quot;If-Modified-Since&quot;, &quot;Sat, 1 Jan 2000 00:00:00 GMT&quot;)
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(&quot;PATCH&quot;, uploadLocation, true)
      HTTP.SetRequestHeader(&quot;User-Agent&quot;, &quot;Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko&quot;)
      HTTP.SetRequestHeader(&quot;Authorization&quot;,&quot;Bearer &quot; token)
      HTTP.SetRequestHeader(&quot;Content-Type&quot;, &quot;application/offset+octet-stream&quot;)
      HTTP.SetRequestHeader(&quot;Fsp-FileName&quot;, FileName)
      HTTP.SetRequestHeader(&quot;Fsp-Offset&quot;, offset)
      HTTP.SetRequestHeader(&quot;Fsp-Version&quot;, &quot;1.0.0&quot;)
      HTTP.SetRequestHeader(&quot;Pragma&quot;, &quot;no-cache&quot;)
      HTTP.SetRequestHeader(&quot;Cache-Control&quot;, &quot;no-cache, no-store&quot;)
      HTTP.SetRequestHeader(&quot;If-Modified-Since&quot;, &quot;Sat, 1 Jan 2000 00:00:00 GMT&quot;)
      HTTP.Send(safeArr)
      HTTP.WaitForResponse()
      if (HTTP.Status = 204)
         break
      if (HTTP.Status = 200)
      {
         RegexMatch(HTTP.ResponseText, &quot;s)&quot;&quot;id&quot;&quot;:(.+?),.+?&quot;&quot;name&quot;&quot;:&quot;&quot;(.+?)&quot;&quot;&quot;, match)
         files_ids := match1, title := match2
         break
      }
      if (HTTP.Status = 500)
      {
         sleep 1000
         continue
      }
      loop
      {
         HTTP.Open(&quot;POST&quot;, &quot;https://api.fex.net/api/v1/file/upload&quot;, true)
         HTTP.SetRequestHeader(&quot;User-Agent&quot;, &quot;Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko&quot;)
         HTTP.SetRequestHeader(&quot;Content-Type&quot;, &quot;application/json&quot;)
         HTTP.SetRequestHeader(&quot;Authorization&quot;,&quot;Bearer &quot; token)
         HTTP.SetRequestHeader(&quot;Pragma&quot;, &quot;no-cache&quot;)
         HTTP.SetRequestHeader(&quot;Cache-Control&quot;, &quot;no-cache, no-store&quot;)
         HTTP.SetRequestHeader(&quot;If-Modified-Since&quot;, &quot;Sat, 1 Jan 2000 00:00:00 GMT&quot;)
         HTTP.Send(&quot;{&quot;&quot;directory_id&quot;&quot;:&quot; directory_id &quot;,&quot;&quot;size&quot;&quot;:&quot; FileSize &quot;,&quot;&quot;name&quot;&quot;:&quot;&quot;&quot; FileName &quot;&quot;&quot;}&quot;)
         HTTP.WaitForResponse()
         if (HTTP.Status = 200)
            break
         sleep 50
      }
   }
   count+=100/chunks
   percents := Format(&quot;{1:0.2f}&quot;, count)
}
safeArr := &quot;&quot;
f.Close()

HTTP.Open(&quot;POST&quot;, &quot;https://api.fex.net/api/v1/file/share&quot;, true)
HTTP.SetRequestHeader(&quot;User-Agent&quot;, &quot;Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko&quot;)
HTTP.SetRequestHeader(&quot;Content-Type&quot;, &quot;application/json&quot;)
HTTP.SetRequestHeader(&quot;Authorization&quot;,&quot;Bearer &quot; token)
HTTP.SetRequestHeader(&quot;Pragma&quot;, &quot;no-cache&quot;)
HTTP.SetRequestHeader(&quot;Cache-Control&quot;, &quot;no-cache, no-store&quot;)
HTTP.SetRequestHeader(&quot;If-Modified-Since&quot;, &quot;Sat, 1 Jan 2000 00:00:00 GMT&quot;)
HTTP.Send(&quot;{&quot;&quot;files_ids&quot;&quot;:[&quot; files_ids &quot;],&quot;&quot;title&quot;&quot;:&quot;&quot;&quot; title &quot;&quot;&quot;}&quot;)
HTTP.WaitForResponse()
RegexMatch(HTTP.ResponseText, &quot;s)&quot;&quot;link&quot;&quot;:&quot;&quot;(.+?)&quot;&quot;&quot;, match)
uploadLink := &quot;https://fex.net/s/&quot; match1
msgbox % clipboard := uploadLink
ExitApp


uploadPercent:
if StrLen(title) &gt; 5
   title := &quot;&quot;
else
   title .= &quot;.&quot;
WinSetTitle, ahk_id %hGui%,, % percents &quot;%&quot; title
return</code></pre></div><p><a href="http://forum.script-coding.com/viewtopic.php?id=14904">Тема для обсуждения</a></p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2023-03-12T03:13:44Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=157105#p157105</id>
		</entry>
</feed>
