Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
"rust-analyzer"
],
"rust-analyzer.check.command": "clippy",
"rust-analyzer.showUnlinkedFileNotification": false,
Copy link
Copy Markdown
Collaborator Author

@Cictrone Cictrone Mar 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this stops an annoying and not very useful vs code pop-up. I would like to leave it in but if we don't want to I'll remove it.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idk what this does

}
5 changes: 5 additions & 0 deletions implants/imix/src/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ impl Agent {
loop {
let start = Instant::now();

// Sometimes Imix starts too quickly in a boot sequence, a NIC is down during the initial callback,
// or the box Imix is on changes its IP. In any case, for each callback we should refresh our claimed
// IP.
self.cfg.refresh_primary_ip();

match self.callback().await {
Ok(_) => {}
Err(_err) => {
Expand Down
22 changes: 22 additions & 0 deletions implants/imix/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,28 @@ impl Default for Config {
}
}

impl Config {
pub fn refresh_primary_ip(&mut self) {
let fresh_ip = get_primary_ip();
if self
.info
.host
.as_ref()
.is_some_and(|h| h.primary_ip != fresh_ip)
{
match self.info.host.as_mut() {
Some(h) => {
h.primary_ip = fresh_ip;
}
None => {
#[cfg(debug_assertions)]
log::error!("host struct was never initialized, failed to set primary ip");
}
}
}
}
}

/*
* Returns which Platform imix has been compiled for.
*/
Expand Down