Home
Calendar
Certifications
Columns
Features
Forum
Resources
Vitals
Latest Additions
April 2013 Free Giveaway Sponsor - eLearnSecurity
Human Intelligence to Navigate the Security Data Deluge
February 2013 Free Giveaway Winner of SANS CyberCon Training
Interview: Bugcrowd Founders on Herding Ninjas for Crowdsourced Bug Bounties
Network Forensics: The Tree in the Forest
March 2013 Free Giveaway Sponsor - Mile2
Book Review: Violent Python
February 2013 Free Giveaway Sponsor - SANS
Holiday 2012 Free Giveaway Winner of Metasploit Pro by Rapid7
Course Review: SANS FOR408 Computer Forensic Investigations – Windows In-Depth
The Security Consulting Sugar High
Tutorial: Fun with SMB on the Command Line
Interview: Ilia Kolochenko, CEO of High-Tech Bridge
October 2012 Free Giveaway Winner of LearningGate Training
The Broken: Assessing Corporate Security in 2012 to Make a Better 2013
EH-Net Login
Welcome Guest.
Username:
Password:
Remember me
Lost Password?
No account yet?
Register
Who's Online
We have 34 guests online
You are here:
Home
Ethical Hacking Discussions and Related Certifications
Malware
Booby-trapped javascript
EH-Net
May 23, 2013, 02:54:20 AM
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email?
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News
: Go back to The Ethical Hacker Network Online Magazine
Home Page
Home
Help
Calendar
Login
Register
EH-Net
>
Ethical Hacking Discussions and Related Certifications
>
Malware
(Moderator:
don
) >
Booby-trapped javascript
Pages: [
1
]
Go Down
« previous
next »
Print
Author
Topic: Booby-trapped javascript (Read 8649 times)
0 Members and 1 Guest are viewing this topic.
Andrew Waite
Hero Member
Offline
Posts: 928
Booby-trapped javascript
«
on:
April 05, 2009, 07:06:59 AM »
Fortinet have recently posted a
new article
detailing some new anti-analysis techniques they have seen used by javascript malcode authors.
Couple of new techniques being used: first is fairly basic, adding debugger specific code into the malicious script to cause different operation inside a debugger/sandbox than when run in a browser. Nothing too unusual there similiar to VM detection used by full-blown malcode, and as Javascript is source, this is more an annoyance than a problem, but may catch out less experienced analysts (or those that haven't had their morning coffee. In the long run this may be a beneficial change, as the added commands have no/limited legitimate use outside of annoying analysts debugging attempts, then only malicious scripts are likely to contain them, making filtering/scanning detection easier. Of course the additional commands could be obfuscated to hide their true purpose....
Which leads us to the other change. Command de-obfuscation techniques can be as simple as replacing the
eval()
method with
print()
causing the script to spit out it's inner workings in a more readable manner. Some malicious code is starting to overload the
print()
method with the malcode author's own code (and who wants to execute that code?) Potentially this would be capable of doing anything, the Fortinet example shows a somewhat deadly combination of ls and rm to give an analyst a bad day.
Similar analysis over at
InfoSanity
with additional links to further sources for those wanting to look at this in more depth, my primary question though is: Is this something people are commonly seeing the wild?
(P.S. I need to take note of this, could have caught me out in the past when I've been away from my lab and 'bored' or 'curious'. After all javascript should be fairly harmless, right?....)
Logged
--
http://www.infosanity.co.uk
--
http://blog.infosanity.co.uk
former33t
Full Member
Offline
Posts: 226
Re: Booby-trapped javascript
«
Reply #1 on:
April 05, 2009, 08:38:09 PM »
I've been seeing a greater amount of Javascript malware in the wild recently than I had before, but I haven't seen anything this cunning. In fact, almost nothing I've seen has tried to do any real obfuscation. I'll certainly be careful not to substitute print() for eval() though in the future. Now all we need is a function to make sure that the print function has not been overloaded and we'll be back ahead of the malcode writers...
Thanks for the heads up.
Logged
Certifications: CREA, MCSE: Security, CCNA, Security+, other junk
timmedin
Sr. Member
Offline
Posts: 469
Re: Booby-trapped javascript
«
Reply #2 on:
April 06, 2009, 05:20:48 PM »
How does javascript (in the browser?) detect that it is in a VM?
Logged
twitter.com/timmedin |
http://blog.securitywhole.com
Andrew Waite
Hero Member
Offline
Posts: 928
Re: Booby-trapped javascript
«
Reply #3 on:
April 07, 2009, 04:57:39 AM »
Quote from: timmedin on April 06, 2009, 05:20:48 PM
How does javascript (in the browser?) detect that it is in a VM?
Sorry, bit ambiguous there. I meant that I don't think anyone will be surprised that Javascript is starting to take steps to mess with an analysts toys, I used malware/VMware detection as a comparison, not a specific ability of the javascript.
I'm not aware of any javascript ability to detect virtual environment, similar to the red pill techniques etc. If anyone knows differently, let me know.
Logged
--
http://www.infosanity.co.uk
--
http://blog.infosanity.co.uk
dean
Guest
Re: Booby-trapped javascript
«
Reply #4 on:
April 07, 2009, 01:31:08 PM »
I spend a lot of my time with web-based malware, the kits for distribution, etc.. and while I've seen a lot of different obfuscation methods, I don't know if it would be possible without the users permission to exec js/java that would determine if you're running in a vm or not.
The authors are making assumptions that a researcher may use rhino or njs and will set up code to exec cmds through the app, as discussed in the article link that was part of the original post.
I've seen code that uses everything from chr(), ord(), arguments.callee(), encode(), replace(), rand(), string splitting, adding non-ascii characters to the page and custom encryptors to obfuscate JavaScript. But the cool thing is that however they do it, the decrypting routine needs to be included in the js or vb. Or just use a site like this:
http://www.iwebtool.com/html_encrypter
Here is a sample of an encryption routine from mpack, a malware distribution webkit:
Code:
function encrypt($content)
{ $table = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_@";
$xor = 165;
$table = array_keys(count_chars($table, 1));
$i_min = min($table);
$i_max = max($table);
for ($c = count($table); $c > 0; $r = mt_rand(0, $c--));
array_splice($table, $r, $c - $r, array_reverse(array_slice($table, $r, $c - $r)));
$len = strlen($content);
$word = $shift = 0;
for ($i = 0; $i < $len; $i++)
{$ch = $xor ^ ord($content[$i]);
$word |= ($ch << $shift);
$shift = ($shift + 2) % 6;
$enc .= chr($table[$word & 0x3F]);
$word >>= 6;
if (!$shift) { $enc .= chr($table[$word]); $word >>= 6; }}
if ($shift)
$enc .= chr($table[$word]);
$tbl = array_fill($i_min, $i_max - $i_min + 1, 0);
while (list($k,$v) = each($table))
$tbl[$v] = $k;
$tbl = implode(",", $tbl);
$fi = ",p=0,s=0,w=0,t=Array({$tbl})";
$f = "w|=(t[x.charCodeAt(p++)-{$i_min}])<<s;";
$f .= "if(s){r+=String.fromCharCode({$xor}^w&255);w>>=8;s-=2}else{s=6}";
$r = "<script language=JavaScript>";
$r.= "function dc(x){";
$r.= "var l=x.length,b=1024,i,j,r{$fi};";
$r.= "for(j=Math.ceil(l/b);j>0;j--){r='';for(i=Math.min(l,b);i>0;i--,l--){{$f}}document.write(r)}";
$r.= "}dc(\"{$enc}\")";
$r.= "</script>";
return $r;}
/dean
Logged
Ketchup
Hero Member
Offline
Posts: 1021
Re: Booby-trapped javascript
«
Reply #5 on:
April 07, 2009, 10:17:46 PM »
I was doing some research on this as well. I found a few ways to detect vmware, including some nifty assembly code. I tried and could not port any of it to javascript. I am not an expert in javascript, but I find it limiting. It just doesn't have the necessary access to memory like C does. I am sure that with a nice ActiveX control, you can detect it
BTW, dean, nice signature tag.
Logged
~~~~~~~~~~~~~~
Ketchup
dean
Guest
Re: Booby-trapped javascript
«
Reply #6 on:
April 10, 2009, 03:27:43 PM »
here you go:
really stupid way to detect a vm using javascript:
http://carnal0wnage.blogspot.com/2009/04/detecting-vmware-with-javascript-or-how.html
/dean
Logged
Ignatius
Jr. Member
Offline
Posts: 91
Re: Booby-trapped javascript
«
Reply #7 on:
April 11, 2009, 12:00:36 PM »
I've had an interest in obfuscated javascript for several months because I was "got" by the technique and had to reinstall my OS! I managed to get the malicious code and deobfuscate it manually and just wonder if the technique used (via RDS.DataSpace object) and detailed here:
http://spamwars.com/dl/javascript_malware_delivery.pdf
might be of use when doing a pen test? If you were on the network and had a page containing the code on a web server under your control, a target machine could browse to the page.
I doubt it would need to be obfuscated but just wonder if any AV might react violently. I guess there are techniques which could be used to bypass tha AV. Is this likely to add to the battery of techniques that the experts here might use?
Logged
dean
Guest
Re: Booby-trapped javascript
«
Reply #8 on:
April 11, 2009, 04:19:14 PM »
Most web based malware takes advantage of the various ClassID's that are part of the RDS.Dataspace Objects. Still works great especially with IE6. IE7 will prompt when the control is loaded. Look at the MS06_014 patch for more info about it.
Post I did a while ago on using it in a pentest:
http://carnal0wnage.blogspot.com/2008/08/owning-client-without-and-exploit.html
Depending on your payload AV may or may not react but any good network IDS will flag on it. This object is used in AJAX a lot so you'll likely see some false positives too.
/dean
«
Last Edit: April 11, 2009, 04:24:35 PM by dean
»
Logged
Ignatius
Jr. Member
Offline
Posts: 91
Re: Booby-trapped javascript
«
Reply #9 on:
April 12, 2009, 06:08:41 AM »
Thanks dean - that's exactly the sort of thing that was going through my mind. I'm relieved to know that my idea (for using this in a pen test) wasn't completely ridiculous!
I'll dust off my books and take the purposely-modified snippets that you provided to see if I can come up wth something that I can use for testing purposes in a VMWare network.
Logged
Pages: [
1
]
Go Up
Print
« previous
next »
Jump to:
Please select a destination:
-----------------------------
EH-Net
-----------------------------
=> Calendar Of Events
===> ChicagoCon 2007
===> ChicagoCon 2008s
===> ChicagoCon 2008f
===> ChicagoCon 2009s
=> Ethical Hacktivism
=> News Items and General Discussion About EH-Net
===> Greetings
=> Special Events
-----------------------------
Ethical Hacking Discussions and Related Certifications
-----------------------------
=> General Certification
===> Networking
===> OS
===> Security
=> Compliance, Regulations & Standards
=> Control Systems
=> Cyber Warfare
=> Forensics
===> CCE / MCCE - (Master) Certified Computer Examiner
===> CHFI - Computer Hacking Forensic Investigator
===> EnCE - EnCase® Certified Examiner
===> GCFA - GIAC Certified Forensics Analyst
=> Hardware
=> Incident Response
===> CSIH - Computer Security Incident Handler
===> GCIH - GIAC Certified Incident Handler
=> Malware
===> Advisories
=> Mobile
=> Network Pen Testing
===> CEH - Certified Ethical Hacker
===> CPTC - Certified Penetration Testing Consultant
===> CPTE - Certified Penetration Testing Engineer
===> CSTA - Certified Security Testing Associate
===> eCPPT - eLearnSecurity Certified Professional Penetration Tester
===> ECSA - EC-Council Certified Security Analyst
===> GPEN - GIAC Certified Penetration Tester
===> OSCP - Offensive Security Certified Professional
=> Physical Security
=> Programming
=> Social Engineering
=> Web Applications
=> Wireless
===> CWNP Certs
===> GAWN - GIAC Assessing Wireless Networks
===> OSWP - Offensive Security Wireless Professional
=> Other
-----------------------------
Columns
-----------------------------
=> Editor-In-Chief
=> Andress
=> Gates
=> Haddix
=> Hadnagy
=> Heffner
=> Hoffman
=> Linn
=> RichM
=> Murray
=> J. Peltier
=> Weidman
=> Wilson
-----------------------------
Features
-----------------------------
=> /root
=> Book Reviews
=> Opinions
=> Skillz
===> Examples
===> May 06 - Star Hacks, Episode V: The Empire Hacks Back
===> July 06 - Hack Bill!
===> Sept 06 - Netcat in the Hat
===> Nov 06 - Hitch-Hackers Guide to the Galaxy
===> Dec 06 - A Christmas (Hacking) Story
===> Feb 07 - Charlottes Web Site
===> April 07 - Microsoft Office Space
===> June 07 - Serenity Hack
===> Oct 07 - Worst. Ethical. Hacker. Challenge. Ever.
===> Dec 07 - Frosty the Snow Crash
===> March 2008 - It Happened One Friday
===> Oct 2008 - Scooby Doo and the Crypto Caper
===> Dec 08 - Santa Claus Is Hacking to Town
===> Feb 2009 - Brady Bunch Boondoggle
===> July 2009 - Prison Break
===> October 2009 - SSHliders
===> December 2009 - Miracle on Thirty-Hack Street
===> December 2010 - The Nightmare Before Charlie Browns Christmas
-----------------------------
Resources
-----------------------------
=> Career Central
===> Looking For Work
===> Looking To Hire
=> Links to cool sites.
=> Mass Media
=> News from the Outside World
=> Tools
=> Tutorials
===> Tutorial Requests
Loading...
Exclusive Deal
SANSFIRE 2013
June 15 - 22
5% Off
w/ Code
:
EHN_5
SANS Deals 4 EH-Netters
5% OFF
Any
SANS Course
in Any Format!
Coupon Code:
EHN_5
Including
SANS Rocky Mountain 2013
&
SANS Boston 2013
Polls
Compared to this year, 2013 will be:
Great!
Better.
About the same.
Little worse.
FUBAR!
Recent Forum Topics
Editor-In-Chief
: Special Xmas Deal: 10% Off eLearnSecurity Courses
(3) by
hekvvddtest
Greetings
: Hello
(6) by
hekvvddtest
Greetings
: Obtain The Scoop On mulberry bags Before You Are Too Late
(13) by
hekvvddtest
Calendar Of Events
: HITBSecConf2013 – Amsterdam
(9) by
hekvvddtest
Special Events
: [Article]-Webcast: Deep Dive into Red Teaming with the Metasploit Framework
(19) by
hekvvddtest
Network Pen Testing
: HackaServer - Anyone tried it?
(4) by
hekvvddtest
Greetings
: Good day ...
(7) by
hekvvddtest
Gates
: Chris Gates' Blog RSA Finalist
(5) by
hekvvddtest
Network Pen Testing
: Ruby on Rails Vulnerabilities / Attacks in BackTrack 5 r3
(1) by
hekvvddtest
General Certification
: nth topic on Career Advice
(9) by
hekvvddtest
General Certification
: Direction
(5) by
hekvvddtest
Hardware
: Discreet Hacking Devices
(8) by
hekvvddtest
Calendar Of Events
: CanSecWest 2013
(5) by
hekvvddtest
Forensics
: Burn Note
(5) by
hekvvddtest
Calendar Of Events
: Cyber Readiness Challenge - Rome
(1) by
hekvvddtest
GCIH - GIAC Certified Incident Handler
: GCIH Free Practice test attempt
(0) by
prats84
GCIH - GIAC Certified Incident Handler
: Passed my GCIH
(0) by
prats84
News Items and General Discussion About EH-Net
: Change is Coming to EH-Net!!
(27) by
don
Greetings
: Hi from the UK
(2) by
n37sh@rk
Network Pen Testing
: AIX Vulnerability Assessments
(2) by
ras76
Tutorials
: Need guidance
(9) by
hanyhasan
Programming
: Finished Python Course in Codecademy now what?
(15) by
hanyhasan
Network Pen Testing
: De-ICE 1.140 released!
(2) by
superkojiman
General Certification
: CPT Practical Submission
(1) by
UNIX
OSCP - Offensive Security Certified Professional
: Failed my first attempt at the OSCP exam
(94) by
azmatt
Tools
: Social-Engineer Toolkit (SET) Version 5.0 “The Wild West” Released
(2) by
m0wgli
Malware
: EICAR?
(3) by
UKSecurityGuy
Advisories
: HTB23154: Multiple Vulnerabilities in Exponent CMS
(0) by
AndyP
Advisories
: HTB23153: Multiple Vulnerabilities in Jojo CMS
(0) by
AndyP
Advisories
: HTB23151: Cross-Site Request Forgery (CSRF) in UMI.CMS
(0) by
AndyP
OSCP - Offensive Security Certified Professional
: Class Scheduled 6/8 - Linux n00b
(7) by
Taemyks
OSCP - Offensive Security Certified Professional
: OSCP exam scheduled
(6) by
gbhat
Incident Response
: LinkedIn Forensics
(0) by
AFENTIS_Forensics
General Certification
: Red Team/Blue Team
(1) by
ajohnson
Career Central
: Starter cert?
(3) by
Grendel
Network Pen Testing
: Beginner Ethical Hacker
(1) by
m0wgli
EH-Net News Feeds
Latest Additions
Privacy Notice
for TDCC & All Properties
Free Business and Tech Magazines and eBooks
© 2013 The Ethical Hacker Network
Joomla!
is Free Software released under the GNU/GPL License.