def _inject_cookie(r, value, pds, pre_func): rs = [] cookies = r.cookies for i, c in enumerate(cookies): if c.name == value: break else: return rs c = Cookie(value, "") for p in pds: c.value = pre_func(p) cookies[i] = c r_new = r.copy() r_new.headers = [ (h,v) for h,v in r.headers if h != 'Cookie' ] r_new.headers.append(('Cookie', "; ".join([str(x) for x in cookies]))) r_new.injection_point = value r_new.payload = p rs.append(r_new) return rs
def _inject_cookie(r, value, pds): rs = [] cookies = r.cookies for i, c in enumerate(cookies): if c.name == value: break else: return rs c = Cookie(value, "") for p in pds: c.value = p cookies[i] = c r_new = r.copy() r_new.remove_header('Cookie') r_new.add_header('Cookie', "; ".join([str(x) for x in cookies])) r_new.injection_point = value r_new.payload = p rs.append(r_new) return rs
def bind(self, r): """Bind the Request to another one. This method will copy the supplied request's cookies and response set-cookies to the Request.""" r_new = self.copy() for c in r.get_header('Cookie'): r_new.add_header('Cookie', c) if r.response: cookies = [] for c in r.response.get_header('Set-Cookie'): cookies.append(Cookie.parse(c, set_cookie=True)) r_new.add_header('Cookie', "; ".join([str(x) for x in cookies])) return r_new
def _inject_cookie(r, target, payloads, append): rs = [] cookies = r.cookies for i, c in enumerate(cookies): if c.name == target: original_value = c.value break else: return rs c = Cookie(target, "") for p in payloads: if append: c.value = original_value + p else: c.value = p cookies[i] = c r_new = r.copy() r_new.remove_header('Cookie') r_new.add_header('Cookie', "; ".join([str(x) for x in cookies])) r_new.injection_point = target r_new.payload = p rs.append(r_new) return rs
def cookies(self): cookies = [] for h in self.get_header("Cookie"): cookies.extend(Cookie.parse(h)) return cookies
def cookies(self): cookies = [] for h in self.get_header("Set-Cookie"): cookies.append(Cookie.parse(h, set_cookie=True)) return cookies