From 6df41f7f48799662a22cc11d47cb92fdc3646fe5 Mon Sep 17 00:00:00 2001 From: Dnomd343 Date: Mon, 17 Oct 2022 21:34:50 +0800 Subject: [PATCH] docs: update alpine package fetch script --- docs/campus_network_cracking.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/docs/campus_network_cracking.md b/docs/campus_network_cracking.md index 825ba44..399539d 100644 --- a/docs/campus_network_cracking.md +++ b/docs/campus_network_cracking.md @@ -207,18 +207,27 @@ XProxy 容器默认不自带 WireGuard 功能,需要额外安装 `wireguard-to > 以下代码用于生成 Alpine 的 WireGuard 安装脚本,您也可以选择手动拉取 apk 安装包 ```python +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +import os +import re +import sys + alpine = '3.16' -import os, re, sys if len(sys.argv) != 2: print('Invalid argument') sys.exit(1) + workDir = os.path.join(os.path.dirname(os.path.realpath(__file__)), sys.argv[1]) + output = os.popen(' '.join([ 'docker', 'run', '--rm', '-it', '-v', '%s:/pkg' % workDir, '-w', '/pkg', 'alpine:%s' % alpine, 'sh', '-c', '\'apk update && apk fetch -R %s\'' % sys.argv[1] ])).read() print("%(line)s\n%(msg)s%(line)s" % {'line': '=' * 88, 'msg': output}) + with open(os.path.join(workDir, 'setup'), 'w') as script: script.write("#!/bin/sh\ncd `dirname $0`\napk add --no-network " + ' '.join([ s + '.apk' for s in re.findall(r'Downloading (\S+)', output)