//Test On Request, intecept requests //Read browser URL send back to proxy by the injection script in OnResponse event public void OnRequest(object sender, SessionEventArgs e) { string Random = e.RequestURL.Substring(e.RequestURL.LastIndexOf(@"/") + 1); int index = _URLList.IndexOf(Random); if (index >= 0) { string URL = e.Decode(); if (_lastURL != URL) { OnChanged(new VisitedEventArgs() { hostname = e.Hostname, URL = URL, remoteIP = e.ipAddress, remotePort = e.Port }); } e.Ok(null); _lastURL = URL; } }
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); } } } } }