public void setConnection(SessionEventArgs e) { if (this.InvokeRequired) { this.Invoke(new setInfo(setConnection), new object[] { e }); } else { label1.Text = "Hostname: " + e.RequestHostname; label2.Text = "URL: " + e.RequestURL; label3.Text = "Useragent: " + e.ProxyRequest.UserAgent; label4.Text = "Status Code: " + ((e.ServerResponse!=null)?e.ServerResponse.StatusDescription:"-1"); label5.Text = "Referer: " + e.ProxyRequest.Referer; label6.Text = "Keep alive: " + e.ProxyRequest.KeepAlive; label7.Text = "Request URI: " + e.ProxyRequest.RequestUri; try { textBox1.Text = e.GetResponseHtmlBody(); } catch(Exception exception) { textBox1.Text = "Could not read response! ["+exception.Message+"]"; } } }
public void OnResponse(object sender, SessionEventArgs e) { foreach (Tuple<int, SessionEventArgs> request in connections) { if (e.ProxyRequest.Equals(request.Item2.ProxyRequest)) { modifyFrom(request.Item1, e); break; } } if (e.ServerResponse.StatusCode == HttpStatusCode.OK) { if (e.ServerResponse.ContentType.Trim().ToLower().Contains("text/html")) { if (e.GetResponseHtmlBody() != null) { try { String body = e.GetResponseHtmlBody(); try { foreach (DataGridViewRow row in dataGridView2.Rows) { if (row == null) continue; bool check = true; foreach (DataGridViewCell cell in row.Cells) { if (cell.Value == null) { check = false; continue; } String val = (String)cell.Value; if (val.Trim().Length <= 1) { check = false; } } if (check) { HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument(); doc.LoadHtml(body); Console.WriteLine("//" + row.Cells[0].Value + "[@" + row.Cells[1].Value + "]"); foreach (HtmlNode img in doc.DocumentNode.SelectNodes("//" + row.Cells[0].Value + "[@" + row.Cells[1].Value + "]")) { if (img == null) continue; if (img.Attributes[(String)row.Cells[1].Value] != null) { img.SetAttributeValue((String)row.Cells[1].Value, (String)row.Cells[2].Value); } } body = doc.DocumentNode.OuterHtml; } } } catch { } e.Ok("<!-- Processed by RequestBuilder -->\n" + body); } catch(Exception exception) { Console.WriteLine("EXCEPTION: " + exception.Message); } } } } }