本文整理汇总了C#中IronWASP.Request.SetCookie方法的典型用法代码示例。如果您正苦于以下问题:C# Request.SetCookie方法的具体用法?C# Request.SetCookie怎么用?C# Request.SetCookie使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IronWASP.Request
的用法示例。
在下文中一共展示了Request.SetCookie方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetRedirect
public Request GetRedirect(Response Res)
{
if (Res.Code == 301 || Res.Code == 302 || Res.Code == 303 || Res.Code == 307)
{
if (Res.Headers.Has("Location"))
{
string NewUrl = Res.Headers.Get("Location");
Request NewReq = new Request(this.FullURL);
if (NewUrl.StartsWith("/"))
{
NewReq.URL = NewUrl;
}
else if (NewUrl.StartsWith("http://") || NewUrl.StartsWith("https://"))
{
NewReq.FullURL = NewUrl;
}
else if (NewUrl.StartsWith(".."))
{
int DirBackNumber = 0;
List<string> UpdatedNewUrlPathParts = NewReq.UrlPathParts;
List<string> NewUrlPathParts = new List<string>(NewUrl.Split('/'));
if (!NewReq.Url.EndsWith("/") && UpdatedNewUrlPathParts.Count > 0) UpdatedNewUrlPathParts.RemoveAt(UpdatedNewUrlPathParts.Count - 1);
foreach (string NewUrlPathPart in NewUrlPathParts)
{
if (NewUrlPathPart.Equals(".."))
DirBackNumber++;
else
break;
}
while (UpdatedNewUrlPathParts.Count > 0 && DirBackNumber > 0)
{
UpdatedNewUrlPathParts.RemoveAt(UpdatedNewUrlPathParts.Count - 1);
if (NewUrlPathParts.Count > 0) NewUrlPathParts.RemoveAt(0);
DirBackNumber--;
}
UpdatedNewUrlPathParts.AddRange(NewUrlPathParts);
NewReq.UrlPathParts = UpdatedNewUrlPathParts;
if (NewUrl.EndsWith("/"))
{
if (!NewReq.Url.EndsWith("/")) NewReq.Url = NewReq.Url + "/";
}
else
{
if (NewReq.Url.EndsWith("/") && NewReq.Url.Length > 1) NewReq.Url = NewReq.Url.TrimEnd(new char[] { '/' });
}
}
else
{
List<string> NewUrlPathParts = NewReq.UrlPathParts;
if (!NewReq.Url.EndsWith("/") && NewUrlPathParts.Count > 0) NewUrlPathParts.RemoveAt(NewUrlPathParts.Count - 1);
NewReq.UrlPathParts = NewUrlPathParts;
if (!NewReq.Url.EndsWith("/")) NewReq.Url = NewReq.Url + "/";
NewReq.Url = NewReq.Url + NewUrl;
}
//this check is needed since sometimes the redirect can go to a different domain
if (this.Host == NewReq.Host)
{
NewReq.CookieString = this.CookieString;
NewReq.SetCookie(Res.SetCookies);
}
return NewReq;
}
}
return null;
}
示例2: Crawl
void Crawl(Request Req, int Depth, bool Scraped)
{
if (Stopped) return;
if (Depth > MaxDepth) return;
if (WasCrawled(Req)) return;
if (!CanCrawl(Req)) return;
lock (PageSignatures)
{
PageSignatures.Add(GetPageSignature(Req));
}
Req.Source = RequestSource.Probe;
Req.SetCookie(Cookies);
if (UserAgent.Length > 0) Req.Headers.Set("User-Agent", UserAgent);
Response Res = Req.Send();
Cookies.Add(Req, Res);
bool Is404File = IsA404(Req, Res);
if (!Res.IsHtml)
{
try
{
Res.ProcessHtml();
}
catch
{
return;
}
}
if (Depth + 1 > MaxDepth) return;
List<Request> LinkClicks = GetLinkClicks(Req, Res);
foreach (Request LinkClick in LinkClicks)
{
AddToCrawlQueue(LinkClick, Depth + 1, true);
}
List<Request> FormSubmissions = GetFormSubmissionRequests(Req, Res);
foreach (Request FormSubmission in FormSubmissions)
{
AddToCrawlQueue(FormSubmission, Depth + 1, true);
}
Request DirCheck = Req.GetClone();
DirCheck.Method = "GET";
DirCheck.Body.RemoveAll();
DirCheck.Url = DirCheck.UrlDir;
if (!Req.Url.EndsWith("/"))
{
AddToCrawlQueue(DirCheck, Depth + 1, false);
}
if (PerformDirAndFileGuessing && !Is404File)
{
foreach (string File in FileNamesToCheck)
{
Request FileCheck = DirCheck.GetClone();
FileCheck.Url = FileCheck.Url + File;
AddToCrawlQueue(FileCheck, Depth + 1, false);
}
foreach (string Dir in DirNamesToCheck)
{
Request DirectoryCheck = DirCheck.GetClone();
DirectoryCheck.Url = DirectoryCheck.Url + Dir + "/";
AddToCrawlQueue(DirectoryCheck, Depth + 1, false);
}
}
if (Scraped || !Is404File)
{
lock (CrawledRequests)
{
CrawledRequests.Enqueue(Req);
}
IronUpdater.AddToSiteMap(Req);
}
}
示例3: GetLinkClicks
List<Request> GetLinkClicks(Request Req, Response Res)
{
List<Request> LinkClicks = new List<Request>();
List<string> Links = GetLinks(Req, Res);
foreach (string Link in Links)
{
try
{
Request LinkReq = new Request(Link);
LinkReq.SetCookie(Cookies);
LinkClicks.Add(LinkReq);
}
catch { }
}
return LinkClicks;
}
示例4: GetRedirect
public Request GetRedirect(Response Res)
{
if (Res.IsRedirect)
{
if (Res.Headers.Has("Location"))
{
string NewUrl = Res.Headers.Get("Location");
Request NewReq = new Request(this.FullURL);
if (NewUrl.StartsWith("/"))
{
NewReq.URL = NewUrl;
}
else if (NewUrl.StartsWith("http://") || NewUrl.StartsWith("https://"))
{
NewReq.FullURL = NewUrl;
}
else if (NewUrl.StartsWith(".."))
{
int DirBackNumber = 0;
List<string> UpdatedNewUrlPathParts = NewReq.UrlPathParts;
List<string> NewUrlPathParts = new List<string>(NewUrl.Split('/'));
if (!NewReq.Url.EndsWith("/") && UpdatedNewUrlPathParts.Count > 0) UpdatedNewUrlPathParts.RemoveAt(UpdatedNewUrlPathParts.Count - 1);
foreach (string NewUrlPathPart in NewUrlPathParts)
{
if (NewUrlPathPart.Equals(".."))
DirBackNumber++;
else
break;
}
while (UpdatedNewUrlPathParts.Count > 0 && DirBackNumber > 0)
{
UpdatedNewUrlPathParts.RemoveAt(UpdatedNewUrlPathParts.Count - 1);
if (NewUrlPathParts.Count > 0) NewUrlPathParts.RemoveAt(0);
DirBackNumber--;
}
UpdatedNewUrlPathParts.AddRange(NewUrlPathParts);
NewReq.UrlPathParts = UpdatedNewUrlPathParts;
if (NewUrl.EndsWith("/"))
{
if (!NewReq.Url.EndsWith("/")) NewReq.Url = NewReq.Url + "/";
}
else
{
if (NewReq.Url.EndsWith("/") && NewReq.Url.Length > 1) NewReq.Url = NewReq.Url.TrimEnd(new char[] { '/' });
}
}
else
{
List<string> NewUrlPathParts = NewReq.UrlPathParts;
if (!NewReq.Url.EndsWith("/") && NewUrlPathParts.Count > 0) NewUrlPathParts.RemoveAt(NewUrlPathParts.Count - 1);
NewReq.UrlPathParts = NewUrlPathParts;
if (!NewReq.Url.EndsWith("/")) NewReq.Url = NewReq.Url + "/";
NewReq.Url = NewReq.Url + NewUrl;
}
//this check is needed since sometimes the redirect can go to a different domain
if (this.Host == NewReq.Host)
{
NewReq.CookieString = this.CookieString;
NewReq.SetCookie(Res.SetCookies);
}
//Update the Source of the redirect request with the value of the current request
NewReq.Source = this.Source;
if (this.Source.Equals("Scan"))
NewReq.ScanID = this.ScanID;
//Update general headers associated with the current request in to the header of the redirect request
foreach (string HeaderName in this.Headers.GetNames())
{
if (!(HeaderName.Equals("Host", StringComparison.OrdinalIgnoreCase) || HeaderName.Equals("Content-Length", StringComparison.OrdinalIgnoreCase) || HeaderName.Equals("Content-Type", StringComparison.OrdinalIgnoreCase) || HeaderName.Equals("Cookie", StringComparison.OrdinalIgnoreCase)))
{
foreach (string HeaderValue in this.Headers.GetAll(HeaderName))
{
NewReq.Headers.Add(HeaderName, HeaderValue);
}
}
}
return NewReq;
}
}
return null;
}
示例5: GetRedirects
public static List<Request> GetRedirects(Request Req, Response Res, CookieStore Cookies)
{
List<Request> Redirects = new List<Request>();
List<string> RedirectUrls = GetRedirectUrls(Req, Res);
foreach (string RedirectUrl in RedirectUrls)
{
try
{
Request RedirectReq = new Request(RedirectUrl);
RedirectReq.SetCookie(Cookies);
Redirects.Add(RedirectReq);
}
catch { }
}
return Redirects;
}
示例6: Update
public virtual Request Update(Request Request, Response Response)
{
Request.SetCookie(Response);
return Request;
}
示例7: ReadFromStore
public static void ReadFromStore(Request Req)
{
Req.SetCookie(StaticCookieStore);
}
示例8: GetRedirect
public Request GetRedirect(Response Res)
{
if (Res.Code == 301 || Res.Code == 302 || Res.Code == 303 || Res.Code == 307)
{
if (Res.Headers.Has("Location"))
{
string NewUrl = Res.Headers.Get("Location");
Request NewReq = new Request(this.FullURL);
if (NewUrl.StartsWith("/"))
{
NewReq.URL = NewUrl;
return NewReq;
}
if (NewUrl.StartsWith("http://") || NewUrl.StartsWith("https://"))
{
NewReq.FullURL = NewUrl;
if (this.Host == NewReq.Host)
{
NewReq.CookieString = this.CookieString;
NewReq.SetCookie(Res.SetCookies);
}
return NewReq;
}
}
}
return null;
}