Browse Source

docs: update alpine package fetch script

v1.x.x
Dnomd343 2 years ago
parent
commit
6df41f7f48
  1. 11
      docs/campus_network_cracking.md

11
docs/campus_network_cracking.md

@ -207,18 +207,27 @@ XProxy 容器默认不自带 WireGuard 功能,需要额外安装 `wireguard-to
> 以下代码用于生成 Alpine 的 WireGuard 安装脚本,您也可以选择手动拉取 apk 安装包 > 以下代码用于生成 Alpine 的 WireGuard 安装脚本,您也可以选择手动拉取 apk 安装包
```python ```python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import re
import sys
alpine = '3.16' alpine = '3.16'
import os, re, sys
if len(sys.argv) != 2: if len(sys.argv) != 2:
print('Invalid argument') print('Invalid argument')
sys.exit(1) sys.exit(1)
workDir = os.path.join(os.path.dirname(os.path.realpath(__file__)), sys.argv[1]) workDir = os.path.join(os.path.dirname(os.path.realpath(__file__)), sys.argv[1])
output = os.popen(' '.join([ output = os.popen(' '.join([
'docker', 'run', '--rm', '-it', '-v', '%s:/pkg' % workDir, '-w', '/pkg', 'docker', 'run', '--rm', '-it', '-v', '%s:/pkg' % workDir, '-w', '/pkg',
'alpine:%s' % alpine, 'sh', '-c', '\'apk update && apk fetch -R %s\'' % sys.argv[1] 'alpine:%s' % alpine, 'sh', '-c', '\'apk update && apk fetch -R %s\'' % sys.argv[1]
])).read() ])).read()
print("%(line)s\n%(msg)s%(line)s" % {'line': '=' * 88, 'msg': output}) print("%(line)s\n%(msg)s%(line)s" % {'line': '=' * 88, 'msg': output})
with open(os.path.join(workDir, 'setup'), 'w') as script: with open(os.path.join(workDir, 'setup'), 'w') as script:
script.write("#!/bin/sh\ncd `dirname $0`\napk add --no-network " + ' '.join([ script.write("#!/bin/sh\ncd `dirname $0`\napk add --no-network " + ' '.join([
s + '.apk' for s in re.findall(r'Downloading (\S+)', output) s + '.apk' for s in re.findall(r'Downloading (\S+)', output)

Loading…
Cancel
Save