-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
67 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
use ::code::CodeTemplate; | ||
use askama::Template; | ||
|
||
#[derive(Template)] | ||
#[template(path = "python.py", escape = "none")] | ||
pub struct PythonCodeTemplate { | ||
comment_files: Vec<(String, Vec<String>)>, | ||
executable: String, | ||
assets: Vec<(String, String)>, | ||
} | ||
|
||
impl CodeTemplate for PythonCodeTemplate { | ||
fn render(executable_b64: String, payload_b64: Vec<(String, String)>, comment_files: Vec<(String, Vec<String>)>) -> String { | ||
let template = PythonCodeTemplate {executable: executable_b64, assets: payload_b64, comment_files}; | ||
template.render().unwrap() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# This source code was generated by anyexec2c. | ||
# Link: https://github.com/exyi/anyexec2C | ||
|
||
{% for (filename, content) in comment_files %} | ||
# ============================== | ||
# {{ filename }} | ||
# ============================== | ||
# | ||
{% for line in content %}# {{ line }} | ||
{% endfor %} | ||
|
||
|
||
{% endfor %} | ||
|
||
import base64 | ||
import os | ||
import sys | ||
|
||
|
||
binaryName = "myBinaryPayload" | ||
|
||
def extract(payload, filename): | ||
length = 0 | ||
data = base64.b64decode(payload) | ||
with open(filename, 'wb') as f: | ||
f.write(data) | ||
os.chmod(filename, 511) | ||
|
||
executable = "{{ executable }}" | ||
|
||
# extract the main binary | ||
extract(executable, binaryName) | ||
|
||
# extract assets | ||
{% for (name, asset) in assets %} | ||
extract("{{ asset }}", "{{ name }}") | ||
{% endfor %} | ||
|
||
args = list(sys.argv) | ||
args[0] = binaryName | ||
os.execv(binaryName, args) | ||
exit(2) |