bigsnitch/httpflow.h

162 lines
3.7 KiB
C
Raw Normal View History

2020-08-13 03:35:22 +00:00
#pragma once
#include <includes.h>
/*
{
"flow": {
"client_conn": {
2020-08-13 21:25:04 +00:00
"address": [
"::1",
37570,
0,
0
],
"alpn_proto_negotiated": "http/1.1",
"cipher_name": "TLS_AES_256_GCM_SHA384",
"clientcert": null,
"id": "a1e82917-2d58-4b99-be9e-2b962bc499b2",
"mitmcert": "mitmcertstring",
"sni": "yolo.jetzt",
"timestamp_end": null,
"timestamp_start": 1597284668.6260498,
"timestamp_tls_setup": 1597284669.8449724,
"tls_established": true,
"tls_extensions": [...],
"tls_version": "TLSv1.3"
2020-08-13 03:35:22 +00:00
},
"error": null,
"id": "a6aa4e6e-ca31-4f58-bf47-2da7bfcf0000",
"intercepted": false,
"marked": false,
"metadata": {},
"mode": "transparent",
"request": {
2020-08-13 21:25:04 +00:00
"content": "",
"first_line_format": "relative",
"headers": [
[
"Host",
"yolo.jetzt"
],
[
"User-Agent",
"curl/7.68.0"
],
[
"Accept",
]
],
"host": "yolo.jetzt",
"http_version": "HTTP/1.1",
"is_replay": false,
"method": "GET",
"path": "/",
"port": 443,
"scheme": "https",
"timestamp_end": 1597284669.92817,
"timestamp_start": 1597284669.8761458
2020-08-13 03:35:22 +00:00
},
"response": null,
"server_conn": {
2020-08-13 21:25:04 +00:00
"address": [
"yolo.jetzt",
443
],
"alpn_proto_negotiated": "http/1.1",
"cert": "certstring",
"id": "50a3b79d-2912-45f3-991b-c03406a1018f",
"ip_address": [
"95.156.226.69",
443
],
"sni": "yolo.jetzt",
"source_address": [
"192.168.42.102",
44949
],
"timestamp_end": null,
"timestamp_start": 1597284669.2133315,
"timestamp_tcp_setup": 1597284669.2892282,
"timestamp_tls_setup": 1597284669.584602,
"tls_established": true,
"tls_version": "TLSv1.2",
"via": null
2020-08-13 03:35:22 +00:00
},
"type": "http",
"version": 7
},
"msg": "request"
}
*/
namespace http {
struct Request
{
std::string server_conn_id;
std::string server_ip_address;
bool tls;
std::string content;
std::string scheme;
std::string method;
std::string host;
std::string address;
unsigned short port;
std::string http_version;
std::string path;
double timestamp_start;
double timestamp_end;
std::vector<std::tuple<std::string,std::string>> headers;
std::string error;
};
2020-08-13 21:25:04 +00:00
struct Response {
int status_code;
std::string http_version;
std::string reason;
std::string content;
double timestamp_start;
double timestamp_end;
std::vector<std::tuple<std::string,std::string>> headers;
};
2020-08-13 03:35:22 +00:00
struct Flow {
Request request;
Response response;
};
inline void to_json(json& j, const Flow& flow) {}
inline void from_json(const json& j, Flow& flow) {
std::cout << std::setw(4) << j << "\n\n";
if(!j.contains("flow")) {
return;
}
if(j.at("flow").contains("server_conn")) {
j.at("flow").at("server_conn").at("id").get_to(flow.request.server_conn_id);
j.at("flow").at("server_conn").at("tls_established").get_to(flow.request.tls);
}
if(j.at("flow").contains("request")) {
j.at("flow").at("request").at("port").get_to(flow.request.port);
j.at("flow").at("request").at("host").get_to(flow.request.host);
j.at("flow").at("request").at("scheme").get_to(flow.request.scheme);
j.at("flow").at("request").at("path").get_to(flow.request.path);
j.at("flow").at("request").at("content").get_to(flow.request.content);
j.at("flow").at("request").at("method").get_to(flow.request.method);
j.at("flow").at("request").at("http_version").get_to(flow.request.http_version);
2020-08-13 21:25:04 +00:00
//j.at("server_conn").at("address").get_to(flow.server_conn_address);
2020-08-13 03:35:22 +00:00
}
}
}
Q_DECLARE_METATYPE(http::Flow)