-
Notifications
You must be signed in to change notification settings - Fork 29
HTTP Host and TLS SNI fragmentation/stuttering/fuzzing test #1522
Conversation
auto aread = std::make_shared<std::string>(); | ||
auto awrite = std::make_shared<std::string>(); | ||
|
||
SSL_CTX* ctx = SSL_CTX_new(SSLv23_method()); //XXX don't ignore errors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SSLv23_method()
cannot fail, IIRC. It should return a pointer to a statically allocated struct
.
return *aread; //XXX probably raise exception | ||
} | ||
|
||
if (connect(sockfd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) < 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If think you can ask OpenSSL to connect on your behalf
|
||
void dpi_fragment(Settings options, Callback<SharedPtr<report::Entry>> callback, | ||
SharedPtr<Reactor> reactor, SharedPtr<Logger> logger) { | ||
reactor->call_in_thread(logger, [=]() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest to do [callback = std::move(callback)]
. This is C++14 and should guarantee that the thread uniquely owns the callback. I remember not doing that was leading to weird behavior sometimes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
logger->info("unfragmented https response length: %d", unfragmented_https.length()); | ||
logger->info("fragmented http response length: %d", fragmented_http.length()); | ||
logger->info("unfragmented http response length: %d", unfragmented_http.length()); | ||
callback(entry); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest to do
reactor->call_soon([entry = std::move(entry), callback = std::move(callback)]() {
callback(entry);
});
so that the callback is called from the I/O thread loop, which is what usually happens.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
int main(std::list<Callback<BaseTest &>> &initializers, int argc, char **argv) { | ||
mk::nettests::DpiFragmentTest test; | ||
int ch; | ||
while ((ch = getopt(argc, argv, "B:f:")) != -1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should clean the options string here
d80070b
to
e15375d
Compare
e15375d
to
d74f415
Compare
|
Closing as stated in ooni/spec#103 (comment). |
Link to spec PR
So instead of trying to hook things at the libevent level, which even Simone says is Hard To Do (:)), I'm doing a good ol' blocking
socket(); connect(); select(); read(); write();
loop in my own thread. I'm telling OpenSSL to talk to some buffers instead of the socket directly, and I'm taking care of read/writing them to the socket (with thesleep()
trick around the plaintext hostname).