EG Information

Main Index
EG Manual
Disclaimer
Legal Information
Hall of Fame
Hall of Shame
Member Rankings
Members List
Meet the Staff

Training Missions

Read Me First New
Basic Skills
Realistic Scenarios
Cryptography
Software Cracking
Linux ELF Binary Cracking
Logical Thinking
Programming
Patching
Steganography
Deface This Wall
/dev/null
/dev/urandom

Knowledge Bank

Discussion Forums
Enigma Chat New
RSS Feeds RSS
Articles / Tutorials
Videos
Online EG MP3 Player Radio
Enigma Zine
Downloads
Tools New

Code Resources

Submit Code
Ajax
ASM
Bash
C
CPP
Csharp
Delphi
Haskell
Java
Javascript
Jython
Lisp
mIRC
MySQL
Perl
PHP
Python
QBASIC
VisualBasic

Hakipedia: An open collaborative for all your information security needs.

The Urinal

Click Here To Vote For EG!

Has Enigma Group Helped You? Then Help Us By Advertising For Us. Place One Of The Following Images On Your Site.

enigma group

enigma group

enigma group

enigma group

Enigma Group's Code Bank


Smiple Bot

By: NotMyOwn  -  Date Submitted: 2008-09-12 00:49:42

  1. <?php
  2. /*
  3.  * Written By: NotMyOwn
  4.  * Email: admin@unrealcomps.org
  5.  *
  6.  * This is for Enigma Group and is ment soley for learning. This bot is in no way advanced, but it is a good learning ground.
  7.  * Note: \n is basically the same as a human hitting enter and makes it so the command runs, this is ONLY for Linux,for it
  8.  * to work on Windows, you must use \r\n
  9.  */
  10. //Main variables
  11. $host = "unrealcomps.org";
  12. $port = 6667;
  13. $nick = "MyBot";
  14. $chan = "#test";
  15. $readbuffer = "";
  16.  
  17. //Open the socket to the IRC Host
  18. $irc = fsockopen($host, $port, $errno, $errstr, 30);
  19.  
  20. //Checks to see if the connection was made and there were no problems
  21. if ($irc)
  22. {
  23. /*fputs is how you write data to the server, it is basically how you make the bot type
  24.   Bots don't act exactly like a real person and when start a command you must remember it is typing in
  25.   the main server window, and not the channel window
  26.   Commands are capitalized and not used like you would with a client, because when you type /nick in a
  27.   client it turns out as NICK in the main code*/
  28.  
  29. //Since you aren't using a client that does ths automatically, we must define it all.
  30. //This sets the nickname of the bot ^see variables above to change the nickname^
  31. fputs($irc, "NICK " . $nick . "\n");
  32. //This sets the whois of the bot, since this is a simple bot, it will all just be the nickname repatedly
  33. fputs($irc, "USER " . $nick . " " . $nick . " " . $nick . " :" . $nick . "\n");
  34. //This is the command to join the channel, see above to change the channel
  35. fputs($irc, "JOIN :" . $chan . "\n");
  36. //This is how you talk on the channel, PRIVMSG is basically like PMing a user on IRC only it is
  37. //PMing the whole channel because we are on the main server window, and not the channel
  38. fputs($irc, "PRIVMSG " . $chan . " :" . $nick . " is now online\n");
  39.  
  40. //This will keep the bot running because while in this loop you can never read feof (end-of-file)
  41. while (!feof($irc))
  42. {
  43. //fgets is the opisite of fputs, it gets what as already been displayed on the server
  44. $line = fgets($irc, 128);
  45. //This echos out the $line so we can see what the server has said
  46. echo "" . $line . "\n";
  47. //This parses $line into an array so we can select certain vlaues from it (for the commands) and using a space as the dilimeter
  48. //which is where it will make a new value, so like this: $text = "this is a sentance"; $text = exploit(" ", $text); print_r($text);
  49. //which will display something like this: array('this', 'is', 'a', 'sentance');
  50. $line = explode(" ", $line);
  51. //This will mainly be used to keep the bot from timing out, see below for usage
  52. $line0 = trim($line[0]);
  53. //This will in general be the main text a user says
  54. $command = trim($line[3]);
  55.  
  56. //Uncomment the below to for debugging and figuring out how long the array is and what $line[#] you should use
  57. //print_r($line);
  58.  
  59. //Checks to see if the server has pinged us for a timeout
  60. if ($line0 == "PING")
  61. {
  62. //If it has, says pong to the server, $line[1] is the server name, because the way pong works is: /pong irc.server.net
  63. fputs($irc, "PONG " . $line[1] . "\n");
  64. }
  65.  
  66. //This is how to do a basic command, note: the : is required because if you type something it shows up as :My test on the main code
  67. //What is inside the "" is what the command will be, so to use this command, you would type "!quit" without quotes into IRC from a client
  68. elseif ($command == ":!exit")
  69. {
  70. //Like I said before, this just basically types things into the channel, this notifys us that the bot has quit
  71. fputs($irc, "PRIVMSG " . $chan . " :Connection Closed\n");
  72. ///Closes the connection to the server/host
  73. fclose($irc);
  74. //Ends the php code so it doesn't just keep running forever if you ran it from command line
  75. die();
  76. }
  77. }
  78.  
  79. //Closes the connection to the server/host
  80. fclose($irc);
  81. //Ends the php code so it doesn't just keep running forever if you ran it from command line
  82. die();
  83.  
  84. }
  85. {
  86. //If there was an error opening the socket, displays the error and the error number
  87. echo "Error: " . $errstr . " | #(" . $errno . ")<br />\n";
  88. }
  89.  
Return to php category list

Who's Online

487 Guests, 99 Users
Diznablo, ckryptix, Nicid1, Ios, viper0i0, rabbidmind, Nasrudin, CollapsingWalls, mehtaparag, bitstrike, jnony, C, Nusquam-Redono-Sapientia, bazcrown, saifulfaizan, The End, Ultraminor, psychomarine, st3alth, themastersinner, pgmrlink, login, lionaneesh, ishkur88, mahraja, Mac, chekifr, gandalf88, Vap0r, t0ast, tantrum6226, BnE, Distorted, Psiber_Syn, Ausome1, invas10n, oldgoat, freedaysbecumei, BinaryShinigami, Rex_Mundi, Red_beard, Strobeflux, s0m3nak3dguy, Descent, teehee, machupicchu, Genetix, Anandarl, NotMyOwn, thegamerdude, Godzila, popo12341234, RedEvolution, velocity_b, myne17, teto111, aVoid, Central-Gsm, 1101, JackalReborn, InjectioN, h4lted, c0re, DisPater, markt4death, splatta, Jackowacko, saint556, Pyron2312, Azerion, howsens, white.hat.gone.bad, vazzilly, pwunkz, Inverted, QuarterCask, Infernoe11, deskata, cr4ck3rj4ck, Blizer, jasonmax, j0sh, gwenwavor, N4g4c3N, spizeyboy, Network X, Uino59, Jae Cee, ianFDK, saykov, medhaavee, zofy, demonkiller410, Stumble, SaMTHG, kishore, Raze, helasraizam, Venom1019