Android on IRC

I recently gave a lecture on DDoS in my Network OS class. I demonstrated a simple bot on the computers in the class. I also demonstrated how portable devices are capable of running bots as well.

I used Android Scripting Environment (ASE) for the demo. The commands I gave it where text, call, speak aloud, and vibrate. The only draw back ASE has is no real GUI support. I can’t wait for the day when OpenGL ES is ported to python. Anyway, ASE allows access to almost all of the phones featurtes. Here is a link to the API ref: http://code.google.com/p/android-scripting/wiki/ApiReference


#-------------------------------------------------------------------------------
# Name:        AndroidIRC
# Purpose:     Android based IRC bot
#
# Author:      K.B. Carte (techb)
#
# Created:     10/26/2010
#
# Copyright:   (c) K.B. Carte (techb) 2010
#-------------------------------------------------------------------------------
#!/usr/bin/env python

import socket, string, time, os, sys, android
droid = android.Android()
os.chdir("sdcard")

droid.makeToast("AndroidBot Started")
droid.vibrate(300)

chan = 'AndroidBot'
ircsite = 'irc.freenode.net'
port = 6667

irc = socket.socket()
irc.connect((ircsite, port))
n = 'AndroidBotV1'
irc.send('NICK %s\r\n' %  n)
irc.send("USER %s %s bla :%s\r\n" % ("Ohlook", 'itsnotmy', 'Realname'))
time.sleep(4)
irc.send("JOIN #%s\r\n" % chan)

readbuffer = ''
while True:
    readbuffer= irc.recv(1024)
    temp=string.split(readbuffer, "\n")
    Check = readbuffer.split(':')
    print readbuffer

    if 'PING' in readbuffer:
        """PIN/PONG connection echo response"""
        irc.send("PONG :%s" % Check[1])

    if 'JOIN' in readbuffer:
        """Greet people that join the channel"""
        na = Check[1].split('!')
        irc.send("PRIVMSG #%s :Hello %s\r\n" % (chan, str(na[0])))

    if '^call' in readbuffer:
        number = readbuffer.split(':')
        droid.phoneCallNumber(number[3].strip())

    if '^text' in readbuffer:
        "texts the number 5 times with given message"
data = readbuffer.split(":")
        number = data[3].strip()
        message = data[4].strip()
        print number, message
        cnt = 0
        while cnt < 5:
            droid.smsSend(number, message)
            cnt += 1

    if '^vibe' in readbuffer:
        droid.vibrate(300)

    if '^say' in readbuffer:
        say = readbuffer.split(":")
        droid.ttsSpeak(say[3].strip()

Advertisements

About Tech B.

I am currently employed as a tech support rep for Frontier DSL internet and Dail-Up service. If you live on the East Coast and have Frontier or the old Verizon, you may have spoken with me at one point. I do side jobs programming and building things for people. I know Python better than any language in my toolbox. I can also develop Android Apps, which are Java based. Other languages include C , VB/VB.NET, some C#, PBASIC, Batch, Javascript, and some PHP. I love microcontrollers and interfacing with the outside world. I am currently working with Arduinos, which are amazing. Also I can work with the Basic Stamp family of microcontrollers; future development includes FPGA and embedded Linux. I was going to school, but have financial issues at the moment that are keeping me from the books. I plan on going back in the next couple semesters and finishing up my Associates in IT, then perusing a BS in computer science.
This entry was posted in Uncategorized and tagged , , , , , , , , , , , , , , , . Bookmark the permalink.

8 Responses to Android on IRC

  1. Adam Evans says:

    I hope I’m not too late to say, “Good Job!”
    Oh how I love Android… Oh how I love IRC… ^_^

    • Tech B. says:

      Android+IRC=amazing. I gave a demo of an android botnet in my network security class that everyone went crazy over. And thank you for liking my stuff =). I am thinking about doing a tutorial series for android and ASE.

  2. dibo says:

    nice work, thx 🙂

    • Tech B. says:

      Your welcome. I was thinking about having it log into a private channel and update my GPS location when requested. Could get more information about the phone too, like battery life, or send a complete link to google maps of my location or something.

  3. emax says:

    Which IRC client were you using on your phone?

  4. Adam Evans says:

    Well… now that I want to get back into SL4A/ASE/whatever it is called now, I could make my own IRC client with it *wonders if that one irc libary coded in Python that’s found online will work for our Android phones (there’s only one way to find out xD)*

    Good luck with life, and I assume you already thought of making a bot that uses the Text-to-Speech engine to say random stuff instead of the normal notification tone when you recieve a text message. That idea is just for humor of course 😉

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s