Post

workspace

리눅스 작업환경 세팅 과정 및 듀얼부팅 설정

workspace

Dual boot

1
2
Laptop: Omen-16 xf0052ax
OS: Windows 11 + Arch Linux

기본 노크북에 Arch Linux를 설치한 SSD를 추가 슬롯에 장착함으로써 듀얼부팅 환경을 구축하였다.

Troubleshooting

omen에서 BIOS가 부트로더를 선택 우선순위를 강제로 windows로 설정하는 문제가 발생하였다. 해결할 방법이 딱히 안 보여서, 근처의 리눅스 잘 아는 친구과 얘기해서 windows EFI를 바꿔버리는 방법으로 해결하였다.

The following script will move every efi bootable files to .efi .efi.bak

1
2
3
mount /dev/nvme?n1p1 /mnt
cd /mnt/EFI
find . -type f -name "*.efi" -exec mv "{}" "{}.bak" \;

Then, modify grub to reflect the changes

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# /etc/grub/grub.cfg

...
### BEGIN /etc/grub.d/30_os-prober ###
# This menu entry is supported only on EFI platforms.
if [ "$grub_platform" = "efi" ]; then
menuentry 'Windows Boot Manager (on /dev/nvme0n1p1)' --class windows --class os $menuentry_id_option 'osprober-efi-E41B-34E0' {
        insmod part_gpt
        insmod fat
        search --no-floppy --fs-uuid --set=root E41B-34E0
# Change start >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-       chainloader /efi/Microsoft/Boot/bootmgfw.efi
+       chainloader /efi/Microsoft/Boot/bootmgfw.efi.bak
# Change end   <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
}
fi
### END /etc/grub.d/30_os-prober ###
...

This way, the BIOS will not find any windows bootloader in the EFI partition and will go to grub.

Note: You should configure efibootmgr as well :)

Windows 업데이트시 위 세팅이 망가질 수 있는데, 그럴때마다 f9를 통해서 부트로더 선택메뉴에서 grub을 선택해주면 된다. 이후 동일하게 efi와 grub 설정을 바꿔주면 된다.

Config

1
2
3
4
5
6
DisplayManager: SDDM
WindowManager: KDE
Terminal: Konsole
Shell: Zsh + Oh My Zsh (with powerlevel10k)
Editor: code
Font: JetBrains Mono, JetBrainsMono Nerd Font Mono

Oh My Zsh

설치 후 powerlevel10k 테마를 설치한다.

이후 필요한 플러그인을 여기서 설치하고 약간의 추가 옵션을 아래처럼 .zshrc에 추가한다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
## Configure completions
bindkey              '^I'         menu-complete
bindkey "$terminfo[kcbt]" reverse-menu-complete

bindkey -M menuselect  '^[[D' .backward-char  '^[OD' .backward-char
bindkey -M menuselect  '^[[C'  .forward-char  '^[OC'  .forward-char

bindkey -M emacs \
    "^[p"   .history-search-backward \
    "^[n"   .history-search-forward \
    "^P"    .up-line-or-history \
    "^[OA"  .up-line-or-history \
    "^[[A"  .up-line-or-history \
    "^N"    .down-line-or-history \
    "^[OB"  .down-line-or-history \
    "^[[B"  .down-line-or-history \
    "^R"    .history-incremental-search-backward \
    "^S"    .history-incremental-search-forward \
    #
bindkey -a \
    "^P"    .up-history \
    "^N"    .down-history \
    "k"     .up-line-or-history \
    "^[OA"  .up-line-or-history \
    "^[[A"  .up-line-or-history \
    "j"     .down-line-or-history \
    "^[OB"  .down-line-or-history \
    "^[[B"  .down-line-or-history \
    "/"     .vi-history-search-backward \
    "?"     .vi-history-search-forward \
    #

zstyle ':autocomplete:*' delay 0.3  # seconds (float)
zstyle ':autocomplete:*' min-input 3  # 최소 글자수

# 너무 많이 나오는거 방지
zstyle -e ':autocomplete:*:*' list-lines 'reply=( $(( LINES / 3 )) )'

Shortcuts

  • Ctrl + Shift + f : Open Firefox
  • Super + Shift + ↑ : Maximize window

yay

설치하셔야 합니다.

Keyboard

키보드가 약간 어려워서 까먹지 않게 저장한다.

일단 LiteHell님의 글을 참고하여 fcitx5 설정을 마친다. 그래도 일부 설치가 다른 것이 있어 다시 적다면,

1
2
3
4
5
6
7
8
9
10
11
sudo pacman -S fcitx5-im fcitx5-hangul

cat << EOF >> /etc/environment
GTK_IM_MODULE=fcitx
QT_IM_MODULE=fcitx
QT4_IM_MODULE=fcitx
QT5_IM_MODULE=fcitx
XMODIFIERS=@im=fcitx
EOF 

echo 'fcitx5 -d' >> ~/.xprofile

이후 fcitx5-configtool에서 Hangul을 추가하면 거의 다 된다.

이때 Keyboard 설정에서 keybinding을 선택하여 right alt를 한/영 전환키로 설정해준다. virtual keyboard가 아님에 유의한다. 이렇게 하면 윈도우에서 사용하던 것과 동일한 키보드 환경을 구축할 수 있다.

Micromamba

설치하고 alias conda='micromamba'를 .zshrc에 추가한다.

1
2
3
conda create -n ctf python=3.11
conda activate ctf
pip install pwntools requests

vmliux-to-elf

1
2
3
4
cd $HOME
git clone https://github.com/marin-m/vmlinux-to-elf.git
cd vmlinux-to-elf
echo 'export PATH="$HOME/vmlinux-to-elf:$PATH"' >> ~/.zshrc

debugger

디버거는 pwndbg를 메인으로, kernel을 디버깅할 때는 gef를 쓴다. 그러기 위해서 gef의 경우 gef로 심볼릭 링크를 걸어준다.

  1. pwndbg 설치
1
2
3
4
cd $HOME
git clone https://github.com/pwndbg/pwndbg.git
cd pwndbg
./setup.sh
  1. gef 설치

Prerequisite를 먼저 설치한다. 설치가 필요한 패키지는 여기서 확인할 수 있다. 아마 후술한 설치용 레포/패키지 모음에 대부분 포함되어 있을 것이다.

그리고 전제는 conda 환경에서 gef를 설치하는 것이다.

1
2
conda activate ctf
pip install crccheck unicorn capstone ropper keystone-engine tqdm

설치 스크립트 수동 설치

1
2
3
4
5
6
7
8
9
wget -q https://raw.githubusercontent.com/bata24/gef/dev/gef.py -O $HOME/.gdbinit-gef.py
cat << EOF >> $HOME/gef
#!/bin/bash
gdb -nx -x $HOME/.gdbinit-gef.py "\$@"
EOF

chmod +x $HOME/gef
sudo ln -s $HOME/gef /usr/local/bin/gef
echo "[*] gef installed at $HOME/gef"

설치용 레포 / 패키지 모음

  • nvm
  • yay -S visual-studio-code-bin AUR
  • sudo pacman -S base-devel gem (필수품)
  • sudo pacman -S checksec ghidra (hack tools)
  • yay -S rp++ (hack tools)
  • gem install one_gadget seccomp-tools (gem-related)
  • (misc)
    • sudo pacman -S solaar (logitech device manager)
    • sudo pacman -S ouch (compression tool)
    • sudo pacman -S fastfetch (system info fetcher)
    • sudo pacman -S bat (cat alternative)
    • sudo pacman -S tealdeer (tldr with rust)
    • sudo pacman -S z (directory jumper)
This post is licensed under CC BY 4.0 by the author.