Jetsong 发布的文章

原因是 高级Mock 可以执行系统命令,如果恰好用的默认端口3000,并且没有关闭注册功能。很大概率会中招。

解决办法: 编辑 config.json

1.修改默认端口

2.关闭注册

3.关闭mock(看需求)

已经中招的清理步骤:

kill KaBot
killall -9 /tmp/moni.lod

killall -9 /tmp/gates.lod

killall -9 /usr/bin/bsd-port/getty/lock

rm -rf /tmp/moni.lod

rm -rf /tmp/gates.lod

rm -rf /etc/init.d/selinux
rm -rf /etc/rc1.d/S97DbSecuritySpt /etc/rc1.d/S99selinux
rm -rf /etc/rc2.d/S97DbSecuritySpt /etc/rc2.d/S99selinux
rm -rf /etc/rc3.d/S97DbSecuritySpt /etc/rc3.d/S99selinux
rm -rf /etc/rc4.d/S97DbSecuritySpt /etc/rc4.d/S99selinux
rm -rf /etc/rc5.d/S97DbSecuritySpt /etc/rc5.d/S99selinux
rm -rf /usr/bin/lsof /bin/ps /bin/ss /bin/netstat

mv /usr/bin/dpkgd/* /bin/

mv /bin/lsof /usr/bin/

参考:

https://github.com/YMFE/yapi/issues/2229

https://v2ex.com/t/787350

命令计算给定的一个或多个有序集的交集,其中给定 key 的数量必须以 numkeys 参数指定,并将该交集(结果集)储存到 destination 。

默认情况下,结果集中某个成员的分数值是所有给定集下该成员分数值之和。

ZINTERSTORE destination numkeys key [key ...] [WEIGHTS weight] [AGGREGATE SUM|MIN|MAX]

 

$ redis-cli -h 127.0.0.1 -p 6379
127.0.0.1:6379> zadd z1 2 cat 3 dog
(integer) 2
127.0.0.1:6379> zadd z2 1 cat 4 goose
(integer) 2
// 返回交集里成员的数量。新集合中成员分数值默认是给定集合下成员分数值之和
127.0.0.1:6379> ZINTERSTORE z3 2 z1 z2
(integer) 1
127.0.0.1:6379> ZRANGE z3 0 -1 withscores
1) "cat"
2) "3"
// 使用权重时,也返回交集里成员的数量。默认依然是分数值相加,但是要先乘以权重值,此处即是2*1+1*2=4
127.0.0.1:6379> ZINTERSTORE z4 2 z1 z2 WEIGHTS 1 2
(integer) 1
127.0.0.1:6379> ZRANGE z4 0 -1 withscores
1) "cat"
2) "4"
// AGGREGATE包含SUM/MIN/MAX。ZINTERSTORE默认使用SUM。
// MIN即为取给定集合里最小的分数值,MAX则反之
127.0.0.1:6379> ZINTERSTORE z5 2 z1 z2 AGGREGATE MIN
(integer) 1
127.0.0.1:6379> ZRANGE z5 0 -1 withscores
1) "cat"
2) "1"
127.0.0.1:6379> ZINTERSTORE z6 2 z1 z2 AGGREGATE MAX
(integer) 1
127.0.0.1:6379> ZRANGE z6 0 -1 withscores
1) "cat"
2) "2"
//AGGREGATE和权重WEIGHTS一起使用时,取经过权重计算后的结果
//此处即2*3>1*4
127.0.0.1:6379> ZINTERSTORE z7 2 z1 z2 WEIGHTS 3 4 AGGREGATE MAX
(integer) 1
127.0.0.1:6379> ZRANGE z7 0 -1 withscores
1) "cat"
2) "6"



 

1,dd操作就是简单的按字节复制,什么分区表啊,MBR(master boot record)啊统统照搬;

1. 磁盘克隆
也就是把整个硬盘复制一份。当然你首先需要在计算机上在接上一块新硬盘,并让系统识别。例如这块硬盘可能被识别为/dev/sdb,原有硬盘叫/dev/sda. 然后你可以在linux命令行上简单地执行:
dd if=/dev/sda of=/dev/sdb
对就这么简单,此命令完成后,你的第二块硬盘上将有一个和第一块硬盘一模一样的副本,也是可以启动的。因为dd操作就是简单的按字节复制,什么分区表啊,MBR啊统统照搬。
当然你也可以做一些微调,来定制一下克隆操作。例如你可能希望把硬盘上的内容全部备份到一个磁盘文件中,而不是另一块新硬盘,你可以
dd if=/dev/sda of=~/disk1.img
之后,disk1.img就是备份好的磁盘映像文件,你可以复制或转移到其他介质也可以压缩一下:
gzip disk1.img #generates disk1.img.gz
或者在创建磁盘映像文件的同时就执行压缩:
dd if=/dev/sda | gzip > disk.img.gz
dd if=/dev/sda | bzip2 > disk.img.bz2

不错吧!ghost的功能都有了。

2.分区克隆
如果我们不想克隆整块磁盘,只想把某些存放数据的分区备份一下,你会需要克隆一个分区。正如预备知识所述,分区在linux下也是一个文件。例如
dd if=/dev/sda1 of=~/part1.img
将把第一块磁盘的第一个分区备份到名为part1.img的文件中。
也可以进行分区复制:
dd if=/dev/hda1 of=/dev/hda3
将把分区一原样复制到分区3.

3. 从镜像文件恢复磁盘或分区
很简单,把上面命令中,of和if指向的文件名互换一下即可实现恢复。例如
dd if=disk1.img of=/dev/sda
把保存在disk1.img中的映像恢复到第一块磁盘
dd if=part1.img of=/dev/hda2
把保存在part1.img中的映像恢复到第一块硬盘的第二个分区

最后,需要注意一点是,无论备份还是恢复,都需要保证 of 指向的文件或磁盘空间要大于 if 指向的内容,因为是按字节复制 如果没有足够的空间去存储内容,备份自然会失败。

jetsong-server:

1. 备份 dd if=/dev/nvme1n1 of=centos_disk_220502.img 

2. 还原 dd if=centos_disk_220502.img of=/dev/sda

硬盘复制

 dd if=/dev/nvme1n1 of=/dev/sda bs=1M 1>log.log 2>&1

 

1. 修改 gitlab 配置 vi /etc/gitlab/gitlab.rb ,增加 custom_hooks_dir 路径:

默认路径: /opt/gitlab/embedded/service/gitlab-shell/hooks/

2. 执行 sudo gitlab-ctl reconfigure

3. 创建 hook 文件

自定义脚本目录要符合 <custom_hooks_dir>/<hook_name.d>/*的规范。具体来说就是:

  • 在自定的 custom_hooks_dir目录下可创建三个文件夹对应三类 server hook name
    • pre-receive.d
    • update.d
    • post-receive.d
  • 在每个文件夹下可创建任意文件,在对应的 hook 时期,gitlab 就会主动调用
  • 文件名以 ~结尾的文件会被忽略
  • 如果想看这部分的实现细节可以看 <gitlab-shell>/lib/gitlab_custom_hook.rb文件


4.环境变量

Environment variable Description
GL_ID GitLab identifier of user that initiated the push. For example, user-2234
GL_PROJECT_PATH (GitLab 13.2 and later) GitLab project path
GL_PROTOCOL (GitLab 13.2 and later) Protocol used with push
GL_REPOSITORY project-<id> where id is the ID of the project
GL_USERNAME GitLab username of the user that initiated the push

Pre-receive and post-receive server hooks can also access the following Git environment variables.

Environment variable Description
GIT_ALTERNATE_OBJECT_DIRECTORIES Alternate object directories in the quarantine environment. See Git receive-packdocumentation.
GIT_OBJECT_DIRECTORY GitLab project path in the quarantine environment. See Git receive-pack documentation.
GIT_PUSH_OPTION_COUNT Number of push options. See Git pre-receivedocumentation.
GIT_PUSH_OPTION_<i> Value of push options where i is from 0 to GIT_PUSH_OPTION_COUNT - 1. See Git pre-receivedocumentation.

 

git config credential.helper store

centos8 安装php8

1.下载软件
   

 wget http://www.ijg.org/files/jpegsrc.v9d.tar.gz
 wget http://prdownloads.sourceforge.net/libpng/libpng-1.6.37.tar.gz?download
 wget http://mirrors.nju.edu.cn/gnu/libiconv/libiconv-1.16.tar.gz

2.安装 扩展库
    2.1 
    

 tar zxvf jpegsrc.v9d.tar.gz 
 cd jpeg-9d/
 ./configure --prefix=/usr/local/lib/jpeg --enable-shared --enable-static
 make
 make install
 cd ../

     2.2
    

 tar zxvf libpng-1.6.37.tar.gz 
 cd libpng-1.6.37
 ./configure --prefix=/usr/local/lib/libpng
 make
 make install
 cd ../

     2.1
     tar zxvf libiconv-1.16.tar.gz
     cd libiconv-1.16/
     ./configure --prefix=/usr/local/lib/libiconv
     make
     make install
     cd ../

     vi /etc/ld.so.conf.d/my.conf

    添加yihang:
    /usr/local/lib
    /usr/local/lib/lib
    

    然后:
    ldconfig

    tar zxvf libxml2-2.9.10.tar.gz
    cd libxml2-2.9.10/
    ./configure
    make
    make install
    cd ../

    yum install gcc gcc-c++ autoconf zlib zlib-devel glibc glibc-devel libpng libpng-devel libjpeg-turbo libjpeg-turbo-devel freetype freetype-devel xz gd libmcrypt mhash libxml2 libxml2-devel glib2 glib2-devel bzip2 bzip2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel  libidn  openssl openssl-devel 
    yum install sqlite-devel libcurl-devel oniguruma libzip libzip-devel

    tar xvzf sqlite-autoconf-3071502.tar.gz
    cd sqlite-autoconf-3071502
    ./configure --prefix=/usr/local
    make
    make install

    https://github.com/kkos/oniguruma

    ./configure
    ./configure --prefix=/usr --libdir=/lib64
    make
    sudo make install


3.安装php
    cd php-8.0.3
    export LIBS="-lm -lresolv"
    export DYLD_LIBRARY_PATH="/lib/:/usr/lib/:/usr/local/lib:/lib64/:/usr/lib64/:/usr/local/lib64:/usr/libexec/"n
    export LD_LIBRARY_PATH="/lib/:/usr/lib/:/usr/local/lib:/lib64/:/usr/lib64/:/usr/local/lib64:/usr/libexec/"
    ./configure \
    --prefix=/usr/local/service/php8.0.3 \
    --with-config-file-path=/usr/local/service/php8.0.3/etc \
    --with-mysqli=shared,mysqlnd \
    --with-pdo-mysql=shared,mysqlnd \
    --enable-opcache \
    --with-iconv=/usr/local/lib/libiconv \
    --with-freetype \
    --with-jpeg \
    --with-libxml \
    --enable-xml \
    --enable-bcmath \
    --enable-shmop \
    --enable-sysvsem \
    --enable-inline-optimization \
    --with-curl \
    --enable-mbregex \
    --enable-fpm \
    --enable-mbstring  \
    --with-openssl \
    --with-mhash \
    --enable-pcntl \
    --enable-sockets \
    --enable-gd \
    --with-zip \
    --enable-soap \
    --with-fpm-user=www \
    --with-fpm-group=www \
    --with-mysql-sock=/data/mysql/mysql.sock \


    --disable-rpath \ (使用后,不会搜索附加的动态链接库,会造成opcache编译不过)
    --with-xmlrpc \ XML-RPC是Userland Software公司设计的一种格式:是一种使用HTTP协议传输XML格式文件来获取远程程序调用(Remote Procedure Call)的传输方式。官方网站是www.xmlrpc.com。
    --enable-maintainer-zts \  pthreads多线程扩展需要开启zts

    
    make 
    make install

    echo -e '\nexport PATH=/usr/local/service/php8.0.3/bin:/usr/local/service/php8.0.3/sbin:$PATH\n' >> /etc/profile && source /etc/profile

4.配置文件

5. 安装扩展
ImageMagick是一套功能强大、稳定而且免费的工具集和开发包,可以用来读、写和处理超过89种基本格式的图片文件

        yum -y install perl-CPAN ImageMagick

        tar zxvf ImageMagick-7.0.7-28.tar.gz
        cd ImageMagick-7.0.7-28
        ./configure
        make
        make install
        cd ../

        tar zxvf imagick-3.4.3.tgz
        cd imagick-3.4.3
        /usr/local/service/php8.0.3/bin/phpize
        ./configure --with-php-config=/usr/local/service/php8.0.3/bin/php-config
        make
        make install
        cd ../

    5.2 redis

    wget https://download.redis.io/releases/redis-6.2.1.tar.gz
    make
    make PREFIX=/usr/local/service/redis install
    cd ../

    mkdir -p /data/redis/6379/
    配置文件:redis.conf
    启动:
    /usr/local/service/redis/bin/redis-server /data/redis/6379/redis.conf & 2&1 > /data/redis/6379/redis.log


    redis.so

    https://github.com/phpredis/phpredis/archive/5.3.3.tar.gz

    tar zxvf 5.3.3.tar.gz 
    cd  phpredis-5.3.3/
    /usr/local/service/php8.0.3/bin/phpize
    ./configure --with-php-config=/usr/local/service/php8.0.3/bin/php-config
    make
    make install
    cd ..


    swoole

    wget https://github.com/swoole/swoole-src/archive/v4.6.3.tar.gz
    tar zxvf v4.6.3.tar.gz
    cd swoole-src-4.6.3
    /usr/local/service/php8.0.3/bin/phpize
    ./configure --with-php-config=/usr/local/service/php8.0.3/bin/php-config --enable-swoole-json
    make
    make install
    cd ..