I need to send several post requests to my virtual machine. I get examples of packets from pcap file and then modify them to insert my data(I do it because format of data is rather strange). At first, I send an empty post request (variable none) to my server and everything is OK, server responds to me. But then I need to send another post request(variable challenge_responce), but when I do it as the first time, server doesn't responses me.
none = "POST /jsproxy HTTP/1.1
Host: 192.168.37.2
Connection: keep-alive
Content-Length: 0
Pragma: no-cache
Cache-Control: no-cache
Origin: file://
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/44.0.2403.89 Chrome/44.0.2403.89 Safari/537.36
Content-Type: text/plain;charset=UTF-8
Accept: */*
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.8
Cookie: username=admin"
challenge_responce = "POST /jsproxy HTTP/1.1
Host: 192.168.37.2
Connection: keep-alive
Content-Length: 117
Pragma: no-cache
Cache-Control: no-cache
Origin: file://
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/44.0.2403.89 Chrome/44.0.2403.89 Safari/537.36
Content-Type: text/plain;charset=UTF-8
Accept: */*
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.8
Cookie: username=admin
ДЂДЂДЂДЂДЂДЂДЂ/Rñ±•Â$0[^96“ù¦ĀĀ!##$%^&*()_+:3|~ĀĀĀĀĀĀĀĀ§Ç1&TВЌВЌpMГЇm)[4}(В¤<HГѓ%Гў(Г„Гadmin"
Here is my code:
packet = pcap_next(handle, &header);
Arrcpy(none, ParsePacket(packet, length), 1000);
packet = pcap_next(handle, &header);
Arrcpy(challenge, ParsePacket(packet, length), 1000);
packet = pcap_next(handle, &header);
Arrcpy(challenge_responce, ParsePacket(packet, length), 1000);
boost::asio::ip::tcp::iostream stream("192.168.37.2", "http");
stream << none;
std::string temp;
std::string chPacket;
auto t = stream.rdbuf();
while (std::getline(stream, temp))
chPacket += temp;
auto code = GetChallenge(chPacket);
std::string modChallengeResponce = ModifyChallengeResponce(challenge_responce, length, code, "qazwsx12");
stream << modChallengeResponce;
std::string resq;
while (std::getline(stream, temp))
resq += temp;
std::cout << stream.rdbuf();
How can i fix it?? May be I shoule not use tcp::iostream ??
Related
First URL is presigned. Then with PUT message the gif file is uploaded. Content-Type is set both when presigning and also in PUT message, but in AWS interface gif type is not visible. Why?
PUT request header:
Accept: application/json, text/plain, */*
Accept-Encoding: gzip, deflate, br
Accept-Language: en,nl;q=0.9,hu;q=0.8,de;q=0.7
Cache-Control: no-cache
Connection: keep-alive
Content-Length: 10912652
Content-Type: image/gif. // <---------------
Host: t44-post-cover.s3.eu-central-1.amazonaws.com
Origin: http://localhost:3000
Pragma: no-cache
Referer: http://localhost:3000/
sec-ch-ua: ".Not/A)Brand";v="99", "Google Chrome";v="103", "Chromium";v="103"
sec-ch-ua-mobile: ?0
sec-ch-ua-platform: "macOS"
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors
Sec-Fetch-Site: cross-site
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36
x-amz-acl: public-read
If image is uploaded from web interface, gif type is visible.
Content-type is S3 metadata. So to change it, you have to modify the metadata properties of your objects.
I'm using Django Rest Framework and Vue.js to build a basic web app, and am currently working on the auth. Using axios to send a post request while registering a new user returns 401 in Chrome for some reason, but works in other browsers (Edge) and returns a 201 Created.
The error in chrome is "detail: Invalid Token", but this particular endpoint (registration) doesn't even need auth/token to access.
My frontend is at http://192.168.1.33:8080 and my backend is at http://127.0.0.1:8000
I am trying to POST data to http://127.0.0.1:8000/api/v1/users/auths/
The Network tab in chrome dev tools after trying a request:
Request URL: http://127.0.0.1:8000/api/v1/users/auths/
Request Method: POST
Status Code: 401 Unauthorized
Remote Address: 127.0.0.1:8000
Referrer Policy: strict-origin-when-cross-origin
Access-Control-Allow-Origin: http://192.168.1.33:8080
Allow: GET, POST, HEAD, OPTIONS
Content-Length: 27
Content-Type: application/json
Date: Mon, 06 Dec 2021 12:19:15 GMT
Referrer-Policy: same-origin
Server: WSGIServer/0.2 CPython/3.8.5
Vary: Accept, Origin
WWW-Authenticate: Token
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
Accept: application/json, text/plain, */*
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9
Authorization: Token acf8b9099de5eba413dea141ce2c06b6cfb03159
Connection: keep-alive
Content-Length: 53
Content-Type: application/json
Host: 127.0.0.1:8000
Origin: http://192.168.1.33:8080
Referer: http://192.168.1.33:8080/
sec-ch-ua: " Not A;Brand";v="99", "Chromium";v="96", "Google Chrome";v="96"
sec-ch-ua-mobile: ?0
sec-ch-ua-platform: "Windows"
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors
Sec-Fetch-Site: cross-site
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36
The network tab in Edge dev tools after trying the same thing:
Request URL: http://127.0.0.1:8000/api/v1/users/auths/
Request Method: POST
Status Code: 201 Created
Remote Address: 127.0.0.1:8000
Referrer Policy: strict-origin-when-cross-origin
Access-Control-Allow-Origin: http://192.168.1.33:8080
Allow: GET, POST, HEAD, OPTIONS
Content-Length: 89
Content-Type: application/json
Date: Mon, 06 Dec 2021 12:20:25 GMT
Location: http://127.0.0.1:8000/api/v1/users/auths/12/
Referrer-Policy: same-origin
Server: WSGIServer/0.2 CPython/3.8.5
Vary: Accept, Origin, Cookie
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
Accept: application/json, text/plain, */*
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9
Authorization
Connection: keep-alive
Content-Length: 51
Content-Type: application/json
Host: 127.0.0.1:8000
Origin: http://192.168.1.33:8080
Referer: http://192.168.1.33:8080/
sec-ch-ua: " Not A;Brand";v="99", "Chromium";v="96", "Microsoft Edge";v="96"
sec-ch-ua-mobile: ?0
sec-ch-ua-platform: "Windows"
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors
Sec-Fetch-Site: cross-site
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.55 Safari/537.36 Edg/96.0.1054.43
The obvious difference is that there is a "WWW-Authenticate: Token" in the Chrome Network tab, which is odd.
CORS headers and all have been set up properly, plus the issue is only in Chrome. Is this some Chrome quirk, or am I missing something?
Why is it that, after spending some two hours on a problem, you only get the answer after you've posted it on a forum? Probably something to do with putting the problem down categorically and formally...
Anyway. Turns out the issue was with there being a random token sitting in Chrome's local storage, which was causing all the trouble with the "invalid" token. I cleared local storage, and it's working now. No clue why I had to do this specifically — I had made sure to clear the cache earlier...
See the following GET request headers. I would like some direction regarding forming these GET requests using libcurl in C++.
GET url.aspx?TabID=100000021 HTTP/1.1
Host: url.net
Connection: keep-alive
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
Referer: http://url/Login.aspx?BackToStartPage=true
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.9
Cookie: erJOJPQYCFBMNUJDDYWOH5; ASP.NET_SessionId=ickaamclvh45; BIGipServer~url~Flexnet-url-Prod.app~url-Prod_pool=rd1o00006a0do80; WebPortalSession=77d0601a4_1; LoginPageCookie=http://url/Login.aspx?CurrentUserLanguageId=1033&CurrentUserTimeZoneId=1129; .ASPXAUTH=92C511D2B670AE9DDC3D55A88BBEF6CAF16FBBF0BFFFB016C20B655BAB1B54428F9C55A8430F806F74211354557A8A918DFD8FE9589BF3F95D0340180E89806C4BDF7813CCD5DC027349F8714B1A319C1E51E8C43
GET url.aspx?TabID=0 HTTP/1.1
Host: url.net
Connection: keep-alive
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
Referer: http:/url.net/Login.aspx?BackToStartPage=true
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.9
Cookie: &LGN=MIYDMMBQGUZTS; ASP.NET_SessionId=ickaax45p; url~url~url-url-Prod.app~url-url-Prod_pool=rd1o0000o80; WebPortalSession=77d0601a9_1; LoginPageCookie=http://url.net/Login.aspx?CurrentUserLanguageId=1033&CurrentUserTimeZoneId=1129; .ASPXAUTH=7516499A62192592C485B17AF1D3BDB25DBDE26DF6A1FC179CC3658F3AD1E74E32
I'm using cloudfront for a simple javascript asset that is the following:
https://d1syjrf5lltxmn.cloudfront.net/Content/JavaScript/jquery-migrate-1.2.1.min.js
I've got the Origin Domain name and path set to
www.siliconvalley-codecamp.com
Origin type is custom origin, policy i sMatch Viewer, view policy is http and https. Problem is when it hit this (over and over) it keeps returning a 301 and doing another request from my origin server.
I can't figure out why it keeps doing the 301's. I've read others having issues but can not find a solution.
GET https://d1syjrf5lltxmn.cloudfront.net/Content/JavaScript/jquery-migrate- 1.2.1.min.js HTTP/1.1
Host: d1syjrf5lltxmn.cloudfront.net
Connection: keep-alive
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.99 Safari/537.36
DNT: 1
Accept-Encoding: gzip, deflate, sdch
Accept-Language: en-US,en;q=0.8
and the return is:
HTTP/1.1 301 Moved Permanently
Content-Type: text/html; charset=UTF-8
Content-Length: 208
Connection: keep-alive
Location: https://www.siliconvalley-codecamp.com/Content/JavaScript/jquery-migrate-1.2.1.min.js
Server: Microsoft-IIS/7.5
X-Powered-By: ASP.NET
Date: Fri, 23 Jan 2015 04:18:21 GMT
Age: 10575
X-Cache: Hit from cloudfront
Via: 1.1 f86dab587205f74a0e6f36b42207dec2.cloudfront.net (CloudFront)
X-Amz-Cf-Id: 8h4R0WTOl1wg8LDafMoeAkcvOr1G8ujfAVMgz84Uy_BVE8QlxTbTrQ==
<head><title>Document Moved</title></head>
<body><h1>Object Moved</h1>This document may be found here</body>
Origin server setup:
Hi quick question about Jayrock... I have a Jayrock JSON-RPC web service that generally works fine. However, when I try to post to my jqGrid editUrl, Jayrock throws an error. The web service works fine in other situations.
Anyone have a clue why Jayrock doesn't like the following request? Perhaps a way to configure Jayrock to accept this request?
Request:
POST
/StoryManager/StoryManager.ashx/setPageItemRoles
HTTP/1.1
Host: localhost:2064
User-Agent: Mozilla/5.0 (Windows; U;
Windows NT 5.1; en-US; rv:1.9.1)
Gecko/20090624 Firefox/3.5 (.NET CLR
3.5.30729)
Accept: */*
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset:
ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Content-Type:
application/x-www-form-urlencoded;
charset=UTF-8
X-Requested-With: XMLHttpRequest
Referer:
http://localhost:2064/StoryManager/PageItemDetail.aspx
Content-Length: 183
Cookie:
ASP.NET_SessionId=uycy1qmowzzqhiac1kg3e455
Pragma: no-cache
Cache-Control: no-cache
title=Narrative&assignedto=dfghdfgh&assigned=2009-06-25T14%3A52%3A24.0868931-05%3A00&due=2009-08-02T14%3A52%3A24.0868931-05%3A00&completed=2009-07-17T14%3A52%3A24.0868931-05%3A00&id=3
Response:
{"id":null,"error":{"name":"JSONRPCError","message":"Found
String where Object was
expected.","stackTrace":" at
Jayrock.Json.JsonReader.ReadToken(JsonTokenClass
token) in
c:\Projects\Public\Jayrock\rel\rel-0.9.8316\src\Jayrock.Json\Json\JsonReader.cs:line
142\r\n at
Jayrock.JsonRpc.JsonRpcDispatcher.ParseRequest(TextReader
input) in
c:\Projects\Public\Jayrock\rel\rel-0.9.8316\src\Jayrock\JsonRpc\JsonRpcDispatcher.cs:line
271\r\n at
Jayrock.JsonRpc.JsonRpcDispatcher.Process(TextReader
input, TextWriter output) in
c:\Projects\Public\Jayrock\rel\rel-0.9.8316\src\Jayrock\JsonRpc\JsonRpcDispatcher.cs:line
127","errors":[{"name":"JsonException","message":"Found
String where Object was expected."}]}}
Because you send application/x-www-form-urlencoded request with "form-like" post data instead of application/json with correct json object.