# Analysis of an IRC based Botnet **[stratosphereips.org/blog/2019/4/12/analysis-of-a-irc-based-botnet](https://www.stratosphereips.org/blog/2019/4/12/analysis-of-a-irc-based-botnet)** Stratosphere IPS April 18, 2019 **_This blog post was authored by_** **_[María José Erquiaga (@MaryJo_E), on 2019-04-26](https://twitter.com/MaryJo_E)_** _This blogpost aims to give a insight of an IRCBased botnet describing the network behavior_ _and showing the analysis of the C&C. By analyzing this botnet network traffic it was_ _possible to identify the botmasters using an IRC channel and observe not only the_ _conversation between them but also the orders they give to the bot._ ## Botnet behavior The infected device was a RaspberryPi (ARMv6) using Raspbian OS. The sample we executed was 49fd1cb22e0325c1f9038160da534fc23672e5509e903a94ce5bcddc893eb2c0, the capture Id is [34-1. According to VirusTotal, the possible name for that malware sample is Mirai.](https://mcfp.felk.cvut.cz/publicDatasets/IoTDatasets/CTU-IoT-Malware-Capture-34-1/) After running the malware for the first time, the device contacts the IP 185.244.25.235 on port 80/TCP and downloads a file called “misp” using GNU Wget agent. It repeats the same action by downloading other files. The name of the downloaded files are: mips, mipsel, sh4, x86, armv7l, armv6l, i686, powerpc, i586, m68k, sparc and armv4l. Then, the bot establishes a connection with the IP 185.244.25.235 on port 6667 and joins an IRC channel called Summit. The communication with the remote server is the following: ``` IP 185.244.25.235.6667 > 192.168.1.195.48986: irc.Summit.gov.GoV NOTICE AUTH :*** Looking up your hostname... irc.Summit.gov.GoV NOTICE AUTH :*** Found your hostnameIP 192.168.1.195.48986 > 185.244.25.235.6667: NICK [ARM4T|PCVREB]USER VHIDFQC localhost localhost :VHIDFQC ``` The remote server sends a PING and our devices replies with a PONG. Then, the infected device, receives its first order, given by the botmaster which nickname is AmpAttacks: ``` AmpAttacks :TCP Packeting 66.67.61.168! ``` The bot sends SYN NS Packet packets to 66.67.61.168 port 63798. The NS flag, which stands for Nonce Sum, is still an experimental flag used to help protect against accidental malicious concealment of packets from the sender[1]. The services related to the port ----- **63798 are for Apple: Xsan. Xsan Filesystem Access. This means that either the remote** server was using that port for another service or that the botnet owners knew, or the attack aimed to an Apple device. The domain registered to that IP is rr.com. The nmap scanning to that IP reveals that all ports are filtered, it also reveals that the host is up using the domain cpe-66-67-61_168.rochester.res.rr.com._ The bot then sends an IRC Packet to report the successful end of AmpAttack TCP Flood Against 66.67.61.168: IRC Packet reporting TCP Flood Against 66.67.61.168 Since our bot is on the IRC channel, it is possible to observe the conversation between the members of that channel. According to the IRC RFC [2], the format to send messages on an IRC channel is: ``` msgto =/ nickname / ( nickname "!" user "@" host ) ``` Considering that format, it is possible to identify the nicknames and users in the channel, some of them are: Spoof, Tragedy, Erradic and AmpAttacks. In the conversation, the botmasters are talking about IRC. Some of the conversation is transcript here: ----- ``` IP 185.244.25.235 > 192.168.1.195:irc.Summit.gov.GoV MODE ##Summit +q Spoof Spoof!Spoof@Summit.gov.GoV PRIVMSG ##Summit :crazy how i know rock shit about ircs lmdao Spoof!Spoof@Summit.gov.GoV PRIVMSG ##Summit :fao* Spoof!Spoof@Summit.gov.GoV PRIVMSG ##Summit :crazy how i know rock shit about ircs lmdao Spoof!Spoof@Summit.gov.GoV PRIVMSG ##Summit :fao* Tragedy!Erradic@Summit.gov.GoV PRIVMSG ##Summit :It's literally just a chatting program Tragedy!Erradic@Summit.gov.GoV PRIVMSG ##Summit :But the IRC bot forces the device to join the channel as another "client" Tragedy!Erradic@Summit.gov.GoV PRIVMSG ##Summit :And they listen Tragedy!Erradic@Summit.gov.GoV PRIVMSG ##Summit :!* makes them listen Tragedy!Erradic@Summit.gov.GoV MODE ##Summit +v [x86_64|BWQLXKB] Tragedy!Erradic@Summit.gov.GoV MODE ##Summit +v [MIPS|WGEQAV] Tragedy!Erradic@Summit.gov.GoV MODE ##Summit +v [ARM4T|PCVREB] AmpAttacks!AmpAttacks@Summit.gov.GoV PRIVMSG ##Summit :??? Tragedy!Erradic@Summit.gov.GoV PRIVMSG ##Summit :Giving them a voice so they can reply Tragedy!Erradic@Summit.gov.GoV PRIVMSG ##Summit :This is the part I need to fix Tragedy!Erradic@Summit.gov.GoV PRIVMSG ##Summit :!* STD 1.1.1.1 1 1 ``` Our bot replies: ``` ##Summit :STD Packeting 1.1.1.1! ``` The bot sends two kind of packets to the IP 1.1.1.1. Those are: 1. To the IP 1.1.1.1 on port 256/UDP: bad length 4096 > 1472 ``` SUMMIT.. %s, STD Flood Against %s Finished!....Incorrect Usage, %s :XMAS