RE: C++ Web Browser 12-18-2014, 12:54 PM
#7
(12-18-2014, 11:11 AM)dopamine Wrote: What the fuck is that? Thats not how a HTTP GET packet looks like.
Code:GET /newreply.php HTTP/0.9\r\n Host: sinister.ly\r\n User-Agent: Penis
This is more like it.
The fields you specified are optional fields.
Here is a basic web browser written in C++ (utilizes the libsocket framework)
Given, a web browser does not have to have ANY HTML parsing. This one does not, but it is still a web browser in essence.
Code:
#include "libsocket.h"
#include <stdio.h>
#include <string.h>
#include <time.h>
int main(int argc, char * * argv)
{
clientSocket *conn = new clientSocket("74.125.196.101", 80);
char c, buf[1024];
printf("%02x\n", conn->getStatus());
sprintf(buf, "GET / HTTP/1.0\r\n\r\n"); //sample packet header
conn->Write(buf, strlen(buf));
sleep(3); //give a tad delay
while (conn->Read(&c, 1) > 0)
printf("%c", c);
fflush(stdout);
conn->Close();
return 0;
}

























![[+]](https://sinister.li/images/modern/collapse_collapsed.png)