Skip to content

Commit 8afe4e9

Browse files
committed
Using improved logging interface. (self.log vs self.stoq.log)
1 parent 450d1f3 commit 8afe4e9

File tree

123 files changed

+220
-269
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

123 files changed

+220
-269
lines changed

carver/ole/ole/ole.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,10 @@ def carve(self, payload, **kwargs):
7575
'size': len(stream_buffer)}
7676
results.append((meta, stream_buffer))
7777

78-
self.stoq.log.info("Carved OLE stream {}[{}] ({} bytes)".format(meta['name'],
79-
meta['stream'],
80-
meta['size']))
78+
self.log.info("Carved OLE stream {}[{}] ({} bytes)".format(meta['name'],
79+
meta['stream'],
80+
meta['size']))
8181
except:
8282
pass
8383

8484
return results
85-

carver/ole/ole/ole.stoq

+1-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ Module = ole
1818

1919
[Documentation]
2020
Author = Marcus LaFerrera
21-
Version = 0.9.1
21+
Version = 0.10
2222
Website = https://github.com/PUNCH-Cyber/stoq-plugins-public
2323
Description = Carve OLE streams within Microsoft Office Documents
24-

carver/ole/setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setup(
44
name="ole",
5-
version="0.9",
5+
version="0.10",
66
author="Marcus LaFerrera (@mlaferrera)",
77
url="https://github.com/PUNCH-Cyber/stoq-plugins-public",
88
license="Apache License 2.0",

carver/olepackagestream/olepackagestream/olepackagestream.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def carve(self, payload, **kwargs):
5656
payload = BytesIO(payload)
5757
return self.parse_stream(payload)
5858
except:
59-
return None
59+
return None
6060

6161
def split_null(self, payload):
6262
pos = payload.tell()
@@ -104,9 +104,7 @@ def parse_stream(self, payload):
104104

105105
meta['OrgFileW'] = hexlify(payload.read(meta['OrgFileWLength'] * 2)).decode()
106106

107-
self.stoq.log.info("Carved OLE Package Stream {} ({} bytes)".format(meta['DefaultExtractPath'],
108-
meta['size']))
109-
110-
return [(meta, stream_buffer)]
111-
107+
self.log.info("Carved OLE Package Stream {} ({} bytes)".format(meta['DefaultExtractPath'],
108+
meta['size']))
112109

110+
return [(meta, stream_buffer)]

carver/olepackagestream/olepackagestream/olepackagestream.stoq

+1-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ Module = olepackagestream
1818

1919
[Documentation]
2020
Author = Marcus LaFerrera
21-
Version = 0.2
21+
Version = 0.3
2222
Website = https://github.com/PUNCH-Cyber/stoq-plugins-public
2323
Description = Carve OLE Package Streams
24-

carver/olepackagestream/setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setup(
44
name="olepackagestream",
5-
version="0.2",
5+
version="0.3",
66
author="Marcus LaFerrera (@mlaferrera)",
77
url="https://github.com/PUNCH-Cyber/stoq-plugins-public",
88
license="Apache License 2.0",

carver/pe/pe/pe.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ def carve(self, payload, **kwargs):
7878
meta = {'offset': start, 'size': len(binary)}
7979
results.append((meta, pe.trim()))
8080

81-
self.stoq.log.info("Carved executable at offset {} ({} bytes)".format(meta['offset'],
82-
meta['size']))
81+
self.log.info("Carved executable at offset {} ({} bytes)".format(meta['offset'],
82+
meta['size']))
8383

8484
# Start all over
8585
payload.seek(0)

carver/pe/pe/pe.stoq

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Module = pe
1818

1919
[Documentation]
2020
Author = Jeff Ito, Marcus LaFerrera
21-
Version = 0.9
21+
Version = 0.10
2222
Website = https://github.com/PUNCH-Cyber/stoq-plugins-public
2323
Description = Carve portable executable files from a data stream
2424

carver/pe/setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setup(
44
name="pe",
5-
version="0.9",
5+
version="0.10",
66
author="Jeff Ito, Marcus LaFerrera (@mlaferrera)",
77
url="https://github.com/PUNCH-Cyber/stoq-plugins-public",
88
license="Apache License 2.0",

carver/rtf/rtf/rtf.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ def carve(self, payload, **kwargs):
9595
meta = {"offset": start, "size": content_size}
9696
results.append((meta, content))
9797

98-
self.stoq.log.info("Carved binary stream in RTF at offset {} ({} bytes)".format(start, content_size))
98+
self.log.info("Carved binary stream in RTF at offset {} ({} bytes)".format(start, content_size))
9999

100100
return results
101-

carver/rtf/rtf/rtf.stoq

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Module = rtf
1818

1919
[Documentation]
2020
Author = Marcus LaFerrera
21-
Version = 0.9
21+
Version = 0.10
2222
Website = https://github.com/PUNCH-Cyber/stoq-plugins-public
2323
Description = Carve hex/binary streams from RTF payloads
2424

carver/rtf/setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setup(
44
name="rtf",
5-
version="0.9",
5+
version="0.10",
66
author="Marcus LaFerrera (@mlaferrera)",
77
url="https://github.com/PUNCH-Cyber/stoq-plugins-public",
88
license="Apache License 2.0",

carver/swf/setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setup(
44
name="swf",
5-
version="0.9.1",
5+
version="0.10",
66
author="Marcus LaFerrera (@mlaferrera)",
77
url="https://github.com/PUNCH-Cyber/stoq-plugins-public",
88
license="Apache License 2.0",

carver/swf/swf/swf.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def carve(self, payload, **kwargs):
7373
return results
7474

7575
def decompress(self, payload, offset=0):
76-
try:
76+
try:
7777
##
7878
# Header as obtained from SWF File Specification:
7979
# Field Type Comment
@@ -98,13 +98,13 @@ def decompress(self, payload, offset=0):
9898
payload.seek(offset)
9999

100100
# Grab the first three bytes, should be FWS, CWS or ZWS
101-
magic = payload.read(3).decode()
101+
magic = payload.read(3).decode()
102102

103103
# Grab the SWF version - 1 byte
104104
swf_version = struct.unpack('<b', payload.read(1))[0]
105105

106106
# Grab next 4 bytes so we can unpack to calculate the uncompressed
107-
# size of the payload.
107+
# size of the payload.
108108
decompressed_size = struct.unpack("<i", payload.read(4))[0] - 8
109109

110110
# Let's go back to the offset byte, jumping beyond the SWF header
@@ -141,16 +141,15 @@ def decompress(self, payload, offset=0):
141141
'size': decompressed_size + 8
142142
}
143143

144-
self.stoq.log.info("Carved SWF at offset {} ({} bytes)".format(meta['offset'],
144+
self.log.info("Carved SWF at offset {} ({} bytes)".format(meta['offset'],
145145
meta['size']))
146146
return (meta, swf)
147147

148148
except:
149-
self.stoq.log.warn("Unable to decompress SWF payload at offset {}".format(offset))
149+
self.log.warn("Unable to decompress SWF payload at offset {}".format(offset))
150150
return None
151151

152152

153153
class InvalidSWFSize(Exception):
154154
""" Invalid size of carved SWF content """
155155
pass
156-

carver/swf/swf/swf.stoq

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Module = swf
1818

1919
[Documentation]
2020
Author = Marcus LaFerrera
21-
Version = 0.9.1
21+
Version = 0.10
2222
Website = https://github.com/PUNCH-Cyber/stoq-plugins-public
2323
Description = Carve and decompress SWF payloads
2424

carver/xdp/setup.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22

33
setup(
44
name="xdp",
5-
version="0.9",
5+
version="0.10",
66
author="Marcus LaFerrera (@mlaferrera)",
77
url="https://github.com/PUNCH-Cyber/stoq-plugins-public",
88
license="Apache License 2.0",
99
description="Carve and decode streams from XDP documents",
1010
packages=find_packages(),
1111
include_package_data=True,
1212
)
13-

carver/xdp/xdp/xdp.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def activate(self, stoq):
4141
try:
4242
self.base64 = self.stoq.load_plugin("b64", "decoder")
4343
except:
44-
self.stoq.log.error("Unable to load decoder:b64 plugin.")
44+
self.log.error("Unable to load decoder:b64 plugin.")
4545
pass
4646

4747
def carve(self, payload, **kwargs):
@@ -96,9 +96,8 @@ def carve(self, payload, **kwargs):
9696

9797
# Gather the metadata and content
9898
meta = {"size": len(content), "element_name": name}
99-
self.stoq.log.info("Carved XDP {} ({} bytes)".format(meta['element_name'],
100-
meta['size']))
99+
self.log.info("Carved XDP {} ({} bytes)".format(meta['element_name'],
100+
meta['size']))
101101
results.append((meta, content))
102102

103103
return results
104-

carver/xdp/xdp/xdp.stoq

+1-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ Module = xdp
1818

1919
[Documentation]
2020
Author = Marcus LaFerrera
21-
Version = 0.9
21+
Version = 0.10
2222
Website = https://github.com/PUNCH-Cyber/stoq-plugins-public
2323
Description = Carve and decode streams from XDP documents
24-

connector/elasticsearch/elasticsearch/elasticsearch.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ def _commit(self):
7979
self.buffer.pop()
8080
except TransportError:
8181
tb = traceback.format_exc()
82-
self.stoq.log.error("Error committing to Elasticsearch: {}".format(tb))
83-
self.stoq.log.error("Failed commits: {}".format(str(self.buffer)))
82+
self.log.error("Error committing to Elasticsearch: {}".format(tb))
83+
self.log.error("Failed commits: {}".format(str(self.buffer)))
8484
finally:
8585
self.buffer_lock.release()
8686

connector/elasticsearch/elasticsearch/elasticsearch.stoq

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Module = elasticsearch
1818

1919
[Documentation]
2020
Author = Marcus LaFerrera
21-
Version = 0.4
21+
Version = 0.5
2222
Website = https://github.com/PUNCH-Cyber/stoq-plugins-public
2323
Description = Saves content to an ElasticSearch index
2424

@@ -51,4 +51,4 @@ bulk = False
5151

5252
bulk_interval = 10
5353

54-
bulk_size = 500
54+
bulk_size = 500

connector/elasticsearch/setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setup(
44
name="elasticsearch",
5-
version="0.4",
5+
version="0.5",
66
author="Marcus LaFerrera (@mlaferrera) Aaron Gee-Clough (@gclef_)",
77
url="https://github.com/PUNCH-Cyber/stoq-plugins-public",
88
license="Apache License 2.0",

connector/emailer/emailer/emailer.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def save(self, payload, archive=False, **kwargs):
6060
recipients = self.recipients_list
6161

6262
if not recipients:
63-
self.stoq.log.error("No recipient defined!")
63+
self.log.error("No recipient defined!")
6464
return None
6565

6666
msg = MIMEMultipart('alternative')

connector/emailer/emailer/emailer.stoq

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Module = emailer
1818

1919
[Documentation]
2020
Author = Marcus LaFerrera
21-
Version = 0.3
21+
Version = 0.4
2222
Website = https://github.com/PUNCH-Cyber/stoq-plugins-public
2323
Description = Send results to recipients via e-mail
2424

connector/emailer/setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setup(
44
name="emailer",
5-
version="0.3",
5+
version="0.4",
66
author="Marcus LaFerrera (@mlaferrera)",
77
url="https://github.com/PUNCH-Cyber/stoq-plugins-public",
88
license="Apache License 2.0",

connector/gcs/gcs/gcs.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,9 @@ def save(self, payload, archive=False, **kwargs):
109109
req = self.conn.objects().insert(bucket=bucket, body=body,
110110
media_body=media_body)
111111
resp = req.execute()
112-
self.stoq.log.debug(resp)
112+
self.log.debug(resp)
113113
except Exception as err:
114-
self.stoq.log.error("Unable to save file to GCS: {}".format(str(err)))
114+
self.log.error("Unable to save file to GCS: {}".format(str(err)))
115115
return None
116116

117117
return filename

connector/gcs/gcs/gcs.stoq

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Module = gcs
1818

1919
[Documentation]
2020
Author = Marcus LaFerrera
21-
Version = 0.2
21+
Version = 0.3
2222
Website = https://github.com/PUNCH-Cyber/stoq-plugins-public
2323
Description = Sends and retrieves content from Google Cloud Storage buckets
2424

connector/gcs/setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setup(
44
name="gcs",
5-
version="0.2",
5+
version="0.3",
66
author="Marcus LaFerrera (@mlaferrera)",
77
url="https://github.com/PUNCH-Cyber/stoq-plugins-public",
88
license="Apache License 2.0",

connector/mongodb/mongodb/mongodb.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
from pymongo.errors import DuplicateKeyError
2626
from gridfs.errors import FileExists
2727

28-
from stoq.scan import get_sha1
2928
from stoq.plugins import StoqConnectorPlugin
3029

3130

@@ -70,7 +69,7 @@ def get_file(self, **kwargs):
7069

7170
# So gridfs' documentation states we can use find_one, but
7271
# it doesn't exist. So instead, we are going to use find,
73-
# then just use the first item in the index, since we
72+
# then just use the first item in the index, since we
7473
# should always only return a single result anyway.
7574
results = self.collection.find({key: kwargs[key]})
7675

@@ -79,8 +78,7 @@ def get_file(self, **kwargs):
7978
with self.collection.get(results[0]._id) as requested_file:
8079
return requested_file.read()
8180
except Exception as e:
82-
self.stoq.log.error("Unable to retrieve file "
83-
"{0} :: {1}".format(kwargs, str(e)))
81+
self.log.error("Unable to retrieve file {} :: {}".format(kwargs, str(e)))
8482
return None
8583

8684
# No results, carry on.
@@ -104,7 +102,7 @@ def save(self, payload, archive=False, **kwargs):
104102

105103
self.archive = archive
106104

107-
# Define the index name, if available.
105+
# Define the index name, if available.
108106
index = kwargs.get('index', None)
109107

110108
if not hasattr(self, 'collection'):
@@ -187,4 +185,3 @@ def disconnect(self):
187185

188186
self.mongo_client.disconnect()
189187
super().disconnect()
190-

connector/mongodb/mongodb/mongodb.stoq

+1-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Module = mongodb
1818

1919
[Documentation]
2020
Author = Marcus LaFerrera
21-
Version = 0.9.2
21+
Version = 0.10
2222
Website = https://github.com/PUNCH-Cyber/stoq-plugins-public
2323
Description = Sends and retrieves content from MongoDB
2424

@@ -35,4 +35,3 @@ Description = Sends and retrieves content from MongoDB
3535
# conn = mongodb://localhost:27017/
3636

3737
conn = mongodb://localhost:27017/
38-

connector/mongodb/setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setup(
44
name="mongodb",
5-
version="0.9.2",
5+
version="0.10",
66
author="Marcus LaFerrera (@mlaferrera)",
77
url="https://github.com/PUNCH-Cyber/stoq-plugins-public",
88
license="Apache License 2.0",

0 commit comments

Comments
 (0)