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


JavaBo

By: ishkur88  -  Date Submitted: 2008-09-13 12:57:38

  1. package ircbot;
  2.  
  3. /**
  4.  * JavaBot (version 1.2)
  5.  *
  6.  * MIT License, dydx (Josh Sandlin) <dydx@thenullbyte.org>
  7.  *
  8.  */
  9.  
  10. import java.io.*;
  11. import java.net.*;
  12. import java.util.regex.*;
  13. import java.util.Date;
  14.  
  15. public class Main
  16. {
  17. public static void main( String[] args ) throws IOException
  18. {
  19. //connection variables
  20. String server = "irc.snappeh.com";
  21. String nick = "JavaBot";
  22. String login = "JavaBot";
  23. String channel = "#enigmagroup";
  24. int port = 6667;
  25.  
  26. //for security
  27. String owner = "dydx";
  28.  
  29. try {
  30.  
  31. //our socket we're connected with
  32. Socket irc = new Socket( server, port );
  33. //out output stream
  34. BufferedWriter bw = new BufferedWriter( new OutputStreamWriter( irc.getOutputStream() ) );
  35. //our input stream
  36. BufferedReader br = new BufferedReader( new InputStreamReader( irc.getInputStream() ) );
  37.  
  38. //authenticate with the server
  39. bw.write( "NICK " + nick + "n" );
  40. bw.write( "USER " + login + " thenullbyte.org JB: Java Botn" );
  41. bw.flush();
  42.  
  43. //join a channel
  44. bw.write( "JOIN " + channel + "n" );
  45. bw.write( "PRIVMSG " + channel + " :Whats up everybody?n" );
  46. bw.flush();
  47. System.out.println( "Successfully connected to IRC" );
  48.  
  49. String currLine = null;
  50. while( ( currLine = br.readLine() ) != null )
  51. {
  52. //checks for PING, if one is found; return a PONG
  53. Pattern pingRegex = Pattern.compile( "^PING", Pattern.CASE_INSENSITIVE );
  54. Matcher ping = pingRegex.matcher( currLine );
  55. if( ping.find() )
  56. {
  57. bw.write( "PONG " + channel + "n" );
  58. bw.flush();
  59. }
  60.  
  61.  
  62. //check for ownership
  63. Pattern checkOwner = Pattern.compile( "^:"+owner, Pattern.CASE_INSENSITIVE );
  64. Matcher ownership = checkOwner.matcher( currLine );
  65.  
  66. //!exit - quit current irc room
  67. Pattern exitRegex = Pattern.compile( "!exit", Pattern.CASE_INSENSITIVE );
  68. Matcher exit = exitRegex.matcher( currLine );
  69. if( exit.find() && ownership.find() )
  70. {
  71. bw.write( "PRIVMSG " + channel + " :Bye Byen" );
  72. bw.write( "PART " + channel + "n" );
  73. bw.flush();
  74. irc.close();
  75. }
  76.  
  77. //!time - return current time
  78. Pattern timeRegex = Pattern.compile( "!time", Pattern.CASE_INSENSITIVE );
  79. Matcher time = timeRegex.matcher( currLine );
  80. if( time.find() && ownership.find() )
  81. {
  82. Date d = new Date();
  83. bw.write( "PRIVMSG " + channel + " :" + d +"n" );
  84. bw.flush();
  85. }
  86.  
  87. //!sayhi - shows a little message saying hello
  88. Pattern helloRegex = Pattern.compile( "!sayhi", Pattern.CASE_INSENSITIVE );
  89. Matcher hello = helloRegex.matcher( currLine );
  90. if( hello.find() && ownership.find() )
  91. {
  92. bw.write( "PRIVMSG " + channel + " :Hi, I'm a JavaBot. I was coded by dydx in Java!n");
  93. bw.flush();
  94. }
  95.  
  96. //!join <room> - changes to a new room and sets the variables accordingly
  97. Pattern joinRegex = Pattern.compile( "!join", Pattern.CASE_INSENSITIVE );
  98. Matcher join = joinRegex.matcher( currLine );
  99. if( join.find() && ownership.find() )
  100. {
  101. String[] token = currLine.split( " " );
  102. bw.write( "PRIVMSG " + channel + " :Im going over to " + token[4] + "n" );
  103. bw.write( "PART " + channel + "n" );
  104. channel = token[4];
  105. bw.write( "JOIN " + channel + "n" );
  106. bw.flush();
  107. }
  108.  
  109. //just to be mean ;)
  110. Pattern howDoI = Pattern.compile( "how do i", Pattern.CASE_INSENSITIVE );
  111. Matcher how = howDoI.matcher( currLine );
  112. if( how.find() )
  113. {
  114. bw.write( "PRIVMSG " + channel + " :just fucking google it...n" );
  115. bw.flush();
  116. }
  117.  
  118. Pattern whyRegex = Pattern.compile( "why", Pattern.CASE_INSENSITIVE );
  119. Matcher why = whyRegex.matcher( currLine );
  120. if( why.find() )
  121. {
  122. bw.write( "PRIVMSG " + channel + " :DONT ASK QUESTIONS!n" );
  123. bw.flush();
  124. }
  125.  
  126. }
  127. } catch ( UnknownHostException e ) {
  128. System.err.println( "No such host" );
  129. } catch ( IOException e ) {
  130. System.err.println( "There was an error connecting to the host" );
  131. }
  132. }
  133. }
Return to java category list

Who's Online

483 Guests, 101 Users
ckryptix, Ios, viper0i0, Diznablo, rabbidmind, asapong, Nasrudin, CollapsingWalls, mehtaparag, bitstrike, jnony, C, Nicid1, 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, Jakabo