forked from ZenBrowserMirrors/zen-desktop
chore: Upload virus total checker from previous zen repo, b=(no-bug), c=no-component
This commit is contained in:
parent
5c30c83341
commit
cc1619ab5d
12 changed files with 26625 additions and 0 deletions
38
tools/virustotal-checker/.gitignore
vendored
Normal file
38
tools/virustotal-checker/.gitignore
vendored
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
# Prerequisites
|
||||||
|
*.d
|
||||||
|
|
||||||
|
# Compiled Object files
|
||||||
|
*.slo
|
||||||
|
*.lo
|
||||||
|
*.o
|
||||||
|
*.obj
|
||||||
|
|
||||||
|
# Precompiled Headers
|
||||||
|
*.gch
|
||||||
|
*.pch
|
||||||
|
|
||||||
|
# Compiled Dynamic libraries
|
||||||
|
*.so
|
||||||
|
*.dylib
|
||||||
|
*.dll
|
||||||
|
|
||||||
|
# Fortran module files
|
||||||
|
*.mod
|
||||||
|
*.smod
|
||||||
|
|
||||||
|
CMakeFiles/
|
||||||
|
_deps/
|
||||||
|
CMakeCache.txt
|
||||||
|
|
||||||
|
malware-snitch
|
||||||
|
|
||||||
|
# Compiled Static libraries
|
||||||
|
*.lai
|
||||||
|
*.la
|
||||||
|
*.a
|
||||||
|
*.lib
|
||||||
|
|
||||||
|
# Executables
|
||||||
|
*.exe
|
||||||
|
*.out
|
||||||
|
*.app
|
14
tools/virustotal-checker/CMakeLists.txt
Normal file
14
tools/virustotal-checker/CMakeLists.txt
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
|
||||||
|
project("malware-snitch" LANGUAGES CXX)
|
||||||
|
|
||||||
|
set(CMAKE_CXX_STANDARD 20)
|
||||||
|
|
||||||
|
# Define a binary target
|
||||||
|
file(GLOB_RECURSE SOURCES src/*.cc)
|
||||||
|
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lcrypto -lcurl -Wall -Wextra -pedantic")
|
||||||
|
|
||||||
|
add_executable(${PROJECT_NAME} ${SOURCES})
|
||||||
|
target_include_directories(${PROJECT_NAME} PRIVATE src)
|
||||||
|
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_20)
|
||||||
|
|
373
tools/virustotal-checker/LICENSE
Normal file
373
tools/virustotal-checker/LICENSE
Normal file
|
@ -0,0 +1,373 @@
|
||||||
|
Mozilla Public License Version 2.0
|
||||||
|
==================================
|
||||||
|
|
||||||
|
1. Definitions
|
||||||
|
--------------
|
||||||
|
|
||||||
|
1.1. "Contributor"
|
||||||
|
means each individual or legal entity that creates, contributes to
|
||||||
|
the creation of, or owns Covered Software.
|
||||||
|
|
||||||
|
1.2. "Contributor Version"
|
||||||
|
means the combination of the Contributions of others (if any) used
|
||||||
|
by a Contributor and that particular Contributor's Contribution.
|
||||||
|
|
||||||
|
1.3. "Contribution"
|
||||||
|
means Covered Software of a particular Contributor.
|
||||||
|
|
||||||
|
1.4. "Covered Software"
|
||||||
|
means Source Code Form to which the initial Contributor has attached
|
||||||
|
the notice in Exhibit A, the Executable Form of such Source Code
|
||||||
|
Form, and Modifications of such Source Code Form, in each case
|
||||||
|
including portions thereof.
|
||||||
|
|
||||||
|
1.5. "Incompatible With Secondary Licenses"
|
||||||
|
means
|
||||||
|
|
||||||
|
(a) that the initial Contributor has attached the notice described
|
||||||
|
in Exhibit B to the Covered Software; or
|
||||||
|
|
||||||
|
(b) that the Covered Software was made available under the terms of
|
||||||
|
version 1.1 or earlier of the License, but not also under the
|
||||||
|
terms of a Secondary License.
|
||||||
|
|
||||||
|
1.6. "Executable Form"
|
||||||
|
means any form of the work other than Source Code Form.
|
||||||
|
|
||||||
|
1.7. "Larger Work"
|
||||||
|
means a work that combines Covered Software with other material, in
|
||||||
|
a separate file or files, that is not Covered Software.
|
||||||
|
|
||||||
|
1.8. "License"
|
||||||
|
means this document.
|
||||||
|
|
||||||
|
1.9. "Licensable"
|
||||||
|
means having the right to grant, to the maximum extent possible,
|
||||||
|
whether at the time of the initial grant or subsequently, any and
|
||||||
|
all of the rights conveyed by this License.
|
||||||
|
|
||||||
|
1.10. "Modifications"
|
||||||
|
means any of the following:
|
||||||
|
|
||||||
|
(a) any file in Source Code Form that results from an addition to,
|
||||||
|
deletion from, or modification of the contents of Covered
|
||||||
|
Software; or
|
||||||
|
|
||||||
|
(b) any new file in Source Code Form that contains any Covered
|
||||||
|
Software.
|
||||||
|
|
||||||
|
1.11. "Patent Claims" of a Contributor
|
||||||
|
means any patent claim(s), including without limitation, method,
|
||||||
|
process, and apparatus claims, in any patent Licensable by such
|
||||||
|
Contributor that would be infringed, but for the grant of the
|
||||||
|
License, by the making, using, selling, offering for sale, having
|
||||||
|
made, import, or transfer of either its Contributions or its
|
||||||
|
Contributor Version.
|
||||||
|
|
||||||
|
1.12. "Secondary License"
|
||||||
|
means either the GNU General Public License, Version 2.0, the GNU
|
||||||
|
Lesser General Public License, Version 2.1, the GNU Affero General
|
||||||
|
Public License, Version 3.0, or any later versions of those
|
||||||
|
licenses.
|
||||||
|
|
||||||
|
1.13. "Source Code Form"
|
||||||
|
means the form of the work preferred for making modifications.
|
||||||
|
|
||||||
|
1.14. "You" (or "Your")
|
||||||
|
means an individual or a legal entity exercising rights under this
|
||||||
|
License. For legal entities, "You" includes any entity that
|
||||||
|
controls, is controlled by, or is under common control with You. For
|
||||||
|
purposes of this definition, "control" means (a) the power, direct
|
||||||
|
or indirect, to cause the direction or management of such entity,
|
||||||
|
whether by contract or otherwise, or (b) ownership of more than
|
||||||
|
fifty percent (50%) of the outstanding shares or beneficial
|
||||||
|
ownership of such entity.
|
||||||
|
|
||||||
|
2. License Grants and Conditions
|
||||||
|
--------------------------------
|
||||||
|
|
||||||
|
2.1. Grants
|
||||||
|
|
||||||
|
Each Contributor hereby grants You a world-wide, royalty-free,
|
||||||
|
non-exclusive license:
|
||||||
|
|
||||||
|
(a) under intellectual property rights (other than patent or trademark)
|
||||||
|
Licensable by such Contributor to use, reproduce, make available,
|
||||||
|
modify, display, perform, distribute, and otherwise exploit its
|
||||||
|
Contributions, either on an unmodified basis, with Modifications, or
|
||||||
|
as part of a Larger Work; and
|
||||||
|
|
||||||
|
(b) under Patent Claims of such Contributor to make, use, sell, offer
|
||||||
|
for sale, have made, import, and otherwise transfer either its
|
||||||
|
Contributions or its Contributor Version.
|
||||||
|
|
||||||
|
2.2. Effective Date
|
||||||
|
|
||||||
|
The licenses granted in Section 2.1 with respect to any Contribution
|
||||||
|
become effective for each Contribution on the date the Contributor first
|
||||||
|
distributes such Contribution.
|
||||||
|
|
||||||
|
2.3. Limitations on Grant Scope
|
||||||
|
|
||||||
|
The licenses granted in this Section 2 are the only rights granted under
|
||||||
|
this License. No additional rights or licenses will be implied from the
|
||||||
|
distribution or licensing of Covered Software under this License.
|
||||||
|
Notwithstanding Section 2.1(b) above, no patent license is granted by a
|
||||||
|
Contributor:
|
||||||
|
|
||||||
|
(a) for any code that a Contributor has removed from Covered Software;
|
||||||
|
or
|
||||||
|
|
||||||
|
(b) for infringements caused by: (i) Your and any other third party's
|
||||||
|
modifications of Covered Software, or (ii) the combination of its
|
||||||
|
Contributions with other software (except as part of its Contributor
|
||||||
|
Version); or
|
||||||
|
|
||||||
|
(c) under Patent Claims infringed by Covered Software in the absence of
|
||||||
|
its Contributions.
|
||||||
|
|
||||||
|
This License does not grant any rights in the trademarks, service marks,
|
||||||
|
or logos of any Contributor (except as may be necessary to comply with
|
||||||
|
the notice requirements in Section 3.4).
|
||||||
|
|
||||||
|
2.4. Subsequent Licenses
|
||||||
|
|
||||||
|
No Contributor makes additional grants as a result of Your choice to
|
||||||
|
distribute the Covered Software under a subsequent version of this
|
||||||
|
License (see Section 10.2) or under the terms of a Secondary License (if
|
||||||
|
permitted under the terms of Section 3.3).
|
||||||
|
|
||||||
|
2.5. Representation
|
||||||
|
|
||||||
|
Each Contributor represents that the Contributor believes its
|
||||||
|
Contributions are its original creation(s) or it has sufficient rights
|
||||||
|
to grant the rights to its Contributions conveyed by this License.
|
||||||
|
|
||||||
|
2.6. Fair Use
|
||||||
|
|
||||||
|
This License is not intended to limit any rights You have under
|
||||||
|
applicable copyright doctrines of fair use, fair dealing, or other
|
||||||
|
equivalents.
|
||||||
|
|
||||||
|
2.7. Conditions
|
||||||
|
|
||||||
|
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
|
||||||
|
in Section 2.1.
|
||||||
|
|
||||||
|
3. Responsibilities
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
3.1. Distribution of Source Form
|
||||||
|
|
||||||
|
All distribution of Covered Software in Source Code Form, including any
|
||||||
|
Modifications that You create or to which You contribute, must be under
|
||||||
|
the terms of this License. You must inform recipients that the Source
|
||||||
|
Code Form of the Covered Software is governed by the terms of this
|
||||||
|
License, and how they can obtain a copy of this License. You may not
|
||||||
|
attempt to alter or restrict the recipients' rights in the Source Code
|
||||||
|
Form.
|
||||||
|
|
||||||
|
3.2. Distribution of Executable Form
|
||||||
|
|
||||||
|
If You distribute Covered Software in Executable Form then:
|
||||||
|
|
||||||
|
(a) such Covered Software must also be made available in Source Code
|
||||||
|
Form, as described in Section 3.1, and You must inform recipients of
|
||||||
|
the Executable Form how they can obtain a copy of such Source Code
|
||||||
|
Form by reasonable means in a timely manner, at a charge no more
|
||||||
|
than the cost of distribution to the recipient; and
|
||||||
|
|
||||||
|
(b) You may distribute such Executable Form under the terms of this
|
||||||
|
License, or sublicense it under different terms, provided that the
|
||||||
|
license for the Executable Form does not attempt to limit or alter
|
||||||
|
the recipients' rights in the Source Code Form under this License.
|
||||||
|
|
||||||
|
3.3. Distribution of a Larger Work
|
||||||
|
|
||||||
|
You may create and distribute a Larger Work under terms of Your choice,
|
||||||
|
provided that You also comply with the requirements of this License for
|
||||||
|
the Covered Software. If the Larger Work is a combination of Covered
|
||||||
|
Software with a work governed by one or more Secondary Licenses, and the
|
||||||
|
Covered Software is not Incompatible With Secondary Licenses, this
|
||||||
|
License permits You to additionally distribute such Covered Software
|
||||||
|
under the terms of such Secondary License(s), so that the recipient of
|
||||||
|
the Larger Work may, at their option, further distribute the Covered
|
||||||
|
Software under the terms of either this License or such Secondary
|
||||||
|
License(s).
|
||||||
|
|
||||||
|
3.4. Notices
|
||||||
|
|
||||||
|
You may not remove or alter the substance of any license notices
|
||||||
|
(including copyright notices, patent notices, disclaimers of warranty,
|
||||||
|
or limitations of liability) contained within the Source Code Form of
|
||||||
|
the Covered Software, except that You may alter any license notices to
|
||||||
|
the extent required to remedy known factual inaccuracies.
|
||||||
|
|
||||||
|
3.5. Application of Additional Terms
|
||||||
|
|
||||||
|
You may choose to offer, and to charge a fee for, warranty, support,
|
||||||
|
indemnity or liability obligations to one or more recipients of Covered
|
||||||
|
Software. However, You may do so only on Your own behalf, and not on
|
||||||
|
behalf of any Contributor. You must make it absolutely clear that any
|
||||||
|
such warranty, support, indemnity, or liability obligation is offered by
|
||||||
|
You alone, and You hereby agree to indemnify every Contributor for any
|
||||||
|
liability incurred by such Contributor as a result of warranty, support,
|
||||||
|
indemnity or liability terms You offer. You may include additional
|
||||||
|
disclaimers of warranty and limitations of liability specific to any
|
||||||
|
jurisdiction.
|
||||||
|
|
||||||
|
4. Inability to Comply Due to Statute or Regulation
|
||||||
|
---------------------------------------------------
|
||||||
|
|
||||||
|
If it is impossible for You to comply with any of the terms of this
|
||||||
|
License with respect to some or all of the Covered Software due to
|
||||||
|
statute, judicial order, or regulation then You must: (a) comply with
|
||||||
|
the terms of this License to the maximum extent possible; and (b)
|
||||||
|
describe the limitations and the code they affect. Such description must
|
||||||
|
be placed in a text file included with all distributions of the Covered
|
||||||
|
Software under this License. Except to the extent prohibited by statute
|
||||||
|
or regulation, such description must be sufficiently detailed for a
|
||||||
|
recipient of ordinary skill to be able to understand it.
|
||||||
|
|
||||||
|
5. Termination
|
||||||
|
--------------
|
||||||
|
|
||||||
|
5.1. The rights granted under this License will terminate automatically
|
||||||
|
if You fail to comply with any of its terms. However, if You become
|
||||||
|
compliant, then the rights granted under this License from a particular
|
||||||
|
Contributor are reinstated (a) provisionally, unless and until such
|
||||||
|
Contributor explicitly and finally terminates Your grants, and (b) on an
|
||||||
|
ongoing basis, if such Contributor fails to notify You of the
|
||||||
|
non-compliance by some reasonable means prior to 60 days after You have
|
||||||
|
come back into compliance. Moreover, Your grants from a particular
|
||||||
|
Contributor are reinstated on an ongoing basis if such Contributor
|
||||||
|
notifies You of the non-compliance by some reasonable means, this is the
|
||||||
|
first time You have received notice of non-compliance with this License
|
||||||
|
from such Contributor, and You become compliant prior to 30 days after
|
||||||
|
Your receipt of the notice.
|
||||||
|
|
||||||
|
5.2. If You initiate litigation against any entity by asserting a patent
|
||||||
|
infringement claim (excluding declaratory judgment actions,
|
||||||
|
counter-claims, and cross-claims) alleging that a Contributor Version
|
||||||
|
directly or indirectly infringes any patent, then the rights granted to
|
||||||
|
You by any and all Contributors for the Covered Software under Section
|
||||||
|
2.1 of this License shall terminate.
|
||||||
|
|
||||||
|
5.3. In the event of termination under Sections 5.1 or 5.2 above, all
|
||||||
|
end user license agreements (excluding distributors and resellers) which
|
||||||
|
have been validly granted by You or Your distributors under this License
|
||||||
|
prior to termination shall survive termination.
|
||||||
|
|
||||||
|
************************************************************************
|
||||||
|
* *
|
||||||
|
* 6. Disclaimer of Warranty *
|
||||||
|
* ------------------------- *
|
||||||
|
* *
|
||||||
|
* Covered Software is provided under this License on an "as is" *
|
||||||
|
* basis, without warranty of any kind, either expressed, implied, or *
|
||||||
|
* statutory, including, without limitation, warranties that the *
|
||||||
|
* Covered Software is free of defects, merchantable, fit for a *
|
||||||
|
* particular purpose or non-infringing. The entire risk as to the *
|
||||||
|
* quality and performance of the Covered Software is with You. *
|
||||||
|
* Should any Covered Software prove defective in any respect, You *
|
||||||
|
* (not any Contributor) assume the cost of any necessary servicing, *
|
||||||
|
* repair, or correction. This disclaimer of warranty constitutes an *
|
||||||
|
* essential part of this License. No use of any Covered Software is *
|
||||||
|
* authorized under this License except under this disclaimer. *
|
||||||
|
* *
|
||||||
|
************************************************************************
|
||||||
|
|
||||||
|
************************************************************************
|
||||||
|
* *
|
||||||
|
* 7. Limitation of Liability *
|
||||||
|
* -------------------------- *
|
||||||
|
* *
|
||||||
|
* Under no circumstances and under no legal theory, whether tort *
|
||||||
|
* (including negligence), contract, or otherwise, shall any *
|
||||||
|
* Contributor, or anyone who distributes Covered Software as *
|
||||||
|
* permitted above, be liable to You for any direct, indirect, *
|
||||||
|
* special, incidental, or consequential damages of any character *
|
||||||
|
* including, without limitation, damages for lost profits, loss of *
|
||||||
|
* goodwill, work stoppage, computer failure or malfunction, or any *
|
||||||
|
* and all other commercial damages or losses, even if such party *
|
||||||
|
* shall have been informed of the possibility of such damages. This *
|
||||||
|
* limitation of liability shall not apply to liability for death or *
|
||||||
|
* personal injury resulting from such party's negligence to the *
|
||||||
|
* extent applicable law prohibits such limitation. Some *
|
||||||
|
* jurisdictions do not allow the exclusion or limitation of *
|
||||||
|
* incidental or consequential damages, so this exclusion and *
|
||||||
|
* limitation may not apply to You. *
|
||||||
|
* *
|
||||||
|
************************************************************************
|
||||||
|
|
||||||
|
8. Litigation
|
||||||
|
-------------
|
||||||
|
|
||||||
|
Any litigation relating to this License may be brought only in the
|
||||||
|
courts of a jurisdiction where the defendant maintains its principal
|
||||||
|
place of business and such litigation shall be governed by laws of that
|
||||||
|
jurisdiction, without reference to its conflict-of-law provisions.
|
||||||
|
Nothing in this Section shall prevent a party's ability to bring
|
||||||
|
cross-claims or counter-claims.
|
||||||
|
|
||||||
|
9. Miscellaneous
|
||||||
|
----------------
|
||||||
|
|
||||||
|
This License represents the complete agreement concerning the subject
|
||||||
|
matter hereof. If any provision of this License is held to be
|
||||||
|
unenforceable, such provision shall be reformed only to the extent
|
||||||
|
necessary to make it enforceable. Any law or regulation which provides
|
||||||
|
that the language of a contract shall be construed against the drafter
|
||||||
|
shall not be used to construe this License against a Contributor.
|
||||||
|
|
||||||
|
10. Versions of the License
|
||||||
|
---------------------------
|
||||||
|
|
||||||
|
10.1. New Versions
|
||||||
|
|
||||||
|
Mozilla Foundation is the license steward. Except as provided in Section
|
||||||
|
10.3, no one other than the license steward has the right to modify or
|
||||||
|
publish new versions of this License. Each version will be given a
|
||||||
|
distinguishing version number.
|
||||||
|
|
||||||
|
10.2. Effect of New Versions
|
||||||
|
|
||||||
|
You may distribute the Covered Software under the terms of the version
|
||||||
|
of the License under which You originally received the Covered Software,
|
||||||
|
or under the terms of any subsequent version published by the license
|
||||||
|
steward.
|
||||||
|
|
||||||
|
10.3. Modified Versions
|
||||||
|
|
||||||
|
If you create software not governed by this License, and you want to
|
||||||
|
create a new license for such software, you may create and use a
|
||||||
|
modified version of this License if you rename the license and remove
|
||||||
|
any references to the name of the license steward (except to note that
|
||||||
|
such modified license differs from this License).
|
||||||
|
|
||||||
|
10.4. Distributing Source Code Form that is Incompatible With Secondary
|
||||||
|
Licenses
|
||||||
|
|
||||||
|
If You choose to distribute Source Code Form that is Incompatible With
|
||||||
|
Secondary Licenses under the terms of this version of the License, the
|
||||||
|
notice described in Exhibit B of this License must be attached.
|
||||||
|
|
||||||
|
Exhibit A - Source Code Form License Notice
|
||||||
|
-------------------------------------------
|
||||||
|
|
||||||
|
This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
|
If it is not possible or desirable to put the notice in a particular
|
||||||
|
file, then You may include the notice in a location (such as a LICENSE
|
||||||
|
file in a relevant directory) where a recipient would be likely to look
|
||||||
|
for such a notice.
|
||||||
|
|
||||||
|
You may add additional accurate notices of copyright ownership.
|
||||||
|
|
||||||
|
Exhibit B - "Incompatible With Secondary Licenses" Notice
|
||||||
|
---------------------------------------------------------
|
||||||
|
|
||||||
|
This Source Code Form is "Incompatible With Secondary Licenses", as
|
||||||
|
defined by the Mozilla Public License, v. 2.0.
|
208
tools/virustotal-checker/Makefile
Normal file
208
tools/virustotal-checker/Makefile
Normal file
|
@ -0,0 +1,208 @@
|
||||||
|
# CMAKE generated file: DO NOT EDIT!
|
||||||
|
# Generated by "Unix Makefiles" Generator, CMake Version 3.29
|
||||||
|
|
||||||
|
# Default target executed when no arguments are given to make.
|
||||||
|
default_target: all
|
||||||
|
.PHONY : default_target
|
||||||
|
|
||||||
|
# Allow only one "make -f Makefile2" at a time, but pass parallelism.
|
||||||
|
.NOTPARALLEL:
|
||||||
|
|
||||||
|
#=============================================================================
|
||||||
|
# Special targets provided by cmake.
|
||||||
|
|
||||||
|
# Disable implicit rules so canonical targets will work.
|
||||||
|
.SUFFIXES:
|
||||||
|
|
||||||
|
# Disable VCS-based implicit rules.
|
||||||
|
% : %,v
|
||||||
|
|
||||||
|
# Disable VCS-based implicit rules.
|
||||||
|
% : RCS/%
|
||||||
|
|
||||||
|
# Disable VCS-based implicit rules.
|
||||||
|
% : RCS/%,v
|
||||||
|
|
||||||
|
# Disable VCS-based implicit rules.
|
||||||
|
% : SCCS/s.%
|
||||||
|
|
||||||
|
# Disable VCS-based implicit rules.
|
||||||
|
% : s.%
|
||||||
|
|
||||||
|
.SUFFIXES: .hpux_make_needs_suffix_list
|
||||||
|
|
||||||
|
# Command-line flag to silence nested $(MAKE).
|
||||||
|
$(VERBOSE)MAKESILENT = -s
|
||||||
|
|
||||||
|
#Suppress display of executed commands.
|
||||||
|
$(VERBOSE).SILENT:
|
||||||
|
|
||||||
|
# A target that is always out of date.
|
||||||
|
cmake_force:
|
||||||
|
.PHONY : cmake_force
|
||||||
|
|
||||||
|
#=============================================================================
|
||||||
|
# Set environment variables for the build.
|
||||||
|
|
||||||
|
# The shell in which to execute make rules.
|
||||||
|
SHELL = /bin/sh
|
||||||
|
|
||||||
|
# The CMake executable.
|
||||||
|
CMAKE_COMMAND = /usr/local/bin/cmake
|
||||||
|
|
||||||
|
# The command to remove a file.
|
||||||
|
RM = /usr/local/bin/cmake -E rm -f
|
||||||
|
|
||||||
|
# Escaping for special characters.
|
||||||
|
EQUALS = =
|
||||||
|
|
||||||
|
# The top-level source directory on which CMake was run.
|
||||||
|
CMAKE_SOURCE_DIR = /home/mauro/work/malware-snitch
|
||||||
|
|
||||||
|
# The top-level build directory on which CMake was run.
|
||||||
|
CMAKE_BINARY_DIR = /home/mauro/work/malware-snitch
|
||||||
|
|
||||||
|
#=============================================================================
|
||||||
|
# Targets provided globally by CMake.
|
||||||
|
|
||||||
|
# Special rule for the target edit_cache
|
||||||
|
edit_cache:
|
||||||
|
@$(CMAKE_COMMAND) -E cmake_echo_color "--switch=$(COLOR)" --cyan "Running CMake cache editor..."
|
||||||
|
/usr/local/bin/ccmake -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
|
||||||
|
.PHONY : edit_cache
|
||||||
|
|
||||||
|
# Special rule for the target edit_cache
|
||||||
|
edit_cache/fast: edit_cache
|
||||||
|
.PHONY : edit_cache/fast
|
||||||
|
|
||||||
|
# Special rule for the target rebuild_cache
|
||||||
|
rebuild_cache:
|
||||||
|
@$(CMAKE_COMMAND) -E cmake_echo_color "--switch=$(COLOR)" --cyan "Running CMake to regenerate build system..."
|
||||||
|
/usr/local/bin/cmake --regenerate-during-build -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
|
||||||
|
.PHONY : rebuild_cache
|
||||||
|
|
||||||
|
# Special rule for the target rebuild_cache
|
||||||
|
rebuild_cache/fast: rebuild_cache
|
||||||
|
.PHONY : rebuild_cache/fast
|
||||||
|
|
||||||
|
# The main all target
|
||||||
|
all: cmake_check_build_system
|
||||||
|
$(CMAKE_COMMAND) -E cmake_progress_start /home/mauro/work/malware-snitch/CMakeFiles /home/mauro/work/malware-snitch//CMakeFiles/progress.marks
|
||||||
|
$(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 all
|
||||||
|
$(CMAKE_COMMAND) -E cmake_progress_start /home/mauro/work/malware-snitch/CMakeFiles 0
|
||||||
|
.PHONY : all
|
||||||
|
|
||||||
|
# The main clean target
|
||||||
|
clean:
|
||||||
|
$(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 clean
|
||||||
|
.PHONY : clean
|
||||||
|
|
||||||
|
# The main clean target
|
||||||
|
clean/fast: clean
|
||||||
|
.PHONY : clean/fast
|
||||||
|
|
||||||
|
# Prepare targets for installation.
|
||||||
|
preinstall: all
|
||||||
|
$(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 preinstall
|
||||||
|
.PHONY : preinstall
|
||||||
|
|
||||||
|
# Prepare targets for installation.
|
||||||
|
preinstall/fast:
|
||||||
|
$(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 preinstall
|
||||||
|
.PHONY : preinstall/fast
|
||||||
|
|
||||||
|
# clear depends
|
||||||
|
depend:
|
||||||
|
$(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1
|
||||||
|
.PHONY : depend
|
||||||
|
|
||||||
|
#=============================================================================
|
||||||
|
# Target rules for targets named malware-snitch
|
||||||
|
|
||||||
|
# Build rule for target.
|
||||||
|
malware-snitch: cmake_check_build_system
|
||||||
|
$(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 malware-snitch
|
||||||
|
.PHONY : malware-snitch
|
||||||
|
|
||||||
|
# fast build rule for target.
|
||||||
|
malware-snitch/fast:
|
||||||
|
$(MAKE) $(MAKESILENT) -f CMakeFiles/malware-snitch.dir/build.make CMakeFiles/malware-snitch.dir/build
|
||||||
|
.PHONY : malware-snitch/fast
|
||||||
|
|
||||||
|
# target to build an object file
|
||||||
|
src/hasher.o:
|
||||||
|
$(MAKE) $(MAKESILENT) -f CMakeFiles/malware-snitch.dir/build.make CMakeFiles/malware-snitch.dir/src/hasher.o
|
||||||
|
.PHONY : src/hasher.o
|
||||||
|
|
||||||
|
# target to preprocess a source file
|
||||||
|
src/hasher.i:
|
||||||
|
$(MAKE) $(MAKESILENT) -f CMakeFiles/malware-snitch.dir/build.make CMakeFiles/malware-snitch.dir/src/hasher.i
|
||||||
|
.PHONY : src/hasher.i
|
||||||
|
|
||||||
|
# target to generate assembly for a file
|
||||||
|
src/hasher.s:
|
||||||
|
$(MAKE) $(MAKESILENT) -f CMakeFiles/malware-snitch.dir/build.make CMakeFiles/malware-snitch.dir/src/hasher.s
|
||||||
|
.PHONY : src/hasher.s
|
||||||
|
|
||||||
|
# target to build an object file
|
||||||
|
src/main.o:
|
||||||
|
$(MAKE) $(MAKESILENT) -f CMakeFiles/malware-snitch.dir/build.make CMakeFiles/malware-snitch.dir/src/main.o
|
||||||
|
.PHONY : src/main.o
|
||||||
|
|
||||||
|
# target to preprocess a source file
|
||||||
|
src/main.i:
|
||||||
|
$(MAKE) $(MAKESILENT) -f CMakeFiles/malware-snitch.dir/build.make CMakeFiles/malware-snitch.dir/src/main.i
|
||||||
|
.PHONY : src/main.i
|
||||||
|
|
||||||
|
# target to generate assembly for a file
|
||||||
|
src/main.s:
|
||||||
|
$(MAKE) $(MAKESILENT) -f CMakeFiles/malware-snitch.dir/build.make CMakeFiles/malware-snitch.dir/src/main.s
|
||||||
|
.PHONY : src/main.s
|
||||||
|
|
||||||
|
# target to build an object file
|
||||||
|
src/scanner.o:
|
||||||
|
$(MAKE) $(MAKESILENT) -f CMakeFiles/malware-snitch.dir/build.make CMakeFiles/malware-snitch.dir/src/scanner.o
|
||||||
|
.PHONY : src/scanner.o
|
||||||
|
|
||||||
|
# target to preprocess a source file
|
||||||
|
src/scanner.i:
|
||||||
|
$(MAKE) $(MAKESILENT) -f CMakeFiles/malware-snitch.dir/build.make CMakeFiles/malware-snitch.dir/src/scanner.i
|
||||||
|
.PHONY : src/scanner.i
|
||||||
|
|
||||||
|
# target to generate assembly for a file
|
||||||
|
src/scanner.s:
|
||||||
|
$(MAKE) $(MAKESILENT) -f CMakeFiles/malware-snitch.dir/build.make CMakeFiles/malware-snitch.dir/src/scanner.s
|
||||||
|
.PHONY : src/scanner.s
|
||||||
|
|
||||||
|
# Help Target
|
||||||
|
help:
|
||||||
|
@echo "The following are some of the valid targets for this Makefile:"
|
||||||
|
@echo "... all (the default if no target is provided)"
|
||||||
|
@echo "... clean"
|
||||||
|
@echo "... depend"
|
||||||
|
@echo "... edit_cache"
|
||||||
|
@echo "... rebuild_cache"
|
||||||
|
@echo "... malware-snitch"
|
||||||
|
@echo "... src/hasher.o"
|
||||||
|
@echo "... src/hasher.i"
|
||||||
|
@echo "... src/hasher.s"
|
||||||
|
@echo "... src/main.o"
|
||||||
|
@echo "... src/main.i"
|
||||||
|
@echo "... src/main.s"
|
||||||
|
@echo "... src/scanner.o"
|
||||||
|
@echo "... src/scanner.i"
|
||||||
|
@echo "... src/scanner.s"
|
||||||
|
.PHONY : help
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#=============================================================================
|
||||||
|
# Special targets to cleanup operation of make.
|
||||||
|
|
||||||
|
# Special rule to run CMake to check the build system integrity.
|
||||||
|
# No rule that depends on this can have commands that come from listfiles
|
||||||
|
# because they might be regenerated.
|
||||||
|
cmake_check_build_system:
|
||||||
|
$(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0
|
||||||
|
.PHONY : cmake_check_build_system
|
||||||
|
|
54
tools/virustotal-checker/cmake_install.cmake
Normal file
54
tools/virustotal-checker/cmake_install.cmake
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
# Install script for directory: /home/mauro/work/malware-snitch
|
||||||
|
|
||||||
|
# Set the install prefix
|
||||||
|
if(NOT DEFINED CMAKE_INSTALL_PREFIX)
|
||||||
|
set(CMAKE_INSTALL_PREFIX "/usr/local")
|
||||||
|
endif()
|
||||||
|
string(REGEX REPLACE "/$" "" CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
|
||||||
|
|
||||||
|
# Set the install configuration name.
|
||||||
|
if(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME)
|
||||||
|
if(BUILD_TYPE)
|
||||||
|
string(REGEX REPLACE "^[^A-Za-z0-9_]+" ""
|
||||||
|
CMAKE_INSTALL_CONFIG_NAME "${BUILD_TYPE}")
|
||||||
|
else()
|
||||||
|
set(CMAKE_INSTALL_CONFIG_NAME "")
|
||||||
|
endif()
|
||||||
|
message(STATUS "Install configuration: \"${CMAKE_INSTALL_CONFIG_NAME}\"")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Set the component getting installed.
|
||||||
|
if(NOT CMAKE_INSTALL_COMPONENT)
|
||||||
|
if(COMPONENT)
|
||||||
|
message(STATUS "Install component: \"${COMPONENT}\"")
|
||||||
|
set(CMAKE_INSTALL_COMPONENT "${COMPONENT}")
|
||||||
|
else()
|
||||||
|
set(CMAKE_INSTALL_COMPONENT)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Install shared libraries without execute permission?
|
||||||
|
if(NOT DEFINED CMAKE_INSTALL_SO_NO_EXE)
|
||||||
|
set(CMAKE_INSTALL_SO_NO_EXE "0")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Is this installation the result of a crosscompile?
|
||||||
|
if(NOT DEFINED CMAKE_CROSSCOMPILING)
|
||||||
|
set(CMAKE_CROSSCOMPILING "FALSE")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Set default install directory permissions.
|
||||||
|
if(NOT DEFINED CMAKE_OBJDUMP)
|
||||||
|
set(CMAKE_OBJDUMP "/usr/bin/objdump")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(CMAKE_INSTALL_COMPONENT)
|
||||||
|
set(CMAKE_INSTALL_MANIFEST "install_manifest_${CMAKE_INSTALL_COMPONENT}.txt")
|
||||||
|
else()
|
||||||
|
set(CMAKE_INSTALL_MANIFEST "install_manifest.txt")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
string(REPLACE ";" "\n" CMAKE_INSTALL_MANIFEST_CONTENT
|
||||||
|
"${CMAKE_INSTALL_MANIFEST_FILES}")
|
||||||
|
file(WRITE "/home/mauro/work/malware-snitch/${CMAKE_INSTALL_MANIFEST}"
|
||||||
|
"${CMAKE_INSTALL_MANIFEST_CONTENT}")
|
33
tools/virustotal-checker/src/app.h
Normal file
33
tools/virustotal-checker/src/app.h
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
|
#ifndef __MALWARE_SNITCH_APP_H_
|
||||||
|
#define __MALWARE_SNITCH_APP_H_
|
||||||
|
|
||||||
|
namespace malware_snitch {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @struct AppArgs
|
||||||
|
* @brief Data structure to hold the API key and files.
|
||||||
|
*/
|
||||||
|
struct AppArgs {
|
||||||
|
std::string api_key; ///< The API key for VirusTotal.
|
||||||
|
std::vector<std::string> files; ///< The files to be scanned.
|
||||||
|
};
|
||||||
|
|
||||||
|
using CallBackType = std::function<int(AppArgs&)>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Parses command line arguments and runs the scanner.
|
||||||
|
* @param argc The number of command line arguments.
|
||||||
|
* @param argv The command line arguments.
|
||||||
|
* @param callback A callback function to be executed with the parsed arguments.
|
||||||
|
* @return An integer indicating the success or failure of the operation.
|
||||||
|
*/
|
||||||
|
auto ParseArgsAndRun(int argc, char** argv, CallBackType callback) -> int;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // __MALWARE_SNITCH_APP_H_
|
68
tools/virustotal-checker/src/hasher.cc
Normal file
68
tools/virustotal-checker/src/hasher.cc
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
|
||||||
|
#include "hasher.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
#include <iostream>
|
||||||
|
#include <fstream>
|
||||||
|
#include <array>
|
||||||
|
|
||||||
|
#include <openssl/evp.h>
|
||||||
|
|
||||||
|
#define HASHER_FAIL(message) \
|
||||||
|
std::cerr << "Hasher Error: " << message << std::endl; \
|
||||||
|
return std::string();
|
||||||
|
|
||||||
|
namespace malware_snitch {
|
||||||
|
|
||||||
|
auto Hasher::CalculateSHA256Helper(const std::string& aFile) -> std::string {
|
||||||
|
std::array<unsigned char, EVP_MAX_MD_SIZE> hash;
|
||||||
|
unsigned int hashLength = 0;
|
||||||
|
EVP_MD_CTX* ctx = EVP_MD_CTX_new();
|
||||||
|
if (!ctx) {
|
||||||
|
HASHER_FAIL("Failed to create EVP_MD_CTX");
|
||||||
|
}
|
||||||
|
if (EVP_DigestInit_ex(ctx, EVP_sha256(), nullptr) != 1) {
|
||||||
|
EVP_MD_CTX_free(ctx);
|
||||||
|
HASHER_FAIL("Failed to initialize digest context");
|
||||||
|
}
|
||||||
|
std::ifstream file(aFile, std::ios::binary);
|
||||||
|
if (!file) {
|
||||||
|
EVP_MD_CTX_free(ctx);
|
||||||
|
HASHER_FAIL("Failed to open file: " + aFile);
|
||||||
|
}
|
||||||
|
std::vector<char> buffer(8192);
|
||||||
|
while (file) {
|
||||||
|
file.read(buffer.data(), buffer.size());
|
||||||
|
std::streamsize bytesRead = file.gcount();
|
||||||
|
if (bytesRead > 0) {
|
||||||
|
if (EVP_DigestUpdate(ctx, buffer.data(), bytesRead) != 1) {
|
||||||
|
EVP_MD_CTX_free(ctx);
|
||||||
|
HASHER_FAIL("Failed to update digest");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (EVP_DigestFinal_ex(ctx, hash.data(), &hashLength) != 1) {
|
||||||
|
EVP_MD_CTX_free(ctx);
|
||||||
|
HASHER_FAIL("Failed to finalize digest");
|
||||||
|
}
|
||||||
|
EVP_MD_CTX_free(ctx);
|
||||||
|
return HashToString<EVP_MAX_MD_SIZE>(hash, hashLength);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto Hasher::CalculateSHA256Files(const std::vector<std::string>& aFiles) -> std::vector<std::string> {
|
||||||
|
std::vector<std::string> hashes;
|
||||||
|
for (const auto& file : aFiles) {
|
||||||
|
hashes.push_back(CalculateSHA256(file));
|
||||||
|
}
|
||||||
|
return hashes;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto Hasher::CalculateSHA256(const std::string& aFile) -> std::string {
|
||||||
|
auto hash = CalculateSHA256Helper(aFile);
|
||||||
|
std::cout << "\t[+] Hashed: " << aFile << " -> " << hash << std::endl;
|
||||||
|
return hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
}; // namespace malware_snitch
|
64
tools/virustotal-checker/src/hasher.h
Normal file
64
tools/virustotal-checker/src/hasher.h
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef __MALWARE_SNITCH_HASHER_H_
|
||||||
|
#define __MALWARE_SNITCH_HASHER_H_
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
#include <memory>
|
||||||
|
#include <array>
|
||||||
|
#include <sstream>
|
||||||
|
#include <iomanip>
|
||||||
|
|
||||||
|
namespace malware_snitch {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @class Hasher
|
||||||
|
* @brief A class with the purpose of calculating the SHA256 hash of a file.
|
||||||
|
* It provides a method to calculate the hash and return it as a string.
|
||||||
|
*/
|
||||||
|
class Hasher {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* @brief Calculates the SHA256 hash of a file.
|
||||||
|
* @param aFile The path to the file.
|
||||||
|
* @return The SHA256 hash as a string.
|
||||||
|
*/
|
||||||
|
static auto CalculateSHA256(const std::string& aFile) -> std::string;
|
||||||
|
/**
|
||||||
|
* @brief Calculates the SHA256 hash from a list of files.
|
||||||
|
* @param aFiles A vector of file paths.
|
||||||
|
* @return A vector of SHA256 hashes.
|
||||||
|
*/
|
||||||
|
static auto CalculateSHA256Files(const std::vector<std::string>& aFiles) -> std::vector<std::string>;
|
||||||
|
private:
|
||||||
|
/**
|
||||||
|
* @brief Helper function to calculate the SHA256 hash.
|
||||||
|
* @param aFile The path to the file.
|
||||||
|
* @return The SHA256 hash as a string.
|
||||||
|
*/
|
||||||
|
static auto CalculateSHA256Helper(const std::string& aFile) -> std::string;
|
||||||
|
/**
|
||||||
|
* @brief Converts a hash to a string.
|
||||||
|
* @param hash The hash data.
|
||||||
|
* @param length The length of the hash.
|
||||||
|
* @return The hash as a string.
|
||||||
|
*/
|
||||||
|
template <size_t N>
|
||||||
|
static auto HashToString(const std::array<unsigned char, N> &aHash, const uint aLength) -> std::string {
|
||||||
|
std::stringstream ss;
|
||||||
|
for (size_t i = 0; i < aLength; ++i) {
|
||||||
|
ss << std::hex << std::setw(2) << std::setfill('0') << static_cast<int>(aHash[i]);
|
||||||
|
}
|
||||||
|
return ss.str();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace malware_snitch
|
||||||
|
|
||||||
|
#endif // __MALWARE_SNITCH_HASHER_H_
|
25526
tools/virustotal-checker/src/json.hpp
Normal file
25526
tools/virustotal-checker/src/json.hpp
Normal file
File diff suppressed because it is too large
Load diff
77
tools/virustotal-checker/src/main.cc
Normal file
77
tools/virustotal-checker/src/main.cc
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
|
||||||
|
#include "app.h"
|
||||||
|
#include "scanner.h"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
#include <optional>
|
||||||
|
|
||||||
|
namespace malware_snitch {
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
/// @brief Function to convert C argv into a vector of strings
|
||||||
|
/// @param argc The number of command line arguments.
|
||||||
|
/// @param argv The command line arguments.
|
||||||
|
/// @return A vector of strings containing the command line arguments.
|
||||||
|
auto ConvertArgsToVector(int argc, char** argv) -> std::vector<std::string> {
|
||||||
|
std::vector<std::string> args;
|
||||||
|
for (int i = 0; i < argc; ++i) {
|
||||||
|
args.emplace_back(argv[i]);
|
||||||
|
}
|
||||||
|
return args;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @brief Show CLI help message.
|
||||||
|
auto ShowHelp() -> int {
|
||||||
|
std::cerr << "Usage: malware_snitch <API_KEY> <FILE1> <FILE2> ...\n";
|
||||||
|
std::cerr << "Example: malware_snitch my_api_key file1.txt file2.txt\n";
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @brief Function to fetch the API key and files from the command line arguments.
|
||||||
|
/// @param args The command line arguments as a vector of strings.
|
||||||
|
auto FetchArgs(const std::vector<std::string>& args) -> std::optional<AppArgs> {
|
||||||
|
AppArgs app_args;
|
||||||
|
if (args.size() < 3) {
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
app_args.api_key = args[1];
|
||||||
|
for (size_t i = 2; i < args.size(); ++i) {
|
||||||
|
app_args.files.emplace_back(args[i]);
|
||||||
|
}
|
||||||
|
return app_args;
|
||||||
|
}
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
/// @brief Function to parse command line arguments and run the scanner.
|
||||||
|
/// @param argc The number of command line arguments.
|
||||||
|
/// @param argv The command line arguments.
|
||||||
|
/// @param callback A callback function to be executed with the parsed arguments.
|
||||||
|
/// @return An integer indicating the success or failure of the operation.
|
||||||
|
auto ParseArgsAndRun(int argc, char** argv, CallBackType callback) -> int {
|
||||||
|
auto parsedArgs = FetchArgs(ConvertArgsToVector(argc, argv));
|
||||||
|
if (!parsedArgs.has_value()) {
|
||||||
|
ShowHelp();
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
return callback(
|
||||||
|
parsedArgs.value()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @brief Main function to run the malware scanner.
|
||||||
|
/// @param argc The number of command line arguments.
|
||||||
|
/// @param argv The command line arguments.
|
||||||
|
/// @return An integer indicating the success or failure of the operation.
|
||||||
|
auto Main(int argc, char** argv) -> int {
|
||||||
|
return ParseArgsAndRun(argc, argv, [](AppArgs& args) -> int {
|
||||||
|
auto scanner = Scanner::Singleton(args.files);
|
||||||
|
return scanner->CheckFiles(args.api_key);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} // namespace malware_snitch
|
||||||
|
|
||||||
|
int main(int argc, char** argv) {
|
||||||
|
return malware_snitch::Main(argc, argv);
|
||||||
|
}
|
104
tools/virustotal-checker/src/scanner.cc
Normal file
104
tools/virustotal-checker/src/scanner.cc
Normal file
|
@ -0,0 +1,104 @@
|
||||||
|
|
||||||
|
#include "scanner.h"
|
||||||
|
#include "hasher.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
#include <iostream>
|
||||||
|
#include <fstream>
|
||||||
|
#include <array>
|
||||||
|
|
||||||
|
#include <curl/curl.h>
|
||||||
|
|
||||||
|
namespace malware_snitch {
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
auto CurlWriteCallback(char *contents, size_t size, size_t nmemb, void *userp) -> size_t{
|
||||||
|
((std::string*)userp)->append((char*)contents, size * nmemb);
|
||||||
|
return size * nmemb;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto GetFileName(const std::string& aFile) -> std::string {
|
||||||
|
size_t pos = aFile.find_last_of("/\\");
|
||||||
|
if (pos == std::string::npos) {
|
||||||
|
return aFile; // No path, return the file name
|
||||||
|
}
|
||||||
|
return aFile.substr(pos + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
auto Scanner::Singleton(std::vector<std::string> aFiles) -> Scanner* {
|
||||||
|
static Scanner* instance = new Scanner(aFiles);
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto Scanner::CheckFiles(const std::string& aKey) -> int {
|
||||||
|
auto uploadResponses = UploadFile(aKey);
|
||||||
|
auto statusResponse = CheckStatus(aKey);
|
||||||
|
// Process the responses as needed
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto Scanner::UploadFile(const std::string& aKey) -> std::vector<json> {
|
||||||
|
auto hashes = CalculateSHA256Files();
|
||||||
|
for (uint i = 0; i < mFiles.size(); ++i) {
|
||||||
|
auto& file = mFiles[i];
|
||||||
|
auto& hash = hashes[i];
|
||||||
|
std::cout << "\t[+] Uploading " << file << std::endl;
|
||||||
|
CURL *hnd = curl_easy_init();
|
||||||
|
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
|
||||||
|
curl_easy_setopt(hnd, CURLOPT_WRITEDATA, stdout);
|
||||||
|
curl_easy_setopt(hnd, CURLOPT_URL, VIRUS_TOTAL_API_URL VIRUS_TOTAL_UPLOAD_ROUTE);
|
||||||
|
|
||||||
|
struct curl_slist *headers = NULL;
|
||||||
|
headers = curl_slist_append(headers, "accept: application/json");
|
||||||
|
headers = curl_slist_append(headers, ("X-Apikey: " + aKey).c_str());
|
||||||
|
headers = curl_slist_append(headers, (
|
||||||
|
"Content-Disposition: form-data; name=\"file\"; filename=\"" +
|
||||||
|
GetFileName(file) +
|
||||||
|
"\""
|
||||||
|
).c_str());
|
||||||
|
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
|
||||||
|
std::string response;
|
||||||
|
|
||||||
|
curl_easy_setopt(hnd, CURLOPT_WRITEFUNCTION, CurlWriteCallback);
|
||||||
|
curl_easy_setopt(hnd, CURLOPT_WRITEDATA, &response);
|
||||||
|
std::ifstream fileStream(file, std::ios::binary);
|
||||||
|
if (!fileStream) {
|
||||||
|
std::cerr << "Error: Could not open file " << file << std::endl;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string fileData((std::istreambuf_iterator<char>(fileStream)), std::istreambuf_iterator<char>());
|
||||||
|
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, fileData.c_str());
|
||||||
|
curl_easy_setopt(hnd, CURLOPT_POSTFIELDSIZE, fileData.size());
|
||||||
|
CURLcode ret = curl_easy_perform(hnd);
|
||||||
|
|
||||||
|
if (ret != CURLE_OK) {
|
||||||
|
std::cerr << "\nError: " << curl_easy_strerror(ret) << std::endl;
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << "\t[+] Response: " << response << std::endl;
|
||||||
|
|
||||||
|
auto jsonResponse = json::parse(response);
|
||||||
|
auto uploadUrl = jsonResponse["data"];
|
||||||
|
}
|
||||||
|
return json();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto Scanner::CalculateSHA256Files() -> std::vector<std::string> {
|
||||||
|
return Hasher::CalculateSHA256Files(mFiles);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto Scanner::CheckStatus(const std::string& aKey) -> json {
|
||||||
|
// Implement the status check logic here
|
||||||
|
// Use libcurl to send a GET request to VirusTotal
|
||||||
|
// Return the response as a json object
|
||||||
|
return json();
|
||||||
|
}
|
||||||
|
|
||||||
|
}; // namespace malware_snitch
|
66
tools/virustotal-checker/src/scanner.h
Normal file
66
tools/virustotal-checker/src/scanner.h
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
|
||||||
|
#ifndef __MALWARE_SNITCH_SCANNER_H_
|
||||||
|
#define __MALWARE_SNITCH_SCANNER_H_
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
#include <json.hpp>
|
||||||
|
|
||||||
|
#define VIRUS_TOTAL_API_URL "https://www.virustotal.com/api/v3"
|
||||||
|
#define VIRUS_TOTAL_FILES_ROUTE "/files"
|
||||||
|
#define VIRUS_TOTAL_UPLOAD_ROUTE VIRUS_TOTAL_FILES_ROUTE "/upload_url"
|
||||||
|
|
||||||
|
namespace malware_snitch {
|
||||||
|
using json = nlohmann::json;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @class Scanner
|
||||||
|
* @brief A class that represents a scanner for malware detection.
|
||||||
|
* It performs various operations on a set of files. The scanner uploads them to VirusTotal,
|
||||||
|
* checks their status, and downloads the results. It also checks for signatures in the files.
|
||||||
|
*/
|
||||||
|
class Scanner {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* @brief Construct or initialize the scanner.
|
||||||
|
* @param aFiles A vector of file paths to be scanned.
|
||||||
|
*/
|
||||||
|
static auto Singleton(std::vector<std::string> aFiles) -> Scanner*;
|
||||||
|
/**
|
||||||
|
* @brief Uploads files to VirusTotal, check for their status, and download results.
|
||||||
|
* @param aKey The API key for VirusTotal.
|
||||||
|
*/
|
||||||
|
auto CheckFiles(const std::string& aKey) -> int;
|
||||||
|
|
||||||
|
~Scanner() = default;
|
||||||
|
private:
|
||||||
|
Scanner(std::vector<std::string> aFiles) : mFiles(aFiles) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Uploads a file to VirusTotal.
|
||||||
|
* @return The response from the upload request for each file.
|
||||||
|
*/
|
||||||
|
auto UploadFile(const std::string& aKey) -> std::vector<json>;
|
||||||
|
/**
|
||||||
|
* @brief Calculates the SHA256 hash of the given files.
|
||||||
|
* @return A list of SHA256 hashes.
|
||||||
|
*/
|
||||||
|
auto CalculateSHA256Files() -> std::vector<std::string>;
|
||||||
|
/**
|
||||||
|
* @brief Checks the status of the uploaded files.
|
||||||
|
* @return The response from the status check request.
|
||||||
|
*/
|
||||||
|
auto CheckStatus(const std::string& aKey) -> json;
|
||||||
|
protected:
|
||||||
|
std::vector<std::string> mFiles; ///< The files to be scanned.
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace malware_snitch
|
||||||
|
#endif // __MALWARE_SNITCH_SCANNER_H_
|
Loading…
Add table
Add a link
Reference in a new issue