Вверх ↑
Ответов: 537
Рейтинг: 14
#1: 2021-05-17 07:01:23 ЛС | профиль | цитата
Помогите загрузить файл на фотохостинг, сделал загрузку как в браузере, получаю ошибку, несоответствие токена, с чем он его сравнивает, не понятно. Смотрел как в браузере загружается, тот токен что в html коде, тот и отправляется для загрузки

Add(MainForm,2953706,112,140)
{
Width=723
Height=559
}
Add(HTTPClient,13545577,168,210)
{
URL="https://www.imagebam.com/"
UserAgent="Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko"
IgnoreInvalidCN=1
IgnoreInvalidDate=1
IgnoreUnknownCA=1
IgnoreWrongUsage=1
IgnoreWeakSignature=1
link(onFinish,481389:doSearch,[])
}
Add(BlockFind,481389,217,217)
{
@Hint=#10:csrf-token|
IncludeBlock=1
StartBlock="<meta name="csrf-token" content=""
EndBlock="""
link(onSearch,16316165:doString,[])
AddHint(-9,-36,62,13,@Hint)
}
Add(FormatStr,16316165,266,217)
{
DataCount=1
Mask="Accept: application/json, text/javascript, */*; q=0.01\r\nX-CSRF-TOKEN: %1"
Point(FString)
link(onFString,6361315:doData,[])
}
Add(HTTPClient,10459769,364,217)
{
URL="https://www.imagebam.com/upload/session"
Method=1
UserAgent="Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko"
EncType=1
IgnoreInvalidCN=1
IgnoreInvalidDate=1
IgnoreUnknownCA=1
IgnoreWrongUsage=1
IgnoreWeakSignature=1
Decompress=1
Point(Headers)
Point(PostData)
link(onFinish,4490939:doAdd,[])
link(Headers,16316165:FString,[(384,205)(345,205)(345,261)(272,261)])
}
Add(DoData,6361315,315,217)
{
link(onEventData,10459769:doLoadString,[])
}
Add(HTTPClient,15388071,518,238)
{
URL="https://www.imagebam.com/upload"
Method=1
UserAgent="Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko"
FileField="files[0]"
IgnoreInvalidCN=1
IgnoreInvalidDate=1
IgnoreUnknownCA=1
IgnoreWrongUsage=1
IgnoreWeakSignature=1
Decompress=1
Point(Headers)
Point(PostData)
Point(UploadFile)
}
Add(Memo,4490939,413,224)
{
Top=35
Width=705
Height=480
ScrollBars=2
}
Add(Button,12260979,112,210)
{
Left=10
Top=5
Caption="Upload"
link(onClick,13545577:doLoadString,[])
}
Пример запросов и ответов с браузера

POST https://www.imagebam.com/upload/session HTTP/1.1
Accept: application/json, text/javascript, */*; q=0.01
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
X-CSRF-TOKEN: bnxalr3ceizYfmnFNCI8sXCvQMVOZEctytMF38xS
X-Requested-With: XMLHttpRequest
Referer: https://www.imagebam.com/
Accept-Language: ru-RU
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko
Host: www.imagebam.com
Content-Length: 57
DNT: 1
Connection: Keep-Alive
Cache-Control: no-cache
Cookie:

thumbnail_size=3&content_type=nsfw&comments_enabled=false

HTTP/1.1 200 OK
Server: nginx
Content-Type: application/json
Connection: keep-alive
Cache-Control: no-cache, private
Date: Mon, 17 May 2021 02:25:55 GMT
Set-Cookie:
X-Server-W: web01
Content-Length: 588

{"data":"eyJpdiI6InFkalNMTXdyMC9rQWpENlRyUUs1dXc9PSIsInZhbHVlIjoiZWthYnhtd1FCaTB6ejE3R1RqYjRWQTN6MHdDWWxZZ0NXS294RUtGZmJKUGFBTXlqaGRuMjFBcE1iSlNlUFpEbXFtallyOXFDNWFCdjduSjQ0ZUtjaUs1QkljU3BTMmZqL3RHTmRpNDltQXhSd21kSE00SVpScTNHbG91eWQ0Mk9DckJzblNIQWJyZWFaTVBsdzM4OWh5ekh2MjExbitMV0Z4Wml6NFdDUVZNZEpVTzRsS3ZzdWdmazUvVkhlQTE0VmxLdnV4L25kZUpSbWJwYmxBZE1MTnBML2JUQzBmekJycXRFWldpY2gzTWxjeTNJS0tacG80N29iNWZRaVFpSE8zMzNWZ05rMG80cktaSWVwTjZSTVE9PSIsIm1hYyI6ImMwZTdjM2IwMDliZDcxMWNhN2NiYjI3YTM5YzAzY2IwNDM4MmM3MTVkMzI0ZDhlMDhmNjhhN2U2NzQ5Njk5OTYifQ==","session":"5c30118a015383ddc01979bb5585ce20"}


POST https://www.imagebam.com/upload HTTP/1.1
Cache-Control: no-cache
Accept: application/json
X-Requested-With: XMLHttpRequest
Content-Type: multipart/form-data; boundary=---------------------------7e564630308
Referer: https://www.imagebam.com/
Accept-Language: ru-RU
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko
Host: www.imagebam.com
Content-Length: 31620
DNT: 1
Connection: Keep-Alive
Cookie:

-----------------------------7e564630308
Content-Disposition: form-data; name="data"

eyJpdiI6InFkalNMTXdyMC9rQWpENlRyUUs1dXc9PSIsInZhbHVlIjoiZWthYnhtd1FCaTB6ejE3R1RqYjRWQTN6MHdDWWxZZ0NXS294RUtGZmJKUGFBTXlqaGRuMjFBcE1iSlNlUFpEbXFtallyOXFDNWFCdjduSjQ0ZUtjaUs1QkljU3BTMmZqL3RHTmRpNDltQXhSd21kSE00SVpScTNHbG91eWQ0Mk9DckJzblNIQWJyZWFaTVBsdzM4OWh5ekh2MjExbitMV0Z4Wml6NFdDUVZNZEpVTzRsS3ZzdWdmazUvVkhlQTE0VmxLdnV4L25kZUpSbWJwYmxBZE1MTnBML2JUQzBmekJycXRFWldpY2gzTWxjeTNJS0tacG80N29iNWZRaVFpSE8zMzNWZ05rMG80cktaSWVwTjZSTVE9PSIsIm1hYyI6ImMwZTdjM2IwMDliZDcxMWNhN2NiYjI3YTM5YzAzY2IwNDM4MmM3MTVkMzI0ZDhlMDhmNjhhN2U2NzQ5Njk5OTYifQ==
-----------------------------7e564630308
Content-Disposition: form-data; name="_token"

bnxalr3ceizYfmnFNCI8sXCvQMVOZEctytMF38xS
-----------------------------7e564630308
Content-Disposition: form-data; name="files[0]"; filename="001_image.gif"
Content-Type: image/gif

Картинка
-----------------------------7e564630308--


HTTP/1.1 200 OK
Server: nginx
Content-Type: application/json
Transfer-Encoding: chunked
Connection: keep-alive
Cache-Control: no-cache, private
Date: Mon, 17 May 2021 02:25:56 GMT
Set-Cookie:
X-Server-W: web01

63
{"success":"https:\/\/www.imagebam.com\/upload\/complete?session=5c30118a015383ddc01979bb5585ce20"}
0



GET https://www.imagebam.com/upload/complete?session=5c30118a015383ddc01979bb5585ce20 HTTP/1.1
Accept: text/html, application/xhtml+xml, */*
Referer: https://www.imagebam.com/
Accept-Language: ru-RU
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko
Accept-Encoding: gzip, deflate
Host: www.imagebam.com
DNT: 1
Connection: Keep-Alive
Cookie:

В ответ получаем html код страницы со ссылками
Нужно разобраться почему сервер присылает, что токен не соответствует
карма: 4

0