Skip to content

Commit b4b17a4

Browse files
committed
cookies of target page are now taken automatically via extention and posted to server
1 parent 66e3ac9 commit b4b17a4

File tree

3 files changed

+57
-24
lines changed

3 files changed

+57
-24
lines changed

xssi check/jsFinder/app/page_analyzer.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
//document.body.innerHTML = document.body.innerHTML.replace(new RegExp("Gmail", "g"), "nobody");
22

33
window.onload = function () {
4+
var cookies = document.cookie;
5+
var currenturl = window.location.href;
46
var scripts = document.getElementsByTagName("script");
57
for (var i = 0; i < scripts.length; i++) {
68
if (scripts[i].src) {
@@ -13,12 +15,21 @@ window.onload = function () {
1315
loadDoc(i, window.location.href, scripts[i].innerHTML);
1416
}
1517
}
16-
17-
//getScriptContent();
18+
postCookies(cookies, currenturl);
19+
getScriptContent();
1820
//alert(scripts.length);
1921
}
2022

21-
23+
function postCookies(cookies, currenturl) {
24+
var xhttp = new XMLHttpRequest();
25+
xhttp.onreadystatechange = function () {
26+
if (this.readyState === 4 && this.status === 200) {
27+
}
28+
};
29+
xhttp.open("POST", "http://localhost:55168/home/PostCookies", true);
30+
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
31+
xhttp.send("cookies="+cookies+"&url="+ currenturl);
32+
}
2233

2334

2435
function loadDoc(scriptNumber, src, content) {
@@ -33,7 +44,7 @@ function loadDoc(scriptNumber, src, content) {
3344
}
3445

3546

36-
/*function getScriptContent() {
47+
function getScriptContent() {
3748
var xhttp = new XMLHttpRequest();
3849
xhttp.onreadystatechange = function () {
3950
if (this.readyState === 4 && this.status === 200) {
@@ -42,4 +53,4 @@ function loadDoc(scriptNumber, src, content) {
4253
xhttp.open("GET", "http://localhost:55168/home/GetScriptContent", true);
4354
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
4455
xhttp.send();
45-
}*/
56+
}

xssi check/xssiServer/Controllers/HomeController.cs

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ public class HomeController : Controller
1515
{
1616

1717
ApplicationDbContext Db = new ApplicationDbContext();
18-
CookieContainer Cookies = new CookieContainer();
19-
public ActionResult ReqWithCookies()
18+
//public CookieContainer Cookies = new CookieContainer();
19+
/*public ActionResult ReqWithCookies()
2020
{
2121
//HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://www.foodiez.com.bd/Home/GetCityFromSession");
2222
//request.CookieContainer = new CookieContainer();
@@ -29,7 +29,7 @@ public ActionResult ReqWithCookies()
2929
Cookies.Add(new Cookie("PHPSESSID", "ktt4a4eue8cpq60evul997dia1") { Domain = target.Host });
3030
3131
32-
//cookies.Add(response.Cookies);
32+
//Cookies.Add(response.Cookies);
3333
3434
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://localhost/demo/userInformationView.php");
3535
request.CookieContainer = Cookies;
@@ -40,17 +40,9 @@ public ActionResult ReqWithCookies()
4040
string strResponse = reader.ReadToEnd();
4141
4242
return Json(strResponse, JsonRequestBehavior.AllowGet);
43-
}
43+
}*/
4444

45-
public CookieContainer GetCookie()
46-
{
47-
CookieContainer cookies = new CookieContainer();
48-
Uri target = new Uri("http://localhost/demo/userInformationView.php");
49-
cookies.Add(new Cookie("__RequestVerificationToken", "05QKJgFJ8ZGk6KmgD1QR6RjeW1sHUwx5JGERq2NTUW0GXp7Hbu1Cs2cgQmkZ3-QFvynb876pKezKp-CvIoZmYF-8p28365lcvUK0be4eMf81") { Domain = target.Host });
50-
cookies.Add(new Cookie("io", "rVBILLp7745vDsrDAAAA") { Domain = target.Host });
51-
cookies.Add(new Cookie("PHPSESSID", "ktt4a4eue8cpq60evul997dia1") { Domain = target.Host });
52-
return cookies;
53-
}
45+
5446

5547
public ActionResult Index()
5648
{
@@ -81,7 +73,7 @@ public ActionResult GetScriptContent()
8173
});
8274
}
8375
}
84-
if (s.Source != null && !s.Source.Contains("facebook") && s.Content == null)
76+
if (s.Source != null && s.Content == null)
8577
{
8678
var withoutLoginContent = ExecuteHttpGet(s.Source);
8779
var withLoginContent = ExecuteHttpGet(s.Source, cookies);
@@ -158,7 +150,40 @@ public ActionResult About()
158150
return View();
159151
}
160152

153+
154+
public string Cookies, TargetUrl;
161155
[HttpPost]
156+
public ActionResult PostCookies(string cookies, string url)
157+
{
158+
Cookies = cookies;
159+
TargetUrl = url;
160+
161+
162+
return null;
163+
}
164+
165+
public CookieContainer GetCookie()
166+
{
167+
168+
Uri target = new Uri(TargetUrl);
169+
var createdCookies = new CookieContainer();
170+
171+
var splitWithSemicolon = Cookies.Split(';');
172+
foreach (var splitted in splitWithSemicolon)
173+
{
174+
var cookieValue = splitted.Split('=');
175+
createdCookies.Add(new Cookie(cookieValue[0].Trim(), cookieValue[1].Trim())
176+
{
177+
Domain = target.Host
178+
});
179+
}
180+
return createdCookies;
181+
}
182+
183+
184+
185+
186+
[HttpPost]
162187
public ActionResult PostScript(GenericScriptHolder genericScriptHolder)
163188
{
164189
ViewBag.Message = "Your contact page.";

xssi check/xssiServer/Views/Shared/_Layout.cshtml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<ul class="nav navbar-nav">
2424
<li>@Html.ActionLink("Home", "Index", "Home")</li>
2525
<li>@Html.ActionLink("About", "About", "Home")</li>
26-
<li>@Html.ActionLink("Contact", "Contact", "Home")</li>
26+
2727
</ul>
2828
@Html.Partial("_LoginPartial")
2929
</div>
@@ -40,10 +40,7 @@
4040
@Scripts.Render("~/bundles/jquery")
4141
@Scripts.Render("~/bundles/bootstrap")
4242
@RenderSection("scripts", required: false)
43-
<script src="http://localhost/demo_project/js/myApp.php">
44-
45-
46-
</script>
43+
<script src="http://localhost/xssi_vulnerable_website/js/myApp.php"></script>
4744
<script>
4845
var info = document.getElementById("effect");
4946
console.log(info);

0 commit comments

Comments
 (0)