1、 启动Windows PowerShell,以管理员身份运行。
2、 使用root账号登录wsl
我之前已安装Ubuntu-22.04,并强制使用WSL2。
Ubuntu-22.04,可以通过Windows Store进行安装。
强制使用WSL2的命令
wsl --set-default-version 2
3、 在/opt目录下下载anaconda
cd /opt
curl -L -O https://mirrors.tuna.tsinghua.edu.cn/github-release/conda-forge/miniforge/LatestRelease/Miniforge3-Linux-x86_64.sh
Sage Installation Guide 中给出的下载安装地址不好用,使用清华开源软件的镜像源。
4、 安装anaconda,并创建虚拟环境sage,python版本为3.11
bash Miniforge3-Linux-x86_64.sh
conda create -n sage sage python=3.11
安装结束时会提示是否初始化conda,用户需要决定是否让conda在每次启动终端时自动初始化。
installation finished.
Do you wish to update your shell profile to automatically initialize conda?
This will activate conda on startup and change the command prompt when activated.
If you'd prefer that conda's base environment not be activated on startup,
run the following command when conda is activated:
conda config --set auto_activate_base false
You can undo this by running `conda init --reverse $SHELL`? [yes|no]
推荐yes,然后禁用base环境自动激活(避免每次启动终端都进入 Conda 环境)。
conda config --set auto_activate_base false
可以手动激活
conda activate base # 按需手动激活
5、 查看虚拟环境
conda env list
6、 激活sage环境,查看python版本。
conda activate sage
python --version
7、 安装pwntools
pip install pwntools
我这里已经安装过。
8、启动jupyter notebook
sage -n --allow-root
复制红框的内容(两行选择任意一行),粘贴到浏览器地址栏。
跳转后,点击New。
如果执行的是普通的python代码,选择Python3(ipykernel)。
弹出的页面可以输入代码执行。
如果是进行sagemath运算的,选择sagemath,比如ctf的crypto 或pwn方面。