Skip to content

Latest commit

 

History

History
788 lines (538 loc) · 25.8 KB

File metadata and controls

788 lines (538 loc) · 25.8 KB

安全研究员的macOS配置完全指南

文档最新更新请访问:https://github.com/feicong/re-docs/edit/master/macOS.md

Apple M4 Pro为演示配置的环境,收到机器后,开机然后开始设置。

环境准备

首先,打开App Store下载安装Xcode。

启动Xcode,安装好命令行工具。或者终端执行xcode-select --install也行。

终端执行sudo spctl --master-disable来开启第三方或ad-hoc签名的程序运行。在macOS15以上,执行这条命令后,过需要在设置->隐私与安全性->安全性中,改为任何来源。

接下来,安装HomeBrew。下载地址需要代理一下,执行如下命令安装:

/bin/bash -c "$(curl -fsSL https://github.com/Homebrew/install/raw/master/install.sh)"

下载软件可能有时候不能成功,执行如下命令设置一下代理。

echo 'export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git"' >> ~/.zprofile
echo 'export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git"' >> ~/.zprofile
export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git"
export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git"

常用的命令行工具与库

下面这些工具与库建议都安装一下。

编程语言与开发工具

brew install pkg-config poetry gtk+3 gtk4 libtool autoconf automake help2man pygobject3 python3 python@3.11 qt \
    llvm llvm@18 ruby lua make meson ninja node npm gcc nvm vala vala-language-server git git-lfs openjdk openjdk@17 \
    kotlin kotlin-native go perl gradle maven pipx vim cmake oracle-jdk oracle-jdk@17

工具与库

brew install graphviz libsoup grep libsoup@2 plantuml gstreamer libssh2 aria2 axel libtiff protobuf psutils libunibreak pup libusb \
    pycparser bash libusbmuxd bash-completion libusrsctp bc binutils imagemagick bison libx11 brotli qemu u-boot-tools jpeg-turbo \
    jq json-glib readline jsoncpp jsonrpc-glib libyaml repo reprepro colima quickjs coreutils cryptography libarchive scrcpy curl grpcurl \
    sdl2 lz4 shared-mime-info dbus lzip simg2img dbus-glib docker-completion dtc dwarf mbedtls dwarfutils libedit sqlite libelf \
    libevent mitmproxy ffmpeg libffi file-formula libgcrypt flac libgee mpg123 tcpdump flex tesseract fontconfig ncurses tesseract-lang \
    freetype texinfo libimobiledevice gawk tree ca-certificates gdbm libmagic nspr ucl gettext gh unifdef libnghttp2 unzip libnghttp3 \
    libnice glib glib-networking webp libpcap openjpeg wget gnu-sed libplist gnupg libpng openssl openssl@1.1 gnutls libpsl x265 x264 \
    gobject-introspection xz googletest pcre2 gperf z3 libslirp zip libsodium zstd p7zip jtool2 ios-deploy binwalk upx XQuartz \
    apktool jadx capstone neofetch mpv windsurf websocat 

配置x11

打开XQuartz,在设置的安全性中打开允许连接。关闭后,重新打开它。

echo "export DISPLAY=:0" >> ~/.zshrc
source ~/.zshrc

export DISPLAY=:0
xhost +
# 运行xclock看效果

配置环境变量

修改:/.bash_profile 或者修改:/.zprofile

export HOMEBREW_API_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/api"
export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles"

export LANG="en_US.UTF-8"
export LC_ALL="en_US.UTF-8"
export LC_CTYPE="en_US.UTF-8"
export LC_COLLATE="en_US.UTF-8"

export PATH="/opt/homebrew/opt/llvm/bin:~/Library/Python/3.9/bin:~/go/bin:$PATH"

export ANDROID_HOME=~/Library/Android/sdk
export ANDROID_SDK_ROOT=~/Library/Android/sdk

export NDK_ROOT=$ANDROID_HOME/ndk/28.1.13356709
export ANDROID_NDK_ROOT=$ANDROID_HOME/ndk/28.1.13356709
export ANDROID_NDK=$ANDROID_HOME/ndk/28.1.13356709
export PATH=$PATH:$ANDROID_NDK_ROOT

export PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools
export PATH=$PATH:$ANDROID_HOME/emulator
export JAVA_HOME=/Library/Java/JavaVirtualMachines/openjdk-17.jdk/Contents/Home
export PATH="$JAVA_HOME/bin:$PATH"
export PATH="$PATH:/Applications/010 Editor.app/Contents/CmdLine:/opt/homebrew/bin"

软件功能说明

graphvizplantuml画图必备。

apktoolsmali反编译APK要用到。

aria2wgetcurl下载软件用到。

yt-dlpyoutube-dl是下载youtube视频的命令行工具。

llvmgcc编译器套件用于软件开发。

limacolima采用命令行方法管理虚拟机。

pythonnode等是运行大量第三方软件的基础环境。

scrcpy用于安卓设备投屏。

tesseract用于OCR识别。

ffmpeg用于视频编解与转码,这一个就够了。

其中,还有大量的库是这些软件用到的依赖,还有一些是开发vala程序用到的,这里不一一介绍了。

配置

一些软件需要配置登陆与设置代理。

gh

这个是github官方的命令行工具,管理仓库贼方便。登陆后就可以使用了。

gh auth login

golang

go env -w GOPROXY=https://goproxy.cn,direct

pip

设置pip的mirror。

export HOMEBREW_PIP_INDEX_URL="https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple"
python3 -m pip install --upgrade pip
pip config set global.index-url https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple

npm

设置npm的mirror。

mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
npm config set registry https://registry.npmmirror.com

安装一些npm工具。

npm install -g @anthropic-ai/claude-code @google/gemini-cli typescript

maven

mkdir -p ~/.m2

echo '<?xml version="1.0" encoding="UTF-8"?> 
<settings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="settings.xsd">
    <mirrors>
        <mirror>
            <id>aliyunmaven</id>
            <mirrorOf>*</mirrorOf>
            <name>阿里云公共仓库</name>
            <url>https://maven.aliyun.com/repository/public</url>
        </mirror>

        <mirror>
            <id>huaweicloud</id>
            <mirrorOf>*</mirrorOf>
            <url>https://repo.huaweicloud.com/repository/maven/</url>
        </mirror>

        <mirror>
            <id>nexus-163</id>
            <mirrorOf>*</mirrorOf>
            <name>Nexus 163</name>
            <url>https://mirrors.163.com/maven/repository/maven-public/</url>
        </mirror>

        <mirror>
            <id>nexus-tencentyun</id>
            <mirrorOf>*</mirrorOf>
            <name>Nexus tencentyun</name>
            <url>https://mirrors.cloud.tencent.com/nexus/repository/maven-public/</url>
        </mirror>
    </mirrors>
</settings>' > ~/.m2/settings.xml

maven项目中,执行mvn install命令即可看到效果。

gradle

依赖mirror:

code ~/.gradle/init.gradle.kts

fun RepositoryHandler.enableMirror() {
    all {
        if (this is MavenArtifactRepository) {
            val originalUrl = this.url.toString().removeSuffix("/")
            urlMappings[originalUrl]?.let {
                logger.lifecycle("Repository[$url] is mirrored to $it")
                this.setUrl(it)
            }
        }
    }
}

val urlMappings = mapOf(
    "https://repo.maven.apache.org/maven2" to "https://mirrors.tencent.com/nexus/repository/maven-public/",
    "https://dl.google.com/dl/android/maven2" to "https://mirrors.tencent.com/nexus/repository/maven-public/",
    "https://plugins.gradle.org/m2" to "https://mirrors.tencent.com/nexus/repository/gradle-plugins/"
)

gradle.allprojects {
    buildscript {
        repositories.enableMirror()
    }
    repositories.enableMirror()
}

gradle.beforeSettings { 
    pluginManagement.repositories.enableMirror()
    dependencyResolutionManagement.repositories.enableMirror()
}

设置代理:

code ~/.gradle/gradle.properties

# https://docs.gradle.org/current/userguide/networking.html
systemProp.http.proxyHost=127.0.0.1
systemProp.http.proxyPort=7890
systemProp.https.proxyHost=127.0.0.1
systemProp.https.proxyPort=7890

常用的GUI工具

首先是常用的IDE,根据个人开发需要安装。brew install android-studio intellij-idea pycharm clion goland

JB系列有免费社区版本的,专业版本收费可以弄开源项目申请免费使用,可以用一年。也可以其它渠道购买或和谐。有条件建议购买,生产力工具真的好用。

通过brew安装

brew install --cask wireshark charles reqable postman httpie 1password disk-drill windows-app displays \
    flux utm balenaetcher phantomjs vienna beyond-compare visual-studio-code github chatgpt raycast \
    ghidra vnc-viewer hiddenbar crescendo iina cryptomator itraffic iterm2 tabby termius orbstack obs \
    microsoft-office google-chrome xmind localsend 010-editor wechat qq bilibili showyedge angry-ip-scanner \
    battery microsoft-auto-update viz pearcleaner pdf-expert hex-fiend cherry-studio claude cursor lulu \
    ios-app-signer motrix listen1 bit-slicer clash-verge-rev qingg logseq Snipaste licecap drawio syncthing \
    db-browser-for-sqlite macs-fan-control keyboardcleantool karabiner-elements pika gemini-cli Shottr pixel-picker

brew install alienator88/homebrew-cask/sentinel-app

wiresharkcharles还有reqable是抓包必备的。

1password是最好用的密码管理软件。

disk-drill是不错的磁盘管理工具。

image

windows-app是微软件出品的3389远程连接软件,免费好用,基本杀死了苹果官方出品的同类收费软件。

image

displays是桌面分辨率管理软件。

orbstack是Docker与虚拟机一体的免费软件,必装。

image

obs是开源的录屏与推流软件,最好用,没有之一。

image

usbimagerbalenaetcherraspberry-pi-imager这三个是烧硬盘镜像的工具,我一般用中间这个。

image

flux是护眼神器,自动根据时间与时区调整显示器亮度与色温。

image

vienna是免费的RSS订阅器,我每天用它来看博客与技术仓库更新。

image

beyond-compare010-editor是文件编辑与比较的利器。

visual-studio-code是每天必用的编辑器,也可以说是IDE了,微软出品的全球开发人员都喜爱的工具。

ghidra是开源的反编译工具,用于替换商业软件IDA Pro,但目前无法动摇其地位。

github是官方的仓库代码管理工具,也怪好用的。vnc-viewer是VNC远程连接工具,有总比没有强。

image

hiddenbar是用于管理状态栏的图标们的显示与隐藏,免费的用起来也还可以。

image

crescendo是一个内核扩展,用于行为与网络分析,安全分析人员利器。

image

iina是开源的最好用的视频播放器,没有之一。

image

cryptomator是一个加密工具,管理小秘密必备。

image

itraffic看本机进程的流量,抓偸传流量的软件,恶意上传一目了然。

image

tabbytermius是一个开源免费一个收费的终端工具,也都不错,还有个免费的iterm2我也很喜欢。

image

microsoft-office是办公套件,微软出品,全球人都在用。

image

google-chrome是谷歌的chrome浏览器,也是天天要用的。

xmind画图工具算是国光了。

image

localsend跨平台传文件,我全靠它。

image

wechatqq不用说。

telegram是全球最好用的IM。

bilibili是二次元的天堂。

showyedge对于来说必不可少,它把输入法不同的状态在状态栏用不同颜色的一条线显示,让我知道当前用的是什么输入法,不用梗着脖子看右上角状态栏。

image

angry-ip-scanner用于扫描本地网络IP与设备信息,设备多的网络环境必不可少。

image

snip免费的截图工具,好用。

sentinel对于苹果用户也是必不可少的,经常下载的第三方工具没签名或者ADHOC签名,提示损坏删除,用这个工具抹抹文件的附加信息就可以了。

image

battery是免费的电池管理软件,苹果的电池老金贵了,用它观察准没错。

viz是开源的截图与屏幕二维码扫描工具,比snip还好用的样子。

image

pearcleaner是开源的软件卸载管理软件。

image

pdf-expert是看PDF必备的。

image

hex-fiend是免费的十六进制编辑工具。

image

utmvmware-fusion都是个人免费使用的虚拟机软件,但我现在用orbstack了。

image

raycast用于替代官方的聚焦搜索,怪好用的。

reqable是跨平台的网络抓包与API测试工具。

ios-app-signer是IPA签名工具,只是自己买证书,真的贵。

image

motrix是开源的下载软件,我这里就不推荐迅雷了。

image

listen1是免费的跨平台音乐播放器的,搜歌与听歌于一体,我就不推荐国内的音乐播放器了。

image

bit-slicer是搜内存的工具,懂的都懂。

image

clash-verge-revclash-for-windows的继任者。

image

qingg清歌是最好用的免费输入法了。

image

logseq是一款开源的笔记管理软件,支持markdown,好用,是typora的平替。

image

ImageOptim是一款开源免费的图片压缩工具。

image

Snipaste是一款跨平台功能强大的截图与贴图工具,提供了个人免费版本与付费版。

licecap是一款跨平台开源的gif录制工具。

image

drawio是一款开源的画图工具。跨平台免费真好用。

image

syncthing是一款开源的跨平台的文件同步工具。

alias与bash函数

弄别名与bash函数可以加速处理命令行操作。

cc() {
    git rev-list --count $1
}

rebase() {
    git rebase -i HEAD~$1 && git push -f
}

status() {
    git status
}

log() {
    git log
}

push() {
    git add --all && git commit -m "$1" && git push
}

# squash 4 "update"
squash() {
    git reset --soft HEAD~$1 && git add --all && git commit -m "$2." && git push -f
}

touchm() {
    find $1 -type f -exec touch -m {} \;
}


# rmall ~/ ".DS_Store"
rmall() {
    find $1 -name $2 -exec rm {} \;
}

rmdsstore() {
    find . -name ".DS_Store" -exec rm {} \;
}

# renameext jpg zip
renameext() {
    rename "s/$1/$2/" *
}

cls() {
    /usr/bin/osascript -e 'tell application "System Events" to tell process "Terminal" to keystroke "k" using command down'
}

# xattrd ~/Downloads/1.app
xattrd() {
    /usr/bin/xattr -r -d com.apple.quarantine $1
    # or
    /usr/bin/xattr -c $1
}

# random 32
random() {
    echo $RANDOM | md5sum | head -c $1; echo;
}

xattrd() {
    if [[ -z $1 ]]; then
        echo xattrd path
        return
    fi
    xattr -r -d com.apple.quarantine "$1"
}

alias clean=cls

alias clear="printf '\33c\e[3J'"

alias ll="ls -al"

alias simlog="tail -f ~/Library/Logs/CoreSimulator/*/system.log"

配置

一些常用工具还需要额外的配置一下。

vscode配置

使用下面的命令安装插件。

extensions=(
  "redhat.java"
  "vscjava.vscode-gradle"
  "vscjava.vscode-java-pack"
  "vscjava.vscode-java-debug"
  "adelphes.android-dev-ext"
  "OmarDulaimi.breakpoint-bookmarks"
  "ms-dotnettools.csharp"
  "bito.bito"
  "bpfdeploy.bpftrace"
  "codezombiech.gitignore"
  "cornell3110sp20.rml-highlighter"
  "dbaeumer.vscode-eslint"
  "eriklynd.json-tools"
  "formulahendry.code-runner"
  "foxundermoon.shell-format"
  "genieai.chatgpt-vscode"
  "github.codespaces"
  "github.copilot"
  "github.copilot-chat"
  "github.github-vscode-theme"
  "github.remotehub"
  "github.vscode-github-actions"
  "github.vscode-pull-request-github"
  "golang.go"
  "google.aidl-language"
  "gruntfuggly.todo-tree"
  "jebbs.plantuml"
  "josetr.cmake-language-support-vscode"
  "jrieken.md-navigate"
  "mesonbuild.mesonbuild"
  "ms-azuretools.vscode-docker"
  "ms-ceintl.vscode-language-pack-zh-hans"
  "ms-dotnettools.vscode-dotnet-runtime"
  "ms-python.autopep8"
  "ms-python.debugpy"
  "ms-python.isort"
  "ms-python.python"
  "ms-python.vscode-pylance"
  "ms-vscode-remote.remote-containers"
  "ms-vscode-remote.remote-ssh"
  "ms-vscode-remote.remote-ssh-edit"
  "ms-vscode-remote.remote-wsl"
  "ms-vscode-remote.vscode-remote-extensionpack"
  "ms-vscode.cmake-tools"
  "ms-vscode.cpptools"
  "ms-vscode.cpptools-extension-pack"
  "ms-vscode.cpptools-themes"
  "ms-vscode.hexeditor"
  "ms-vscode.makefile-tools"
  "ms-vscode.powershell"
  "ms-vscode.remote-explorer"
  "ms-vscode.remote-repositories"
  "ms-vscode.remote-server"
  "ms-vscode.vscode-typescript-next"
  "osstekz.vala-code"
  "prince781.vala"
  "redhat.vscode-commons"
  "redhat.vscode-xml"
  "redhat.vscode-yaml"
  "rogalmic.bash-debug"
  "twxs.cmake"
  "vadimcn.vscode-lldb"
  "vscjava.vscode-maven"
  "vscode-icons-team.vscode-icons"
  "xaver.clang-format"
  "shd101wyy.markdown-preview-enhanced"
  "saoudrizwan.claude-dev"
  "Continue.continue"
)

for extension in "${extensions[@]}"; do
  echo "正在安装扩展: $extension"
  code --install-extension "$extension"
done
image

orbstack配置

启动orbstack一次。然后命令行配置它。

orb config docker
{
  "registry-mirrors": [
      "https://docker.1ms.run",
      "https://docker.xuanyuan.me",
      "https://dockerhub.timeweb.cloud",
      "http://mirrors.ustc.edu.cn/",
      "http://mirror.azure.cn/",
      "https://docker.m.daocloud.io"
    ]
}

Ctrl+O,Ctrl+X保存并退出。下载镜像测试,效果如下:

image

安装一个arm64版本的Ubuntu系统日常使用。

orb create ubuntu:jammy ubuntu

安装一个x86_64版本的Ubuntu系统解决一些x86_64使用场景。

softwareupdate --install-rosetta --agree-to-license
orb create --arch amd64 ubuntu:jammy ubuntu64

安装好这些虚拟机系统后,进去后docker配置使用下面的命令。

sudo tee /etc/docker/daemon.json <<EOF
{
  "registry-mirrors": [
      "https://docker.1ms.run",
      "https://docker.xuanyuan.me",
      "https://dockerhub.timeweb.cloud",
      "http://mirrors.ustc.edu.cn/",
      "http://mirror.azure.cn/",
      "https://docker.m.daocloud.io"
    ]
}
EOF

UTM配置

安装好程序后,下载Ubuntu镜像。地址可以点击界面的浏览UTM库,然后选择Ubuntu。 目前最新下载地址是:https://archive.org/download/ubuntu-20.04-arm64-utm/ubuntu-20.04-arm64-utm.zip

下载解压,然后双击Ubuntu22.04.utm,会自动导入。右链编译,改内存8g。 image

改共享,添加主机的下载目录,方便虚拟机与主机共享文件。 image

改网络,虚拟vlan方式,可以添加端口转发,方便ssh连接

image

完事后,启动虚拟机,输入用户名与密码:ubuntu。打开终端安装openssh-server与其它需要用到的软件。

image

Chrome设置

主要是扩展程序。访问页面是:https://chromewebstore.google.com/detail/xxx xxx为扩展的ID。

我安装的一些扩展如下。

cfhdojbkjhnklbpkdaibdccddilifddb
anlikcnbgdeidpacdbdljnabclhahhmd
dodmmooeoklaejobgleioelladacbeki
ghbmnnjooekpmoecnnnilnnbdlolhkhi
mclkkofklkfljcocdinagocijmpgbhab
cpcifbdmkopohnnofedkjghjiclmhdah
legbfeljfbjgfifnkmpoajgpgejojooj
padekgcemlokbadohgkifijomclgjgif
kpdjmbiefanbdgnkcikhllpmjnnllbbc
lieodnapokbjkkdkhdljlllmgkmdokcm
ikhdkkncnoglghljlkmcimlnlhkeamad
bciglihaegkdhoogebcdblfhppoilclp
bpoadfkcbjbfhfodiogcnhhhpibjhbnh
dhdgffkkebhmkfjojejmpbldmpobfkfo

iTerm2配置

导入主题:

git clone https://github.com/mbadolato/iTerm2-Color-Schemes --depth 1
cd iTerm2-Color-Schemes
tools/import-scheme.sh schemes/*

重启iTerm2,cmd+,打开设置,切换到Profiles->Default->Colors,Color Presets里面选主题,比如Ubuntu主题。

然后执行:touch ~/.hushlogin禁止显示最后登陆信息。

打开 Preferences > Profiles > Window。找到 Style 设置,选择No Title Bar,禁止显示标题。

image

解决中文件乱码:

在.bash_profile或.zshrc中加入:

export LANG="en_US.UTF-8"
export LC_ALL="en_US.UTF-8"
export LC_CTYPE="en_US.UTF-8"
export LC_COLLATE="en_US.UTF-8"

科学软件

2024比较常用的有ClashX Proclash-for-windows。 2025使用clash-verge-rev的好像更多一些。

这里就不展开安装与配置了。

收费软件

根据个人使用习惯,还有一些收费的软件是要使用到的。比如CleanMyMac XParallels DesktopIDA ProTyporaBeyond Compareparagon-extfsparagon-ntfs010-editor。它们多可以通过brew来安装,IDA Pro除外,安装好后可以试用或购买。

Parallels Desktop就是一年一订真的贵,看自己的需要了。

这是说一下Office,微软对“免费”使用目前查得并不严格,brew安装的版本,可以使用网上的2021 VL license无限制使用。使用microsoft-auto-update可以完美的升级更新,有条件还是建议购买正版,好用省事。

Office激活

参考

https://brew.sh/

https://mirrors.tuna.tsinghua.edu.cn/help/homebrew/

https://mirrors.tuna.tsinghua.edu.cn/help/pypi/

https://code.visualstudio.com/docs/editor/extension-marketplace

https://docs.orbstack.dev/machines/

https://www.sweetscape.com/download/010editor/

https://www.paragon-software.com/

https://developer.chrome.com/docs/extensions/how-to/distribute/install-extensions?hl=zh-cn

https://github.com/gitbito/CLI

https://github.com/pypa/pipx