Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial Agent Looksy #2

Merged
merged 58 commits into from
Feb 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
8ea3fae
started imix bot
Cictrone Feb 15, 2022
674a7cd
added basic reading of config file and a bit of a touch up around args
Cictrone Feb 16, 2022
7fa9be8
wrote the linux install and re-orged some of the namespacing
Cictrone Feb 16, 2022
7100a29
added a ton fo logic for the initial call back, also errors!
Cictrone Feb 17, 2022
00b3964
changed the String to a PathBuf for newman :^)
Cictrone Feb 17, 2022
2c066e8
Update README.md
KCarretto Feb 22, 2022
4c4d3a7
Fixed bug with tests (only encountered when they fail on a require)
KCarretto Feb 22, 2022
2e31218
Added test for CreateTarget
KCarretto Feb 22, 2022
f68f64a
Added test for targets root query
KCarretto Feb 22, 2022
20eb4ad
Split target query tests into seperate file
KCarretto Feb 22, 2022
0df07ad
Added Test for createCredential
KCarretto Feb 22, 2022
c9a2041
project structure?
Cictrone Feb 23, 2022
456048b
RESTRUCTURING
Cictrone Feb 23, 2022
31b086e
Added new Implant Ents
KCarretto Feb 23, 2022
12e117d
Removed unused function
KCarretto Feb 23, 2022
4f6331d
Added initial callback mutation
KCarretto Feb 23, 2022
8dc5c06
gett the initial starlark setup
Cictrone Feb 23, 2022
1e2534e
perf issues fixed and working examplegit add .!
Cictrone Feb 23, 2022
827e0f9
stubbed out the first version of the eldritch stdlib
Cictrone Feb 24, 2022
30ec8e7
rebase!
Cictrone Feb 24, 2022
8cd5836
started imix bot
Cictrone Feb 15, 2022
2f75a20
added basic reading of config file and a bit of a touch up around args
Cictrone Feb 16, 2022
fc7f389
wrote the linux install and re-orged some of the namespacing
Cictrone Feb 16, 2022
e589c81
added a ton fo logic for the initial call back, also errors!
Cictrone Feb 17, 2022
d6610e6
changed the String to a PathBuf for newman :^)
Cictrone Feb 17, 2022
03ed3c9
project structure?
Cictrone Feb 23, 2022
d14698e
RESTRUCTURING
Cictrone Feb 23, 2022
46697e9
gett the initial starlark setup
Cictrone Feb 23, 2022
eec9cc2
perf issues fixed and working examplegit add .!
Cictrone Feb 23, 2022
7d59622
stubbed out the first version of the eldritch stdlib
Cictrone Feb 24, 2022
d563bc3
rebase!
Cictrone Feb 24, 2022
6f94a9c
Merge branch 'nick' of github.com:KCarretto/realm into nick
Cictrone Feb 24, 2022
4b20962
Added GithubPages Documentation (#3)
KCarretto Feb 26, 2022
e465515
Attempting VSCode shenannigans
KCarretto Feb 26, 2022
56310f0
Ooops
KCarretto Feb 26, 2022
c088c4e
started imix bot
Cictrone Feb 15, 2022
59ed0be
added basic reading of config file and a bit of a touch up around args
Cictrone Feb 16, 2022
1bec3ca
wrote the linux install and re-orged some of the namespacing
Cictrone Feb 16, 2022
4d5174c
added a ton fo logic for the initial call back, also errors!
Cictrone Feb 17, 2022
40eca3e
changed the String to a PathBuf for newman :^)
Cictrone Feb 17, 2022
31cf508
project structure?
Cictrone Feb 23, 2022
c1e49fc
RESTRUCTURING
Cictrone Feb 23, 2022
9cd3838
gett the initial starlark setup
Cictrone Feb 23, 2022
a88b76f
perf issues fixed and working examplegit add .!
Cictrone Feb 23, 2022
4a107d8
stubbed out the first version of the eldritch stdlib
Cictrone Feb 24, 2022
07ab706
rebase!
Cictrone Feb 24, 2022
2d4ccd4
started imix bot
Cictrone Feb 15, 2022
f47867f
added basic reading of config file and a bit of a touch up around args
Cictrone Feb 16, 2022
537f4ed
wrote the linux install and re-orged some of the namespacing
Cictrone Feb 16, 2022
45b31ac
added a ton fo logic for the initial call back, also errors!
Cictrone Feb 17, 2022
15942b8
changed the String to a PathBuf for newman :^)
Cictrone Feb 17, 2022
fd764e4
project structure?
Cictrone Feb 23, 2022
04234ab
RESTRUCTURING
Cictrone Feb 23, 2022
86100e8
gett the initial starlark setup
Cictrone Feb 23, 2022
58f78d2
perf issues fixed and working examplegit add .!
Cictrone Feb 23, 2022
a8aadd3
stubbed out the first version of the eldritch stdlib
Cictrone Feb 24, 2022
bd91924
rebase!
Cictrone Feb 24, 2022
b4e1abd
Merge...
KCarretto Feb 26, 2022
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
11 changes: 9 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"RUST_VARIANT": "buster",
// Options
"NODE_VERSION": "lts/*"
}
},
},
"runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" ],

Expand Down Expand Up @@ -37,4 +37,11 @@

// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
// "remoteUser": "vscode"
}

// SPEEEEEEED
"mounts": [
"source=realm-cmd-implants-eldritch-target,target=${containerWorkspaceFolder}/cmd/implants/eldritch/target,type=volume",
"source=realm-cmd-implants-eldritch-target,target=${containerWorkspaceFolder}/cmd/implants/imix/target,type=volume",
"source=realm-cmd-implants-target,target=${containerWorkspaceFolder}/cmd/implants/target,type=volume"
]
}
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
# will have compiled files and executables
/target/

# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Cargo.lock

# These are backup files generated by rustfmt
**/*.rs.bk

Expand Down
9 changes: 9 additions & 0 deletions cmd/implants/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Generated by Cargo
# will have compiled files and executables
target/

# These are backup files generated by rustfmt
**/*.rs.bk

# Also not an exec create so no Cargo.lock
/Cargo.lock
5 changes: 5 additions & 0 deletions cmd/implants/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[workspace]
members = [
"imix",
"eldritch"
]
47 changes: 47 additions & 0 deletions cmd/implants/contrib/example_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"target_name":"Team 1 - Web",
"callback_interval":60000,
"callback_jitter":5000,
"c2_configs":[
{
"uri":"http://c2.prn0.realm.pub",
"timeout":5,
"priority":10,
"sticky":false,
"failsafe":false
},
{
"uri":"http://c2.frc0.realm.pub",
"timeout":5,
"priority":10,
"sticky":false,
"failsafe":false
},
{
"uri":"http://sketchy.realm.pub",
"timeout":5,
"priority":5,
"sticky":true,
"failsafe":false
},
{
"uri":"http://secret.realm.pub.com",
"timeout":5,
"priority":5,
"sticky":false,
"failsafe":true
}
],
"service_configs":[
{
"name":"rsyslog-ng",
"description":"Definitely logging",
"executable_path":"/usr/sbin/rsyslog-ng"
},
{
"name":"thermald",
"description":"careful things don't overheat",
"executable_path":"/bin/thermald"
}
]
}
9 changes: 9 additions & 0 deletions cmd/implants/eldritch/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Generated by Cargo
# will have compiled files and executables
target/

# These are backup files generated by rustfmt
**/*.rs.bk

# Also not an exec create so no Cargo.lock
Cargo.lock
9 changes: 9 additions & 0 deletions cmd/implants/eldritch/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "eldritch"
version = "0.1.0"
edition = "2021"

[dependencies]
starlark = "0.6.0"
anyhow = "1.0.55"
derive_more = "0.99.17"
2 changes: 2 additions & 0 deletions cmd/implants/eldritch/rust-toolchain
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[toolchain]
channel = "nightly-2021-11-22"
102 changes: 102 additions & 0 deletions cmd/implants/eldritch/src/file.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
mod append_impl;
mod copy_impl;
mod download_impl;
mod exists_impl;
mod hash_impl;
mod is_dir_impl;
mod mkdir_impl;
mod read_impl;
mod remove_impl;
mod rename_impl;
mod replace_all_impl;
mod replace_impl;
mod timestomp_impl;
mod write_impl;

use derive_more::Display;

use starlark::environment::{Methods, MethodsBuilder, MethodsStatic};
use starlark::values::{StarlarkValue, Value, UnpackValue, ValueLike};
use starlark::values::none::NoneType;
use starlark::{starlark_type, starlark_simple_value, starlark_module};

#[derive(Copy, Clone, Debug, PartialEq, Display)]
#[display(fmt = "FileLibrary")]
pub struct FileLibrary();
starlark_simple_value!(FileLibrary);

impl<'v> StarlarkValue<'v> for FileLibrary {
starlark_type!("file_library");

fn get_methods(&self) -> Option<&'static Methods> {
static RES: MethodsStatic = MethodsStatic::new();
RES.methods(methods)
}
}

impl<'v> UnpackValue<'v> for FileLibrary {
fn expected() -> String {
FileLibrary::get_type_value_static().as_str().to_owned()
}

fn unpack_value(value: Value<'v>) -> Option<Self> {
Some(*value.downcast_ref::<FileLibrary>().unwrap())
}
}

// This is where all of the "file.X" impl methods are bound
#[starlark_module]
fn methods(builder: &mut MethodsBuilder) {
fn append(_this: FileLibrary, path: String, content: String) -> NoneType {
append_impl::append(path, content)?;
Ok(NoneType{})
}
fn copy(_this: FileLibrary, src: String, dst: String) -> NoneType {
copy_impl::copy(src, dst)?;
Ok(NoneType{})
}
fn download(_this: FileLibrary, uri: String, dst: String) -> NoneType {
download_impl::download(uri, dst)?;
Ok(NoneType{})
}
fn exists(_this: FileLibrary, path: String) -> bool {
exists_impl::exists(path)
}
fn hash(_this: FileLibrary, path: String) -> String {
hash_impl::hash(path)
}
fn is_dir(_this: FileLibrary, path: String) -> bool {
is_dir_impl::is_dir(path)
}
fn mkdir(_this: FileLibrary, path: String) -> NoneType {
mkdir_impl::mkdir(path)?;
Ok(NoneType{})
}
fn read(_this: FileLibrary, path: String) -> String {
read_impl::read(path)
}
fn remove(_this: FileLibrary, path: String) -> NoneType {
remove_impl::remove(path)?;
Ok(NoneType{})
}
fn rename(_this: FileLibrary, old: String, new: String) -> NoneType {
rename_impl::rename(old, new)?;
Ok(NoneType{})
}
fn replace_all(_this: FileLibrary, path: String, pattern: String, value: String) -> NoneType {
replace_all_impl::replace_all(path, pattern, value)?;
Ok(NoneType{})
}
fn replace(_this: FileLibrary, path: String, pattern: String, value: String) -> NoneType {
replace_impl::replace(path, pattern, value)?;
Ok(NoneType{})
}
fn timestomp(_this: FileLibrary, src: String, dst: String) -> NoneType {
timestomp_impl::timestomp(src, dst)?;
Ok(NoneType{})
}
fn write(_this: FileLibrary, path: String, content: String) -> NoneType {
write_impl::write(path, content)?;
Ok(NoneType{})
}
}
5 changes: 5 additions & 0 deletions cmd/implants/eldritch/src/file/append_impl.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
use anyhow::Result;

pub fn append(_path: String, _content: String) -> Result<()> {
unimplemented!("Method unimplemented")
}
5 changes: 5 additions & 0 deletions cmd/implants/eldritch/src/file/copy_impl.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
use anyhow::Result;

pub fn copy(_src: String, _dst: String) -> Result<()> {
unimplemented!("Method unimplemented")
}
5 changes: 5 additions & 0 deletions cmd/implants/eldritch/src/file/download_impl.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
use anyhow::Result;

pub fn download(_uri: String, _dst: String) -> Result<()> {
unimplemented!("Method unimplemented")
}
5 changes: 5 additions & 0 deletions cmd/implants/eldritch/src/file/exists_impl.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
use anyhow::Result;

pub fn exists(_path: String) -> Result<bool> {
unimplemented!("Method unimplemented")
}
5 changes: 5 additions & 0 deletions cmd/implants/eldritch/src/file/hash_impl.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
use anyhow::Result;

pub fn hash(_path: String) -> Result<String> {
unimplemented!("Method unimplemented")
}
5 changes: 5 additions & 0 deletions cmd/implants/eldritch/src/file/is_dir_impl.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
use anyhow::Result;

pub fn is_dir(_path: String) -> Result<bool> {
unimplemented!("Method unimplemented")
}
5 changes: 5 additions & 0 deletions cmd/implants/eldritch/src/file/mkdir_impl.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
use anyhow::Result;

pub fn mkdir(_path: String) -> Result<()> {
unimplemented!("Method unimplemented")
}
5 changes: 5 additions & 0 deletions cmd/implants/eldritch/src/file/read_impl.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
use anyhow::Result;

pub fn read(_path: String) -> Result<String> {
unimplemented!("Method unimplemented")
}
5 changes: 5 additions & 0 deletions cmd/implants/eldritch/src/file/remove_impl.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
use anyhow::Result;

pub fn remove(_path: String) -> Result<()> {
unimplemented!("Method unimplemented")
}
5 changes: 5 additions & 0 deletions cmd/implants/eldritch/src/file/rename_impl.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
use anyhow::Result;

pub fn rename(_old: String, _new: String) -> Result<()> {
unimplemented!("Method unimplemented")
}
5 changes: 5 additions & 0 deletions cmd/implants/eldritch/src/file/replace_all_impl.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
use anyhow::Result;

pub fn replace_all(_path: String, _pattern: String, _value: String) -> Result<()> {
unimplemented!("Method unimplemented")
}
5 changes: 5 additions & 0 deletions cmd/implants/eldritch/src/file/replace_impl.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
use anyhow::Result;

pub fn replace(_path: String, _pattern: String, _value: String) -> Result<()> {
unimplemented!("Method unimplemented")
}
5 changes: 5 additions & 0 deletions cmd/implants/eldritch/src/file/timestomp_impl.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
use anyhow::Result;

pub fn timestomp(_src: String, _dst: String) -> Result<()> {
unimplemented!("Method unimplemented")
}
5 changes: 5 additions & 0 deletions cmd/implants/eldritch/src/file/write_impl.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
use anyhow::Result;

pub fn write(_path: String, _content: String) -> Result<()> {
unimplemented!("Method unimplemented")
}
35 changes: 35 additions & 0 deletions cmd/implants/eldritch/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
mod file;
mod process;
mod sys;

#[cfg(test)]
mod tests {
use starlark::environment::{GlobalsBuilder};
use starlark::{starlark_module};
use starlark::assert::Assert;

use super::file::FileLibrary;
use super::process::ProcessLibrary;
use super::sys::SysLibrary;

// just checks dir...
#[test]
fn test_library_bindings() {
#[starlark_module]
fn globals(builder: &mut GlobalsBuilder) {
const file: FileLibrary = FileLibrary();
const process: ProcessLibrary = ProcessLibrary();
const sys: SysLibrary = SysLibrary();
}

let mut a = Assert::new();
a.globals_add(globals);
a.all_true(
r#"
dir(file) == ["append", "copy", "download", "exists", "hash", "is_dir", "mkdir", "read", "remove", "rename", "replace", "replace_all", "timestomp", "write"]
dir(process) == ["kill", "list", "name"]
dir(sys) == ["exec", "is_linux", "is_windows", "shell"]
"#,
);
}
}
Loading