-
Notifications
You must be signed in to change notification settings - Fork 41
/
match.py
executable file
·69 lines (59 loc) · 2.72 KB
/
match.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/python
########################################################################
# Copyright (c) 2017
# Daniel Plohmann <daniel.plohmann<at>mailbox<dot>org>
# Steffen Enders <steffen<at>enders<dot>nrw>
# All rights reserved.
########################################################################
#
# This file is part of apiscout
#
# apiscout is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see
# <http://www.gnu.org/licenses/>.
#
########################################################################
import argparse
import os
import sys
import logging
from apiscout.ApiScout import ApiScout
LOG = logging.getLogger(__name__)
logging.basicConfig(level=logging.INFO, format="%(asctime)-15s %(message)s")
def get_this_dir():
return os.path.abspath(os.path.join(os.path.dirname(__file__)))
def get_winapi1024_path():
return get_this_dir() + os.sep + "apiscout" + os.sep + "data" + os.sep + "winapi1024v1.txt"
def main():
parser = argparse.ArgumentParser(description='Demo: Use apiscout to match WinApi1024 vectors.')
parser.add_argument('vector_a', type=str, default='', help='compressed version of first vector.')
parser.add_argument('-v', '--vector_b', type=str, default='', help='compressed version of second vector.')
parser.add_argument('-c', '--collection', type=str, default='', help='Path to a collection of compressed vectors.')
parser.add_argument('-n', '--max_results', type=int, default=5, help='Maximum number of family results to show.')
args = parser.parse_args()
scout = ApiScout()
# load WinApi1024 vector
scout.loadWinApi1024(get_winapi1024_path())
if args.vector_a and args.vector_b:
score = scout.matchVectors(args.vector_a, args.vector_b)
print("Result of matching vectors:")
print("Vector A: {}".format(args.vector_a))
print("Vector B: {}".format(args.vector_b))
print("Score: {}".format(score))
elif args.vector_a and args.collection:
collection_result = scout.matchVectorCollection(args.vector_a, args.collection)
print(scout.renderVectorCollectionResults(collection_result, args.max_results))
else:
parser.print_help()
if __name__ == "__main__":
sys.exit(main())