text stringlengths 0 9.3M |
|---|
import os
from PyQt5.QtWidgets import (
QWidget, QVBoxLayout, QHBoxLayout, QPushButton, QLineEdit,
QTextEdit, QLabel
)
from PyQt5.QtGui import QFont, QPixmap
from PyQt5.QtCore import Qt, pyqtSignal
class C2Widget(QWidget):
"""C2 (Command and Control) tab widget."""
connect_requested = pyqtSignal... |
from .c2 import C2Widget
|
import os
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QTextEdit
from PyQt5.QtGui import QFont
class DocsWidget(QWidget):
"""Documentation tab widget."""
def __init__(self, script_dir, parent=None):
super().__init__(parent)
self.script_dir = script_dir
self.init_ui()
... |
from .docs import DocsWidget
|
import os
from pathlib import Path
from PyQt5.QtWidgets import (
QWidget, QVBoxLayout, QHBoxLayout, QPushButton, QLineEdit,
QLabel, QGroupBox, QListWidget, QListWidgetItem, QFileDialog, QApplication
)
from PyQt5.QtGui import QFont, QPixmap
from PyQt5.QtCore import Qt, pyqtSignal
class GarbageCollectorWidget(... |
from .garbage import GarbageCollectorWidget
|
import os
from PyQt5.QtWidgets import (
QWidget, QVBoxLayout, QHBoxLayout, QPushButton, QLineEdit,
QComboBox, QLabel, QGroupBox, QTableWidget, QTableWidgetItem, QHeaderView
)
from PyQt5.QtGui import QFont, QPixmap
from PyQt5.QtCore import Qt, pyqtSignal
class KrashWidget(QWidget):
"""KRASH/Decryptor tab ... |
from .krash import KrashWidget
|
import os
import sys
import subprocess
from pathlib import Path
from PyQt5.QtWidgets import (
QWidget, QVBoxLayout, QHBoxLayout, QPushButton, QTextEdit,
QLabel, QListWidget, QListWidgetItem
)
from PyQt5.QtGui import QFont, QPixmap
from PyQt5.QtCore import Qt, pyqtSignal
class OutputWidget(QWidget):
"""Ou... |
from .output import OutputWidget
|
import sys
from PyQt5.QtWidgets import (
QWidget, QVBoxLayout, QHBoxLayout, QPushButton, QLineEdit,
QLabel, QGroupBox
)
from PyQt5.QtGui import QFont
from PyQt5.QtCore import pyqtSignal
class SettingsWidget(QWidget):
"""Settings tab widget."""
save_requested = pyqtSignal()
install_nim_tool_r... |
from .settings import SettingsWidget
|
from PyQt5.QtWidgets import (
QWidget, QVBoxLayout, QHBoxLayout, QPushButton, QLineEdit,
QLabel, QGroupBox, QTextEdit, QComboBox, QSpinBox
)
from PyQt5.QtGui import QFont, QPixmap
from PyQt5.QtCore import Qt, QThread, pyqtSignal, QTimer
import os
import subprocess
import json
import time
try:
import matplo... |
from .whispers import SilentWhispersWidget
|
from setuptools import setup, find_packages
from pathlib import Path
current_dir = Path(__file__).parent.resolve()
with open(str(current_dir / "README.md"), "r") as f:
long_description = f.read()
version = '0.4.2'
setup(
name="secml_malware",
version=version,
author="zangobot",
author_email="luc... |
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Path setup --------------------------------------------------------------
# If ex... |
import os
from pathlib import Path
import magic
from secml.array import CArray
from secml_malware.attack.blackbox.c_black_box_padding_evasion import CBlackBoxPaddingEvasionProblem
from secml_malware.attack.blackbox.c_wrapper_phi import CEnd2EndWrapperPhi
from secml_malware.attack.blackbox.ga.c_base_genetic_engine imp... |
from pathlib import Path
from secml.array import CArray
from examples.utils import load_test_data
from secml_malware.attack.blackbox.c_black_box_padding_evasion import CBlackBoxPaddingEvasionProblem
from secml_malware.attack.blackbox.c_gamma_sections_evasion import CGammaSectionsEvasionProblem
from secml_malware.atta... |
import os
from pathlib import Path
import magic
from secml.array import CArray
from secml_malware.models import End2EndModel
def load_test_data():
folder = str(Path(__file__).parent.parent / "secml_malware" / "data" / "malware_samples" / "test_folder")
X = []
file_names = []
for i, f in enumerate(os... |
from examples.utils import load_test_data
from secml_malware.models.c_classifier_remote import CClassifierRemote, AvailableOnlineAntivirus
X, names = load_test_data()
x = X[0, :]
filename = names[0]
api_key = "INSERT HERE YOUR API KEY"
vt_antivirus = CClassifierRemote(AvailableOnlineAntivirus.VirusTotal, api_key=api_k... |
"""
Exe package module
"""
from secml_malware import attack, models, utils, visualization
__version__ = '0.3.2'
|
"""
Evasion attack against MalConv
""" |
import struct
from copy import deepcopy
import numpy as np
from secml.array import CArray
from secml_malware.attack.blackbox.c_blackbox_problem import CBlackBoxProblem
from secml_malware.attack.blackbox.c_wrapper_phi import CWrapperPhi
from secml_malware.utils.pe_operations import create_indexes_for_header_fields_man... |
import struct
from copy import copy, deepcopy
from secml.array import CArray
from secml_malware.attack.blackbox.c_blackbox_problem import CBlackBoxProblem
from secml_malware.attack.blackbox.c_wrapper_phi import CWrapperPhi
import numpy as np
class CBlackBoxHeaderEvasionProblem(CBlackBoxProblem):
"""
Blackbox attac... |
from abc import abstractmethod
from secml.array import CArray
from secml_malware.attack.blackbox.c_wrapper_phi import CWrapperPhi
import numpy as np
def _slice_sequence(slice_size, sequence, irregular=None):
if irregular is not None:
expanded_sequence = [
sequence[: sum(irregular[:i + 1])] for i, _ in enumerate... |
import numpy as np
from secml.array import CArray
from secml_malware.attack.blackbox.c_blackbox_problem import CBlackBoxProblem
from secml_malware.attack.blackbox.c_wrapper_phi import CWrapperPhi
from secml_malware.utils.pe_operations import shift_section_by, shift_pe_header_by, create_int_list_from_x_adv
class CBla... |
import numpy as np
from secml.array import CArray
from secml_malware.attack.blackbox.c_blackbox_problem import CBlackBoxProblem
from secml_malware.attack.blackbox.c_wrapper_phi import CWrapperPhi
class CBlackBoxPaddingEvasionProblem(CBlackBoxProblem):
"""
Padding black-box problem
"""
def __init__(
self,
m... |
import copy
import os
import lief
import magic
from secml.array import CArray
from secml_malware.attack.blackbox.c_blackbox_problem import CBlackBoxProblem
from secml_malware.attack.blackbox.c_wrapper_phi import CWrapperPhi
class CGammaAPIEvasionProblem(CBlackBoxProblem):
def __init__(self,
ap... |
import copy
import os
import pickle
import lief
import magic
import numpy as np
from secml.array import CArray
from secml_malware.attack.blackbox.c_blackbox_problem import CBlackBoxProblem
from secml_malware.attack.blackbox.c_wrapper_phi import CWrapperPhi
class CGammaEvasionProblem(CBlackBoxProblem):
"""
GAMMA pad... |
import copy
import random
import string
import lief
import numpy as np
from secml.array import CArray
from secml_malware.attack.blackbox.c_gamma_evasion import CGammaEvasionProblem
from secml_malware.attack.blackbox.c_wrapper_phi import CWrapperPhi
class CGammaSectionsEvasionProblem(CGammaEvasionProblem):
"""
... |
import copy
from secml.array import CArray
from secml_malware.attack.blackbox.c_gamma_evasion import CGammaEvasionProblem
from secml_malware.attack.blackbox.c_wrapper_phi import CWrapperPhi
from secml_malware.utils.pe_operations import create_int_list_from_x_adv, shift_section_by
class CGammaShiftEvasionProblem(CGam... |
from abc import abstractmethod
from secml.array import CArray
from secml.ml.classifiers import CClassifier
from secml_malware.models import CClassifierEnd2EndMalware, CClassifierEmber
from secml_malware.models.c_classifier_sorel_net import CClassifierSorel
class CWrapperPhi:
"""
Abstract class that encapsul... |
import copy
import random
import time
from typing import Tuple, Any
import numpy as np
from secml.adv.attacks import CAttackEvasion
from secml.array import CArray
from secml.data import CDataset
from secml_malware.attack.blackbox.c_blackbox_problem import CBlackBoxProblem
try:
import deap
from deap import base, cr... |
import copy
import random
from typing import Tuple, Any, Optional
import numpy as np
from secml.adv.attacks import CAttackEvasion
from secml.array import CArray
from secml.data import CDataset
from secml_malware.attack.blackbox.c_blackbox_problem import CBlackBoxProblem
try:
import nevergrad
from nevergrad.o... |
import os
from os import listdir
import magic
import numpy as np
from secml.array import CArray
from secml.testing import CUnitTest
from secml_malware.models import CClassifierEnd2EndMalware, MalConv, CClassifierEmber
class BlackBoxBaseTests(CUnitTest):
def setUp(self):
self.max_length = 2 ** 20
... |
from pathlib import Path
import lief.PE
from secml_malware.attack.blackbox.c_black_box_format_exploit_evasion import CBlackBoxFormatExploitEvasionProblem
from secml_malware.attack.blackbox.c_black_box_padding_evasion import CBlackBoxPaddingEvasionProblem
from secml_malware.attack.blackbox.c_blackbox_header_problem im... |
from secml_malware.attack.blackbox.c_black_box_padding_evasion import CBlackBoxPaddingEvasionProblem
from secml_malware.attack.blackbox.c_blackbox_header_problem import CBlackBoxHeaderEvasionProblem
from secml_malware.attack.blackbox.c_wrapper_phi import CEnd2EndWrapperPhi
from secml_malware.attack.blackbox.ga.c_neverg... |
import numpy as np
import torch
from secml.array import CArray
from secml.settings import SECML_PYTORCH_USE_CUDA
from secml_malware.attack.whitebox import CEnd2EndMalwareEvasion
from secml_malware.models import CClassifierEnd2EndMalware
use_cuda = torch.cuda.is_available() and SECML_PYTORCH_USE_CUDA
def gradient_se... |
import copy
from abc import abstractmethod
import numpy as np
import torch
from secml.adv.attacks import CAttackEvasion
from secml.array import CArray
from secml.array.c_dense import CDense
from secml.settings import SECML_PYTORCH_USE_CUDA
from secml_malware.models import CClassifierEnd2EndMalware
use_cuda = torch.c... |
from secml_malware.attack.whitebox import CFormatExploitEvasion
from secml_malware.models import CClassifierEnd2EndMalware
from secml_malware.utils.pe_operations import create_int_list_from_x_adv, shift_pe_header_by
class CExtendDOSEvasion(CFormatExploitEvasion):
"""
DOS header extension attack
"""
def __init__(s... |
import torch
import numpy as np
from secml.array import CArray
from secml.settings import SECML_PYTORCH_USE_CUDA
from secml_malware.attack.whitebox import CEnd2EndMalwareEvasion
from secml_malware.models import CClassifierEnd2EndMalware
use_cuda = torch.cuda.is_available() and SECML_PYTORCH_USE_CUDA
class CFastGradie... |
import numpy
from secml.array import CArray
from secml_malware.attack.whitebox.c_discretized_bytes_evasion import CDiscreteBytesEvasion
from secml_malware.models import CClassifierEnd2EndMalware, End2EndModel
from secml_malware.utils.pe_operations import shift_section_by, shift_pe_header_by, create_int_list_from_x_adv... |
import struct
import torch
from secml.settings import SECML_PYTORCH_USE_CUDA
from secml_malware.attack.whitebox.c_discretized_bytes_evasion import CDiscreteBytesEvasion
from secml_malware.models import CClassifierEnd2EndMalware
from secml_malware.utils.pe_operations import create_indexes_for_header_fields_manipulatio... |
import struct
import numpy as np
import torch
from secml.settings import SECML_PYTORCH_USE_CUDA
from secml_malware.attack.whitebox.c_discretized_bytes_evasion import CDiscreteBytesEvasion
from secml_malware.models import CClassifierEnd2EndMalware
use_cuda = torch.cuda.is_available() and SECML_PYTORCH_USE_CUDA
class... |
import lief
import numpy as np
from secml_malware.attack.whitebox.c_fast_gradient_sign_evasion import CFastGradientSignMethodEvasion
from secml_malware.models import CClassifierEnd2EndMalware
from secml_malware.utils.pe_operations import create_int_list_from_x_adv
class CKreukEvasion(CFastGradientSignMethodEvasion):... |
from secml_malware.attack.whitebox.c_discretized_bytes_evasion import CDiscreteBytesEvasion
from secml_malware.models import CClassifierEnd2EndMalware
class CPaddingEvasion(CDiscreteBytesEvasion):
"""
Constructs an attack object that append one byte at time.
"""
def __init__(
self,
end2end_model: CClassifi... |
from secml_malware.attack.whitebox import CFormatExploitEvasion
from secml_malware.models import CClassifierEnd2EndMalware
class CContentShiftingEvasion(CFormatExploitEvasion):
"""
Content shifting attack
"""
def __init__(self,
end2end_model : CClassifierEnd2EndMalware,
preferable_extension_amount=0x200,
... |
import lief
import numpy as np
import torch
from secml_malware.utils.pe_operations import create_int_list_from_x_adv
from secml.settings import SECML_PYTORCH_USE_CUDA
from secml_malware.attack.whitebox.c_discretized_bytes_evasion import CDiscreteBytesEvasion
from secml_malware.models import CClassifierEnd2EndMalware
... |
import numpy as np
from secml_malware.attack.whitebox.c_kreuk_evasion import CKreukEvasion
from secml_malware.models import CClassifierEnd2EndMalware
class CSuciuEvasion(CKreukEvasion):
def __init__(
self,
end2end_model: CClassifierEnd2EndMalware,
how_many_padding_bytes: int,
epsilon: float,
is_debug... |
from secml_malware.attack.whitebox.c_end2end_evasion import CEnd2EndMalwareEvasion
from secml_malware.attack.whitebox.c_discretized_bytes_evasion import CDiscreteBytesEvasion
from secml_malware.attack.whitebox.c_fast_gradient_sign_evasion import CFastGradientSignMethodEvasion
from secml_malware.attack.whitebox.c_format... |
import os
from os import listdir
import magic
import numpy as np
from secml.array import CArray
from secml.testing import CUnitTest
from secml_malware.models import CClassifierEmber
from secml_malware.models.c_classifier_end2end_malware import CClassifierEnd2EndMalware
from secml_malware.models.malconv import MalConv... |
import unittest
from secml.array import CArray
from secml_malware.attack.whitebox import CHeaderEvasion, CPaddingEvasion, CKreukEvasion, CSuciuEvasion, \
CContentShiftingEvasion
from secml_malware.attack.whitebox.c_format_exploit_evasion import CFormatExploitEvasion
from secml_malware.attack.whitebox.c_headerfields_... |
from abc import abstractmethod
from os.path import isfile
import numpy as np
import torch
from secml.settings import SECML_PYTORCH_USE_CUDA
from torch.nn import Module
from secml_malware.utils.exceptions import FileNotExistsException
use_cuda = torch.cuda.is_available() and SECML_PYTORCH_USE_CUDA
class End2EndMode... |
import lightgbm
import numpy as np
from ember import PEFeatureExtractor
from secml.array import CArray
from secml.ml.classifiers import CClassifier
class CClassifierEmber(CClassifier):
"""
The wrapper for the EMBER GBDT, by Anderson et al. https://arxiv.org/abs/1804.04637
"""
def __init__(self, tree_path: str = ... |
import os
import sys
import numpy as np
import torch
import torchvision.transforms as transforms
from secml.array import CArray
from secml.ml.classifiers.pytorch.c_classifier_pytorch import CClassifierPyTorch
from secml.settings import SECML_PYTORCH_USE_CUDA
from secml_malware.models.basee2e import End2EndModel
use_... |
import hashlib
import json
from abc import ABC
from enum import Enum
from time import sleep
from urllib.parse import urlparse
import numpy as np
import requests
from secml.array import CArray
from secml.ml.classifiers import CClassifier
def is_valid_url(url):
result = urlparse(url)
return result.scheme and r... |
# Copyright 2020, Sophos Limited. All rights reserved.
#
# 'Sophos' and 'Sophos Anti-Virus' are registered trademarks of
# Sophos Limited and Sophos Group. All other product and company
# names mentioned are trademarks or registered trademarks of their
# respective owners.
import os
import numpy as np
import torch
fro... |
"""
Malware Detection by Eating a Whole EXE
Edward Raff, Jon Barker, Jared Sylvester, Robert Brandon, Bryan Catanzaro, Charles Nicholas
https://arxiv.org/abs/1710.09435
"""
import os
import sys
import torch
import torch.nn as nn
import torch.nn.functional as F
from secml.settings import SECML_PYTORCH_USE_CUDA
from se... |
import io
import os
import sys
from pathlib import Path
import requests
import torch
import torch.nn.functional as F
from secml.settings import SECML_PYTORCH_USE_CUDA
from secml_malware.models import End2EndModel
use_cuda = torch.cuda.is_available() and SECML_PYTORCH_USE_CUDA
class MalConv2MB(End2EndModel):
d... |
from .c_classifier_end2end_malware import CClassifierEnd2EndMalware
from .malconv import MalConv
from .basee2e import End2EndModel
from .c_classifier_ember import CClassifierEmber |
from secml.array import CArray
from secml_malware.attack.whitebox.tests.malware_test_base import EmberBaseTests
class EmberTestSuite(EmberBaseTests):
def test_empty_baseline_gbdt_classifier_wrapper(self):
features = self.classifier.extract_features(self.X[0,:])
y = self.classifier.predict(features, return_deci... |
import unittest
import torch
from secml.array import CArray
from secml_malware.attack.whitebox.tests.malware_test_base import End2EndBaseTests
from secml_malware.models import MalConv
class MalConvTestSuite(End2EndBaseTests):
def setUp(self):
super(MalConvTestSuite, self).setUp()
self.m = MalConv()
def test_... |
class FileNotExistsException(Exception):
def __init__(self, message):
super(FileNotExistsException, self).__init__(message)
class FolderNotExistsException(Exception):
def __init__(self, message):
super(FolderNotExistsException, self).__init__(message)
class OptimizerNotSetException(Exception):
def __init__(se... |
import itertools
import math
import struct
import lief
import numpy as np
from secml.array import CArray
def shift_pointer_to_section_content(liefpe: lief.PE.Binary, raw_code: bytearray, entry_index: int, amount: int,
pe_shifted_by: int = 0) -> bytearray:
"""
Shifts the section content pointer.
Paramet... |
import struct
import string
import seaborn
import numpy as np
import matplotlib.pyplot as plt
seaborn.set()
COFF_LENGTH = 24
SECT_ENTRY_LEN = 40
def _pick_color(max_v, value):
color = str.format("{:02x}", 255 - int(value / max_v * 255))
rgb = "#ff{}ff".format(color)
return rgb
def plot_bins(itgs: np.ndarray, n_... |
# import numpy as np
# from secml.array import CArray
# from secml_malware.attack.whitebox.tests.malware_test_base import End2EndBaseTests
# from secml_malware.visualization.exe import plot_code_segment, plot_header_contribution_histogram,plot_range_histogram, plot_bins
#
#
# class ExeVisualizationTests(End2EndBaseTest... |
import torch
import numpy as np
from secml.array import CArray
from secml_malware.models.c_classifier_end2end_malware import CClassifierEnd2EndMalware, End2EndModel
def integrated_gradients(net, path, aggregation_type=None, baseline=None, steps=50):
""" Computes the Integrated Gradients for a given PE file input.... |
from Crypto.Cipher import ARC4
class FormBookDecryption:
def decrypt_func1(self, encbuf, plainbuf_len):
plainbuf = []
ebl = [ord(b) for b in encbuf]
if ebl[0] != 0x55 or ebl[1] != 0x8b:
print "doesn't start with a function prologue"
return
ebl = ebl[3:]
... |
# decrypts ismdoor-dns' encrypted config
# https://www.virustotal.com/en/file/5bc0a1f33c982916c8085076e8898ddbe8726249867b47df02e58ac3bf466b27/analysis/
import struct
mapping = {
167: "a",
212: "b",
208: "c",
210: "d",
216: "e",
165: "f",
182: "g",
294: "h",
404: "i",
386: "j",... |
# input file was created with the following tshark command:
# tshark -nr dns_comms.pcapng -Y "dns.qry.name contains dnslookup && dns.flags.response == 1" -T fields -e dns.qry.name -e dns.aaaa
import base64
import collections
import io
import re
import sys
import zipfile
def parse_lines(line, sessions):
query, re... |
def resolve_func_by_hash(func_name, xor_key1, xor_key2):
func_hash = 0
i = 0
v3 = 0
while i < len(func_name):
ch = ord(func_name[i])
func_hash ^= ch
v4 = (i + ch) & 0x3f
if v4 and v4 != 0x20:
if v4 > 0x20:
v11 = v4 - 32
... |
seed_lo = 0x43EB4A76
seed_hi = 0x7393C9A6
num_bytes = 164
buf = []
for i in range(num_bytes):
new_seed_lo = 36969 * (seed_lo & 0xffff) + (seed_lo >> 16)
seed_lo = new_seed_lo
new_seed_hi = 18000 * (seed_hi & 0xffff) + (seed_hi >> 16)
seed_hi = new_seed_hi
rand_byte = new_seed_hi + (new_seed_lo <<... |
start = ScreenEA()
xor_key = []
for i in range(4):
xor_key.append(chr(Byte(start+i)))
xor_key = "".join(xor_key)
start += 4
encbuf = []
i = 0
while True:
encbyte = Byte(start+i)
if encbyte == 0:
break
encbuf.append(chr(encbyte))
i += 1
encbuf = "".join(encbuf)
round1 = []
f... |
import sys
def hash_math(str_buf):
ret = 0x811c9dc5
for c in str_buf:
ret = (0x1000193 * (ord(c) ^ ret)) & 0xffffffff
return ret & 0xffffffff
#buf = "\x00".join("%s" % sys.argv[1]) + "\x00"
buf = sys.argv[1]
print hex(hash_math(buf))
|
# Panda banker DGA PoC
# Dennis Schwarz, Arbor Networks, ASERT, September 2016
import base64
import hashlib
import json
import struct
from datetime import datetime
from calendar import timegm
def rc4_ksa(key):
S = []
for i in range(256):
S.append(i)
j = 0
for i in range(256):
j = (... |
# Panda banker DGA PoC
# Dennis Schwarz, Arbor Networks, ASERT, November 2016
import base64
import hashlib
import json
import struct
from datetime import datetime
from calendar import timegm
def rc4_ksa(key):
S = []
for i in range(256):
S.append(i)
j = 0
for i in range(256):
j = (j... |
import sys
def hash_math(str_buf):
ret = -1
for c in str_buf:
ret = (ret ^ ord(c)) & 0xffffffff
for i in range(8):
if ret & 1:
ret = (ret ^ 0x4358ad54) & 0xffffffff
ret = (ret >> 1) & 0xffffffff
ret = (~ret) & 0xffffffff
return ret... |
import sys
def rol(num, count, size):
return ((num << count) | (num >> (size-count)))
def api_hash(api_name):
hash = 0
for c in api_name:
c = ord(c)
v7 = rol(hash, 8, 32)
hash = (c ^ v7) & 0xffffffff
return hash
print "0x%x" % api_hash(sys.argv[1])
|
import struct
import sys
from Crypto.Cipher import ARC4
def generate_key(seed):
pieces = []
math1 = 0xC0DE1EE7
for i in range(6):
v6 = math1
math1 = (math1 - 0x21524111) & 0xffffffff
math2 = (v6 ^ seed) & 0xffffffff
pieces.append(math2)
key = "%08X%X%X%X%08X%X" % (p... |
# Sphinx Zeus DGA PoC
# Dennis Schwarz, Arbor Networks, ASERT, October 2016
import ctypes
def dga(year, month, day):
ymd_str = "%d%d%d" % (year, month, day)
seed = int(ymd_str)
domains = []
for idx in range(128):
domain = []
for i in range(16):
seed = (idx + i + ((seed >> ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.