menu Chancel's Blog
rss_feed lightbulb_outline

我的笔记

搜索
列表(141)
HTTP代理转换为Socks5
类型:Network

将HTTP代理转换为Socks5代理

更新于 2021-09-16 17:21:02
创建于 2021-09-16 17:21:02

HTTP代理转换为Socks5
gost -L=:9000 -F=http://127.0.0.1:8080
Linux创建无法登录的用户
类型:Linux

Linux创建无法登录的用户,常用于运行软件

更新于 2021-09-05 23:17:08
创建于 2021-09-05 23:17:08

Linux创建无法登录的用户
sudo useradd -M -s /sbin/nologin aria2c
Shell命令加解密AES
类型:Linux

使用Shell命令行来加密解密字符串

更新于 2021-08-30 11:47:41
创建于 2021-08-30 11:34:33

Shell命令加解密AES

使用Openssl加密与解密

echo -n "加密字符串" | openssl enc -aes-128-ecb -a -iter 100 -pbkdf2 -e -pass pass:"很随意的密钥" -nosalt
echo 加密后的字符串" | openssl enc -aes-128-ecb -a -iter 100 -pbkdf2 -d -pass pass:"很随意的密钥" -nosalt
手动安装Android SDK
类型:Android

在Windows10下手动安装Android SDK

更新于 2021-08-24 22:41:26
创建于 2021-08-24 16:01:23

手动安装Android SDK

commandlinetools-win的下载地址:developer.android.com/studio

解压之后运行

sdkmanager.bat --sdk_root=C:\Programs\android-sdk\ "cmdline-tools;latest"

安装基础套件

cd C:\Programs\android-sdk\cmdline-tools\latest\bin
sdkmanager.bat --install "emulator"
sdkmanager.bat --install "platform-tools"
sdkmanager.bat --install "build-tools"

创建环境变量

  • ANDROID_SDK_ROOT:C:\Programs\android-sdk
  • ANDROID_SDK_HOME:C:\Programs\android-sdk.android
  • ANDROID_AVD_HOME:C:\Programs\android-sdk.android\avd

修改系统环境变量Path的值,添加如下几个值

  • %ANDROID_SDK_ROOT%\cmdline-tools\latest\bin
  • %ANDROID_SDK_ROOT%\emulator
  • %ANDROID_SDK_ROOT%\platform-tools
  • %ANDROID_SDK_ROOT%\build-tools\31.0

检验配置成功与否 ```shell C:\Users\chancel>sdkmanager --version 5.0

Android APP抓包
类型:Network

使用Fiddler抓包Android APP的HTTPS流量(需要Root权限)

更新于 2021-08-17 09:51:20
创建于 2021-08-16 16:33:03

Android APP抓包
# 首先将Fiddler的cer证书转换成pem证书
➜  openssl x509 -inform der -in FiddlerRoot.cer -out FiddlerRoot.pem 

# 制作Android的内置证书(一)
➜  openssl x509 -inform PEM -subject_hash_old -in FiddlerRoot.pem | head -1
e5c3944b
➜  cat FiddlerRoot.pem > e5c3944b.0 
➜  openssl x509 -inform PEM -text -in FiddlerRoot.pem -out /dev/null >> e5c3944b.0
# 制作Android的内置证书(二)
➜  openssl x509 -inform PEM -subject_hash -in FiddlerRoot.pem | head -1 
82635c12
➜  cat FiddlerRoot.pem > 82635c12.0
➜  openssl x509 -inform PEM -text -in FiddlerRoot.pem -out /dev/null >> 82635c12.0

# 将制作完的2个证书推送到Android的sdcard/中
➜  adb push 82635c12.0 /sdcard/
82635c12.0: 1 file pushed, 0 skipped. 7.6 MB/s (1322 bytes in 0.000s)
➜  adb push e5c3944b.0 /sdcard/
e5c3944b.0: 1 file pushed, 0 skipped. 5.3 MB/s (1322 bytes in 0.000s)

# 使用shell模式并进入Root用户操作Android手机
➜  adb shell
polaris:/ # su

# 挂载system分区,然后复制2张Android证书到系统内部,更改其权限后重启机器
:/ mount -o remount,rw /system
:/ cp /sdcard/e5c3944b.0 /system/etc/security/cacerts/                            
:/ cp /sdcard/82635c12.0 /system/etc/security/cacerts/                            
:/ chmod 644 /system/etc/security/cacerts/e5c3944b.0
:/ chmod 644 /system/etc/security/cacerts/82635c12.0
:/ reboot
pyenv环境打包程序错误
类型:Python

PyInstaller Python library not found

更新于 2021-08-14 00:29:15
创建于 2021-08-14 00:29:15

pyenv环境打包程序错误

解决方法是卸载当前环境的Python解释器并重新安装,安装时附带生成共享库的参数,大致如下

env PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install 3.6.9
VSCode配置代码行长度
类型:Python

使用VSCode时如何配置代码行长度

更新于 2021-09-01 16:06:47
创建于 2021-08-13 23:26:14

VSCode配置代码行长度

VSCode的setting.json文件如下,使用flake8/yapf作为格式化插件

{
    "python.linting.flake8Enabled": true,
    "python.formatting.provider": "yapf",
    "python.formatting.yapfArgs": ["--style={column_limit=128}"],
    "python.linting.flake8Args": ["--max-line-length=320", "--ignore=W191, E266, W504"],
    "python.linting.pylintEnabled": false
}
MitmProxy抓包软件指南
类型:Software

优秀的开源抓包软件MitmProxy

更新于 2021-08-12 11:21:25
创建于 2021-08-12 11:15:47

MitmProxy抓包软件指南
❯ sudo pacman -S mitmproxy

❯ mitmweb

需要抓包HTTPS的设备设置网络代理至mitmproxy的代理监听端口,然后访问 http://mitm.it/

Linux使用fsck修复磁盘
类型:Linux

Ubuntu1804 异常关机导致磁盘错误无法正常启动系统(Read Only)

更新于 2021-08-12 10:03:27
创建于 2021-08-12 10:03:27

Linux使用fsck修复磁盘

进入CD-LIVE系统后,查找相关系统盘并修复

❯ sudo fdisk -l                                                               ~
[sudo] password for chancel: 
Disk /dev/nvme0n1: 465.76 GiB, 500107862016 bytes, 976773168 sectors
Disk model: KIOXIA-EXCERIA SSD                      
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: D01367E9-8A85-5249-815A-240299266312

Device             Start       End   Sectors   Size Type
/dev/nvme0n1p1      4096    618495    614400   300M EFI System
/dev/nvme0n1p2    618496 841037811 840419316 400.7G Linux filesystem
/dev/nvme0n1p3 841037812 976768064 135730253  64.7G Linux swap

Disk /dev/loop0: 99.38 MiB, 104202240 bytes, 203520 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/loop1: 99.38 MiB, 104210432 bytes, 203536 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

...

❯ sudo fsck /dev/nvme0n1p2
logging自动创建日志文件
类型:Python

logging的配置以YAML形式导入项目后自动创建日志文件

更新于 2021-09-02 11:02:52
创建于 2021-07-08 11:28:38

logging自动创建日志文件
import logging
import yaml

with open('logging.yaml' 'r', encoding='utf-8') as f:
    config = yaml.load(f, Loader=yaml.FullLoader)
    for key,value in config['handlers'].items():
        if value.get('filename'): 
            if not os.path.exists(os.path.dirname(value.get('filename'))):
                os.mkdir(os.path.dirname(value.get('filename')))
    logging.config.dictConfig(config)
logger = logging.getLogger('main.common')
Curl命令统计耗时情况
类型:Linux

使用curl命令分析请求情况

更新于 2021-07-01 16:45:08
创建于 2021-07-01 16:44:29

Curl命令统计耗时情况

创建需要分析的文本内容,可参考CURL - www.mit.edu

➜  ~ cat curl-format.txt
    time_namelookup:  %{time_namelookup}\n
       time_connect:  %{time_connect}\n
    time_appconnect:  %{time_appconnect}\n
      time_redirect:  %{time_redirect}\n
   time_pretransfer:  %{time_pretransfer}\n
 time_starttransfer:  %{time_starttransfer}\n
                    ----------\n
         time_total:  %{time_total}\n

使用 curl-format.txt 内的格式进行分析

curl -w "@curl-format.txt" -o /dev/null -s -L "https://baidu.com"

资料转载自:使用 curl 命令分析请求的耗时情况

Rsync增量同步文件
类型:Linux

使用Rsync增量备份服务器文件

更新于 2021-07-01 15:01:33
创建于 2021-07-01 15:01:33

Rsync增量同步文件

备份机器开启Rsync服务,创建配置文件

➜  ~ sudo systemctl status rsync
● rsync.service - fast remote file copy program daemon
   Loaded: loaded (/lib/systemd/system/rsync.service; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2021-06-30 16:15:49 UTC; 14h ago
 Main PID: 8218 (rsync)
    Tasks: 1 (limit: 4655)
   CGroup: /system.slice/rsync.service
           └─8218 /usr/bin/rsync --daemon --no-detach

Jun 30 16:15:49 ubuntu1804-server systemd[1]: Started fast remote file copy program daemon.

可以看到B机器的Rsync正常运行中,接下来编辑(或添加)Rsync的配置文件

sudo vim /etc/rsyncd.conf

# /etc/rsyncd: configuration file for rsync daemon mode
# See rsyncd.conf man page for more options.
# configuration example:
uid = root
gid = root
use chroot = no
max connections = 10
strict modes = no
port = 41000
# pid文件,如无法再次启动可删除
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsyncd.lock
log file = /var/run/rsyncd.log

[rsync-backup]
path = /mnt/sdb/rsync-server
comment = rsync backup
ignore errors
read only = no
write only = no
hosts allow = 10.0.0.0/24
list = false
uid = chancel
gid = chancel
auth users = rsync
# 用户认证配置文件
secrets file = /etc/rsync-user.pass

/etc/rsync-user.pass文件

sudo vim /etc/rsync-user.pass

user:password

rsync-user.pass文件的权限应为400,然后重启下B机器的Rsync服务

sudo chmod 400 /etc/rsync-user.pass
sudo systemctl restart rsync.service

接下来我们登录A机器,同样创建 /etc/rsync-user.pass 文件,存入密码即可

sudo vim /etc/rsync-user.pass

password

注意rsync-user.pass为400权限

sudo chmod 400 /etc/rsync-user.pass

进行同步

rsync -vzrtp --delete --progress --password-file=/etc/rsync_user.pass --port=41000 /srv rsync@192.168.11.11::rsync-backup/10.0.0.100
1 of 12 | A total of 141