1 / 13

Networking 2 Project

Networking 2 Project. Android App to control an IRC Bot. Background. What is IRC and what does an IRC Bot do?

louie
Download Presentation

Networking 2 Project

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Networking 2 Project Android App to control an IRC Bot

  2. Background • What is IRC and what does an IRC Bot do? • IRC is Internet Relay Chat. It is a place that you can connect to and send messages, and files from all over the world. You have the ability to chat privately and in channels with many people. • IRC Bots are clients that sit in channels and have the ability to manipulate the channels. The Bot itself can control the channel and make it so other people can control the channel. This means it can make it so you can kick and ban people and give them rights.

  3. The Project • What I wanted to do with this app: • Start and Stop a PHP Bot from the app • Change the settings of the bot • Server • Port • Server Password • Channel • Name of the Bot • Run commands on the server • View the settings • Change the server • Run on Wi-Fi and 3G

  4. Research • What I had to find out? • How to execute commands directly from php on a Linux Box. • exec(“/usr/bin/php –f /var/www/bot.php &”) • How to Post to a website with a Android. (Next Slide) • Brush up on Menu’s and HttpGet to get the data.

  5. Posting with Android • String address = BotControl.Server + "/post.php"; //get address • HttpClient client = new DefaultHttpClient(); • HttpPost post = new HttpPost(address); • List<NameValuePair> pairs = new ArrayList<NameValuePair>(); • pairs.add(new BasicNameValuePair("serv", serv.getText().toString())); • pairs.add(new BasicNameValuePair("port", port.getText().toString())); • pairs.add(new BasicNameValuePair("name", name.getText().toString())); • pairs.add(new BasicNameValuePair("nick", nick.getText().toString())); • pairs.add(new BasicNameValuePair("chan", chan.getText().toString())); • pairs.add(new BasicNameValuePair("pass", pass.getText().toString())); • //try catches • post.setEntity(new UrlEncodedFormEntity(pairs)); • //try catches • HttpResponse response = client.execute(post);

  6. How is this done? • The server (Ubuntu 10.10) runs a apache web server with PHP and MYSQL also. • The Bot is a PHP script that gets its settings from the MYSQL database. • The app connects to the server and runs commands to start and stop the Bot, through PHP scripts. • The app posts to the web server to manipulate the settings. • The app gets information from the server by talking to the web server also.

  7. The Bot • The Bot is a PHP script that runs on the server that I have the ability to execute with certain commands. • To execute the bot from command line you would do something similar to this. /usr/bin/php –f /var/www/bot.php & • To kill the bot you would do something like this: $output = shell_exec("ps | grep php | awk '{print $1}'"); if ($output != null) { kill($output); echo "Killed process id:/" $output /""; } else { echo “Bot is not running!"; }

  8. The Bot Continued… • Kill command continued: function kill($PID){ if(is_running($PID)){ exec("kill -KILL$PID"); return true; }else return false; } function is_running($PID){ exec("ps $PID", $ProcessState); return(count($ProcessState) >= 2); }

  9. The App • Settings Page • Has the ability to change the Server, Port, Channel,Name, Nickname, and the password to get into the server. • When you click submit the app posts to a web server to update the database.

  10. The App Continued… • Menu • You have the ability to Edit Settings, View Settings, Start Bot, Stop Bot, Run Command(on the server), and change the servers address. • View Settings • You can view the current settings by hitting the View settings button.

  11. The App Continued… • Command Page • Here you can run any command you want on the Linux server, even shut it down if you want. You will just have to authenticate if you wanted to do that. • Server Address • Here you can change the server address.

  12. Running the Bot

  13. Questions?

More Related