Skip to content

Commit

Permalink
Merge pull request #42 from MythicAgents/chrono-deprecation
Browse files Browse the repository at this point in the history
Replace deprecated chrono functions
  • Loading branch information
MEhrn00 authored Dec 19, 2024
2 parents 2214c3f + 7a59fa6 commit 104d5c1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
7 changes: 5 additions & 2 deletions Payload_Type/thanatos/thanatos/agent_code/src/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,13 +239,16 @@ impl Agent {
if now < working_start {
// Calculate the sleep interval if the current time is before
// the working hours
let delta = Duration::seconds(working_start.timestamp() - now.timestamp());
let delta = Duration::seconds(
working_start.and_utc().timestamp() - now.and_utc().timestamp(),
);
sleep_time = delta.to_std().unwrap();
} else if now > working_end {
// Calculate the sleep interval if the current time as after the
// working hours
let next_start = working_start.checked_add_signed(Duration::days(1)).unwrap();
let delta = Duration::seconds(next_start.timestamp() - now.timestamp());
let delta =
Duration::seconds(next_start.and_utc().timestamp() - now.and_utc().timestamp());
sleep_time = delta.to_std().unwrap();
}

Expand Down
6 changes: 4 additions & 2 deletions Payload_Type/thanatos/thanatos/agent_code/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,13 @@ fn run_beacon() -> Result<(), Box<dyn Error>> {

// Check the agent's working hours and don't check in if not in the configured time frame
if now < working_start {
let delta = Duration::seconds(working_start.timestamp() - now.timestamp());
let delta =
Duration::seconds(working_start.and_utc().timestamp() - now.and_utc().timestamp());
std::thread::sleep(delta.to_std()?);
} else if now > working_end {
let next_start = working_start.checked_add_signed(Duration::days(1)).unwrap();
let delta = Duration::seconds(next_start.timestamp() - now.timestamp());
let delta =
Duration::seconds(next_start.and_utc().timestamp() - now.and_utc().timestamp());
std::thread::sleep(delta.to_std()?);
}

Expand Down

0 comments on commit 104d5c1

Please sign in to comment.