Skip to content

Commit

Permalink
20220423a
Browse files Browse the repository at this point in the history
  • Loading branch information
DidierStevens committed Apr 23, 2022
1 parent 19f10af commit 908ce25
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
23 changes: 17 additions & 6 deletions re-search.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

__description__ = "Program to use Python's re.findall on files"
__author__ = 'Didier Stevens'
__version__ = '0.0.18'
__date__ = '2021/09/21'
__version__ = '0.0.19'
__date__ = '2022/04/18'

"""
Expand Down Expand Up @@ -50,6 +50,7 @@
2021/05/05: added public ips filter
2021/09/19: 0.0.18 map Python3 fix
2021/09/21: added sys.stdin.reconfigure
2022/04/18: 0.0.19 Python3 fix stdin binary
Todo:
add hostname to header
Expand Down Expand Up @@ -481,10 +482,15 @@ def RESearchSingle(regex, filenames, oOutput, options):
for filename in filenames:
if filename == '':
if options.fullread or options.extractstrings or options.grepall:
IfWIN32SetBinary(sys.stdin)
if sys.version_info[0] == 2:
IfWIN32SetBinary(sys.stdin)
else:
fIn = sys.stdin.buffer
elif MinimalPythonVersion(3, 7):
sys.stdin.reconfigure(encoding=ParseOptionEncoding(options.encoding)[0], errors=ParseOptionEncoding(options.encoding)[1])
fIn = sys.stdin
fIn = sys.stdin
else:
fIn = sys.stdin
fType = 1
elif os.path.splitext(filename)[1].lower() == '.gz':
fIn = gzip.GzipFile(filename, 'rb')
Expand Down Expand Up @@ -542,10 +548,15 @@ def RESearchCSV(csvFilename, filenames, oOutput, options):
for filename in filenames:
if filename == '':
if options.fullread or options.extractstrings or options.grepall:
IfWIN32SetBinary(sys.stdin)
if sys.version_info[0] == 2:
IfWIN32SetBinary(sys.stdin)
else:
fIn = sys.stdin.buffer
elif MinimalPythonVersion(3, 7):
sys.stdin.reconfigure(encoding=ParseOptionEncoding(options.encoding)[0], errors=ParseOptionEncoding(options.encoding)[1])
fIn = sys.stdin
fIn = sys.stdin
else:
fIn = sys.stdin
fType = 1
elif os.path.splitext(filename)[1].lower() == '.gz':
fIn = gzip.GzipFile(filename, 'rb')
Expand Down
10 changes: 6 additions & 4 deletions reextra.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

__description__ = 're extra'
__author__ = 'Didier Stevens'
__version__ = '0.0.5'
__date__ = '2020/12/28'
__version__ = '0.0.6'
__date__ = '2021/02/06'

"""
Expand All @@ -14,6 +14,7 @@
2018/07/15: 0.0.4 made decode_base58 more robust
2020/12/08: 0.0.5 added DomainTLDValidate
2020/12/28: Python 3
2021/02/06: 0.0.6 Fix execfile for Python 3; changed "extra" logic with groups
Todo:
"""
Expand Down Expand Up @@ -1575,7 +1576,7 @@ def CountUniques(data):
return len(dCount)

def Script(filename):
execfile(filename, globals(), globals())
exec(open(filename, 'r').read(), globals(), globals())

def Execute(pythoncode):
exec(pythoncode, globals())
Expand Down Expand Up @@ -2529,7 +2530,8 @@ def Findall(self, line):
if self.Test(result):
results.append(result)
if isinstance(result, tuple):
results.append(result)
if self.Test(result[0]):
results.append(result)
return results

def Search(self, line, flags=0):
Expand Down

0 comments on commit 908ce25

Please sign in to comment.