Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed occurrences #20

Open
wants to merge 148 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
148 commits
Select commit Hold shift + click to select a range
61f551e
Updated to version 0.6
Neo23x0 Jan 25, 2014
fd645db
Bugfix - Update DB not working
Neo23x0 Jan 27, 2014
cd7a428
Removed debug output and README update
Neo23x0 Jan 28, 2014
f7708b9
README Update
Neo23x0 Jan 28, 2014
6bf1b36
Added option to ignore extensions
Neo23x0 Feb 16, 2014
2d2d554
Bugfix
Neo23x0 Apr 14, 2014
b0c91f5
Binary Signature Generator
Neo23x0 Jun 23, 2014
b83c1ae
Byte Mapper
Neo23x0 Jun 23, 2014
83c4653
0.7 Update - Unicode Strings, GibberishDetect
Neo23x0 Jul 6, 2014
22d4434
Scoring Improvements
Neo23x0 Jul 16, 2014
ed6d387
Fixes and minor improvements
Neo23x0 Nov 10, 2014
a6d448d
ignore
Neo23x0 Nov 10, 2014
d46d0e7
0.8 added date field
Neo23x0 Dec 3, 2014
bad664b
0.8.2 - New detections and PEStudio XML option
Neo23x0 Dec 4, 2014
1637711
Name Change
Neo23x0 Dec 5, 2014
7064834
Name Change
Neo23x0 Dec 5, 2014
40767db
Name Change Prog
Neo23x0 Dec 5, 2014
6b90f8b
yarGen Update
Neo23x0 Dec 6, 2014
c450b1d
YarGen v0.9
Neo23x0 Dec 6, 2014
76c031a
README and Sample
Neo23x0 Dec 6, 2014
18841ea
0.9.1
Neo23x0 Dec 9, 2014
789ddb2
ignore
Neo23x0 Dec 9, 2014
acbb3fc
v0.9.2 - lxml optional, CMS sources in GoodStrings
Neo23x0 Jan 5, 2015
de74374
0.9.4 - recursive is the new default
Neo23x0 Jan 5, 2015
cb5fec1
Update README.txt
Neo23x0 Jan 5, 2015
4f25f48
Screenshots
Neo23x0 Jan 5, 2015
9e4ba80
README Markdown
Neo23x0 Jan 5, 2015
13b31a0
Markdown
Neo23x0 Jan 5, 2015
e00c67f
Markdown Syntax Bugs
Neo23x0 Jan 5, 2015
dbf8c9c
Visual improment
Neo23x0 Jan 5, 2015
2a28885
Ready Update - Examples
Neo23x0 Jan 5, 2015
af2dc04
Typo
Neo23x0 Jan 5, 2015
66117ee
Update README.md
Neo23x0 Jan 5, 2015
458f1d3
Update README.md
Neo23x0 Jan 5, 2015
0cfb446
License
Neo23x0 Jan 5, 2015
290f487
License
Neo23x0 Jan 5, 2015
36e6c3c
Delete .gitignore
Neo23x0 Jan 5, 2015
ef3c91e
Removed file
Neo23x0 Jan 5, 2015
e730c60
Clean up
Neo23x0 Jan 6, 2015
29e5768
0.10.0
Neo23x0 Feb 11, 2015
bbc9935
yarGen v0.11.0
Neo23x0 May 1, 2015
15c09e3
Update README.md
Neo23x0 May 1, 2015
ab705d1
Screenshot Update
Neo23x0 May 1, 2015
b44cad3
Screenshot Update
Neo23x0 May 1, 2015
9ad7288
Update README.md
Neo23x0 May 1, 2015
34ecd4e
Screenshot updated
Neo23x0 May 1, 2015
63b3012
v0.11.1
Neo23x0 May 1, 2015
de84160
Typo and Readme Update
Neo23x0 May 1, 2015
7b6d294
Added Gitter badge
gitter-badger May 7, 2015
ff0089d
Merge pull request #1 from gitter-badger/gitter-badge
Neo23x0 May 7, 2015
e3c3906
Detects base64 encoded strings
Neo23x0 May 7, 2015
29589f8
v0.11.3 Reversed String Detection
Neo23x0 May 7, 2015
f1db409
v0.12.0
Neo23x0 May 15, 2015
324ead2
Adjusted scoring
Neo23x0 May 15, 2015
95a6497
Accidentally included
Neo23x0 May 15, 2015
95e5902
v0.12.1 - Bugfix
Neo23x0 May 15, 2015
31d8e42
Typo
Neo23x0 May 16, 2015
79b5464
Update for 0.12.0
Neo23x0 May 16, 2015
e4f623d
Update README.md
Neo23x0 May 16, 2015
9e04252
Fix args typo
May 17, 2015
fcf82f4
Merge pull request #2 from seanthegeek/master
Neo23x0 May 17, 2015
e94169d
Improved String Filtering: RATs, User Profiles
Neo23x0 May 24, 2015
10f4878
Updated Memory Usage - uses up to 2GB
Neo23x0 May 31, 2015
67a9a20
v0.13.0
Neo23x0 May 31, 2015
5e40747
Cleanup
Neo23x0 May 31, 2015
4ed7c93
Scoring Adjustments
Neo23x0 Jun 3, 2015
8f058b8
Scoring Adjustments
Neo23x0 Jun 3, 2015
3437354
Score - Floating Point Cosmetics
Neo23x0 Jun 3, 2015
749a4c0
Bugfixes and Improvements
Neo23x0 Jun 13, 2015
bc98a80
v0.14.0
Neo23x0 Jul 8, 2015
50ba9dd
v0.14.1
Neo23x0 Jul 8, 2015
2f5cc81
README Update and Default Max String Size
Neo23x0 Jul 9, 2015
4522fd3
v0.14.2
Neo23x0 Jul 9, 2015
4b87120
Improved the Fuzzy Regex Filtes
Neo23x0 Jul 10, 2015
7697e17
Bugfix
Neo23x0 Jul 13, 2015
c4db781
Bugfix
Neo23x0 Jul 13, 2015
4a42143
v0.14.3
Neo23x0 Jul 14, 2015
1ccf977
v0.15.0 - still beta
Neo23x0 Jul 20, 2015
6ffd1d6
Updated README - fixed Bug
Neo23x0 Jul 24, 2015
d221ade
Improved Regex Filters
Neo23x0 Jul 30, 2015
0311261
Bugfixes and minor changes
Neo23x0 Aug 11, 2015
22aebd6
Removed unneeded package pickle
Neo23x0 Nov 11, 2015
9031fde
Minor Fixes / Changes
Neo23x0 Oct 16, 2015
26cb539
Minor improvements of regex extraction
Neo23x0 Feb 2, 2016
f156c9c
Update README.md
Neo23x0 Feb 19, 2016
d5837b1
Removed sample rules
Neo23x0 Apr 11, 2016
97e839e
v0.16.0b
Neo23x0 Apr 15, 2016
deaddfa
fix crash: file_opcodes[filePath] crash when key does not exist.
CrimsonGlory May 6, 2016
7a1dd9e
Merge pull request #9 from CrimsonGlory/master
Neo23x0 May 6, 2016
ce306be
Added link to new blog article
Neo23x0 May 6, 2016
9b11da4
allow script to be executed from any directory
CrimsonGlory May 12, 2016
73025b1
Merge pull request #10 from CrimsonGlory/master
Neo23x0 May 12, 2016
b85a099
v0.16.1
Neo23x0 Aug 9, 2016
f9a5b82
Improvements and cleanup
Nov 15, 2016
7df70c3
Opcode extraction improvement by @jemik
Nov 15, 2016
a458b52
Cosmetics
Feb 5, 2017
98148ae
Changes to get_binarly_data (service currently offline)
Feb 5, 2017
166ef0e
Changes to --opcodes feature
Feb 5, 2017
60035e3
0.16.3 Extraction improvements
Feb 5, 2017
3bfad91
Multiple database support
Feb 6, 2017
8138585
yarGen 0.17.0 cleanup
Feb 6, 2017
01f97fb
README update for version 0.17.0
Feb 6, 2017
a40eab1
README cosmetics
Feb 6, 2017
a99ae3e
README cosmetics
Neo23x0 Feb 6, 2017
6cf514d
REAME line break fix
Neo23x0 Feb 6, 2017
34ecde9
Bugfixes
Feb 11, 2017
37f04b8
Improvements
Feb 11, 2017
5913420
0.17.1 Bugfixes and new signature database downloads
Feb 17, 2017
505ed61
allow the script to be executed from any directory
CrimsonGlory Mar 17, 2017
0f078f2
Merge pull request #14 from CrimsonGlory/patch-1
Neo23x0 Mar 17, 2017
76571cd
Preferred Opcodes, Bugfix
Apr 10, 2017
6a06747
Cosmetics
Apr 12, 2017
aa2b413
New keywords: Attack, Unix/Linux
Apr 12, 2017
6d389b6
Changed line separator to Linux/Unix for less comfortable IDEs
Jun 10, 2017
50921b2
Fixes
Neo23x0 Jun 10, 2017
7682e2d
Regex extensions
Jun 23, 2017
793bf6f
v0.18.0
Aug 14, 2017
6249402
Updated README
Aug 14, 2017
c91c17e
Minor change: x of ($s*) to x of them
Aug 18, 2017
95a157f
Included link to post-processing tutorial
Neo23x0 Oct 24, 2017
435fc09
Fixed typo
Neo23x0 Feb 17, 2018
4e1bda1
Dropzone mode testing
Feb 19, 2018
5b5e87e
Bugfixes
Feb 19, 2018
fe7fc01
Added option to manually set the identifier
Feb 19, 2018
044ad96
README update
Feb 19, 2018
c886039
Dropzone mode update, README update
Feb 19, 2018
7afbf66
Minor bugfix/improvement
Feb 19, 2018
cf3038e
Bugfix - creation (-c)
Feb 24, 2018
bcfcf38
Improved bugfix
Feb 24, 2018
f5686ca
Inverse evaluation only when needed
Apr 18, 2018
7277aa6
Changed string extraction function
Apr 18, 2018
6fec354
Score adjustments
Apr 18, 2018
96dab2e
--debug / --trace parameter adjustments
Apr 18, 2018
6182371
Cosmetics: missing space in rule condition
Apr 18, 2018
3552147
Hex Encoded Strings Extraction and Analysis
Apr 18, 2018
07836d8
Version Number Updated
Apr 18, 2018
1fbbd4f
Scoring adjustments
Apr 18, 2018
f60700a
README updated
Apr 18, 2018
d78be2e
README fixes
Apr 18, 2018
84662f0
Slight modification to avoid strings with too many repeated characters
Apr 21, 2018
e6764c6
Drop non-ASCII strings in comment
Apr 23, 2018
2ebda48
refactor: major refactoring of the condition creation process
Sep 8, 2018
b9d9729
Regular expressions updated
Sep 26, 2018
ce32de7
Changed download location for the default databases
Oct 16, 2018
bab6e73
feat: Write strings to file
Nov 1, 2018
15e3c6d
requirements.txt file
Nov 1, 2018
6ee5b9f
refactor: preparations for Python3 compatibility
Nov 1, 2018
6a5e8e7
fixed occurrences
0xflotus Dec 16, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions .gitignore

This file was deleted.

3,193 changes: 3,193 additions & 0 deletions 3rdparty/strings.xml

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
yarGen - Yara Rule Generator, Copyright (c) 2015, Florian Roth
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the copyright owner nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL Florian Roth BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
265 changes: 265 additions & 0 deletions README.md

Large diffs are not rendered by default.

56 changes: 0 additions & 56 deletions README.txt

This file was deleted.

224 changes: 224 additions & 0 deletions db-lookup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,224 @@
#!/usr/bin/env python
# -*- coding: iso-8859-1 -*-
# -*- coding: utf-8 -*-
#
# Imphash Lookup in yarGens database
#
# Florian Roth

import os
import gzip
import pickle
import traceback
import argparse
import sys
import re
import signal as signal_module
import readline
from colorama import init, Fore, Back, Style
from collections import Counter

readline.parse_and_bind('tab: complete')
readline.parse_and_bind('set editing-mode vi')

__AUTHOR__ = "Florian Roth"
__VERSION__ = "0.1"

VALID_LOOKUPS = ["strings", "exports", "opcodes", "imphash"]

def get_abs_path(filename):
return os.path.join(os.path.dirname(os.path.abspath(__file__)), filename)

def load(filename):
file = gzip.GzipFile(filename, 'rb')
buffer = ""
while 1:
data = file.read()
if data == "":
break
buffer += data
object = pickle.loads(buffer)
del (buffer)
file.close()
return object

def init_database(lookups):
"""
Initialize the database for the lookups
:return:
"""

opcodes_num = 0
strings_num = 0
imphash_num = 0
exports_num = 0

# Initialize all databases
for file in os.listdir(get_abs_path("./dbs/")):
if not file.endswith(".db"):
continue
filePath = os.path.join("./dbs/", file)

# String databases
if file.startswith("good-strings") and "strings" in lookups:
try:
print "[+] Loading %s ..." % filePath
good_pickle = load(get_abs_path(filePath))
good_strings_db.update(good_pickle)
print "[+] Total: %s / Added %d entries" % (
len(good_strings_db), len(good_strings_db) - strings_num)
strings_num = len(good_strings_db)
except Exception, e:
traceback.print_exc()
# Opcode databases
if file.startswith("good-opcodes") and "opcodes" in lookups:
try:
if use_opcodes:
print "[+] Loading %s ..." % filePath
good_op_pickle = load(get_abs_path(filePath))
good_opcodes_db.update(good_op_pickle)
print "[+] Total: %s (removed duplicates) / Added %d entries" % (
len(good_opcodes_db), len(good_opcodes_db) - opcodes_num)
opcodes_num = len(good_opcodes_db)
except Exception, e:
use_opcodes = False
traceback.print_exc()
# Imphash databases
if file.startswith("good-imphash") and "imphash" in lookups:
try:
print "[+] Loading %s ..." % filePath
good_imphashes_pickle = load(get_abs_path(filePath))
good_imphashes_db.update(good_imphashes_pickle)
print "[+] Total: %s / Added %d entries" % (
len(good_imphashes_db), len(good_imphashes_db) - imphash_num)
imphash_num = len(good_imphashes_db)
except Exception, e:
traceback.print_exc()
# Export databases
if file.startswith("good-exports") and "exports" in lookups:
try:
print "[+] Loading %s ..." % filePath
good_exports_pickle = load(get_abs_path(filePath))
good_exports_db.update(good_exports_pickle)
print "[+] Total: %s / Added %d entries" % (
len(good_exports_db), len(good_exports_db) - exports_num)
exports_num = len(good_exports_db)
except Exception, e:
traceback.print_exc()

def print_welcome():
print Style.RESET_ALL
print Fore.WHITE + Back.BLUE
print " ".ljust(80)
print " ______ __ __ ".ljust(80)
print " __ ______ ______/ ____/__ ____ / / ____ ____ / /____ ______ ".ljust(80)
print " / / / / __ `/ ___/ / __/ _ \\/ __ \\ / / / __ \\/ __ \\/ //_/ / / / __ \\".ljust(80)
print " / /_/ / /_/ / / / /_/ / __/ / / / / /___/ /_/ / /_/ / ,< / /_/ / /_/ /".ljust(80)
print " \\__, /\\__,_/_/ \\____/\\___/_/ /_/ /_____/\\____/\\____/_/|_|\\__,_/ .___/ ".ljust(80)
print " /____/ /_/ ".ljust(80)
print " ".ljust(80)
print (" " + __AUTHOR__ + " - " + __VERSION__ + "").ljust(80)
print " ".ljust(80) + Style.RESET_ALL
print Style.RESET_ALL + " "


# CTRL+C Handler --------------------------------------------------------------
def signal_handler(signal_name, frame):
print "------------------------------------------------------------------------------\n"
print 'INTERRUPTED'
sys.exit(0)


# MAIN ################################################################
if __name__ == '__main__':
# Parse Arguments
parser = argparse.ArgumentParser(description='yarGen')

parser.add_argument('-f', help='File that contains imphashes/strings/exports')
parser.add_argument('-l', action='append', nargs='+', help='Activate the following lookups only (seperated by '
'space; valid values are: strings, opcodes, imphash, '
'exports)', metavar='activelookups')

args = parser.parse_args()

# Print Welcome
print_welcome()

# Signal handler for CTRL+C ---------------------------------------
signal_module.signal(signal_module.SIGINT, signal_handler)

# Error checks
if not args.l:
print "[E] You must define at least on lookup module -l [%s]" % " ".join(VALID_LOOKUPS)
sys.exit(1)
for l in args.l[0]:
if l not in VALID_LOOKUPS:
print "[E] '%s' is an unknown lookup - valid lookups are: %s" % (l, ", ".join(VALID_LOOKUPS))
sys.exit(1)

# Active lookups
active_lookpups = args.l[0]

# Initialize the lookup databases
good_strings_db = Counter()
good_opcodes_db = Counter()
good_imphashes_db = Counter()
good_exports_db = Counter()

init_database(active_lookpups)

# File input or command line input
if args.f:
print "not yet implemented"
else:
# Input loop
print "Provide a value (%s) as input" % ", ".join(active_lookpups)
while True:
input_value = raw_input("> ")

types = []

# Determine input values format
# MD5 > Imphash
res_md5 = re.search(r'^[\s]*([A-Fa-f0-9]{32})[\s]*$', input_value)
if res_md5:
types.append("imphash")
# Cleanup value
input_value = res_md5.group(0)
# Could also be opcode or string
types.append("opcode")
types.append("string")
# Opcode
res_op = re.search(r'^[\s]*([A-Fa-f0-9\s]+)[\s]*$', input_value)
if res_op:
types.append("opcode")
# Cleanup value
input_value = res_op.group(0)
input_value = re.sub(r' ', '', input_value, count=0)
# Could also be a string
types.append("string")
# String
if not res_md5 and not res_op:
types.append("string")

# Type lookups
if "imphash" in types:
if "imphash" in active_lookpups:
if input_value in good_imphashes_db:
print Fore.BLACK, Back.GREEN, "IMPHASH KNOWN GOOD FROM %d FILES" \
% good_imphashes_db[input_value], Style.RESET_ALL
else:
print Fore.BLACK, Back.WHITE, "IMPHASH UNKNOWN", Style.RESET_ALL
if "string" in types:
if "strings" in active_lookpups:
if input_value in good_strings_db:
print Fore.BLACK, Back.GREEN, "STRING KNOWN GOOD IN %d FILES" \
% good_strings_db[input_value], Style.RESET_ALL
else:
print Fore.BLACK, Back.WHITE, "STRING UNKNOWN", Style.RESET_ALL
if "exports" in active_lookpups:
if input_value in good_exports_db:
print Fore.BLACK, Back.GREEN, "EXPORT KNOWN GOOD IN %d FILES" \
% good_exports_db[input_value], Style.RESET_ALL
else:
print Fore.BLACK, Back.WHITE, "EXPORT UNKNOWN", Style.RESET_ALL
Loading