generated from oracle/template-repo
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: setup test environment for source code analyzer
- Loading branch information
Showing
12 changed files
with
704 additions
and
33 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Items added to this file will be ignored by Semgrep. |
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
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
26 changes: 26 additions & 0 deletions
26
tests/malware_analyzer/pypi/resources/sourcecode_samples/obfuscation/decode_and_execute.py
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,26 @@ | ||
# Copyright (c) 2025 - 2025, Oracle and/or its affiliates. All rights reserved. | ||
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/. | ||
|
||
""" | ||
Running this code will not produce any malicious behavior, but code isolation measures are | ||
in place for safety. | ||
""" | ||
|
||
import sys | ||
|
||
# ensure no symbols are exported so this code cannot accidentally be used | ||
__all__ = [] | ||
sys.exit() | ||
|
||
def test_function(): | ||
""" | ||
All code to be tested will be defined inside this function, so it is all local to it. This is | ||
to isolate the code to be tested, as it exists to replicate the patterns present in malware | ||
samples. | ||
""" | ||
sys.exit() | ||
# marshal encryption from pyobfuscate.com/marshal-encrypt, script is just print("Hello world!") | ||
|
||
from marshal import loads | ||
bytecode = loads(b'\xe3\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00@\x00\x00\x00s\x0c\x00\x00\x00e\x00d\x00\x83\x01\x01\x00d\x01S\x00)\x02z\x0cHello world!N)\x01\xda\x05print\xa9\x00r\x02\x00\x00\x00r\x02\x00\x00\x00\xfa\x08<string>\xda\x08<module>\x01\x00\x00\x00\xf3\x00\x00\x00\x00') | ||
exec(bytecode) |
61 changes: 61 additions & 0 deletions
61
tests/malware_analyzer/pypi/resources/sourcecode_samples/obfuscation/default_assigning.py
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,61 @@ | ||
# Copyright (c) 2025 - 2025, Oracle and/or its affiliates. All rights reserved. | ||
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/. | ||
|
||
""" | ||
Running this code will not produce any malicious behavior, but code isolation measures are | ||
in place for safety. | ||
""" | ||
|
||
import sys | ||
|
||
# ensure no symbols are exported so this code cannot accidentally be used | ||
__all__ = [] | ||
sys.exit() | ||
|
||
def test_function(): | ||
""" | ||
All code to be tested will be defined inside this function, so it is all local to it. This is | ||
to isolate the code to be tested, as it exists to replicate the patterns present in malware | ||
samples. | ||
""" | ||
sys.exit() | ||
import builtins | ||
_ = __import__ | ||
_ = getattr | ||
_ = bytes | ||
_ = bytearray | ||
_ = exec | ||
_ = eval | ||
_ = setattr | ||
_ = compile | ||
_ = map | ||
_ = open | ||
_ = zip | ||
_ = vars | ||
_ = dir | ||
_ = builtins.__import__ | ||
_ = builtins.getattr | ||
_ = builtins.bytes | ||
_ = builtins.bytearray | ||
_ = builtins.exec | ||
_ = builtins.eval | ||
_ = builtins.setattr | ||
_ = builtins.compile | ||
_ = builtins.map | ||
_ = builtins.open | ||
_ = builtins.zip | ||
_ = builtins.vars | ||
_ = builtins.dir | ||
_ = __import__('builtins').__import__ | ||
_ = __import__('builtins').getattr | ||
_ = __import__('builtins').bytes | ||
_ = __import__('builtins').bytearray | ||
_ = __import__('builtins').exec | ||
_ = __import__('builtins').eval | ||
_ = __import__('builtins').setattr | ||
_ = __import__('builtins').compile | ||
_ = __import__('builtins').builtins.map | ||
_ = __import__('builtins').open | ||
_ = __import__('builtins').zip | ||
_ = __import__('builtins').vars | ||
_ = __import__('builtins').dir |
Oops, something went wrong.