Windows

coinminer 바이러스 PC 삭제

빙주 2025. 4. 2. 16:53
반응형

Malwr-Resource

 

pc에 감염된 파일을 삭제하자

 

아래 내용을 복사하여 배치파일(.bat)로 저장 후 관리자 권한으로 실행

 


@echo off

REM 관리자 권한 획득

>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"

if '%errorlevel%' NEQ '0' (

    echo 관리자 권한을 요청 ...

    goto UACPrompt

) else ( goto gotAdmin )

:UACPrompt

    echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"

    set params = %*:"=""

    echo UAC.ShellExecute "cmd.exe", "/c %~s0 %params%", "", "runas", 1 >> "%temp%\getadmin.vbs"



    "%temp%\getadmin.vbs"

    rem del "%temp%\getadmin.vbs"

    exit /B



:gotAdmin

pushd "%CD%"

    CD /D "%~dp0"




setlocal enabledelayedexpansion

:: 날짜 및 시간으로 로그 파일명 생성
for /f "tokens=1-3 delims=/ " %%A in ('echo %date%') do set log_date=%%C%%A%%B
for /f "tokens=1-3 delims=: " %%X in ('echo %time%') do set log_time=%%X%%Y%%Z
set "log_dir=C:\VirusLog"
set "log_file=%log_dir%\delete_log_%log_date%_%log_time%.txt"

set "target_dir=%WINDIR%\System32"
set "task_path=%WINDIR%\System32\Tasks\console_zero"
set "winsvcf_path=%WINDIR%\System32\winsvcf"
set "reg_services=HKLM\SYSTEM\CurrentControlSet\Services"
set "reg_svchost=HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Svchost\DcomLaunch"

:: 로그 초기화
if not exist "%log_dir%" mkdir "%log_dir%"
echo [검사 시작 - %date% %time%] > "%log_file%"

set /a total_files=0
set /a deleted_files=0
set /a failed_files=0
set /a pending_delete=0
set /a total_reg=0
set /a deleted_reg=0
set /a failed_reg=0

:: ?? 실행 중 프로세스 종료
taskkill /f /im console_zero.exe >nul 2>&1

:: ?? 작업 스케줄러 태스크 종료 및 삭제
schtasks /End /TN "console_zero" >nul 2>&1
schtasks /Delete /TN "console_zero" /F >nul 2>&1

:: ?? 감염 파일 검사 및 삭제
echo [파일 검사 시작] >> "%log_file%"
for /f %%f in ('dir /b /a-d "%target_dir%\x*.exe" "%target_dir%\x*.dat" 2^>nul ^| findstr /r "^x[0-9][0-9][0-9][0-9][0-9][0-9]\.exe$ ^x[0-9][0-9][0-9][0-9][0-9][0-9]\.dat$"') do (
    set /a total_files+=1
    set "filepath=%target_dir%\%%f"
    del /f /q "!filepath!" >nul 2>&1
    if exist "!filepath!" (
        :: 삭제 실패 → 재부팅 후 삭제 예약
        reg add "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager" /v PendingFileRenameOperations /t REG_MULTI_SZ /f /d "\??\!filepath!" >nul 2>&1
        echo [삭제 실패 → 재부팅시 삭제 예약됨] !filepath! >> "%log_file%"
        set /a pending_delete+=1
    ) else (
        echo [삭제됨] !filepath! >> "%log_file%"
        set /a deleted_files+=1
    )
    echo 진행 상태: 파일 검사 !total_files!개 중 !deleted_files!개 삭제됨, !pending_delete!개 삭제 예약됨...
)

:: ?? 추가 감염 항목 삭제
echo [추가 감염 항목 삭제] >> "%log_file%"

:: console_zero.exe 삭제 (재확인)
if exist "%target_dir%\console_zero.exe" (
    del /f /q "%target_dir%\console_zero.exe"
    if exist "%target_dir%\console_zero.exe" (
        reg add "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager" /v PendingFileRenameOperations /t REG_MULTI_SZ /f /d "\??\%target_dir%\console_zero.exe" >nul
        echo [삭제 실패 → 재부팅시 삭제 예약됨] %target_dir%\console_zero.exe >> "%log_file%"
        set /a pending_delete+=1
    ) else (
        echo [삭제됨] %target_dir%\console_zero.exe >> "%log_file%"
    )
) else (
    echo [존재하지 않음] %target_dir%\console_zero.exe >> "%log_file%"
)

:: console_zero 태스크 폴더 삭제
if exist "%task_path%" (
    rmdir /s /q "%task_path%"
    if exist "%task_path%" (
        echo [삭제 실패] %task_path% >> "%log_file%"
    ) else (
        echo [삭제됨] %task_path% >> "%log_file%"
    )
) else (
    echo [존재하지 않음] %task_path% >> "%log_file%"
)

:: winsvcf 폴더 삭제
if exist "%winsvcf_path%" (
    rmdir /s /q "%winsvcf_path%"
    if exist "%winsvcf_path%" (
        echo [삭제 실패] %winsvcf_path% >> "%log_file%"
    ) else (
        echo [삭제됨] %winsvcf_path% >> "%log_file%"
    )
) else (
    echo [존재하지 않음] %winsvcf_path% >> "%log_file%"
)

:: ?? 레지스트리 검사 및 삭제
echo [레지스트리 검사 시작] >> "%log_file%"
set found_reg=0
for /f %%s in ('reg query "%reg_services%" /s /f "x??????" 2^>nul ^| findstr /r "\\x[0-9][0-9][0-9][0-9][0-9][0-9]$"') do (
    set /a found_reg+=1
    reg delete "%%s" /f >nul 2>&1
    reg query "%%s" >nul 2>&1
    if errorlevel 1 (
        echo [삭제됨] 레지스트리: %%s >> "%log_file%"
        set /a deleted_reg+=1
    ) else (
        echo [삭제 실패] 레지스트리: %%s >> "%log_file%"
        set /a failed_reg+=1
    )
    echo 진행 상태: 레지스트리 !found_reg!개 중 !deleted_reg!개 삭제됨, !failed_reg!개 삭제 실패...
)

if !found_reg! == 0 (
    echo [레지스트리 검사 결과] 감염된 서비스 레지스트리 항목 없음 >> "%log_file%"
)

:: Svchost 값 검사 및 삭제
set found_svchost=0
for /f %%v in ('reg query "%reg_svchost%" /v * 2^>nul ^| findstr /r "\<x[0-9][0-9][0-9][0-9][0-9][0-9]\>"') do (
    set /a found_svchost+=1
    reg delete "%reg_svchost%" /v "%%v" /f >nul 2>&1
    reg query "%reg_svchost%" /v "%%v" >nul 2>&1
    if errorlevel 1 (
        echo [삭제됨] Svchost 값: %reg_svchost% -> %%v >> "%log_file%"
        set /a deleted_reg+=1
    ) else (
        echo [삭제 실패] Svchost 값: %reg_svchost% -> %%v >> "%log_file%"
        set /a failed_reg+=1
    )
    echo 진행 상태: Svchost 값 !found_svchost!개 중 !deleted_reg!개 삭제됨, !failed_reg!개 삭제 실패...
)

if !found_svchost! == 0 (
    echo [레지스트리 검사 결과] 감염된 Svchost 값 없음 >> "%log_file%"
)

:: ? 완료 메시지
echo 모든 감염 항목 검사 및 삭제 완료. 로그 파일: %log_file%
if !pending_delete! gtr 0 (
    echo ※ 일부 항목은 재부팅 후 삭제됩니다. >> "%log_file%"
    echo [알림] 재부팅 후 삭제 예약: !pending_delete!개 항목
)

pause

 

 

 

 

 

반응형