Grab a web page

Jun 7, 2011 at 5:05 PM

I have some trouble getting a web page from a LAN pc.

 

                // Supposing to be on ethernet, set mac source to 1:1:1:1:1:1
                MacAddress source = new MacAddress("x:x:x:x:x");

                // set mac destination to 2:2:2:2:2:2
                MacAddress destination = new MacAddress("x:x:x:x:x");

                // Create the packets layers

                // Ethernet Layer
                EthernetLayer ethernetLayer = new EthernetLayer
                                                  {
                                                      Source = source,
                                                      Destination = destination
                                                  };

                // IPv4 Layer
                IpV4Layer ipV4Layer = new IpV4Layer
                                          {
                                              Destination = new IpV4Address("lol.lol.lol.lol"),
                                              Identification = 0,
                                              Source = new IpV4Address("lol.lol.lol.lol"),
                                              Ttl = 128,
                                              // The rest of the important parameters will be set for each packet
                                          };

               
                //TPC Layer
                TcpLayer tcpLayer = new TcpLayer
                {
                    SourcePort = 57001,
                    DestinationPort = 80,
                    ControlBits = TcpControlBits.Push|TcpControlBits.Acknowledgment,
                    AcknowledgmentNumber = 1,
                    SequenceNumber = 0,
                    Window = 8192
                };

                HttpRequestLayer httpLayer = new HttpRequestLayer()
                {
                    Header = new HttpHeader(
                        HttpField.CreateField("Host", "x.x.x.x"),
                        HttpField.CreateField("User-Agent", "gigi"),
                        HttpField.CreateField("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"),
                        HttpField.CreateField("Accept-Language", "it-it,it;q=0.8,en-us;q=0.5,en;q=0.3"),
                        HttpField.CreateField("Accept-Encoding", "gzip, deflate"),
                        HttpField.CreateField("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7"),
                        HttpField.CreateField("Keep-Alive", "115"),
                        HttpField.CreateField("Connection", "keep-alive"),
                        HttpField.CreateField("Cache-Control", "max-age=0")

                        ),
                    Version = HttpVersion.Version11,
                    Method = new HttpRequestMethod("GET"),
                    Uri = "/loggaip/"
                };
                // Create the builder that will build our packets
                

                PacketBuilder builder = new PacketBuilder(ethernetLayer, ipV4Layer, tcpLayer, httpLayer);
Packet packet = builder.Build(DateTime.Now);
communicator.SendPacket(packet);

Analizing Wireshark I notice that firefox connection send 1 SYN, receive 1 ACK|SYN, send 1 ACK and then send the packet (ACK|PSH). So, I've try to send 1 SYN packet. I sniff with wireshark that I've receive ACK|SYN but every time I try to send next ACK packet I miss ack number.

Is there a way to grab a web page? Is there a way to get ACK number from ACK|SYN sequence number?

 

Thanks :)

Coordinator
Jun 9, 2011 at 2:16 PM
Edited Jun 9, 2011 at 2:17 PM

I believe you should have your application sniff the SYN|ACK packet and send the appropriate ack and seq number in the GET packet.