signature wizard-1 {
ip-proto == tcp
payload /.*wizard.*/
event "Found a Wizard!"
}
In this exercise, we analyze IRC chat traffic as an example of performing application-layer analysis. Using a IRC client, a user connects to a central IRC server, specifying a nickname under which he will be known on that server. Each client can join one or more chat channels and then send messages to these channels which will be broadcasted across all other channel participants. Likewise, a client receives copies of all messages other users are posting to any of the channels he has joined. See Wikipedia for more information on IRC.
Bro has an application-layer IRC analyzer which generates events for most of the IRC protocol's standard commands. See the skeletons below for the events relevant to this exercise.
Finding a user on a channel. Let's suppose somebody told us that an IRC client using the nickname "wizard" is suspected to be malicious and should better be monitored for. We now implement three different ways to report the presence of a specific nickname on an IRC session, all having different properties. For the following, use the trace irc-1.pcap and run Bro with at least the scripts tcp.bro, alarm.bro, and irc.bro, plus those mentioned belowd. When looking at the output, examine in particular notice.log, irc.log, and conn.log.
The template below gives a signature which simply looks for the string wizard in the payload of all connections. Run Bro with this signature on trace irc-1.pcap, also loading the script signatures.bro. Examine the alerts Bro reports, then repeat but add dpd_match_only_beginning=F to the command-line. What's the difference?
Adapt IRC::hot_words (from irc.bro) to raise a notice when Bro sees the string wizard in an IRC connection. Examine the alerts you get.
Write your own handlers for the events irc_names_info and irc_join_message (see skeleton below) to raise a notice when an IRC server specifically reports a user "wizard" being on a channel. Again, examine the alerts.
Finally, compare the alarms of (a) - (c). What are the advantages/disadvantages of each approach? Which one would you chose? Is there anything you would do to improve the detection further?
Extracting host names from IRC sessions. Suppose attackers have been seen publishing names of compromised hosts on IRC channels. We now want to write a Bro script that alarms once it sees an established connection to any host mentioned on IRC. For the following, start from the skeleton below and run Bro on the trace irc-2.pcap.
Write a script which scans all messages posted to any IRC channel for numeric IP addresses (e.g., 72.14.253.103) and prints out the addresses it finds.
Extend the script to raise a notice whenever some host has established a connection to one of the addresses found in (a).
Extend the script further to also handle DNS host names (e.g., www.google.com) found in IRC messages.
Bonus exercise: Our security consultant believes that IRC users joining a channel without saying anything are suspicious. Write a Bro script which reports the nick names of all users who, after joining a channel, leave without posting any message to the channel. Run your script on the trace irc-2.pcap.