Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
c488171
Update label_request.yml
jshcodes Apr 2, 2021
1d13967
Sample code: Sample Uploads API
jshcodes Apr 2, 2021
bcb75a4
Code sample: Sample Uploads API
jshcodes Apr 2, 2021
78efe40
Sample config.json file
jshcodes Apr 2, 2021
c74cc9c
Documentation updates
jshcodes Apr 2, 2021
6a35d1f
Documentation updates
jshcodes Apr 2, 2021
9292c75
Documentation updates
jshcodes Apr 2, 2021
35eab6d
Documentation updates
jshcodes Apr 2, 2021
b3a2ac8
Documentation updates
jshcodes Apr 2, 2021
f4d5497
Documentation updates
jshcodes Apr 2, 2021
d0dd5e7
Documentation updates
jshcodes Apr 2, 2021
19ac67c
Documentation updates
jshcodes Apr 2, 2021
086e476
Documentation updates
jshcodes Apr 2, 2021
2af4478
Documentation updates
jshcodes Apr 2, 2021
f750d7b
Uploading simple example of containing and uncontaining a host via API
Apr 2, 2021
bbd9017
Documentation updates
jshcodes Apr 2, 2021
72b237e
Documentation updates
jshcodes Apr 2, 2021
5d44b68
Documentation updates
jshcodes Apr 2, 2021
aaa7412
Update labeler.yml
jshcodes Apr 3, 2021
d9b8f02
Update labeler.yml
jshcodes Apr 3, 2021
660ffa0
Update wordlist.txt
jshcodes Apr 3, 2021
ea336d2
Linting
jshcodes Apr 3, 2021
6149b51
Update linting.yml
jshcodes Apr 3, 2021
301dc98
Sample Uploads sample adjustments
jshcodes Apr 3, 2021
e594b27
Merge branch 'ver_0.4.4' of https://github.com/CrowdStrike/falconpy i…
jshcodes Apr 3, 2021
cb1f683
Added samples to bandit analysis
jshcodes Apr 3, 2021
87d206f
Update bandit.yml
jshcodes Apr 3, 2021
668d35b
Merge branch 'ver_0.4.4' of https://github.com/CrowdStrike/falconpy i…
jshcodes Apr 3, 2021
51d8d03
Documentation updates
jshcodes Apr 3, 2021
ed4e3f0
Documentation updates
jshcodes Apr 3, 2021
b13be05
Documentation updates
jshcodes Apr 3, 2021
7778d56
Falcon Discover example
jshcodes Apr 4, 2021
c4dbb01
Update bandit.yml
jshcodes Apr 4, 2021
7019038
Adjustments
jshcodes Apr 4, 2021
fe10c3d
Update test_uber_api_complete.py
jshcodes Apr 4, 2021
c5e5574
Update test_uber_api_complete.py
jshcodes Apr 4, 2021
6069722
Update labeler.yml
jshcodes Apr 4, 2021
7cb1d16
Update test_uber_api_complete.py
jshcodes Apr 4, 2021
f42ada1
Merge remote-tracking branch 'upstream/main' into ver_0.4.4
jshcodes Apr 4, 2021
6485486
Comment update
jshcodes Apr 4, 2021
4a3ccb0
Update bandit.yml
jshcodes Apr 4, 2021
153b3b0
Update linting.yml
jshcodes Apr 4, 2021
791a9b2
Update unit_testing.yml
jshcodes Apr 4, 2021
7ffdebc
Update dev-deploy.yml
jshcodes Apr 4, 2021
6604fe2
Issue #114 - action_name parameter fix
jshcodes Apr 4, 2021
8bac7f8
Merge branch 'ver_0.4.4' of https://github.com/CrowdStrike/falconpy i…
jshcodes Apr 4, 2021
40c8f31
Updated unit tests for issue #114
jshcodes Apr 4, 2021
433b393
Feature/sensordownloads (#113)
CalebSchwartz Apr 4, 2021
b7fab5e
Updated unit test to complete coverage
jshcodes Apr 4, 2021
9639009
Merge remote-tracking branch 'upstream/main' into ver_0.4.4
jshcodes Apr 5, 2021
e3849d0
Documentation updates
jshcodes Apr 5, 2021
5d6f3b6
Parameter handling fix
jshcodes Apr 5, 2021
5e3033a
Updated sample to reflect fix for issue #114
jshcodes Apr 5, 2021
99c79f6
Labelling updates to cover unit testing
jshcodes Apr 5, 2021
d56c23f
Bump version 0.4.3 -> 0.4.4
jshcodes Apr 5, 2021
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
Prev Previous commit
Next Next commit
Sample code: Sample Uploads API
  • Loading branch information
jshcodes committed Apr 2, 2021
commit 1d13967e7e1798ec0c264fa601d685a0c6bbbf26
1 change: 1 addition & 0 deletions samples/sample_uploads/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# FalconPy usage examples
97 changes: 97 additions & 0 deletions samples/sample_uploads/sample_uploads.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# ____ _ _ _ _ _
# / ___| __ _ _ __ ___ _ __ | | ___ | | | |_ __ | | ___ __ _ __| |___
# \___ \ / _` | '_ ` _ \| '_ \| |/ _ \ | | | | '_ \| |/ _ \ / _` |/ _` / __|
# ___) | (_| | | | | | | |_) | | __/ | |_| | |_) | | (_) | (_| | (_| \__ \
# |____/ \__,_|_| |_| |_| .__/|_|\___| \___/| .__/|_|\___/ \__,_|\__,_|___/
# |_| |_|

# _ ____ ___ _____ _
# / \ | _ \_ _| | ____|_ ____ _ _ __ ___ _ __ | | ___ ___
# / _ \ | |_) | | | _| \ \/ / _` | '_ ` _ \| '_ \| |/ _ \/ __|
# / ___ \| __/| | | |___ > < (_| | | | | | | |_) | | __/\__ \
# /_/ \_\_| |___| |_____/_/\_\__,_|_| |_| |_| .__/|_|\___||___/
# |_|
#
# These examples show how to interact with the Sample Uploads API using
# both the Uber class, and the regular Service class.
#
import json

# _ _ _ ____ _
# | | | | |__ ___ _ __ / ___| | __ _ ___ ___
# | | | | '_ \ / _ \ '__| | | | |/ _` / __/ __|
# | |_| | |_) | __/ | | |___| | (_| \__ \__ \
# \___/|_.__/ \___|_| \____|_|\__,_|___/___/
#
# This example shows how to interact with the
# Sample Uploads API using the Uber class.

from falconpy import api_complete as FalconSDK

# Grab our config parameters
with open('config.json', 'r') as file_config:
config = json.loads(file_config.read())

# Create an instance of the Uber class
falcon = FalconSDK.APIHarness(creds={
"client_id": config["falcon_client_id"],
"client_secret": config["falcon_client_secret"]
}
)

# Define our file
FILENAME = "testfile.jpg"
# Open the file for binary read, this will be our payload
PAYLOAD = open(FILENAME, 'rb').read()
# Upload the file using the Sample Uploads API, name this file "newfile.jpg" in the API
response = falcon.command('UploadSampleV3', file_name="newfile.jpg", data=PAYLOAD, content_type="application/octet-stream")
# Grab the SHA256 unique identifier for the file we just uploaded
sha = response["body"]["resources"][0]["sha256"]
# Download a copy of this file, use the SHA256 ID to retrieve it
response = falcon.command("GetSampleV3", ids=sha)
# Save the result to a new file
open('uberclass.jpg', 'wb').write(response)
# Delete the file from the API
response = falcon.command("DeleteSampleV3", ids=sha)
# Print the results of our delete command
print(json.dumps(response, indent=4))


# ____ _ ____ _
# / ___| ___ _ ____ _(_) ___ ___ / ___| | __ _ ___ ___
# \___ \ / _ \ '__\ \ / / |/ __/ _ \ | | | |/ _` / __/ __|
# ___) | __/ | \ V /| | (_| __/ | |___| | (_| \__ \__ \
# |____/ \___|_| \_/ |_|\___\___| \____|_|\__,_|___/___/
#
# This example shows how to interact with the
# Sample Uploads API using the Uber class.

from falconpy import sample_uploads as FalconUploads

# #Grab our config parameters
with open('config.json', 'r') as file_config:
config = json.loads(file_config.read())

falcon = FalconUploads.Sample_Uploads(creds={
"client_id": config["falcon_client_id"],
"client_secret": config["falcon_client_secret"]
}
)

# Define our file
FILENAME = "testfile.jpg"
# Open the file for binary read, this will be our payload
PAYLOAD = open(FILENAME, 'rb').read()
# Upload the file using the Sample Uploads API, name this file "newfile.jpg" in the API
# Since we are using the Service Class, we do not need to specify the content type
response = falcon.UploadSampleV3(file_name="newfile.jpg", file_data=PAYLOAD)
# Grab the SHA256 unique identifier for the file we just uploaded
sha = response["body"]["resources"][0]["sha256"]
# Download a copy of this file, use the SHA256 ID to retrieve it
response = falcon.GetSampleV3(ids=sha)
# Save the result to a new file
open('serviceclass.jpg', 'wb').write(response)
# Delete the file from the API
response = falcon.DeleteSampleV3(ids=sha)
# Print the results of our delete command
print(json.dumps(response, indent=4))