Skip to content

Commit c36287a

Browse files
Merge pull request #11 from MislavReversingLabs/main
Add tiscale to directory_scanning.ipynb
2 parents b396985 + dfe523b commit c36287a

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

Scenarios and Workflows/directory_scanning.ipynb

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,69 @@
155155
"collapsed": false
156156
},
157157
"id": "6b6774a15517020b"
158+
},
159+
{
160+
"cell_type": "markdown",
161+
"source": [
162+
"### 3. Scanning the files with TitaniumScale\n",
163+
"To collect files from a local directory and send them for analysis on TitaniumScale, see the following code example."
164+
],
165+
"metadata": {
166+
"collapsed": false
167+
},
168+
"id": "75a945aa9a600013"
169+
},
170+
{
171+
"cell_type": "code",
172+
"execution_count": null,
173+
"outputs": [],
174+
"source": [
175+
"import json\n",
176+
"import os\n",
177+
"from ReversingLabs.SDK.tiscale import TitaniumScale\n",
178+
"\n",
179+
"# Linux and Unix systems - Edit before use\n",
180+
"FOLDER_PATH_LINUX = \"/full/path/to/folder\"\n",
181+
"\n",
182+
"# Windows systems - Edit before use\n",
183+
"FOLDER_PATH_WINDOWS = \"C:\\\\full\\\\path\\\\to\\\\folder\"\n",
184+
"\n",
185+
"# Change this so the FOLDER_PATH variable fits your local system\n",
186+
"FOLDER_PATH = FOLDER_PATH_LINUX\n",
187+
"\n",
188+
"CREDENTIALS = json.load(open(\"credentials.json\"))\n",
189+
"HOST = CREDENTIALS.get(\"tiscale\").get(\"tiscale_url\")\n",
190+
"TOKEN = CREDENTIALS.get(\"tiscale\").get(\"token\")\n",
191+
"\n",
192+
"# Set the verify parameter to False if your A1000 instance doesn't have a valid CA certificate\n",
193+
"tiscale = TitaniumScale(\n",
194+
" host=HOST,\n",
195+
" token=TOKEN,\n",
196+
" verify=True\n",
197+
")\n",
198+
"\n",
199+
"# Files that should not be analyzed can be added to this list\n",
200+
"skip_files = [\"file_name_1\", \"file_name_2\"]\n",
201+
"\n",
202+
"for file_name in os.listdir(FOLDER_PATH):\n",
203+
" if file_name in skip_files:\n",
204+
" continue\n",
205+
" \n",
206+
" file_path = os.path.join(FOLDER_PATH, file_name)\n",
207+
" \n",
208+
" try:\n",
209+
" tiscale.upload_sample_from_path(file_path=file_path)\n",
210+
" \n",
211+
" except Exception as e:\n",
212+
" if hasattr(e, \"response_object\"):\n",
213+
" raise Exception(e.response_object.content)\n",
214+
" \n",
215+
" raise "
216+
],
217+
"metadata": {
218+
"collapsed": false
219+
},
220+
"id": "7b6f4ed40dcfbd26"
158221
}
159222
],
160223
"metadata": {

0 commit comments

Comments
 (0)